use of com.vaadin.flow.component.contextmenu.MenuItem 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.contextmenu.MenuItem 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.contextmenu.MenuItem 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);
}
use of com.vaadin.flow.component.contextmenu.MenuItem in project linkki by linkki-framework.
the class ApplicationHeaderTest method testAddThemeVariantToggles_SingleItem.
@Test
void testAddThemeVariantToggles_SingleItem() {
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);
assertThat(helpMenuItem.getSubMenu().getItems()).anyMatch(mi -> mi.getText().equals("Card Theme"));
}
use of com.vaadin.flow.component.contextmenu.MenuItem in project linkki by linkki-framework.
the class ThemeVariantToggleMenuItemDefinitionTest method testCreateItem_ApplicationMenu.
@Test
void testCreateItem_ApplicationMenu() {
ApplicationMenu menu = new ApplicationMenu();
UI.getCurrent().getElement().getThemeList().add("variant");
new ThemeVariantToggleMenuItemDefinition("name", "id", "variant").createItem(menu);
assertThat(menu.getItems()).hasSize(1);
MenuItem createdItem = menu.getItems().get(0);
assertThat(createdItem.getText()).isEqualTo("name");
assertThat(createdItem.getId()).hasValue("id");
}
Aggregations