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

Side by Side Diff: content/browser/renderer_host/resource_dispatcher_host_unittest.cc

Issue 8400060: Switch content tests to use BrowserThreadImpl directly. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/renderer_host/resource_dispatcher_host.h" 5 #include "content/browser/renderer_host/resource_dispatcher_host.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/file_path.h" 10 #include "base/file_path.h"
11 #include "base/message_loop.h" 11 #include "base/message_loop.h"
12 #include "base/process_util.h" 12 #include "base/process_util.h"
13 #include "content/browser/browser_thread_impl.h"
13 #include "content/browser/child_process_security_policy.h" 14 #include "content/browser/child_process_security_policy.h"
14 #include "content/browser/download/download_id.h" 15 #include "content/browser/download/download_id.h"
15 #include "content/browser/mock_resource_context.h" 16 #include "content/browser/mock_resource_context.h"
16 #include "content/browser/renderer_host/dummy_resource_handler.h" 17 #include "content/browser/renderer_host/dummy_resource_handler.h"
17 #include "content/browser/renderer_host/global_request_id.h" 18 #include "content/browser/renderer_host/global_request_id.h"
18 #include "content/browser/renderer_host/resource_dispatcher_host.h" 19 #include "content/browser/renderer_host/resource_dispatcher_host.h"
19 #include "content/browser/renderer_host/resource_dispatcher_host_request_info.h" 20 #include "content/browser/renderer_host/resource_dispatcher_host_request_info.h"
20 #include "content/browser/renderer_host/resource_handler.h" 21 #include "content/browser/renderer_host/resource_handler.h"
21 #include "content/browser/renderer_host/resource_message_filter.h" 22 #include "content/browser/renderer_host/resource_message_filter.h"
22 #include "content/common/resource_messages.h" 23 #include "content/common/resource_messages.h"
23 #include "content/common/resource_response.h" 24 #include "content/common/resource_response.h"
24 #include "content/common/view_messages.h" 25 #include "content/common/view_messages.h"
25 #include "content/test/test_browser_thread.h"
26 #include "net/base/net_errors.h" 26 #include "net/base/net_errors.h"
27 #include "net/base/upload_data.h" 27 #include "net/base/upload_data.h"
28 #include "net/http/http_util.h" 28 #include "net/http/http_util.h"
29 #include "net/url_request/url_request.h" 29 #include "net/url_request/url_request.h"
30 #include "net/url_request/url_request_job.h" 30 #include "net/url_request/url_request_job.h"
31 #include "net/url_request/url_request_test_job.h" 31 #include "net/url_request/url_request_test_job.h"
32 #include "testing/gtest/include/gtest/gtest.h" 32 #include "testing/gtest/include/gtest/gtest.h"
33 #include "webkit/appcache/appcache_interfaces.h" 33 #include "webkit/appcache/appcache_interfaces.h"
34 34
35 using content::BrowserThreadImpl;
36
35 // TODO(eroman): Write unit tests for SafeBrowsing that exercise 37 // TODO(eroman): Write unit tests for SafeBrowsing that exercise
36 // SafeBrowsingResourceHandler. 38 // SafeBrowsingResourceHandler.
37 39
38 namespace { 40 namespace {
39 41
40 // Returns the resource response header structure for this request. 42 // Returns the resource response header structure for this request.
41 void GetResponseHead(const std::vector<IPC::Message>& messages, 43 void GetResponseHead(const std::vector<IPC::Message>& messages,
42 ResourceResponseHead* response_head) { 44 ResourceResponseHead* response_head) {
43 ASSERT_GE(messages.size(), 2U); 45 ASSERT_GE(messages.size(), 2U);
44 46
(...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after
378 false); 380 false);
379 } 381 }
380 } 382 }
381 } 383 }
382 384
383 void SetDelayedStartJobGeneration(bool delay_job_start) { 385 void SetDelayedStartJobGeneration(bool delay_job_start) {
384 delay_start_ = delay_job_start; 386 delay_start_ = delay_job_start;
385 } 387 }
386 388
387 MessageLoopForIO message_loop_; 389 MessageLoopForIO message_loop_;
388 content::TestBrowserThread ui_thread_; 390 BrowserThreadImpl ui_thread_;
389 content::TestBrowserThread io_thread_; 391 BrowserThreadImpl io_thread_;
390 scoped_refptr<ForwardingFilter> filter_; 392 scoped_refptr<ForwardingFilter> filter_;
391 ResourceDispatcherHost host_; 393 ResourceDispatcherHost host_;
392 ResourceIPCAccumulator accum_; 394 ResourceIPCAccumulator accum_;
393 std::string response_headers_; 395 std::string response_headers_;
394 std::string response_data_; 396 std::string response_data_;
395 std::string scheme_; 397 std::string scheme_;
396 net::URLRequest::ProtocolFactory* old_factory_; 398 net::URLRequest::ProtocolFactory* old_factory_;
397 ResourceType::Type resource_type_; 399 ResourceType::Type resource_type_;
398 static ResourceDispatcherHostTest* test_fixture_; 400 static ResourceDispatcherHostTest* test_fixture_;
399 static bool delay_start_; 401 static bool delay_start_;
(...skipping 815 matching lines...) Expand 10 before | Expand all | Expand 10 after
1215 EXPECT_EQ(1, host_.pending_requests()); 1217 EXPECT_EQ(1, host_.pending_requests());
1216 1218
1217 // Cancelling by other methods shouldn't work either. 1219 // Cancelling by other methods shouldn't work either.
1218 host_.CancelRequestsForProcess(render_view_id); 1220 host_.CancelRequestsForProcess(render_view_id);
1219 EXPECT_EQ(1, host_.pending_requests()); 1221 EXPECT_EQ(1, host_.pending_requests());
1220 1222
1221 // Cancelling by context should work. 1223 // Cancelling by context should work.
1222 host_.CancelRequestsForContext(&filter_->resource_context()); 1224 host_.CancelRequestsForContext(&filter_->resource_context());
1223 EXPECT_EQ(0, host_.pending_requests()); 1225 EXPECT_EQ(0, host_.pending_requests());
1224 } 1226 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698