From 8a1ba09ee825d160ce2f1d00877d4ba9f0ee4ebd Mon Sep 17 00:00:00 2001 From: Dan Nixon Date: Sun, 10 Sep 2017 15:20:11 +0100 Subject: [PATCH] Test rendering of existing OSD power element --- src/test/unit/osd_unittest.cc | 62 +++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) 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. */