Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <limits> | 10 #include <limits> |
| (...skipping 509 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 520 return true; | 520 return true; |
| 521 } | 521 } |
| 522 | 522 |
| 523 void SyncTest::InitializeProfile(int index, Profile* profile) { | 523 void SyncTest::InitializeProfile(int index, Profile* profile) { |
| 524 DCHECK(profile); | 524 DCHECK(profile); |
| 525 profiles_[index] = profile; | 525 profiles_[index] = profile; |
| 526 | 526 |
| 527 // CheckInitialState() assumes that no windows are open at startup. | 527 // CheckInitialState() assumes that no windows are open at startup. |
| 528 browsers_[index] = new Browser(Browser::CreateParams(GetProfile(index))); | 528 browsers_[index] = new Browser(Browser::CreateParams(GetProfile(index))); |
| 529 | 529 |
| 530 EXPECT_FALSE(GetBrowser(index) == nullptr) << "Could not create Browser " | 530 EXPECT_NE(nullptr, GetBrowser(index)) << "Could not create Browser " << index |
| 531 << index << "."; | 531 << "."; |
|
maxbogue
2016/10/28 23:31:00
Don't need no stinkin' .'s round these parts (and
skym
2016/10/31 15:08:18
Removed all << "." from this file. This fits on on
| |
| 532 | 532 |
| 533 // Make sure the ProfileSyncService has been created before creating the | 533 // Make sure the ProfileSyncService has been created before creating the |
| 534 // ProfileSyncServiceHarness - some tests expect the ProfileSyncService to | 534 // ProfileSyncServiceHarness - some tests expect the ProfileSyncService to |
| 535 // already exist. | 535 // already exist. |
| 536 ProfileSyncService* profile_sync_service = | 536 ProfileSyncService* profile_sync_service = |
| 537 ProfileSyncServiceFactory::GetForProfile(GetProfile(index)); | 537 ProfileSyncServiceFactory::GetForProfile(GetProfile(index)); |
| 538 | 538 |
| 539 if (server_type_ == IN_PROCESS_FAKE_SERVER) { | 539 if (server_type_ == IN_PROCESS_FAKE_SERVER) { |
| 540 // TODO(pvalenzuela): Run the fake server via EmbeddedTestServer. | 540 // TODO(pvalenzuela): Run the fake server via EmbeddedTestServer. |
| 541 profile_sync_service->OverrideNetworkResourcesForTest( | 541 profile_sync_service->OverrideNetworkResourcesForTest( |
| 542 base::WrapUnique<syncer::NetworkResources>( | 542 base::WrapUnique<syncer::NetworkResources>( |
| 543 new fake_server::FakeServerNetworkResources( | 543 new fake_server::FakeServerNetworkResources( |
| 544 fake_server_->AsWeakPtr()))); | 544 fake_server_->AsWeakPtr()))); |
| 545 } | 545 } |
| 546 | 546 |
| 547 ProfileSyncServiceHarness::SigninType singin_type = UsingExternalServers() | 547 ProfileSyncServiceHarness::SigninType singin_type = UsingExternalServers() |
| 548 ? ProfileSyncServiceHarness::SigninType::UI_SIGNIN | 548 ? ProfileSyncServiceHarness::SigninType::UI_SIGNIN |
| 549 : ProfileSyncServiceHarness::SigninType::FAKE_SIGNIN; | 549 : ProfileSyncServiceHarness::SigninType::FAKE_SIGNIN; |
| 550 | 550 |
| 551 clients_[index] = | 551 clients_[index] = |
| 552 ProfileSyncServiceHarness::Create(GetProfile(index), | 552 ProfileSyncServiceHarness::Create(GetProfile(index), |
| 553 username_, | 553 username_, |
| 554 password_, | 554 password_, |
| 555 singin_type); | 555 singin_type); |
| 556 EXPECT_FALSE(GetClient(index) == nullptr) << "Could not create Client " | 556 EXPECT_NE(nullptr, GetClient(index)) << "Could not create Client " << index |
| 557 << index << "."; | 557 << "."; |
|
maxbogue
2016/10/28 23:31:00
psh
skym
2016/10/31 15:08:18
Done.
| |
| 558 InitializeInvalidations(index); | 558 InitializeInvalidations(index); |
| 559 } | 559 } |
| 560 | 560 |
| 561 void SyncTest::InitializeInvalidations(int index) { | 561 void SyncTest::InitializeInvalidations(int index) { |
| 562 if (UsingExternalServers()) { | 562 if (UsingExternalServers()) { |
| 563 // DO NOTHING. External live sync servers use GCM to notify profiles of any | 563 // DO NOTHING. External live sync servers use GCM to notify profiles of any |
| 564 // invalidations in sync'ed data. In this case, to notify other profiles of | 564 // invalidations in sync'ed data. In this case, to notify other profiles of |
| 565 // invalidations, we use sync refresh notifications instead. | 565 // invalidations, we use sync refresh notifications instead. |
| 566 } else if (server_type_ == IN_PROCESS_FAKE_SERVER) { | 566 } else if (server_type_ == IN_PROCESS_FAKE_SERVER) { |
| 567 CHECK(fake_server_.get()); | 567 CHECK(fake_server_.get()); |
| (...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 786 fake_factory_->SetFakeResponse( | 786 fake_factory_->SetFakeResponse( |
| 787 GaiaUrls::GetInstance()->oauth2_revoke_url(), | 787 GaiaUrls::GetInstance()->oauth2_revoke_url(), |
| 788 "", | 788 "", |
| 789 net::HTTP_OK, | 789 net::HTTP_OK, |
| 790 net::URLRequestStatus::SUCCESS); | 790 net::URLRequestStatus::SUCCESS); |
| 791 } | 791 } |
| 792 | 792 |
| 793 void SyncTest::SetOAuth2TokenResponse(const std::string& response_data, | 793 void SyncTest::SetOAuth2TokenResponse(const std::string& response_data, |
| 794 net::HttpStatusCode response_code, | 794 net::HttpStatusCode response_code, |
| 795 net::URLRequestStatus::Status status) { | 795 net::URLRequestStatus::Status status) { |
| 796 ASSERT_TRUE(nullptr != fake_factory_.get()); | 796 ASSERT_NE(nullptr, fake_factory_.get()); |
| 797 fake_factory_->SetFakeResponse(GaiaUrls::GetInstance()->oauth2_token_url(), | 797 fake_factory_->SetFakeResponse(GaiaUrls::GetInstance()->oauth2_token_url(), |
| 798 response_data, response_code, status); | 798 response_data, response_code, status); |
| 799 } | 799 } |
| 800 | 800 |
| 801 void SyncTest::ClearMockGaiaResponses() { | 801 void SyncTest::ClearMockGaiaResponses() { |
| 802 // Clear any mock gaia responses that might have been set. | 802 // Clear any mock gaia responses that might have been set. |
| 803 if (fake_factory_) { | 803 if (fake_factory_) { |
| 804 fake_factory_->ClearFakeResponses(); | 804 fake_factory_->ClearFakeResponses(); |
| 805 fake_factory_.reset(); | 805 fake_factory_.reset(); |
| 806 } | 806 } |
| (...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1128 | 1128 |
| 1129 void SyncTest::TriggerSyncForModelTypes(int index, | 1129 void SyncTest::TriggerSyncForModelTypes(int index, |
| 1130 syncer::ModelTypeSet model_types) { | 1130 syncer::ModelTypeSet model_types) { |
| 1131 GetSyncService(index)->TriggerRefresh(model_types); | 1131 GetSyncService(index)->TriggerRefresh(model_types); |
| 1132 } | 1132 } |
| 1133 | 1133 |
| 1134 void SyncTest::SetPreexistingPreferencesFileContents( | 1134 void SyncTest::SetPreexistingPreferencesFileContents( |
| 1135 const std::string& contents) { | 1135 const std::string& contents) { |
| 1136 preexisting_preferences_file_contents_ = contents; | 1136 preexisting_preferences_file_contents_ = contents; |
| 1137 } | 1137 } |
| OLD | NEW |