| Index: chrome/test/live_sync/preferences_helper.cc
|
| diff --git a/chrome/test/live_sync/live_preferences_sync_test.cc b/chrome/test/live_sync/preferences_helper.cc
|
| similarity index 52%
|
| rename from chrome/test/live_sync/live_preferences_sync_test.cc
|
| rename to chrome/test/live_sync/preferences_helper.cc
|
| index 5a00cd5f0c9d7e7fcbb07db1b4de1786c7098778..7934830e9e60a1bab13ca6ad5f50dda500d34639 100644
|
| --- a/chrome/test/live_sync/live_preferences_sync_test.cc
|
| +++ b/chrome/test/live_sync/preferences_helper.cc
|
| @@ -2,79 +2,86 @@
|
| // Use of this source code is governed by a BSD-style license that can be
|
| // found in the LICENSE file.
|
|
|
| -#include "chrome/test/live_sync/live_preferences_sync_test.h"
|
| +#include "chrome/test/live_sync/preferences_helper.h"
|
|
|
| #include "base/values.h"
|
| #include "chrome/browser/prefs/pref_service.h"
|
| #include "chrome/browser/prefs/scoped_user_pref_update.h"
|
| #include "chrome/browser/profiles/profile.h"
|
| #include "chrome/browser/sync/profile_sync_service_harness.h"
|
| +#include "chrome/test/live_sync/live_sync_test.h"
|
|
|
| -LivePreferencesSyncTest::LivePreferencesSyncTest(TestType test_type)
|
| - : LiveSyncTest(test_type),
|
| - use_verifier_prefs_(true) {}
|
| +PreferencesHelper::PreferencesHelper() {}
|
|
|
| -LivePreferencesSyncTest::~LivePreferencesSyncTest() {}
|
| +PreferencesHelper::~PreferencesHelper() {}
|
|
|
| -PrefService* LivePreferencesSyncTest::GetPrefs(int index) {
|
| - return GetProfile(index)->GetPrefs();
|
| +// static
|
| +PrefService* PreferencesHelper::GetPrefs(int index) {
|
| + return test()->GetProfile(index)->GetPrefs();
|
| }
|
|
|
| -PrefService* LivePreferencesSyncTest::GetVerifierPrefs() {
|
| - return verifier()->GetPrefs();
|
| +// static
|
| +PrefService* PreferencesHelper::GetVerifierPrefs() {
|
| + return test()->verifier()->GetPrefs();
|
| }
|
|
|
| -void LivePreferencesSyncTest::ChangeBooleanPref(int index,
|
| - const char* pref_name) {
|
| +// static
|
| +void PreferencesHelper::ChangeBooleanPref(int index, const char* pref_name) {
|
| bool new_value = !GetPrefs(index)->GetBoolean(pref_name);
|
| GetPrefs(index)->SetBoolean(pref_name, new_value);
|
| - if (use_verifier_prefs_)
|
| + if (test()->use_verifier())
|
| GetVerifierPrefs()->SetBoolean(pref_name, new_value);
|
| }
|
|
|
| -void LivePreferencesSyncTest::ChangeIntegerPref(int index,
|
| - const char* pref_name,
|
| - int new_value) {
|
| +// static
|
| +void PreferencesHelper::ChangeIntegerPref(int index,
|
| + const char* pref_name,
|
| + int new_value) {
|
| GetPrefs(index)->SetInteger(pref_name, new_value);
|
| - if (use_verifier_prefs_)
|
| + if (test()->use_verifier())
|
| GetVerifierPrefs()->SetInteger(pref_name, new_value);
|
| }
|
|
|
| -void LivePreferencesSyncTest::ChangeDoublePref(int index,
|
| - const char* pref_name,
|
| - double new_value) {
|
| +// static
|
| +void PreferencesHelper::ChangeDoublePref(int index,
|
| + const char* pref_name,
|
| + double new_value) {
|
| GetPrefs(index)->SetDouble(pref_name, new_value);
|
| - if (use_verifier_prefs_)
|
| + if (test()->use_verifier())
|
| GetVerifierPrefs()->SetDouble(pref_name, new_value);
|
| }
|
|
|
| -void LivePreferencesSyncTest::ChangeStringPref(int index,
|
| - const char* pref_name,
|
| - const std::string& new_value) {
|
| +// static
|
| +void PreferencesHelper::ChangeStringPref(int index,
|
| + const char* pref_name,
|
| + const std::string& new_value) {
|
| GetPrefs(index)->SetString(pref_name, new_value);
|
| - if (use_verifier_prefs_)
|
| + if (test()->use_verifier())
|
| GetVerifierPrefs()->SetString(pref_name, new_value);
|
| }
|
|
|
| -void LivePreferencesSyncTest::AppendStringPref(
|
| - int index,
|
| - const char* pref_name,
|
| - const std::string& append_value) {
|
| - ChangeStringPref(index, pref_name,
|
| +// static
|
| +void PreferencesHelper::AppendStringPref(int index,
|
| + const char* pref_name,
|
| + const std::string& append_value) {
|
| + ChangeStringPref(index,
|
| + pref_name,
|
| GetPrefs(index)->GetString(pref_name) + append_value);
|
| }
|
|
|
| -void LivePreferencesSyncTest::ChangeFilePathPref(int index,
|
| - const char* pref_name,
|
| - const FilePath& new_value) {
|
| +// static
|
| +void PreferencesHelper::ChangeFilePathPref(int index,
|
| + const char* pref_name,
|
| + const FilePath& new_value) {
|
| GetPrefs(index)->SetFilePath(pref_name, new_value);
|
| - if (use_verifier_prefs_)
|
| + if (test()->use_verifier())
|
| GetVerifierPrefs()->SetFilePath(pref_name, new_value);
|
| }
|
|
|
| -void LivePreferencesSyncTest::ChangeListPref(int index,
|
| - const char* pref_name,
|
| - const ListValue& new_value) {
|
| +// static
|
| +void PreferencesHelper::ChangeListPref(int index,
|
| + const char* pref_name,
|
| + const ListValue& new_value) {
|
| {
|
| ListPrefUpdate update(GetPrefs(index), pref_name);
|
| ListValue* list = update.Get();
|
| @@ -85,7 +92,7 @@ void LivePreferencesSyncTest::ChangeListPref(int index,
|
| }
|
| }
|
|
|
| - if (use_verifier_prefs_) {
|
| + if (test()->use_verifier()) {
|
| ListPrefUpdate update_verifier(GetVerifierPrefs(), pref_name);
|
| ListValue* list_verifier = update_verifier.Get();
|
| for (ListValue::const_iterator it = new_value.begin();
|
| @@ -96,116 +103,121 @@ void LivePreferencesSyncTest::ChangeListPref(int index,
|
| }
|
| }
|
|
|
| -bool LivePreferencesSyncTest::BooleanPrefMatches(const char* pref_name) {
|
| +// static
|
| +bool PreferencesHelper::BooleanPrefMatches(const char* pref_name) {
|
| bool reference_value;
|
| - if (use_verifier_prefs_) {
|
| + if (test()->use_verifier()) {
|
| reference_value = GetVerifierPrefs()->GetBoolean(pref_name);
|
| } else {
|
| reference_value = GetPrefs(0)->GetBoolean(pref_name);
|
| }
|
| - for (int i = 0; i < num_clients(); ++i) {
|
| + for (int i = 0; i < test()->num_clients(); ++i) {
|
| if (reference_value != GetPrefs(i)->GetBoolean(pref_name)) {
|
| LOG(ERROR) << "Boolean preference " << pref_name << " mismatched in"
|
| - << "profile " << i << ".";
|
| + << " profile " << i << ".";
|
| return false;
|
| }
|
| }
|
| return true;
|
| }
|
|
|
| -bool LivePreferencesSyncTest::IntegerPrefMatches(const char* pref_name) {
|
| +// static
|
| +bool PreferencesHelper::IntegerPrefMatches(const char* pref_name) {
|
| int reference_value;
|
| - if (use_verifier_prefs_) {
|
| + if (test()->use_verifier()) {
|
| reference_value = GetVerifierPrefs()->GetInteger(pref_name);
|
| } else {
|
| reference_value = GetPrefs(0)->GetInteger(pref_name);
|
| }
|
| - for (int i = 0; i < num_clients(); ++i) {
|
| + for (int i = 0; i < test()->num_clients(); ++i) {
|
| if (reference_value != GetPrefs(i)->GetInteger(pref_name)) {
|
| LOG(ERROR) << "Integer preference " << pref_name << " mismatched in"
|
| - << "profile " << i << ".";
|
| + << " profile " << i << ".";
|
| return false;
|
| }
|
| }
|
| return true;
|
| }
|
|
|
| -bool LivePreferencesSyncTest::DoublePrefMatches(const char* pref_name) {
|
| +// static
|
| +bool PreferencesHelper::DoublePrefMatches(const char* pref_name) {
|
| double reference_value;
|
| - if (use_verifier_prefs_) {
|
| + if (test()->use_verifier()) {
|
| reference_value = GetVerifierPrefs()->GetDouble(pref_name);
|
| } else {
|
| reference_value = GetPrefs(0)->GetDouble(pref_name);
|
| }
|
| - for (int i = 0; i < num_clients(); ++i) {
|
| + for (int i = 0; i < test()->num_clients(); ++i) {
|
| if (reference_value != GetPrefs(i)->GetDouble(pref_name)) {
|
| LOG(ERROR) << "Double preference " << pref_name << " mismatched in"
|
| - << "profile " << i << ".";
|
| + << " profile " << i << ".";
|
| return false;
|
| }
|
| }
|
| return true;
|
| }
|
|
|
| -bool LivePreferencesSyncTest::StringPrefMatches(const char* pref_name) {
|
| +// static
|
| +bool PreferencesHelper::StringPrefMatches(const char* pref_name) {
|
| std::string reference_value;
|
| - if (use_verifier_prefs_) {
|
| + if (test()->use_verifier()) {
|
| reference_value = GetVerifierPrefs()->GetString(pref_name);
|
| } else {
|
| reference_value = GetPrefs(0)->GetString(pref_name);
|
| }
|
| - for (int i = 0; i < num_clients(); ++i) {
|
| + for (int i = 0; i < test()->num_clients(); ++i) {
|
| if (reference_value != GetPrefs(i)->GetString(pref_name)) {
|
| LOG(ERROR) << "String preference " << pref_name << " mismatched in"
|
| - << "profile " << i << ".";
|
| + << " profile " << i << ".";
|
| return false;
|
| }
|
| }
|
| return true;
|
| }
|
|
|
| -bool LivePreferencesSyncTest::FilePathPrefMatches(const char* pref_name) {
|
| +// static
|
| +bool PreferencesHelper::FilePathPrefMatches(const char* pref_name) {
|
| FilePath reference_value;
|
| - if (use_verifier_prefs_) {
|
| + if (test()->use_verifier()) {
|
| reference_value = GetVerifierPrefs()->GetFilePath(pref_name);
|
| } else {
|
| reference_value = GetPrefs(0)->GetFilePath(pref_name);
|
| }
|
| - for (int i = 0; i < num_clients(); ++i) {
|
| + for (int i = 0; i < test()->num_clients(); ++i) {
|
| if (reference_value != GetPrefs(i)->GetFilePath(pref_name)) {
|
| LOG(ERROR) << "FilePath preference " << pref_name << " mismatched in"
|
| - << "profile " << i << ".";
|
| + << " profile " << i << ".";
|
| return false;
|
| }
|
| }
|
| return true;
|
| }
|
|
|
| -bool LivePreferencesSyncTest::ListPrefMatches(const char* pref_name) {
|
| +// static
|
| +bool PreferencesHelper::ListPrefMatches(const char* pref_name) {
|
| const ListValue* reference_value;
|
| - if (use_verifier_prefs_) {
|
| + if (test()->use_verifier()) {
|
| reference_value = GetVerifierPrefs()->GetList(pref_name);
|
| } else {
|
| reference_value = GetPrefs(0)->GetList(pref_name);
|
| }
|
| - for (int i = 0; i < num_clients(); ++i) {
|
| + for (int i = 0; i < test()->num_clients(); ++i) {
|
| if (!reference_value->Equals(GetPrefs(i)->GetList(pref_name))) {
|
| LOG(ERROR) << "List preference " << pref_name << " mismatched in"
|
| - << "profile " << i << ".";
|
| + << " profile " << i << ".";
|
| return false;
|
| }
|
| }
|
| return true;
|
| }
|
|
|
| -void LivePreferencesSyncTest::DisableVerifier() {
|
| - use_verifier_prefs_ = false;
|
| +// static
|
| +bool PreferencesHelper::EnableEncryption(int index) {
|
| + return test()->GetClient(index)->EnableEncryptionForType(
|
| + syncable::PREFERENCES);
|
| }
|
|
|
| -bool LivePreferencesSyncTest::EnableEncryption(int index) {
|
| - return GetClient(index)->EnableEncryptionForType(syncable::PREFERENCES);
|
| -}
|
| -
|
| -bool LivePreferencesSyncTest::IsEncrypted(int index) {
|
| - return GetClient(index)->IsTypeEncrypted(syncable::PREFERENCES);
|
| +// static
|
| +bool PreferencesHelper::IsEncrypted(int index) {
|
| + return test()->GetClient(index)->IsTypeEncrypted(syncable::PREFERENCES);
|
| }
|
|
|