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

Side by Side Diff: components/navigation_interception/intercept_navigation_resource_throttle_unittest.cc

Issue 17127002: Correctly integrate StoragePartition into TestingProfile. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: cleanup TODOs. merge code. kill more threads. i never get tired of thread carnage. Created 7 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 | Annotate | Revision Log
OLDNEW
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/bind.h" 5 #include "base/bind.h"
6 #include "base/bind_helpers.h" 6 #include "base/bind_helpers.h"
7 #include "base/memory/scoped_ptr.h" 7 #include "base/memory/scoped_ptr.h"
8 #include "base/memory/scoped_vector.h" 8 #include "base/memory/scoped_vector.h"
9 #include "base/run_loop.h" 9 #include "base/run_loop.h"
10 #include "base/synchronization/waitable_event.h" 10 #include "base/synchronization/waitable_event.h"
11 #include "components/navigation_interception/intercept_navigation_resource_throt tle.h" 11 #include "components/navigation_interception/intercept_navigation_resource_throt tle.h"
12 #include "components/navigation_interception/navigation_params.h" 12 #include "components/navigation_interception/navigation_params.h"
13 #include "content/public/browser/browser_thread.h" 13 #include "content/public/browser/browser_thread.h"
14 #include "content/public/browser/render_process_host.h" 14 #include "content/public/browser/render_process_host.h"
15 #include "content/public/browser/resource_context.h" 15 #include "content/public/browser/resource_context.h"
16 #include "content/public/browser/resource_controller.h" 16 #include "content/public/browser/resource_controller.h"
17 #include "content/public/browser/resource_dispatcher_host.h" 17 #include "content/public/browser/resource_dispatcher_host.h"
18 #include "content/public/browser/resource_dispatcher_host_delegate.h" 18 #include "content/public/browser/resource_dispatcher_host_delegate.h"
19 #include "content/public/browser/resource_request_info.h" 19 #include "content/public/browser/resource_request_info.h"
20 #include "content/public/browser/resource_throttle.h" 20 #include "content/public/browser/resource_throttle.h"
21 #include "content/public/browser/web_contents.h" 21 #include "content/public/browser/web_contents.h"
22 #include "content/public/browser/web_contents_delegate.h" 22 #include "content/public/browser/web_contents_delegate.h"
23 #include "content/public/common/page_transition_types.h" 23 #include "content/public/common/page_transition_types.h"
24 #include "content/public/test/mock_resource_context.h" 24 #include "content/public/test/mock_resource_context.h"
25 #include "content/public/test/test_renderer_host.h" 25 #include "content/public/test/test_renderer_host.h"
26 #include "net/url_request/url_request.h" 26 #include "net/url_request/url_request.h"
27 #include "net/url_request/url_request_test_util.h"
27 #include "testing/gmock/include/gmock/gmock.h" 28 #include "testing/gmock/include/gmock/gmock.h"
28 #include "testing/gtest/include/gtest/gtest.h" 29 #include "testing/gtest/include/gtest/gtest.h"
29 30
30 using testing::_; 31 using testing::_;
31 using testing::Eq; 32 using testing::Eq;
33 using testing::Ne;
32 using testing::Property; 34 using testing::Property;
33 using testing::Ne;
34 using testing::Return; 35 using testing::Return;
35 36
36 namespace navigation_interception { 37 namespace navigation_interception {
37 38
38 namespace { 39 namespace {
39 40
40 const char kTestUrl[] = "http://www.test.com/"; 41 const char kTestUrl[] = "http://www.test.com/";
41 const char kUnsafeTestUrl[] = "about:crash"; 42 const char kUnsafeTestUrl[] = "about:crash";
42 43
43 // The MS C++ compiler complains about not being able to resolve which url() 44 // The MS C++ compiler complains about not being able to resolve which url()
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 103
103 // TestIOThreadState ---------------------------------------------------------- 104 // TestIOThreadState ----------------------------------------------------------
104 105
105 class TestIOThreadState { 106 class TestIOThreadState {
106 public: 107 public:
107 TestIOThreadState(const GURL& url, 108 TestIOThreadState(const GURL& url,
108 int render_process_id, 109 int render_process_id,
109 int render_view_id, 110 int render_view_id,
110 const std::string& request_method, 111 const std::string& request_method,
111 MockInterceptCallbackReceiver* callback_receiver) 112 MockInterceptCallbackReceiver* callback_receiver)
112 : request_(url, NULL, resource_context_.GetRequestContext()) { 113 : resource_context_(&test_url_request_context_),
114 request_(url, NULL, resource_context_.GetRequestContext()) {
113 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)); 115 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO));
114 if (render_process_id != MSG_ROUTING_NONE && 116 if (render_process_id != MSG_ROUTING_NONE &&
115 render_view_id != MSG_ROUTING_NONE) { 117 render_view_id != MSG_ROUTING_NONE) {
116 content::ResourceRequestInfo::AllocateForTesting( 118 content::ResourceRequestInfo::AllocateForTesting(
117 &request_, 119 &request_,
118 ResourceType::MAIN_FRAME, 120 ResourceType::MAIN_FRAME,
119 &resource_context_, 121 &resource_context_,
120 render_process_id, 122 render_process_id,
121 render_view_id); 123 render_view_id);
122 } 124 }
(...skipping 14 matching lines...) Expand all
137 return throttle_controller_.status() == 139 return throttle_controller_.status() ==
138 MockResourceController::RESUMED; 140 MockResourceController::RESUMED;
139 } 141 }
140 142
141 bool request_cancelled() const { 143 bool request_cancelled() const {
142 return throttle_controller_.status() == 144 return throttle_controller_.status() ==
143 MockResourceController::CANCELLED; 145 MockResourceController::CANCELLED;
144 } 146 }
145 147
146 private: 148 private:
149 net::TestURLRequestContext test_url_request_context_;
147 content::MockResourceContext resource_context_; 150 content::MockResourceContext resource_context_;
148 net::URLRequest request_; 151 net::URLRequest request_;
149 scoped_ptr<InterceptNavigationResourceThrottle> throttle_; 152 scoped_ptr<InterceptNavigationResourceThrottle> throttle_;
150 MockResourceController throttle_controller_; 153 MockResourceController throttle_controller_;
151 }; 154 };
152 155
153 // InterceptNavigationResourceThrottleTest ------------------------------------ 156 // InterceptNavigationResourceThrottleTest ------------------------------------
154 157
155 class InterceptNavigationResourceThrottleTest 158 class InterceptNavigationResourceThrottleTest
156 : public content::RenderViewHostTestHarness { 159 : public content::RenderViewHostTestHarness {
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after
403 "POST", 406 "POST",
404 web_contents()->GetRenderViewHost()->GetProcess()->GetID(), 407 web_contents()->GetRenderViewHost()->GetProcess()->GetID(),
405 web_contents()->GetRenderViewHost()->GetRoutingID(), 408 web_contents()->GetRenderViewHost()->GetRoutingID(),
406 base::Unretained(&defer))); 409 base::Unretained(&defer)));
407 410
408 // Wait for the request to finish processing. 411 // Wait for the request to finish processing.
409 base::RunLoop().RunUntilIdle(); 412 base::RunLoop().RunUntilIdle();
410 } 413 }
411 414
412 } // namespace navigation_interception 415 } // namespace navigation_interception
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698