| 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 #include "base/message_loop.h" | 5 #include "base/message_loop.h" |
| 6 #include "chrome/browser/browser_thread.h" | 6 #include "chrome/browser/browser_thread.h" |
| 7 #include "chrome/browser/policy/device_management_backend_mock.h" | 7 #include "chrome/browser/policy/device_management_backend_mock.h" |
| 8 #include "chrome/browser/policy/device_management_service.h" | 8 #include "chrome/browser/policy/device_management_service.h" |
| 9 #include "chrome/browser/policy/proto/device_management_constants.h" |
| 9 #include "chrome/browser/profile.h" | 10 #include "chrome/browser/profile.h" |
| 10 #include "chrome/browser/ui/browser.h" | 11 #include "chrome/browser/ui/browser.h" |
| 11 #include "chrome/test/in_process_browser_test.h" | 12 #include "chrome/test/in_process_browser_test.h" |
| 12 #include "net/test/test_server.h" | 13 #include "net/test/test_server.h" |
| 13 #include "net/url_request/url_request.h" | 14 #include "net/url_request/url_request.h" |
| 14 #include "net/url_request/url_request_test_job.h" | 15 #include "net/url_request/url_request_test_job.h" |
| 15 #include "testing/gtest/include/gtest/gtest.h" | 16 #include "testing/gtest/include/gtest/gtest.h" |
| 16 #include "testing/gmock/include/gmock/gmock.h" | 17 #include "testing/gmock/include/gmock/gmock.h" |
| 17 | 18 |
| 18 using testing::_; | 19 using testing::_; |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 MessageLoop::current()->Run(); | 108 MessageLoop::current()->Run(); |
| 108 } | 109 } |
| 109 | 110 |
| 110 { | 111 { |
| 111 CannedResponseInterceptor interceptor( | 112 CannedResponseInterceptor interceptor( |
| 112 GURL(kServiceUrl), PROTO_STRING(kServiceResponsePolicy)); | 113 GURL(kServiceUrl), PROTO_STRING(kServiceResponsePolicy)); |
| 113 DevicePolicyResponseDelegateMock delegate; | 114 DevicePolicyResponseDelegateMock delegate; |
| 114 EXPECT_CALL(delegate, HandlePolicyResponse(_)) | 115 EXPECT_CALL(delegate, HandlePolicyResponse(_)) |
| 115 .WillOnce(InvokeWithoutArgs(QuitMessageLoop)); | 116 .WillOnce(InvokeWithoutArgs(QuitMessageLoop)); |
| 116 em::DevicePolicyRequest request; | 117 em::DevicePolicyRequest request; |
| 117 request.set_policy_scope("chrome"); | 118 request.set_policy_scope(kChromePolicyScope); |
| 118 em::DevicePolicySettingRequest* setting_request = | 119 em::DevicePolicySettingRequest* setting_request = |
| 119 request.add_setting_request(); | 120 request.add_setting_request(); |
| 120 setting_request->set_key("policy"); | 121 setting_request->set_key(kChromeDevicePolicySettingKey); |
| 121 backend->ProcessPolicyRequest(token_, "testid", request, &delegate); | 122 backend->ProcessPolicyRequest(token_, "testid", request, &delegate); |
| 122 | 123 |
| 123 MessageLoop::current()->Run(); | 124 MessageLoop::current()->Run(); |
| 124 } | 125 } |
| 125 | 126 |
| 126 { | 127 { |
| 127 CannedResponseInterceptor interceptor( | 128 CannedResponseInterceptor interceptor( |
| 128 GURL(kServiceUrl), PROTO_STRING(kServiceResponseUnregister)); | 129 GURL(kServiceUrl), PROTO_STRING(kServiceResponseUnregister)); |
| 129 DeviceUnregisterResponseDelegateMock delegate; | 130 DeviceUnregisterResponseDelegateMock delegate; |
| 130 EXPECT_CALL(delegate, HandleUnregisterResponse(_)) | 131 EXPECT_CALL(delegate, HandleUnregisterResponse(_)) |
| (...skipping 27 matching lines...) Expand all Loading... |
| 158 MessageLoop::current()->Run(); | 159 MessageLoop::current()->Run(); |
| 159 } | 160 } |
| 160 | 161 |
| 161 { | 162 { |
| 162 em::DevicePolicyResponse expected_response; | 163 em::DevicePolicyResponse expected_response; |
| 163 | 164 |
| 164 DevicePolicyResponseDelegateMock delegate; | 165 DevicePolicyResponseDelegateMock delegate; |
| 165 EXPECT_CALL(delegate, HandlePolicyResponse(_)) | 166 EXPECT_CALL(delegate, HandlePolicyResponse(_)) |
| 166 .WillOnce(InvokeWithoutArgs(QuitMessageLoop)); | 167 .WillOnce(InvokeWithoutArgs(QuitMessageLoop)); |
| 167 em::DevicePolicyRequest request; | 168 em::DevicePolicyRequest request; |
| 168 request.set_policy_scope("chrome"); | 169 request.set_policy_scope(kChromePolicyScope); |
| 169 em::DevicePolicySettingRequest* setting_request = | 170 em::DevicePolicySettingRequest* setting_request = |
| 170 request.add_setting_request(); | 171 request.add_setting_request(); |
| 171 setting_request->set_key("policy"); | 172 setting_request->set_key(kChromeDevicePolicySettingKey); |
| 172 backend->ProcessPolicyRequest(token_, "testid", request, &delegate); | 173 backend->ProcessPolicyRequest(token_, "testid", request, &delegate); |
| 173 | 174 |
| 174 MessageLoop::current()->Run(); | 175 MessageLoop::current()->Run(); |
| 175 } | 176 } |
| 176 | 177 |
| 177 { | 178 { |
| 178 DeviceUnregisterResponseDelegateMock delegate; | 179 DeviceUnregisterResponseDelegateMock delegate; |
| 179 EXPECT_CALL(delegate, HandleUnregisterResponse(_)) | 180 EXPECT_CALL(delegate, HandleUnregisterResponse(_)) |
| 180 .WillOnce(InvokeWithoutArgs(QuitMessageLoop)); | 181 .WillOnce(InvokeWithoutArgs(QuitMessageLoop)); |
| 181 em::DeviceUnregisterRequest request; | 182 em::DeviceUnregisterRequest request; |
| 182 backend->ProcessUnregisterRequest(token_, "testid", request, &delegate); | 183 backend->ProcessUnregisterRequest(token_, "testid", request, &delegate); |
| 183 | 184 |
| 184 MessageLoop::current()->Run(); | 185 MessageLoop::current()->Run(); |
| 185 } | 186 } |
| 186 } | 187 } |
| 187 | 188 |
| 188 } // namespace policy | 189 } // namespace policy |
| OLD | NEW |