use of com.thecoderscorner.menu.editorui.generator.core.VariableNameGenerator in project tcMenu by davetcc.
the class UIActionItemAndCoreTest method testEnteringBadValuesIntoBaseEditor.
@Test
void testEnteringBadValuesIntoBaseEditor(FxRobot robot) throws InterruptedException {
MenuItem subItem = menuTree.getSubMenuById(100).orElseThrow();
VariableNameGenerator vng = new VariableNameGenerator(menuTree, false);
var uiSubItem = editorUI.createPanelForMenuItem(subItem, menuTree, vng, mockedConsumer);
// open the sub menu item editor panel
createMainPanel(uiSubItem);
// firstly check that all the fields are populated properly
performAllCommonChecks(subItem, false);
tryToEnterBadValueIntoField(robot, "nameField", "variableField", "This#Is+Err", "Name - Text can only contain letters, numbers, spaces and '-_()*%'");
tryToEnterBadValueIntoField(robot, "nameField", "variableField", "", "Name - field must not be blank and less than 19 characters");
tryToEnterBadValueIntoField(robot, "functionNameTextField", "variableField", "name spaces", "Field must use only letters, digits, and '_'");
tryToEnterBadValueIntoField(robot, "nameField", "variableField", "This name is too long for menuitem", "Name - field must not be blank and less than 19 characters");
tryToEnterBadValueIntoField(robot, "functionNameTextField", "nameField", "19_Bad", "Field must use only letters, digits, and '_'");
ArgumentCaptor<MenuItem> captor = ArgumentCaptor.forClass(MenuItem.class);
verify(mockedConsumer, atLeastOnce()).accept(eq(subItem), captor.capture());
assertEquals(-1, captor.getValue().getEepromAddress());
MenuItem subItemCompare = menuTree.getSubMenuById(100).orElseThrow();
assertEquals(-1, subItemCompare.getEepromAddress());
}
use of com.thecoderscorner.menu.editorui.generator.core.VariableNameGenerator in project tcMenu by davetcc.
the class UIAnalogMenuItemTest method testEnteringValidValuesIntoAnalogEditor.
@Test
void testEnteringValidValuesIntoAnalogEditor(FxRobot robot) throws InterruptedException {
MenuItem analogItem = menuTree.getMenuById(1).orElseThrow();
VariableNameGenerator vng = new VariableNameGenerator(menuTree, false);
var uiSubItem = editorUI.createPanelForMenuItem(analogItem, menuTree, vng, mockedConsumer);
// open the sub menu item editor panel
createMainPanel(uiSubItem);
// firstly check that all the fields are populated properly
performAllCommonChecks(analogItem, true);
robot.clickOn("#offsetField");
robot.eraseText(5);
robot.write("-180");
robot.clickOn("#unitNameField");
robot.eraseText(5);
robot.write("dB");
robot.clickOn("#divisorField");
robot.eraseText(5);
robot.write("2");
robot.clickOn("#maxValueField");
robot.eraseText(5);
robot.write("255");
verifyThatThereAreNoErrorsReported();
ArgumentCaptor<MenuItem> captor = ArgumentCaptor.forClass(MenuItem.class);
verify(mockedConsumer, atLeastOnce()).accept(any(), captor.capture());
AnalogMenuItem item = (AnalogMenuItem) captor.getValue();
assertEquals(-180, item.getOffset());
assertEquals(255, item.getMaxValue());
assertEquals(2, item.getDivisor());
assertEquals("dB", item.getUnitName());
}
use of com.thecoderscorner.menu.editorui.generator.core.VariableNameGenerator in project tcMenu by davetcc.
the class UIEnumMenuItemTest method setup.
@Start
public void setup(Stage stage) {
init(stage);
enumItem = menuTree.getMenuById(20).get();
VariableNameGenerator vng = new VariableNameGenerator(menuTree, false);
uiSubItem = editorUI.createPanelForMenuItem(enumItem, menuTree, vng, mockedConsumer);
}
use of com.thecoderscorner.menu.editorui.generator.core.VariableNameGenerator in project tcMenu by davetcc.
the class UILargeNumberItemTest method generateLargeNumDialog.
private UILargeNumberMenuItem generateLargeNumDialog() throws Exception {
var largeNumItem = EditableLargeNumberMenuItemBuilder.aLargeNumberItemBuilder().withName("Large Num").withId(222).withEepromAddr(22).withDecimalPlaces(5).withTotalDigits(10).withNegativeAllowed(true).menuItem();
menuTree.addMenuItem(MenuTree.ROOT, largeNumItem);
VariableNameGenerator vng = new VariableNameGenerator(menuTree, false);
var uiBoolItem = editorUI.createPanelForMenuItem(largeNumItem, menuTree, vng, mockedConsumer);
if (uiBoolItem.isEmpty())
throw new IllegalArgumentException("No menu item found");
createMainPanel(uiBoolItem);
return (UILargeNumberMenuItem) uiBoolItem.get();
}
use of com.thecoderscorner.menu.editorui.generator.core.VariableNameGenerator 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"));
}
Aggregations