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

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

Issue 11293017: Move navigation interception component to content/components (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add findbugs suppression for compatibility code. Created 8 years, 1 month 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/synchronization/waitable_event.h" 9 #include "base/synchronization/waitable_event.h"
10 #include "chrome/browser/component/navigation_interception/intercept_navigation_ resource_throttle.h" 10 #include "content/components/navigation_interception/intercept_navigation_resour ce_throttle.h"
11 #include "chrome/test/base/chrome_render_view_host_test_harness.h"
12 #include "content/public/browser/render_process_host.h" 11 #include "content/public/browser/render_process_host.h"
13 #include "content/public/browser/resource_context.h" 12 #include "content/public/browser/resource_context.h"
14 #include "content/public/browser/resource_controller.h" 13 #include "content/public/browser/resource_controller.h"
15 #include "content/public/browser/resource_dispatcher_host.h" 14 #include "content/public/browser/resource_dispatcher_host.h"
16 #include "content/public/browser/resource_dispatcher_host_delegate.h" 15 #include "content/public/browser/resource_dispatcher_host_delegate.h"
17 #include "content/public/browser/resource_request_info.h" 16 #include "content/public/browser/resource_request_info.h"
18 #include "content/public/browser/resource_throttle.h" 17 #include "content/public/browser/resource_throttle.h"
19 #include "content/public/browser/web_contents.h" 18 #include "content/public/browser/web_contents.h"
20 #include "content/public/browser/web_contents_delegate.h" 19 #include "content/public/browser/web_contents_delegate.h"
21 #include "content/public/test/mock_resource_context.h" 20 #include "content/public/test/mock_resource_context.h"
22 #include "content/public/test/test_browser_thread.h" 21 #include "content/public/test/test_browser_thread.h"
22 #include "content/public/test/test_renderer_host.h"
23 #include "net/url_request/url_request.h" 23 #include "net/url_request/url_request.h"
24 #include "testing/gmock/include/gmock/gmock.h" 24 #include "testing/gmock/include/gmock/gmock.h"
25 #include "testing/gtest/include/gtest/gtest.h" 25 #include "testing/gtest/include/gtest/gtest.h"
26 26
27 using namespace content; 27 using namespace content;
28 using namespace navigation_interception;
29 using namespace ::testing; 28 using namespace ::testing;
30 29
31 namespace { 30 namespace {
32 31
33 const char* kTestUrl = "http://www.test.com/"; 32 const char* kTestUrl = "http://www.test.com/";
34 const char* kUnsafeTestUrl = "about:crash"; 33 const char* kUnsafeTestUrl = "about:crash";
35 34
36 void ContinueTestCase() { 35 void ContinueTestCase() {
37 BrowserThread::PostTask( 36 BrowserThread::PostTask(
38 BrowserThread::UI, 37 BrowserThread::UI,
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 private: 130 private:
132 content::MockResourceContext resource_context_; 131 content::MockResourceContext resource_context_;
133 net::URLRequest request_; 132 net::URLRequest request_;
134 scoped_ptr<InterceptNavigationResourceThrottle> throttle_; 133 scoped_ptr<InterceptNavigationResourceThrottle> throttle_;
135 MockResourceController throttle_controller_; 134 MockResourceController throttle_controller_;
136 }; 135 };
137 136
138 // InterceptNavigationResourceThrottleTest ------------------------------------ 137 // InterceptNavigationResourceThrottleTest ------------------------------------
139 138
140 class InterceptNavigationResourceThrottleTest 139 class InterceptNavigationResourceThrottleTest
141 : public ChromeRenderViewHostTestHarness { 140 : public RenderViewHostTestHarness {
142 public: 141 public:
143 InterceptNavigationResourceThrottleTest() 142 InterceptNavigationResourceThrottleTest()
144 : mock_callback_receiver_(new MockInterceptCallbackReceiver()), 143 : mock_callback_receiver_(new MockInterceptCallbackReceiver()),
145 ui_thread_(BrowserThread::UI, &message_loop_), 144 ui_thread_(BrowserThread::UI, &message_loop_),
146 io_thread_(BrowserThread::IO), 145 io_thread_(BrowserThread::IO),
147 io_thread_state_(NULL) { 146 io_thread_state_(NULL) {
148 } 147 }
149 148
150 virtual void SetUp() OVERRIDE { 149 virtual void SetUp() OVERRIDE {
151 ChromeRenderViewHostTestHarness::SetUp(); 150 RenderViewHostTestHarness::SetUp();
152 151
153 io_thread_.StartIOThread(); 152 io_thread_.StartIOThread();
154 } 153 }
155 154
156 virtual void TearDown() OVERRIDE { 155 virtual void TearDown() OVERRIDE {
157 if (web_contents()) 156 if (web_contents())
158 web_contents()->SetDelegate(NULL); 157 web_contents()->SetDelegate(NULL);
159 158
160 BrowserThread::PostTask( 159 BrowserThread::PostTask(
161 BrowserThread::IO, 160 BrowserThread::IO,
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
339 RunThrottleWillStartRequestOnIOThread, 338 RunThrottleWillStartRequestOnIOThread,
340 base::Unretained(this), 339 base::Unretained(this),
341 GURL(kUnsafeTestUrl), 340 GURL(kUnsafeTestUrl),
342 web_contents()->GetRenderViewHost()->GetProcess()->GetID(), 341 web_contents()->GetRenderViewHost()->GetProcess()->GetID(),
343 web_contents()->GetRenderViewHost()->GetRoutingID(), 342 web_contents()->GetRenderViewHost()->GetRoutingID(),
344 base::Unretained(&defer))); 343 base::Unretained(&defer)));
345 344
346 // Wait for the request to finish processing. 345 // Wait for the request to finish processing.
347 message_loop_.Run(); 346 message_loop_.Run();
348 } 347 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698