update_engine: Use clock and fake clock from SystemState
No need to pass clock and fake clock anywhere anymore. This CL makes it
to just use those objects available from SystemState and
FakeSystemState.
BUG=b:171829801
TEST=cros_workon_make --board reef --test update_engine
Change-Id: I9a3cf6dd2057620c11b862d3317b83489c76f3ca
Reviewed-on: https://chromium-review.googlesource.com/c/aosp/platform/system/update_engine/+/2546625
Tested-by: Amin Hassani <ahassani@chromium.org>
Reviewed-by: Jae Hoon Kim <kimjae@chromium.org>
Commit-Queue: Jae Hoon Kim <kimjae@chromium.org>
diff --git a/cros/p2p_manager_unittest.cc b/cros/p2p_manager_unittest.cc
index 8b6d741..b66b08c 100644
--- a/cros/p2p_manager_unittest.cc
+++ b/cros/p2p_manager_unittest.cc
@@ -46,12 +46,12 @@
#include <policy/libpolicy.h>
#include <policy/mock_device_policy.h>
-#include "update_engine/common/fake_clock.h"
#include "update_engine/common/prefs.h"
#include "update_engine/common/subprocess.h"
#include "update_engine/common/test_utils.h"
#include "update_engine/common/utils.h"
#include "update_engine/cros/fake_p2p_manager_configuration.h"
+#include "update_engine/cros/fake_system_state.h"
#include "update_engine/update_manager/fake_update_manager.h"
#include "update_engine/update_manager/mock_policy.h"
@@ -72,12 +72,13 @@
// done.
class P2PManagerTest : public testing::Test {
protected:
- P2PManagerTest() : fake_um_(&fake_clock_) {}
- ~P2PManagerTest() override {}
+ P2PManagerTest() = default;
+ ~P2PManagerTest() override = default;
// Derived from testing::Test.
void SetUp() override {
loop_.SetAsCurrent();
+ FakeSystemState::CreateInstance();
async_signal_handler_.Init();
subprocess_.Init(&async_signal_handler_);
test_conf_ = new FakeP2PManagerConfiguration();
@@ -85,12 +86,11 @@
// Allocate and install a mock policy implementation in the fake Update
// Manager. Note that the FakeUpdateManager takes ownership of the policy
// object.
- mock_policy_ = new chromeos_update_manager::MockPolicy(&fake_clock_);
+ mock_policy_ = new chromeos_update_manager::MockPolicy();
fake_um_.set_policy(mock_policy_);
// Construct the P2P manager under test.
manager_.reset(P2PManager::Construct(test_conf_,
- &fake_clock_,
&fake_um_,
"cros_au",
3,
@@ -110,7 +110,6 @@
// The P2PManager::Configuration instance used for testing.
FakeP2PManagerConfiguration* test_conf_;
- FakeClock fake_clock_;
chromeos_update_manager::MockPolicy* mock_policy_ = nullptr;
chromeos_update_manager::FakeUpdateManager fake_um_;
@@ -149,7 +148,6 @@
// will be freed.
test_conf_ = new FakeP2PManagerConfiguration();
manager_.reset(P2PManager::Construct(test_conf_,
- &fake_clock_,
&fake_um_,
"cros_au",
3,
@@ -207,14 +205,14 @@
// Set the clock just so files with a timestamp before |cutoff_time|
// will be deleted at housekeeping.
- fake_clock_.SetWallclockTime(cutoff_time + age_limit);
+ FakeSystemState::Get()->fake_clock()->SetWallclockTime(cutoff_time +
+ age_limit);
// Specifically pass 0 for |num_files_to_keep| to allow any number of files.
// Note that we need to reallocate the test_conf_ member, whose currently
// aliased object will be freed.
test_conf_ = new FakeP2PManagerConfiguration();
manager_.reset(P2PManager::Construct(test_conf_,
- &fake_clock_,
&fake_um_,
"cros_au",
0 /* num_files_to_keep */,