blob: 4316b16a6147767232869d16064022f4b5f47afc [file] [log] [blame]
Andrew Jefferya607a0d2018-05-23 16:15:26 +09301#include "physical.hpp"
2
3#include <sdbusplus/bus.hpp>
4
5#include <gtest/gtest.h>
6
7constexpr auto LED_OBJ = "/foo/bar/led";
8constexpr auto LED_SYSFS = "/sys/class/leds/test";
9
10using Action = sdbusplus::xyz::openbmc_project::Led::server::Physical::Action;
Andrew Jeffery42e02d32018-05-24 13:34:05 +093011namespace fs = std::experimental::filesystem;
Andrew Jefferya607a0d2018-05-23 16:15:26 +093012
13TEST(Physical, ctor)
14{
15 sdbusplus::bus::bus bus = sdbusplus::bus::new_default();
Andrew Jeffery42e02d32018-05-24 13:34:05 +093016 phosphor::led::SysfsLed led{fs::path(LED_SYSFS)};
17 phosphor::led::Physical phy(bus, LED_OBJ, led);
Andrew Jefferya607a0d2018-05-23 16:15:26 +093018}
19
20TEST(Physical, off)
21{
22 sdbusplus::bus::bus bus = sdbusplus::bus::new_default();
Andrew Jeffery42e02d32018-05-24 13:34:05 +093023 phosphor::led::SysfsLed led{fs::path(LED_SYSFS)};
24 phosphor::led::Physical phy(bus, LED_OBJ, led);
25 phy.state(Action::Off);
Andrew Jefferya607a0d2018-05-23 16:15:26 +093026}
27
28TEST(Physical, on)
29{
30 sdbusplus::bus::bus bus = sdbusplus::bus::new_default();
Andrew Jeffery42e02d32018-05-24 13:34:05 +093031 phosphor::led::SysfsLed led{fs::path(LED_SYSFS)};
32 phosphor::led::Physical phy(bus, LED_OBJ, led);
33 phy.state(Action::On);
Andrew Jefferya607a0d2018-05-23 16:15:26 +093034}
35
36TEST(Physical, blink)
37{
38 sdbusplus::bus::bus bus = sdbusplus::bus::new_default();
Andrew Jeffery42e02d32018-05-24 13:34:05 +093039 phosphor::led::SysfsLed led{fs::path(LED_SYSFS)};
40 phosphor::led::Physical phy(bus, LED_OBJ, led);
41 phy.state(Action::Blink);
Andrew Jefferya607a0d2018-05-23 16:15:26 +093042}