summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew Jeffery <andrew@aj.id.au>2018-05-25 14:05:40 +0930
committerAndrew Jeffery <andrew@aj.id.au>2019-04-08 13:48:50 +0930
commitaee9c2c452db3ce43df62a0ac779fda6e65a64ca (patch)
tree269aec8ff8534e9fe291a08e8a6b71ecd4d91c24
parent04275e06d2aab6a5e13807e0a295d3b48a979118 (diff)
downloadphosphor-led-sysfs-aee9c2c452db3ce43df62a0ac779fda6e65a64ca.zip
phosphor-led-sysfs-aee9c2c452db3ce43df62a0ac779fda6e65a64ca.tar.gz
test: physical: Hit both branches of stableStateOperation()
Change-Id: Ic32d87dbe996a03e811e1be88fbcc00bf450e1f3 Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
-rw-r--r--physical.hpp4
-rw-r--r--test/physical.cpp18
2 files changed, 20 insertions, 2 deletions
diff --git a/physical.hpp b/physical.hpp
index c8ef4fd..3d99066 100644
--- a/physical.hpp
+++ b/physical.hpp
@@ -13,10 +13,10 @@ namespace phosphor
namespace led
{
/** @brief Assert LED by writing 255 */
-constexpr auto ASSERT = 255;
+constexpr unsigned long ASSERT = 255;
/** @brief De-assert by writing "0" */
-constexpr auto DEASSERT = 0;
+constexpr unsigned long DEASSERT = 0;
/** @class Physical
* @brief Responsible for applying actions on a particular physical LED
diff --git a/test/physical.cpp b/test/physical.cpp
index 9312598..f62caa2 100644
--- a/test/physical.cpp
+++ b/test/physical.cpp
@@ -66,6 +66,7 @@ class MockLed : public phosphor::led::SysfsLed
MOCK_METHOD1(setDelayOff, void(unsigned long ms));
};
+using ::testing::InSequence;
using ::testing::NiceMock;
using ::testing::Return;
using ::testing::Throw;
@@ -125,3 +126,20 @@ TEST(Physical, ctor_none_trigger_asserted_brightness)
EXPECT_CALL(led, getBrightness()).WillRepeatedly(Return(val));
phosphor::led::Physical phy(bus, LED_OBJ, led);
}
+
+TEST(Physical, on_to_off)
+{
+ InSequence s;
+
+ auto bus = sdbusplus::bus::new_default();
+ NiceMock<MockLed> led;
+ EXPECT_CALL(led, getTrigger()).Times(1).WillOnce(Return("none"));
+ constexpr auto deasserted = phosphor::led::DEASSERT;
+ EXPECT_CALL(led, getBrightness()).WillOnce(Return(deasserted));
+ constexpr auto asserted = phosphor::led::ASSERT;
+ EXPECT_CALL(led, setBrightness(asserted));
+ EXPECT_CALL(led, setBrightness(deasserted));
+ phosphor::led::Physical phy(bus, LED_OBJ, led);
+ phy.state(Action::On);
+ phy.state(Action::Off);
+}
OpenPOWER on IntegriCloud