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

Side by Side Diff: chrome/browser/chromeos/contacts/gdata_contacts_service_unittest.cc

Issue 14113053: chrome: Use base::MessageLoop. (Part 3) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase again Created 7 years, 6 months 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) 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 "chrome/browser/chromeos/contacts/gdata_contacts_service.h" 5 #include "chrome/browser/chromeos/contacts/gdata_contacts_service.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/files/file_path.h" 8 #include "base/files/file_path.h"
9 #include "base/message_loop.h" 9 #include "base/message_loop.h"
10 #include "base/stringprintf.h" 10 #include "base/stringprintf.h"
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 // at a file on |test_server_|. 143 // at a file on |test_server_|.
144 std::string RewritePhotoUrl(const std::string& original_url) { 144 std::string RewritePhotoUrl(const std::string& original_url) {
145 return test_server_->GetURL(GURL(original_url).path()).spec(); 145 return test_server_->GetURL(GURL(original_url).path()).spec();
146 } 146 }
147 147
148 // Handles success for Download(). 148 // Handles success for Download().
149 void OnSuccess(scoped_ptr<ScopedVector<contacts::Contact> > contacts) { 149 void OnSuccess(scoped_ptr<ScopedVector<contacts::Contact> > contacts) {
150 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 150 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
151 download_was_successful_ = true; 151 download_was_successful_ = true;
152 downloaded_contacts_.swap(contacts); 152 downloaded_contacts_.swap(contacts);
153 MessageLoop::current()->Quit(); 153 base::MessageLoop::current()->Quit();
154 } 154 }
155 155
156 // Handles failure for Download(). 156 // Handles failure for Download().
157 void OnFailure() { 157 void OnFailure() {
158 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 158 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
159 download_was_successful_ = false; 159 download_was_successful_ = false;
160 downloaded_contacts_.reset(new ScopedVector<contacts::Contact>()); 160 downloaded_contacts_.reset(new ScopedVector<contacts::Contact>());
161 MessageLoop::current()->Quit(); 161 base::MessageLoop::current()->Quit();
162 } 162 }
163 163
164 // Handles a request for downloading a file. Reads a requested file and 164 // Handles a request for downloading a file. Reads a requested file and
165 // returns the content. 165 // returns the content.
166 scoped_ptr<net::test_server::HttpResponse> HandleDownloadRequest( 166 scoped_ptr<net::test_server::HttpResponse> HandleDownloadRequest(
167 const net::test_server::HttpRequest& request) { 167 const net::test_server::HttpRequest& request) {
168 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 168 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
169 // Requested url must not contain a query string. 169 // Requested url must not contain a query string.
170 scoped_ptr<net::test_server::BasicHttpResponse> result = 170 scoped_ptr<net::test_server::BasicHttpResponse> result =
171 google_apis::test_util::CreateHttpResponseFromFile( 171 google_apis::test_util::CreateHttpResponseFromFile(
172 google_apis::test_util::GetTestFilePath( 172 google_apis::test_util::GetTestFilePath(
173 std::string("chromeos/gdata/contacts") + request.relative_url)); 173 std::string("chromeos/gdata/contacts") + request.relative_url));
174 return result.PassAs<net::test_server::HttpResponse>(); 174 return result.PassAs<net::test_server::HttpResponse>();
175 } 175 }
176 176
177 MessageLoopForUI message_loop_; 177 base::MessageLoopForUI message_loop_;
178 content::TestBrowserThread ui_thread_; 178 content::TestBrowserThread ui_thread_;
179 content::TestBrowserThread io_thread_; 179 content::TestBrowserThread io_thread_;
180 scoped_ptr<TestingProfile> profile_; 180 scoped_ptr<TestingProfile> profile_;
181 scoped_refptr<net::TestURLRequestContextGetter> request_context_getter_; 181 scoped_refptr<net::TestURLRequestContextGetter> request_context_getter_;
182 182
183 // Was the last download successful? Used to pass the result back from 183 // Was the last download successful? Used to pass the result back from
184 // OnSuccess() and OnFailure() to Download(). 184 // OnSuccess() and OnFailure() to Download().
185 bool download_was_successful_; 185 bool download_was_successful_;
186 186
187 // Used to pass downloaded contacts back to Download(). 187 // Used to pass downloaded contacts back to Download().
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
336 scoped_ptr<contacts::Contact> contact2(new contacts::Contact); 336 scoped_ptr<contacts::Contact> contact2(new contacts::Contact);
337 InitContact("http://example.com/2", "2012-06-21T16:20:13.208Z", 337 InitContact("http://example.com/2", "2012-06-21T16:20:13.208Z",
338 false, "Bob Smith", "Bob", "", "Smith", "", "", 338 false, "Bob Smith", "Bob", "", "Smith", "", "",
339 contact2.get()); 339 contact2.get());
340 EXPECT_EQ(contacts::test::VarContactsToString( 340 EXPECT_EQ(contacts::test::VarContactsToString(
341 2, contact1.get(), contact2.get()), 341 2, contact1.get(), contact2.get()),
342 contacts::test::ContactsToString(*contacts)); 342 contacts::test::ContactsToString(*contacts));
343 } 343 }
344 344
345 } // namespace contacts 345 } // namespace contacts
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698