OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROME_BROWSER_SYNC_TEST_INTEGRATION_PREFERENCES_HELPER_H_ | 5 #ifndef CHROME_BROWSER_SYNC_TEST_INTEGRATION_PREFERENCES_HELPER_H_ |
6 #define CHROME_BROWSER_SYNC_TEST_INTEGRATION_PREFERENCES_HELPER_H_ | 6 #define CHROME_BROWSER_SYNC_TEST_INTEGRATION_PREFERENCES_HELPER_H_ |
7 | 7 |
| 8 #include <stdint.h> |
| 9 |
| 10 #include <memory> |
| 11 #include <string> |
| 12 #include <vector> |
| 13 |
8 #include "base/files/file_path.h" | 14 #include "base/files/file_path.h" |
9 #include "base/values.h" | 15 #include "base/values.h" |
| 16 #include "chrome/browser/sync/test/integration/multi_client_status_change_checke
r.h" |
10 | 17 |
11 #include <stdint.h> | 18 class PrefChangeRegistrar; |
12 | |
13 #include <string> | |
14 | |
15 class PrefService; | 19 class PrefService; |
16 | 20 |
17 namespace preferences_helper { | 21 namespace preferences_helper { |
18 | 22 |
19 // Used to access the preferences within a particular sync profile. | 23 // Used to access the preferences within a particular sync profile. |
20 PrefService* GetPrefs(int index); | 24 PrefService* GetPrefs(int index); |
21 | 25 |
22 // Used to access the preferences within the verifier sync profile. | 26 // Used to access the preferences within the verifier sync profile. |
23 PrefService* GetVerifierPrefs(); | 27 PrefService* GetVerifierPrefs(); |
24 | 28 |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 // Used to verify that the file path preference with name |pref_name| has the | 95 // Used to verify that the file path preference with name |pref_name| has the |
92 // same value across all profiles. Also checks |verifier| if DisableVerifier() | 96 // same value across all profiles. Also checks |verifier| if DisableVerifier() |
93 // hasn't been called. | 97 // hasn't been called. |
94 bool FilePathPrefMatches(const char* pref_name) WARN_UNUSED_RESULT; | 98 bool FilePathPrefMatches(const char* pref_name) WARN_UNUSED_RESULT; |
95 | 99 |
96 // Used to verify that the list preference with name |pref_name| has the | 100 // Used to verify that the list preference with name |pref_name| has the |
97 // same value across all profiles. Also checks |verifier| if DisableVerifier() | 101 // same value across all profiles. Also checks |verifier| if DisableVerifier() |
98 // hasn't been called. | 102 // hasn't been called. |
99 bool ListPrefMatches(const char* pref_name) WARN_UNUSED_RESULT; | 103 bool ListPrefMatches(const char* pref_name) WARN_UNUSED_RESULT; |
100 | 104 |
101 // This is the version of ListPrefMatches that waits for the preference list | |
102 // to match in all profiles. Returns false if this operation times out. | |
103 bool AwaitListPrefMatches(const char* pref_name) WARN_UNUSED_RESULT; | |
104 | |
105 // Blocks the test until the specified pref matches on all relevant clients or | |
106 // a timeout occurs. Returns false if it returns because of a timeout. | |
107 bool AwaitBooleanPrefMatches(const char* pref_name) WARN_UNUSED_RESULT; | |
108 | |
109 // Blocks the test until the specified pref matches on all relevant clients or | |
110 // a timeout occurs. Returns false if it returns because of a timeout. | |
111 bool AwaitIntegerPrefMatches(const char* pref_name) WARN_UNUSED_RESULT; | |
112 | |
113 // Blocks the test until the specified pref matches on all relevant clients or | |
114 // a timeout occurs. Returns false if it returns because of a timeout. | |
115 bool AwaitStringPrefMatches(const char* pref_name) WARN_UNUSED_RESULT; | |
116 | |
117 } // namespace preferences_helper | 105 } // namespace preferences_helper |
118 | 106 |
| 107 // Abstract checker that takes care of registering for preference changes. |
| 108 class PrefMatchChecker : public StatusChangeChecker { |
| 109 public: |
| 110 explicit PrefMatchChecker(const char* path); |
| 111 ~PrefMatchChecker() override; |
| 112 |
| 113 // StatusChangeChecker implementation. |
| 114 bool IsExitConditionSatisfied() override = 0; |
| 115 std::string GetDebugMessage() const override; |
| 116 |
| 117 protected: |
| 118 const char* GetPath() const; |
| 119 |
| 120 private: |
| 121 void RegisterPrefListener(PrefService* pref_service); |
| 122 |
| 123 std::vector<std::unique_ptr<PrefChangeRegistrar>> pref_change_registrars_; |
| 124 const char* path_; |
| 125 }; |
| 126 |
| 127 // Matcher that blocks until the specified list pref matches on all clients. |
| 128 class ListPrefMatchChecker : public PrefMatchChecker { |
| 129 public: |
| 130 explicit ListPrefMatchChecker(const char* path); |
| 131 |
| 132 // PrefMatchChecker implementation. |
| 133 bool IsExitConditionSatisfied() override; |
| 134 }; |
| 135 |
| 136 // Matcher that blocks until the specified boolean pref matches on all clients. |
| 137 class BooleanPrefMatchChecker : public PrefMatchChecker { |
| 138 public: |
| 139 explicit BooleanPrefMatchChecker(const char* path); |
| 140 |
| 141 // PrefMatchChecker implementation. |
| 142 bool IsExitConditionSatisfied() override; |
| 143 }; |
| 144 |
| 145 // Matcher that blocks until the specified integer pref matches on all clients. |
| 146 class IntegerPrefMatchChecker : public PrefMatchChecker { |
| 147 public: |
| 148 explicit IntegerPrefMatchChecker(const char* path); |
| 149 |
| 150 // PrefMatchChecker implementation. |
| 151 bool IsExitConditionSatisfied() override; |
| 152 }; |
| 153 |
| 154 // Matcher that blocks until the specified string pref matches on all clients. |
| 155 class StringPrefMatchChecker : public PrefMatchChecker { |
| 156 public: |
| 157 explicit StringPrefMatchChecker(const char* path); |
| 158 |
| 159 // PrefMatchChecker implementation. |
| 160 bool IsExitConditionSatisfied() override; |
| 161 }; |
| 162 |
119 #endif // CHROME_BROWSER_SYNC_TEST_INTEGRATION_PREFERENCES_HELPER_H_ | 163 #endif // CHROME_BROWSER_SYNC_TEST_INTEGRATION_PREFERENCES_HELPER_H_ |
OLD | NEW |