test: Add test cases to cover brightness and asserted values
This commit adds test cases that will validate:
┌────────────┬──────────┬────────────────────────┐
│ brightness │ asserted │ brightness && asserted │
├────────────┼──────────┼────────────────────────┤
│ 0 │ 0 │ 0 │
│ 0 │ 1 │ 0 │
│ 1 │ 0 │ 0 │
│ 1 │ 1 │ 1 │
└────────────┴──────────┴────────────────────────┘
where:
getMaxBrightness() would map to asserted value
getBrightness() would map to brightness value
Change-Id: Iac2373e61614750e2f2879da46973ff1ab06213b
Signed-off-by: Vishwanatha Subbanna <vishwa@linux.vnet.ibm.com>
diff --git a/test/physical.cpp b/test/physical.cpp
index c53a14a..c91fb94 100644
--- a/test/physical.cpp
+++ b/test/physical.cpp
@@ -80,6 +80,54 @@
EXPECT_EQ(phy.state(), Action::Off);
}
+TEST(Physical, ctor_maxbrightness_and_brightness_read_127)
+{
+ sdbusplus::bus::bus bus = sdbusplus::bus::new_default();
+ /* NiceMock ignores calls to methods with no expectations defined */
+ NiceMock<MockLed> led;
+ EXPECT_CALL(led, getTrigger()).WillRepeatedly(Return("none"));
+ EXPECT_CALL(led, getBrightness()).WillOnce(Return(127));
+ EXPECT_CALL(led, getMaxBrightness()).WillOnce(Return(127));
+ phosphor::led::Physical phy(bus, LED_OBJ, led);
+ EXPECT_EQ(phy.state(), Action::On);
+}
+
+TEST(Physical, ctor_maxbrightness_and_brightness_read_0)
+{
+ sdbusplus::bus::bus bus = sdbusplus::bus::new_default();
+ /* NiceMock ignores calls to methods with no expectations defined */
+ NiceMock<MockLed> led;
+ EXPECT_CALL(led, getTrigger()).WillRepeatedly(Return("none"));
+ EXPECT_CALL(led, getBrightness()).WillOnce(Return(0));
+ EXPECT_CALL(led, getMaxBrightness()).WillOnce(Return(0));
+ phosphor::led::Physical phy(bus, LED_OBJ, led);
+ EXPECT_EQ(phy.state(), Action::Off);
+}
+
+TEST(Physical, ctor_only_maxbrightness_read_127)
+{
+ sdbusplus::bus::bus bus = sdbusplus::bus::new_default();
+ /* NiceMock ignores calls to methods with no expectations defined */
+ NiceMock<MockLed> led;
+ EXPECT_CALL(led, getTrigger()).WillRepeatedly(Return("none"));
+ EXPECT_CALL(led, getBrightness()).WillOnce(Return(0));
+ EXPECT_CALL(led, getMaxBrightness()).WillOnce(Return(127));
+ phosphor::led::Physical phy(bus, LED_OBJ, led);
+ EXPECT_EQ(phy.state(), Action::Off);
+}
+
+TEST(Physical, ctor_only_brightness_read_127)
+{
+ sdbusplus::bus::bus bus = sdbusplus::bus::new_default();
+ /* NiceMock ignores calls to methods with no expectations defined */
+ NiceMock<MockLed> led;
+ EXPECT_CALL(led, getTrigger()).WillRepeatedly(Return("none"));
+ EXPECT_CALL(led, getBrightness()).WillOnce(Return(127));
+ EXPECT_CALL(led, getMaxBrightness()).WillOnce(Return(0));
+ phosphor::led::Physical phy(bus, LED_OBJ, led);
+ EXPECT_EQ(phy.state(), Action::Off);
+}
+
TEST(Physical, ctor_timer_trigger)
{
sdbusplus::bus::bus bus = sdbusplus::bus::new_default();