| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_SERVICE_H_ | 5 #ifndef CHROME_BROWSER_POLICY_MOCK_DEVICE_MANAGEMENT_SERVICE_H_ |
| 6 #define CHROME_BROWSER_POLICY_MOCK_DEVICE_MANAGEMENT_SERVICE_H_ | 6 #define CHROME_BROWSER_POLICY_MOCK_DEVICE_MANAGEMENT_SERVICE_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 52 DeviceManagementBackend* backend_; // weak | 52 DeviceManagementBackend* backend_; // weak |
| 53 DISALLOW_COPY_AND_ASSIGN(ProxyDeviceManagementBackend); | 53 DISALLOW_COPY_AND_ASSIGN(ProxyDeviceManagementBackend); |
| 54 }; | 54 }; |
| 55 | 55 |
| 56 class MockDeviceManagementService : public DeviceManagementService { | 56 class MockDeviceManagementService : public DeviceManagementService { |
| 57 public: | 57 public: |
| 58 MockDeviceManagementService(); | 58 MockDeviceManagementService(); |
| 59 virtual ~MockDeviceManagementService(); | 59 virtual ~MockDeviceManagementService(); |
| 60 | 60 |
| 61 MOCK_METHOD0(CreateBackend, DeviceManagementBackend*()); | 61 MOCK_METHOD0(CreateBackend, DeviceManagementBackend*()); |
| 62 MOCK_METHOD2(StartJob, void(DeviceManagementJob*, bool)); | |
| 63 | 62 |
| 64 // This method bypasses the mocked version and calls the superclass' | 63 // This method bypasses the mocked version and calls the superclass' |
| 65 // CreateBackend(), returning a "real" backend. | 64 // CreateBackend(), returning a "real" backend. |
| 66 DeviceManagementBackend* CreateBackendNotMocked() { | 65 DeviceManagementBackend* CreateBackendNotMocked() { |
| 67 return DeviceManagementService::CreateBackend(); | 66 return DeviceManagementService::CreateBackend(); |
| 68 } | 67 } |
| 69 | 68 |
| 70 // This method bypasses the mocked version and calls the superclass' | |
| 71 // StartJob. | |
| 72 void StartJobNotMocked(DeviceManagementJob* job, bool bypass_proxy) { | |
| 73 DeviceManagementService::StartJob(job, bypass_proxy); | |
| 74 } | |
| 75 | |
| 76 private: | 69 private: |
| 77 DISALLOW_COPY_AND_ASSIGN(MockDeviceManagementService); | 70 DISALLOW_COPY_AND_ASSIGN(MockDeviceManagementService); |
| 78 }; | 71 }; |
| 79 | 72 |
| 80 // Use this to make CreateBackend return a ProxyDeviceManagementBackend for | 73 // Use this to make CreateBackend return a ProxyDeviceManagementBackend for |
| 81 // the given |backend|. | 74 // the given |backend|. |
| 82 ACTION_P(MockDeviceManagementServiceProxyBackend, backend) { | 75 ACTION_P(MockDeviceManagementServiceProxyBackend, backend) { |
| 83 return new ProxyDeviceManagementBackend(backend); | 76 return new ProxyDeviceManagementBackend(backend); |
| 84 } | 77 } |
| 85 | 78 |
| 86 // Use this to make StartJob send a faked response to the job immediately. | 79 // Use this to make StartJob send a faked response to the job immediately. |
| 87 ACTION_P4(MockDeviceManagementServiceRespondToJob, status, response_code, | 80 ACTION_P4(MockDeviceManagementServiceRespondToJob, status, response_code, |
| 88 cookies, data) { | 81 cookies, data) { |
| 89 arg0->HandleResponse(status, response_code, cookies, data); | 82 arg0->HandleResponse(status, response_code, cookies, data); |
| 90 } | 83 } |
| 91 | 84 |
| 92 } // namespace policy | 85 } // namespace policy |
| 93 | 86 |
| 94 #endif // CHROME_BROWSER_POLICY_MOCK_DEVICE_MANAGEMENT_SERVICE_H_ | 87 #endif // CHROME_BROWSER_POLICY_MOCK_DEVICE_MANAGEMENT_SERVICE_H_ |
| OLD | NEW |