Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(173)

Side by Side Diff: content/browser/loader/url_loader_factory_impl_unittest.cc

Issue 2364943002: Create NavigationHandles for interstitials if needed (Closed)
Patch Set: Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "content/browser/loader/url_loader_factory_impl.h" 5 #include "content/browser/loader/url_loader_factory_impl.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include <string> 8 #include <string>
9 #include <utility> 9 #include <utility>
10 10
11 #include "base/bind.h" 11 #include "base/bind.h"
12 #include "base/callback.h" 12 #include "base/callback.h"
13 #include "base/files/file_path.h" 13 #include "base/files/file_path.h"
14 #include "base/files/file_util.h" 14 #include "base/files/file_util.h"
15 #include "base/location.h" 15 #include "base/location.h"
16 #include "base/memory/ptr_util.h" 16 #include "base/memory/ptr_util.h"
17 #include "base/memory/weak_ptr.h" 17 #include "base/memory/weak_ptr.h"
18 #include "base/message_loop/message_loop.h" 18 #include "base/message_loop/message_loop.h"
19 #include "base/path_service.h" 19 #include "base/path_service.h"
20 #include "base/run_loop.h" 20 #include "base/run_loop.h"
21 #include "content/browser/loader/mojo_async_resource_handler.h" 21 #include "content/browser/loader/mojo_async_resource_handler.h"
22 #include "content/browser/loader/navigation_resource_throttle.h"
22 #include "content/browser/loader/resource_dispatcher_host_impl.h" 23 #include "content/browser/loader/resource_dispatcher_host_impl.h"
23 #include "content/browser/loader/resource_message_filter.h" 24 #include "content/browser/loader/resource_message_filter.h"
24 #include "content/browser/loader/test_url_loader_client.h" 25 #include "content/browser/loader/test_url_loader_client.h"
25 #include "content/browser/loader_delegate_impl.h" 26 #include "content/browser/loader_delegate_impl.h"
26 #include "content/common/resource_request.h" 27 #include "content/common/resource_request.h"
27 #include "content/common/resource_request_completion_status.h" 28 #include "content/common/resource_request_completion_status.h"
28 #include "content/common/url_loader.mojom.h" 29 #include "content/common/url_loader.mojom.h"
29 #include "content/public/browser/resource_context.h" 30 #include "content/public/browser/resource_context.h"
30 #include "content/public/browser/resource_dispatcher_host_delegate.h" 31 #include "content/public/browser/resource_dispatcher_host_delegate.h"
31 #include "content/public/common/content_paths.h" 32 #include "content/public/common/content_paths.h"
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 LoaderDelegateImpl loader_deleate_; 123 LoaderDelegateImpl loader_deleate_;
123 ResourceDispatcherHostImpl rdh_; 124 ResourceDispatcherHostImpl rdh_;
124 std::unique_ptr<TestBrowserContext> browser_context_; 125 std::unique_ptr<TestBrowserContext> browser_context_;
125 scoped_refptr<ResourceMessageFilter> resource_message_filter_; 126 scoped_refptr<ResourceMessageFilter> resource_message_filter_;
126 mojom::URLLoaderFactoryPtr factory_; 127 mojom::URLLoaderFactoryPtr factory_;
127 128
128 DISALLOW_COPY_AND_ASSIGN(URLLoaderFactoryImplTest); 129 DISALLOW_COPY_AND_ASSIGN(URLLoaderFactoryImplTest);
129 }; 130 };
130 131
131 TEST_P(URLLoaderFactoryImplTest, GetResponse) { 132 TEST_P(URLLoaderFactoryImplTest, GetResponse) {
133 NavigationResourceThrottle::SetUIChecksAlwaysSucceedForTesting(true);
132 mojom::URLLoaderPtr loader; 134 mojom::URLLoaderPtr loader;
133 base::FilePath root; 135 base::FilePath root;
134 PathService::Get(DIR_TEST_DATA, &root); 136 PathService::Get(DIR_TEST_DATA, &root);
135 net::URLRequestMockHTTPJob::AddUrlHandlers(root, 137 net::URLRequestMockHTTPJob::AddUrlHandlers(root,
136 BrowserThread::GetBlockingPool()); 138 BrowserThread::GetBlockingPool());
137 ResourceRequest request; 139 ResourceRequest request;
138 TestURLLoaderClient client; 140 TestURLLoaderClient client;
139 // Assume the file contents is small enough to be stored in the data pipe. 141 // Assume the file contents is small enough to be stored in the data pipe.
140 request.url = net::URLRequestMockHTTPJob::GetMockUrl("hello.html"); 142 request.url = net::URLRequestMockHTTPJob::GetMockUrl("hello.html");
141 request.method = "GET"; 143 request.method = "GET";
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 ASSERT_EQ(MOJO_RESULT_OK, r); 179 ASSERT_EQ(MOJO_RESULT_OK, r);
178 contents += std::string(buffer, read_size); 180 contents += std::string(buffer, read_size);
179 } 181 }
180 std::string expected; 182 std::string expected;
181 base::ReadFileToString( 183 base::ReadFileToString(
182 root.Append(base::FilePath(FILE_PATH_LITERAL("hello.html"))), &expected); 184 root.Append(base::FilePath(FILE_PATH_LITERAL("hello.html"))), &expected);
183 EXPECT_EQ(expected, contents); 185 EXPECT_EQ(expected, contents);
184 } 186 }
185 187
186 TEST_P(URLLoaderFactoryImplTest, GetFailedResponse) { 188 TEST_P(URLLoaderFactoryImplTest, GetFailedResponse) {
189 NavigationResourceThrottle::SetUIChecksAlwaysSucceedForTesting(true);
187 mojom::URLLoaderPtr loader; 190 mojom::URLLoaderPtr loader;
188 ResourceRequest request; 191 ResourceRequest request;
189 TestURLLoaderClient client; 192 TestURLLoaderClient client;
190 net::URLRequestFailedJob::AddUrlHandler(); 193 net::URLRequestFailedJob::AddUrlHandler();
191 request.url = net::URLRequestFailedJob::GetMockHttpUrlWithFailurePhase( 194 request.url = net::URLRequestFailedJob::GetMockHttpUrlWithFailurePhase(
192 net::URLRequestFailedJob::START, net::ERR_TIMED_OUT); 195 net::URLRequestFailedJob::START, net::ERR_TIMED_OUT);
193 request.method = "GET"; 196 request.method = "GET";
194 factory_->CreateLoaderAndStart(mojo::GetProxy(&loader), 1, request, 197 factory_->CreateLoaderAndStart(mojo::GetProxy(&loader), 1, request,
195 client.CreateInterfacePtrAndBind()); 198 client.CreateInterfacePtrAndBind());
196 199
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 EXPECT_EQ(net::ERR_ABORTED, client.completion_status().error_code); 243 EXPECT_EQ(net::ERR_ABORTED, client.completion_status().error_code);
241 } 244 }
242 245
243 INSTANTIATE_TEST_CASE_P(URLLoaderFactoryImplTest, 246 INSTANTIATE_TEST_CASE_P(URLLoaderFactoryImplTest,
244 URLLoaderFactoryImplTest, 247 URLLoaderFactoryImplTest,
245 ::testing::Values(128, 32 * 1024)); 248 ::testing::Values(128, 32 * 1024));
246 249
247 } // namespace 250 } // namespace
248 251
249 } // namespace content 252 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698