Skip to content

Commit

Permalink
Test cases all pass
Browse files Browse the repository at this point in the history
  • Loading branch information
davetcc committed Oct 19, 2024
1 parent 1216a4a commit a36574c
Show file tree
Hide file tree
Showing 8 changed files with 4 additions and 154 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

package com.thecoderscorner.menu.editorui.generator.arduino;

import com.thecoderscorner.embedcontrol.core.service.FormPersistMode;
import com.thecoderscorner.menu.domain.EditableTextMenuItemBuilder;
import com.thecoderscorner.menu.domain.MenuItem;
import com.thecoderscorner.menu.domain.state.MenuTree;
Expand Down Expand Up @@ -48,24 +47,6 @@

public class ArduinoGeneratorTest {
public static final UUID SERVER_UUID = UUID.fromString("d7e57e8d-4528-4081-9b1b-cec5bc37a82e");
private static final String TEST_FORM_XML = """
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<EmbedControl boardUuid="29a725c3-0619-488e-b3bf-0f778dc9ef81" layoutName="Untitled">
<MenuLayouts>
<MenuLayout cols="2" fontInfo="100%" recursive="false" rootId="0">
<MenuElement alignment="LEFT" colorSet="Global" controlType="HORIZONTAL_SLIDER" drawMode="SHOW_NAME_VALUE" fontInfo="100%" menuId="1" position="0,0"/>
<MenuElement alignment="LEFT" colorSet="Global" controlType="UP_DOWN_CONTROL" drawMode="SHOW_NAME_VALUE" fontInfo="100%" menuId="2" position="0,1"/>
<MenuElement alignment="LEFT" colorSet="Global" controlType="UP_DOWN_CONTROL" drawMode="SHOW_NAME_VALUE" fontInfo="100%" menuId="2" position="1,0"/>
<MenuElement alignment="CENTER" colorSet="Global" controlType="BUTTON_CONTROL" drawMode="SHOW_NAME_VALUE" fontInfo="100%" menuId="3" position="1,1"/>
<MenuElement alignment="LEFT" colorSet="Global" controlType="TEXT_CONTROL" drawMode="SHOW_NAME_VALUE" fontInfo="100%" menuId="4" position="2,0"/>
<MenuElement alignment="CENTER" colorSet="Global" controlType="BUTTON_CONTROL" drawMode="SHOW_NAME" fontInfo="100%" menuId="5" position="2,1"/>
<MenuElement alignment="CENTER" colorSet="Global" controlType="BUTTON_CONTROL" drawMode="SHOW_NAME" fontInfo="100%" menuId="6" position="3,0"/>
<StaticText alignment="LEFT" colorSet="Global" position="3,1">Hello world</StaticText>
</MenuLayout>
</MenuLayouts>
<ColorSets/>
</EmbedControl>
""";
private Path projectDir;
private Path pluginDir;
private Path rootDir;
Expand Down Expand Up @@ -141,16 +122,13 @@ private void runConversionWith(String templateToUse, CodeGeneratorOptions option
when(clock.instant()).thenReturn(Instant.ofEpochMilli(1709985287323L)); // for testing, it is always Sat 9th March 2024 at 11.54
ArduinoGenerator generator = new ArduinoGenerator(adjuster, installer, standardOptions.getEmbeddedPlatform(), storage, clock);

var embeddedForm = new TcMenuFormPersistence(0, FormPersistMode.EXTERNAL_MANAGED, standardOptions.getApplicationUUID().toString(), "My Form 1", TEST_FORM_XML);

var firstPlugin = pluginConfig.getPlugins().getFirst();
firstPlugin.getProperties().stream()
.filter(p -> p.getName().equals("SWITCH_IODEVICE"))
.findFirst()
.ifPresent(p -> p.setLatestValue("io23017"));

assertTrue(generator.startConversion(projectDir, pluginConfig.getPlugins(), tree, List.of(), standardOptions,
handler, List.of(embeddedForm)));
assertTrue(generator.startConversion(projectDir, pluginConfig.getPlugins(), tree, List.of(), standardOptions, handler));

VariableNameGenerator gen = new VariableNameGenerator(tree, false, Set.of());
assertEquals("GenState", gen.makeNameToVar(generateItemWithName("Gen &^%State")));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public void testConversion() throws IOException {
.withProperties(plugin.getProperties()).codeOptions();
List<CodePluginItem> plugins = List.of(plugin);
generator.setLoggerFunction((level, s) -> Logger.getAnonymousLogger().log(Level.INFO, level + " " + s));
generator.startConversion(tempPath, plugins, tree, List.of("xyzoerj"), options, LocaleMappingHandler.NOOP_IMPLEMENTATION, List.of());
generator.startConversion(tempPath, plugins, tree, List.of("xyzoerj"), options, LocaleMappingHandler.NOOP_IMPLEMENTATION);

var project = new EmbeddedJavaProject(tempPath, options, storage, LocaleMappingHandler.NOOP_IMPLEMENTATION, (level, s) -> Logger.getAnonymousLogger().log(Level.INFO, level + " " + s));

Expand Down Expand Up @@ -100,7 +100,7 @@ public void testConversionWithMenuInMenuAndModules() throws IOException {
.codeOptions();
List<CodePluginItem> plugins = List.of(plugin);
generator.setLoggerFunction((level, s) -> Logger.getAnonymousLogger().log(Level.INFO, level + " " + s));
generator.startConversion(tempPath, plugins, tree, List.of("xyzoerj"), options, LocaleMappingHandler.NOOP_IMPLEMENTATION, List.of());
generator.startConversion(tempPath, plugins, tree, List.of("xyzoerj"), options, LocaleMappingHandler.NOOP_IMPLEMENTATION);

var project = new EmbeddedJavaProject(tempPath, options, storage, LocaleMappingHandler.NOOP_IMPLEMENTATION,
(level, s) -> Logger.getAnonymousLogger().log(Level.INFO, level + " " + s));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ public void testMbedConversion() throws IOException {

var propsLocale = new PropertiesLocaleEnabledHandler(new SafeBundleLoader(projectDir.resolve("i18n"), MENU_PROJECT_LANG_FILENAME));

assertTrue(generator.startConversion(projectDir, pluginConfig.getPlugins(), tree, List.of(), options, propsLocale, List.of()));
assertTrue(generator.startConversion(projectDir, pluginConfig.getPlugins(), tree, List.of(), options, propsLocale));

var sourceDir = projectDir.resolve("src");
var generatedDir = sourceDir.resolve("generated");
Expand Down
40 changes: 0 additions & 40 deletions tcMenuGenerator/src/test/resources/generator/template.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ EnumMenuItem menuExtra(&minfoExtra, 0, &menuTest, INFO_LOCATION_PGM);

void setupMenu() {
// First we set up eeprom and authentication (if needed).
CombinedMessageProcessor::setFormTemplatesInFlash(tcMenuAllEmbeddedForms);
setSizeBasedEEPROMStorageEnabled(true);
menuMgr.setEepromRef(&glAvrRom);
authManager.initialise(menuMgr.getEepromAbstraction(), 100);
Expand All @@ -62,42 +61,3 @@ void setupMenu() {
});
}

// Embedded form data

const uint8_t formData_MyForm1_d8[] PROGMEM {
0x1f,0x8b,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xcd,0x94,0xdd,0x6a,0xdb,0x40,
0x10,0x85,0xef,0xfd,0x14,0xcb,0x40,0xef,0xa2,0x4a,0xb2,0x93,0x58,0x06,0xc9,0xc1,
0x71,0x94,0xda,0x20,0x4b,0xc5,0x5e,0x35,0x21,0x37,0x62,0xa5,0x5d,0x05,0xc1,0x7a,
0x27,0x48,0xab,0xfc,0xbc,0x7d,0x56,0xae,0x21,0x56,0x4b,0xa9,0x69,0x42,0xe8,0xdd,
0xee,0x0c,0x9c,0xf9,0xe6,0x0c,0x1c,0xff,0xe2,0x79,0x2b,0xc9,0xa3,0xa8,0x9b,0x0a,
0x55,0x00,0xee,0x57,0x07,0x88,0x50,0x05,0xf2,0x4a,0xdd,0x07,0x90,0xd2,0x6b,0xcb,
0x03,0xd2,0x68,0xa6,0x38,0x93,0xa8,0x44,0x00,0x0a,0xe1,0x62,0x3a,0xf0,0xc3,0x6d,
0x2e,0xf8,0x1c,0x95,0xae,0x51,0x92,0x1c,0x59,0xcd,0xd3,0xb6,0xe2,0x01,0x0c,0x27,
0x6c,0x3c,0x3c,0x2b,0x46,0x96,0x73,0xee,0x4e,0xac,0x53,0xcf,0x13,0x56,0x3e,0xca,
0x4b,0xcb,0x29,0xc7,0x63,0x8f,0x17,0x13,0x51,0x7a,0x2e,0x10,0xc9,0x5e,0xb0,0xd5,
0x31,0xdb,0x1a,0xc1,0x54,0xe9,0x4a,0x4b,0xc1,0x61,0x3a,0x20,0xc4,0x5f,0x09,0xd5,
0x46,0xbb,0x6e,0xd3,0xfd,0x7b,0x15,0x52,0xa0,0x6c,0xcc,0x08,0x20,0xa5,0x19,0xbc,
0x54,0x25,0x1a,0x60,0xc7,0xf9,0x02,0xa4,0x16,0x45,0x6b,0x36,0x78,0x34,0x72,0x25,
0x93,0x8d,0x30,0x15,0x44,0xbd,0x34,0x3c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0x05,0x00,0x00
};
const EmbedControlFlashedForm formData_MyForm1 PROGMEM {
"My Form 1",
formData_MyForm1_d8,
437
};

const EmbedControlFlashedForm* tcMenuAllEmbeddedForms[] PROGMEM { &formData_MyForm1, nullptr };
2 changes: 0 additions & 2 deletions tcMenuGenerator/src/test/resources/generator/template.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,4 @@ void CALLBACK_FUNCTION callback2(int id);
int fnAbcRtCall(RuntimeMenuItem* item, uint8_t row, RenderFnMode mode, char* buffer, int bufferSize);
void CALLBACK_FUNCTION headerOnly(int id);

extern const EmbedControlFlashedForm* tcMenuAllEmbeddedForms[];

#endif // MENU_GENERATED_CODE_H
40 changes: 0 additions & 40 deletions tcMenuGenerator/src/test/resources/generator/template32.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ EnumMenuItem menuExtra(&minfoExtra, 0, &menuTest, INFO_LOCATION_PGM);

void setupMenu() {
// First we set up eeprom and authentication (if needed).
CombinedMessageProcessor::setFormTemplatesInFlash(tcMenuAllEmbeddedForms);
setSizeBasedEEPROMStorageEnabled(true);
menuMgr.setEepromRef(&glAvrRom);
authManager.initialise(menuMgr.getEepromAbstraction(), 100);
Expand All @@ -62,42 +61,3 @@ void setupMenu() {
});
}

// Embedded form data

const uint8_t formData_MyForm1_d8[] {
0x1f,0x8b,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xcd,0x94,0xdd,0x6a,0xdb,0x40,
0x10,0x85,0xef,0xfd,0x14,0xcb,0x40,0xef,0xa2,0x4a,0xb2,0x93,0x58,0x06,0xc9,0xc1,
0x71,0x94,0xda,0x20,0x4b,0xc5,0x5e,0x35,0x21,0x37,0x62,0xa5,0x5d,0x05,0xc1,0x7a,
0x27,0x48,0xab,0xfc,0xbc,0x7d,0x56,0xae,0x21,0x56,0x4b,0xa9,0x69,0x42,0xe8,0xdd,
0xee,0x0c,0x9c,0xf9,0xe6,0x0c,0x1c,0xff,0xe2,0x79,0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,0x6c,0xfe,0x80,0x4d,0xa5,0x77,0x56,0x3b,
0x27,0x0e,0xd8,0x1f,0x02,0x97,0x7e,0xcf,0xae,0x92,0x9b,0x38,0x9b,0x1b,0xc0,0x75,
0x12,0xfd,0x13,0xda,0xb0,0x8f,0xe6,0xfe,0xaf,0x68,0xee,0x31,0xae,0xcd,0xc3,0x98,
0x76,0x27,0xfa,0x0b,0xdc,0x65,0x4a,0x69,0xf2,0x3e,0xb6,0x51,0x9f,0xed,0xa3,0x6c,
0xa3,0xe1,0x2d,0x7d,0x17,0xd7,0xe9,0x21,0xd7,0xf0,0x73,0x3d,0xfb,0x33,0xd5,0x59,
0x9f,0xea,0x08,0xb7,0x3e,0x83,0xea,0xfc,0x90,0x6a,0xd4,0xf3,0x6a,0xa3,0x99,0xae,
0x0a,0x2a,0x9e,0x8f,0x3a,0xe1,0xa1,0x8a,0x0b,0xd3,0x85,0x90,0x12,0xc9,0x13,0xd6,
0x92,0xfb,0xf6,0x9b,0xd2,0x3e,0xd6,0xec,0xb7,0x5c,0xdb,0x05,0x9f,0xfd,0x4b,0xf2,
0xf9,0xf3,0xbd,0x7e,0x63,0x70,0x7c,0xfb,0x30,0x6f,0xa7,0x83,0x57,0xa8,0xcd,0x06,
0xaf,0xb6,0x05,0x00,0x00
};
const EmbedControlFlashedForm formData_MyForm1 {
"My Form 1",
formData_MyForm1_d8,
437
};

const EmbedControlFlashedForm* tcMenuAllEmbeddedForms[] { &formData_MyForm1, nullptr };
2 changes: 0 additions & 2 deletions tcMenuGenerator/src/test/resources/generator/template32.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,4 @@ void CALLBACK_FUNCTION callback2(int id);
int fnAbcRtCall(RuntimeMenuItem* item, uint8_t row, RenderFnMode mode, char* buffer, int bufferSize);
void CALLBACK_FUNCTION headerOnly(int id);

extern const EmbedControlFlashedForm* tcMenuAllEmbeddedForms[];

#endif // MENU_GENERATED_CODE_H

0 comments on commit a36574c

Please sign in to comment.