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

Side by Side Diff: chrome/browser/sync/test/integration/sync_test.cc

Issue 60923002: [sync] Allow FakeURLFetcher to return an arbitrary URLRequestStatus (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 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) 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/sync/test/integration/sync_test.h" 5 #include "chrome/browser/sync/test/integration/sync_test.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after
423 } 423 }
424 424
425 void SyncTest::SetupMockGaiaResponses() { 425 void SyncTest::SetupMockGaiaResponses() {
426 username_ = "user@gmail.com"; 426 username_ = "user@gmail.com";
427 password_ = "password"; 427 password_ = "password";
428 factory_.reset(new net::URLFetcherImplFactory()); 428 factory_.reset(new net::URLFetcherImplFactory());
429 fake_factory_.reset(new net::FakeURLFetcherFactory(factory_.get())); 429 fake_factory_.reset(new net::FakeURLFetcherFactory(factory_.get()));
430 fake_factory_->SetFakeResponse( 430 fake_factory_->SetFakeResponse(
431 GaiaUrls::GetInstance()->client_login_url(), 431 GaiaUrls::GetInstance()->client_login_url(),
432 "SID=sid\nLSID=lsid", 432 "SID=sid\nLSID=lsid",
433 net::HTTP_OK); 433 net::HTTP_OK,
434 net::URLRequestStatus::SUCCESS);
434 fake_factory_->SetFakeResponse( 435 fake_factory_->SetFakeResponse(
435 GaiaUrls::GetInstance()->get_user_info_url(), 436 GaiaUrls::GetInstance()->get_user_info_url(),
436 "email=user@gmail.com\ndisplayEmail=user@gmail.com", 437 "email=user@gmail.com\ndisplayEmail=user@gmail.com",
437 net::HTTP_OK); 438 net::HTTP_OK,
439 net::URLRequestStatus::SUCCESS);
438 fake_factory_->SetFakeResponse( 440 fake_factory_->SetFakeResponse(
439 GaiaUrls::GetInstance()->issue_auth_token_url(), 441 GaiaUrls::GetInstance()->issue_auth_token_url(),
440 "auth", 442 "auth",
441 net::HTTP_OK); 443 net::HTTP_OK,
444 net::URLRequestStatus::SUCCESS);
442 fake_factory_->SetFakeResponse( 445 fake_factory_->SetFakeResponse(
443 GURL(GoogleURLTracker::kSearchDomainCheckURL), 446 GURL(GoogleURLTracker::kSearchDomainCheckURL),
444 ".google.com", 447 ".google.com",
445 net::HTTP_OK); 448 net::HTTP_OK,
449 net::URLRequestStatus::SUCCESS);
446 fake_factory_->SetFakeResponse( 450 fake_factory_->SetFakeResponse(
447 GaiaUrls::GetInstance()->client_login_to_oauth2_url(), 451 GaiaUrls::GetInstance()->client_login_to_oauth2_url(),
448 "some_response", 452 "some_response",
449 net::HTTP_OK); 453 net::HTTP_OK,
454 net::URLRequestStatus::SUCCESS);
450 fake_factory_->SetFakeResponse( 455 fake_factory_->SetFakeResponse(
451 GaiaUrls::GetInstance()->oauth2_token_url(), 456 GaiaUrls::GetInstance()->oauth2_token_url(),
452 "{" 457 "{"
453 " \"refresh_token\": \"rt1\"," 458 " \"refresh_token\": \"rt1\","
454 " \"access_token\": \"at1\"," 459 " \"access_token\": \"at1\","
455 " \"expires_in\": 3600," 460 " \"expires_in\": 3600,"
456 " \"token_type\": \"Bearer\"" 461 " \"token_type\": \"Bearer\""
457 "}", 462 "}",
458 net::HTTP_OK); 463 net::HTTP_OK,
464 net::URLRequestStatus::SUCCESS);
459 fake_factory_->SetFakeResponse( 465 fake_factory_->SetFakeResponse(
460 GaiaUrls::GetInstance()->oauth1_login_url(), 466 GaiaUrls::GetInstance()->oauth1_login_url(),
461 "SID=sid\nLSID=lsid\nAuth=auth_token", 467 "SID=sid\nLSID=lsid\nAuth=auth_token",
462 net::HTTP_OK); 468 net::HTTP_OK,
469 net::URLRequestStatus::SUCCESS);
463 } 470 }
464 471
465 void SyncTest::ClearMockGaiaResponses() { 472 void SyncTest::ClearMockGaiaResponses() {
466 // Clear any mock gaia responses that might have been set. 473 // Clear any mock gaia responses that might have been set.
467 if (fake_factory_) { 474 if (fake_factory_) {
468 fake_factory_->ClearFakeResponses(); 475 fake_factory_->ClearFakeResponses();
469 fake_factory_.reset(); 476 fake_factory_.reset();
470 } 477 }
471 478
472 // Cancel any outstanding URL fetches and destroy the URLFetcherImplFactory we 479 // Cancel any outstanding URL fetches and destroy the URLFetcherImplFactory we
(...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after
831 838
832 void SyncTest::SetProxyConfig(net::URLRequestContextGetter* context_getter, 839 void SyncTest::SetProxyConfig(net::URLRequestContextGetter* context_getter,
833 const net::ProxyConfig& proxy_config) { 840 const net::ProxyConfig& proxy_config) {
834 base::WaitableEvent done(false, false); 841 base::WaitableEvent done(false, false);
835 BrowserThread::PostTask( 842 BrowserThread::PostTask(
836 BrowserThread::IO, FROM_HERE, 843 BrowserThread::IO, FROM_HERE,
837 base::Bind(&SetProxyConfigCallback, &done, 844 base::Bind(&SetProxyConfigCallback, &done,
838 make_scoped_refptr(context_getter), proxy_config)); 845 make_scoped_refptr(context_getter), proxy_config));
839 done.Wait(); 846 done.Wait();
840 } 847 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698