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());
}
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());
}
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());
}
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());
}
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());
}
Aggregations