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

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

Issue 10492009: Move test headers from content\test to content\public\test. This way we can enforce that internal c… (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: fix mac Created 8 years, 6 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 "content/browser/renderer_host/resource_dispatcher_host_impl.h" 5 #include "content/browser/renderer_host/resource_dispatcher_host_impl.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/memory/scoped_vector.h" 11 #include "base/memory/scoped_vector.h"
12 #include "base/message_loop.h" 12 #include "base/message_loop.h"
13 #include "base/process_util.h" 13 #include "base/process_util.h"
14 #include "content/browser/browser_thread_impl.h" 14 #include "content/browser/browser_thread_impl.h"
15 #include "content/browser/child_process_security_policy_impl.h" 15 #include "content/browser/child_process_security_policy_impl.h"
16 #include "content/browser/renderer_host/resource_dispatcher_host_impl.h" 16 #include "content/browser/renderer_host/resource_dispatcher_host_impl.h"
17 #include "content/browser/renderer_host/resource_message_filter.h" 17 #include "content/browser/renderer_host/resource_message_filter.h"
18 #include "content/common/child_process_host_impl.h" 18 #include "content/common/child_process_host_impl.h"
19 #include "content/common/resource_messages.h" 19 #include "content/common/resource_messages.h"
20 #include "content/common/view_messages.h" 20 #include "content/common/view_messages.h"
21 #include "content/public/browser/global_request_id.h" 21 #include "content/public/browser/global_request_id.h"
22 #include "content/public/browser/resource_context.h" 22 #include "content/public/browser/resource_context.h"
23 #include "content/public/browser/resource_dispatcher_host_delegate.h" 23 #include "content/public/browser/resource_dispatcher_host_delegate.h"
24 #include "content/public/browser/resource_throttle.h" 24 #include "content/public/browser/resource_throttle.h"
25 #include "content/public/common/resource_response.h" 25 #include "content/public/common/resource_response.h"
26 #include "content/test/test_browser_context.h" 26 #include "content/public/test/test_browser_context.h"
27 #include "net/base/net_errors.h" 27 #include "net/base/net_errors.h"
28 #include "net/base/upload_data.h" 28 #include "net/base/upload_data.h"
29 #include "net/http/http_util.h" 29 #include "net/http/http_util.h"
30 #include "net/url_request/url_request.h" 30 #include "net/url_request/url_request.h"
31 #include "net/url_request/url_request_job.h" 31 #include "net/url_request/url_request_job.h"
32 #include "net/url_request/url_request_test_job.h" 32 #include "net/url_request/url_request_test_job.h"
33 #include "testing/gtest/include/gtest/gtest.h" 33 #include "testing/gtest/include/gtest/gtest.h"
34 #include "webkit/appcache/appcache_interfaces.h" 34 #include "webkit/appcache/appcache_interfaces.h"
35 35
36 // TODO(eroman): Write unit tests for SafeBrowsing that exercise 36 // TODO(eroman): Write unit tests for SafeBrowsing that exercise
(...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after
347 class ResourceDispatcherHostTest : public testing::Test, 347 class ResourceDispatcherHostTest : public testing::Test,
348 public IPC::Message::Sender { 348 public IPC::Message::Sender {
349 public: 349 public:
350 ResourceDispatcherHostTest() 350 ResourceDispatcherHostTest()
351 : ui_thread_(BrowserThread::UI, &message_loop_), 351 : ui_thread_(BrowserThread::UI, &message_loop_),
352 file_thread_(BrowserThread::FILE_USER_BLOCKING, &message_loop_), 352 file_thread_(BrowserThread::FILE_USER_BLOCKING, &message_loop_),
353 cache_thread_(BrowserThread::CACHE, &message_loop_), 353 cache_thread_(BrowserThread::CACHE, &message_loop_),
354 io_thread_(BrowserThread::IO, &message_loop_), 354 io_thread_(BrowserThread::IO, &message_loop_),
355 old_factory_(NULL), 355 old_factory_(NULL),
356 resource_type_(ResourceType::SUB_RESOURCE) { 356 resource_type_(ResourceType::SUB_RESOURCE) {
357 browser_context_.reset(new TestBrowserContext()); 357 browser_context_.reset(new content::TestBrowserContext());
358 BrowserContext::EnsureResourceContextInitialized(browser_context_.get()); 358 BrowserContext::EnsureResourceContextInitialized(browser_context_.get());
359 message_loop_.RunAllPending(); 359 message_loop_.RunAllPending();
360 filter_ = new ForwardingFilter( 360 filter_ = new ForwardingFilter(
361 this, browser_context_->GetResourceContext()); 361 this, browser_context_->GetResourceContext());
362 } 362 }
363 // IPC::Message::Sender implementation 363 // IPC::Message::Sender implementation
364 virtual bool Send(IPC::Message* msg) { 364 virtual bool Send(IPC::Message* msg) {
365 accum_.AddMessage(*msg); 365 accum_.AddMessage(*msg);
366 delete msg; 366 delete msg;
367 return true; 367 return true;
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
474 474
475 void SetDelayedStartJobGeneration(bool delay_job_start) { 475 void SetDelayedStartJobGeneration(bool delay_job_start) {
476 delay_start_ = delay_job_start; 476 delay_start_ = delay_job_start;
477 } 477 }
478 478
479 MessageLoopForIO message_loop_; 479 MessageLoopForIO message_loop_;
480 BrowserThreadImpl ui_thread_; 480 BrowserThreadImpl ui_thread_;
481 BrowserThreadImpl file_thread_; 481 BrowserThreadImpl file_thread_;
482 BrowserThreadImpl cache_thread_; 482 BrowserThreadImpl cache_thread_;
483 BrowserThreadImpl io_thread_; 483 BrowserThreadImpl io_thread_;
484 scoped_ptr<TestBrowserContext> browser_context_; 484 scoped_ptr<content::TestBrowserContext> browser_context_;
485 scoped_refptr<ForwardingFilter> filter_; 485 scoped_refptr<ForwardingFilter> filter_;
486 ResourceDispatcherHostImpl host_; 486 ResourceDispatcherHostImpl host_;
487 ResourceIPCAccumulator accum_; 487 ResourceIPCAccumulator accum_;
488 std::string response_headers_; 488 std::string response_headers_;
489 std::string response_data_; 489 std::string response_data_;
490 std::string scheme_; 490 std::string scheme_;
491 net::URLRequest::ProtocolFactory* old_factory_; 491 net::URLRequest::ProtocolFactory* old_factory_;
492 ResourceType::Type resource_type_; 492 ResourceType::Type resource_type_;
493 static ResourceDispatcherHostTest* test_fixture_; 493 static ResourceDispatcherHostTest* test_fixture_;
494 static bool delay_start_; 494 static bool delay_start_;
(...skipping 882 matching lines...) Expand 10 before | Expand all | Expand 10 after
1377 PickleIterator iter(msgs[0][0]); 1377 PickleIterator iter(msgs[0][0]);
1378 EXPECT_TRUE(IPC::ReadParam(&msgs[0][0], &iter, &request_id)); 1378 EXPECT_TRUE(IPC::ReadParam(&msgs[0][0], &iter, &request_id));
1379 EXPECT_TRUE(IPC::ReadParam(&msgs[0][0], &iter, &status)); 1379 EXPECT_TRUE(IPC::ReadParam(&msgs[0][0], &iter, &status));
1380 1380
1381 EXPECT_EQ(1, request_id); 1381 EXPECT_EQ(1, request_id);
1382 EXPECT_EQ(net::URLRequestStatus::FAILED, status.status()); 1382 EXPECT_EQ(net::URLRequestStatus::FAILED, status.status());
1383 EXPECT_EQ(net::ERR_UNKNOWN_URL_SCHEME, status.error()); 1383 EXPECT_EQ(net::ERR_UNKNOWN_URL_SCHEME, status.error());
1384 } 1384 }
1385 1385
1386 } // namespace content 1386 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698