| OLD | NEW |
| 1 // Copyright (c) 2011 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/sync/glue/http_bridge.h" | 7 #include "chrome/browser/sync/glue/http_bridge.h" |
| 8 #include "chrome/test/base/test_url_request_context_getter.h" | 8 #include "chrome/test/base/test_url_request_context_getter.h" |
| 9 #include "content/browser/browser_thread.h" | 9 #include "content/browser/browser_thread.h" |
| 10 #include "content/test/test_url_fetcher_factory.h" | 10 #include "content/test/test_url_fetcher_factory.h" |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 private: | 122 private: |
| 123 ~ShuntedHttpBridge() {} | 123 ~ShuntedHttpBridge() {} |
| 124 | 124 |
| 125 void CallOnURLFetchComplete() { | 125 void CallOnURLFetchComplete() { |
| 126 ASSERT_TRUE(MessageLoop::current() == test_->io_thread_loop()); | 126 ASSERT_TRUE(MessageLoop::current() == test_->io_thread_loop()); |
| 127 // We return no cookies and a dummy content response. | 127 // We return no cookies and a dummy content response. |
| 128 net::ResponseCookies cookies; | 128 net::ResponseCookies cookies; |
| 129 | 129 |
| 130 std::string response_content = "success!"; | 130 std::string response_content = "success!"; |
| 131 DummyURLFetcher fetcher; | 131 DummyURLFetcher fetcher; |
| 132 OnURLFetchComplete(&fetcher, GURL("www.google.com"), | 132 fetcher.set_url(GURL("www.google.com")); |
| 133 net::URLRequestStatus(), | 133 fetcher.set_response_code(200); |
| 134 200, cookies, response_content); | 134 fetcher.set_cookies(cookies); |
| 135 fetcher.SetResponseString(response_content); |
| 136 OnURLFetchComplete(&fetcher); |
| 135 } | 137 } |
| 136 HttpBridgeTest* test_; | 138 HttpBridgeTest* test_; |
| 137 bool never_finishes_; | 139 bool never_finishes_; |
| 138 }; | 140 }; |
| 139 | 141 |
| 140 TEST_F(HttpBridgeTest, TestUsesSameHttpNetworkSession) { | 142 TEST_F(HttpBridgeTest, TestUsesSameHttpNetworkSession) { |
| 141 // Run this test on the IO thread because we can only call | 143 // Run this test on the IO thread because we can only call |
| 142 // URLRequestContextGetter::GetURLRequestContext on the IO thread. | 144 // URLRequestContextGetter::GetURLRequestContext on the IO thread. |
| 143 BrowserThread::PostTask( | 145 BrowserThread::PostTask( |
| 144 BrowserThread::IO, FROM_HERE, | 146 BrowserThread::IO, FROM_HERE, |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 301 http_bridge->SetPostPayload("text/plain", 2, " "); | 303 http_bridge->SetPostPayload("text/plain", 2, " "); |
| 302 | 304 |
| 303 int os_error = 0; | 305 int os_error = 0; |
| 304 int response_code = 0; | 306 int response_code = 0; |
| 305 | 307 |
| 306 bool success = http_bridge->MakeSynchronousPost(&os_error, &response_code); | 308 bool success = http_bridge->MakeSynchronousPost(&os_error, &response_code); |
| 307 ASSERT_TRUE(success); | 309 ASSERT_TRUE(success); |
| 308 http_bridge->Abort(); | 310 http_bridge->Abort(); |
| 309 // Ensures no double-free of URLFetcher, etc. | 311 // Ensures no double-free of URLFetcher, etc. |
| 310 } | 312 } |
| OLD | NEW |