1// Copyright (c) 2012 The Chromium Authors. All rights reserved. 2// Use of this source code is governed by a BSD-style license that can be 3// found in the LICENSE file. 4 5#ifndef CHROME_BROWSER_SYNC_TEST_INTEGRATION_PREFERENCES_HELPER_H_ 6#define CHROME_BROWSER_SYNC_TEST_INTEGRATION_PREFERENCES_HELPER_H_ 7 8#include "base/files/file_path.h" 9#include "base/values.h" 10 11#include <string> 12 13class PrefService; 14 15namespace preferences_helper { 16 17// Used to access the preferences within a particular sync profile. 18PrefService* GetPrefs(int index); 19 20// Used to access the preferences within the verifier sync profile. 21PrefService* GetVerifierPrefs(); 22 23// Inverts the value of the boolean preference with name |pref_name| in the 24// profile with index |index|. Also inverts its value in |verifier| if 25// DisableVerifier() hasn't been called. 26void ChangeBooleanPref(int index, const char* pref_name); 27 28// Changes the value of the integer preference with name |pref_name| in the 29// profile with index |index| to |new_value|. Also changes its value in 30// |verifier| if DisableVerifier() hasn't been called. 31void ChangeIntegerPref(int index, const char* pref_name, int new_value); 32 33// Changes the value of the int64 preference with name |pref_name| in the 34// profile with index |index| to |new_value|. Also changes its value in 35// |verifier| if DisableVerifier() hasn't been called. 36void ChangeInt64Pref(int index, const char* pref_name, int64 new_value); 37 38// Changes the value of the double preference with name |pref_name| in the 39// profile with index |index| to |new_value|. Also changes its value in 40// |verifier| if DisableVerifier() hasn't been called. 41void ChangeDoublePref(int index, const char* pref_name, double new_value); 42 43// Changes the value of the string preference with name |pref_name| in the 44// profile with index |index| to |new_value|. Also changes its value in 45// |verifier| if DisableVerifier() hasn't been called. 46void ChangeStringPref(int index, 47 const char* pref_name, 48 const std::string& new_value); 49 50// Changes the value of the file path preference with name |pref_name| in the 51// profile with index |index| to |new_value|. Also changes its value in 52// |verifier| if DisableVerifier() hasn't been called. 53void ChangeFilePathPref(int index, 54 const char* pref_name, 55 const base::FilePath& new_value); 56 57// Changes the value of the list preference with name |pref_name| in the 58// profile with index |index| to |new_value|. Also changes its value in 59// |verifier| if DisableVerifier() hasn't been called. 60void ChangeListPref(int index, 61 const char* pref_name, 62 const base::ListValue& new_value); 63 64// Used to verify that the boolean preference with name |pref_name| has the 65// same value across all profiles. Also checks |verifier| if DisableVerifier() 66// hasn't been called. 67bool BooleanPrefMatches(const char* pref_name) WARN_UNUSED_RESULT; 68 69// Used to verify that the integer preference with name |pref_name| has the 70// same value across all profiles. Also checks |verifier| if DisableVerifier() 71// hasn't been called. 72bool IntegerPrefMatches(const char* pref_name) WARN_UNUSED_RESULT; 73 74// Used to verify that the int64 preference with name |pref_name| has the 75// same value across all profiles. Also checks |verifier| if DisableVerifier() 76// hasn't been called. 77bool Int64PrefMatches(const char* pref_name) WARN_UNUSED_RESULT; 78 79// Used to verify that the double preference with name |pref_name| has the 80// same value across all profiles. Also checks |verifier| if DisableVerifier() 81// hasn't been called. 82bool DoublePrefMatches(const char* pref_name) WARN_UNUSED_RESULT; 83 84// Used to verify that the string preference with name |pref_name| has the 85// same value across all profiles. Also checks |verifier| if DisableVerifier() 86// hasn't been called. 87bool StringPrefMatches(const char* pref_name) WARN_UNUSED_RESULT; 88 89// Used to verify that the file path preference with name |pref_name| has the 90// same value across all profiles. Also checks |verifier| if DisableVerifier() 91// hasn't been called. 92bool FilePathPrefMatches(const char* pref_name) WARN_UNUSED_RESULT; 93 94// Used to verify that the list preference with name |pref_name| has the 95// same value across all profiles. Also checks |verifier| if DisableVerifier() 96// hasn't been called. 97bool ListPrefMatches(const char* pref_name) WARN_UNUSED_RESULT; 98 99// This is the version of ListPrefMatches that waits for the preference list 100// to match in all profiles. Returns false if this operation times out. 101bool AwaitListPrefMatches(const char* pref_name) WARN_UNUSED_RESULT; 102 103// Blocks the test until the specified pref matches on all relevant clients or 104// a timeout occurs. Returns false if it returns because of a timeout. 105bool AwaitBooleanPrefMatches(const char* pref_name) WARN_UNUSED_RESULT; 106 107// Blocks the test until the specified pref matches on all relevant clients or 108// a timeout occurs. Returns false if it returns because of a timeout. 109bool AwaitIntegerPrefMatches(const char* pref_name) WARN_UNUSED_RESULT; 110 111// Blocks the test until the specified pref matches on all relevant clients or 112// a timeout occurs. Returns false if it returns because of a timeout. 113bool AwaitStringPrefMatches(const char* pref_name) WARN_UNUSED_RESULT; 114 115} // namespace preferences_helper 116 117#endif // CHROME_BROWSER_SYNC_TEST_INTEGRATION_PREFERENCES_HELPER_H_ 118