Andrew Jeffery | a607a0d | 2018-05-23 16:15:26 +0930 | [diff] [blame] | 1 | #include "physical.hpp" |
| 2 | |
| 3 | #include <sdbusplus/bus.hpp> |
| 4 | |
| 5 | #include <gtest/gtest.h> |
| 6 | |
| 7 | constexpr auto LED_OBJ = "/foo/bar/led"; |
| 8 | constexpr auto LED_SYSFS = "/sys/class/leds/test"; |
| 9 | |
| 10 | using Action = sdbusplus::xyz::openbmc_project::Led::server::Physical::Action; |
Andrew Jeffery | 42e02d3 | 2018-05-24 13:34:05 +0930 | [diff] [blame^] | 11 | namespace fs = std::experimental::filesystem; |
Andrew Jeffery | a607a0d | 2018-05-23 16:15:26 +0930 | [diff] [blame] | 12 | |
| 13 | TEST(Physical, ctor) |
| 14 | { |
| 15 | sdbusplus::bus::bus bus = sdbusplus::bus::new_default(); |
Andrew Jeffery | 42e02d3 | 2018-05-24 13:34:05 +0930 | [diff] [blame^] | 16 | phosphor::led::SysfsLed led{fs::path(LED_SYSFS)}; |
| 17 | phosphor::led::Physical phy(bus, LED_OBJ, led); |
Andrew Jeffery | a607a0d | 2018-05-23 16:15:26 +0930 | [diff] [blame] | 18 | } |
| 19 | |
| 20 | TEST(Physical, off) |
| 21 | { |
| 22 | sdbusplus::bus::bus bus = sdbusplus::bus::new_default(); |
Andrew Jeffery | 42e02d3 | 2018-05-24 13:34:05 +0930 | [diff] [blame^] | 23 | phosphor::led::SysfsLed led{fs::path(LED_SYSFS)}; |
| 24 | phosphor::led::Physical phy(bus, LED_OBJ, led); |
| 25 | phy.state(Action::Off); |
Andrew Jeffery | a607a0d | 2018-05-23 16:15:26 +0930 | [diff] [blame] | 26 | } |
| 27 | |
| 28 | TEST(Physical, on) |
| 29 | { |
| 30 | sdbusplus::bus::bus bus = sdbusplus::bus::new_default(); |
Andrew Jeffery | 42e02d3 | 2018-05-24 13:34:05 +0930 | [diff] [blame^] | 31 | phosphor::led::SysfsLed led{fs::path(LED_SYSFS)}; |
| 32 | phosphor::led::Physical phy(bus, LED_OBJ, led); |
| 33 | phy.state(Action::On); |
Andrew Jeffery | a607a0d | 2018-05-23 16:15:26 +0930 | [diff] [blame] | 34 | } |
| 35 | |
| 36 | TEST(Physical, blink) |
| 37 | { |
| 38 | sdbusplus::bus::bus bus = sdbusplus::bus::new_default(); |
Andrew Jeffery | 42e02d3 | 2018-05-24 13:34:05 +0930 | [diff] [blame^] | 39 | phosphor::led::SysfsLed led{fs::path(LED_SYSFS)}; |
| 40 | phosphor::led::Physical phy(bus, LED_OBJ, led); |
| 41 | phy.state(Action::Blink); |
Andrew Jeffery | a607a0d | 2018-05-23 16:15:26 +0930 | [diff] [blame] | 42 | } |