OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "base/message_loop_proxy.h" | 5 #include "base/message_loop_proxy.h" |
6 #include "base/threading/thread.h" | 6 #include "base/threading/thread.h" |
7 #include "chrome/browser/browser_thread.h" | 7 #include "chrome/browser/browser_thread.h" |
8 #include "chrome/browser/sync/glue/http_bridge.h" | 8 #include "chrome/browser/sync/glue/http_bridge.h" |
9 #include "chrome/common/net/test_url_fetcher_factory.h" | 9 #include "chrome/common/net/test_url_fetcher_factory.h" |
10 #include "net/url_request/url_request_unittest.h" | 10 #include "net/url_request/url_request_unittest.h" |
11 #include "net/test/test_server.h" | 11 #include "net/test/test_server.h" |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 private: | 130 private: |
131 ~ShuntedHttpBridge() {} | 131 ~ShuntedHttpBridge() {} |
132 | 132 |
133 void CallOnURLFetchComplete() { | 133 void CallOnURLFetchComplete() { |
134 ASSERT_TRUE(MessageLoop::current() == test_->io_thread_loop()); | 134 ASSERT_TRUE(MessageLoop::current() == test_->io_thread_loop()); |
135 // We return no cookies and a dummy content response. | 135 // We return no cookies and a dummy content response. |
136 ResponseCookies cookies; | 136 ResponseCookies cookies; |
137 | 137 |
138 std::string response_content = "success!"; | 138 std::string response_content = "success!"; |
139 DummyURLFetcher fetcher; | 139 DummyURLFetcher fetcher; |
140 OnURLFetchComplete(&fetcher, GURL("www.google.com"), URLRequestStatus(), | 140 OnURLFetchComplete(&fetcher, GURL("www.google.com"), |
| 141 net::URLRequestStatus(), |
141 200, cookies, response_content); | 142 200, cookies, response_content); |
142 } | 143 } |
143 HttpBridgeTest* test_; | 144 HttpBridgeTest* test_; |
144 }; | 145 }; |
145 | 146 |
146 TEST_F(HttpBridgeTest, TestUsesSameHttpNetworkSession) { | 147 TEST_F(HttpBridgeTest, TestUsesSameHttpNetworkSession) { |
147 // Run this test on the IO thread because we can only call | 148 // Run this test on the IO thread because we can only call |
148 // URLRequestContextGetter::GetURLRequestContext on the IO thread. | 149 // URLRequestContextGetter::GetURLRequestContext on the IO thread. |
149 BrowserThread::PostTask( | 150 BrowserThread::PostTask( |
150 BrowserThread::IO, FROM_HERE, | 151 BrowserThread::IO, FROM_HERE, |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
270 int os_error = 0; | 271 int os_error = 0; |
271 int response_code = 0; | 272 int response_code = 0; |
272 bool success = http_bridge->MakeSynchronousPost(&os_error, &response_code); | 273 bool success = http_bridge->MakeSynchronousPost(&os_error, &response_code); |
273 EXPECT_TRUE(success); | 274 EXPECT_TRUE(success); |
274 EXPECT_EQ(200, response_code); | 275 EXPECT_EQ(200, response_code); |
275 EXPECT_EQ(0, os_error); | 276 EXPECT_EQ(0, os_error); |
276 | 277 |
277 EXPECT_EQ(http_bridge->GetResponseHeaderValue("Content-type"), "text/html"); | 278 EXPECT_EQ(http_bridge->GetResponseHeaderValue("Content-type"), "text/html"); |
278 EXPECT_TRUE(http_bridge->GetResponseHeaderValue("invalid-header").empty()); | 279 EXPECT_TRUE(http_bridge->GetResponseHeaderValue("invalid-header").empty()); |
279 } | 280 } |
OLD | NEW |