summaryrefslogtreecommitdiff
path: root/update_manager/update_manager_unittest.cc
diff options
context:
space:
mode:
authorAlex Deymo <deymo@chromium.org>2014-11-10 21:52:57 -0800
committerchrome-internal-fetch <chrome-internal-fetch@google.com>2014-11-12 19:56:39 +0000
commit10875d90cf67f883ba7c9ed13bc8d706aa8c6fbc (patch)
tree97effd2a6cce73cbb6f131df93284d4fb5efc345 /update_manager/update_manager_unittest.cc
parent192393ba515e917d06248b6459b20b6547ef496d (diff)
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>
Diffstat (limited to 'update_manager/update_manager_unittest.cc')
-rw-r--r--update_manager/update_manager_unittest.cc13
1 files changed, 7 insertions, 6 deletions
diff --git a/update_manager/update_manager_unittest.cc b/update_manager/update_manager_unittest.cc
index 3534cfa2..c0ce0925 100644
--- a/update_manager/update_manager_unittest.cc
+++ b/update_manager/update_manager_unittest.cc
@@ -30,6 +30,7 @@ using base::Time;
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 @@ TEST_F(UmUpdateManagerTest, AsyncPolicyRequestDelaysEvaluation) {
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 @@ TEST_F(UmUpdateManagerTest, AsyncPolicyRequestTimeoutDoesNotFire) {
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 @@ TEST_F(UmUpdateManagerTest, AsyncPolicyRequestTimesOut) {
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 @@ TEST_F(UmUpdateManagerTest, AsyncPolicyRequestTimesOut) {
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 @@ TEST_F(UmUpdateManagerTest, AsyncPolicyRequestTimesOut) {
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);