summaryrefslogtreecommitdiffstats
path: root/uitest
diff options
context:
space:
mode:
authorJonni Madekivi <jonni@egarden.fi>2018-12-17 09:43:37 +0200
committerSun Zhe <31067185+ZheSun88@users.noreply.github.com>2018-12-17 09:43:37 +0200
commit5ad9dbf519d131e69f3b9c5a3fdf73d0e96011e0 (patch)
treefbae75c4561a8817bedc38e5c85e3e66320f1e76 /uitest
parentc9c960ee57c54d2a1d3b6572cc91b73cb561ac60 (diff)
downloadvaadin-framework-5ad9dbf519d131e69f3b9c5a3fdf73d0e96011e0.tar.gz
vaadin-framework-5ad9dbf519d131e69f3b9c5a3fdf73d0e96011e0.zip
Prevent IndexOutOfBoundException in VMenuBar.CustomMenuItem (#11285)
* Fixes #10814 * Add missing tests Fixes #11374
Diffstat (limited to 'uitest')
-rw-r--r--uitest/src/main/java/com/vaadin/tests/components/menubar/MenuBarSmallWidth.java37
-rw-r--r--uitest/src/test/java/com/vaadin/tests/components/menubar/MenuBarSmallWidthTest.java13
2 files changed, 50 insertions, 0 deletions
diff --git a/uitest/src/main/java/com/vaadin/tests/components/menubar/MenuBarSmallWidth.java b/uitest/src/main/java/com/vaadin/tests/components/menubar/MenuBarSmallWidth.java
new file mode 100644
index 0000000000..650cae0f62
--- /dev/null
+++ b/uitest/src/main/java/com/vaadin/tests/components/menubar/MenuBarSmallWidth.java
@@ -0,0 +1,37 @@
+package com.vaadin.tests.components.menubar;
+
+import com.vaadin.annotations.Widgetset;
+import com.vaadin.server.ThemeResource;
+import com.vaadin.server.VaadinRequest;
+import com.vaadin.tests.components.AbstractTestUI;
+import com.vaadin.ui.Label;
+import com.vaadin.ui.MenuBar;
+
+@Widgetset("com.vaadin.DefaultWidgetSet")
+public class MenuBarSmallWidth extends AbstractTestUI {
+ @Override
+ protected void setup(VaadinRequest request) {
+ MenuBar barmenu = new MenuBar();
+ barmenu.setWidth("50px");
+ addComponent(barmenu);
+ // A top-level menu item that opens a submenu
+ MenuBar.MenuItem drinks = barmenu.addItem("Beverages", null, null);
+
+ // Submenu item with a sub-submenu
+ MenuBar.MenuItem hots = drinks.addItem("Hot", null, null);
+ hots.addItem("Tea", new ThemeResource("icons/tea-16px.png"), null);
+ hots.addItem("Coffee", new ThemeResource("icons/coffee-16px.png"),
+ null);
+
+ // Another submenu item with a sub-submenu
+ MenuBar.MenuItem colds = drinks.addItem("Cold", null, null);
+ colds.addItem("Milk", null, null);
+ colds.addItem("Weissbier", null, null);
+
+ // Another top-level item
+ MenuBar.MenuItem snacks = barmenu.addItem("Snacks", null, null);
+ snacks.addItem("Weisswurst", null, null);
+ snacks.addItem("Bratwurst", null, null);
+ snacks.addItem("Currywurst", null, null);
+ }
+}
diff --git a/uitest/src/test/java/com/vaadin/tests/components/menubar/MenuBarSmallWidthTest.java b/uitest/src/test/java/com/vaadin/tests/components/menubar/MenuBarSmallWidthTest.java
new file mode 100644
index 0000000000..cf3fb294cc
--- /dev/null
+++ b/uitest/src/test/java/com/vaadin/tests/components/menubar/MenuBarSmallWidthTest.java
@@ -0,0 +1,13 @@
+package com.vaadin.tests.components.menubar;
+
+import com.vaadin.tests.tb3.MultiBrowserTest;
+import org.junit.Test;
+
+public class MenuBarSmallWidthTest extends MultiBrowserTest {
+
+ @Test
+ public void noIndexOutOfBoundsExceptionPresent() {
+ openTestURL("debug");
+ assertNoErrorNotifications();
+ }
+}