aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--client/src/main/java/com/vaadin/client/ui/VMenuBar.java1
-rw-r--r--uitest/src/main/java/com/vaadin/tests/components/menubar/MenuItemStyleAdd.java31
-rw-r--r--uitest/src/test/java/com/vaadin/tests/components/menubar/MenuItemStyleAddTest.java38
3 files changed, 70 insertions, 0 deletions
diff --git a/client/src/main/java/com/vaadin/client/ui/VMenuBar.java b/client/src/main/java/com/vaadin/client/ui/VMenuBar.java
index 684527a380..77377acdbd 100644
--- a/client/src/main/java/com/vaadin/client/ui/VMenuBar.java
+++ b/client/src/main/java/com/vaadin/client/ui/VMenuBar.java
@@ -967,6 +967,7 @@ FocusHandler, SubPartAware, MouseOutHandler, MouseOverHandler {
if (styleName != null) {
addStyleDependentName(styleName);
+ addStyleName(styleName);
}
if (enabled) {
diff --git a/uitest/src/main/java/com/vaadin/tests/components/menubar/MenuItemStyleAdd.java b/uitest/src/main/java/com/vaadin/tests/components/menubar/MenuItemStyleAdd.java
new file mode 100644
index 0000000000..a0fe70c732
--- /dev/null
+++ b/uitest/src/main/java/com/vaadin/tests/components/menubar/MenuItemStyleAdd.java
@@ -0,0 +1,31 @@
+package com.vaadin.tests.components.menubar;
+
+import com.vaadin.annotations.Widgetset;
+import com.vaadin.server.VaadinRequest;
+import com.vaadin.tests.components.AbstractTestUI;
+import com.vaadin.ui.MenuBar;
+
+@Widgetset("com.vaadin.DefaultWidgetSet")
+public class MenuItemStyleAdd extends AbstractTestUI {
+
+ @Override
+ protected void setup(VaadinRequest request) {
+ MenuBar barmenu = new MenuBar();
+ MenuBar.MenuItem more = barmenu.addItem("More", null, null);
+ more.setStyleName("styleNameMore");
+ barmenu.setMoreMenuItem(more);
+
+ MenuBar.MenuItem drinks = barmenu.addItem("Drinks", null, null);
+ MenuBar.MenuItem hots = drinks.addItem("Hot", null, null);
+ hots.addItem("Tea", null);
+ hots.addItem("Coffee", null);
+ hots.setStyleName("styleTest");
+
+ MenuBar.MenuItem colds = drinks.addItem("Cold", null, null);
+ colds.addItem("Milk", null);
+ colds.addItem("Weissbier", null);
+
+ addComponent(barmenu);
+ }
+
+}
diff --git a/uitest/src/test/java/com/vaadin/tests/components/menubar/MenuItemStyleAddTest.java b/uitest/src/test/java/com/vaadin/tests/components/menubar/MenuItemStyleAddTest.java
new file mode 100644
index 0000000000..79e390fcff
--- /dev/null
+++ b/uitest/src/test/java/com/vaadin/tests/components/menubar/MenuItemStyleAddTest.java
@@ -0,0 +1,38 @@
+package com.vaadin.tests.components.menubar;
+
+import com.vaadin.testbench.By;
+import com.vaadin.testbench.elements.MenuBarElement;
+import com.vaadin.tests.tb3.MultiBrowserTest;
+import org.junit.Test;
+import org.openqa.selenium.WebElement;
+import static org.junit.Assert.assertEquals;
+
+import java.util.List;
+
+public class MenuItemStyleAddTest extends MultiBrowserTest {
+
+ @Test
+ public void testCustomStyleShouldStayAfterMenuSelect() {
+ openTestURL();
+
+ MenuBarElement menu = $(MenuBarElement.class).first();
+ List<WebElement> elements = menu
+ .findElements(By.className("v-menubar-menuitem"));
+ WebElement more = elements.get(0);
+ assertEquals(true,
+ more.getAttribute("class")
+ .replaceAll("v-menubar-menuitem-styleNameMore", "")
+ .contains("styleNameMore"));
+ assertEquals(2, elements.size());
+ menu.clickItem("Drinks");
+ WebElement popup = getDriver()
+ .findElement(By.className("v-menubar-popup"));
+ List<WebElement> popupElCon = popup
+ .findElements(By.className("styleTest"));
+ assertEquals(1, popupElCon.size());
+ assertEquals(true,
+ popupElCon.get(0).getAttribute("class")
+ .replaceAll("v-menubar-menuitem-styleTest", "")
+ .contains("styleTest"));
+ }
+} \ No newline at end of file