Fix/extend unit test related functionality.

* Adds mock methods to UpdateAttempterMock and turning corresponding
  base methods into a virtual (needed for subsequent unit testing).

* Adds a setter to OmahaRequestParams.

* Limited general cleanup.

BUG=chromium:346914
TEST=Unit tests.

Change-Id: I0519ad5c43ddebabc1aff6585cf43a290a2081dc
Reviewed-on: https://chromium-review.googlesource.com/192660
Reviewed-by: Alex Deymo <deymo@chromium.org>
Commit-Queue: Gilad Arnold <garnold@chromium.org>
Tested-by: Gilad Arnold <garnold@chromium.org>
diff --git a/mock_system_state.cc b/mock_system_state.cc
index 00e9c12..e7ec886 100644
--- a/mock_system_state.cc
+++ b/mock_system_state.cc
@@ -4,7 +4,6 @@
 
 #include "update_engine/mock_system_state.h"
 #include "update_engine/policy_manager/fake_state.h"
-#include "update_engine/update_attempter_mock.h"
 
 using chromeos_policy_manager::FakeState;
 
@@ -37,8 +36,4 @@
   delete mock_gpio_handler_;
 }
 
-UpdateAttempter* MockSystemState::update_attempter() {
-  return mock_update_attempter_;
-}
-
 }  // namespace chromeos_update_engine
diff --git a/mock_system_state.h b/mock_system_state.h
index 19efaf1..73987d5 100644
--- a/mock_system_state.h
+++ b/mock_system_state.h
@@ -20,6 +20,7 @@
 #include "update_engine/policy_manager/fake_policy_manager.h"
 #include "update_engine/prefs_mock.h"
 #include "update_engine/system_state.h"
+#include "update_engine/update_attempter_mock.h"
 
 namespace chromeos_update_engine {
 
@@ -69,7 +70,9 @@
     return mock_gpio_handler_;
   }
 
-  virtual UpdateAttempter* update_attempter();
+  inline virtual UpdateAttempterMock* update_attempter() const override {
+    return mock_update_attempter_;
+  }
 
   inline virtual OmahaRequestParams* request_params() {
     return request_params_;
diff --git a/omaha_request_params.h b/omaha_request_params.h
index b04640c..b370bb7 100644
--- a/omaha_request_params.h
+++ b/omaha_request_params.h
@@ -247,6 +247,9 @@
   void set_current_channel(const std::string& channel) {
     current_channel_ = channel;
   }
+  void set_target_channel(const std::string& channel) {
+    target_channel_ = channel;
+  }
 
   // Enforce security mode for testing purposes.
   void SetLockDown(bool lock);
diff --git a/real_system_state.h b/real_system_state.h
index ed24ed8..df1280f 100644
--- a/real_system_state.h
+++ b/real_system_state.h
@@ -69,7 +69,7 @@
     return gpio_handler_.get();
   }
 
-  virtual inline UpdateAttempter* update_attempter() {
+  virtual inline UpdateAttempter* update_attempter() const override {
     return update_attempter_.get();
   }
 
diff --git a/system_state.h b/system_state.h
index ce561e1..987cb6c 100644
--- a/system_state.h
+++ b/system_state.h
@@ -76,7 +76,7 @@
   virtual GpioHandler* gpio_handler() const = 0;
 
   // Returns a pointer to the update attempter object.
-  virtual UpdateAttempter* update_attempter() = 0;
+  virtual UpdateAttempter* update_attempter() const = 0;
 
   // Returns a pointer to the object that stores the parameters that are
   // common to all Omaha requests.
diff --git a/update_attempter.h b/update_attempter.h
index dfde4ff..20b0173 100644
--- a/update_attempter.h
+++ b/update_attempter.h
@@ -100,11 +100,11 @@
   bool ResetStatus();
 
   // Returns the current status in the out params. Returns true on success.
-  bool GetStatus(int64_t* last_checked_time,
-                 double* progress,
-                 std::string* current_operation,
-                 std::string* new_version,
-                 int64_t* new_size);
+  virtual bool GetStatus(int64_t* last_checked_time,
+                         double* progress,
+                         std::string* current_operation,
+                         std::string* new_version,
+                         int64_t* new_size);
 
   // Runs chromeos-setgoodkernel, whose responsibility it is to mark the
   // currently booted partition has high priority/permanent/etc. The execution
@@ -192,7 +192,7 @@
 
   // Returns the boottime (CLOCK_BOOTTIME) recorded at the last
   // successful update. Returns false if the device has not updated.
-  bool GetBootTimeAtUpdate(base::Time *out_boot_time);
+  virtual bool GetBootTimeAtUpdate(base::Time *out_boot_time);
 
   // Returns a version OS version that was being used before the last reboot,
   // and if that reboot happended to be into an update (current version).
diff --git a/update_attempter_mock.h b/update_attempter_mock.h
index af1b7c1..29e46bc 100644
--- a/update_attempter_mock.h
+++ b/update_attempter_mock.h
@@ -5,27 +5,29 @@
 #ifndef CHROMEOS_PLATFORM_UPDATE_ENGINE_UPDATE_ATTEMPTER_MOCK_H_
 #define CHROMEOS_PLATFORM_UPDATE_ENGINE_UPDATE_ATTEMPTER_MOCK_H_
 
-#include <gmock/gmock.h>
-
-#include "update_engine/mock_dbus_wrapper.h"
-#include "update_engine/mock_system_state.h"
 #include "update_engine/update_attempter.h"
 
+#include <gmock/gmock.h>
+
 namespace chromeos_update_engine {
 
-class MockSystemState;
-
 class UpdateAttempterMock : public UpdateAttempter {
  public:
-  explicit UpdateAttempterMock(MockSystemState* mock_system_state,
-                               MockDBusWrapper* dbus)
-      : UpdateAttempter(mock_system_state, dbus) {}
+  using UpdateAttempter::UpdateAttempter;
 
   MOCK_METHOD5(Update, void(const std::string& app_version,
                             const std::string& omaha_url,
                             bool obey_proxies,
                             bool interactive,
                             bool is_test));
+
+  MOCK_METHOD5(GetStatus, bool(int64_t* last_checked_time,
+                               double* progress,
+                               std::string* current_operation,
+                               std::string* new_version,
+                               int64_t* new_size));
+
+  MOCK_METHOD1(GetBootTimeAtUpdate, bool(base::Time* out_boot_time));
 };
 
 }  // namespace chromeos_update_engine