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

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

Issue 2108643004: Remove use of WebContentsImpl from ResourceDispatcherHostImpl (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@render-view-try-3
Patch Set: fixes Created 4 years, 5 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 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 <memory> 5 #include <memory>
6 #include <utility> 6 #include <utility>
7 7
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "base/memory/ptr_util.h" 10 #include "base/memory/ptr_util.h"
11 #include "base/memory/ref_counted.h" 11 #include "base/memory/ref_counted.h"
12 #include "base/run_loop.h" 12 #include "base/run_loop.h"
13 #include "content/browser/frame_host/navigation_request_info.h" 13 #include "content/browser/frame_host/navigation_request_info.h"
14 #include "content/browser/loader/navigation_url_loader_impl.h" 14 #include "content/browser/loader/navigation_url_loader_impl.h"
15 #include "content/browser/loader/resource_dispatcher_host_impl.h" 15 #include "content/browser/loader/resource_dispatcher_host_impl.h"
16 #include "content/browser/loader_delegate_impl.h"
16 #include "content/browser/streams/stream.h" 17 #include "content/browser/streams/stream.h"
17 #include "content/browser/streams/stream_context.h" 18 #include "content/browser/streams/stream_context.h"
18 #include "content/browser/streams/stream_registry.h" 19 #include "content/browser/streams/stream_registry.h"
19 #include "content/browser/streams/stream_url_request_job.h" 20 #include "content/browser/streams/stream_url_request_job.h"
20 #include "content/common/navigation_params.h" 21 #include "content/common/navigation_params.h"
21 #include "content/public/browser/browser_context.h" 22 #include "content/public/browser/browser_context.h"
22 #include "content/public/browser/resource_context.h" 23 #include "content/public/browser/resource_context.h"
23 #include "content/public/browser/resource_dispatcher_host_delegate.h" 24 #include "content/public/browser/resource_dispatcher_host_delegate.h"
24 #include "content/public/browser/stream_handle.h" 25 #include "content/public/browser/stream_handle.h"
25 #include "content/public/common/content_switches.h" 26 #include "content/public/common/content_switches.h"
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 } 77 }
77 }; 78 };
78 79
79 } // namespace 80 } // namespace
80 81
81 class NavigationURLLoaderTest : public testing::Test { 82 class NavigationURLLoaderTest : public testing::Test {
82 public: 83 public:
83 NavigationURLLoaderTest() 84 NavigationURLLoaderTest()
84 : thread_bundle_(TestBrowserThreadBundle::IO_MAINLOOP), 85 : thread_bundle_(TestBrowserThreadBundle::IO_MAINLOOP),
85 browser_context_(new TestBrowserContext) { 86 browser_context_(new TestBrowserContext) {
87 host_.SetLoaderDelegate(&loader_delegate_);
86 BrowserContext::EnsureResourceContextInitialized(browser_context_.get()); 88 BrowserContext::EnsureResourceContextInitialized(browser_context_.get());
87 base::RunLoop().RunUntilIdle(); 89 base::RunLoop().RunUntilIdle();
88 net::URLRequestContext* request_context = 90 net::URLRequestContext* request_context =
89 browser_context_->GetResourceContext()->GetRequestContext(); 91 browser_context_->GetResourceContext()->GetRequestContext();
90 // Attach URLRequestTestJob and make streams work. 92 // Attach URLRequestTestJob and make streams work.
91 job_factory_.SetProtocolHandler( 93 job_factory_.SetProtocolHandler(
92 "test", net::URLRequestTestJob::CreateProtocolHandler()); 94 "test", net::URLRequestTestJob::CreateProtocolHandler());
93 job_factory_.SetProtocolHandler( 95 job_factory_.SetProtocolHandler(
94 "blob", 96 "blob",
95 base::WrapUnique(new StreamProtocolHandler( 97 base::WrapUnique(new StreamProtocolHandler(
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 130
129 EXPECT_TRUE(request->status().is_success()); 131 EXPECT_TRUE(request->status().is_success());
130 EXPECT_EQ(200, request->response_headers()->response_code()); 132 EXPECT_EQ(200, request->response_headers()->response_code());
131 return delegate.data_received(); 133 return delegate.data_received();
132 } 134 }
133 135
134 protected: 136 protected:
135 TestBrowserThreadBundle thread_bundle_; 137 TestBrowserThreadBundle thread_bundle_;
136 net::URLRequestJobFactoryImpl job_factory_; 138 net::URLRequestJobFactoryImpl job_factory_;
137 std::unique_ptr<TestBrowserContext> browser_context_; 139 std::unique_ptr<TestBrowserContext> browser_context_;
140 LoaderDelegateImpl loader_delegate_;
138 ResourceDispatcherHostImpl host_; 141 ResourceDispatcherHostImpl host_;
139 }; 142 };
140 143
141 // Tests that a basic request works. 144 // Tests that a basic request works.
142 TEST_F(NavigationURLLoaderTest, Basic) { 145 TEST_F(NavigationURLLoaderTest, Basic) {
143 TestNavigationURLLoaderDelegate delegate; 146 TestNavigationURLLoaderDelegate delegate;
144 std::unique_ptr<NavigationURLLoader> loader = 147 std::unique_ptr<NavigationURLLoader> loader =
145 MakeTestLoader(net::URLRequestTestJob::test_url_1(), &delegate); 148 MakeTestLoader(net::URLRequestTestJob::test_url_1(), &delegate);
146 149
147 // Wait for the response to come back. 150 // Wait for the response to come back.
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
328 331
329 // Release the body. 332 // Release the body.
330 delegate.ReleaseBody(); 333 delegate.ReleaseBody();
331 base::RunLoop().RunUntilIdle(); 334 base::RunLoop().RunUntilIdle();
332 335
333 // Verify that URLRequestTestJob no longer has anything paused. 336 // Verify that URLRequestTestJob no longer has anything paused.
334 EXPECT_FALSE(net::URLRequestTestJob::ProcessOnePendingMessage()); 337 EXPECT_FALSE(net::URLRequestTestJob::ProcessOnePendingMessage());
335 } 338 }
336 339
337 } // namespace content 340 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698