| Index: chrome/browser/sync/test/integration/multiple_client_password_manager_setting_migrater_service_sync_test.cc
|
| diff --git a/chrome/browser/sync/test/integration/multiple_client_password_manager_setting_migrater_service_sync_test.cc b/chrome/browser/sync/test/integration/multiple_client_password_manager_setting_migrater_service_sync_test.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..1160efec83294bf47e49cf07a947ff73131e8800
|
| --- /dev/null
|
| +++ b/chrome/browser/sync/test/integration/multiple_client_password_manager_setting_migrater_service_sync_test.cc
|
| @@ -0,0 +1,97 @@
|
| +// Copyright (c) 2015 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#include "base/metrics/field_trial.h"
|
| +#include "base/prefs/pref_service.h"
|
| +#include "chrome/browser/chrome_notification_types.h"
|
| +#include "chrome/browser/password_manager/password_manager_setting_migrater_service.h"
|
| +#include "chrome/browser/prefs/pref_service_syncable.h"
|
| +#include "chrome/browser/sync/test/integration/password_manager_setting_migrater_helper.h"
|
| +#include "chrome/browser/sync/test/integration/preferences_helper.h"
|
| +#include "chrome/browser/sync/test/integration/profile_sync_service_harness.h"
|
| +#include "chrome/browser/sync/test/integration/sync_integration_test_util.h"
|
| +#include "chrome/browser/sync/test/integration/sync_test.h"
|
| +#include "chrome/common/pref_names.h"
|
| +#include "components/password_manager/core/common/password_manager_pref_names.h"
|
| +#include "content/public/browser/notification_details.h"
|
| +#include "content/public/browser/notification_service.h"
|
| +#include "content/public/browser/notification_source.h"
|
| +#include "content/public/test/test_browser_thread_bundle.h"
|
| +
|
| +using password_manager_setting_migrater_helper::AssertPrefValuesOnClient;
|
| +using preferences_helper::AwaitBooleanPrefMatches;
|
| +using preferences_helper::BooleanPrefMatches;
|
| +using preferences_helper::ChangeBooleanPref;
|
| +using preferences_helper::GetPrefs;
|
| +
|
| +class MultipleClientPasswordManagerSettingMigraterServiceSyncTest
|
| + : public SyncTest {
|
| + public:
|
| + MultipleClientPasswordManagerSettingMigraterServiceSyncTest()
|
| + : SyncTest(MULTIPLE_CLIENT) {}
|
| + ~MultipleClientPasswordManagerSettingMigraterServiceSyncTest() override {}
|
| +
|
| + bool SetupClients() override {
|
| + if (!SyncTest::SetupClients())
|
| + return false;
|
| + DisableVerifier();
|
| + return true;
|
| + }
|
| +
|
| + void EnsureMigrationStartsForClient(int index) {
|
| + trial_ = password_manager_setting_migrater_helper::MigrationFieldTrial();
|
| + password_manager_setting_migrater_helper::SendProfileAddNotification(
|
| + GetProfile(index));
|
| + }
|
| +
|
| + bool TestUsesSelfNotifications() override { return false; }
|
| +
|
| + private:
|
| + scoped_refptr<base::FieldTrial> trial_;
|
| +
|
| + DISALLOW_COPY_AND_ASSIGN(
|
| + MultipleClientPasswordManagerSettingMigraterServiceSyncTest);
|
| +};
|
| +
|
| +IN_PROC_BROWSER_TEST_F(
|
| + MultipleClientPasswordManagerSettingMigraterServiceSyncTest,
|
| + TwoClientsWithMigrationOneClientWithoutChangeFromOnToOff) {
|
| + DisableVerifier();
|
| + ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
|
| + EnsureMigrationStartsForClient(0);
|
| + EnsureMigrationStartsForClient(1);
|
| + ASSERT_TRUE(AwaitBooleanPrefMatches(
|
| + password_manager::prefs::kPasswordManagerSavingEnabled));
|
| + // Client without migration changes the legacy pref.
|
| + ChangeBooleanPref(2, password_manager::prefs::kPasswordManagerSavingEnabled);
|
| + ASSERT_TRUE(AwaitBooleanPrefMatches(
|
| + password_manager::prefs::kPasswordManagerSavingEnabled));
|
| + ASSERT_TRUE(AwaitBooleanPrefMatches(
|
| + password_manager::prefs::kPasswordManagerSavingEnabled));
|
| + // Check that new and legacy preferences have correct value on client with
|
| + // migration.
|
| + for (int i = 0; i < num_clients() - 1; ++i) {
|
| + AssertPrefValuesOnClient(i, false, false);
|
| + }
|
| +}
|
| +
|
| +IN_PROC_BROWSER_TEST_F(
|
| + MultipleClientPasswordManagerSettingMigraterServiceSyncTest,
|
| + TwoClientsWithMigrationOneClientWithoutChangeFromOffToOn) {
|
| + DisableVerifier();
|
| + ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
|
| + EnsureMigrationStartsForClient(0);
|
| + EnsureMigrationStartsForClient(1);
|
| + ASSERT_TRUE(AwaitBooleanPrefMatches(
|
| + password_manager::prefs::kPasswordManagerSavingEnabled));
|
| + ChangeBooleanPref(0, password_manager::prefs::kPasswordManagerSavingEnabled);
|
| + ASSERT_TRUE(AwaitBooleanPrefMatches(
|
| + password_manager::prefs::kPasswordManagerSavingEnabled));
|
| + ChangeBooleanPref(0, password_manager::prefs::kPasswordManagerSavingEnabled);
|
| + ASSERT_TRUE(AwaitBooleanPrefMatches(
|
| + password_manager::prefs::kPasswordManagerSavingEnabled));
|
| + for (int i = 0; i < num_clients() - 1; ++i) {
|
| + AssertPrefValuesOnClient(i, true, true);
|
| + }
|
| +}
|
|
|