blob: b193969ee99cf78bac678057810e44e9bb515b08 [file] [log] [blame]
Lei YU2f9c0cc2017-01-20 14:02:03 +08001#include "epoch_base.hpp"
Gunnar Millsab4cc6a2018-09-14 14:42:39 -05002#include "types.hpp"
3
4#include <sdbusplus/bus.hpp>
5
6#include <gtest/gtest.h>
Lei YU2f9c0cc2017-01-20 14:02:03 +08007
8namespace phosphor
9{
10namespace time
11{
12
13class TestEpochBase : public testing::Test
14{
Gunnar Millsab4cc6a2018-09-14 14:42:39 -050015 public:
16 sdbusplus::bus::bus bus;
17 EpochBase epochBase;
Lei YU2f9c0cc2017-01-20 14:02:03 +080018
Gunnar Millsab4cc6a2018-09-14 14:42:39 -050019 TestEpochBase() : bus(sdbusplus::bus::new_default()), epochBase(bus, "")
20 {
21 // Empty
22 }
Lei YU2f9c0cc2017-01-20 14:02:03 +080023
Gunnar Millsab4cc6a2018-09-14 14:42:39 -050024 Mode getMode()
25 {
26 return epochBase.timeMode;
27 }
28 Owner getOwner()
29 {
30 return epochBase.timeOwner;
31 }
Lei YU2f9c0cc2017-01-20 14:02:03 +080032};
33
Lei YU415b9642017-02-09 11:37:26 +080034TEST_F(TestEpochBase, onModeChange)
Lei YU2f9c0cc2017-01-20 14:02:03 +080035{
Lei YU415b9642017-02-09 11:37:26 +080036 epochBase.onModeChanged(Mode::NTP);
37 EXPECT_EQ(Mode::NTP, getMode());
Lei YU2f9c0cc2017-01-20 14:02:03 +080038
Lei YUad143542017-07-25 14:27:07 +080039 epochBase.onModeChanged(Mode::Manual);
40 EXPECT_EQ(Mode::Manual, getMode());
Lei YU2f9c0cc2017-01-20 14:02:03 +080041}
42
Lei YU415b9642017-02-09 11:37:26 +080043TEST_F(TestEpochBase, onOwnerChange)
Lei YU2f9c0cc2017-01-20 14:02:03 +080044{
Lei YU415b9642017-02-09 11:37:26 +080045 epochBase.onOwnerChanged(Owner::BMC);
46 EXPECT_EQ(Owner::BMC, getOwner());
Lei YU2f9c0cc2017-01-20 14:02:03 +080047
Lei YUad143542017-07-25 14:27:07 +080048 epochBase.onOwnerChanged(Owner::Host);
49 EXPECT_EQ(Owner::Host, getOwner());
Lei YU415b9642017-02-09 11:37:26 +080050
Lei YUad143542017-07-25 14:27:07 +080051 epochBase.onOwnerChanged(Owner::Split);
52 EXPECT_EQ(Owner::Split, getOwner());
Lei YU415b9642017-02-09 11:37:26 +080053
Lei YUad143542017-07-25 14:27:07 +080054 epochBase.onOwnerChanged(Owner::Both);
55 EXPECT_EQ(Owner::Both, getOwner());
Lei YU2f9c0cc2017-01-20 14:02:03 +080056}
57
Gunnar Millsab4cc6a2018-09-14 14:42:39 -050058} // namespace time
59} // namespace phosphor