Add test cases to validate state of physical LED
This commit adds code that verifies the state of
physical LED is appropriately set in various cases
Change-Id: I9eab752f6f2b47e719934c14ef95e775d36bcaa0
Signed-off-by: Vishwanatha Subbanna <vishwa@linux.vnet.ibm.com>
diff --git a/test/physical.cpp b/test/physical.cpp
index 10dc9b7..c53a14a 100644
--- a/test/physical.cpp
+++ b/test/physical.cpp
@@ -77,6 +77,7 @@
NiceMock<MockLed> led;
ON_CALL(led, getTrigger()).WillByDefault(Return("none"));
phosphor::led::Physical phy(bus, LED_OBJ, led);
+ EXPECT_EQ(phy.state(), Action::Off);
}
TEST(Physical, ctor_timer_trigger)
@@ -87,6 +88,7 @@
EXPECT_CALL(led, getDelayOn()).WillOnce(Return(500));
EXPECT_CALL(led, getDelayOff()).WillOnce(Return(500));
phosphor::led::Physical phy(bus, LED_OBJ, led);
+ EXPECT_EQ(phy.state(), Action::Off);
}
TEST(Physical, off)
@@ -99,6 +101,7 @@
EXPECT_CALL(led, setBrightness(phosphor::led::DEASSERT)).Times(0);
phosphor::led::Physical phy(bus, LED_OBJ, led);
phy.state(Action::Off);
+ EXPECT_EQ(phy.state(), Action::Off);
}
TEST(Physical, on)
@@ -113,6 +116,7 @@
EXPECT_CALL(led, setBrightness(asserted));
phosphor::led::Physical phy(bus, LED_OBJ, led);
phy.state(Action::On);
+ EXPECT_EQ(phy.state(), Action::On);
}
TEST(Physical, blink)
@@ -125,6 +129,7 @@
EXPECT_CALL(led, setDelayOff(500));
phosphor::led::Physical phy(bus, LED_OBJ, led);
phy.state(Action::Blink);
+ EXPECT_EQ(phy.state(), Action::Blink);
}
TEST(Physical, ctor_none_trigger_asserted_brightness)
@@ -134,6 +139,7 @@
EXPECT_CALL(led, getTrigger()).WillRepeatedly(Return("none"));
EXPECT_CALL(led, getBrightness()).WillRepeatedly(Return(127));
phosphor::led::Physical phy(bus, LED_OBJ, led);
+ EXPECT_EQ(phy.state(), Action::Off);
}
TEST(Physical, on_to_off)
@@ -151,5 +157,7 @@
EXPECT_CALL(led, setBrightness(deasserted));
phosphor::led::Physical phy(bus, LED_OBJ, led);
phy.state(Action::On);
+ EXPECT_EQ(phy.state(), Action::On);
phy.state(Action::Off);
+ EXPECT_EQ(phy.state(), Action::Off);
}