1 // Copyright (c) 2011 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 #pragma once 8 9 #include <string> 10 11 #include "chrome/browser/policy/device_management_backend.h" 12 #include "chrome/browser/policy/device_management_service.h" 13 #include "chrome/browser/policy/proto/device_management_backend.pb.h" 14 15 namespace policy { 16 17 // This proxy class is used so that expectations can be defined for a single 18 // persistent instance of DMBackend while the DeviceTokenFetcher under test 19 // merrily creates and destroys proxies. 20 class ProxyDeviceManagementBackend : public DeviceManagementBackend { 21 public: 22 explicit ProxyDeviceManagementBackend(DeviceManagementBackend* backend); 23 virtual ~ProxyDeviceManagementBackend(); 24 25 virtual void ProcessRegisterRequest( 26 const std::string& auth_token, 27 const std::string& device_id, 28 const em::DeviceRegisterRequest& request, 29 DeviceRegisterResponseDelegate* delegate); 30 31 virtual void ProcessUnregisterRequest( 32 const std::string& device_management_token, 33 const std::string& device_id, 34 const em::DeviceUnregisterRequest& request, 35 DeviceUnregisterResponseDelegate* delegate); 36 37 virtual void ProcessPolicyRequest( 38 const std::string& device_management_token, 39 const std::string& device_id, 40 const em::DevicePolicyRequest& request, 41 DevicePolicyResponseDelegate* delegate); 42 43 private: 44 DeviceManagementBackend* backend_; // weak 45 DISALLOW_COPY_AND_ASSIGN(ProxyDeviceManagementBackend); 46 }; 47 48 class MockDeviceManagementService : public DeviceManagementService { 49 public: 50 MockDeviceManagementService(); 51 virtual ~MockDeviceManagementService(); 52 53 void set_backend(DeviceManagementBackend* backend) { 54 backend_ = backend; 55 } 56 57 virtual DeviceManagementBackend* CreateBackend(); 58 59 private: 60 DeviceManagementBackend* backend_; // weak 61 DISALLOW_COPY_AND_ASSIGN(MockDeviceManagementService); 62 }; 63 64 } // namespace policy 65 66 #endif // CHROME_BROWSER_POLICY_MOCK_DEVICE_MANAGEMENT_SERVICE_H_ 67