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