Remove Deferred Updates

Remove deferred consumption of settings Manual/NTP and allow instant
consumption.

Tested:
Manually set the timeMode to NTP on the WEB and successfully.
busctl get-property xyz.openbmc_project.Settings
/xyz/openbmc_project/time/sync_method
xyz.openbmc_project.Time.Synchronization TimeSyncMethod
s "xyz.openbmc_project.Time.Synchronization.Method.NTP"

Manually set the date time successfully by D-Bus when timeMode is MANUAL
busctl set-property xyz.openbmc_project.Time.Manager
/xyz/openbmc_project/time/bmc xyz.openbmc_project.Time.EpochTime Elapsed
t 1514765953791262

Manually set the date time failed by D-Bus when timeMode is NTP.
busctl set-property xyz.openbmc_project.Time.Manager
/xyz/openbmc_project/time/bmc xyz.openbmc_project.Time.EpochTime Elapsed
t 1514765953791262
Failed to set property Elapsed on interface
xyz.openbmc_project.TIme.EpochTime: The operation failed

~# journalctl -b | grep timemanager
   Jan 01 00:15:26 fp5280g2 phosphor-timemanager[309]: Error in setting
system time
   Jan 01 00:15:26 fp5280g2 phosphor-timemanager[309]: The operation
failed

Refer: https://lists.ozlabs.org/pipermail/openbmc/2020-April/021409.html

Signed-off-by: George Liu <liuxiwei@inspur.com>
Change-Id: I7be25a9d0f56615bad6800a0b07df7f84fc0acc3
diff --git a/test/TestManager.cpp b/test/TestManager.cpp
index 95f5734..b1cf4ec 100644
--- a/test/TestManager.cpp
+++ b/test/TestManager.cpp
@@ -18,15 +18,9 @@
   public:
     sdbusplus::bus::bus bus;
     Manager manager;
-    MockPropertyChangeListner listener1;
-    MockPropertyChangeListner listener2;
 
     TestManager() : bus(sdbusplus::bus::new_default()), manager(bus)
     {
-        // Add two mocked listeners so that we can test
-        // the behavior related to listeners
-        manager.addListener(&listener1);
-        manager.addListener(&listener2);
     }
 
     // Proxies for Manager's private members and functions
@@ -34,129 +28,26 @@
     {
         return manager.timeMode;
     }
-    bool hostOn()
-    {
-        return manager.hostOn;
-    }
-    std::string getRequestedMode()
-    {
-        return manager.requestedMode;
-    }
     void notifyPropertyChanged(const std::string& key, const std::string& value)
     {
         manager.onPropertyChanged(key, value);
     }
-    void notifyOnHostState(bool hostOn)
-    {
-        manager.onHostState(hostOn);
-    }
 };
 
-TEST_F(TestManager, DISABLED_empty)
-{
-    EXPECT_FALSE(hostOn());
-    EXPECT_EQ("", getRequestedMode());
-
-    // Default mode is MANUAL
-    EXPECT_EQ(Mode::Manual, getTimeMode());
-}
-
-TEST_F(TestManager, DISABLED_hostStateChange)
-{
-    notifyOnHostState(true);
-    EXPECT_TRUE(hostOn());
-    notifyOnHostState(false);
-    EXPECT_FALSE(hostOn());
-}
-
 TEST_F(TestManager, DISABLED_propertyChanged)
 {
-    // When host is off, property change will be notified to listeners
-    EXPECT_FALSE(hostOn());
-
-    // Check mocked listeners shall receive notifications on property changed
-    EXPECT_CALL(listener1, onModeChanged(Mode::Manual)).Times(1);
-    EXPECT_CALL(listener2, onModeChanged(Mode::Manual)).Times(1);
-
     notifyPropertyChanged(
         "TimeSyncMethod",
         "xyz.openbmc_project.Time.Synchronization.Method.Manual");
-
-    EXPECT_EQ("", getRequestedMode());
-
-    // When host is on, property changes are saved as requested ones
-    notifyOnHostState(true);
-
-    // Check mocked listeners shall not receive notifications
-    EXPECT_CALL(listener1, onModeChanged(Mode::Manual)).Times(0);
-    EXPECT_CALL(listener2, onModeChanged(Mode::Manual)).Times(0);
+    EXPECT_EQ(Mode::Manual, getTimeMode());
 
     notifyPropertyChanged(
         "TimeSyncMethod",
         "xyz.openbmc_project.Time.Synchronization.Method.NTP");
+    EXPECT_EQ(Mode::NTP, getTimeMode());
 
-    EXPECT_EQ("xyz.openbmc_project.Time.Synchronization.Method.NTP",
-              getRequestedMode());
-
-    // When host becomes off, the requested mode shall be notified
-    // to listeners, and be cleared
-    EXPECT_CALL(listener1, onModeChanged(Mode::NTP)).Times(1);
-    EXPECT_CALL(listener2, onModeChanged(Mode::NTP)).Times(1);
-
-    notifyOnHostState(false);
-
-    EXPECT_EQ("", getRequestedMode());
-
-    // When host is on, and invalid property is changed,
-    // verify the code asserts because it shall never occur
-    notifyOnHostState(true);
     ASSERT_DEATH(notifyPropertyChanged("invalid property", "whatever"), "");
 }
 
-TEST_F(TestManager, DISABLED_propertyChangedAndChangedbackWhenHostOn)
-{
-    // Property is now MANUAL/HOST
-    notifyPropertyChanged(
-        "TimeSyncMethod",
-        "xyz.openbmc_project.Time.Synchronization.Method.Manual");
-
-    // Set host on
-    notifyOnHostState(true);
-
-    // Check mocked listeners shall not receive notifications
-    EXPECT_CALL(listener1, onModeChanged(_)).Times(0);
-    EXPECT_CALL(listener2, onModeChanged(_)).Times(0);
-
-    notifyPropertyChanged(
-        "TimeSyncMethod",
-        "xyz.openbmc_project.Time.Synchronization.Method.NTP");
-
-    // Saved as requested mode
-    EXPECT_EQ("xyz.openbmc_project.Time.Synchronization.Method.NTP",
-              getRequestedMode());
-
-    // Property changed back to MANUAL/HOST
-    notifyPropertyChanged(
-        "TimeSyncMethod",
-        "xyz.openbmc_project.Time.Synchronization.Method.Manual");
-
-    // Requested mode shall be updated
-    EXPECT_EQ("xyz.openbmc_project.Time.Synchronization.Method.Manual",
-              getRequestedMode());
-
-    // Because the latest mode is the same as when host is off,
-    // The listeners shall not be notified, and requested mode
-    // shall be cleared
-    EXPECT_CALL(listener1, onModeChanged(_)).Times(0);
-    EXPECT_CALL(listener2, onModeChanged(_)).Times(0);
-
-    notifyOnHostState(false);
-
-    EXPECT_EQ("", getRequestedMode());
-}
-
-// TODO: if gmock is ready, add case to test
-// updateNtpSetting() and updateNetworkSetting()
-
 } // namespace time
 } // namespace phosphor