| 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" |
| 11 #include "net/base/upload_data.h" | 11 #include "net/base/upload_bytes_element_reader.h" |
| 12 #include "net/base/upload_data_stream.h" |
| 12 #include "net/test/test_server.h" | 13 #include "net/test/test_server.h" |
| 13 #include "net/url_request/url_fetcher.h" | 14 #include "net/url_request/url_fetcher.h" |
| 14 #include "net/url_request/url_request.h" | 15 #include "net/url_request/url_request.h" |
| 15 #include "net/url_request/url_request_test_job.h" | 16 #include "net/url_request/url_request_test_job.h" |
| 16 #include "testing/gmock/include/gmock/gmock.h" | 17 #include "testing/gmock/include/gmock/gmock.h" |
| 17 #include "testing/gtest/include/gtest/gtest.h" | 18 #include "testing/gtest/include/gtest/gtest.h" |
| 18 | 19 |
| 19 using testing::DoAll; | 20 using testing::DoAll; |
| 20 using testing::Invoke; | 21 using testing::Invoke; |
| 21 using testing::InvokeWithoutArgs; | 22 using testing::InvokeWithoutArgs; |
| (...skipping 16 matching lines...) Expand all Loading... |
| 38 | 39 |
| 39 virtual ~CannedResponseInterceptor() { | 40 virtual ~CannedResponseInterceptor() { |
| 40 net::URLRequest::Deprecated::UnregisterRequestInterceptor(this); | 41 net::URLRequest::Deprecated::UnregisterRequestInterceptor(this); |
| 41 } | 42 } |
| 42 | 43 |
| 43 // net::URLRequest::Interceptor overrides. | 44 // net::URLRequest::Interceptor overrides. |
| 44 virtual net::URLRequestJob* MaybeIntercept( | 45 virtual net::URLRequestJob* MaybeIntercept( |
| 45 net::URLRequest* request, | 46 net::URLRequest* request, |
| 46 net::NetworkDelegate* network_delegate) OVERRIDE { | 47 net::NetworkDelegate* network_delegate) OVERRIDE { |
| 47 em::DeviceManagementRequest dm_request; | 48 em::DeviceManagementRequest dm_request; |
| 48 net::UploadData* upload = request->get_upload_mutable(); | 49 const net::UploadDataStream* upload = request->get_upload(); |
| 49 if (request->url().GetOrigin() == service_url_.GetOrigin() && | 50 if (request->url().GetOrigin() == service_url_.GetOrigin() && |
| 50 request->url().path() == service_url_.path() && | 51 request->url().path() == service_url_.path() && |
| 51 upload != NULL && | 52 upload != NULL && |
| 52 upload->elements().size() == 1) { | 53 upload->element_readers().size() == 1 && |
| 54 upload->element_readers()[0]->AsBytesReader()) { |
| 53 std::string response_data; | 55 std::string response_data; |
| 54 ConstructResponse(upload->elements()[0]->bytes(), | 56 const net::UploadBytesElementReader* bytes_reader = |
| 55 upload->elements()[0]->bytes_length(), | 57 upload->element_readers()[0]->AsBytesReader(); |
| 58 ConstructResponse(bytes_reader->bytes(), |
| 59 bytes_reader->length(), |
| 56 &response_data); | 60 &response_data); |
| 57 return new net::URLRequestTestJob(request, | 61 return new net::URLRequestTestJob(request, |
| 58 network_delegate, | 62 network_delegate, |
| 59 net::URLRequestTestJob::test_headers(), | 63 net::URLRequestTestJob::test_headers(), |
| 60 response_data, | 64 response_data, |
| 61 true); | 65 true); |
| 62 } | 66 } |
| 63 | 67 |
| 64 return NULL; | 68 return NULL; |
| 65 } | 69 } |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 210 MessageLoop::current()->Run(); | 214 MessageLoop::current()->Run(); |
| 211 } | 215 } |
| 212 | 216 |
| 213 INSTANTIATE_TEST_CASE_P( | 217 INSTANTIATE_TEST_CASE_P( |
| 214 DeviceManagementServiceIntegrationTestInstance, | 218 DeviceManagementServiceIntegrationTestInstance, |
| 215 DeviceManagementServiceIntegrationTest, | 219 DeviceManagementServiceIntegrationTest, |
| 216 testing::Values(&DeviceManagementServiceIntegrationTest::InitCannedResponse, | 220 testing::Values(&DeviceManagementServiceIntegrationTest::InitCannedResponse, |
| 217 &DeviceManagementServiceIntegrationTest::InitTestServer)); | 221 &DeviceManagementServiceIntegrationTest::InitTestServer)); |
| 218 | 222 |
| 219 } // namespace policy | 223 } // namespace policy |
| OLD | NEW |