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

Side by Side Diff: chrome/browser/sync/test/integration/sync_exponential_backoff_test.cc

Issue 2365763002: [Sync] Removed passphrase helper methods, removed ((n)) pattern, and fixed lint violations. (Closed)
Patch Set: Removed useless pass-through accessors. 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 unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/bind.h" 5 #include "base/bind.h"
6 #include "base/macros.h" 6 #include "base/macros.h"
7 #include "base/strings/stringprintf.h" 7 #include "base/strings/stringprintf.h"
8 #include "chrome/browser/sync/test/integration/bookmarks_helper.h" 8 #include "chrome/browser/sync/test/integration/bookmarks_helper.h"
9 #include "chrome/browser/sync/test/integration/retry_verifier.h" 9 #include "chrome/browser/sync/test/integration/retry_verifier.h"
10 #include "chrome/browser/sync/test/integration/single_client_status_change_check er.h" 10 #include "chrome/browser/sync/test/integration/single_client_status_change_check er.h"
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 RetryVerifier retry_verifier_; 61 RetryVerifier retry_verifier_;
62 62
63 DISALLOW_COPY_AND_ASSIGN(ExponentialBackoffChecker); 63 DISALLOW_COPY_AND_ASSIGN(ExponentialBackoffChecker);
64 }; 64 };
65 65
66 IN_PROC_BROWSER_TEST_F(SyncExponentialBackoffTest, OfflineToOnline) { 66 IN_PROC_BROWSER_TEST_F(SyncExponentialBackoffTest, OfflineToOnline) {
67 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; 67 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
68 68
69 // Add an item and ensure that sync is successful. 69 // Add an item and ensure that sync is successful.
70 ASSERT_TRUE(AddFolder(0, 0, "folder1")); 70 ASSERT_TRUE(AddFolder(0, 0, "folder1"));
71 ASSERT_TRUE(AwaitCommitActivityCompletion(GetSyncService((0)))); 71 ASSERT_TRUE(AwaitCommitActivityCompletion(GetSyncService(0)));
72 72
73 GetFakeServer()->DisableNetwork(); 73 GetFakeServer()->DisableNetwork();
74 74
75 // Add a new item to trigger another sync cycle. 75 // Add a new item to trigger another sync cycle.
76 ASSERT_TRUE(AddFolder(0, 0, "folder2")); 76 ASSERT_TRUE(AddFolder(0, 0, "folder2"));
77 77
78 // Verify that the client goes into exponential backoff while it is unable to 78 // Verify that the client goes into exponential backoff while it is unable to
79 // reach the sync server. 79 // reach the sync server.
80 ExponentialBackoffChecker exponential_backoff_checker( 80 ExponentialBackoffChecker exponential_backoff_checker(GetSyncService(0));
81 GetSyncService((0)));
82 exponential_backoff_checker.Wait(); 81 exponential_backoff_checker.Wait();
83 ASSERT_FALSE(exponential_backoff_checker.TimedOut()); 82 ASSERT_FALSE(exponential_backoff_checker.TimedOut());
84 83
85 // Trigger network change notification and remember time when it happened. 84 // Trigger network change notification and remember time when it happened.
86 // Ensure that scheduler runs canary job immediately. 85 // Ensure that scheduler runs canary job immediately.
87 GetFakeServer()->EnableNetwork(); 86 GetFakeServer()->EnableNetwork();
88 net::NetworkChangeNotifier::NotifyObserversOfConnectionTypeChangeForTests( 87 net::NetworkChangeNotifier::NotifyObserversOfConnectionTypeChangeForTests(
89 net::NetworkChangeNotifier::CONNECTION_ETHERNET); 88 net::NetworkChangeNotifier::CONNECTION_ETHERNET);
90 89
91 base::Time network_notification_time = base::Time::Now(); 90 base::Time network_notification_time = base::Time::Now();
92 91
93 // Verify that sync was able to recover. 92 // Verify that sync was able to recover.
94 ASSERT_TRUE(AwaitCommitActivityCompletion(GetSyncService((0)))); 93 ASSERT_TRUE(AwaitCommitActivityCompletion(GetSyncService(0)));
95 ASSERT_TRUE(ModelMatchesVerifier(0)); 94 ASSERT_TRUE(ModelMatchesVerifier(0));
96 95
97 // Verify that recovery time is short. Without canary job recovery time would 96 // Verify that recovery time is short. Without canary job recovery time would
98 // be more than 5 seconds. 97 // be more than 5 seconds.
99 base::TimeDelta recovery_time = 98 base::TimeDelta recovery_time =
100 GetSyncService(0)->GetLastCycleSnapshot().sync_start_time() - 99 GetSyncService(0)->GetLastCycleSnapshot().sync_start_time() -
101 network_notification_time; 100 network_notification_time;
102 ASSERT_LE(recovery_time, base::TimeDelta::FromSeconds(2)); 101 ASSERT_LE(recovery_time, base::TimeDelta::FromSeconds(2));
103 } 102 }
104 103
105 IN_PROC_BROWSER_TEST_F(SyncExponentialBackoffTest, TransientErrorTest) { 104 IN_PROC_BROWSER_TEST_F(SyncExponentialBackoffTest, TransientErrorTest) {
106 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; 105 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
107 106
108 // Add an item and ensure that sync is successful. 107 // Add an item and ensure that sync is successful.
109 ASSERT_TRUE(AddFolder(0, 0, "folder1")); 108 ASSERT_TRUE(AddFolder(0, 0, "folder1"));
110 ASSERT_TRUE(AwaitCommitActivityCompletion(GetSyncService((0)))); 109 ASSERT_TRUE(AwaitCommitActivityCompletion(GetSyncService(0)));
111 110
112 GetFakeServer()->TriggerError(sync_pb::SyncEnums::TRANSIENT_ERROR); 111 GetFakeServer()->TriggerError(sync_pb::SyncEnums::TRANSIENT_ERROR);
113 112
114 // Add a new item to trigger another sync cycle. 113 // Add a new item to trigger another sync cycle.
115 ASSERT_TRUE(AddFolder(0, 0, "folder2")); 114 ASSERT_TRUE(AddFolder(0, 0, "folder2"));
116 115
117 // Verify that the client goes into exponential backoff while it is unable to 116 // Verify that the client goes into exponential backoff while it is unable to
118 // reach the sync server. 117 // reach the sync server.
119 ExponentialBackoffChecker exponential_backoff_checker( 118 ExponentialBackoffChecker exponential_backoff_checker(GetSyncService(0));
120 GetSyncService((0)));
121 exponential_backoff_checker.Wait(); 119 exponential_backoff_checker.Wait();
122 ASSERT_FALSE(exponential_backoff_checker.TimedOut()); 120 ASSERT_FALSE(exponential_backoff_checker.TimedOut());
123 } 121 }
124 122
125 } // namespace 123 } // namespace
OLDNEW
« no previous file with comments | « chrome/browser/sync/test/integration/sync_auth_test.cc ('k') | chrome/browser/sync/test/integration/sync_extension_helper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698