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

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

Issue 37683004: GTTF: Make EmbeddedTestServer always use its own thread for IO (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: trybots Created 7 years, 2 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
« no previous file with comments | « no previous file | chrome/browser/extensions/api/streams_private/streams_private_apitest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/message_loop.h" 9 #include "base/message_loop/message_loop.h"
10 #include "base/strings/stringprintf.h" 10 #include "base/strings/stringprintf.h"
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 io_thread_(content::BrowserThread::IO), 71 io_thread_(content::BrowserThread::IO),
72 download_was_successful_(false) { 72 download_was_successful_(false) {
73 } 73 }
74 74
75 virtual void SetUp() OVERRIDE { 75 virtual void SetUp() OVERRIDE {
76 io_thread_.StartIOThread(); 76 io_thread_.StartIOThread();
77 request_context_getter_ = new net::TestURLRequestContextGetter( 77 request_context_getter_ = new net::TestURLRequestContextGetter(
78 content::BrowserThread::GetMessageLoopProxyForThread( 78 content::BrowserThread::GetMessageLoopProxyForThread(
79 content::BrowserThread::IO)); 79 content::BrowserThread::IO));
80 80
81 test_server_.reset( 81 test_server_.reset(new net::test_server::EmbeddedTestServer);
82 new net::test_server::EmbeddedTestServer(
83 content::BrowserThread::GetMessageLoopProxyForThread(
84 content::BrowserThread::IO)));
85 ASSERT_TRUE(test_server_->InitializeAndWaitUntilReady()); 82 ASSERT_TRUE(test_server_->InitializeAndWaitUntilReady());
86 test_server_->RegisterRequestHandler( 83 test_server_->RegisterRequestHandler(
87 base::Bind(&GDataContactsServiceTest::HandleDownloadRequest, 84 base::Bind(&GDataContactsServiceTest::HandleDownloadRequest,
88 base::Unretained(this))); 85 base::Unretained(this)));
89 service_.reset(new GDataContactsService(request_context_getter_.get(), 86 service_.reset(new GDataContactsService(request_context_getter_.get(),
90 new google_apis::DummyAuthService)); 87 new google_apis::DummyAuthService));
91 service_->set_rewrite_photo_url_callback_for_testing( 88 service_->set_rewrite_photo_url_callback_for_testing(
92 base::Bind(&GDataContactsServiceTest::RewritePhotoUrl, 89 base::Bind(&GDataContactsServiceTest::RewritePhotoUrl,
93 base::Unretained(this))); 90 base::Unretained(this)));
94 service_->set_groups_feed_url_for_testing( 91 service_->set_groups_feed_url_for_testing(
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 146 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
150 download_was_successful_ = false; 147 download_was_successful_ = false;
151 downloaded_contacts_.reset(new ScopedVector<contacts::Contact>()); 148 downloaded_contacts_.reset(new ScopedVector<contacts::Contact>());
152 base::MessageLoop::current()->Quit(); 149 base::MessageLoop::current()->Quit();
153 } 150 }
154 151
155 // Handles a request for downloading a file. Reads a requested file and 152 // Handles a request for downloading a file. Reads a requested file and
156 // returns the content. 153 // returns the content.
157 scoped_ptr<net::test_server::HttpResponse> HandleDownloadRequest( 154 scoped_ptr<net::test_server::HttpResponse> HandleDownloadRequest(
158 const net::test_server::HttpRequest& request) { 155 const net::test_server::HttpRequest& request) {
159 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
160 // Requested url must not contain a query string. 156 // Requested url must not contain a query string.
161 scoped_ptr<net::test_server::BasicHttpResponse> result = 157 scoped_ptr<net::test_server::BasicHttpResponse> result =
162 google_apis::test_util::CreateHttpResponseFromFile( 158 google_apis::test_util::CreateHttpResponseFromFile(
163 google_apis::test_util::GetTestFilePath( 159 google_apis::test_util::GetTestFilePath(
164 std::string("chromeos/gdata/contacts") + request.relative_url)); 160 std::string("chromeos/gdata/contacts") + request.relative_url));
165 return result.PassAs<net::test_server::HttpResponse>(); 161 return result.PassAs<net::test_server::HttpResponse>();
166 } 162 }
167 163
168 base::MessageLoopForUI message_loop_; 164 base::MessageLoopForUI message_loop_;
169 content::TestBrowserThread ui_thread_; 165 content::TestBrowserThread ui_thread_;
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
326 scoped_ptr<contacts::Contact> contact2(new contacts::Contact); 322 scoped_ptr<contacts::Contact> contact2(new contacts::Contact);
327 InitContact("http://example.com/2", "2012-06-21T16:20:13.208Z", 323 InitContact("http://example.com/2", "2012-06-21T16:20:13.208Z",
328 false, "Bob Smith", "Bob", "", "Smith", "", "", 324 false, "Bob Smith", "Bob", "", "Smith", "", "",
329 contact2.get()); 325 contact2.get());
330 EXPECT_EQ(contacts::test::VarContactsToString( 326 EXPECT_EQ(contacts::test::VarContactsToString(
331 2, contact1.get(), contact2.get()), 327 2, contact1.get(), contact2.get()),
332 contacts::test::ContactsToString(*contacts)); 328 contacts::test::ContactsToString(*contacts));
333 } 329 }
334 330
335 } // namespace contacts 331 } // namespace contacts
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/extensions/api/streams_private/streams_private_apitest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698