mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-26 09:45:37 +03:00
WIP: Unit test for OSD Sats element
This commit is contained in:
parent
c56d81457f
commit
561b15be70
1 changed files with 43 additions and 1 deletions
|
@ -104,6 +104,7 @@ extern "C" {
|
||||||
int32_t simulationAltitude;
|
int32_t simulationAltitude;
|
||||||
int32_t simulationVerticalSpeed;
|
int32_t simulationVerticalSpeed;
|
||||||
uint16_t simulationCoreTemperature;
|
uint16_t simulationCoreTemperature;
|
||||||
|
bool simulationGpsHealthy;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t simulationFeatureFlags = FEATURE_GPS;
|
uint32_t simulationFeatureFlags = FEATURE_GPS;
|
||||||
|
@ -130,6 +131,7 @@ void setDefaultSimulationState()
|
||||||
simulationAltitude = 0;
|
simulationAltitude = 0;
|
||||||
simulationVerticalSpeed = 0;
|
simulationVerticalSpeed = 0;
|
||||||
simulationCoreTemperature = 0;
|
simulationCoreTemperature = 0;
|
||||||
|
simulationGpsHealthy = false;
|
||||||
|
|
||||||
rcData[PITCH] = 1500;
|
rcData[PITCH] = 1500;
|
||||||
|
|
||||||
|
@ -1134,6 +1136,46 @@ TEST_F(OsdTest, TestConvertTemperatureUnits)
|
||||||
EXPECT_EQ(osdConvertTemperatureToSelectedUnit(41), 106);
|
EXPECT_EQ(osdConvertTemperatureToSelectedUnit(41), 106);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_F(OsdTest, TestGpsElements)
|
||||||
|
{
|
||||||
|
// given
|
||||||
|
osdElementConfigMutable()->item_pos[OSD_GPS_SATS] = OSD_POS(2, 4) | OSD_PROFILE_1_FLAG;
|
||||||
|
|
||||||
|
sensorsSet(SENSOR_GPS);
|
||||||
|
osdAnalyzeActiveElements();
|
||||||
|
|
||||||
|
// when
|
||||||
|
simulationGpsHealthy = false;
|
||||||
|
gpsSol.numSat = 0;
|
||||||
|
|
||||||
|
displayClearScreen(&testDisplayPort);
|
||||||
|
osdRefresh(simulationTime);
|
||||||
|
|
||||||
|
// then
|
||||||
|
displayPortTestBufferSubstring(2, 4, "%c%cNC", SYM_SAT_L, SYM_SAT_R);
|
||||||
|
|
||||||
|
// when
|
||||||
|
simulationGpsHealthy = true;
|
||||||
|
gpsSol.numSat = 0;
|
||||||
|
|
||||||
|
displayClearScreen(&testDisplayPort);
|
||||||
|
osdRefresh(simulationTime);
|
||||||
|
|
||||||
|
// then
|
||||||
|
displayPortTestBufferSubstring(2, 4, "%c%c%2d", SYM_SAT_L, SYM_SAT_R, 0);
|
||||||
|
|
||||||
|
// when
|
||||||
|
simulationGpsHealthy = true;
|
||||||
|
gpsSol.numSat = 10;
|
||||||
|
|
||||||
|
displayClearScreen(&testDisplayPort);
|
||||||
|
osdRefresh(simulationTime);
|
||||||
|
|
||||||
|
// then
|
||||||
|
displayPortTestBufferSubstring(2, 4, "%c%c%2d", SYM_SAT_L, SYM_SAT_R, 10);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
// STUBS
|
// STUBS
|
||||||
extern "C" {
|
extern "C" {
|
||||||
bool featureIsEnabled(uint32_t f) { return simulationFeatureFlags & f; }
|
bool featureIsEnabled(uint32_t f) { return simulationFeatureFlags & f; }
|
||||||
|
@ -1242,7 +1284,7 @@ extern "C" {
|
||||||
bool pidOsdAntiGravityActive(void) { return false; }
|
bool pidOsdAntiGravityActive(void) { return false; }
|
||||||
bool failsafeIsActive(void) { return false; }
|
bool failsafeIsActive(void) { return false; }
|
||||||
bool gpsRescueIsConfigured(void) { return false; }
|
bool gpsRescueIsConfigured(void) { return false; }
|
||||||
bool gpsIsHealthy(void) { return true; }
|
bool gpsIsHealthy(void) { return simulationGpsHealthy; }
|
||||||
int8_t calculateThrottlePercent(void) { return 0; }
|
int8_t calculateThrottlePercent(void) { return 0; }
|
||||||
uint32_t persistentObjectRead(persistentObjectId_e) { return 0; }
|
uint32_t persistentObjectRead(persistentObjectId_e) { return 0; }
|
||||||
void persistentObjectWrite(persistentObjectId_e, uint32_t) {}
|
void persistentObjectWrite(persistentObjectId_e, uint32_t) {}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue