More unit tests and unified target for all tests (#6661)

* added general settings tests

* fixed pre-219 switchUnlockState (CPN)

* X7 radio settings tests

* updated X10 model

* patched TESTS_PATH to point directly at the complete tests path

* fixed horus general settings switch conversion

* cpn x10 general settings tests

* fixed horus cpn import

* use x10 model from otx file to ease editing with companion

* added make targets "gtests" and "tests"

gtests builds all the tests (radio & companion)
tests builds and executes all the tests (radio & companion)

* fixed companion tests cmake

* fixed gtests-radio target

* fixed commit tests

* fixed converting LS & RS on X10

* fixed converting global functions on X10

* fixed source conversion on X10

* fixed throttle source on X10

* fixed throttle source on radio and companion

* more checks and re-enabled Horus screenData copy

* more tests (X10)

* [X10] restore correct direction for RS & LS

* [horus] convert "Value" widget source

* fixed conversion of ModelHeader::bitmap length

* added missing X10 radio tests to companion tests

* fixed conversion of telemetry sources in logical switches

* [horus] fixed potential crash

* fixed "AND switch" conversion in logical switches
This commit is contained in:
Raphael Coeffic
2019-08-26 08:36:31 +02:00
committed by Bertrand Songis
parent 274528ee1d
commit 5db30ea7bc
19 changed files with 340 additions and 105 deletions
+78 -12
View File
@@ -33,12 +33,26 @@ void loadEEPROMFile(const char * filename)
#if defined(PCBX9DP)
TEST(Conversions, ConversionX9DPFrom22)
{
loadEEPROMFile(TESTS_PATH "/tests/eeprom_22_x9d+.bin");
loadEEPROMFile(TESTS_PATH "/eeprom_22_x9d+.bin");
eepromOpen();
eeLoadGeneralSettingsData();
convertRadioData_218_to_219(g_eeGeneral);
eeConvertModel(0, 218);
eeLoadModel(0);
EXPECT_EQ(-30, g_eeGeneral.vBatMin);
EXPECT_EQ(8, g_eeGeneral.speakerVolume);
EXPECT_EQ('e', g_eeGeneral.ttsLanguage[0]);
EXPECT_EQ('n', g_eeGeneral.ttsLanguage[1]);
EXPECT_EQ(SWSRC_TELEMETRY_STREAMING, g_eeGeneral.customFn[0].swtch);
EXPECT_EQ(FUNC_LOGS, g_eeGeneral.customFn[0].func);
EXPECT_EQ(20, g_eeGeneral.customFn[0].all.val);
EXPECT_ZSTREQ("Tes", g_eeGeneral.switchNames[0]);
EXPECT_EQ(SWITCH_3POS, SWITCH_CONFIG(0));
EXPECT_ZSTREQ("Test", g_model.header.name);
EXPECT_EQ(TMRMODE_COUNT - 1 + SWSRC_SA0, g_model.timers[0].mode);
EXPECT_EQ(80, g_model.mixData[0].weight);
@@ -60,12 +74,26 @@ TEST(Conversions, ConversionX9DPFrom22)
#if defined(PCBX7)
TEST(Conversions, ConversionX7From22)
{
loadEEPROMFile(TESTS_PATH "/tests/eeprom_22_x7.bin");
loadEEPROMFile(TESTS_PATH "/eeprom_22_x7.bin");
eepromOpen();
eeLoadGeneralSettingsData();
convertRadioData_218_to_219(g_eeGeneral);
eeConvertModel(0, 218);
eeLoadModel(0);
EXPECT_EQ(-30, g_eeGeneral.vBatMin);
EXPECT_EQ(8, g_eeGeneral.speakerVolume);
EXPECT_EQ('e', g_eeGeneral.ttsLanguage[0]);
EXPECT_EQ('n', g_eeGeneral.ttsLanguage[1]);
EXPECT_EQ(SWSRC_TELEMETRY_STREAMING, g_eeGeneral.customFn[0].swtch);
EXPECT_EQ(FUNC_LOGS, g_eeGeneral.customFn[0].func);
EXPECT_EQ(20, g_eeGeneral.customFn[0].all.val);
EXPECT_ZSTREQ("Tes", g_eeGeneral.switchNames[0]);
EXPECT_EQ(SWITCH_3POS, SWITCH_CONFIG(0));
EXPECT_ZSTREQ("Test", g_model.header.name);
EXPECT_EQ(MODULE_TYPE_R9M_PXX1, g_model.moduleData[EXTERNAL_MODULE].type);
EXPECT_EQ(MODULE_SUBTYPE_R9M_EU, g_model.moduleData[EXTERNAL_MODULE].subType);
@@ -97,30 +125,61 @@ TEST(Conversions, ConversionX7From22)
#endif
#if defined(PCBX10)
TEST(X10Conversions, ConversionRadioFrom22)
TEST(Conversions, ConversionX10From22)
{
simuFatfsSetPaths(TESTS_PATH "/tests/", TESTS_PATH "/tests/");
loadRadioSettings("/radio_22_x10.bin");
simuFatfsSetPaths(TESTS_PATH "/model_22_x10/", TESTS_PATH "/model_22_x10/");
loadRadioSettings("/RADIO/radio.bin");
loadModel("model1.bin");
EXPECT_EQ(219, g_eeGeneral.version);
EXPECT_EQ(100, g_eeGeneral.calib[9].spanNeg);
EXPECT_EQ(500, g_eeGeneral.calib[9].mid);
EXPECT_EQ(900, g_eeGeneral.calib[9].spanPos);
EXPECT_EQ(200, g_eeGeneral.calib[10].spanNeg);
EXPECT_EQ(400, g_eeGeneral.calib[10].mid);
EXPECT_EQ(600, g_eeGeneral.calib[10].spanPos);
EXPECT_EQ(-23, g_eeGeneral.vBatMin);
EXPECT_EQ(8, g_eeGeneral.speakerVolume);
EXPECT_STRNEQ("en", g_eeGeneral.ttsLanguage);
EXPECT_STRNEQ("model1.bin", g_eeGeneral.currModelFilename);
}
TEST(X10Conversions, ConversionModelFrom22)
{
simuFatfsSetPaths(TESTS_PATH "/tests/", TESTS_PATH "/tests/");
loadModel("model_22_x10.bin");
EXPECT_EQ(SWSRC_TELEMETRY_STREAMING, g_eeGeneral.customFn[0].swtch);
EXPECT_EQ(FUNC_LOGS, g_eeGeneral.customFn[0].func);
EXPECT_EQ(20, g_eeGeneral.customFn[0].all.val);
EXPECT_EQ(SWSRC_ON, g_eeGeneral.customFn[1].swtch);
EXPECT_EQ(FUNC_VOLUME, g_eeGeneral.customFn[1].func);
EXPECT_EQ(MIXSRC_RS, g_eeGeneral.customFn[1].all.val);
EXPECT_ZSTREQ("Tes", g_eeGeneral.switchNames[0]);
EXPECT_EQ(SWITCH_3POS, SWITCH_CONFIG(0));
EXPECT_ZSTREQ("BT_X10", g_eeGeneral.bluetoothName);
EXPECT_STREQ("Default", g_eeGeneral.themeName);
EXPECT_EQ(WHITE, g_eeGeneral.themeData.options[0].unsignedValue);
EXPECT_EQ(RED, g_eeGeneral.themeData.options[1].unsignedValue);
EXPECT_ZSTREQ("Test", g_model.header.name);
EXPECT_EQ(0, g_model.noGlobalFunctions);
EXPECT_EQ(0, g_model.beepANACenter);
EXPECT_EQ(80, g_model.mixData[0].weight);
EXPECT_EQ(MIXSRC_FIRST_TRAINER, g_model.mixData[4].srcRaw);
EXPECT_EQ(SWSRC_TELEMETRY_STREAMING, g_model.mixData[4].swtch);
EXPECT_EQ(MIXSRC_MAX, g_model.mixData[2].srcRaw); // MAX
EXPECT_EQ(MIXSRC_LS, g_model.mixData[3].srcRaw); // LS
EXPECT_EQ(MIXSRC_FIRST_TRAINER, g_model.mixData[5].srcRaw);
EXPECT_EQ(SWSRC_TELEMETRY_STREAMING, g_model.mixData[5].swtch);
EXPECT_EQ(-100, g_model.limitData[0].max);
EXPECT_EQ(80, g_model.expoData[0].weight);
EXPECT_EQ(LS_FUNC_VPOS, g_model.logicalSw[0].func);
EXPECT_EQ(MIXSRC_FIRST_TRAINER, g_model.logicalSw[0].v1);
EXPECT_EQ(0, g_model.logicalSw[0].v2);
EXPECT_EQ(MIXSRC_FIRST_TELEM+19*3, g_model.logicalSw[1].v1); // TELE:20
EXPECT_EQ(20, g_model.logicalSw[1].v2);
EXPECT_EQ(SWSRC_FIRST_LOGICAL_SWITCH, g_model.logicalSw[1].andsw);
EXPECT_EQ(SWASH_TYPE_120X, g_model.swashR.type);
EXPECT_ZSTREQ("Tes", g_model.flightModeData[0].name);
EXPECT_EQ(10, g_model.flightModeData[0].gvars[0]);
@@ -131,6 +190,13 @@ TEST(X10Conversions, ConversionModelFrom22)
EXPECT_ZSTREQ("Tes", g_model.telemetrySensors[0].label);
EXPECT_EQ(10, g_model.telemetrySensors[0].id);
EXPECT_EQ(9, g_model.telemetrySensors[0].frskyInstance.physID);
EXPECT_EQ((NUM_POTS + NUM_SLIDERS + 3), g_model.thrTraceSrc); // CH3
EXPECT_STREQ("Layout2P1", g_model.screenData[0].layoutName);
EXPECT_STREQ("ModelBmp", g_model.screenData[0].layoutData.zones[0].widgetName);
EXPECT_STREQ("Value", g_model.topbarData.zones[0].widgetName);
EXPECT_EQ(MIXSRC_FIRST_TELEM, g_model.topbarData.zones[0].widgetData.options[0].unsignedValue);
EXPECT_EQ(MIXSRC_RS, g_model.screenData[0].layoutData.zones[2].widgetData.options[0].unsignedValue);
}
#endif