| 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()); |
| 60 request.set_method("GET"); | 63 request.set_method("GET"); |
| 61 request.SetExtraRequestHeaderByName("Foo", "Bar", false); | 64 request.SetExtraRequestHeaderByName("Foo", "Bar", false); |
| 62 request.Start(); | 65 request.Start(); |
| 63 base::MessageLoop::current()->Run(); | 66 base::MessageLoop::current()->Run(); |
| 64 EXPECT_EQ("Bar", delegate.data_received()); | 67 EXPECT_EQ("Bar", delegate.data_received()); |
| 65 } | 68 } |
| 66 | 69 |
| 67 TEST_F(URLRequestContextBuilderTest, UserAgent) { | 70 TEST_F(URLRequestContextBuilderTest, UserAgent) { |
| 68 ASSERT_TRUE(test_server_.Start()); | 71 ASSERT_TRUE(test_server_.Start()); |
| 69 | 72 |
| 70 builder_.set_user_agent("Bar"); | 73 builder_.set_user_agent("Bar"); |
| 71 scoped_ptr<URLRequestContext> context(builder_.Build()); | 74 scoped_ptr<URLRequestContext> context(builder_.Build()); |
| 72 TestDelegate delegate; | 75 TestDelegate delegate; |
| 73 URLRequest request( | 76 URLRequest request(test_server_.GetURL("echoheader?User-Agent"), |
| 74 test_server_.GetURL("echoheader?User-Agent"), &delegate, context.get()); | 77 DEFAULT_PRIORITY, |
| 78 &delegate, |
| 79 context.get()); |
| 75 request.set_method("GET"); | 80 request.set_method("GET"); |
| 76 request.Start(); | 81 request.Start(); |
| 77 base::MessageLoop::current()->Run(); | 82 base::MessageLoop::current()->Run(); |
| 78 EXPECT_EQ("Bar", delegate.data_received()); | 83 EXPECT_EQ("Bar", delegate.data_received()); |
| 79 } | 84 } |
| 80 | 85 |
| 81 } // namespace | 86 } // namespace |
| 82 | 87 |
| 83 } // namespace net | 88 } // namespace net |
| OLD | NEW |