blob: b1cf4ecb272dd738d771499e8cc256e0aa23e023 [file] [log] [blame]
Lei YU415b9642017-02-09 11:37:26 +08001#include "manager.hpp"
Lei YUa5003ce2017-02-24 15:35:25 +08002#include "mocked_property_change_listener.hpp"
Gunnar Millsab4cc6a2018-09-14 14:42:39 -05003#include "types.hpp"
4
5#include <sdbusplus/bus.hpp>
6
7#include <gtest/gtest.h>
Lei YUa5003ce2017-02-24 15:35:25 +08008
9using ::testing::_;
Lei YU415b9642017-02-09 11:37:26 +080010
11namespace phosphor
12{
13namespace time
14{
15
16class TestManager : public testing::Test
17{
Gunnar Millsab4cc6a2018-09-14 14:42:39 -050018 public:
19 sdbusplus::bus::bus bus;
20 Manager manager;
Lei YU415b9642017-02-09 11:37:26 +080021
Gunnar Millsab4cc6a2018-09-14 14:42:39 -050022 TestManager() : bus(sdbusplus::bus::new_default()), manager(bus)
23 {
Gunnar Millsab4cc6a2018-09-14 14:42:39 -050024 }
Lei YU415b9642017-02-09 11:37:26 +080025
Gunnar Millsab4cc6a2018-09-14 14:42:39 -050026 // Proxies for Manager's private members and functions
27 Mode getTimeMode()
28 {
29 return manager.timeMode;
30 }
Gunnar Millsab4cc6a2018-09-14 14:42:39 -050031 void notifyPropertyChanged(const std::string& key, const std::string& value)
32 {
33 manager.onPropertyChanged(key, value);
34 }
Lei YU415b9642017-02-09 11:37:26 +080035};
36
Lei YUddd54422017-04-18 16:38:44 +080037TEST_F(TestManager, DISABLED_propertyChanged)
Lei YU7f4fca52017-02-23 15:15:51 +080038{
Lei YUad143542017-07-25 14:27:07 +080039 notifyPropertyChanged(
Lei YU710d49b2017-08-01 17:10:17 +080040 "TimeSyncMethod",
Lei YUad143542017-07-25 14:27:07 +080041 "xyz.openbmc_project.Time.Synchronization.Method.Manual");
George Liu0a704522020-04-13 14:51:40 +080042 EXPECT_EQ(Mode::Manual, getTimeMode());
Lei YUa5003ce2017-02-24 15:35:25 +080043
Lei YUad143542017-07-25 14:27:07 +080044 notifyPropertyChanged(
Lei YU710d49b2017-08-01 17:10:17 +080045 "TimeSyncMethod",
Lei YUad143542017-07-25 14:27:07 +080046 "xyz.openbmc_project.Time.Synchronization.Method.NTP");
George Liu0a704522020-04-13 14:51:40 +080047 EXPECT_EQ(Mode::NTP, getTimeMode());
Lei YUa5003ce2017-02-24 15:35:25 +080048
Lei YU7f4fca52017-02-23 15:15:51 +080049 ASSERT_DEATH(notifyPropertyChanged("invalid property", "whatever"), "");
50}
51
Gunnar Millsab4cc6a2018-09-14 14:42:39 -050052} // namespace time
53} // namespace phosphor