Search in sources :

Example 1 with CustomBuilderMenuItem

use of com.thecoderscorner.menu.domain.CustomBuilderMenuItem in project tcMenu by davetcc.

the class UIRemoteAndFloatMenuItemTest method testAuthenticationItem.

@Test
void testAuthenticationItem(FxRobot robot) throws InterruptedException {
    MenuItem authItem = new CustomBuilderMenuItemBuilder().withId(1001).withName("Auth test").withEepromAddr(-1).withMenuType(CustomBuilderMenuItem.CustomMenuType.AUTHENTICATION).withFunctionName("onAuth").menuItem();
    menuTree.addMenuItem(MenuTree.ROOT, authItem);
    VariableNameGenerator vng = new VariableNameGenerator(menuTree, false);
    var uiAuthPanel = editorUI.createPanelForMenuItem(authItem, menuTree, vng, mockedConsumer);
    // open the sub menu item editor panel
    createMainPanel(uiAuthPanel);
    // firstly check that all the fields are populated properly
    performAllCommonChecks(authItem, false);
    TestUtils.writeIntoField(robot, "#nameField", "new name", 10);
    ArgumentCaptor<MenuItem> captor = ArgumentCaptor.forClass(MenuItem.class);
    verify(mockedConsumer, atLeastOnce()).accept(any(), captor.capture());
    var item = (CustomBuilderMenuItem) captor.getValue();
    assertEquals("new name", item.getName());
    assertEquals(CustomBuilderMenuItem.CustomMenuType.AUTHENTICATION, item.getMenuType());
    FxAssert.verifyThat("#onlineDocsHyperlink", LabeledMatchers.hasText("Online documentation for AuthenticationItem"));
}
Also used : CustomBuilderMenuItem(com.thecoderscorner.menu.domain.CustomBuilderMenuItem) FloatMenuItem(com.thecoderscorner.menu.domain.FloatMenuItem) CustomBuilderMenuItem(com.thecoderscorner.menu.domain.CustomBuilderMenuItem) UIMenuItem(com.thecoderscorner.menu.editorui.uimodel.UIMenuItem) MenuItem(com.thecoderscorner.menu.domain.MenuItem) VariableNameGenerator(com.thecoderscorner.menu.editorui.generator.core.VariableNameGenerator) CustomBuilderMenuItemBuilder(com.thecoderscorner.menu.domain.CustomBuilderMenuItemBuilder) Test(org.junit.jupiter.api.Test)

Example 2 with CustomBuilderMenuItem

use of com.thecoderscorner.menu.domain.CustomBuilderMenuItem in project tcMenu by davetcc.

the class UIRemoteAndFloatMenuItemTest method testRemoteMenuItem.

@Test
void testRemoteMenuItem(FxRobot robot) throws InterruptedException {
    MenuItem remoteItem = new CustomBuilderMenuItemBuilder().withId(1001).withName("Remote Test").withEepromAddr(-1).withMenuType(CustomBuilderMenuItem.CustomMenuType.REMOTE_IOT_MONITOR).withFunctionName("onRemo").menuItem();
    menuTree.addMenuItem(MenuTree.ROOT, remoteItem);
    VariableNameGenerator vng = new VariableNameGenerator(menuTree, false);
    var uiRemotePanel = editorUI.createPanelForMenuItem(remoteItem, menuTree, vng, mockedConsumer);
    // open the sub menu item editor panel
    createMainPanel(uiRemotePanel);
    // firstly check that all the fields are populated properly
    performAllCommonChecks(remoteItem, false);
    TestUtils.writeIntoField(robot, "#nameField", "abc123", 11);
    ArgumentCaptor<MenuItem> captor = ArgumentCaptor.forClass(MenuItem.class);
    verify(mockedConsumer, atLeastOnce()).accept(any(), captor.capture());
    var item = (CustomBuilderMenuItem) captor.getValue();
    assertEquals("abc123", item.getName());
    assertEquals(CustomBuilderMenuItem.CustomMenuType.REMOTE_IOT_MONITOR, item.getMenuType());
    FxAssert.verifyThat("#onlineDocsHyperlink", LabeledMatchers.hasText("Online documentation for Remote/IoT Monitor"));
}
Also used : CustomBuilderMenuItem(com.thecoderscorner.menu.domain.CustomBuilderMenuItem) FloatMenuItem(com.thecoderscorner.menu.domain.FloatMenuItem) CustomBuilderMenuItem(com.thecoderscorner.menu.domain.CustomBuilderMenuItem) UIMenuItem(com.thecoderscorner.menu.editorui.uimodel.UIMenuItem) MenuItem(com.thecoderscorner.menu.domain.MenuItem) VariableNameGenerator(com.thecoderscorner.menu.editorui.generator.core.VariableNameGenerator) CustomBuilderMenuItemBuilder(com.thecoderscorner.menu.domain.CustomBuilderMenuItemBuilder) Test(org.junit.jupiter.api.Test)

Aggregations

CustomBuilderMenuItem (com.thecoderscorner.menu.domain.CustomBuilderMenuItem)2 CustomBuilderMenuItemBuilder (com.thecoderscorner.menu.domain.CustomBuilderMenuItemBuilder)2 FloatMenuItem (com.thecoderscorner.menu.domain.FloatMenuItem)2 MenuItem (com.thecoderscorner.menu.domain.MenuItem)2 VariableNameGenerator (com.thecoderscorner.menu.editorui.generator.core.VariableNameGenerator)2 UIMenuItem (com.thecoderscorner.menu.editorui.uimodel.UIMenuItem)2 Test (org.junit.jupiter.api.Test)2