| 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 |
| 11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
| 12 #include "chrome/browser/policy/device_management_service.h" | 12 #include "chrome/browser/policy/device_management_service.h" |
| 13 #include "chrome/browser/policy/proto/device_management_backend.pb.h" |
| 13 #include "testing/gmock/include/gmock/gmock.h" | 14 #include "testing/gmock/include/gmock/gmock.h" |
| 14 | 15 |
| 15 namespace policy { | 16 namespace policy { |
| 16 | 17 |
| 18 class MockDeviceManagementJob { |
| 19 public: |
| 20 virtual ~MockDeviceManagementJob(); |
| 21 virtual void SendResponse( |
| 22 DeviceManagementStatus status, |
| 23 const enterprise_management::DeviceManagementResponse& response) = 0; |
| 24 }; |
| 25 |
| 17 class MockDeviceManagementService : public DeviceManagementService { | 26 class MockDeviceManagementService : public DeviceManagementService { |
| 18 public: | 27 public: |
| 19 MockDeviceManagementService(); | 28 MockDeviceManagementService(); |
| 20 virtual ~MockDeviceManagementService(); | 29 virtual ~MockDeviceManagementService(); |
| 21 | 30 |
| 22 typedef DeviceManagementRequestJob* CreateJobFunction( | 31 typedef DeviceManagementRequestJob* CreateJobFunction( |
| 23 DeviceManagementRequestJob::JobType); | 32 DeviceManagementRequestJob::JobType); |
| 24 | 33 |
| 25 MOCK_METHOD1(CreateJob, CreateJobFunction); | 34 MOCK_METHOD1(CreateJob, CreateJobFunction); |
| 26 MOCK_METHOD7( | 35 MOCK_METHOD7( |
| 27 StartJob, | 36 StartJob, |
| 28 void(const std::string& request_type, | 37 void(const std::string& request_type, |
| 29 const std::string& gaia_token, | 38 const std::string& gaia_token, |
| 30 const std::string& oauth_token, | 39 const std::string& oauth_token, |
| 31 const std::string& dm_token, | 40 const std::string& dm_token, |
| 32 const std::string& user_affiliation, | 41 const std::string& user_affiliation, |
| 33 const std::string& client_id, | 42 const std::string& client_id, |
| 34 const enterprise_management::DeviceManagementRequest& request)); | 43 const enterprise_management::DeviceManagementRequest& request)); |
| 35 | 44 |
| 36 // Creates a gmock action that will make the job succeed. | 45 // Creates a gmock action that will make the job succeed. |
| 37 testing::Action<CreateJobFunction> SucceedJob( | 46 testing::Action<CreateJobFunction> SucceedJob( |
| 38 const enterprise_management::DeviceManagementResponse& response); | 47 const enterprise_management::DeviceManagementResponse& response); |
| 48 |
| 39 // Creates a gmock action which will fail the job with the given error. | 49 // Creates a gmock action which will fail the job with the given error. |
| 40 testing::Action<CreateJobFunction> FailJob(DeviceManagementStatus status); | 50 testing::Action<CreateJobFunction> FailJob(DeviceManagementStatus status); |
| 41 | 51 |
| 52 // Creates a gmock action which will capture the job so the test code can |
| 53 // delay job completion. |
| 54 testing::Action<CreateJobFunction> CreateAsyncJob( |
| 55 MockDeviceManagementJob** job); |
| 56 |
| 42 private: | 57 private: |
| 43 DISALLOW_COPY_AND_ASSIGN(MockDeviceManagementService); | 58 DISALLOW_COPY_AND_ASSIGN(MockDeviceManagementService); |
| 44 }; | 59 }; |
| 45 | 60 |
| 46 } // namespace policy | 61 } // namespace policy |
| 47 | 62 |
| 48 #endif // CHROME_BROWSER_POLICY_MOCK_DEVICE_MANAGEMENT_SERVICE_H_ | 63 #endif // CHROME_BROWSER_POLICY_MOCK_DEVICE_MANAGEMENT_SERVICE_H_ |
| OLD | NEW |