Search in sources :

Example 6 with MenuItem

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"));
}
Also used : MenuBar(com.vaadin.flow.component.menubar.MenuBar) MenuItem(com.vaadin.flow.component.contextmenu.MenuItem) Test(org.junit.jupiter.api.Test)

Example 7 with MenuItem

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");
}
Also used : MenuBar(com.vaadin.flow.component.menubar.MenuBar) MenuItem(com.vaadin.flow.component.contextmenu.MenuItem) Test(org.junit.jupiter.api.Test)

Example 8 with MenuItem

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);
}
Also used : MenuBar(com.vaadin.flow.component.menubar.MenuBar) MenuItem(com.vaadin.flow.component.contextmenu.MenuItem) Test(org.junit.jupiter.api.Test)

Example 9 with MenuItem

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"));
}
Also used : MenuBar(com.vaadin.flow.component.menubar.MenuBar) MenuItem(com.vaadin.flow.component.contextmenu.MenuItem) Test(org.junit.jupiter.api.Test)

Example 10 with MenuItem

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");
}
Also used : MenuItem(com.vaadin.flow.component.contextmenu.MenuItem) Test(org.junit.jupiter.api.Test)

Aggregations

MenuItem (com.vaadin.flow.component.contextmenu.MenuItem)27 MenuBar (com.vaadin.flow.component.menubar.MenuBar)9 Test (org.junit.jupiter.api.Test)8 ContextMenu (com.vaadin.flow.component.contextmenu.ContextMenu)6 Label (com.vaadin.flow.component.html.Label)6 Component (com.vaadin.flow.component.Component)5 SubMenu (com.vaadin.flow.component.contextmenu.SubMenu)5 Text (com.vaadin.flow.component.Text)2 Button (com.vaadin.flow.component.button.Button)2 Hr (com.vaadin.flow.component.html.Hr)2 Span (com.vaadin.flow.component.html.Span)2 Icon (com.vaadin.flow.component.icon.Icon)2 VaadinIcon (com.vaadin.flow.component.icon.VaadinIcon)2 Registration (com.vaadin.flow.shared.Registration)2 Test (org.junit.Test)2 AttachEvent (com.vaadin.flow.component.AttachEvent)1 ComponentEvent (com.vaadin.flow.component.ComponentEvent)1 ComponentEventListener (com.vaadin.flow.component.ComponentEventListener)1 DetachEvent (com.vaadin.flow.component.DetachEvent)1 UI (com.vaadin.flow.component.UI)1