| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/macros.h" | 5 #include "base/macros.h" |
| 6 #include "base/memory/scoped_ptr.h" | 6 #include "base/memory/scoped_ptr.h" |
| 7 #include "base/run_loop.h" | 7 #include "base/run_loop.h" |
| 8 #include "content/browser/webui/url_data_manager_backend.h" | 8 #include "content/browser/webui/url_data_manager_backend.h" |
| 9 #include "content/public/test/mock_resource_context.h" | 9 #include "content/public/test/mock_resource_context.h" |
| 10 #include "content/public/test/test_browser_thread_bundle.h" | 10 #include "content/public/test/test_browser_thread_bundle.h" |
| (...skipping 27 matching lines...) Expand all Loading... |
| 38 private: | 38 private: |
| 39 DISALLOW_COPY_AND_ASSIGN(CancelAfterFirstReadURLRequestDelegate); | 39 DISALLOW_COPY_AND_ASSIGN(CancelAfterFirstReadURLRequestDelegate); |
| 40 }; | 40 }; |
| 41 | 41 |
| 42 class UrlDataManagerBackendTest : public testing::Test { | 42 class UrlDataManagerBackendTest : public testing::Test { |
| 43 public: | 43 public: |
| 44 UrlDataManagerBackendTest() { | 44 UrlDataManagerBackendTest() { |
| 45 // URLRequestJobFactory takes ownership of the passed in ProtocolHandler. | 45 // URLRequestJobFactory takes ownership of the passed in ProtocolHandler. |
| 46 url_request_job_factory_.SetProtocolHandler( | 46 url_request_job_factory_.SetProtocolHandler( |
| 47 "chrome", URLDataManagerBackend::CreateProtocolHandler( | 47 "chrome", URLDataManagerBackend::CreateProtocolHandler( |
| 48 &resource_context_, false, nullptr, nullptr)); | 48 &resource_context_, false, nullptr)); |
| 49 url_request_context_.set_job_factory(&url_request_job_factory_); | 49 url_request_context_.set_job_factory(&url_request_job_factory_); |
| 50 } | 50 } |
| 51 | 51 |
| 52 scoped_ptr<net::URLRequest> CreateRequest(net::URLRequest::Delegate* delegate, | 52 scoped_ptr<net::URLRequest> CreateRequest(net::URLRequest::Delegate* delegate, |
| 53 const char* origin) { | 53 const char* origin) { |
| 54 scoped_ptr<net::URLRequest> request = url_request_context_.CreateRequest( | 54 scoped_ptr<net::URLRequest> request = url_request_context_.CreateRequest( |
| 55 GURL("chrome://resources/polymer/v1_0/polymer/polymer-extracted.js"), | 55 GURL("chrome://resources/polymer/v1_0/polymer/polymer-extracted.js"), |
| 56 net::HIGHEST, delegate); | 56 net::HIGHEST, delegate); |
| 57 request->SetExtraRequestHeaderByName("Origin", origin, true); | 57 request->SetExtraRequestHeaderByName("Origin", origin, true); |
| 58 return request; | 58 return request; |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 124 scoped_ptr<net::URLRequest> error_request = | 124 scoped_ptr<net::URLRequest> error_request = |
| 125 url_request_context_.CreateRequest( | 125 url_request_context_.CreateRequest( |
| 126 GURL("chrome://network-error/-123456789"), net::HIGHEST, &delegate_); | 126 GURL("chrome://network-error/-123456789"), net::HIGHEST, &delegate_); |
| 127 error_request->Start(); | 127 error_request->Start(); |
| 128 base::RunLoop().Run(); | 128 base::RunLoop().Run(); |
| 129 EXPECT_EQ(net::URLRequestStatus::FAILED, error_request->status().status()); | 129 EXPECT_EQ(net::URLRequestStatus::FAILED, error_request->status().status()); |
| 130 EXPECT_EQ(net::ERR_INVALID_URL, error_request->status().error()); | 130 EXPECT_EQ(net::ERR_INVALID_URL, error_request->status().error()); |
| 131 } | 131 } |
| 132 | 132 |
| 133 } // namespace content | 133 } // namespace content |
| OLD | NEW |