Lei YU | 415b964 | 2017-02-09 11:37:26 +0800 | [diff] [blame] | 1 | #include "manager.hpp" |
Lei YU | a5003ce | 2017-02-24 15:35:25 +0800 | [diff] [blame] | 2 | #include "mocked_property_change_listener.hpp" |
Gunnar Mills | ab4cc6a | 2018-09-14 14:42:39 -0500 | [diff] [blame] | 3 | #include "types.hpp" |
| 4 | |
| 5 | #include <sdbusplus/bus.hpp> |
| 6 | |
| 7 | #include <gtest/gtest.h> |
Lei YU | a5003ce | 2017-02-24 15:35:25 +0800 | [diff] [blame] | 8 | |
Lei YU | 415b964 | 2017-02-09 11:37:26 +0800 | [diff] [blame] | 9 | namespace phosphor |
| 10 | { |
| 11 | namespace time |
| 12 | { |
| 13 | |
| 14 | class TestManager : public testing::Test |
| 15 | { |
Gunnar Mills | ab4cc6a | 2018-09-14 14:42:39 -0500 | [diff] [blame] | 16 | public: |
Patrick Williams | 3867926 | 2022-07-22 19:26:55 -0500 | [diff] [blame] | 17 | sdbusplus::bus_t bus; |
Gunnar Mills | ab4cc6a | 2018-09-14 14:42:39 -0500 | [diff] [blame] | 18 | Manager manager; |
Lei YU | 415b964 | 2017-02-09 11:37:26 +0800 | [diff] [blame] | 19 | |
Patrick Williams | ea22036 | 2023-05-10 07:50:45 -0500 | [diff] [blame^] | 20 | TestManager() : bus(sdbusplus::bus::new_default()), manager(bus) {} |
Lei YU | 415b964 | 2017-02-09 11:37:26 +0800 | [diff] [blame] | 21 | |
Gunnar Mills | ab4cc6a | 2018-09-14 14:42:39 -0500 | [diff] [blame] | 22 | void notifyPropertyChanged(const std::string& key, const std::string& value) |
| 23 | { |
| 24 | manager.onPropertyChanged(key, value); |
| 25 | } |
Lei YU | 415b964 | 2017-02-09 11:37:26 +0800 | [diff] [blame] | 26 | }; |
| 27 | |
George Liu | 7e5f9f7 | 2022-08-17 12:32:24 +0800 | [diff] [blame] | 28 | TEST_F(TestManager, propertyChanged) |
Lei YU | 7f4fca5 | 2017-02-23 15:15:51 +0800 | [diff] [blame] | 29 | { |
Lei YU | ad14354 | 2017-07-25 14:27:07 +0800 | [diff] [blame] | 30 | notifyPropertyChanged( |
Lei YU | 710d49b | 2017-08-01 17:10:17 +0800 | [diff] [blame] | 31 | "TimeSyncMethod", |
Lei YU | ad14354 | 2017-07-25 14:27:07 +0800 | [diff] [blame] | 32 | "xyz.openbmc_project.Time.Synchronization.Method.Manual"); |
George Liu | cb42109 | 2022-08-16 17:02:31 +0800 | [diff] [blame] | 33 | EXPECT_EQ(Mode::Manual, manager.getTimeMode()); |
Lei YU | a5003ce | 2017-02-24 15:35:25 +0800 | [diff] [blame] | 34 | |
Lei YU | ad14354 | 2017-07-25 14:27:07 +0800 | [diff] [blame] | 35 | notifyPropertyChanged( |
Lei YU | 710d49b | 2017-08-01 17:10:17 +0800 | [diff] [blame] | 36 | "TimeSyncMethod", |
Lei YU | ad14354 | 2017-07-25 14:27:07 +0800 | [diff] [blame] | 37 | "xyz.openbmc_project.Time.Synchronization.Method.NTP"); |
George Liu | cb42109 | 2022-08-16 17:02:31 +0800 | [diff] [blame] | 38 | EXPECT_EQ(Mode::NTP, manager.getTimeMode()); |
Lei YU | a5003ce | 2017-02-24 15:35:25 +0800 | [diff] [blame] | 39 | |
Lei YU | 7f4fca5 | 2017-02-23 15:15:51 +0800 | [diff] [blame] | 40 | ASSERT_DEATH(notifyPropertyChanged("invalid property", "whatever"), ""); |
| 41 | } |
| 42 | |
Gunnar Mills | ab4cc6a | 2018-09-14 14:42:39 -0500 | [diff] [blame] | 43 | } // namespace time |
| 44 | } // namespace phosphor |