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

Side by Side Diff: net/url_request/url_request_context_builder_unittest.cc

Issue 22795006: Remove WorkerPool dependency from URLRequestFileJob. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix android include Created 7 years, 4 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 "net/url_request/url_request_context_builder.h" 5 #include "net/url_request/url_request_context_builder.h"
6 6
7 #include "base/run_loop.h"
7 #include "build/build_config.h" 8 #include "build/build_config.h"
8 #include "net/test/spawned_test_server/spawned_test_server.h" 9 #include "net/test/spawned_test_server/spawned_test_server.h"
9 #include "net/url_request/url_request.h" 10 #include "net/url_request/url_request.h"
10 #include "net/url_request/url_request_test_util.h" 11 #include "net/url_request/url_request_test_util.h"
11 #include "testing/gtest/include/gtest/gtest.h" 12 #include "testing/gtest/include/gtest/gtest.h"
12 #include "testing/platform_test.h" 13 #include "testing/platform_test.h"
13 14
14 #if defined(OS_LINUX) || defined(OS_ANDROID) 15 #if defined(OS_LINUX) || defined(OS_ANDROID)
15 #include "net/proxy/proxy_config.h" 16 #include "net/proxy/proxy_config.h"
16 #include "net/proxy/proxy_config_service_fixed.h" 17 #include "net/proxy/proxy_config_service_fixed.h"
(...skipping 15 matching lines...) Expand all
32 LocalHttpTestServer() 33 LocalHttpTestServer()
33 : SpawnedTestServer(SpawnedTestServer::TYPE_HTTP, 34 : SpawnedTestServer(SpawnedTestServer::TYPE_HTTP,
34 ScopedCustomUrlRequestTestHttpHost::value(), 35 ScopedCustomUrlRequestTestHttpHost::value(),
35 base::FilePath()) {} 36 base::FilePath()) {}
36 }; 37 };
37 38
38 class URLRequestContextBuilderTest : public PlatformTest { 39 class URLRequestContextBuilderTest : public PlatformTest {
39 protected: 40 protected:
40 URLRequestContextBuilderTest() 41 URLRequestContextBuilderTest()
41 : test_server_( 42 : test_server_(
42 base::FilePath(FILE_PATH_LITERAL("net/data/url_request_unittest"))) { 43 base::FilePath(FILE_PATH_LITERAL("net/data/url_request_unittest"))),
44 builder_(base::MessageLoopProxy::current()) {
43 #if defined(OS_LINUX) || defined(OS_ANDROID) 45 #if defined(OS_LINUX) || defined(OS_ANDROID)
44 builder_.set_proxy_config_service( 46 builder_.set_proxy_config_service(
45 new ProxyConfigServiceFixed(ProxyConfig::CreateDirect())); 47 new ProxyConfigServiceFixed(ProxyConfig::CreateDirect()));
46 #endif // defined(OS_LINUX) || defined(OS_ANDROID) 48 #endif // defined(OS_LINUX) || defined(OS_ANDROID)
47 } 49 }
48 50
49 LocalHttpTestServer test_server_; 51 LocalHttpTestServer test_server_;
50 URLRequestContextBuilder builder_; 52 URLRequestContextBuilder builder_;
51 }; 53 };
52 54
53 TEST_F(URLRequestContextBuilderTest, DefaultSettings) { 55 TEST_F(URLRequestContextBuilderTest, DefaultSettings) {
54 ASSERT_TRUE(test_server_.Start()); 56 ASSERT_TRUE(test_server_.Start());
55 57
56 scoped_ptr<URLRequestContext> context(builder_.Build()); 58 scoped_ptr<URLRequestContext> context(builder_.Build());
57 TestDelegate delegate; 59 TestDelegate delegate;
58 URLRequest request( 60 URLRequest request(
59 test_server_.GetURL("echoheader?Foo"), &delegate, context.get()); 61 test_server_.GetURL("echoheader?Foo"), &delegate, context.get());
60 request.set_method("GET"); 62 request.set_method("GET");
61 request.SetExtraRequestHeaderByName("Foo", "Bar", false); 63 request.SetExtraRequestHeaderByName("Foo", "Bar", false);
62 request.Start(); 64 request.Start();
63 base::MessageLoop::current()->Run(); 65 base::RunLoop().Run();
64 EXPECT_EQ("Bar", delegate.data_received()); 66 EXPECT_EQ("Bar", delegate.data_received());
65 } 67 }
66 68
67 TEST_F(URLRequestContextBuilderTest, UserAgent) { 69 TEST_F(URLRequestContextBuilderTest, UserAgent) {
68 ASSERT_TRUE(test_server_.Start()); 70 ASSERT_TRUE(test_server_.Start());
69 71
70 builder_.set_user_agent("Bar"); 72 builder_.set_user_agent("Bar");
71 scoped_ptr<URLRequestContext> context(builder_.Build()); 73 scoped_ptr<URLRequestContext> context(builder_.Build());
72 TestDelegate delegate; 74 TestDelegate delegate;
73 URLRequest request( 75 URLRequest request(
74 test_server_.GetURL("echoheader?User-Agent"), &delegate, context.get()); 76 test_server_.GetURL("echoheader?User-Agent"), &delegate, context.get());
75 request.set_method("GET"); 77 request.set_method("GET");
76 request.Start(); 78 request.Start();
77 base::MessageLoop::current()->Run(); 79 base::RunLoop().Run();
78 EXPECT_EQ("Bar", delegate.data_received()); 80 EXPECT_EQ("Bar", delegate.data_received());
79 } 81 }
80 82
81 } // namespace 83 } // namespace
82 84
83 } // namespace net 85 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698