Commit a3003e11 authored by Rushan Suleymanov's avatar Rushan Suleymanov Committed by Commit Bot

[Sync] Keep profiles and browsers synced in integration tests

This change guarantees that each browser has appropriate profile with
the same index in SyncTest.

Bug: None.
Change-Id: I5acbacf2b0c4e6b609ce6861f634e31709bcc076
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2519451Reviewed-by: default avatarMaksim Moskvitin <mmoskvitin@google.com>
Commit-Queue: Rushan Suleymanov <rushans@google.com>
Cr-Commit-Position: refs/heads/master@{#824086}
parent 978c29aa
...@@ -780,12 +780,12 @@ IN_PROC_BROWSER_TEST_F( ...@@ -780,12 +780,12 @@ IN_PROC_BROWSER_TEST_F(
GetFakeServer()); GetFakeServer());
EXPECT_TRUE( EXPECT_TRUE(
PassphraseRequiredStateChecker(GetSyncService(1), /*desired_state=*/true) PassphraseRequiredStateChecker(GetSyncService(0), /*desired_state=*/true)
.Wait()); .Wait());
EXPECT_TRUE(GetSyncService(1)->GetUserSettings()->SetDecryptionPassphrase( EXPECT_TRUE(GetSyncService(0)->GetUserSettings()->SetDecryptionPassphrase(
kCustomPassphraseKeyParams.password)); kCustomPassphraseKeyParams.password));
EXPECT_TRUE( EXPECT_TRUE(
PassphraseRequiredStateChecker(GetSyncService(1), /*desired_state=*/false) PassphraseRequiredStateChecker(GetSyncService(0), /*desired_state=*/false)
.Wait()); .Wait());
// Ensure that client can decrypt with both |kTrustedVaultKeyParams| // Ensure that client can decrypt with both |kTrustedVaultKeyParams|
......
...@@ -490,12 +490,12 @@ Profile* SyncTest::MakeTestProfile(base::FilePath profile_path, int index) { ...@@ -490,12 +490,12 @@ Profile* SyncTest::MakeTestProfile(base::FilePath profile_path, int index) {
} }
Profile* SyncTest::GetProfile(int index) { Profile* SyncTest::GetProfile(int index) {
EXPECT_FALSE(profiles_.empty()) << "SetupClients() has not yet been called."; DCHECK(!profiles_.empty()) << "SetupClients() has not yet been called.";
EXPECT_FALSE(index < 0 || index >= static_cast<int>(profiles_.size())) DCHECK(index >= 0 && index < static_cast<int>(profiles_.size()))
<< "GetProfile(): Index is out of bounds."; << "GetProfile(): Index is out of bounds: " << index;
Profile* profile = profiles_[index]; Profile* profile = profiles_[index];
EXPECT_NE(nullptr, profile) << "No profile found at index: " << index; DCHECK(profile) << "No profile found at index: " << index;
return profile; return profile;
} }
...@@ -513,12 +513,12 @@ std::vector<Profile*> SyncTest::GetAllProfiles() { ...@@ -513,12 +513,12 @@ std::vector<Profile*> SyncTest::GetAllProfiles() {
#if !defined(OS_ANDROID) #if !defined(OS_ANDROID)
Browser* SyncTest::GetBrowser(int index) { Browser* SyncTest::GetBrowser(int index) {
EXPECT_FALSE(browsers_.empty()) << "SetupClients() has not yet been called."; DCHECK(!browsers_.empty()) << "SetupClients() has not yet been called.";
EXPECT_FALSE(index < 0 || index >= static_cast<int>(browsers_.size())) DCHECK(index >= 0 && index < static_cast<int>(browsers_.size()))
<< "GetBrowser(): Index is out of bounds."; << "GetBrowser(): Index is out of bounds: " << index;
Browser* browser = browsers_[index]; Browser* browser = browsers_[index];
EXPECT_NE(browser, nullptr); DCHECK(browser);
return browsers_[index]; return browsers_[index];
} }
...@@ -527,6 +527,7 @@ Browser* SyncTest::AddBrowser(int profile_index) { ...@@ -527,6 +527,7 @@ Browser* SyncTest::AddBrowser(int profile_index) {
Profile* profile = GetProfile(profile_index); Profile* profile = GetProfile(profile_index);
browsers_.push_back(Browser::Create(Browser::CreateParams(profile, true))); browsers_.push_back(Browser::Create(Browser::CreateParams(profile, true)));
profiles_.push_back(profile); profiles_.push_back(profile);
DCHECK_EQ(browsers_.size(), profiles_.size());
return browsers_[browsers_.size() - 1]; return browsers_[browsers_.size() - 1];
} }
...@@ -687,7 +688,8 @@ void SyncTest::InitializeProfile(int index, Profile* profile) { ...@@ -687,7 +688,8 @@ void SyncTest::InitializeProfile(int index, Profile* profile) {
SetUpInvalidations(index); SetUpInvalidations(index);
#if !defined(OS_ANDROID) #if !defined(OS_ANDROID)
AddBrowser(index); browsers_.push_back(Browser::Create(Browser::CreateParams(profile, true)));
DCHECK_EQ(static_cast<size_t>(index), browsers_.size() - 1);
#endif #endif
// Make sure the ProfileSyncService has been created before creating the // Make sure the ProfileSyncService has been created before creating the
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment