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

Unified Diff: chrome/browser/sync/test/integration/dictionary_helper.cc

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/dictionary_helper.cc
diff --git a/chrome/browser/sync/test/integration/dictionary_helper.cc b/chrome/browser/sync/test/integration/dictionary_helper.cc
index b9937bcb79d24ea0c4c7c7d87f87785d397d07c2..30f92967f51644028dfc736ea9fbf6a5d66353e1 100644
--- a/chrome/browser/sync/test/integration/dictionary_helper.cc
+++ b/chrome/browser/sync/test/integration/dictionary_helper.cc
@@ -16,8 +16,6 @@
#include "chrome/browser/spellchecker/spellcheck_factory.h"
#include "chrome/browser/spellchecker/spellcheck_service.h"
#include "chrome/browser/sync/test/integration/dictionary_load_observer.h"
-#include "chrome/browser/sync/test/integration/multi_client_status_change_checker.h"
-#include "chrome/browser/sync/test/integration/single_client_status_change_checker.h"
#include "chrome/browser/sync/test/integration/sync_datatype_helper.h"
#include "chrome/browser/sync/test/integration/sync_test.h"
#include "content/public/test/test_utils.h"
@@ -99,80 +97,6 @@ bool DictionariesMatch() {
return true;
}
-namespace {
-
-// Helper class used in the implementation of AwaitDictionariesMatch.
-class DictionaryMatchStatusChecker : public MultiClientStatusChangeChecker {
- public:
- DictionaryMatchStatusChecker();
- ~DictionaryMatchStatusChecker() override;
-
- bool IsExitConditionSatisfied() override;
- std::string GetDebugMessage() const override;
-};
-
-DictionaryMatchStatusChecker::DictionaryMatchStatusChecker()
- : MultiClientStatusChangeChecker(
- sync_datatype_helper::test()->GetSyncServices()) {}
-
-DictionaryMatchStatusChecker::~DictionaryMatchStatusChecker() {}
-
-bool DictionaryMatchStatusChecker::IsExitConditionSatisfied() {
- return DictionariesMatch();
-}
-
-std::string DictionaryMatchStatusChecker::GetDebugMessage() const {
- return "Waiting for matching dictionaries";
-}
-
-// Helper class used in the implementation of AwaitNumDictionaryEntries.
-class NumDictionaryEntriesStatusChecker
- : public SingleClientStatusChangeChecker {
- public:
- NumDictionaryEntriesStatusChecker(int index, size_t num_words);
- ~NumDictionaryEntriesStatusChecker() override;
-
- bool IsExitConditionSatisfied() override;
- std::string GetDebugMessage() const override;
-
- private:
- int index_;
- size_t num_words_;
-};
-
-NumDictionaryEntriesStatusChecker::NumDictionaryEntriesStatusChecker(
- int index, size_t num_words)
- : SingleClientStatusChangeChecker(
- sync_datatype_helper::test()->GetSyncService(index)),
- index_(index),
- num_words_(num_words) {}
-
-NumDictionaryEntriesStatusChecker::~NumDictionaryEntriesStatusChecker() {}
-
-bool NumDictionaryEntriesStatusChecker::IsExitConditionSatisfied() {
- return GetDictionarySize(index_) == num_words_;
-}
-
-std::string NumDictionaryEntriesStatusChecker::GetDebugMessage() const {
- return base::StringPrintf(
- "Waiting for client %d: %" PRIuS " / %" PRIuS " words downloaded",
- index_, GetDictionarySize(index_), num_words_);
-}
-
-} // namespace
-
-bool AwaitDictionariesMatch() {
- DictionaryMatchStatusChecker checker;
- checker.Wait();
- return !checker.TimedOut();
-}
-
-bool AwaitNumDictionaryEntries(int index, size_t num_words) {
- NumDictionaryEntriesStatusChecker checker(index, num_words);
- checker.Wait();
- return !checker.TimedOut();
-}
-
bool DictionaryMatchesVerifier(int index) {
const std::set<std::string>& expected = GetVerifierDictionary()->GetWords();
const std::set<std::string>& actual = GetDictionary(index)->GetWords();
@@ -213,3 +137,32 @@ bool RemoveWord(int index, const std::string& word) {
}
} // namespace dictionary_helper
+
+DictionaryMatchChecker::DictionaryMatchChecker()
+ : MultiClientStatusChangeChecker(
+ sync_datatype_helper::test()->GetSyncServices()) {}
+
+bool DictionaryMatchChecker::IsExitConditionSatisfied() {
+ return dictionary_helper::DictionariesMatch();
+}
+
+std::string DictionaryMatchChecker::GetDebugMessage() const {
+ return "Waiting for matching dictionaries";
+}
+
+NumDictionaryEntriesChecker::NumDictionaryEntriesChecker(int index,
+ size_t num_words)
+ : SingleClientStatusChangeChecker(
+ sync_datatype_helper::test()->GetSyncService(index)),
+ index_(index),
+ num_words_(num_words) {}
+
+bool NumDictionaryEntriesChecker::IsExitConditionSatisfied() {
+ return dictionary_helper::GetDictionarySize(index_) == num_words_;
+}
+
+std::string NumDictionaryEntriesChecker::GetDebugMessage() const {
+ return base::StringPrintf(
+ "Waiting for client %d: %" PRIuS " / %" PRIuS " words downloaded", index_,
+ dictionary_helper::GetDictionarySize(index_), num_words_);
+}

Powered by Google App Engine
This is Rietveld 408576698