Search in sources :

Example 6 with MenuBar

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"));
}
Also used : MenuBar(com.vaadin.flow.component.menubar.MenuBar) Span(com.vaadin.flow.component.html.Span) Before(org.junit.Before)

Example 7 with MenuBar

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");
}
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 MenuBar

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"));
}
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 MenuBar

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");
}
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 MenuBar

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

Aggregations

MenuBar (com.vaadin.flow.component.menubar.MenuBar)22 MenuItem (com.vaadin.flow.component.contextmenu.MenuItem)9 Test (org.junit.jupiter.api.Test)8 Button (com.vaadin.flow.component.button.Button)6 lombok.val (lombok.val)6 SubMenu (com.vaadin.flow.component.contextmenu.SubMenu)3 TextField (com.vaadin.flow.component.textfield.TextField)3 HorizontalLayout (com.vaadin.flow.component.orderedlayout.HorizontalLayout)2 ComponentEvent (com.vaadin.flow.component.ComponentEvent)1 ComponentEventListener (com.vaadin.flow.component.ComponentEventListener)1 Text (com.vaadin.flow.component.Text)1 Unit (com.vaadin.flow.component.Unit)1 Anchor (com.vaadin.flow.component.html.Anchor)1 Image (com.vaadin.flow.component.html.Image)1 Label (com.vaadin.flow.component.html.Label)1 Span (com.vaadin.flow.component.html.Span)1 Notification (com.vaadin.flow.component.notification.Notification)1 VerticalLayout (com.vaadin.flow.component.orderedlayout.VerticalLayout)1 RouterLink (com.vaadin.flow.router.RouterLink)1 VaadinService (com.vaadin.flow.server.VaadinService)1