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

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

Issue 7345010: Tests for cloud policy UMA metrics. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Refactored as a browser_test, share mocks Created 9 years, 5 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
Index: chrome/browser/policy/mock_device_management_service.h
diff --git a/chrome/browser/policy/mock_device_management_service.h b/chrome/browser/policy/mock_device_management_service.h
index e481f1eaeec9f6f14ede1c9056f2b5376bcdb4f8..710ef7c8dda74ddd2344ae4b3c66801085fb3023 100644
--- a/chrome/browser/policy/mock_device_management_service.h
+++ b/chrome/browser/policy/mock_device_management_service.h
@@ -8,9 +8,11 @@
#include <string>
+#include "base/basictypes.h"
#include "chrome/browser/policy/device_management_backend.h"
#include "chrome/browser/policy/device_management_service.h"
#include "chrome/browser/policy/proto/device_management_backend.pb.h"
+#include "net/url_request/url_request_status.h"
namespace policy {
@@ -26,19 +28,19 @@ class ProxyDeviceManagementBackend : public DeviceManagementBackend {
const std::string& auth_token,
const std::string& device_id,
const em::DeviceRegisterRequest& request,
- DeviceRegisterResponseDelegate* delegate);
+ DeviceRegisterResponseDelegate* delegate) OVERRIDE;
virtual void ProcessUnregisterRequest(
const std::string& device_management_token,
const std::string& device_id,
const em::DeviceUnregisterRequest& request,
- DeviceUnregisterResponseDelegate* delegate);
+ DeviceUnregisterResponseDelegate* delegate) OVERRIDE;
virtual void ProcessPolicyRequest(
const std::string& device_management_token,
const std::string& device_id,
const em::DevicePolicyRequest& request,
- DevicePolicyResponseDelegate* delegate);
+ DevicePolicyResponseDelegate* delegate) OVERRIDE;
private:
DeviceManagementBackend* backend_; // weak
@@ -50,14 +52,41 @@ class MockDeviceManagementService : public DeviceManagementService {
MockDeviceManagementService();
virtual ~MockDeviceManagementService();
+ // If backend is set, this mock will just provide proxies for it on calls
+ // to CreateBackend().
void set_backend(DeviceManagementBackend* backend) {
backend_ = backend;
}
- virtual DeviceManagementBackend* CreateBackend();
+ virtual DeviceManagementBackend* CreateBackend() OVERRIDE;
+
+ // If the backend is set, this method will pass-through to the super class.
+ // Otherwise, this method will use the parameters stored and complete the
+ // job immediately.
+ virtual void StartJob(DeviceManagementJob* job) OVERRIDE;
+
+ void set_url_request_status(const net::URLRequestStatus& status) {
+ status_ = status;
+ }
+
+ void set_response_code(int response_code) {
+ response_code_ = response_code;
+ }
+
+ void set_cookies(const net::ResponseCookies& cookies) {
+ cookies_ = cookies;
+ }
+
+ void set_data(const std::string& data) {
+ data_ = data;
+ }
private:
DeviceManagementBackend* backend_; // weak
+ net::URLRequestStatus status_;
+ int response_code_;
+ net::ResponseCookies cookies_;
+ std::string data_;
DISALLOW_COPY_AND_ASSIGN(MockDeviceManagementService);
};

Powered by Google App Engine
This is Rietveld 408576698