update_engine: Move test-only utils to test_utils.{h,cc}.
utils.{h,cc} contains a collections of basic or small functions used
in different parts of the codebase. The test_utils.{h,cc} instead
contains functions only required during testing split out to a
separated file to be reused in different tests.
This CL moves without changes some functions defined in utils.h that
were only used during unittests. Two other basic functions were replaced
by the same function already present in base/ (StringHasSuffix and
StringHasPrefix). The functions in test_utils.h now have their own
namespace chromeos_update_engine::test_utils so is clear they come
from the test_utils file, in the same way the ones from utils are
in their own namespace.
Some othe minor linter fixes included here.
BUG=chromium:351429
TEST=Unittest still pass.
Change-Id: I73ab72a14158cb21c8e1f404cbc728423bc8f34f
Reviewed-on: https://chromium-review.googlesource.com/229021
Reviewed-by: Alex Deymo <deymo@chromium.org>
Commit-Queue: Alex Deymo <deymo@chromium.org>
Tested-by: Alex Deymo <deymo@chromium.org>
diff --git a/update_manager/update_manager_unittest.cc b/update_manager/update_manager_unittest.cc
index 3534cfa..c0ce092 100644
--- a/update_manager/update_manager_unittest.cc
+++ b/update_manager/update_manager_unittest.cc
@@ -30,6 +30,7 @@
using base::TimeDelta;
using chromeos_update_engine::ErrorCode;
using chromeos_update_engine::FakeClock;
+using chromeos_update_engine::test_utils::RunGMainLoopMaxIterations;
using std::pair;
using std::string;
using std::tuple;
@@ -229,7 +230,7 @@
umut_->AsyncPolicyRequest(callback, &Policy::UpdateCheckAllowed);
// The callback should wait until we run the main loop for it to be executed.
EXPECT_EQ(0, calls.size());
- chromeos_update_engine::RunGMainLoopMaxIterations(100);
+ RunGMainLoopMaxIterations(100);
EXPECT_EQ(1, calls.size());
}
@@ -246,14 +247,14 @@
umut_->AsyncPolicyRequest(callback, &Policy::UpdateCheckAllowed);
// Run the main loop, ensure that policy was attempted once before deferring
// to the default.
- chromeos_update_engine::RunGMainLoopMaxIterations(100);
+ RunGMainLoopMaxIterations(100);
EXPECT_EQ(1, num_called);
ASSERT_EQ(1, calls.size());
EXPECT_EQ(EvalStatus::kSucceeded, calls[0].first);
// Wait for the timeout to expire, run the main loop again, ensure that
// nothing happened.
sleep(2);
- chromeos_update_engine::RunGMainLoopMaxIterations(10);
+ RunGMainLoopMaxIterations(10);
EXPECT_EQ(1, num_called);
EXPECT_EQ(1, calls.size());
}
@@ -274,7 +275,7 @@
umut_->AsyncPolicyRequest(callback, &Policy::UpdateCheckAllowed);
// Run the main loop, ensure that policy was attempted once but the callback
// was not invoked.
- chromeos_update_engine::RunGMainLoopMaxIterations(100);
+ RunGMainLoopMaxIterations(100);
EXPECT_EQ(1, num_called);
EXPECT_EQ(0, calls.size());
// Wait for the expiration timeout to expire, run the main loop again,
@@ -283,7 +284,7 @@
sleep(2);
fake_clock_.SetWallclockTime(fake_clock_.GetWallclockTime() +
TimeDelta::FromSeconds(2));
- chromeos_update_engine::RunGMainLoopMaxIterations(10);
+ RunGMainLoopMaxIterations(10);
EXPECT_EQ(2, num_called);
EXPECT_EQ(0, calls.size());
// Wait for reevaluation due to delay to happen, ensure that it occurs and
@@ -291,7 +292,7 @@
sleep(2);
fake_clock_.SetWallclockTime(fake_clock_.GetWallclockTime() +
TimeDelta::FromSeconds(2));
- chromeos_update_engine::RunGMainLoopMaxIterations(10);
+ RunGMainLoopMaxIterations(10);
EXPECT_EQ(3, num_called);
ASSERT_EQ(1, calls.size());
EXPECT_EQ(EvalStatus::kSucceeded, calls[0].first);