blob: a43254786f8f3d9b40e7f551a978481e6362be50 [file] [log] [blame]
Alexander Hanseneb1f46a2024-07-30 16:09:07 +02001#include "group.hpp"
2#include "ledlayout.hpp"
3#include "manager.hpp"
4#include "test-led-priority.hpp"
5
6#include <sdbusplus/bus.hpp>
7
8#include <algorithm>
9#include <set>
10
11#include <gtest/gtest.h>
12
13using namespace phosphor::led;
14
15using Action = phosphor::led::Layout::Action;
16
17// systemLedMap is generated code
18// static const phosphor::led::GroupMap systemLedMap = {};
19
20const std::string basePath = "/xyz/openbmc_project/led/groups/";
21
22TEST(YamlLedPriorityTest, assertPriorityOn)
23{
24 const std::string groupPath = basePath + "group1";
25 EXPECT_EQ(systemLedMap.contains(groupPath), true);
26
27 phosphor::led::Layout::GroupLayout group = systemLedMap.at(groupPath);
28
29 EXPECT_EQ(group.priority, 0);
30 EXPECT_EQ(group.actionSet.size(), 1);
31
George Liu3d487512024-08-23 09:19:57 +080032 for (const auto& led : group.actionSet)
Alexander Hanseneb1f46a2024-07-30 16:09:07 +020033 {
34 EXPECT_EQ(led.name, "led1");
35 EXPECT_EQ(led.action, Action::On);
36 EXPECT_EQ(led.priority, Action::On);
37 }
38}
39
40TEST(YamlLedPriorityTest, assertPriorityOff)
41{
42 const std::string groupPath = basePath + "group2";
43 EXPECT_EQ(systemLedMap.contains(groupPath), true);
44
45 phosphor::led::Layout::GroupLayout group = systemLedMap.at(groupPath);
46
47 EXPECT_EQ(group.priority, 0);
48 EXPECT_EQ(group.actionSet.size(), 1);
49
George Liu3d487512024-08-23 09:19:57 +080050 for (const auto& led : group.actionSet)
Alexander Hanseneb1f46a2024-07-30 16:09:07 +020051 {
52 EXPECT_EQ(led.name, "led2");
53 EXPECT_EQ(led.action, Action::Off);
54 EXPECT_EQ(led.priority, Action::Off);
55 }
56}
57
58TEST(YamlLedPriorityTest, assertPriorityBlink)
59{
60 const std::string groupPath = basePath + "group3";
61 EXPECT_EQ(systemLedMap.contains(groupPath), true);
62
63 phosphor::led::Layout::GroupLayout group = systemLedMap.at(groupPath);
64
65 EXPECT_EQ(group.priority, 0);
66 EXPECT_EQ(group.actionSet.size(), 1);
67
George Liu3d487512024-08-23 09:19:57 +080068 for (const auto& led : group.actionSet)
Alexander Hanseneb1f46a2024-07-30 16:09:07 +020069 {
70 EXPECT_EQ(led.name, "led3");
71 EXPECT_EQ(led.action, Action::Blink);
72 EXPECT_EQ(led.priority, Action::Blink);
73 }
74}