| Index: chrome/browser/sync/test/integration/two_client_password_manager_setting_migrater_service_sync_test.cc
|
| diff --git a/chrome/browser/sync/test/integration/two_client_password_manager_setting_migrater_service_sync_test.cc b/chrome/browser/sync/test/integration/two_client_password_manager_setting_migrater_service_sync_test.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..75c68f948b5af23c1af460ff2dc6799448089234
|
| --- /dev/null
|
| +++ b/chrome/browser/sync/test/integration/two_client_password_manager_setting_migrater_service_sync_test.cc
|
| @@ -0,0 +1,152 @@
|
| +// 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/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/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 preferences_helper::AwaitBooleanPrefMatches;
|
| +using preferences_helper::BooleanPrefMatches;
|
| +using preferences_helper::ChangeBooleanPref;
|
| +using preferences_helper::GetPrefs;
|
| +
|
| +class TwoClientsPasswordManagerSettingMigraterServiceSyncTest
|
| + : public SyncTest {
|
| + public:
|
| + TwoClientsPasswordManagerSettingMigraterServiceSyncTest()
|
| + : SyncTest(TWO_CLIENT) {}
|
| +
|
| + bool SetupClients() override {
|
| + if (!SyncTest::SetupClients())
|
| + return false;
|
| + DisableVerifier();
|
| + return true;
|
| + }
|
| +
|
| + // Changes the |pref_name| preference value on the client with |index| and
|
| + // checks that the value is the same on both clients after the change.
|
| + void TestPrefChangeOnClient(int index, const char* pref_name) {
|
| + ASSERT_TRUE(AwaitBooleanPrefMatches(
|
| + password_manager::prefs::kPasswordManagerSavingEnabled));
|
| + ASSERT_TRUE(AwaitBooleanPrefMatches(
|
| + password_manager::prefs::kCredentialsEnableService));
|
| +
|
| + ChangeBooleanPref(index, pref_name);
|
| + // Check that changed pref is equals on both clients
|
| + ASSERT_TRUE(AwaitBooleanPrefMatches(pref_name));
|
| + ASSERT_TRUE(AwaitBooleanPrefMatches(
|
| + password_manager::prefs::kPasswordManagerSavingEnabled));
|
| + ASSERT_TRUE(AwaitBooleanPrefMatches(
|
| + password_manager::prefs::kCredentialsEnableService));
|
| + }
|
| +
|
| + ~TwoClientsPasswordManagerSettingMigraterServiceSyncTest() override {}
|
| +
|
| + void NotifyProfileAdded(int index) {
|
| + content::NotificationService::current()->Notify(
|
| + chrome::NOTIFICATION_PROFILE_ADDED,
|
| + content::Source<Profile>(GetProfile(index)),
|
| + content::NotificationService::NoDetails());
|
| + }
|
| +
|
| + void ExpectOnValueOnBothClientsForBothPreference() {
|
| + for (int i = 0; i < num_clients(); ++i) {
|
| + EXPECT_TRUE(GetPrefs(i)->GetBoolean(
|
| + password_manager::prefs::kCredentialsEnableService));
|
| + EXPECT_TRUE(GetPrefs(i)->GetBoolean(
|
| + password_manager::prefs::kPasswordManagerSavingEnabled));
|
| + }
|
| + }
|
| +
|
| + void ExpectOffValueOnBothClientsForBothPreference() {
|
| + for (int i = 0; i < num_clients(); ++i) {
|
| + EXPECT_FALSE(GetPrefs(i)->GetBoolean(
|
| + password_manager::prefs::kCredentialsEnableService));
|
| + EXPECT_FALSE(GetPrefs(i)->GetBoolean(
|
| + password_manager::prefs::kPasswordManagerSavingEnabled));
|
| + }
|
| + }
|
| +
|
| + Profile* profile() { return GetProfile(0); }
|
| + bool TestUsesSelfNotifications() override { return false; }
|
| +
|
| + private:
|
| + DISALLOW_COPY_AND_ASSIGN(
|
| + TwoClientsPasswordManagerSettingMigraterServiceSyncTest);
|
| +};
|
| +
|
| +IN_PROC_BROWSER_TEST_F(TwoClientsPasswordManagerSettingMigraterServiceSyncTest,
|
| + ChangeLegacyPrefTestBothClientsWithMigration) {
|
| + ASSERT_TRUE(SetupSync());
|
| + NotifyProfileAdded(0);
|
| + NotifyProfileAdded(1);
|
| + TestPrefChangeOnClient(
|
| + 1, password_manager::prefs::kPasswordManagerSavingEnabled);
|
| +}
|
| +
|
| +IN_PROC_BROWSER_TEST_F(TwoClientsPasswordManagerSettingMigraterServiceSyncTest,
|
| + ChangeNewPrefTestBothClientsWithMigration) {
|
| + ASSERT_TRUE(SetupSync());
|
| + NotifyProfileAdded(0);
|
| + NotifyProfileAdded(1);
|
| + TestPrefChangeOnClient(1, password_manager::prefs::kCredentialsEnableService);
|
| +}
|
| +
|
| +IN_PROC_BROWSER_TEST_F(
|
| + TwoClientsPasswordManagerSettingMigraterServiceSyncTest,
|
| + ChangeLegacyPrefOnMigratedClientOneClientsWithMigration) {
|
| + ASSERT_TRUE(SetupSync());
|
| + NotifyProfileAdded(0);
|
| + TestPrefChangeOnClient(
|
| + 0, password_manager::prefs::kPasswordManagerSavingEnabled);
|
| + ExpectOffValueOnBothClientsForBothPreference();
|
| +}
|
| +
|
| +IN_PROC_BROWSER_TEST_F(
|
| + TwoClientsPasswordManagerSettingMigraterServiceSyncTest,
|
| + ChangeLegacyPrefOnNonMigratedClientOneClientsWithMigration) {
|
| + ASSERT_TRUE(SetupSync());
|
| + NotifyProfileAdded(0);
|
| + TestPrefChangeOnClient(
|
| + 1, password_manager::prefs::kPasswordManagerSavingEnabled);
|
| + ExpectOffValueOnBothClientsForBothPreference();
|
| +}
|
| +
|
| +IN_PROC_BROWSER_TEST_F(TwoClientsPasswordManagerSettingMigraterServiceSyncTest,
|
| + ChangeNewPrefOnMigratedClientOneClientsWithMigration) {
|
| + ASSERT_TRUE(SetupSync());
|
| + NotifyProfileAdded(0);
|
| + TestPrefChangeOnClient(0, password_manager::prefs::kCredentialsEnableService);
|
| + ExpectOffValueOnBothClientsForBothPreference();
|
| +}
|
| +
|
| +IN_PROC_BROWSER_TEST_F(
|
| + TwoClientsPasswordManagerSettingMigraterServiceSyncTest,
|
| + ChangeNewPrefOnNonMigratedClientOneClientsWithMigration) {
|
| + ASSERT_TRUE(SetupSync());
|
| + NotifyProfileAdded(0);
|
| + TestPrefChangeOnClient(1, password_manager::prefs::kCredentialsEnableService);
|
| + ExpectOffValueOnBothClientsForBothPreference();
|
| +}
|
| +
|
| +IN_PROC_BROWSER_TEST_F(TwoClientsPasswordManagerSettingMigraterServiceSyncTest,
|
| + ChangeOnClientWithMigrationThenChangeOnClientWithout) {
|
| + ASSERT_TRUE(SetupSync());
|
| + NotifyProfileAdded(0);
|
| + TestPrefChangeOnClient(0, password_manager::prefs::kCredentialsEnableService);
|
| + ExpectOffValueOnBothClientsForBothPreference();
|
| + TestPrefChangeOnClient(1, password_manager::prefs::kCredentialsEnableService);
|
| + ExpectOnValueOnBothClientsForBothPreference();
|
| +}
|
|
|