Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2528)

Unified Diff: chrome/browser/policy/mock_device_management_service.cc

Issue 9109009: Introduce CloudPolicyClient (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Restore DCHECKS. Created 8 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/policy/mock_device_management_service.h ('k') | chrome/browser/policy/policy_constants.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/policy/mock_device_management_service.cc
diff --git a/chrome/browser/policy/mock_device_management_service.cc b/chrome/browser/policy/mock_device_management_service.cc
index d143d27d6ea21439fb560bccb1225c8fcea58a7b..106e4545570e8132c7080d1d4704b1767287f3c7 100644
--- a/chrome/browser/policy/mock_device_management_service.cc
+++ b/chrome/browser/policy/mock_device_management_service.cc
@@ -4,6 +4,10 @@
#include "chrome/browser/policy/mock_device_management_service.h"
+#include "base/string_util.h"
+
+using testing::Action;
+
namespace em = enterprise_management;
namespace policy {
@@ -19,14 +23,33 @@ class MockDeviceManagementRequestJob : public DeviceManagementRequestJob {
service_(service),
status_(status),
response_(response) {}
+ virtual ~MockDeviceManagementRequestJob() {}
protected:
virtual void Run() OVERRIDE {
- service_->StartJob(this);
+ service_->StartJob(ExtractParameter(dm_protocol::kParamRequest),
+ gaia_token_,
+ ExtractParameter(dm_protocol::kParamOAuthToken),
+ dm_token_,
+ ExtractParameter(dm_protocol::kParamUserAffiliation),
+ ExtractParameter(dm_protocol::kParamDeviceID),
+ request_);
callback_.Run(status_, response_);
}
private:
+ // Searches for a query parameter and returns the associated value.
+ const std::string& ExtractParameter(const std::string& name) const {
+ for (ParameterMap::const_iterator entry(query_params_.begin());
+ entry != query_params_.end();
+ ++entry) {
+ if (name == entry->first)
+ return entry->second;
+ }
+
+ return EmptyString();
+ }
+
MockDeviceManagementService* service_;
DeviceManagementStatus status_;
enterprise_management::DeviceManagementResponse response_;
@@ -43,14 +66,14 @@ MockDeviceManagementService::MockDeviceManagementService()
MockDeviceManagementService::~MockDeviceManagementService() {}
-testing::Action<MockDeviceManagementService::CreateJobFunction>
+Action<MockDeviceManagementService::CreateJobFunction>
MockDeviceManagementService::SucceedJob(
const enterprise_management::DeviceManagementResponse& response) {
return CreateMockDeviceManagementRequestJob(this, DM_STATUS_SUCCESS,
response);
}
-testing::Action<MockDeviceManagementService::CreateJobFunction>
+Action<MockDeviceManagementService::CreateJobFunction>
MockDeviceManagementService::FailJob(DeviceManagementStatus status) {
const enterprise_management::DeviceManagementResponse dummy_response;
return CreateMockDeviceManagementRequestJob(this, status, dummy_response);
« no previous file with comments | « chrome/browser/policy/mock_device_management_service.h ('k') | chrome/browser/policy/policy_constants.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698