[Horus] Google tests added

This commit is contained in:
Bertrand Songis
2016-03-22 19:36:53 +01:00
parent 74992a69dc
commit 5691395dcf
9 changed files with 99 additions and 266 deletions
+1 -1
View File
@@ -319,7 +319,7 @@ void getLogicalSwitchAudioFile(char * filename, int index, unsigned int event)
{
char * str = getModelAudioPath(filename);
#if defined(PCBTARANIS)
#if defined(PCBTARANIS) || defined(PCBHORUS)
*str++ = 'L';
if (index >= 9) {
div_t qr = div(index+1, 10);
-14
View File
@@ -34,11 +34,6 @@ PACK(struct RamBackupUncompressed {
Backup::RamBackupUncompressed ramBackupUncompressed __DMA;
PACK(struct RamBackup {
uint16_t size;
uint8_t data[4094];
});
#if defined(SIMU)
RamBackup _ramBackup;
RamBackup * ramBackup = &_ramBackup;
@@ -52,15 +47,6 @@ void rambackupWrite()
copyModelData(&ramBackupUncompressed.model, &g_model);
ramBackup->size = compress(ramBackup->data, 4094, (const uint8_t *)&ramBackupUncompressed, sizeof(ramBackupUncompressed));
TRACE("RamBackupWrite sdsize=%d backupsize=%d rlcsize=%d", sizeof(ModelData)+sizeof(RadioData), sizeof(Backup::RamBackupUncompressed), ramBackup->size);
#if 0
// TODO move this code to non regression tests
Backup::RamBackupUncompressed ramBackupRestored;
if (uncompress((uint8_t *)&ramBackupRestored, sizeof(ramBackupRestored), ramBackup->data, ramBackup->size) != sizeof(ramBackupUncompressed))
TRACE("ERROR uncompress");
if (memcmp(&ramBackupUncompressed, &ramBackupRestored, sizeof(ramBackupUncompressed)) != 0)
TRACE("ERROR restore");
#endif
}
bool rambackupRestore()
+7
View File
@@ -30,4 +30,11 @@ const char * readModel(const char * filename, uint8_t * buffer, uint32_t size);
const char * loadModel(const char * filename);
const char * createModel();
PACK(struct RamBackup {
uint16_t size;
uint8_t data[4094];
});
extern RamBackup * ramBackup;
#endif // _SDCARD_RAW_H_
+25 -2
View File
@@ -2,7 +2,7 @@
* Copyright (C) OpenTX
*
* Based on code named
* th9x - http://code.google.com/p/th9x
* th9x - http://code.google.com/p/th9x
* er9x - http://code.google.com/p/er9x
* gruvin9x - http://code.google.com/p/gruvin9x
*
@@ -20,7 +20,30 @@
#include "gtests.h"
#if !defined(PCBSKY9X)
#if !defined(EEPROM) && defined(SDCARD)
namespace Backup {
#define BACKUP
#include "datastructs.h"
PACK(struct RamBackupUncompressed {
ModelData model;
RadioData radio;
});
#undef BACKUP
};
extern Backup::RamBackupUncompressed ramBackupUncompressed;
TEST(Storage, BackupAndRestore)
{
rambackupWrite();
Backup::RamBackupUncompressed ramBackupRestored;
if (uncompress((uint8_t *)&ramBackupRestored, sizeof(ramBackupRestored), ramBackup->data, ramBackup->size) != sizeof(ramBackupUncompressed))
TRACE("ERROR uncompress");
if (memcmp(&ramBackupUncompressed, &ramBackupRestored, sizeof(ramBackupUncompressed)) != 0)
TRACE("ERROR restore");
}
#endif
#if defined(EEPROM_RLC)
TEST(Eeprom, 100_random_writes)
{
eepromFile = NULL; // in memory
+15 -9
View File
@@ -2,7 +2,7 @@
* Copyright (C) OpenTX
*
* Based on code named
* th9x - http://code.google.com/p/th9x
* th9x - http://code.google.com/p/th9x
* er9x - http://code.google.com/p/er9x
* gruvin9x - http://code.google.com/p/gruvin9x
*
@@ -82,7 +82,7 @@ TEST(FrSky, FrskyValueWithMinAveraging)
{
/*
The following expected[] array is filled
with values that correspond to 4 elements
with values that correspond to 4 elements
long averaging buffer.
If length of averaging buffer is changed, this
values must be adjusted
@@ -91,7 +91,7 @@ TEST(FrSky, FrskyValueWithMinAveraging)
int testPos = 0;
//test of averaging
FrskyValueWithMin testVal;
testVal.value = 0;
testVal.value = 0;
testVal.set(10);
EXPECT_EQ(RAW_FRSKY_MINMAX(testVal), 10);
EXPECT_EQ(testVal.value, expected[testPos++]);
@@ -162,16 +162,16 @@ TEST(FrSky, HubAltNegative)
// first trigger hi precision, by setting AP above 9
processHubPacket(BARO_ALT_BP_ID, -1); // set value of -1.35m
processHubPacket(BARO_ALT_AP_ID, 35);
EXPECT_EQ(telemetryItems[0].value, -13);
EXPECT_EQ(telemetryItems[0].value, -13);
processHubPacket(BARO_ALT_BP_ID, 12); // set value of 12.35m
processHubPacket(BARO_ALT_AP_ID, 35);
EXPECT_EQ(telemetryItems[0].value, 123);
EXPECT_EQ(telemetryItems[0].value, 123);
// now test with the AP less than 10 to check if hiprecision is still active
processHubPacket(BARO_ALT_BP_ID, 12); // set value of 12.05m
processHubPacket(BARO_ALT_AP_ID, 05);
EXPECT_EQ(telemetryItems[0].value, 120);
EXPECT_EQ(telemetryItems[0].value, 120);
}
#endif // #if defined(FRSKY) && defined(CPUARM)
@@ -250,7 +250,7 @@ TEST(FrSkySPORT, frskySetCellVoltage)
generateSportCellPacket(packet, 3, 0, _V(405), _V(300)); processSportPacket(packet);
generateSportCellPacket(packet, 3, 2, _V(430), _V( 0)); processSportPacket(packet);
EXPECT_EQ(telemetryItems[0].cells.count, 3);
EXPECT_EQ(telemetryItems[0].cells.values[0].value, 405);
EXPECT_EQ(telemetryItems[0].cells.values[1].value, 300);
@@ -262,10 +262,10 @@ TEST(FrSkySPORT, frskySetCellVoltage)
generateSportCellPacket(packet, 3, 0, _V(405), _V(250)); processSportPacket(packet);
generateSportCellPacket(packet, 3, 2, _V(430), _V( 0)); processSportPacket(packet);
generateSportCellPacket(packet, 3, 0, _V(410), _V(420)); processSportPacket(packet);
generateSportCellPacket(packet, 3, 2, _V(430), _V( 0)); processSportPacket(packet);
EXPECT_EQ(telemetryItems[0].cells.count, 3);
EXPECT_EQ(telemetryItems[0].cells.values[0].value, 410);
EXPECT_EQ(telemetryItems[0].cells.values[1].value, 420);
@@ -326,7 +326,10 @@ TEST(FrSkySPORT, frskySetCellVoltage)
//display test
lcdClear();
#if !defined(COLORLCD)
g_model.frsky.voltsSource = FRSKY_VOLTS_SOURCE_A1;
#endif
}
TEST(FrSkySPORT, StrangeCellsBug)
@@ -401,7 +404,10 @@ TEST(FrSkySPORT, frskySetCellVoltageTwoSensors)
//display test
lcdClear();
#if !defined(COLORLCD)
g_model.frsky.voltsSource = FRSKY_VOLTS_SOURCE_A1;
#endif
}
void generateSportFasVoltagePacket(uint8_t * packet, uint32_t voltage)
+3 -3
View File
@@ -2,7 +2,7 @@
* Copyright (C) OpenTX
*
* Based on code named
* th9x - http://code.google.com/p/th9x
* th9x - http://code.google.com/p/th9x
* er9x - http://code.google.com/p/er9x
* gruvin9x - http://code.google.com/p/gruvin9x
*
@@ -35,7 +35,7 @@ extern uint16_t anaInValues[NUM_STICKS+NUM_POTS];
void doMixerCalculations();
#if defined(PCBTARANIS)
#if defined(PCBTARANIS) || defined(PCBHORUS)
#define RADIO_RESET() \
g_eeGeneral.switchConfig = 0x00007bff
#else
@@ -44,7 +44,7 @@ void doMixerCalculations();
inline void SYSTEM_RESET()
{
#if defined(CPUARM)
#if defined(CPUARM) && defined(EEPROM)
memset(modelHeaders, 0, sizeof(modelHeaders));
#endif
generalDefault();
+16 -13
View File
@@ -2,7 +2,7 @@
* Copyright (C) OpenTX
*
* Based on code named
* th9x - http://code.google.com/p/th9x
* th9x - http://code.google.com/p/th9x
* er9x - http://code.google.com/p/er9x
* gruvin9x - http://code.google.com/p/gruvin9x
*
@@ -96,6 +96,9 @@ bool checkScreenshot(const QString & test)
return true;
}
#if defined(COLORLCD)
// TODO
#else
TEST(outdezNAtt, test_unsigned)
{
lcdClear();
@@ -113,7 +116,6 @@ TEST(outdezNAtt, testBigNumbers)
}
#endif // #if defined(CPUARM)
TEST(Lcd, Invers_0_0)
{
lcdClear();
@@ -204,7 +206,7 @@ TEST(Lcd, Smlsize)
bool invert = false;
for(int i=0; i<3; i++) {
lcdDrawText(40+(4*i), 0+(4*i), "ABC", SMLSIZE|(invert?INVERS:0));
lcdDrawText(40+(4*i), 0+(4*i), "ABC", SMLSIZE|(invert?INVERS:0));
invert = !invert;
}
@@ -221,7 +223,7 @@ TEST(Lcd, Stdsize)
bool invert = false;
for(int i=0; i<3; i++) {
lcdDrawText(40+(4*i), 0+(4*i), "ABC", (invert?INVERS:0));
lcdDrawText(40+(4*i), 0+(4*i), "ABC", (invert?INVERS:0));
invert = !invert;
}
@@ -238,7 +240,7 @@ TEST(Lcd, Midsize)
bool invert = false;
for(int i=0; i<3; i++) {
lcdDrawText(40+(4*i), 0+(4*i), "ABC", MIDSIZE|(invert?INVERS:0));
lcdDrawText(40+(4*i), 0+(4*i), "ABC", MIDSIZE|(invert?INVERS:0));
invert = !invert;
}
@@ -255,7 +257,7 @@ TEST(Lcd, Dblsize)
bool invert = false;
for(int i=0; i<3; i++) {
lcdDrawText(10+(4*i), 30+(4*i), "ABC", DBLSIZE|(invert?INVERS:0));
lcdDrawText(10+(4*i), 30+(4*i), "ABC", DBLSIZE|(invert?INVERS:0));
invert = !invert;
}
@@ -329,11 +331,11 @@ public:
};
~TestBuffer() { if (buf) delete[] buf; };
uint8_t * buffer() { return buf + padding; };
void leakCheck() const {
void leakCheck() const {
uint8_t paddingCompareBuf[padding];
memset(paddingCompareBuf, 0xA5, padding);
if (memcmp(buf, paddingCompareBuf, padding) != 0) {
ADD_FAILURE() << "buffer leaked low";
ADD_FAILURE() << "buffer leaked low";
};
memset(paddingCompareBuf, 0x5A, padding);
if (memcmp(buf+padding+size, paddingCompareBuf, padding) != 0) {
@@ -397,33 +399,33 @@ TEST(Lcd, lcdDrawBitmapLoadAndDisplay)
TEST(Lcd, lcdDrawLine)
{
int start, length, xOffset;
uint8_t pattern;
uint8_t pattern;
lcdClear();
start = 5;
pattern = SOLID;
pattern = SOLID;
length = 40;
xOffset = 0;
lcdDrawLine(start+(length>0?1:-1)+xOffset, start, start+(length>0?1:-1)+xOffset+length, start, pattern, 0);
lcdDrawLine(start+xOffset, start+(length>0?1:-1), start+xOffset, start+(length>0?1:-1)+length, pattern, 0);
start = 10;
pattern = DOTTED;
pattern = DOTTED;
length = 40;
xOffset = 0;
lcdDrawLine(start+(length>0?1:-1)+xOffset, start, start+(length>0?1:-1)+xOffset+length, start, pattern, 0);
lcdDrawLine(start+xOffset, start+(length>0?1:-1), start+xOffset, start+(length>0?1:-1)+length, pattern, 0);
start = 55;
pattern = SOLID;
pattern = SOLID;
length = -40;
xOffset = 80;
lcdDrawLine(start+(length>0?1:-1)+xOffset, start, start+(length>0?1:-1)+xOffset+length, start, pattern, 0);
lcdDrawLine(start+xOffset, start+(length>0?1:-1), start+xOffset, start+(length>0?1:-1)+length, pattern, 0);
start = 50;
pattern = DOTTED;
pattern = DOTTED;
length = -40;
xOffset = 80;
lcdDrawLine(start+(length>0?1:-1)+xOffset, start, start+(length>0?1:-1)+xOffset+length, start, pattern, 0);
@@ -459,3 +461,4 @@ TEST(Lcd, lcdDrawLine)
EXPECT_TRUE(checkScreenshot("lcdDrawLine"));
}
#endif
#endif
+11 -11
View File
@@ -2,7 +2,7 @@
* Copyright (C) OpenTX
*
* Based on code named
* th9x - http://code.google.com/p/th9x
* th9x - http://code.google.com/p/th9x
* er9x - http://code.google.com/p/er9x
* gruvin9x - http://code.google.com/p/gruvin9x
*
@@ -19,7 +19,7 @@
*/
#include "gtests.h"
#include "../templates.h"
#include "templates.h"
#define CHECK_NO_MOVEMENT(channel, value, duration) \
for (int i=1; i<=(duration); i++) { \
@@ -173,7 +173,7 @@ TEST(Trims, throttleTrimWithZeroWeightOnThrottle)
MODEL_RESET();
modelDefault(0);
g_model.thrTrim = 1;
#if defined(PCBTARANIS)
#if defined(VIRTUALINPUTS)
// the input already exists
ExpoData *expo = expoAddress(THR_STICK);
#else
@@ -252,7 +252,7 @@ TEST(Trims, invertedThrottlePlusthrottleTrimWithZeroWeightOnThrottle)
modelDefault(0);
g_model.throttleReversed = 1;
g_model.thrTrim = 1;
#if defined(PCBTARANIS)
#if defined(VIRTUALINPUTS)
// the input already exists
ExpoData *expo = expoAddress(THR_STICK);
#else
@@ -325,7 +325,7 @@ TEST(Trims, invertedThrottlePlusthrottleTrimWithZeroWeightOnThrottle)
EXPECT_EQ(channelOutputs[2], 0);
}
#if !defined(PCBTARANIS)
#if !defined(VIRTUALINPUTS)
TEST(Trims, greaterTrimLink)
{
MODEL_RESET();
@@ -395,7 +395,7 @@ TEST(Trims, InstantTrim)
EXPECT_EQ(25, getTrimValue(0, AIL_STICK));
}
#if defined(PCBTARANIS)
#if defined(VIRTUALINPUTS)
TEST(Trims, InstantTrimNegativeCurve)
{
MODEL_RESET();
@@ -639,7 +639,7 @@ TEST(Mixer, SlowOnSwitch)
g_model.mixData[0].speedDown = SLOW_STEP*5;
s_mixer_first_run_done = true;
evalFlightModeMixes(e_perout_mode_normal, 0);
EXPECT_EQ(chans[0], 0);
@@ -747,7 +747,7 @@ TEST(Mixer, SlowOnSwitchSource)
g_model.mixData[0].weight = 100;
g_model.mixData[0].speedUp = SLOW_STEP*5;
g_model.mixData[0].speedDown = SLOW_STEP*5;
#if defined(PCBTARANIS)
#if defined(PCBTARANIS) || defined(PCBHORUS)
g_eeGeneral.switchConfig = 0x03;
#endif
@@ -818,7 +818,7 @@ TEST(Mixer, SlowAndDelayOnReplace3POSSource)
g_model.mixData[0].speedDown = SLOW_STEP*5;
s_mixer_first_run_done = true;
simuSetSwitch(3, -1);
CHECK_SLOW_MOVEMENT(0, -1, 250);
EXPECT_EQ(chans[0], -CHANNEL_MAX);
@@ -866,7 +866,7 @@ TEST(Mixer, SlowOnSwitchReplace)
}
#endif
#if !defined(PCBTARANIS)
#if !defined(VIRTUALINPUTS)
TEST(Mixer, NoTrimOnInactiveMix)
{
MODEL_RESET();
@@ -982,7 +982,7 @@ TEST(Heli, Mode2Test)
}
#endif
#if defined(HELI) && !defined(PCBTARANIS)
#if defined(HELI) && !defined(VIRTUALINPUTS)
TEST(Heli, SimpleTest)
{
MODEL_RESET();
+21 -213
View File
@@ -2,7 +2,7 @@
* Copyright (C) OpenTX
*
* Based on code named
* th9x - http://code.google.com/p/th9x
* th9x - http://code.google.com/p/th9x
* er9x - http://code.google.com/p/er9x
* gruvin9x - http://code.google.com/p/gruvin9x
*
@@ -20,7 +20,7 @@
#include "gtests.h"
#if !defined(PCBTARANIS)
#if !defined(VIRTUALINPUTS)
TEST(getSwitch, undefCSW)
{
MODEL_RESET();
@@ -45,9 +45,9 @@ TEST(getSwitch, circularCSW)
}
#endif
#if defined(PCBTARANIS)
#if defined(VIRTUALINPUTS)
void setLogicalSwitch(int index, uint16_t _func, int16_t _v1, int16_t _v2, int16_t _v3 = 0, uint8_t _delay = 0, uint8_t _duration = 0, int8_t _andsw = 0)
void setLogicalSwitch(int index, uint16_t _func, int16_t _v1, int16_t _v2, int16_t _v3 = 0, uint8_t _delay = 0, uint8_t _duration = 0, int8_t _andsw = 0)
{
g_model.logicalSw[index].func = _func;
g_model.logicalSw[index].v1 = _v1;
@@ -89,7 +89,7 @@ TEST(getSwitch, OldTypeStickyCSW)
EXPECT_EQ(getSwitch(SWSRC_SW1), false);
EXPECT_EQ(getSwitch(SWSRC_SW2), false);
}
#endif // #if defined(PCBTARANIS)
#endif // #if defined(VIRTUALINPUTS)
TEST(getSwitch, nullSW)
{
@@ -97,207 +97,6 @@ TEST(getSwitch, nullSW)
EXPECT_EQ(getSwitch(0), true);
}
#if 0
TEST(getSwitch, DISABLED_VfasWithDelay)
{
MODEL_RESET();
MIXER_RESET();
memclear(&frskyData, sizeof(frskyData));
/*
Test for logical switch:
L1 Vfas < 9.6 Delay (0.5s)
(gdb) print Open9xX9D::g_model.logicalSw[0]
$3 = {v1 = -39 '\331', v2 = 96, v3 = 0, func = 4 '\004', delay = 5 '\005', duration = 0 '\000', andsw = 0 '\000'}
*/
g_model.logicalSw[0] = {int8_t(MIXSRC_FIRST_TELEM+TELEM_VFAS-1), 96, 0, 4, 5, 0, 0};
frskyData.hub.vfas = 150; //unit is 100mV
//telemetry streaming is FALSE, so L1 should be FALSE no matter what value Vfas has
evalLogicalSwitches();
EXPECT_EQ(getSwitch(SWSRC_SW1), false);
logicalSwitchesTimerTick();
evalLogicalSwitches();
EXPECT_EQ(getSwitch(SWSRC_SW1), false);
logicalSwitchesTimerTick();
evalLogicalSwitches();
EXPECT_EQ(getSwitch(SWSRC_SW1), false);
logicalSwitchesTimerTick();
evalLogicalSwitches();
EXPECT_EQ(getSwitch(SWSRC_SW1), false);
logicalSwitchesTimerTick();
evalLogicalSwitches();
EXPECT_EQ(getSwitch(SWSRC_SW1), false);
//every logicalSwitchesTimerTick() represents 100ms
//so now after 5 ticks we should still have a FALSE value
logicalSwitchesTimerTick();
evalLogicalSwitches();
EXPECT_EQ(getSwitch(SWSRC_SW1), false);
//now turn on telemetry
EXPECT_EQ(TELEMETRY_STREAMING(), false);
TELEMETRY_RSSI() = 50;
EXPECT_EQ(TELEMETRY_STREAMING(), true);
//vfas is 15.0V so L1 should still be FALSE
logicalSwitchesTimerTick();
evalLogicalSwitches();
EXPECT_EQ(getSwitch(SWSRC_SW1), false);
logicalSwitchesTimerTick();
logicalSwitchesTimerTick();
logicalSwitchesTimerTick();
logicalSwitchesTimerTick();
logicalSwitchesTimerTick();
evalLogicalSwitches();
EXPECT_EQ(getSwitch(SWSRC_SW1), false);
//now reduce vfas to 9.5V and L1 should become TRUE after 0.5s
frskyData.hub.vfas = 95;
evalLogicalSwitches();
logicalSwitchesTimerTick();
evalLogicalSwitches();
EXPECT_EQ(getSwitch(SWSRC_SW1), false);
logicalSwitchesTimerTick();
evalLogicalSwitches();
EXPECT_EQ(getSwitch(SWSRC_SW1), false);
logicalSwitchesTimerTick();
evalLogicalSwitches();
EXPECT_EQ(getSwitch(SWSRC_SW1), false);
logicalSwitchesTimerTick();
evalLogicalSwitches();
EXPECT_EQ(getSwitch(SWSRC_SW1), false);
logicalSwitchesTimerTick();
evalLogicalSwitches();
EXPECT_EQ(getSwitch(SWSRC_SW1), true);
logicalSwitchesTimerTick();
logicalSwitchesTimerTick();
logicalSwitchesTimerTick();
logicalSwitchesTimerTick();
evalLogicalSwitches();
EXPECT_EQ(getSwitch(SWSRC_SW1), true);
//now stop telemetry, L1 should become FALSE immediatelly
TELEMETRY_RSSI() = 0;
EXPECT_EQ(TELEMETRY_STREAMING(), false);
evalLogicalSwitches();
logicalSwitchesTimerTick();
logicalSwitchesTimerTick();
logicalSwitchesTimerTick();
logicalSwitchesTimerTick();
logicalSwitchesTimerTick();
evalLogicalSwitches();
EXPECT_EQ(getSwitch(SWSRC_SW1), false);
}
TEST(getSwitch, DISABLED_RssiWithDuration)
{
MODEL_RESET();
MIXER_RESET();
memclear(&frskyData, sizeof(frskyData));
/*
Test for logical switch:
L1 RSSI > 10 Duration (0.5s)
(gdb) print Open9xX9D::g_model.logicalSw[0]
$1 = {v1 = -55 '\311', v2 = 10, v3 = 0, func = 3 '\003', delay = 0 '\000', duration = 5 '\005', andsw = 0 '\000'}
*/
g_model.logicalSw[0] = {int8_t(MIXSRC_FIRST_TELEM+TELEM_RSSI_RX-1), 10, 0, 3, 0, 5, 0};
EXPECT_EQ(TELEMETRY_STREAMING(), false);
evalLogicalSwitches();
logicalSwitchesTimerTick();
evalLogicalSwitches();
EXPECT_EQ(getSwitch(SWSRC_SW1), false);
logicalSwitchesTimerTick();
evalLogicalSwitches();
EXPECT_EQ(getSwitch(SWSRC_SW1), false);
//now set RSSI to 5, L1 should still be FALSE
TELEMETRY_RSSI() = 5;
evalLogicalSwitches();
EXPECT_EQ(TELEMETRY_STREAMING(), true);
logicalSwitchesTimerTick();
evalLogicalSwitches();
EXPECT_EQ(getSwitch(SWSRC_SW1), false);
logicalSwitchesTimerTick();
evalLogicalSwitches();
EXPECT_EQ(getSwitch(SWSRC_SW1), false);
//now set RSSI to 100, L1 should become TRUE for 0.5s
TELEMETRY_RSSI() = 100;
evalLogicalSwitches();
EXPECT_EQ(TELEMETRY_STREAMING(), true);
logicalSwitchesTimerTick();
evalLogicalSwitches();
EXPECT_EQ(getSwitch(SWSRC_SW1), true);
logicalSwitchesTimerTick();
evalLogicalSwitches();
EXPECT_EQ(getSwitch(SWSRC_SW1), true);
logicalSwitchesTimerTick();
evalLogicalSwitches();
EXPECT_EQ(getSwitch(SWSRC_SW1), true);
logicalSwitchesTimerTick();
evalLogicalSwitches();
EXPECT_EQ(getSwitch(SWSRC_SW1), true);
logicalSwitchesTimerTick();
evalLogicalSwitches();
EXPECT_EQ(getSwitch(SWSRC_SW1), false);
logicalSwitchesTimerTick();
evalLogicalSwitches();
EXPECT_EQ(getSwitch(SWSRC_SW1), false);
//repeat telemetry streaming OFF and ON to test for duration processing
TELEMETRY_RSSI() = 0;
evalLogicalSwitches();
EXPECT_EQ(TELEMETRY_STREAMING(), false);
logicalSwitchesTimerTick();
evalLogicalSwitches();
EXPECT_EQ(getSwitch(SWSRC_SW1), false);
//now set RSSI to 100, L1 should become TRUE for 0.5s
TELEMETRY_RSSI() = 100;
evalLogicalSwitches();
EXPECT_EQ(TELEMETRY_STREAMING(), true);
logicalSwitchesTimerTick();
evalLogicalSwitches();
EXPECT_EQ(getSwitch(SWSRC_SW1), true);
logicalSwitchesTimerTick();
logicalSwitchesTimerTick();
logicalSwitchesTimerTick();
logicalSwitchesTimerTick();
evalLogicalSwitches();
EXPECT_EQ(getSwitch(SWSRC_SW1), false);
}
#endif // #if defined(PCBTARANIS) && defined(FRSKY)
#if !defined(CPUARM)
TEST(getSwitch, recursiveSW)
{
@@ -329,7 +128,7 @@ TEST(getSwitch, recursiveSW)
}
#endif // #if !defined(CPUARM)
#if defined(PCBTARANIS)
#if defined(VIRTUALINPUTS)
TEST(getSwitch, inputWithTrim)
{
MODEL_RESET();
@@ -350,7 +149,7 @@ TEST(getSwitch, inputWithTrim)
}
#endif
#if defined(PCBTARANIS)
#if defined(VIRTUALINPUTS)
TEST(evalLogicalSwitches, playFile)
{
SYSTEM_RESET();
@@ -361,14 +160,23 @@ TEST(evalLogicalSwitches, playFile)
extern uint64_t sdAvailableLogicalSwitchAudioFiles;
sdAvailableLogicalSwitchAudioFiles = 0xffffffffffffffff;
char filename[AUDIO_FILENAME_MAXLEN+1];
#if defined(EEPROM)
#define MODELNAME "MODEL01"
#else
#define MODELNAME "Model00"
#endif
isAudioFileReferenced((LOGICAL_SWITCH_AUDIO_CATEGORY << 24) + (0 << 16) + AUDIO_EVENT_OFF, filename);
EXPECT_EQ(strcmp(filename, "/SOUNDS/en/MODEL01/L1-off.wav"), 0);
EXPECT_EQ(strcmp(filename, "/SOUNDS/en/" MODELNAME "/L1-off.wav"), 0);
isAudioFileReferenced((LOGICAL_SWITCH_AUDIO_CATEGORY << 24) + (0 << 16) + AUDIO_EVENT_ON, filename);
EXPECT_EQ(strcmp(filename, "/SOUNDS/en/MODEL01/L1-on.wav"), 0);
EXPECT_EQ(strcmp(filename, "/SOUNDS/en/" MODELNAME "/L1-on.wav"), 0);
isAudioFileReferenced((LOGICAL_SWITCH_AUDIO_CATEGORY << 24) + (31 << 16) + AUDIO_EVENT_OFF, filename);
EXPECT_EQ(strcmp(filename, "/SOUNDS/en/MODEL01/L32-off.wav"), 0);
EXPECT_EQ(strcmp(filename, "/SOUNDS/en/" MODELNAME "/L32-off.wav"), 0);
isAudioFileReferenced((LOGICAL_SWITCH_AUDIO_CATEGORY << 24) + (31 << 16) + AUDIO_EVENT_ON, filename);
EXPECT_EQ(strcmp(filename, "/SOUNDS/en/MODEL01/L32-on.wav"), 0);
EXPECT_EQ(strcmp(filename, "/SOUNDS/en/" MODELNAME "/L32-on.wav"), 0);
#undef MODELNAME
}
TEST(getSwitch, edgeInstant)
@@ -443,7 +251,7 @@ TEST(getSwitch, edgeInstant)
EXPECT_EQ(getSwitch(SWSRC_SW1), false);
EXPECT_EQ(getSwitch(SWSRC_SW2), false);
// now bug #2939
// now bug #2939
// SF is kept up and SA is toggled
simuSetSwitch(0, -1); //SA down
simuSetSwitch(5, 1); //SF up