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/p2p_manager_unittest.cc b/p2p_manager_unittest.cc
index a790289..12b6709 100644
--- a/p2p_manager_unittest.cc
+++ b/p2p_manager_unittest.cc
@@ -30,6 +30,7 @@
 #include "update_engine/utils.h"
 
 using base::TimeDelta;
+using chromeos_update_engine::test_utils::System;
 using std::string;
 using std::unique_ptr;
 using testing::DoAll;
@@ -82,7 +83,7 @@
   EXPECT_CALL(*mock_policy_, P2PEnabledChanged(_, _, _, _, false));
 
   EXPECT_FALSE(manager_->IsP2PEnabled());
-  RunGMainLoopMaxIterations(100);
+  test_utils::RunGMainLoopMaxIterations(100);
   EXPECT_FALSE(manager_->IsP2PEnabled());
 }
 
@@ -97,7 +98,7 @@
   EXPECT_CALL(*mock_policy_, P2PEnabledChanged(_, _, _, _, false));
 
   EXPECT_TRUE(manager_->IsP2PEnabled());
-  RunGMainLoopMaxIterations(100);
+  test_utils::RunGMainLoopMaxIterations(100);
   EXPECT_FALSE(manager_->IsP2PEnabled());
 }
 
@@ -180,7 +181,7 @@
   // flakiness) since the epoch and then we put two files before that
   // date and three files after.
   time_t cutoff_time = 1000000000;
-  base::TimeDelta age_limit = base::TimeDelta::FromDays(5);
+  TimeDelta age_limit = TimeDelta::FromDays(5);
 
   // Set the clock just so files with a timestamp before |cutoff_time|
   // will be deleted at housekeeping.
@@ -209,7 +210,7 @@
     //                       cutoff_time
     //
     base::Time file_date = base::Time::FromTimeT(cutoff_time) +
-      (n - 2)*base::TimeDelta::FromDays(1) + base::TimeDelta::FromHours(12);
+      (n - 2)*TimeDelta::FromDays(1) + TimeDelta::FromHours(12);
 
     // The touch(1) command expects input like this
     // --date="2004-02-27 14:19:13.489392193 +0530"
@@ -346,7 +347,7 @@
 
 // Check that sharing a *new* file works.
 TEST_F(P2PManagerTest, ShareFile) {
-  if (!utils::IsXAttrSupported(base::FilePath("/tmp"))) {
+  if (!test_utils::IsXAttrSupported(base::FilePath("/tmp"))) {
     LOG(WARNING) << "Skipping test because /tmp does not support xattr. "
                  << "Please update your system to support this feature.";
     return;
@@ -367,7 +368,7 @@
 
 // Check that making a shared file visible, does what is expected.
 TEST_F(P2PManagerTest, MakeFileVisible) {
-  if (!utils::IsXAttrSupported(base::FilePath("/tmp"))) {
+  if (!test_utils::IsXAttrSupported(base::FilePath("/tmp"))) {
     LOG(WARNING) << "Skipping test because /tmp does not support xattr. "
                  << "Please update your system to support this feature.";
     return;
@@ -392,7 +393,7 @@
 
 // Check that we return the right values for existing files in P2P_DIR.
 TEST_F(P2PManagerTest, ExistingFiles) {
-  if (!utils::IsXAttrSupported(base::FilePath("/tmp"))) {
+  if (!test_utils::IsXAttrSupported(base::FilePath("/tmp"))) {
     LOG(WARNING) << "Skipping test because /tmp does not support xattr. "
                  << "Please update your system to support this feature.";
     return;