OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROME_BROWSER_POLICY_MOCK_DEVICE_MANAGEMENT_BACKEND_H_ | 5 #ifndef CHROME_BROWSER_POLICY_MOCK_DEVICE_MANAGEMENT_BACKEND_H_ |
6 #define CHROME_BROWSER_POLICY_MOCK_DEVICE_MANAGEMENT_BACKEND_H_ | 6 #define CHROME_BROWSER_POLICY_MOCK_DEVICE_MANAGEMENT_BACKEND_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <map> | 9 #include <map> |
10 #include <string> | 10 #include <string> |
11 | 11 |
12 #include "base/values.h" | 12 #include "base/values.h" |
13 #include "chrome/browser/policy/device_management_backend.h" | 13 #include "chrome/browser/policy/device_management_backend.h" |
| 14 #include "testing/gmock/include/gmock/gmock.h" |
14 #include "testing/gtest/include/gtest/gtest.h" | 15 #include "testing/gtest/include/gtest/gtest.h" |
15 #include "testing/gmock/include/gmock/gmock.h" | |
16 | 16 |
17 namespace policy { | 17 namespace policy { |
18 | 18 |
19 namespace em = enterprise_management; | 19 namespace em = enterprise_management; |
20 | 20 |
21 // Useful for unit testing when a server-based backend isn't | 21 // Useful for unit testing when a server-based backend isn't |
22 // available. Simulates both successful and failed requests to the device | 22 // available. Simulates both successful and failed requests to the device |
23 // management server. | 23 // management server. |
24 class MockDeviceManagementBackend | 24 class MockDeviceManagementBackend |
25 : public DeviceManagementBackend { | 25 : public DeviceManagementBackend { |
(...skipping 16 matching lines...) Expand all Loading... |
42 | 42 |
43 MOCK_METHOD4(ProcessPolicyRequest, void( | 43 MOCK_METHOD4(ProcessPolicyRequest, void( |
44 const std::string& device_management_token, | 44 const std::string& device_management_token, |
45 const std::string& device_id, | 45 const std::string& device_id, |
46 const em::DevicePolicyRequest& request, | 46 const em::DevicePolicyRequest& request, |
47 DevicePolicyResponseDelegate* delegate)); | 47 DevicePolicyResponseDelegate* delegate)); |
48 | 48 |
49 void AllShouldSucceed(); | 49 void AllShouldSucceed(); |
50 void AllShouldFail(); | 50 void AllShouldFail(); |
51 void UnmanagedDevice(); | 51 void UnmanagedDevice(); |
| 52 void RegisterFailsOncePolicyFailsTwice(); |
| 53 void AllWorksFirstPolicyFailsLater(); |
52 | 54 |
53 void SimulateSuccessfulRegisterRequest( | 55 void SimulateSuccessfulRegisterRequest( |
54 const std::string& auth_token, | 56 const std::string& auth_token, |
55 const std::string& device_id, | 57 const std::string& device_id, |
56 const em::DeviceRegisterRequest& request, | 58 const em::DeviceRegisterRequest& request, |
57 DeviceRegisterResponseDelegate* delegate); | 59 DeviceRegisterResponseDelegate* delegate); |
58 | 60 |
59 void SimulateSuccessfulPolicyRequest( | 61 void SimulateSuccessfulPolicyRequest( |
60 const std::string& device_management_token, | 62 const std::string& device_management_token, |
61 const std::string& device_id, | 63 const std::string& device_id, |
(...skipping 17 matching lines...) Expand all Loading... |
79 const std::string& device_id, | 81 const std::string& device_id, |
80 const em::DeviceRegisterRequest& request, | 82 const em::DeviceRegisterRequest& request, |
81 DeviceRegisterResponseDelegate* delegate); | 83 DeviceRegisterResponseDelegate* delegate); |
82 | 84 |
83 void AddBooleanPolicy(const char* policy_name, bool value); | 85 void AddBooleanPolicy(const char* policy_name, bool value); |
84 | 86 |
85 private: | 87 private: |
86 em::DevicePolicyResponse policy_response_; | 88 em::DevicePolicyResponse policy_response_; |
87 em::DevicePolicySetting* policy_setting_; | 89 em::DevicePolicySetting* policy_setting_; |
88 | 90 |
| 91 int policy_remaining_fail_count_; |
| 92 int register_remaining_fail_count_; |
| 93 int policy_remaining_success_count_; |
| 94 |
89 DISALLOW_COPY_AND_ASSIGN(MockDeviceManagementBackend); | 95 DISALLOW_COPY_AND_ASSIGN(MockDeviceManagementBackend); |
90 }; | 96 }; |
91 | 97 |
92 } // namespace policy | 98 } // namespace policy |
93 | 99 |
94 #endif // CHROME_BROWSER_POLICY_MOCK_DEVICE_MANAGEMENT_BACKEND_H_ | 100 #endif // CHROME_BROWSER_POLICY_MOCK_DEVICE_MANAGEMENT_BACKEND_H_ |
OLD | NEW |