| 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 14 matching lines...) Expand all Loading... |
| 40 DeviceUnregisterResponseDelegate* delegate)); | 40 DeviceUnregisterResponseDelegate* delegate)); |
| 41 | 41 |
| 42 MOCK_METHOD3(ProcessPolicyRequest, void( | 42 MOCK_METHOD3(ProcessPolicyRequest, void( |
| 43 const std::string& device_management_token, | 43 const std::string& device_management_token, |
| 44 const em::DevicePolicyRequest& request, | 44 const em::DevicePolicyRequest& request, |
| 45 DevicePolicyResponseDelegate* delegate)); | 45 DevicePolicyResponseDelegate* delegate)); |
| 46 | 46 |
| 47 void AllShouldSucceed(); | 47 void AllShouldSucceed(); |
| 48 void AllShouldFail(); | 48 void AllShouldFail(); |
| 49 void UnmanagedDevice(); | 49 void UnmanagedDevice(); |
| 50 void RegisterFailsOncePolicyFailsTwice(); |
| 51 void AllWorksFirstPolicyFailsLater(); |
| 50 | 52 |
| 51 void SimulateSuccessfulRegisterRequest( | 53 void SimulateSuccessfulRegisterRequest( |
| 52 const std::string& auth_token, | 54 const std::string& auth_token, |
| 53 const std::string& device_id, | 55 const std::string& device_id, |
| 54 const em::DeviceRegisterRequest& request, | 56 const em::DeviceRegisterRequest& request, |
| 55 DeviceRegisterResponseDelegate* delegate); | 57 DeviceRegisterResponseDelegate* delegate); |
| 56 | 58 |
| 57 void SimulateSuccessfulPolicyRequest( | 59 void SimulateSuccessfulPolicyRequest( |
| 58 const std::string& device_management_token, | 60 const std::string& device_management_token, |
| 59 const em::DevicePolicyRequest& request, | 61 const em::DevicePolicyRequest& request, |
| (...skipping 15 matching lines...) Expand all Loading... |
| 75 const std::string& device_id, | 77 const std::string& device_id, |
| 76 const em::DeviceRegisterRequest& request, | 78 const em::DeviceRegisterRequest& request, |
| 77 DeviceRegisterResponseDelegate* delegate); | 79 DeviceRegisterResponseDelegate* delegate); |
| 78 | 80 |
| 79 void AddBooleanPolicy(const char* policy_name, bool value); | 81 void AddBooleanPolicy(const char* policy_name, bool value); |
| 80 | 82 |
| 81 private: | 83 private: |
| 82 em::DevicePolicyResponse policy_response_; | 84 em::DevicePolicyResponse policy_response_; |
| 83 em::DevicePolicySetting* policy_setting_; | 85 em::DevicePolicySetting* policy_setting_; |
| 84 | 86 |
| 87 bool policy_works_later_; |
| 88 int policy_remaining_fail_count_; |
| 89 bool register_works_later_; |
| 90 int register_remaining_fail_count_; |
| 91 bool policy_fails_later_; |
| 92 int policy_remaining_success_count_; |
| 93 |
| 85 DISALLOW_COPY_AND_ASSIGN(MockDeviceManagementBackend); | 94 DISALLOW_COPY_AND_ASSIGN(MockDeviceManagementBackend); |
| 86 }; | 95 }; |
| 87 | 96 |
| 88 } // namespace policy | 97 } // namespace policy |
| 89 | 98 |
| 90 #endif // CHROME_BROWSER_POLICY_MOCK_DEVICE_MANAGEMENT_BACKEND_H_ | 99 #endif // CHROME_BROWSER_POLICY_MOCK_DEVICE_MANAGEMENT_BACKEND_H_ |
| OLD | NEW |