Add time Manager to handle property changes callback
1. Implement time::Manager who registers property change signal for time
mode and owner;
2. Add PropertyChangeListner interface to handle the callback;
3. Make EpochBase to implement the interface.
Change-Id: I185580ae37353e1ed82a47e4905fb22e269ac09d
Signed-off-by: Lei YU <mine260309@gmail.com>
diff --git a/test/TestManager.cpp b/test/TestManager.cpp
new file mode 100644
index 0000000..4d9ae73
--- /dev/null
+++ b/test/TestManager.cpp
@@ -0,0 +1,76 @@
+#include <sdbusplus/bus.hpp>
+#include <gtest/gtest.h>
+
+#include "types.hpp"
+#include "manager.hpp"
+
+namespace phosphor
+{
+namespace time
+{
+
+class TestManager : public testing::Test
+{
+ public:
+ sdbusplus::bus::bus bus;
+ Manager manager;
+
+ TestManager()
+ : bus(sdbusplus::bus::new_default()),
+ manager(bus)
+ {
+ // Empty
+ }
+
+ // Proxies for Manager's private members and functions
+ Mode getTimeMode()
+ {
+ return manager.timeMode;
+ }
+ Owner getTimeOwner()
+ {
+ return manager.timeOwner;
+ }
+ Mode convertToMode(const std::string& mode)
+ {
+ return Manager::convertToMode(mode);
+ }
+ Owner convertToOwner(const std::string& owner)
+ {
+ return Manager::convertToOwner(owner);
+ }
+};
+
+TEST_F(TestManager, empty)
+{
+ EXPECT_EQ(Mode::NTP, getTimeMode());
+ EXPECT_EQ(Owner::BMC, getTimeOwner());
+}
+
+TEST_F(TestManager, convertToMode)
+{
+ EXPECT_EQ(Mode::NTP, convertToMode("NTP"));
+ EXPECT_EQ(Mode::MANUAL, convertToMode("MANUAL"));
+
+ // All unrecognized strings are mapped to Ntp
+ EXPECT_EQ(Mode::NTP, convertToMode(""));
+ EXPECT_EQ(Mode::NTP, convertToMode("Manual"));
+ EXPECT_EQ(Mode::NTP, convertToMode("whatever"));
+}
+
+
+TEST_F(TestManager, convertToOwner)
+{
+ EXPECT_EQ(Owner::BMC, convertToOwner("BMC"));
+ EXPECT_EQ(Owner::HOST, convertToOwner("HOST"));
+ EXPECT_EQ(Owner::SPLIT, convertToOwner("SPLIT"));
+ EXPECT_EQ(Owner::BOTH, convertToOwner("BOTH"));
+
+ // All unrecognized strings are mapped to Bmc
+ EXPECT_EQ(Owner::BMC, convertToOwner(""));
+ EXPECT_EQ(Owner::BMC, convertToOwner("Split"));
+ EXPECT_EQ(Owner::BMC, convertToOwner("xyz"));
+}
+
+}
+}