diff --git a/src/test/unit/osd_unittest.cc b/src/test/unit/osd_unittest.cc index f45005fc4a..def9532ea0 100644 --- a/src/test/unit/osd_unittest.cc +++ b/src/test/unit/osd_unittest.cc @@ -604,6 +604,68 @@ TEST(OsdTest, TestElementMahDrawn) displayPortTestBufferSubstring(1, 11, "1042%c", SYM_MAH); } +/* + * Tests the instantaneous electrical power OSD element. + */ +TEST(OsdTest, TestElementPower) +{ + // given + osdConfigMutable()->item_pos[OSD_POWER] = OSD_POS(1, 10) | VISIBLE_FLAG; + + // and + simulationBatteryVoltage = 100; // 10V + + // and + simulationBatteryAmperage = 0; + + // when + displayClearScreen(&testDisplayPort); + osdRefresh(simulationTime); + + // then + displayPortTestBufferSubstring(1, 10, "0W"); + + // given + simulationBatteryAmperage = 10; // 0.1AA + + // when + displayClearScreen(&testDisplayPort); + osdRefresh(simulationTime); + + // then + displayPortTestBufferSubstring(1, 10, "1W"); + + // given + simulationBatteryAmperage = 120; // 1.2A + + // when + displayClearScreen(&testDisplayPort); + osdRefresh(simulationTime); + + // then + displayPortTestBufferSubstring(1, 10, "12W"); + + // given + simulationBatteryAmperage = 1230; // 12.3A + + // when + displayClearScreen(&testDisplayPort); + osdRefresh(simulationTime); + + // then + displayPortTestBufferSubstring(1, 10, "123W"); + + // given + simulationBatteryAmperage = 12340; // 123.4A + + // when + displayClearScreen(&testDisplayPort); + osdRefresh(simulationTime); + + // then + displayPortTestBufferSubstring(1, 10, "1234W"); +} + /* * Tests the altitude OSD element. */