Move timeMode property to manager
The current logic is to maintain the same attribute in manager and
epoch_base, the purpose of this commit is to merge this attribute
into manager for maintenance.
Also, Update the test/TestBmcEpoch.cpp file.
Tested: Built phosphor-time-manager successfully and UT passed.
Signed-off-by: George Liu <liuxiwei@inspur.com>
Change-Id: I05fea271d672bf12ecb722005023dfa6a2a980d1
diff --git a/test/TestBmcEpoch.cpp b/test/TestBmcEpoch.cpp
index 0f4dbea..aee19f9 100644
--- a/test/TestBmcEpoch.cpp
+++ b/test/TestBmcEpoch.cpp
@@ -1,6 +1,7 @@
#include "config.h"
#include "bmc_epoch.hpp"
+#include "manager.hpp"
#include "types.hpp"
#include <sdbusplus/bus.hpp>
@@ -16,15 +17,16 @@
{
public:
sdbusplus::bus_t bus;
+ Manager manager;
sd_event* event;
std::unique_ptr<BmcEpoch> bmcEpoch;
- TestBmcEpoch() : bus(sdbusplus::bus::new_default())
+ TestBmcEpoch() : bus(sdbusplus::bus::new_default()), manager(bus)
{
// BmcEpoch requires sd_event to init
sd_event_default(&event);
bus.attach_event(event, SD_EVENT_PRIORITY_NORMAL);
- bmcEpoch = std::make_unique<BmcEpoch>(bus, OBJPATH_BMC);
+ bmcEpoch = std::make_unique<BmcEpoch>(bus, OBJPATH_BMC, manager);
}
~TestBmcEpoch()
@@ -32,31 +34,21 @@
bus.detach_event();
sd_event_unref(event);
}
-
- // Proxies for BmcEpoch's private members and functions
- Mode getTimeMode()
- {
- return bmcEpoch->timeMode;
- }
- void setTimeMode(Mode mode)
- {
- bmcEpoch->timeMode = mode;
- }
};
TEST_F(TestBmcEpoch, onModeChange)
{
bmcEpoch->onModeChanged(Mode::NTP);
- EXPECT_EQ(Mode::NTP, getTimeMode());
+ EXPECT_EQ(Mode::NTP, manager.getTimeMode());
bmcEpoch->onModeChanged(Mode::Manual);
- EXPECT_EQ(Mode::Manual, getTimeMode());
+ EXPECT_EQ(Mode::Manual, manager.getTimeMode());
}
TEST_F(TestBmcEpoch, empty)
{
// Default mode is MANUAL
- EXPECT_EQ(Mode::Manual, getTimeMode());
+ EXPECT_EQ(Mode::Manual, manager.getTimeMode());
}
TEST_F(TestBmcEpoch, getElapsed)