Search in sources :

Example 1 with AlwaysApplicable

use of com.thecoderscorner.menu.editorui.generator.applicability.AlwaysApplicable in project tcMenu by davetcc.

the class AuthenticatorDefinitionTest method testFlashBasedAuthenticator.

@Test
public void testFlashBasedAuthenticator() {
    var definition = AuthenticatorDefinition.readFromProject("flash:1234:super123:94242-234234-23423-2342:super2:342342-234234-234-234-234");
    assertThat(definition).isInstanceOf(ReadOnlyAuthenticatorDefinition.class);
    assertEquals("flash:1234:super123:94242-234234-23423-2342:super2:342342-234234-234-234-234", definition.writeToProject());
    assertThat(definition.generateHeader()).contains(new HeaderDefinition("RemoteAuthentication.h", GLOBAL, PRIORITY_NORMAL, new AlwaysApplicable()));
    assertThat(definition.generateGlobal()).contains("const AuthBlock authMgrAllowedRemotes[] PROGMEM = {" + LINE_BREAK + "    { \"94242-234234-23423-2342\", \"super123\" }," + LINE_BREAK + "    { \"342342-234234-234-234-234\", \"super2\" }" + LINE_BREAK + "};" + LINE_BREAK + "const char pgmAuthMgrPassword[] PROGMEM = \"1234\";" + LINE_BREAK + "ReadOnlyAuthenticationManager authManager(authMgrAllowedRemotes, 2, pgmAuthMgrPassword);");
    assertThat(definition.generateCode()).contains("    menuMgr.setAuthenticator(&authManager);");
    assertEquals("FLASH Authenticator, remotes=2", definition.toString());
}
Also used : HeaderDefinition(com.thecoderscorner.menu.editorui.generator.core.HeaderDefinition) AlwaysApplicable(com.thecoderscorner.menu.editorui.generator.applicability.AlwaysApplicable) Test(org.junit.jupiter.api.Test)

Example 2 with AlwaysApplicable

use of com.thecoderscorner.menu.editorui.generator.applicability.AlwaysApplicable in project tcMenu by davetcc.

the class AuthenticatorDefinitionTest method testEEPROMBasedAuthenticator.

@Test
public void testEEPROMBasedAuthenticator() {
    var definition = AuthenticatorDefinition.readFromProject("rom:512:3");
    assertThat(definition).isInstanceOf(EepromAuthenticatorDefinition.class);
    assertEquals("rom:512:3", definition.writeToProject());
    assertThat(definition.generateHeader()).contains(new HeaderDefinition("RemoteAuthentication.h", GLOBAL, PRIORITY_NORMAL, new AlwaysApplicable()));
    assertThat(definition.generateGlobal()).contains("EepromAuthenticatorManager authManager(3);");
    assertThat(definition.generateCode()).contains("    authManager.initialise(menuMgr.getEepromAbstraction(), 512);" + LINE_BREAK + "    menuMgr.setAuthenticator(&authManager);");
    assertEquals("EEPROM Authenticator, offset=512", definition.toString());
}
Also used : HeaderDefinition(com.thecoderscorner.menu.editorui.generator.core.HeaderDefinition) AlwaysApplicable(com.thecoderscorner.menu.editorui.generator.applicability.AlwaysApplicable) Test(org.junit.jupiter.api.Test)

Example 3 with AlwaysApplicable

use of com.thecoderscorner.menu.editorui.generator.applicability.AlwaysApplicable in project tcMenu by davetcc.

the class EepromDefinitionTest method testArduinoClassEepromDefinition.

@Test
public void testArduinoClassEepromDefinition() {
    var definition = EepromDefinition.readFromProject("eeprom:");
    assertThat(definition).isInstanceOf(ArduinoClassEepromDefinition.class);
    assertEquals("eeprom:", definition.writeToProject());
    assertThat(definition.generateHeader()).contains(new HeaderDefinition("ArduinoEEPROMAbstraction.h", GLOBAL, PRIORITY_NORMAL, new AlwaysApplicable()));
    assertThat(definition.generateGlobal()).contains("ArduinoEEPROMAbstraction glArduinoEeprom(&EEPROM);");
    assertThat(definition.generateCode()).contains("    menuMgr.setEepromRef(&glArduinoEeprom);");
    assertEquals("Arduino EEPROM class", definition.toString());
}
Also used : HeaderDefinition(com.thecoderscorner.menu.editorui.generator.core.HeaderDefinition) AlwaysApplicable(com.thecoderscorner.menu.editorui.generator.applicability.AlwaysApplicable) Test(org.junit.jupiter.api.Test)

Example 4 with AlwaysApplicable

use of com.thecoderscorner.menu.editorui.generator.applicability.AlwaysApplicable in project tcMenu by davetcc.

the class EepromDefinitionTest method testBspStEepromDefinition.

@Test
public void testBspStEepromDefinition() {
    BspStm32EepromDefinition definition = (BspStm32EepromDefinition) EepromDefinition.readFromProject("bsp:256");
    assertThat(definition).isInstanceOf(BspStm32EepromDefinition.class);
    assertEquals("bsp:256", definition.writeToProject());
    assertEquals(256, definition.getOffset());
    assertThat(definition.generateHeader()).contains(new HeaderDefinition("mbed/HalStm32EepromAbstraction.h", GLOBAL, PRIORITY_NORMAL, new AlwaysApplicable()));
    assertThat(definition.generateGlobal()).contains("HalStm32EepromAbstraction glBspRom;");
    assertThat(definition.generateCode()).contains("    glBspRom.initialise(256);" + LINE_BREAK + "    menuMgr.setEepromRef(&glBspRom);");
    assertEquals("STM32 BSP offset=256", definition.toString());
}
Also used : HeaderDefinition(com.thecoderscorner.menu.editorui.generator.core.HeaderDefinition) AlwaysApplicable(com.thecoderscorner.menu.editorui.generator.applicability.AlwaysApplicable) Test(org.junit.jupiter.api.Test)

Example 5 with AlwaysApplicable

use of com.thecoderscorner.menu.editorui.generator.applicability.AlwaysApplicable in project tcMenu by davetcc.

the class EepromDefinitionTest method testAt24EepromDefinition.

@Test
public void testAt24EepromDefinition() {
    At24EepromDefinition definition = (At24EepromDefinition) EepromDefinition.readFromProject("at24:32:PAGESIZE_AT24C256");
    assertThat(definition).isInstanceOf(At24EepromDefinition.class);
    assertEquals("at24:32:PAGESIZE_AT24C256", definition.writeToProject());
    assertEquals(32, definition.getAddress());
    assertEquals("PAGESIZE_AT24C256", definition.getPageSize());
    assertThat(definition.generateHeader()).contains(new HeaderDefinition("EepromAbstractionWire.h", GLOBAL, PRIORITY_NORMAL, new AlwaysApplicable()));
    assertThat(definition.generateGlobal()).contains("I2cAt24Eeprom glI2cRom(0x20, PAGESIZE_AT24C256);");
    assertThat(definition.generateCode()).contains("    menuMgr.setEepromRef(&glI2cRom);");
    assertEquals("I2C AT24 addr=0x20, PAGESIZE_AT24C256", definition.toString());
}
Also used : HeaderDefinition(com.thecoderscorner.menu.editorui.generator.core.HeaderDefinition) AlwaysApplicable(com.thecoderscorner.menu.editorui.generator.applicability.AlwaysApplicable) Test(org.junit.jupiter.api.Test)

Aggregations

AlwaysApplicable (com.thecoderscorner.menu.editorui.generator.applicability.AlwaysApplicable)8 Test (org.junit.jupiter.api.Test)8 HeaderDefinition (com.thecoderscorner.menu.editorui.generator.core.HeaderDefinition)7 MenuTree (com.thecoderscorner.menu.domain.state.MenuTree)1 CodeGeneratorOptionsBuilder (com.thecoderscorner.menu.editorui.generator.CodeGeneratorOptionsBuilder)1 CreatorProperty (com.thecoderscorner.menu.editorui.generator.core.CreatorProperty)1 IoExpanderDefinitionCollection (com.thecoderscorner.menu.editorui.generator.parameters.IoExpanderDefinitionCollection)1 NoAuthenticatorDefinition (com.thecoderscorner.menu.editorui.generator.parameters.auth.NoAuthenticatorDefinition)1 NoEepromDefinition (com.thecoderscorner.menu.editorui.generator.parameters.eeprom.NoEepromDefinition)1 CustomDeviceExpander (com.thecoderscorner.menu.editorui.generator.parameters.expander.CustomDeviceExpander)1 Path (java.nio.file.Path)1