use of com.thecoderscorner.menu.domain.Rgb32MenuItemBuilder 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());
}
Aggregations