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

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

Issue 165393010: Draft: Moving code out of ProfileSyncServiceHarness (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 10 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_exponential_backoff_test.cc
diff --git a/chrome/browser/sync/test/integration/sync_exponential_backoff_test.cc b/chrome/browser/sync/test/integration/sync_exponential_backoff_test.cc
index 16e5a092741d454c56c1e4c50777a46d02f1e6a0..47fa5748896a430d89998afe459db179b81a9add 100644
--- a/chrome/browser/sync/test/integration/sync_exponential_backoff_test.cc
+++ b/chrome/browser/sync/test/integration/sync_exponential_backoff_test.cc
@@ -3,10 +3,11 @@
// found in the LICENSE file.
#include "base/bind.h"
+#include "base/strings/stringprintf.h"
#include "chrome/browser/sync/test/integration/bookmarks_helper.h"
#include "chrome/browser/sync/test/integration/profile_sync_service_harness.h"
#include "chrome/browser/sync/test/integration/retry_verifier.h"
-#include "chrome/browser/sync/test/integration/status_change_checker.h"
+#include "chrome/browser/sync/test/integration/single_client_status_change_checker.h"
#include "chrome/browser/sync/test/integration/sync_test.h"
namespace {
@@ -26,13 +27,11 @@ class SyncExponentialBackoffTest : public SyncTest {
// Helper class that checks if a sync client has successfully gone through
// exponential backoff after it encounters an error.
-class ExponentialBackoffChecker : public StatusChangeChecker {
+class ExponentialBackoffChecker : public SingleClientStatusChangeChecker {
public:
- explicit ExponentialBackoffChecker(const ProfileSyncServiceHarness* harness)
- : StatusChangeChecker("ExponentialBackoffChecker"),
- harness_(harness) {
- DCHECK(harness);
- const SyncSessionSnapshot& snap = harness_->GetLastSessionSnapshot();
+ explicit ExponentialBackoffChecker(ProfileSyncService* pss)
+ : SingleClientStatusChangeChecker(pss) {
+ const SyncSessionSnapshot& snap = service()->GetLastSessionSnapshot();
retry_verifier_.Initialize(snap);
}
@@ -41,15 +40,18 @@ class ExponentialBackoffChecker : public StatusChangeChecker {
// Checks if backoff is complete. Called repeatedly each time PSS notifies
// observers of a state change.
virtual bool IsExitConditionSatisfied() OVERRIDE {
- const SyncSessionSnapshot& snap = harness_->GetLastSessionSnapshot();
+ const SyncSessionSnapshot& snap = service()->GetLastSessionSnapshot();
retry_verifier_.VerifyRetryInterval(snap);
return (retry_verifier_.done() && retry_verifier_.Succeeded());
}
- private:
- // The sync client for which backoff is being verified.
- const ProfileSyncServiceHarness* harness_;
+ virtual std::string GetDebugMessage() const OVERRIDE {
+ return base::StringPrintf("Verifying backoff intervals (%d/%d)",
+ retry_verifier_.retry_count(),
+ RetryVerifier::kMaxRetry);
+ }
+ private:
// Keeps track of the number of attempts at exponential backoff and its
// related bookkeeping information for verification.
RetryVerifier retry_verifier_;
@@ -72,9 +74,9 @@ IN_PROC_BROWSER_TEST_F(SyncExponentialBackoffTest, OfflineToOnline) {
// Verify that the client goes into exponential backoff while it is unable to
// reach the sync server.
- ExponentialBackoffChecker exponential_backoff_checker(GetClient(0));
- ASSERT_TRUE(GetClient(0)->AwaitStatusChange(&exponential_backoff_checker,
- "Checking exponential backoff"));
+ ExponentialBackoffChecker exponential_backoff_checker(
+ GetClient(0)->service());
+ ASSERT_TRUE(GetClient(0)->AwaitStatusChange(&exponential_backoff_checker));
// Recover from the network error.
EnableNetwork(GetProfile(0));
@@ -99,9 +101,9 @@ IN_PROC_BROWSER_TEST_F(SyncExponentialBackoffTest, TransientErrorTest) {
// Verify that the client goes into exponential backoff while it is unable to
// reach the sync server.
- ExponentialBackoffChecker exponential_backoff_checker(GetClient(0));
- ASSERT_TRUE(GetClient(0)->AwaitStatusChange(&exponential_backoff_checker,
- "Checking exponential backoff"));
+ ExponentialBackoffChecker exponential_backoff_checker(
+ GetClient(0)->service());
+ ASSERT_TRUE(GetClient(0)->AwaitStatusChange(&exponential_backoff_checker));
}
} // namespace
« no previous file with comments | « chrome/browser/sync/test/integration/sync_errors_test.cc ('k') | chrome/browser/sync/test/integration/sync_test.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698