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

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

Issue 2455343003: [Sync] Replaced ASSERT/EXPECT_TRUE/FALSE with expected/actual checks. (Closed)
Patch Set: \Updates for Max and rebase. Created 4 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
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 <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
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 << ".";
532 531
533 // Make sure the ProfileSyncService has been created before creating the 532 // Make sure the ProfileSyncService has been created before creating the
534 // ProfileSyncServiceHarness - some tests expect the ProfileSyncService to 533 // ProfileSyncServiceHarness - some tests expect the ProfileSyncService to
535 // already exist. 534 // already exist.
536 ProfileSyncService* profile_sync_service = 535 ProfileSyncService* profile_sync_service =
537 ProfileSyncServiceFactory::GetForProfile(GetProfile(index)); 536 ProfileSyncServiceFactory::GetForProfile(GetProfile(index));
538 537
539 if (server_type_ == IN_PROCESS_FAKE_SERVER) { 538 if (server_type_ == IN_PROCESS_FAKE_SERVER) {
540 // TODO(pvalenzuela): Run the fake server via EmbeddedTestServer. 539 // TODO(pvalenzuela): Run the fake server via EmbeddedTestServer.
541 profile_sync_service->OverrideNetworkResourcesForTest( 540 profile_sync_service->OverrideNetworkResourcesForTest(
542 base::WrapUnique<syncer::NetworkResources>( 541 base::WrapUnique<syncer::NetworkResources>(
543 new fake_server::FakeServerNetworkResources( 542 new fake_server::FakeServerNetworkResources(
544 fake_server_->AsWeakPtr()))); 543 fake_server_->AsWeakPtr())));
545 } 544 }
546 545
547 ProfileSyncServiceHarness::SigninType singin_type = UsingExternalServers() 546 ProfileSyncServiceHarness::SigninType singin_type = UsingExternalServers()
548 ? ProfileSyncServiceHarness::SigninType::UI_SIGNIN 547 ? ProfileSyncServiceHarness::SigninType::UI_SIGNIN
549 : ProfileSyncServiceHarness::SigninType::FAKE_SIGNIN; 548 : ProfileSyncServiceHarness::SigninType::FAKE_SIGNIN;
550 549
551 clients_[index] = 550 clients_[index] =
552 ProfileSyncServiceHarness::Create(GetProfile(index), 551 ProfileSyncServiceHarness::Create(GetProfile(index),
553 username_, 552 username_,
554 password_, 553 password_,
555 singin_type); 554 singin_type);
556 EXPECT_FALSE(GetClient(index) == nullptr) << "Could not create Client " 555 EXPECT_NE(nullptr, GetClient(index)) << "Could not create Client " << index;
557 << index << ".";
558 InitializeInvalidations(index); 556 InitializeInvalidations(index);
559 } 557 }
560 558
561 void SyncTest::InitializeInvalidations(int index) { 559 void SyncTest::InitializeInvalidations(int index) {
562 if (UsingExternalServers()) { 560 if (UsingExternalServers()) {
563 // DO NOTHING. External live sync servers use GCM to notify profiles of any 561 // 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 562 // invalidations in sync'ed data. In this case, to notify other profiles of
565 // invalidations, we use sync refresh notifications instead. 563 // invalidations, we use sync refresh notifications instead.
566 } else if (server_type_ == IN_PROCESS_FAKE_SERVER) { 564 } else if (server_type_ == IN_PROCESS_FAKE_SERVER) {
567 CHECK(fake_server_.get()); 565 CHECK(fake_server_.get());
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after
786 fake_factory_->SetFakeResponse( 784 fake_factory_->SetFakeResponse(
787 GaiaUrls::GetInstance()->oauth2_revoke_url(), 785 GaiaUrls::GetInstance()->oauth2_revoke_url(),
788 "", 786 "",
789 net::HTTP_OK, 787 net::HTTP_OK,
790 net::URLRequestStatus::SUCCESS); 788 net::URLRequestStatus::SUCCESS);
791 } 789 }
792 790
793 void SyncTest::SetOAuth2TokenResponse(const std::string& response_data, 791 void SyncTest::SetOAuth2TokenResponse(const std::string& response_data,
794 net::HttpStatusCode response_code, 792 net::HttpStatusCode response_code,
795 net::URLRequestStatus::Status status) { 793 net::URLRequestStatus::Status status) {
796 ASSERT_TRUE(nullptr != fake_factory_.get()); 794 ASSERT_NE(nullptr, fake_factory_.get());
797 fake_factory_->SetFakeResponse(GaiaUrls::GetInstance()->oauth2_token_url(), 795 fake_factory_->SetFakeResponse(GaiaUrls::GetInstance()->oauth2_token_url(),
798 response_data, response_code, status); 796 response_data, response_code, status);
799 } 797 }
800 798
801 void SyncTest::ClearMockGaiaResponses() { 799 void SyncTest::ClearMockGaiaResponses() {
802 // Clear any mock gaia responses that might have been set. 800 // Clear any mock gaia responses that might have been set.
803 if (fake_factory_) { 801 if (fake_factory_) {
804 fake_factory_->ClearFakeResponses(); 802 fake_factory_->ClearFakeResponses();
805 fake_factory_.reset(); 803 fake_factory_.reset();
806 } 804 }
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
926 options.start_hidden = true; 924 options.start_hidden = true;
927 #endif 925 #endif
928 test_server_ = base::LaunchProcess(server_cmdline, options); 926 test_server_ = base::LaunchProcess(server_cmdline, options);
929 if (!test_server_.IsValid()) 927 if (!test_server_.IsValid())
930 LOG(ERROR) << "Could not launch local test server."; 928 LOG(ERROR) << "Could not launch local test server.";
931 929
932 const base::TimeDelta kMaxWaitTime = TestTimeouts::action_max_timeout(); 930 const base::TimeDelta kMaxWaitTime = TestTimeouts::action_max_timeout();
933 const int kNumIntervals = 15; 931 const int kNumIntervals = 15;
934 if (WaitForTestServerToStart(kMaxWaitTime, kNumIntervals)) { 932 if (WaitForTestServerToStart(kMaxWaitTime, kNumIntervals)) {
935 DVLOG(1) << "Started local test server at " 933 DVLOG(1) << "Started local test server at "
936 << cl->GetSwitchValueASCII(switches::kSyncServiceURL) << "."; 934 << cl->GetSwitchValueASCII(switches::kSyncServiceURL);
937 return true; 935 return true;
938 } else { 936 } else {
939 LOG(ERROR) << "Could not start local test server at " 937 LOG(ERROR) << "Could not start local test server at "
940 << cl->GetSwitchValueASCII(switches::kSyncServiceURL) << "."; 938 << cl->GetSwitchValueASCII(switches::kSyncServiceURL);
941 return false; 939 return false;
942 } 940 }
943 } 941 }
944 942
945 bool SyncTest::TearDownLocalPythonTestServer() { 943 bool SyncTest::TearDownLocalPythonTestServer() {
946 if (!sync_server_.Stop()) { 944 if (!sync_server_.Stop()) {
947 LOG(ERROR) << "Could not stop local python test server."; 945 LOG(ERROR) << "Could not stop local python test server.";
948 return false; 946 return false;
949 } 947 }
950 xmpp_port_.reset(); 948 xmpp_port_.reset();
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
1128 1126
1129 void SyncTest::TriggerSyncForModelTypes(int index, 1127 void SyncTest::TriggerSyncForModelTypes(int index,
1130 syncer::ModelTypeSet model_types) { 1128 syncer::ModelTypeSet model_types) {
1131 GetSyncService(index)->TriggerRefresh(model_types); 1129 GetSyncService(index)->TriggerRefresh(model_types);
1132 } 1130 }
1133 1131
1134 void SyncTest::SetPreexistingPreferencesFileContents( 1132 void SyncTest::SetPreexistingPreferencesFileContents(
1135 const std::string& contents) { 1133 const std::string& contents) {
1136 preexisting_preferences_file_contents_ = contents; 1134 preexisting_preferences_file_contents_ = contents;
1137 } 1135 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698