| 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/test/test_server.h" | 8 #include "net/test/test_server.h" |
| 9 #include "net/url_request/url_request.h" | 9 #include "net/url_request/url_request.h" |
| 10 #include "net/url_request/url_request_test_util.h" | 10 #include "net/url_request/url_request_test_util.h" |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 | 48 |
| 49 LocalHttpTestServer test_server_; | 49 LocalHttpTestServer test_server_; |
| 50 URLRequestContextBuilder builder_; | 50 URLRequestContextBuilder builder_; |
| 51 }; | 51 }; |
| 52 | 52 |
| 53 TEST_F(URLRequestContextBuilderTest, DefaultSettings) { | 53 TEST_F(URLRequestContextBuilderTest, DefaultSettings) { |
| 54 ASSERT_TRUE(test_server_.Start()); | 54 ASSERT_TRUE(test_server_.Start()); |
| 55 | 55 |
| 56 scoped_ptr<URLRequestContext> context(builder_.Build()); | 56 scoped_ptr<URLRequestContext> context(builder_.Build()); |
| 57 TestDelegate delegate; | 57 TestDelegate delegate; |
| 58 URLRequest request(test_server_.GetURL("echoheader?Foo"), &delegate); | 58 URLRequest request( |
| 59 request.set_context(context.get()); | 59 test_server_.GetURL("echoheader?Foo"), &delegate, context.get()); |
| 60 request.set_method("GET"); | 60 request.set_method("GET"); |
| 61 request.SetExtraRequestHeaderByName("Foo", "Bar", false); | 61 request.SetExtraRequestHeaderByName("Foo", "Bar", false); |
| 62 request.Start(); | 62 request.Start(); |
| 63 MessageLoop::current()->Run(); | 63 MessageLoop::current()->Run(); |
| 64 EXPECT_EQ("Bar", delegate.data_received()); | 64 EXPECT_EQ("Bar", delegate.data_received()); |
| 65 } | 65 } |
| 66 | 66 |
| 67 TEST_F(URLRequestContextBuilderTest, UserAgent) { | 67 TEST_F(URLRequestContextBuilderTest, UserAgent) { |
| 68 ASSERT_TRUE(test_server_.Start()); | 68 ASSERT_TRUE(test_server_.Start()); |
| 69 | 69 |
| 70 builder_.set_user_agent("Bar"); | 70 builder_.set_user_agent("Bar"); |
| 71 scoped_ptr<URLRequestContext> context(builder_.Build()); | 71 scoped_ptr<URLRequestContext> context(builder_.Build()); |
| 72 TestDelegate delegate; | 72 TestDelegate delegate; |
| 73 URLRequest request(test_server_.GetURL("echoheader?User-Agent"), &delegate); | 73 URLRequest request( |
| 74 request.set_context(context.get()); | 74 test_server_.GetURL("echoheader?User-Agent"), &delegate, context.get()); |
| 75 request.set_method("GET"); | 75 request.set_method("GET"); |
| 76 request.Start(); | 76 request.Start(); |
| 77 MessageLoop::current()->Run(); | 77 MessageLoop::current()->Run(); |
| 78 EXPECT_EQ("Bar", delegate.data_received()); | 78 EXPECT_EQ("Bar", delegate.data_received()); |
| 79 } | 79 } |
| 80 | 80 |
| 81 } // namespace | 81 } // namespace |
| 82 | 82 |
| 83 } // namespace net | 83 } // namespace net |
| OLD | NEW |