update_engine: Standarize mock/fake filenames.

Mock classes implement mostly MOCK_METHOD* methods used with gmock.
Those classes should be named with the prefix "Mock" in the class
name and "mock_" in the header filename.

Fake classes implement a working version of the interface they provide,
often with extra functionality to change their behavior. Those classes
should be prefixed with "Fake" in the class name and "fake_" in the
file name.

Other minor include order fixes are included in this patch.

BUG=None
TEST=Unittest still pass.

Change-Id: I23de7cb11e25182d5855afacca47d431c97b82bb
Reviewed-on: https://chromium-review.googlesource.com/227779
Reviewed-by: Alex Deymo <deymo@chromium.org>
Commit-Queue: Alex Deymo <deymo@chromium.org>
Tested-by: Alex Deymo <deymo@chromium.org>
diff --git a/action_processor.cc b/action_processor.cc
index 5e08a5f..9a27aac 100644
--- a/action_processor.cc
+++ b/action_processor.cc
@@ -3,8 +3,11 @@
 // found in the LICENSE file.
 
 #include "update_engine/action_processor.h"
+
 #include <string>
-#include "base/logging.h"
+
+#include <base/logging.h>
+
 #include "update_engine/action.h"
 
 using std::string;
diff --git a/certificate_checker_unittest.cc b/certificate_checker_unittest.cc
index 7ac2830..d75b543 100644
--- a/certificate_checker_unittest.cc
+++ b/certificate_checker_unittest.cc
@@ -2,6 +2,8 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
+#include "update_engine/certificate_checker.h"
+
 #include <string>
 
 #include <base/strings/string_util.h>
@@ -10,11 +12,10 @@
 #include <gtest/gtest.h>
 #include <metrics/metrics_library_mock.h>
 
-#include "update_engine/certificate_checker.h"
-#include "update_engine/certificate_checker_mock.h"
 #include "update_engine/constants.h"
 #include "update_engine/fake_system_state.h"
-#include "update_engine/prefs_mock.h"
+#include "update_engine/mock_certificate_checker.h"
+#include "update_engine/mock_prefs.h"
 
 using ::testing::DoAll;
 using ::testing::Return;
@@ -55,8 +56,8 @@
   virtual void TearDown() {}
 
   FakeSystemState fake_system_state_;
-  PrefsMock* prefs_;  // shortcut to fake_system_state_.mock_prefs()
-  OpenSSLWrapperMock openssl_wrapper_;
+  MockPrefs* prefs_;  // shortcut to fake_system_state_.mock_prefs()
+  MockOpenSSLWrapper openssl_wrapper_;
   // Parameters of our mock certificate digest.
   int depth_;
   unsigned int length_;
diff --git a/connection_manager_unittest.cc b/connection_manager_unittest.cc
index 748c725..05c700f 100644
--- a/connection_manager_unittest.cc
+++ b/connection_manager_unittest.cc
@@ -2,6 +2,8 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
+#include "update_engine/connection_manager.h"
+
 #include <set>
 #include <string>
 
@@ -10,7 +12,6 @@
 #include <gmock/gmock.h>
 #include <gtest/gtest.h>
 
-#include "update_engine/connection_manager.h"
 #include "update_engine/fake_system_state.h"
 #include "update_engine/mock_dbus_wrapper.h"
 #include "update_engine/test_utils.h"
@@ -360,7 +361,7 @@
 
 TEST_F(ConnectionManagerTest, UseUserPrefForUpdatesOverCellularIfNoPolicyTest) {
   policy::MockDevicePolicy no_policy;
-  testing::NiceMock<PrefsMock>* prefs = fake_system_state_.mock_prefs();
+  testing::NiceMock<MockPrefs>* prefs = fake_system_state_.mock_prefs();
 
   fake_system_state_.set_device_policy(&no_policy);
 
diff --git a/delta_performer_unittest.cc b/delta_performer_unittest.cc
index 785d8b9..78cf981 100644
--- a/delta_performer_unittest.cc
+++ b/delta_performer_unittest.cc
@@ -2,6 +2,8 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
+#include "update_engine/delta_performer.h"
+
 #include <inttypes.h>
 #include <sys/mount.h>
 
@@ -16,15 +18,14 @@
 #include <gtest/gtest.h>
 
 #include "update_engine/constants.h"
-#include "update_engine/delta_performer.h"
 #include "update_engine/extent_ranges.h"
 #include "update_engine/fake_hardware.h"
 #include "update_engine/fake_system_state.h"
+#include "update_engine/mock_prefs.h"
 #include "update_engine/payload_constants.h"
 #include "update_engine/payload_generator/delta_diff_generator.h"
 #include "update_engine/payload_generator/payload_signer.h"
 #include "update_engine/payload_verifier.h"
-#include "update_engine/prefs_mock.h"
 #include "update_engine/test_utils.h"
 #include "update_engine/update_metadata.pb.h"
 #include "update_engine/utils.h"
@@ -618,7 +619,7 @@
     EXPECT_FALSE(manifest.new_rootfs_info().hash().empty());
   }
 
-  PrefsMock prefs;
+  MockPrefs prefs;
   EXPECT_CALL(prefs, SetInt64(kPrefsManifestMetadataSize,
                               state->metadata_size)).WillOnce(Return(true));
   EXPECT_CALL(prefs, SetInt64(kPrefsUpdateStateNextOperation, _))
@@ -826,7 +827,7 @@
 void DoMetadataSizeTest(uint64_t expected_metadata_size,
                         uint64_t actual_metadata_size,
                         bool hash_checks_mandatory) {
-  PrefsMock prefs;
+  MockPrefs prefs;
   InstallPlan install_plan;
   install_plan.hash_checks_mandatory = hash_checks_mandatory;
   FakeSystemState fake_system_state;
@@ -923,7 +924,7 @@
   }
 
   // Create the delta performer object.
-  PrefsMock prefs;
+  MockPrefs prefs;
   DeltaPerformer delta_performer(&prefs,
                                  &state.fake_system_state,
                                  &install_plan);
@@ -968,7 +969,7 @@
   static void RunManifestValidation(const DeltaArchiveManifest& manifest,
                                     bool full_payload,
                                     ErrorCode expected) {
-    PrefsMock prefs;
+    MockPrefs prefs;
     InstallPlan install_plan;
     FakeSystemState fake_system_state;
     DeltaPerformer performer(&prefs, &fake_system_state, &install_plan);
@@ -1152,7 +1153,7 @@
 }
 
 TEST(DeltaPerformerTest, BadDeltaMagicTest) {
-  PrefsMock prefs;
+  MockPrefs prefs;
   InstallPlan install_plan;
   FakeSystemState fake_system_state;
   DeltaPerformer performer(&prefs, &fake_system_state, &install_plan);
@@ -1181,7 +1182,7 @@
 }
 
 TEST(DeltaPerformerTest, WriteUpdatesPayloadState) {
-  PrefsMock prefs;
+  MockPrefs prefs;
   InstallPlan install_plan;
   FakeSystemState fake_system_state;
   DeltaPerformer performer(&prefs, &fake_system_state, &install_plan);
@@ -1253,7 +1254,7 @@
 }
 
 TEST(DeltaPerformerTest, UsePublicKeyFromResponse) {
-  PrefsMock prefs;
+  MockPrefs prefs;
   FakeSystemState fake_system_state;
   InstallPlan install_plan;
   base::FilePath key_path;
diff --git a/download_action_unittest.cc b/download_action_unittest.cc
index 93a72ae..f241a32 100644
--- a/download_action_unittest.cc
+++ b/download_action_unittest.cc
@@ -2,6 +2,8 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
+#include "update_engine/download_action.h"
+
 #include <glib.h>
 #include <gmock/gmock.h>
 #include <gtest/gtest.h>
@@ -16,12 +18,11 @@
 #include <base/strings/stringprintf.h>
 
 #include "update_engine/action_pipe.h"
-#include "update_engine/download_action.h"
 #include "update_engine/fake_p2p_manager_configuration.h"
 #include "update_engine/fake_system_state.h"
 #include "update_engine/mock_http_fetcher.h"
+#include "update_engine/mock_prefs.h"
 #include "update_engine/omaha_hash_calculator.h"
-#include "update_engine/prefs_mock.h"
 #include "update_engine/test_utils.h"
 #include "update_engine/utils.h"
 
@@ -155,7 +156,7 @@
                            "");
   ObjectFeederAction<InstallPlan> feeder_action;
   feeder_action.set_obj(install_plan);
-  PrefsMock prefs;
+  MockPrefs prefs;
   MockHttpFetcher* http_fetcher = new MockHttpFetcher(&data[0],
                                                       data.size(),
                                                       nullptr);
@@ -270,7 +271,7 @@
     InstallPlan install_plan(false, false, "", 0, "", 0, "",
                              temp_file.GetPath(), "", "");
     feeder_action.set_obj(install_plan);
-    PrefsMock prefs;
+    MockPrefs prefs;
     DownloadAction download_action(&prefs, nullptr,
                                    new MockHttpFetcher(&data[0],
                                                        data.size(),
@@ -381,7 +382,7 @@
                            "");
   ObjectFeederAction<InstallPlan> feeder_action;
   feeder_action.set_obj(install_plan);
-  PrefsMock prefs;
+  MockPrefs prefs;
   DownloadAction download_action(&prefs, nullptr,
                                  new MockHttpFetcher("x", 1, nullptr));
   download_action.SetTestFileWriter(&writer);
@@ -416,7 +417,7 @@
   InstallPlan install_plan(false, false, "", 0, "", 0, "", path, "", "");
   ObjectFeederAction<InstallPlan> feeder_action;
   feeder_action.set_obj(install_plan);
-  PrefsMock prefs;
+  MockPrefs prefs;
   DownloadAction download_action(&prefs, nullptr,
                                  new MockHttpFetcher("x", 1, nullptr));
   download_action.SetTestFileWriter(&writer);
@@ -495,7 +496,7 @@
                              "");
     ObjectFeederAction<InstallPlan> feeder_action;
     feeder_action.set_obj(install_plan);
-    PrefsMock prefs;
+    MockPrefs prefs;
     http_fetcher_ = new MockHttpFetcher(data_.c_str(),
                                         data_.length(),
                                         nullptr);
diff --git a/extent_writer.h b/extent_writer.h
index db24b4b..883507a 100644
--- a/extent_writer.h
+++ b/extent_writer.h
@@ -6,7 +6,9 @@
 #define UPDATE_ENGINE_EXTENT_WRITER_H_
 
 #include <vector>
-#include "base/logging.h"
+
+#include <base/logging.h>
+
 #include "update_engine/update_metadata.pb.h"
 #include "update_engine/utils.h"
 
diff --git a/fake_file_writer.h b/fake_file_writer.h
new file mode 100644
index 0000000..6ba550d
--- /dev/null
+++ b/fake_file_writer.h
@@ -0,0 +1,63 @@
+// Copyright (c) 2009 The Chromium OS Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef UPDATE_ENGINE_FAKE_FILE_WRITER_H_
+#define UPDATE_ENGINE_FAKE_FILE_WRITER_H_
+
+#include <vector>
+
+#include <base/macros.h>
+
+#include "update_engine/file_writer.h"
+
+// FakeFileWriter is an implementation of FileWriter. It will succeed
+// calls to Open(), Close(), but not do any work. All calls to Write()
+// will append the passed data to an internal vector.
+
+namespace chromeos_update_engine {
+
+class FakeFileWriter : public FileWriter {
+ public:
+  FakeFileWriter() : was_opened_(false), was_closed_(false) {}
+
+  virtual int Open(const char* path, int flags, mode_t mode) {
+    CHECK(!was_opened_);
+    CHECK(!was_closed_);
+    was_opened_ = true;
+    return 0;
+  }
+
+  virtual ssize_t Write(const void* bytes, size_t count) {
+    CHECK(was_opened_);
+    CHECK(!was_closed_);
+    const char* char_bytes = reinterpret_cast<const char*>(bytes);
+    bytes_.insert(bytes_.end(), char_bytes, char_bytes + count);
+    return count;
+  }
+
+  virtual int Close() {
+    CHECK(was_opened_);
+    CHECK(!was_closed_);
+    was_closed_ = true;
+    return 0;
+  }
+
+  const std::vector<char>& bytes() {
+    return bytes_;
+  }
+
+ private:
+  // The internal store of all bytes that have been written
+  std::vector<char> bytes_;
+
+  // These are just to ensure FileWriter methods are called properly.
+  bool was_opened_;
+  bool was_closed_;
+
+  DISALLOW_COPY_AND_ASSIGN(FakeFileWriter);
+};
+
+}  // namespace chromeos_update_engine
+
+#endif  // UPDATE_ENGINE_FAKE_FILE_WRITER_H_
diff --git a/fake_system_state.h b/fake_system_state.h
index 520b1a0..84c37fc 100644
--- a/fake_system_state.h
+++ b/fake_system_state.h
@@ -17,8 +17,8 @@
 #include "update_engine/mock_omaha_request_params.h"
 #include "update_engine/mock_p2p_manager.h"
 #include "update_engine/mock_payload_state.h"
+#include "update_engine/mock_prefs.h"
 #include "update_engine/mock_update_attempter.h"
-#include "update_engine/prefs_mock.h"
 #include "update_engine/system_state.h"
 #include "update_engine/update_manager/fake_update_manager.h"
 
@@ -163,12 +163,12 @@
     return &mock_metrics_lib_;
   }
 
-  inline testing::NiceMock<PrefsMock> *mock_prefs() {
+  inline testing::NiceMock<MockPrefs> *mock_prefs() {
     CHECK(prefs_ == &mock_prefs_);
     return &mock_prefs_;
   }
 
-  inline testing::NiceMock<PrefsMock> *mock_powerwash_safe_prefs() {
+  inline testing::NiceMock<MockPrefs> *mock_powerwash_safe_prefs() {
     CHECK(powerwash_safe_prefs_ == &mock_powerwash_safe_prefs_);
     return &mock_powerwash_safe_prefs_;
   }
@@ -204,8 +204,8 @@
   testing::NiceMock<MockConnectionManager> mock_connection_manager_;
   FakeHardware fake_hardware_;
   testing::NiceMock<MetricsLibraryMock> mock_metrics_lib_;
-  testing::NiceMock<PrefsMock> mock_prefs_;
-  testing::NiceMock<PrefsMock> mock_powerwash_safe_prefs_;
+  testing::NiceMock<MockPrefs> mock_prefs_;
+  testing::NiceMock<MockPrefs> mock_powerwash_safe_prefs_;
   testing::NiceMock<MockPayloadState> mock_payload_state_;
   testing::NiceMock<MockUpdateAttempter> mock_update_attempter_;
   testing::NiceMock<MockOmahaRequestParams> mock_request_params_;
diff --git a/file_descriptor.h b/file_descriptor.h
index 21c2758..3b1f1b2 100644
--- a/file_descriptor.h
+++ b/file_descriptor.h
@@ -8,7 +8,7 @@
 #include <errno.h>
 #include <sys/types.h>
 
-#include "base/logging.h"
+#include <base/logging.h>
 
 #include "update_engine/utils.h"
 
diff --git a/file_writer_mock.h b/file_writer_mock.h
deleted file mode 100644
index a2c5251..0000000
--- a/file_writer_mock.h
+++ /dev/null
@@ -1,22 +0,0 @@
-// Copyright (c) 2010 The Chromium OS Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef UPDATE_ENGINE_FILE_WRITER_MOCK_H_
-#define UPDATE_ENGINE_FILE_WRITER_MOCK_H_
-
-#include "gmock/gmock.h"
-#include "update_engine/file_writer.h"
-
-namespace chromeos_update_engine {
-
-class FileWriterMock : public FileWriter {
- public:
-  MOCK_METHOD3(Open, int(const char* path, int flags, mode_t mode));
-  MOCK_METHOD2(Write, ssize_t(const void* bytes, size_t count));
-  MOCK_METHOD0(Close, int());
-};
-
-}  // namespace chromeos_update_engine
-
-#endif  // UPDATE_ENGINE_FILE_WRITER_MOCK_H_
diff --git a/install_plan.cc b/install_plan.cc
index 11fe4c3..d991a35 100644
--- a/install_plan.cc
+++ b/install_plan.cc
@@ -4,7 +4,7 @@
 
 #include "update_engine/install_plan.h"
 
-#include "base/logging.h"
+#include <base/logging.h>
 
 #include "update_engine/utils.h"
 
diff --git a/action_mock.h b/mock_action.h
similarity index 71%
rename from action_mock.h
rename to mock_action.h
index 16199f9..f7bfedd 100644
--- a/action_mock.h
+++ b/mock_action.h
@@ -2,8 +2,8 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
-#ifndef UPDATE_ENGINE_ACTION_MOCK_H_
-#define UPDATE_ENGINE_ACTION_MOCK_H_
+#ifndef UPDATE_ENGINE_MOCK_ACTION_H_
+#define UPDATE_ENGINE_MOCK_ACTION_H_
 
 #include <string>
 
@@ -13,16 +13,16 @@
 
 namespace chromeos_update_engine {
 
-class ActionMock;
+class MockAction;
 
 template<>
-class ActionTraits<ActionMock> {
+class ActionTraits<MockAction> {
  public:
   typedef NoneType OutputObjectType;
   typedef NoneType InputObjectType;
 };
 
-class ActionMock : public Action<ActionMock> {
+class MockAction : public Action<MockAction> {
  public:
   MOCK_METHOD0(PerformAction, void());
   MOCK_CONST_METHOD0(Type, std::string());
@@ -30,4 +30,4 @@
 
 }  // namespace chromeos_update_engine
 
-#endif  // UPDATE_ENGINE_ACTION_MOCK_H_
+#endif  // UPDATE_ENGINE_MOCK_ACTION_H_
diff --git a/action_processor_mock.h b/mock_action_processor.h
similarity index 68%
rename from action_processor_mock.h
rename to mock_action_processor.h
index bb91107..24297ea 100644
--- a/action_processor_mock.h
+++ b/mock_action_processor.h
@@ -2,8 +2,8 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
-#ifndef UPDATE_ENGINE_ACTION_PROCESSOR_MOCK_H_
-#define UPDATE_ENGINE_ACTION_PROCESSOR_MOCK_H_
+#ifndef UPDATE_ENGINE_MOCK_ACTION_PROCESSOR_H_
+#define UPDATE_ENGINE_MOCK_ACTION_PROCESSOR_H_
 
 #include <gmock/gmock.h>
 
@@ -11,7 +11,7 @@
 
 namespace chromeos_update_engine {
 
-class ActionProcessorMock : public ActionProcessor {
+class MockActionProcessor : public ActionProcessor {
  public:
   MOCK_METHOD0(StartProcessing, void());
   MOCK_METHOD1(EnqueueAction, void(AbstractAction* action));
@@ -19,4 +19,4 @@
 
 }  // namespace chromeos_update_engine
 
-#endif  // UPDATE_ENGINE_ACTION_PROCESSOR_MOCK_H_
+#endif  // UPDATE_ENGINE_MOCK_ACTION_PROCESSOR_H_
diff --git a/certificate_checker_mock.h b/mock_certificate_checker.h
similarity index 74%
rename from certificate_checker_mock.h
rename to mock_certificate_checker.h
index f00dc85..5731062 100644
--- a/certificate_checker_mock.h
+++ b/mock_certificate_checker.h
@@ -2,8 +2,8 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
-#ifndef UPDATE_ENGINE_CERTIFICATE_CHECKER_MOCK_H_
-#define UPDATE_ENGINE_CERTIFICATE_CHECKER_MOCK_H_
+#ifndef UPDATE_ENGINE_MOCK_CERTIFICATE_CHECKER_H_
+#define UPDATE_ENGINE_MOCK_CERTIFICATE_CHECKER_H_
 
 #include <gmock/gmock.h>
 #include <openssl/ssl.h>
@@ -12,7 +12,7 @@
 
 namespace chromeos_update_engine {
 
-class OpenSSLWrapperMock : public OpenSSLWrapper {
+class MockOpenSSLWrapper : public OpenSSLWrapper {
  public:
   MOCK_CONST_METHOD4(GetCertificateDigest,
                      bool(X509_STORE_CTX* x509_ctx,
@@ -23,4 +23,4 @@
 
 }  // namespace chromeos_update_engine
 
-#endif  // UPDATE_ENGINE_CERTIFICATE_CHECKER_MOCK_H_
+#endif  // UPDATE_ENGINE_MOCK_CERTIFICATE_CHECKER_H_
diff --git a/mock_file_writer.h b/mock_file_writer.h
index 5231e40..65a5531 100644
--- a/mock_file_writer.h
+++ b/mock_file_writer.h
@@ -1,61 +1,20 @@
-// Copyright (c) 2009 The Chromium OS Authors. All rights reserved.
+// Copyright (c) 2010 The Chromium OS Authors. All rights reserved.
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
 #ifndef UPDATE_ENGINE_MOCK_FILE_WRITER_H_
 #define UPDATE_ENGINE_MOCK_FILE_WRITER_H_
 
-#include <vector>
-
-#include <base/macros.h>
-
+#include <gmock/gmock.h>
 #include "update_engine/file_writer.h"
 
-// MockFileWriter is an implementation of FileWriter. It will succeed
-// calls to Open(), Close(), but not do any work. All calls to Write()
-// will append the passed data to an internal vector.
-
 namespace chromeos_update_engine {
 
 class MockFileWriter : public FileWriter {
  public:
-  MockFileWriter() : was_opened_(false), was_closed_(false) {}
-
-  virtual int Open(const char* path, int flags, mode_t mode) {
-    CHECK(!was_opened_);
-    CHECK(!was_closed_);
-    was_opened_ = true;
-    return 0;
-  }
-
-  virtual ssize_t Write(const void* bytes, size_t count) {
-    CHECK(was_opened_);
-    CHECK(!was_closed_);
-    const char* char_bytes = reinterpret_cast<const char*>(bytes);
-    bytes_.insert(bytes_.end(), char_bytes, char_bytes + count);
-    return count;
-  }
-
-  virtual int Close() {
-    CHECK(was_opened_);
-    CHECK(!was_closed_);
-    was_closed_ = true;
-    return 0;
-  }
-
-  const std::vector<char>& bytes() {
-    return bytes_;
-  }
-
- private:
-  // The internal store of all bytes that have been written
-  std::vector<char> bytes_;
-
-  // These are just to ensure FileWriter methods are called properly.
-  bool was_opened_;
-  bool was_closed_;
-
-  DISALLOW_COPY_AND_ASSIGN(MockFileWriter);
+  MOCK_METHOD3(Open, int(const char* path, int flags, mode_t mode));
+  MOCK_METHOD2(Write, ssize_t(const void* bytes, size_t count));
+  MOCK_METHOD0(Close, int());
 };
 
 }  // namespace chromeos_update_engine
diff --git a/mock_payload_state.h b/mock_payload_state.h
index 2d40a19..2ac7e97 100644
--- a/mock_payload_state.h
+++ b/mock_payload_state.h
@@ -7,7 +7,8 @@
 
 #include <string>
 
-#include "gmock/gmock.h"
+#include <gmock/gmock.h>
+
 #include "update_engine/omaha_request_action.h"
 #include "update_engine/payload_state_interface.h"
 
diff --git a/prefs_mock.h b/mock_prefs.h
similarity index 84%
rename from prefs_mock.h
rename to mock_prefs.h
index 9ba4a52..176176b 100644
--- a/prefs_mock.h
+++ b/mock_prefs.h
@@ -2,18 +2,19 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
-#ifndef UPDATE_ENGINE_PREFS_MOCK_H_
-#define UPDATE_ENGINE_PREFS_MOCK_H_
+#ifndef UPDATE_ENGINE_MOCK_PREFS_H_
+#define UPDATE_ENGINE_MOCK_PREFS_H_
 
 #include <string>
 
-#include "gmock/gmock.h"
+#include <gmock/gmock.h>
+
 #include "update_engine/constants.h"
 #include "update_engine/prefs_interface.h"
 
 namespace chromeos_update_engine {
 
-class PrefsMock : public PrefsInterface {
+class MockPrefs : public PrefsInterface {
  public:
   MOCK_METHOD2(GetString, bool(const std::string& key, std::string* value));
   MOCK_METHOD2(SetString, bool(const std::string& key,
@@ -30,4 +31,4 @@
 
 }  // namespace chromeos_update_engine
 
-#endif  // UPDATE_ENGINE_PREFS_MOCK_H_
+#endif  // UPDATE_ENGINE_MOCK_PREFS_H_
diff --git a/omaha_request_action_unittest.cc b/omaha_request_action_unittest.cc
index 4adf998..bcdee84 100644
--- a/omaha_request_action_unittest.cc
+++ b/omaha_request_action_unittest.cc
@@ -2,6 +2,8 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
+#include "update_engine/omaha_request_action.h"
+
 #include <glib.h>
 #include <stdint.h>
 
@@ -21,7 +23,6 @@
 #include "update_engine/mock_http_fetcher.h"
 #include "update_engine/mock_payload_state.h"
 #include "update_engine/omaha_hash_calculator.h"
-#include "update_engine/omaha_request_action.h"
 #include "update_engine/omaha_request_params.h"
 #include "update_engine/prefs.h"
 #include "update_engine/test_utils.h"
@@ -53,7 +54,7 @@
   }
 
   // Returns true iff an output response was obtained from the
-  // OmahaRequestAction. |prefs| may be null, in which case a local PrefsMock
+  // OmahaRequestAction. |prefs| may be null, in which case a local MockPrefs
   // is used. |payload_state| may be null, in which case a local mock is used.
   // |p2p_manager| may be null, in which case a local mock is used.
   // |connection_manager| may be null, in which case a local mock is used.
@@ -1132,7 +1133,7 @@
 
 TEST_F(OmahaRequestActionTest, FormatUpdateCheckOutputTest) {
   vector<char> post_data;
-  NiceMock<PrefsMock> prefs;
+  NiceMock<MockPrefs> prefs;
   fake_system_state_.set_prefs(&prefs);
 
   EXPECT_CALL(prefs, GetString(kPrefsPreviousVersion, _))
@@ -1327,7 +1328,7 @@
 }
 
 void OmahaRequestActionTest::PingTest(bool ping_only) {
-  NiceMock<PrefsMock> prefs;
+  NiceMock<MockPrefs> prefs;
   fake_system_state_.set_prefs(&prefs);
   EXPECT_CALL(prefs, GetInt64(kPrefsMetricsCheckLastReportingTime, _))
     .Times(AnyNumber());
@@ -1376,7 +1377,7 @@
 }
 
 TEST_F(OmahaRequestActionTest, ActivePingTest) {
-  NiceMock<PrefsMock> prefs;
+  NiceMock<MockPrefs> prefs;
   fake_system_state_.set_prefs(&prefs);
   EXPECT_CALL(prefs, GetInt64(kPrefsMetricsCheckLastReportingTime, _))
     .Times(AnyNumber());
@@ -1408,7 +1409,7 @@
 }
 
 TEST_F(OmahaRequestActionTest, RollCallPingTest) {
-  NiceMock<PrefsMock> prefs;
+  NiceMock<MockPrefs> prefs;
   fake_system_state_.set_prefs(&prefs);
   EXPECT_CALL(prefs, GetInt64(kPrefsMetricsCheckLastReportingTime, _))
     .Times(AnyNumber());
@@ -1440,7 +1441,7 @@
 }
 
 TEST_F(OmahaRequestActionTest, NoPingTest) {
-  NiceMock<PrefsMock> prefs;
+  NiceMock<MockPrefs> prefs;
   fake_system_state_.set_prefs(&prefs);
   EXPECT_CALL(prefs, GetInt64(kPrefsMetricsCheckLastReportingTime, _))
     .Times(AnyNumber());
@@ -1477,7 +1478,7 @@
 
 TEST_F(OmahaRequestActionTest, IgnoreEmptyPingTest) {
   // This test ensures that we ignore empty ping only requests.
-  NiceMock<PrefsMock> prefs;
+  NiceMock<MockPrefs> prefs;
   fake_system_state_.set_prefs(&prefs);
   int64_t now = Time::Now().ToInternalValue();
   EXPECT_CALL(prefs, GetInt64(kPrefsLastActivePingDay, _))
@@ -1502,7 +1503,7 @@
 }
 
 TEST_F(OmahaRequestActionTest, BackInTimePingTest) {
-  NiceMock<PrefsMock> prefs;
+  NiceMock<MockPrefs> prefs;
   fake_system_state_.set_prefs(&prefs);
   EXPECT_CALL(prefs, GetInt64(kPrefsMetricsCheckLastReportingTime, _))
     .Times(AnyNumber());
@@ -1547,7 +1548,7 @@
       (Time::Now() - TimeDelta::FromSeconds(200)).ToInternalValue();
   int64_t midnight_slack =
       (Time::Now() - TimeDelta::FromSeconds(195)).ToInternalValue();
-  NiceMock<PrefsMock> prefs;
+  NiceMock<MockPrefs> prefs;
   fake_system_state_.set_prefs(&prefs);
   EXPECT_CALL(prefs, GetInt64(_, _)).Times(AnyNumber());
   EXPECT_CALL(prefs, SetInt64(_, _)).Times(AnyNumber());
@@ -1574,7 +1575,7 @@
 }
 
 TEST_F(OmahaRequestActionTest, NoElapsedSecondsTest) {
-  NiceMock<PrefsMock> prefs;
+  NiceMock<MockPrefs> prefs;
   fake_system_state_.set_prefs(&prefs);
   EXPECT_CALL(prefs, GetInt64(_, _)).Times(AnyNumber());
   EXPECT_CALL(prefs, SetInt64(_, _)).Times(AnyNumber());
@@ -1597,7 +1598,7 @@
 }
 
 TEST_F(OmahaRequestActionTest, BadElapsedSecondsTest) {
-  NiceMock<PrefsMock> prefs;
+  NiceMock<MockPrefs> prefs;
   fake_system_state_.set_prefs(&prefs);
   EXPECT_CALL(prefs, GetInt64(_, _)).Times(AnyNumber());
   EXPECT_CALL(prefs, SetInt64(_, _)).Times(AnyNumber());
@@ -1795,7 +1796,7 @@
   ASSERT_EQ(0, System(string("mkdir -p ") + test_dir +
                       kStatefulPartition + "/etc"));
   vector<char> post_data;
-  NiceMock<PrefsMock> prefs;
+  NiceMock<MockPrefs> prefs;
   fake_system_state_.set_prefs(&prefs);
   ASSERT_TRUE(WriteFileString(
       test_dir + "/etc/lsb-release",
@@ -1844,7 +1845,7 @@
   ASSERT_EQ(0, System(string("mkdir -p ") + test_dir +
                       kStatefulPartition + "/etc"));
   vector<char> post_data;
-  NiceMock<PrefsMock> prefs;
+  NiceMock<MockPrefs> prefs;
   fake_system_state_.set_prefs(&prefs);
   ASSERT_TRUE(WriteFileString(
       test_dir + "/etc/lsb-release",
diff --git a/omaha_request_params_unittest.cc b/omaha_request_params_unittest.cc
index 348e392..c4e84ad 100644
--- a/omaha_request_params_unittest.cc
+++ b/omaha_request_params_unittest.cc
@@ -2,16 +2,18 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
+#include "update_engine/omaha_request_params.h"
+
 #include <stdio.h>
 
 #include <string>
 
-#include "base/files/file_util.h"
-#include "gtest/gtest.h"
+#include <base/files/file_util.h>
+#include <gtest/gtest.h>
+
 #include "update_engine/constants.h"
 #include "update_engine/fake_system_state.h"
 #include "update_engine/install_plan.h"
-#include "update_engine/omaha_request_params.h"
 #include "update_engine/test_utils.h"
 #include "update_engine/utils.h"
 
diff --git a/p2p_manager_unittest.cc b/p2p_manager_unittest.cc
index 9af5458..86dba85 100644
--- a/p2p_manager_unittest.cc
+++ b/p2p_manager_unittest.cc
@@ -2,6 +2,8 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
+#include "update_engine/p2p_manager.h"
+
 #include <glib.h>
 
 #include <dirent.h>
@@ -12,17 +14,15 @@
 
 #include <memory>
 
-#include "gmock/gmock.h"
-#include "gtest/gtest.h"
-
-#include "base/bind.h"
-#include "base/callback.h"
+#include <base/bind.h>
+#include <base/callback.h>
 #include <base/strings/stringprintf.h>
+#include <gmock/gmock.h>
+#include <gtest/gtest.h>
 #include <policy/libpolicy.h>
 #include <policy/mock_device_policy.h>
 
 #include "update_engine/fake_p2p_manager_configuration.h"
-#include "update_engine/p2p_manager.h"
 #include "update_engine/prefs.h"
 #include "update_engine/test_utils.h"
 #include "update_engine/utils.h"
diff --git a/payload_state_unittest.cc b/payload_state_unittest.cc
index 24f75e8..c449d4a 100644
--- a/payload_state_unittest.cc
+++ b/payload_state_unittest.cc
@@ -17,9 +17,9 @@
 #include "update_engine/fake_hardware.h"
 #include "update_engine/fake_prefs.h"
 #include "update_engine/fake_system_state.h"
+#include "update_engine/mock_prefs.h"
 #include "update_engine/omaha_request_action.h"
 #include "update_engine/prefs.h"
-#include "update_engine/prefs_mock.h"
 #include "update_engine/test_utils.h"
 #include "update_engine/utils.h"
 
@@ -105,7 +105,7 @@
 TEST(PayloadStateTest, SetResponseWorksWithEmptyResponse) {
   OmahaResponse response;
   FakeSystemState fake_system_state;
-  NiceMock<PrefsMock>* prefs = fake_system_state.mock_prefs();
+  NiceMock<MockPrefs>* prefs = fake_system_state.mock_prefs();
   EXPECT_CALL(*prefs, SetInt64(_, _)).Times(AnyNumber());
   EXPECT_CALL(*prefs, SetInt64(kPrefsPayloadAttemptNumber, 0))
     .Times(AtLeast(1));
@@ -153,7 +153,7 @@
   response.metadata_size = 58123;
   response.metadata_signature = "msign";
   FakeSystemState fake_system_state;
-  NiceMock<PrefsMock>* prefs = fake_system_state.mock_prefs();
+  NiceMock<MockPrefs>* prefs = fake_system_state.mock_prefs();
   EXPECT_CALL(*prefs, SetInt64(_, _)).Times(AnyNumber());
   EXPECT_CALL(*prefs, SetInt64(kPrefsPayloadAttemptNumber, 0))
     .Times(AtLeast(1));
@@ -206,7 +206,7 @@
   response.metadata_size = 558123;
   response.metadata_signature = "metasign";
   FakeSystemState fake_system_state;
-  NiceMock<PrefsMock>* prefs = fake_system_state.mock_prefs();
+  NiceMock<MockPrefs>* prefs = fake_system_state.mock_prefs();
   EXPECT_CALL(*prefs, SetInt64(_, _)).Times(AnyNumber());
   EXPECT_CALL(*prefs, SetInt64(kPrefsPayloadAttemptNumber, 0))
     .Times(AtLeast(1));
@@ -251,7 +251,7 @@
 TEST(PayloadStateTest, CanAdvanceUrlIndexCorrectly) {
   OmahaResponse response;
   FakeSystemState fake_system_state;
-  NiceMock<PrefsMock>* prefs = fake_system_state.mock_prefs();
+  NiceMock<MockPrefs>* prefs = fake_system_state.mock_prefs();
   PayloadState payload_state;
 
   EXPECT_CALL(*prefs, SetInt64(_, _)).Times(AnyNumber());
@@ -366,7 +366,7 @@
   PayloadState payload_state;
   FakeSystemState fake_system_state;
   int progress_bytes = 100;
-  NiceMock<PrefsMock>* prefs = fake_system_state.mock_prefs();
+  NiceMock<MockPrefs>* prefs = fake_system_state.mock_prefs();
 
   EXPECT_CALL(*prefs, SetInt64(_, _)).Times(AnyNumber());
   EXPECT_CALL(*prefs, SetInt64(kPrefsPayloadAttemptNumber, 0))
@@ -511,7 +511,7 @@
   response.is_delta_payload = false;
   PayloadState payload_state;
   FakeSystemState fake_system_state;
-  NiceMock<PrefsMock>* prefs = fake_system_state.mock_prefs();
+  NiceMock<MockPrefs>* prefs = fake_system_state.mock_prefs();
 
   EXPECT_CALL(*prefs, SetInt64(_, _)).Times(AnyNumber());
   EXPECT_CALL(*prefs, SetInt64(kPrefsPayloadAttemptNumber, 0))
@@ -557,7 +557,7 @@
   response.is_delta_payload = true;
   PayloadState payload_state;
   FakeSystemState fake_system_state;
-  NiceMock<PrefsMock>* prefs = fake_system_state.mock_prefs();
+  NiceMock<MockPrefs>* prefs = fake_system_state.mock_prefs();
 
   EXPECT_CALL(*prefs, SetInt64(_, _)).Times(AnyNumber());
   EXPECT_CALL(*prefs, SetInt64(kPrefsPayloadAttemptNumber, 0))
@@ -622,7 +622,7 @@
   // loaded when update_engine restarts. Using a different prefs object
   // so as to not bother accounting for the uninteresting calls above.
   FakeSystemState fake_system_state2;
-  NiceMock<PrefsMock>* prefs2 = fake_system_state2.mock_prefs();
+  NiceMock<MockPrefs>* prefs2 = fake_system_state2.mock_prefs();
   EXPECT_CALL(*prefs2, Exists(_)).WillRepeatedly(Return(true));
   EXPECT_CALL(*prefs2, GetInt64(_, _)).Times(AtLeast(1));
   EXPECT_CALL(*prefs2, GetInt64(kPrefsPayloadAttemptNumber, _))
@@ -1025,7 +1025,7 @@
   FakeSystemState fake_system_state;
   PayloadState payload_state;
 
-  NiceMock<PrefsMock>* prefs = fake_system_state.mock_prefs();
+  NiceMock<MockPrefs>* prefs = fake_system_state.mock_prefs();
   EXPECT_CALL(*prefs, SetInt64(_, _)).Times(AtLeast(0));
   EXPECT_CALL(*prefs, SetInt64(kPrefsNumReboots, 1)).Times(AtLeast(1));
 
@@ -1053,7 +1053,7 @@
   FakeSystemState fake_system_state;
   PayloadState payload_state;
 
-  NiceMock<PrefsMock>* mock_powerwash_safe_prefs =
+  NiceMock<MockPrefs>* mock_powerwash_safe_prefs =
       fake_system_state.mock_powerwash_safe_prefs();
   EXPECT_TRUE(payload_state.Initialize(&fake_system_state));
 
@@ -1205,7 +1205,7 @@
 TEST(PayloadStateTest, RestartAfterCrash) {
   PayloadState payload_state;
   FakeSystemState fake_system_state;
-  NiceMock<PrefsMock>* prefs = fake_system_state.mock_prefs();
+  NiceMock<MockPrefs>* prefs = fake_system_state.mock_prefs();
 
   EXPECT_TRUE(payload_state.Initialize(&fake_system_state));
 
diff --git a/update_attempter_unittest.cc b/update_attempter_unittest.cc
index b01fbda..d2b1e14 100644
--- a/update_attempter_unittest.cc
+++ b/update_attempter_unittest.cc
@@ -13,20 +13,20 @@
 #include <policy/libpolicy.h>
 #include <policy/mock_device_policy.h>
 
-#include "update_engine/action_mock.h"
-#include "update_engine/action_processor_mock.h"
 #include "update_engine/fake_clock.h"
 #include "update_engine/fake_prefs.h"
 #include "update_engine/fake_system_state.h"
 #include "update_engine/filesystem_copier_action.h"
 #include "update_engine/install_plan.h"
+#include "update_engine/mock_action.h"
+#include "update_engine/mock_action_processor.h"
 #include "update_engine/mock_dbus_wrapper.h"
 #include "update_engine/mock_http_fetcher.h"
 #include "update_engine/mock_p2p_manager.h"
 #include "update_engine/mock_payload_state.h"
+#include "update_engine/mock_prefs.h"
 #include "update_engine/postinstall_runner_action.h"
 #include "update_engine/prefs.h"
-#include "update_engine/prefs_mock.h"
 #include "update_engine/test_utils.h"
 #include "update_engine/utils.h"
 
@@ -119,7 +119,7 @@
     EXPECT_EQ(0, attempter_.last_checked_time_);
     EXPECT_EQ("0.0.0.0", attempter_.new_version_);
     EXPECT_EQ(0, attempter_.new_payload_size_);
-    processor_ = new NiceMock<ActionProcessorMock>();
+    processor_ = new NiceMock<MockActionProcessor>();
     attempter_.processor_.reset(processor_);  // Transfers ownership.
     prefs_ = fake_system_state_.mock_prefs();
 
@@ -199,8 +199,8 @@
   FakeSystemState fake_system_state_;
   NiceMock<MockDBusWrapper> dbus_;
   UpdateAttempterUnderTest attempter_;
-  NiceMock<ActionProcessorMock>* processor_;
-  NiceMock<PrefsMock>* prefs_;  // Shortcut to fake_system_state_->mock_prefs().
+  NiceMock<MockActionProcessor>* processor_;
+  NiceMock<MockPrefs>* prefs_;  // Shortcut to fake_system_state_->mock_prefs().
   NiceMock<MockConnectionManager> mock_connection_manager;
   GMainLoop* loop_;
 
@@ -222,8 +222,8 @@
 }
 
 TEST_F(UpdateAttempterTest, ActionCompletedErrorTest) {
-  ActionMock action;
-  EXPECT_CALL(action, Type()).WillRepeatedly(Return("ActionMock"));
+  MockAction action;
+  EXPECT_CALL(action, Type()).WillRepeatedly(Return("MockAction"));
   attempter_.status_ = UPDATE_STATUS_DOWNLOADING;
   EXPECT_CALL(*prefs_, GetInt64(kPrefsDeltaUpdateFailures, _))
       .WillOnce(Return(false));
@@ -286,8 +286,8 @@
   EXPECT_EQ(ErrorCode::kPostinstallRunnerError,
             GetErrorCodeForAction(&postinstall_runner_action,
                                   ErrorCode::kError));
-  ActionMock action_mock;
-  EXPECT_CALL(action_mock, Type()).WillOnce(Return("ActionMock"));
+  MockAction action_mock;
+  EXPECT_CALL(action_mock, Type()).WillOnce(Return("MockAction"));
   EXPECT_EQ(ErrorCode::kError,
             GetErrorCodeForAction(&action_mock, ErrorCode::kError));
 }
@@ -627,7 +627,7 @@
 }
 
 TEST_F(UpdateAttempterTest, CreatePendingErrorEventTest) {
-  ActionMock action;
+  MockAction action;
   const ErrorCode kCode = ErrorCode::kDownloadTransferError;
   attempter_.CreatePendingErrorEvent(&action, kCode);
   ASSERT_NE(nullptr, attempter_.error_event_.get());
@@ -644,7 +644,7 @@
       new OmahaResponseHandlerAction(&fake_system_state_);
   response_action->install_plan_.is_resume = true;
   attempter_.response_handler_action_.reset(response_action);
-  ActionMock action;
+  MockAction action;
   const ErrorCode kCode = ErrorCode::kInstallDeviceOpenError;
   attempter_.CreatePendingErrorEvent(&action, kCode);
   ASSERT_NE(nullptr, attempter_.error_event_.get());
diff --git a/update_manager/real_updater_provider_unittest.cc b/update_manager/real_updater_provider_unittest.cc
index 1477187..e253d39 100644
--- a/update_manager/real_updater_provider_unittest.cc
+++ b/update_manager/real_updater_provider_unittest.cc
@@ -13,17 +13,17 @@
 
 #include "update_engine/fake_clock.h"
 #include "update_engine/fake_system_state.h"
+#include "update_engine/mock_prefs.h"
 #include "update_engine/mock_update_attempter.h"
 #include "update_engine/omaha_request_params.h"
-#include "update_engine/prefs_mock.h"
 #include "update_engine/update_manager/umtest_utils.h"
 
 using base::Time;
 using base::TimeDelta;
 using chromeos_update_engine::FakeClock;
 using chromeos_update_engine::FakeSystemState;
+using chromeos_update_engine::MockPrefs;
 using chromeos_update_engine::OmahaRequestParams;
-using chromeos_update_engine::PrefsMock;
 using std::string;
 using std::unique_ptr;
 using testing::Return;
@@ -76,7 +76,7 @@
   // so |output| is the value being read.
   void SetupReadBooleanPref(const char* key, bool key_exists,
                             bool get_boolean_success, bool output) {
-    PrefsMock* const mock_prefs = fake_sys_state_.mock_prefs();
+    MockPrefs* const mock_prefs = fake_sys_state_.mock_prefs();
     EXPECT_CALL(*mock_prefs, Exists(StrEq(key))).WillOnce(Return(key_exists));
     if (key_exists) {
       auto& get_boolean = EXPECT_CALL(