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/evaluation_context_unittest.cc b/update_manager/evaluation_context_unittest.cc
index 19e3419..f38b641 100644
--- a/update_manager/evaluation_context_unittest.cc
+++ b/update_manager/evaluation_context_unittest.cc
@@ -21,8 +21,8 @@
 using base::Time;
 using base::TimeDelta;
 using chromeos_update_engine::FakeClock;
-using chromeos_update_engine::RunGMainLoopMaxIterations;
-using chromeos_update_engine::RunGMainLoopUntil;
+using chromeos_update_engine::test_utils::RunGMainLoopMaxIterations;
+using chromeos_update_engine::test_utils::RunGMainLoopUntil;
 using std::string;
 using std::unique_ptr;
 using testing::Return;
diff --git a/update_manager/event_loop_unittest.cc b/update_manager/event_loop_unittest.cc
index 69325fe..4f8f768 100644
--- a/update_manager/event_loop_unittest.cc
+++ b/update_manager/event_loop_unittest.cc
@@ -11,8 +11,8 @@
 
 using base::Bind;
 using base::TimeDelta;
-using chromeos_update_engine::RunGMainLoopMaxIterations;
-using chromeos_update_engine::RunGMainLoopUntil;
+using chromeos_update_engine::test_utils::RunGMainLoopMaxIterations;
+using chromeos_update_engine::test_utils::RunGMainLoopUntil;
 
 namespace {
 
diff --git a/update_manager/generic_variables_unittest.cc b/update_manager/generic_variables_unittest.cc
index 784ac4a..7de6725 100644
--- a/update_manager/generic_variables_unittest.cc
+++ b/update_manager/generic_variables_unittest.cc
@@ -12,7 +12,7 @@
 #include "update_engine/test_utils.h"
 #include "update_engine/update_manager/umtest_utils.h"
 
-using chromeos_update_engine::RunGMainLoopMaxIterations;
+using chromeos_update_engine::test_utils::RunGMainLoopMaxIterations;
 using std::unique_ptr;
 
 namespace chromeos_update_manager {
diff --git a/update_manager/real_config_provider_unittest.cc b/update_manager/real_config_provider_unittest.cc
index 6e8d301..09f9fc0 100644
--- a/update_manager/real_config_provider_unittest.cc
+++ b/update_manager/real_config_provider_unittest.cc
@@ -16,7 +16,7 @@
 #include "update_engine/update_manager/umtest_utils.h"
 
 using base::TimeDelta;
-using chromeos_update_engine::WriteFileString;
+using chromeos_update_engine::test_utils::WriteFileString;
 using std::string;
 using std::unique_ptr;
 
diff --git a/update_manager/real_device_policy_provider_unittest.cc b/update_manager/real_device_policy_provider_unittest.cc
index 627027e..0ed2615 100644
--- a/update_manager/real_device_policy_provider_unittest.cc
+++ b/update_manager/real_device_policy_provider_unittest.cc
@@ -14,7 +14,7 @@
 #include "update_engine/update_manager/umtest_utils.h"
 
 using base::TimeDelta;
-using chromeos_update_engine::RunGMainLoopMaxIterations;
+using chromeos_update_engine::test_utils::RunGMainLoopMaxIterations;
 using std::set;
 using std::string;
 using std::unique_ptr;
diff --git a/update_manager/real_shill_provider_unittest.cc b/update_manager/real_shill_provider_unittest.cc
index 7859501..b384e67 100644
--- a/update_manager/real_shill_provider_unittest.cc
+++ b/update_manager/real_shill_provider_unittest.cc
@@ -19,9 +19,9 @@
 using base::Time;
 using base::TimeDelta;
 using chromeos_update_engine::FakeClock;
-using chromeos_update_engine::GValueFree;
-using chromeos_update_engine::GValueNewString;
 using chromeos_update_engine::MockDBusWrapper;
+using chromeos_update_engine::test_utils::GValueFree;
+using chromeos_update_engine::test_utils::GValueNewString;
 using std::pair;
 using std::unique_ptr;
 using testing::Eq;
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);
diff --git a/update_manager/variable_unittest.cc b/update_manager/variable_unittest.cc
index 09c7649..7944c38 100644
--- a/update_manager/variable_unittest.cc
+++ b/update_manager/variable_unittest.cc
@@ -11,7 +11,7 @@
 #include "update_engine/test_utils.h"
 
 using base::TimeDelta;
-using chromeos_update_engine::RunGMainLoopMaxIterations;
+using chromeos_update_engine::test_utils::RunGMainLoopMaxIterations;
 using std::string;
 using std::vector;