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 #include "base/memory/scoped_ptr.h" | 5 #include "base/memory/scoped_ptr.h" |
6 #include "base/message_loop.h" | 6 #include "base/message_loop.h" |
7 #include "base/stl_util.h" | 7 #include "base/stl_util.h" |
8 #include "chrome/browser/policy/cloud_policy_constants.h" | 8 #include "chrome/browser/policy/cloud_policy_constants.h" |
9 #include "chrome/browser/policy/device_management_service.h" | 9 #include "chrome/browser/policy/device_management_service.h" |
10 #include "chrome/test/base/in_process_browser_test.h" | 10 #include "chrome/test/base/in_process_browser_test.h" |
(...skipping 24 matching lines...) Expand all Loading... |
35 : service_url_(service_url) { | 35 : service_url_(service_url) { |
36 net::URLRequest::Deprecated::RegisterRequestInterceptor(this); | 36 net::URLRequest::Deprecated::RegisterRequestInterceptor(this); |
37 } | 37 } |
38 | 38 |
39 virtual ~CannedResponseInterceptor() { | 39 virtual ~CannedResponseInterceptor() { |
40 net::URLRequest::Deprecated::UnregisterRequestInterceptor(this); | 40 net::URLRequest::Deprecated::UnregisterRequestInterceptor(this); |
41 } | 41 } |
42 | 42 |
43 // net::URLRequest::Interceptor overrides. | 43 // net::URLRequest::Interceptor overrides. |
44 virtual net::URLRequestJob* MaybeIntercept( | 44 virtual net::URLRequestJob* MaybeIntercept( |
45 net::URLRequest* request) OVERRIDE { | 45 net::URLRequest* request, |
| 46 net::NetworkDelegate* network_delegate) OVERRIDE { |
46 em::DeviceManagementRequest dm_request; | 47 em::DeviceManagementRequest dm_request; |
47 net::UploadData* upload = request->get_upload_mutable(); | 48 net::UploadData* upload = request->get_upload_mutable(); |
48 if (request->url().GetOrigin() == service_url_.GetOrigin() && | 49 if (request->url().GetOrigin() == service_url_.GetOrigin() && |
49 request->url().path() == service_url_.path() && | 50 request->url().path() == service_url_.path() && |
50 upload != NULL && | 51 upload != NULL && |
51 upload->elements()->size() == 1) { | 52 upload->elements()->size() == 1) { |
52 std::string response_data; | 53 std::string response_data; |
53 ConstructResponse(upload->elements()->at(0).bytes(), | 54 ConstructResponse(upload->elements()->at(0).bytes(), |
54 upload->elements()->at(0).bytes_length(), | 55 upload->elements()->at(0).bytes_length(), |
55 &response_data); | 56 &response_data); |
56 return new net::URLRequestTestJob(request, | 57 return new net::URLRequestTestJob(request, |
| 58 network_delegate, |
57 net::URLRequestTestJob::test_headers(), | 59 net::URLRequestTestJob::test_headers(), |
58 response_data, | 60 response_data, |
59 true); | 61 true); |
60 } | 62 } |
61 | 63 |
62 return NULL; | 64 return NULL; |
63 } | 65 } |
64 | 66 |
65 private: | 67 private: |
66 void ConstructResponse(const char* request_data, | 68 void ConstructResponse(const char* request_data, |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
208 MessageLoop::current()->Run(); | 210 MessageLoop::current()->Run(); |
209 } | 211 } |
210 | 212 |
211 INSTANTIATE_TEST_CASE_P( | 213 INSTANTIATE_TEST_CASE_P( |
212 DeviceManagementServiceIntegrationTestInstance, | 214 DeviceManagementServiceIntegrationTestInstance, |
213 DeviceManagementServiceIntegrationTest, | 215 DeviceManagementServiceIntegrationTest, |
214 testing::Values(&DeviceManagementServiceIntegrationTest::InitCannedResponse, | 216 testing::Values(&DeviceManagementServiceIntegrationTest::InitCannedResponse, |
215 &DeviceManagementServiceIntegrationTest::InitTestServer)); | 217 &DeviceManagementServiceIntegrationTest::InitTestServer)); |
216 | 218 |
217 } // namespace policy | 219 } // namespace policy |
OLD | NEW |