use of com.vaadin.flow.component.menubar.MenuBar in project flow-components by vaadin.
the class MenuBarTest method init.
@Before
public void init() {
menuBar = new MenuBar();
item1 = menuBar.addItem("foo");
item2 = menuBar.addItem(new Span("bar"));
}
use of com.vaadin.flow.component.menubar.MenuBar in project linkki by linkki-framework.
the class ApplicationHeaderTest method testAddThemeVariantToggles_MultipleItems.
@Test
void testAddThemeVariantToggles_MultipleItems() {
ApplicationHeader header = new ApplicationHeader(new TestApplicationInfo(), Sequence.empty());
header.init();
MenuBar rightComponent = (MenuBar) ((HorizontalLayout) header.getContent().getComponentAt(1)).getComponentAt(0);
MenuItem helpMenuItem = rightComponent.getItems().get(0);
header.addThemeVariantToggles(helpMenuItem, LINKKI_CARD, LINKKI_COMPACT);
assertThat(helpMenuItem.getSubMenu().getItems()).anyMatch(mi -> mi.getText().equals("Themes"));
assertThat(helpMenuItem.getSubMenu().getItems().get(1).getText()).isEqualTo(NlsText.getString("ApplicationHeader.Theme"));
assertThat(helpMenuItem.getSubMenu().getItems().get(1).getSubMenu().getItems().stream().map(MenuItem::getText)).contains("Card Theme", "Compact Theme");
}
use of com.vaadin.flow.component.menubar.MenuBar in project linkki by linkki-framework.
the class ApplicationHeaderTest method testRightMenu_HelpMenu.
@Test
void testRightMenu_HelpMenu() {
ApplicationHeader header = new ApplicationHeader(new TestApplicationInfo(), Sequence.empty());
header.init();
MenuBar rightComponent = (MenuBar) ((HorizontalLayout) header.getContent().getComponentAt(1)).getComponentAt(0);
assertThat(rightComponent.getItems()).hasSize(1);
MenuItem helpMenuItem = rightComponent.getItems().get(0);
assertThat(helpMenuItem.getId()).hasValue(ApplicationHeader.APPMENU_HELP_ID);
assertThat(helpMenuItem.getChildren().findFirst().get().getElement().getAttribute("icon")).isEqualTo(VaadinIcon.QUESTION_CIRCLE.create().getElement().getAttribute("icon"));
}
use of com.vaadin.flow.component.menubar.MenuBar in project linkki by linkki-framework.
the class ApplicationHeaderTest method testAddThemeVariantToggles_NoItems.
@Test
void testAddThemeVariantToggles_NoItems() {
ApplicationHeader header = new ApplicationHeader(new TestApplicationInfo(), Sequence.empty());
header.init();
MenuBar rightComponent = (MenuBar) ((HorizontalLayout) header.getContent().getComponentAt(1)).getComponentAt(0);
MenuItem helpMenuItem = rightComponent.getItems().get(0);
header.addThemeVariantToggles(helpMenuItem);
assertThat(helpMenuItem.getSubMenu().getItems().stream().map(MenuItem::getText)).doesNotContain("Themes", "Card Theme", "Compact Theme");
}
use of com.vaadin.flow.component.menubar.MenuBar in project linkki by linkki-framework.
the class ApplicationHeaderTest method testRightMenu_ApplicationInfoItem.
@Test
void testRightMenu_ApplicationInfoItem() {
ApplicationHeader header = new ApplicationHeader(new TestApplicationInfo(), Sequence.empty());
header.init();
MenuBar rightComponent = (MenuBar) ((HorizontalLayout) header.getContent().getComponentAt(1)).getComponentAt(0);
MenuItem helpMenuItem = rightComponent.getItems().get(0);
assertThat(helpMenuItem.getSubMenu().getItems()).hasSize(1);
MenuItem applicationInfoItem = helpMenuItem.getSubMenu().getItems().get(0);
assertThat(applicationInfoItem.getId()).hasValue(ApplicationHeader.APPMENU_INFO_ID);
}
Aggregations