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

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: Rebase Created 4 years, 2 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..2a98b9122627ea99eaa8d11cd3a6d15bb495a9e4 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,62 @@ 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;
-
-// 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;
-
-// 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;
-
-// 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;
-
} // namespace preferences_helper
+// Abstract checker that takes care of registering for preference changes.
+class PrefMatchChecker : public StatusChangeChecker {
+ public:
+ explicit PrefMatchChecker(const char* path);
+ ~PrefMatchChecker() override;
+
+ // StatusChangeChecker implementation.
+ bool IsExitConditionSatisfied() override = 0;
+ std::string GetDebugMessage() const override;
+
+ protected:
+ const char* GetPath() const;
+
+ private:
+ void RegisterPrefListener(PrefService* pref_service);
+
+ 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