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

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

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/sync_integration_test_util.cc
diff --git a/chrome/browser/sync/test/integration/sync_integration_test_util.cc b/chrome/browser/sync/test/integration/sync_integration_test_util.cc
index 53ed7ae6f476d75c50d2a261ba19d3dd3731c4cd..9ce060fd8bb263f4813c4e0542a869a173e0e1ed 100644
--- a/chrome/browser/sync/test/integration/sync_integration_test_util.cc
+++ b/chrome/browser/sync/test/integration/sync_integration_test_util.cc
@@ -8,88 +8,46 @@
#include "base/strings/stringprintf.h"
#include "chrome/browser/sync/test/integration/fake_server_match_status_checker.h"
-#include "chrome/browser/sync/test/integration/single_client_status_change_checker.h"
-#include "chrome/browser/sync/test/integration/updated_progress_marker_checker.h"
#include "components/browser_sync/profile_sync_service.h"
-namespace {
+ServerCountMatchStatusChecker::ServerCountMatchStatusChecker(
+ syncer::ModelType type,
+ size_t count)
+ : type_(type), count_(count) {}
-// Helper class to block until the server has a given number of entities.
-class ServerCountMatchStatusChecker
- : public fake_server::FakeServerMatchStatusChecker {
- public:
- ServerCountMatchStatusChecker(syncer::ModelType type, size_t count)
- : type_(type), count_(count) {}
- ~ServerCountMatchStatusChecker() override {}
-
- bool IsExitConditionSatisfied() override {
- return count_ == fake_server()->GetSyncEntitiesByModelType(type_).size();
- }
-
- std::string GetDebugMessage() const override {
- return base::StringPrintf(
- "Waiting for fake server entity count %zu to match expected count %zu "
- "for type %d",
- (size_t)fake_server()->GetSyncEntitiesByModelType(type_).size(), count_,
- type_);
- }
-
- private:
- const syncer::ModelType type_;
- const size_t count_;
-};
-
-class PassphraseRequiredChecker : public SingleClientStatusChangeChecker {
- public:
- explicit PassphraseRequiredChecker(browser_sync::ProfileSyncService* service)
- : SingleClientStatusChangeChecker(service) {}
-
- bool IsExitConditionSatisfied() override {
- return service()->IsPassphraseRequired();
- }
-
- std::string GetDebugMessage() const override { return "Passhrase Required"; }
-};
-
-class PassphraseAcceptedChecker : public SingleClientStatusChangeChecker {
- public:
- explicit PassphraseAcceptedChecker(browser_sync::ProfileSyncService* service)
- : SingleClientStatusChangeChecker(service) {}
-
- bool IsExitConditionSatisfied() override {
- return !service()->IsPassphraseRequired() &&
- service()->IsUsingSecondaryPassphrase();
- }
-
- std::string GetDebugMessage() const override { return "Passhrase Accepted"; }
-};
+bool ServerCountMatchStatusChecker::IsExitConditionSatisfied() {
+ return count_ == fake_server()->GetSyncEntitiesByModelType(type_).size();
+}
-} // namespace
+std::string ServerCountMatchStatusChecker::GetDebugMessage() const {
+ return base::StringPrintf(
+ "Waiting for fake server entity count %zu to match expected count %zu "
+ "for type %d",
+ (size_t)fake_server()->GetSyncEntitiesByModelType(type_).size(), count_,
+ type_);
+}
-namespace sync_integration_test_util {
+PassphraseRequiredChecker::PassphraseRequiredChecker(
+ browser_sync::ProfileSyncService* service)
+ : SingleClientStatusChangeChecker(service) {}
-bool AwaitPassphraseRequired(browser_sync::ProfileSyncService* service) {
- PassphraseRequiredChecker checker(service);
- checker.Wait();
- return !checker.TimedOut();
+bool PassphraseRequiredChecker::IsExitConditionSatisfied() {
+ return service()->IsPassphraseRequired();
}
-bool AwaitPassphraseAccepted(browser_sync::ProfileSyncService* service) {
- PassphraseAcceptedChecker checker(service);
- checker.Wait();
- return !checker.TimedOut();
+std::string PassphraseRequiredChecker::GetDebugMessage() const {
+ return "Passhrase Required";
}
-bool AwaitCommitActivityCompletion(browser_sync::ProfileSyncService* service) {
- UpdatedProgressMarkerChecker checker(service);
- checker.Wait();
- return !checker.TimedOut();
-}
+PassphraseAcceptedChecker::PassphraseAcceptedChecker(
+ browser_sync::ProfileSyncService* service)
+ : SingleClientStatusChangeChecker(service) {}
-bool AwaitServerCount(syncer::ModelType type, size_t count) {
- ServerCountMatchStatusChecker checker(type, count);
- checker.Wait();
- return !checker.TimedOut();
+bool PassphraseAcceptedChecker::IsExitConditionSatisfied() {
+ return !service()->IsPassphraseRequired() &&
+ service()->IsUsingSecondaryPassphrase();
}
-} // namespace sync_integration_test_util
+std::string PassphraseAcceptedChecker::GetDebugMessage() const {
+ return "Passhrase Accepted";
+}
« no previous file with comments | « chrome/browser/sync/test/integration/sync_integration_test_util.h ('k') | chrome/browser/sync/test/integration/sync_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698