Search in sources :

Example 1 with Rgb32MenuItem

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

the class UIActionItemAndCoreTest method testRgb32MenuItem.

@Test
void testRgb32MenuItem(FxRobot robot) throws Exception {
    Rgb32MenuItem item = new Rgb32MenuItemBuilder().withName("New Item").withId(321).withEepromAddr(-1).withFunctionName("test").withAlpha(true).menuItem();
    menuTree.addMenuItem(MenuTree.ROOT, item);
    Set<Integer> uncommittedItems = new HashSet<>();
    uncommittedItems.add(item.getId());
    VariableNameGenerator vng = new VariableNameGenerator(menuTree, false, uncommittedItems);
    var uiRgb = editorUI.createPanelForMenuItem(item, menuTree, vng, mockedConsumer);
    // open the sub menu item editor panel
    createMainPanel(uiRgb);
    // firstly check that all the fields are populated properly
    performAllCommonChecks(item, false);
    tryToEnterBadValueIntoField(robot, "eepromField", "nameField", "40000", "EEPROM - Value must be between -1 and 32767");
    tryToEnterBadValueIntoField(robot, "eepromField", "nameField", "-2", "EEPROM - Value must be between -1 and 32767");
    robot.clickOn("#nameField");
    robot.eraseText(10);
    robot.write("My Test");
    verifyThat("#variableField", TextInputControlMatchers.hasText("MyTest"));
    robot.clickOn("#variableField");
    robot.eraseText(10);
    robot.write("OverrideVar");
    robot.clickOn("#nameField");
    robot.eraseText(10);
    robot.write("New Test");
    robot.clickOn("#variableField");
    verifyThat("#variableField", TextInputControlMatchers.hasText("OverrideVar"));
    robot.clickOn("#eepromNextBtn");
    verifyThat("#eepromField", TextInputControlMatchers.hasText("7"));
    ArgumentCaptor<MenuItem> captor = ArgumentCaptor.forClass(MenuItem.class);
    verify(mockedConsumer, atLeastOnce()).accept(any(), captor.capture());
    assertEquals(7, captor.getValue().getEepromAddress());
    assertEquals("OverrideVar", captor.getValue().getVariableName());
}
Also used : Rgb32MenuItemBuilder(com.thecoderscorner.menu.domain.Rgb32MenuItemBuilder) UIMenuItem(com.thecoderscorner.menu.editorui.uimodel.UIMenuItem) MenuItem(com.thecoderscorner.menu.domain.MenuItem) Rgb32MenuItem(com.thecoderscorner.menu.domain.Rgb32MenuItem) ActionMenuItem(com.thecoderscorner.menu.domain.ActionMenuItem) Rgb32MenuItem(com.thecoderscorner.menu.domain.Rgb32MenuItem) VariableNameGenerator(com.thecoderscorner.menu.editorui.generator.core.VariableNameGenerator) HashSet(java.util.HashSet) Test(org.junit.jupiter.api.Test)

Aggregations

ActionMenuItem (com.thecoderscorner.menu.domain.ActionMenuItem)1 MenuItem (com.thecoderscorner.menu.domain.MenuItem)1 Rgb32MenuItem (com.thecoderscorner.menu.domain.Rgb32MenuItem)1 Rgb32MenuItemBuilder (com.thecoderscorner.menu.domain.Rgb32MenuItemBuilder)1 VariableNameGenerator (com.thecoderscorner.menu.editorui.generator.core.VariableNameGenerator)1 UIMenuItem (com.thecoderscorner.menu.editorui.uimodel.UIMenuItem)1 HashSet (java.util.HashSet)1 Test (org.junit.jupiter.api.Test)1