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(
GetFakeServer());
EXPECT_TRUE(
PassphraseRequiredStateChecker(GetSyncService(1), /*desired_state=*/true)
PassphraseRequiredStateChecker(GetSyncService(0), /*desired_state=*/true)
.Wait());
EXPECT_TRUE(GetSyncService(1)->GetUserSettings()->SetDecryptionPassphrase(
EXPECT_TRUE(GetSyncService(0)->GetUserSettings()->SetDecryptionPassphrase(
kCustomPassphraseKeyParams.password));
EXPECT_TRUE(
PassphraseRequiredStateChecker(GetSyncService(1), /*desired_state=*/false)
PassphraseRequiredStateChecker(GetSyncService(0), /*desired_state=*/false)
.Wait());
// Ensure that client can decrypt with both |kTrustedVaultKeyParams|
......
......@@ -490,12 +490,12 @@ Profile* SyncTest::MakeTestProfile(base::FilePath profile_path, int index) {
}
Profile* SyncTest::GetProfile(int index) {
EXPECT_FALSE(profiles_.empty()) << "SetupClients() has not yet been called.";
EXPECT_FALSE(index < 0 || index >= static_cast<int>(profiles_.size()))
<< "GetProfile(): Index is out of bounds.";
DCHECK(!profiles_.empty()) << "SetupClients() has not yet been called.";
DCHECK(index >= 0 && index < static_cast<int>(profiles_.size()))
<< "GetProfile(): Index is out of bounds: " << 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;
}
......@@ -513,12 +513,12 @@ std::vector<Profile*> SyncTest::GetAllProfiles() {
#if !defined(OS_ANDROID)
Browser* SyncTest::GetBrowser(int index) {
EXPECT_FALSE(browsers_.empty()) << "SetupClients() has not yet been called.";
EXPECT_FALSE(index < 0 || index >= static_cast<int>(browsers_.size()))
<< "GetBrowser(): Index is out of bounds.";
DCHECK(!browsers_.empty()) << "SetupClients() has not yet been called.";
DCHECK(index >= 0 && index < static_cast<int>(browsers_.size()))
<< "GetBrowser(): Index is out of bounds: " << index;
Browser* browser = browsers_[index];
EXPECT_NE(browser, nullptr);
DCHECK(browser);
return browsers_[index];
}
......@@ -527,6 +527,7 @@ Browser* SyncTest::AddBrowser(int profile_index) {
Profile* profile = GetProfile(profile_index);
browsers_.push_back(Browser::Create(Browser::CreateParams(profile, true)));
profiles_.push_back(profile);
DCHECK_EQ(browsers_.size(), profiles_.size());
return browsers_[browsers_.size() - 1];
}
......@@ -687,7 +688,8 @@ void SyncTest::InitializeProfile(int index, Profile* profile) {
SetUpInvalidations(index);
#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
// 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