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

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

Issue 1378123003: Adding SSL ETS Tests (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@ets
Patch Set: Rebase. Created 5 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
« no previous file with comments | « net/url_request/url_fetcher_impl_unittest.cc ('k') | net/url_request/url_request_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/memory/scoped_ptr.h" 7 #include "base/memory/scoped_ptr.h"
8 #include "build/build_config.h" 8 #include "build/build_config.h"
9 #include "net/base/request_priority.h" 9 #include "net/base/request_priority.h"
10 #include "net/http/http_auth_handler.h" 10 #include "net/http/http_auth_handler.h"
11 #include "net/http/http_auth_handler_factory.h" 11 #include "net/http/http_auth_handler_factory.h"
12 #include "net/test/spawned_test_server/spawned_test_server.h" 12 #include "net/test/embedded_test_server/embedded_test_server.h"
13 #include "net/url_request/url_request.h" 13 #include "net/url_request/url_request.h"
14 #include "net/url_request/url_request_test_util.h" 14 #include "net/url_request/url_request_test_util.h"
15 #include "testing/gtest/include/gtest/gtest.h" 15 #include "testing/gtest/include/gtest/gtest.h"
16 #include "testing/platform_test.h" 16 #include "testing/platform_test.h"
17 17
18 #if defined(OS_LINUX) || defined(OS_ANDROID) 18 #if defined(OS_LINUX) || defined(OS_ANDROID)
19 #include "net/proxy/proxy_config.h" 19 #include "net/proxy/proxy_config.h"
20 #include "net/proxy/proxy_config_service_fixed.h" 20 #include "net/proxy/proxy_config_service_fixed.h"
21 #endif // defined(OS_LINUX) || defined(OS_ANDROID) 21 #endif // defined(OS_LINUX) || defined(OS_ANDROID)
22 22
(...skipping 17 matching lines...) Expand all
40 handler->reset(); 40 handler->reset();
41 return return_code_; 41 return return_code_;
42 } 42 }
43 43
44 private: 44 private:
45 int return_code_; 45 int return_code_;
46 }; 46 };
47 47
48 class URLRequestContextBuilderTest : public PlatformTest { 48 class URLRequestContextBuilderTest : public PlatformTest {
49 protected: 49 protected:
50 URLRequestContextBuilderTest() 50 URLRequestContextBuilderTest() {
51 : test_server_(SpawnedTestServer::TYPE_HTTP, 51 test_server_.AddDefaultHandlers(
52 SpawnedTestServer::kLocalhost, 52 base::FilePath(FILE_PATH_LITERAL("net/data/url_request_unittest")));
53 base::FilePath(
54 FILE_PATH_LITERAL("net/data/url_request_unittest"))) {
55 #if defined(OS_LINUX) || defined(OS_ANDROID) 53 #if defined(OS_LINUX) || defined(OS_ANDROID)
56 builder_.set_proxy_config_service(make_scoped_ptr( 54 builder_.set_proxy_config_service(make_scoped_ptr(
57 new ProxyConfigServiceFixed(ProxyConfig::CreateDirect()))); 55 new ProxyConfigServiceFixed(ProxyConfig::CreateDirect())));
58 #endif // defined(OS_LINUX) || defined(OS_ANDROID) 56 #endif // defined(OS_LINUX) || defined(OS_ANDROID)
59 } 57 }
60 58
61 SpawnedTestServer test_server_; 59 EmbeddedTestServer test_server_;
62 URLRequestContextBuilder builder_; 60 URLRequestContextBuilder builder_;
63 }; 61 };
64 62
65 TEST_F(URLRequestContextBuilderTest, DefaultSettings) { 63 TEST_F(URLRequestContextBuilderTest, DefaultSettings) {
66 ASSERT_TRUE(test_server_.Start()); 64 ASSERT_TRUE(test_server_.Start());
67 65
68 scoped_ptr<URLRequestContext> context(builder_.Build()); 66 scoped_ptr<URLRequestContext> context(builder_.Build());
69 TestDelegate delegate; 67 TestDelegate delegate;
70 scoped_ptr<URLRequest> request(context->CreateRequest( 68 scoped_ptr<URLRequest> request(context->CreateRequest(
71 test_server_.GetURL("echoheader?Foo"), DEFAULT_PRIORITY, &delegate)); 69 test_server_.GetURL("/echoheader?Foo"), DEFAULT_PRIORITY, &delegate));
72 request->set_method("GET"); 70 request->set_method("GET");
73 request->SetExtraRequestHeaderByName("Foo", "Bar", false); 71 request->SetExtraRequestHeaderByName("Foo", "Bar", false);
74 request->Start(); 72 request->Start();
75 base::MessageLoop::current()->Run(); 73 base::MessageLoop::current()->Run();
76 EXPECT_EQ("Bar", delegate.data_received()); 74 EXPECT_EQ("Bar", delegate.data_received());
77 } 75 }
78 76
79 TEST_F(URLRequestContextBuilderTest, UserAgent) { 77 TEST_F(URLRequestContextBuilderTest, UserAgent) {
80 ASSERT_TRUE(test_server_.Start()); 78 ASSERT_TRUE(test_server_.Start());
81 79
82 builder_.set_user_agent("Bar"); 80 builder_.set_user_agent("Bar");
83 scoped_ptr<URLRequestContext> context(builder_.Build()); 81 scoped_ptr<URLRequestContext> context(builder_.Build());
84 TestDelegate delegate; 82 TestDelegate delegate;
85 scoped_ptr<URLRequest> request( 83 scoped_ptr<URLRequest> request(
86 context->CreateRequest(test_server_.GetURL("echoheader?User-Agent"), 84 context->CreateRequest(test_server_.GetURL("/echoheader?User-Agent"),
87 DEFAULT_PRIORITY, &delegate)); 85 DEFAULT_PRIORITY, &delegate));
88 request->set_method("GET"); 86 request->set_method("GET");
89 request->Start(); 87 request->Start();
90 base::MessageLoop::current()->Run(); 88 base::MessageLoop::current()->Run();
91 EXPECT_EQ("Bar", delegate.data_received()); 89 EXPECT_EQ("Bar", delegate.data_received());
92 } 90 }
93 91
94 TEST_F(URLRequestContextBuilderTest, ExtraHttpAuthHandlerFactory) { 92 TEST_F(URLRequestContextBuilderTest, ExtraHttpAuthHandlerFactory) {
95 GURL gurl("www.google.com"); 93 GURL gurl("www.google.com");
96 const int kBasicReturnCode = OK; 94 const int kBasicReturnCode = OK;
(...skipping 12 matching lines...) Expand all
109 &handler)); 107 &handler));
110 // Verify that a handler isn't returned for a bogus scheme. 108 // Verify that a handler isn't returned for a bogus scheme.
111 EXPECT_EQ(ERR_UNSUPPORTED_AUTH_SCHEME, 109 EXPECT_EQ(ERR_UNSUPPORTED_AUTH_SCHEME,
112 context->http_auth_handler_factory()->CreateAuthHandlerFromString( 110 context->http_auth_handler_factory()->CreateAuthHandlerFromString(
113 "Bogus", HttpAuth::AUTH_SERVER, gurl, BoundNetLog(), &handler)); 111 "Bogus", HttpAuth::AUTH_SERVER, gurl, BoundNetLog(), &handler));
114 } 112 }
115 113
116 } // namespace 114 } // namespace
117 115
118 } // namespace net 116 } // namespace net
OLDNEW
« no previous file with comments | « net/url_request/url_fetcher_impl_unittest.cc ('k') | net/url_request/url_request_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698