Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(40)

Side by Side Diff: chrome/browser/sync/glue/http_bridge_unittest.cc

Issue 8416020: Handle additional feedback from http://codereview.chromium.org/8395038/. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 private: 81 private:
82 // A make-believe "default" request context, as would be returned by 82 // A make-believe "default" request context, as would be returned by
83 // Profile::GetDefaultRequestContext(). Created lazily by BuildBridge. 83 // Profile::GetDefaultRequestContext(). Created lazily by BuildBridge.
84 TestURLRequestContextGetter* fake_default_request_context_getter_; 84 TestURLRequestContextGetter* fake_default_request_context_getter_;
85 85
86 // Separate thread for IO used by the HttpBridge. 86 // Separate thread for IO used by the HttpBridge.
87 BrowserThread io_thread_; 87 BrowserThread io_thread_;
88 MessageLoop loop_; 88 MessageLoop loop_;
89 }; 89 };
90 90
91 class DummyURLFetcher : public TestURLFetcher {
92 public:
93 DummyURLFetcher() : TestURLFetcher(0, GURL(), POST, NULL) {}
94
95 net::HttpResponseHeaders* GetResponseHeaders() const {
96 return NULL;
97 }
98 };
99
100 // An HttpBridge that doesn't actually make network requests and just calls 91 // An HttpBridge that doesn't actually make network requests and just calls
101 // back with dummy response info. 92 // back with dummy response info.
102 class ShuntedHttpBridge : public HttpBridge { 93 class ShuntedHttpBridge : public HttpBridge {
103 public: 94 public:
104 // If |never_finishes| is true, the simulated request never actually 95 // If |never_finishes| is true, the simulated request never actually
105 // returns. 96 // returns.
106 ShuntedHttpBridge(net::URLRequestContextGetter* baseline_context_getter, 97 ShuntedHttpBridge(net::URLRequestContextGetter* baseline_context_getter,
107 HttpBridgeTest* test, bool never_finishes) 98 HttpBridgeTest* test, bool never_finishes)
108 : HttpBridge(new HttpBridge::RequestContextGetter( 99 : HttpBridge(new HttpBridge::RequestContextGetter(
109 baseline_context_getter)), 100 baseline_context_getter)),
(...skipping 11 matching lines...) Expand all
121 } 112 }
122 private: 113 private:
123 ~ShuntedHttpBridge() {} 114 ~ShuntedHttpBridge() {}
124 115
125 void CallOnURLFetchComplete() { 116 void CallOnURLFetchComplete() {
126 ASSERT_TRUE(MessageLoop::current() == test_->io_thread_loop()); 117 ASSERT_TRUE(MessageLoop::current() == test_->io_thread_loop());
127 // We return no cookies and a dummy content response. 118 // We return no cookies and a dummy content response.
128 net::ResponseCookies cookies; 119 net::ResponseCookies cookies;
129 120
130 std::string response_content = "success!"; 121 std::string response_content = "success!";
131 DummyURLFetcher fetcher; 122 TestURLFetcher fetcher(0, GURL(), NULL);
132 fetcher.set_url(GURL("www.google.com")); 123 fetcher.set_url(GURL("www.google.com"));
133 fetcher.set_response_code(200); 124 fetcher.set_response_code(200);
134 fetcher.set_cookies(cookies); 125 fetcher.set_cookies(cookies);
135 fetcher.SetResponseString(response_content); 126 fetcher.SetResponseString(response_content);
136 OnURLFetchComplete(&fetcher); 127 OnURLFetchComplete(&fetcher);
137 } 128 }
138 HttpBridgeTest* test_; 129 HttpBridgeTest* test_;
139 bool never_finishes_; 130 bool never_finishes_;
140 }; 131 };
141 132
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
303 http_bridge->SetPostPayload("text/plain", 2, " "); 294 http_bridge->SetPostPayload("text/plain", 2, " ");
304 295
305 int os_error = 0; 296 int os_error = 0;
306 int response_code = 0; 297 int response_code = 0;
307 298
308 bool success = http_bridge->MakeSynchronousPost(&os_error, &response_code); 299 bool success = http_bridge->MakeSynchronousPost(&os_error, &response_code);
309 ASSERT_TRUE(success); 300 ASSERT_TRUE(success);
310 http_bridge->Abort(); 301 http_bridge->Abort();
311 // Ensures no double-free of URLFetcher, etc. 302 // Ensures no double-free of URLFetcher, etc.
312 } 303 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698