Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5462)

Unified Diff: chrome/browser/sync/test/integration/preferences_helper.h

Issue 2379433002: [Sync] Refactoring of sync integration test checkers to remove boilerplate await methods. (Closed)
Patch Set: Fixing another ChromeOS test. Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/sync/test/integration/preferences_helper.h
diff --git a/chrome/browser/sync/test/integration/preferences_helper.h b/chrome/browser/sync/test/integration/preferences_helper.h
index aaa5ad882018a5188a6d25299de7c9be3f50f6f6..e3582530cb7c9e323c859cc907395726a47ddd27 100644
--- a/chrome/browser/sync/test/integration/preferences_helper.h
+++ b/chrome/browser/sync/test/integration/preferences_helper.h
@@ -5,13 +5,17 @@
#ifndef CHROME_BROWSER_SYNC_TEST_INTEGRATION_PREFERENCES_HELPER_H_
#define CHROME_BROWSER_SYNC_TEST_INTEGRATION_PREFERENCES_HELPER_H_
-#include "base/files/file_path.h"
-#include "base/values.h"
-
#include <stdint.h>
+#include <memory>
#include <string>
+#include <vector>
+#include "base/files/file_path.h"
+#include "base/values.h"
+#include "chrome/browser/sync/test/integration/multi_client_status_change_checker.h"
+
+class PrefChangeRegistrar;
class PrefService;
namespace preferences_helper {
@@ -98,22 +102,61 @@ bool FilePathPrefMatches(const char* pref_name) WARN_UNUSED_RESULT;
// hasn't been called.
bool ListPrefMatches(const char* pref_name) WARN_UNUSED_RESULT;
-// This is the version of ListPrefMatches that waits for the preference list
-// to match in all profiles. Returns false if this operation times out.
-bool AwaitListPrefMatches(const char* pref_name) WARN_UNUSED_RESULT;
+} // namespace preferences_helper
+
+class PrefMatchChecker : public StatusChangeChecker {
maxbogue 2016/09/30 16:27:55 class comment
skym 2016/09/30 17:43:21 Done.
+ public:
+ explicit PrefMatchChecker(const char* path);
+ ~PrefMatchChecker() override;
-// Blocks the test until the specified pref matches on all relevant clients or
-// a timeout occurs. Returns false if it returns because of a timeout.
-bool AwaitBooleanPrefMatches(const char* pref_name) WARN_UNUSED_RESULT;
+ // StatusChangeChecker implementation.
+ bool IsExitConditionSatisfied() override = 0;
+ std::string GetDebugMessage() const override;
-// Blocks the test until the specified pref matches on all relevant clients or
-// a timeout occurs. Returns false if it returns because of a timeout.
-bool AwaitIntegerPrefMatches(const char* pref_name) WARN_UNUSED_RESULT;
+ protected:
+ const char* GetPath() const;
-// Blocks the test until the specified pref matches on all relevant clients or
-// a timeout occurs. Returns false if it returns because of a timeout.
-bool AwaitStringPrefMatches(const char* pref_name) WARN_UNUSED_RESULT;
+ private:
+ void RegisterPrefListener(PrefService* pref_service);
-} // namespace preferences_helper
+ std::vector<std::unique_ptr<PrefChangeRegistrar>> pref_change_registrars_;
+ const char* path_;
+};
+
+// Matcher that blocks until the specified list pref matches on all clients.
+class ListPrefMatchChecker : public PrefMatchChecker {
+ public:
+ explicit ListPrefMatchChecker(const char* path);
+
+ // PrefMatchChecker implementation.
+ bool IsExitConditionSatisfied() override;
+};
+
+// Matcher that blocks until the specified boolean pref matches on all clients.
+class BooleanPrefMatchChecker : public PrefMatchChecker {
+ public:
+ explicit BooleanPrefMatchChecker(const char* path);
+
+ // PrefMatchChecker implementation.
+ bool IsExitConditionSatisfied() override;
+};
+
+// Matcher that blocks until the specified integer pref matches on all clients.
+class IntegerPrefMatchChecker : public PrefMatchChecker {
+ public:
+ explicit IntegerPrefMatchChecker(const char* path);
+
+ // PrefMatchChecker implementation.
+ bool IsExitConditionSatisfied() override;
+};
+
+// Matcher that blocks until the specified string pref matches on all clients.
+class StringPrefMatchChecker : public PrefMatchChecker {
+ public:
+ explicit StringPrefMatchChecker(const char* path);
+
+ // PrefMatchChecker implementation.
+ bool IsExitConditionSatisfied() override;
+};
#endif // CHROME_BROWSER_SYNC_TEST_INTEGRATION_PREFERENCES_HELPER_H_

Powered by Google App Engine
This is Rietveld 408576698