summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew Jeffery <andrew@aj.id.au>2018-05-25 11:41:43 +0930
committerAndrew Jeffery <andrew@aj.id.au>2019-04-08 13:48:50 +0930
commit56692708507e58e889c97123578b376dd84399d9 (patch)
tree41384a03bbaaeda064f3f615e727f44f731a9cf2
parent280afaf32b33ece0ab22ab25ed76e67a9600f92b (diff)
downloadphosphor-led-sysfs-56692708507e58e889c97123578b376dd84399d9.zip
phosphor-led-sysfs-56692708507e58e889c97123578b376dd84399d9.tar.gz
test: physical: Cover trigger:timer branch in setInitialState()
The test causes execution to take the following path in setInitialState(), previously outlined in 264d909d3dc9 ("test: Add tests for Physical class") as being missed: auto trigger = led.getTrigger(); if (trigger == "timer") { // LED is blinking. Get the delay_on and delay_off and compute // DutyCycle. sfsfs values are in strings. Need to convert 'em over to // integer. auto delayOn = led.getDelayOn(); auto delayOff = led.getDelayOff(); // Calculate frequency and then percentage ON frequency = delayOn + delayOff; auto factor = frequency / 100; auto dutyOn = delayOn / factor; // Update. this->dutyOn(dutyOn); } This brings the line coverage to 96.6% (function coverage remains unchanged by this patch). Change-Id: Ie311186f6275d3fdd31de5698c7c14bb335128e1 Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
-rw-r--r--test/physical.cpp12
1 files changed, 11 insertions, 1 deletions
diff --git a/test/physical.cpp b/test/physical.cpp
index 1b546ed..897a43f 100644
--- a/test/physical.cpp
+++ b/test/physical.cpp
@@ -70,7 +70,7 @@ using ::testing::NiceMock;
using ::testing::Return;
using ::testing::Throw;
-TEST(Physical, ctor)
+TEST(Physical, ctor_none_trigger)
{
sdbusplus::bus::bus bus = sdbusplus::bus::new_default();
/* NiceMock ignores calls to methods with no expectations defined */
@@ -79,6 +79,16 @@ TEST(Physical, ctor)
phosphor::led::Physical phy(bus, LED_OBJ, led);
}
+TEST(Physical, ctor_timer_trigger)
+{
+ sdbusplus::bus::bus bus = sdbusplus::bus::new_default();
+ NiceMock<MockLed> led;
+ EXPECT_CALL(led, getTrigger()).WillOnce(Return("timer"));
+ EXPECT_CALL(led, getDelayOn()).WillOnce(Return(500));
+ EXPECT_CALL(led, getDelayOff()).WillOnce(Return(500));
+ phosphor::led::Physical phy(bus, LED_OBJ, led);
+}
+
TEST(Physical, off)
{
sdbusplus::bus::bus bus = sdbusplus::bus::new_default();
OpenPOWER on IntegriCloud