| OLD | NEW |
| 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 "build/build_config.h" | 7 #include "build/build_config.h" |
| 8 #include "net/base/request_priority.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" |
| 17 #endif // defined(OS_LINUX) || defined(OS_ANDROID) | 18 #endif // defined(OS_LINUX) || defined(OS_ANDROID) |
| (...skipping 30 matching lines...) Expand all Loading... |
| 48 | 49 |
| 49 LocalHttpTestServer test_server_; | 50 LocalHttpTestServer test_server_; |
| 50 URLRequestContextBuilder builder_; | 51 URLRequestContextBuilder builder_; |
| 51 }; | 52 }; |
| 52 | 53 |
| 53 TEST_F(URLRequestContextBuilderTest, DefaultSettings) { | 54 TEST_F(URLRequestContextBuilderTest, DefaultSettings) { |
| 54 ASSERT_TRUE(test_server_.Start()); | 55 ASSERT_TRUE(test_server_.Start()); |
| 55 | 56 |
| 56 scoped_ptr<URLRequestContext> context(builder_.Build()); | 57 scoped_ptr<URLRequestContext> context(builder_.Build()); |
| 57 TestDelegate delegate; | 58 TestDelegate delegate; |
| 58 URLRequest request( | 59 URLRequest request(test_server_.GetURL("echoheader?Foo"), |
| 59 test_server_.GetURL("echoheader?Foo"), &delegate, context.get()); | 60 DEFAULT_PRIORITY, |
| 61 &delegate, |
| 62 context.get(), |
| 63 context->network_delegate()); |
| 60 request.set_method("GET"); | 64 request.set_method("GET"); |
| 61 request.SetExtraRequestHeaderByName("Foo", "Bar", false); | 65 request.SetExtraRequestHeaderByName("Foo", "Bar", false); |
| 62 request.Start(); | 66 request.Start(); |
| 63 base::MessageLoop::current()->Run(); | 67 base::MessageLoop::current()->Run(); |
| 64 EXPECT_EQ("Bar", delegate.data_received()); | 68 EXPECT_EQ("Bar", delegate.data_received()); |
| 65 } | 69 } |
| 66 | 70 |
| 67 TEST_F(URLRequestContextBuilderTest, UserAgent) { | 71 TEST_F(URLRequestContextBuilderTest, UserAgent) { |
| 68 ASSERT_TRUE(test_server_.Start()); | 72 ASSERT_TRUE(test_server_.Start()); |
| 69 | 73 |
| 70 builder_.set_user_agent("Bar"); | 74 builder_.set_user_agent("Bar"); |
| 71 scoped_ptr<URLRequestContext> context(builder_.Build()); | 75 scoped_ptr<URLRequestContext> context(builder_.Build()); |
| 72 TestDelegate delegate; | 76 TestDelegate delegate; |
| 73 URLRequest request( | 77 URLRequest request(test_server_.GetURL("echoheader?User-Agent"), |
| 74 test_server_.GetURL("echoheader?User-Agent"), &delegate, context.get()); | 78 DEFAULT_PRIORITY, |
| 79 &delegate, |
| 80 context.get(), |
| 81 context->network_delegate()); |
| 75 request.set_method("GET"); | 82 request.set_method("GET"); |
| 76 request.Start(); | 83 request.Start(); |
| 77 base::MessageLoop::current()->Run(); | 84 base::MessageLoop::current()->Run(); |
| 78 EXPECT_EQ("Bar", delegate.data_received()); | 85 EXPECT_EQ("Bar", delegate.data_received()); |
| 79 } | 86 } |
| 80 | 87 |
| 81 } // namespace | 88 } // namespace |
| 82 | 89 |
| 83 } // namespace net | 90 } // namespace net |
| OLD | NEW |