summaryrefslogtreecommitdiffstats
path: root/chrome/browser/policy/mock_device_management_backend.h
diff options
context:
space:
mode:
authordanno@chromium.org <danno@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-11-24 13:18:56 +0000
committerdanno@chromium.org <danno@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-11-24 13:18:56 +0000
commit180e70131e43e4be95b3bb6448ab2cd8392ca633 (patch)
tree9bbd5be769387c62e1b5c5a2aee7cf227085533f /chrome/browser/policy/mock_device_management_backend.h
parent4712e8528ddbdffe188aeeb84d57c4a1c7660eda (diff)
downloadchromium_src-180e70131e43e4be95b3bb6448ab2cd8392ca633.zip
chromium_src-180e70131e43e4be95b3bb6448ab2cd8392ca633.tar.gz
chromium_src-180e70131e43e4be95b3bb6448ab2cd8392ca633.tar.bz2
Cleanup mock device management backend
Add actions for mock device management backend for request success and failure. BUG=62482 TEST=DeviceManagementPolicyProviderTest*:DeviceTokenFetcherTest* Review URL: http://codereview.chromium.org/5338004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@67255 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/policy/mock_device_management_backend.h')
-rw-r--r--chrome/browser/policy/mock_device_management_backend.h80
1 files changed, 33 insertions, 47 deletions
diff --git a/chrome/browser/policy/mock_device_management_backend.h b/chrome/browser/policy/mock_device_management_backend.h
index 9371dc0..3b0cb33 100644
--- a/chrome/browser/policy/mock_device_management_backend.h
+++ b/chrome/browser/policy/mock_device_management_backend.h
@@ -24,8 +24,8 @@ namespace em = enterprise_management;
class MockDeviceManagementBackend
: public DeviceManagementBackend {
public:
- MockDeviceManagementBackend();
- virtual ~MockDeviceManagementBackend();
+ MockDeviceManagementBackend() {}
+ virtual ~MockDeviceManagementBackend() {}
// DeviceManagementBackend method overrides:
MOCK_METHOD4(ProcessRegisterRequest, void(
@@ -46,55 +46,41 @@ class MockDeviceManagementBackend
const em::DevicePolicyRequest& request,
DevicePolicyResponseDelegate* delegate));
- void AllShouldSucceed();
- void AllShouldFail();
- void UnmanagedDevice();
- void RegisterFailsOncePolicyFailsTwice();
- void AllWorksFirstPolicyFailsLater();
-
- void SimulateSuccessfulRegisterRequest(
- const std::string& auth_token,
- const std::string& device_id,
- const em::DeviceRegisterRequest& request,
- DeviceRegisterResponseDelegate* delegate);
-
- void SimulateSuccessfulPolicyRequest(
- const std::string& device_management_token,
- const std::string& device_id,
- const em::DevicePolicyRequest& request,
- DevicePolicyResponseDelegate* delegate);
-
- void SimulateFailedRegisterRequest(
- const std::string& auth_token,
- const std::string& device_id,
- const em::DeviceRegisterRequest& request,
- DeviceRegisterResponseDelegate* delegate);
-
- void SimulateFailedPolicyRequest(
- const std::string& device_management_token,
- const std::string& device_id,
- const em::DevicePolicyRequest& request,
- DevicePolicyResponseDelegate* delegate);
-
- void SimulateUnmanagedRegisterRequest(
- const std::string& auth_token,
- const std::string& device_id,
- const em::DeviceRegisterRequest& request,
- DeviceRegisterResponseDelegate* delegate);
-
- void AddBooleanPolicy(const char* policy_name, bool value);
-
private:
- em::DevicePolicyResponse policy_response_;
- em::DevicePolicySetting* policy_setting_;
-
- int policy_remaining_fail_count_;
- int register_remaining_fail_count_;
- int policy_remaining_success_count_;
-
DISALLOW_COPY_AND_ASSIGN(MockDeviceManagementBackend);
};
+ACTION(MockDeviceManagementBackendSucceedRegister) {
+ em::DeviceRegisterResponse response;
+ std::string token("FAKE_DEVICE_TOKEN_");
+ static int next_token_suffix;
+ token += next_token_suffix++;
+ response.set_device_management_token(token);
+ arg3->HandleRegisterResponse(response);
+}
+
+ACTION_P2(MockDeviceManagementBackendSucceedBooleanPolicy, name, value) {
+ em::DevicePolicyResponse response;
+ em::DevicePolicySetting* setting = response.add_setting();
+ setting->set_policy_key("chrome-policy");
+ setting->set_watermark("fresh");
+ em::GenericSetting* policy_value = setting->mutable_policy_value();
+ em::GenericNamedValue* named_value = policy_value->add_named_value();
+ named_value->set_name(name);
+ named_value->mutable_value()->set_value_type(
+ em::GenericValue::VALUE_TYPE_BOOL);
+ named_value->mutable_value()->set_bool_value(value);
+ arg3->HandlePolicyResponse(response);
+}
+
+ACTION_P(MockDeviceManagementBackendFailRegister, error) {
+ arg3->OnError(error);
+}
+
+ACTION_P(MockDeviceManagementBackendFailPolicy, error) {
+ arg3->OnError(error);
+}
+
} // namespace policy
#endif // CHROME_BROWSER_POLICY_MOCK_DEVICE_MANAGEMENT_BACKEND_H_