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

Side by Side Diff: chrome/browser/sync/test/integration/profile_sync_service_harness.h

Issue 148723002: [sync] Eliminate Await*SyncCompletion methods in integration tests (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 unified diff | Download patch | Annotate | Revision Log
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 #ifndef CHROME_BROWSER_SYNC_TEST_INTEGRATION_PROFILE_SYNC_SERVICE_HARNESS_H_ 5 #ifndef CHROME_BROWSER_SYNC_TEST_INTEGRATION_PROFILE_SYNC_SERVICE_HARNESS_H_
6 #define CHROME_BROWSER_SYNC_TEST_INTEGRATION_PROFILE_SYNC_SERVICE_HARNESS_H_ 6 #define CHROME_BROWSER_SYNC_TEST_INTEGRATION_PROFILE_SYNC_SERVICE_HARNESS_H_
7 7
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 bool SetupSync(syncer::ModelTypeSet synced_datatypes); 68 bool SetupSync(syncer::ModelTypeSet synced_datatypes);
69 69
70 // ProfileSyncServiceObserver implementation. 70 // ProfileSyncServiceObserver implementation.
71 virtual void OnStateChanged() OVERRIDE; 71 virtual void OnStateChanged() OVERRIDE;
72 virtual void OnSyncCycleCompleted() OVERRIDE; 72 virtual void OnSyncCycleCompleted() OVERRIDE;
73 73
74 // Blocks the caller until the sync backend host associated with this harness 74 // Blocks the caller until the sync backend host associated with this harness
75 // has been initialized. Returns true if the wait was successful. 75 // has been initialized. Returns true if the wait was successful.
76 bool AwaitBackendInitialized(); 76 bool AwaitBackendInitialized();
77 77
78 // Blocks the caller until this harness has completed a single sync cycle 78 // Blocks the caller until the client has nothing left to commit and its
79 // since the previous one. Returns true if a sync cycle has completed. 79 // progress markers are up to date. Returns true if successful.
80 bool AwaitDataSyncCompletion(); 80 bool AwaitCommitActivityCompletion();
81
82 // Blocks the caller until this harness has completed as many sync cycles as
83 // are required to ensure its progress marker matches the latest available on
84 // the server.
85 //
86 // Note: When other clients are committing changes this will not be reliable.
87 // If your test involves changes to multiple clients, you should use one of
88 // the other Await* functions, such as AwaitMutualSyncCycleComplete. Refer to
89 // the documentation of those functions for more details.
90 bool AwaitFullSyncCompletion();
91 81
92 // Blocks the caller until sync has been disabled for this client. Returns 82 // Blocks the caller until sync has been disabled for this client. Returns
93 // true if sync is disabled. 83 // true if sync is disabled.
94 bool AwaitSyncDisabled(); 84 bool AwaitSyncDisabled();
95 85
96 // Blocks the caller until this harness has observed that the sync engine 86 // Blocks the caller until this harness has observed that the sync engine
97 // has downloaded all the changes seen by the |partner| harness's client. 87 // has downloaded all the changes seen by the |partner| harness's client.
98 bool WaitUntilProgressMarkersMatch(ProfileSyncServiceHarness* partner); 88 bool WaitUntilProgressMarkersMatch(ProfileSyncServiceHarness* partner);
99 89
100 // Calling this acts as a barrier and blocks the caller until |this| and 90 // Calling this acts as a barrier and blocks the caller until |this| and
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 // Returns true if encryption is complete for all datatypes, and false 156 // Returns true if encryption is complete for all datatypes, and false
167 // otherwise. 157 // otherwise.
168 bool IsEncryptionComplete() const; 158 bool IsEncryptionComplete() const;
169 159
170 // Check if |type| is registered and the controller is running. 160 // Check if |type| is registered and the controller is running.
171 bool IsTypeRunning(syncer::ModelType type); 161 bool IsTypeRunning(syncer::ModelType type);
172 162
173 // Check if |type| is being synced. 163 // Check if |type| is being synced.
174 bool IsTypePreferred(syncer::ModelType type); 164 bool IsTypePreferred(syncer::ModelType type);
175 165
176 // Returns true if the sync client has no unsynced items.
177 bool IsDataSynced() const;
178
179 // Returns true if the sync client has no unsynced items and its progress
180 // markers are believed to be up to date.
181 //
182 // Although we can't detect when commits from other clients invalidate our
183 // local progress markers, we do know when our own commits have invalidated
184 // our timestmaps. This check returns true when this client has, to the best
185 // of its knowledge, downloaded the latest progress markers.
186 bool IsFullySynced() const;
187
188 // Get the number of sync entries this client has. This includes all top 166 // Get the number of sync entries this client has. This includes all top
189 // level or permanent items, and can include recently deleted entries. 167 // level or permanent items, and can include recently deleted entries.
190 size_t GetNumEntries() const; 168 size_t GetNumEntries() const;
191 169
192 // Get the number of sync datatypes registered (ignoring whatever state 170 // Get the number of sync datatypes registered (ignoring whatever state
193 // they're in). 171 // they're in).
194 size_t GetNumDatatypes() const; 172 size_t GetNumDatatypes() const;
195 173
196 // Gets the |auto_start_enabled_| variable from the |service_|. 174 // Gets the |auto_start_enabled_| variable from the |service_|.
197 bool AutoStartEnabled(); 175 bool AutoStartEnabled();
198 176
177 // Runs the message loop and waits until all in-flight tasks are completed.
178 // Returns true if a steady state was reached within a timeout period, and
179 // false if a timeout was hit.
180 bool AwaitSteadyState();
181
199 // Runs the UI message loop and waits until the Run() method of |checker| 182 // Runs the UI message loop and waits until the Run() method of |checker|
200 // returns true, indicating that the status change we are waiting for has 183 // returns true, indicating that the status change we are waiting for has
201 // taken place. Caller retains ownership of |checker|, which must outlive this 184 // taken place. Caller retains ownership of |checker|, which must outlive this
202 // method. Returns true if the status change was observed. In case of a 185 // method. Returns true if the status change was observed. In case of a
203 // timeout, we log the |source| of the call to this method, and return false. 186 // timeout, we log the |source| of the call to this method, and return false.
204 bool AwaitStatusChange(StatusChangeChecker* checker, 187 bool AwaitStatusChange(StatusChangeChecker* checker,
205 const std::string& source); 188 const std::string& source);
206 189
207 // Returns a string that can be used as the value of an oauth2 refresh token. 190 // Returns a string that can be used as the value of an oauth2 refresh token.
208 // This function guarantees that a different string is returned each time 191 // This function guarantees that a different string is returned each time
209 // it is called. 192 // it is called.
210 std::string GenerateFakeOAuth2RefreshTokenString(); 193 std::string GenerateFakeOAuth2RefreshTokenString();
211 194
212 // Returns a string with relevant info about client's sync state (if 195 // Returns a string with relevant info about client's sync state (if
213 // available), annotated with |message|. Useful for logging. 196 // available), annotated with |message|. Useful for logging.
214 std::string GetClientInfoString(const std::string& message) const; 197 std::string GetClientInfoString(const std::string& message) const;
215 198
216 // Returns true if this client has downloaded all the items that the 199 // Returns true if this client has downloaded all the items that the
217 // other client has. 200 // other client has.
218 bool MatchesPartnerClient() const; 201 bool MatchesPartnerClient() const;
219 202
220 // Returns true if there is a backend migration in progress.
221 bool HasPendingBackendMigration() const;
222
223 private: 203 private:
224 ProfileSyncServiceHarness( 204 ProfileSyncServiceHarness(
225 Profile* profile, 205 Profile* profile,
226 const std::string& username, 206 const std::string& username,
227 const std::string& password, 207 const std::string& password,
228 invalidation::P2PInvalidationService* invalidation_service); 208 invalidation::P2PInvalidationService* invalidation_service);
229 209
210 // Runs the UI message loop. If |quit_when_idle| is true, the loop is quit
211 // soon after in-flight tasks are complete (or a timeout limit is hit).
212 // If |quit_when_idle| is false, the loop is run indefinitely until it is
213 // explicitly quit (or a timeout limit is hit). Returns false if the timeout
214 // limit was hit, and true otherwise.
215 bool RunMessageLoop(bool quit_when_idle);
216
230 // Quits the current message loop. Called when the status change being waited 217 // Quits the current message loop. Called when the status change being waited
231 // on has occurred, or in the event of a timeout. 218 // on has occurred, or in the event of a timeout.
232 void QuitMessageLoop(); 219 void QuitMessageLoop();
233 220
234 // A helper for implementing IsDataSynced() and IsFullySynced().
235 bool IsDataSyncedImpl() const;
236
237 // Signals that sync setup is complete, and that PSS may begin syncing. 221 // Signals that sync setup is complete, and that PSS may begin syncing.
238 void FinishSyncSetup(); 222 void FinishSyncSetup();
239 223
240 // Gets the current progress marker of the current sync session for a 224 // Gets the current progress marker of the current sync session for a
241 // particular datatype. Returns an empty string if the progress marker isn't 225 // particular datatype. Returns an empty string if the progress marker isn't
242 // found. 226 // found.
243 std::string GetSerializedProgressMarker(syncer::ModelType model_type) const; 227 std::string GetSerializedProgressMarker(syncer::ModelType model_type) const;
244 228
229 // Returns true if a client has nothing left to commit and its progress
230 // markers are up to date.
231 bool IsCommitActivityComplete() const;
232
233 // Returns true if sync setup is complete. Called during first time sync setup
234 // and when sync is re-enabled after having been disabled.
235 bool IsSyncSetupComplete() const;
236
245 // Gets detailed status from |service_| in pretty-printable form. 237 // Gets detailed status from |service_| in pretty-printable form.
246 std::string GetServiceStatus(); 238 std::string GetServiceStatus();
247 239
248 // Sync profile associated with this sync client. 240 // Sync profile associated with this sync client.
249 Profile* profile_; 241 Profile* profile_;
250 242
251 // ProfileSyncService object associated with |profile_|. 243 // ProfileSyncService object associated with |profile_|.
252 ProfileSyncService* service_; 244 ProfileSyncService* service_;
253 245
254 // P2PInvalidationService associated with |profile_|. 246 // P2PInvalidationService associated with |profile_|.
(...skipping 15 matching lines...) Expand all
270 const std::string profile_debug_name_; 262 const std::string profile_debug_name_;
271 263
272 // Keeps track of the state change on which we are waiting. PSSHarness can 264 // Keeps track of the state change on which we are waiting. PSSHarness can
273 // wait on only one status change at a time. 265 // wait on only one status change at a time.
274 StatusChangeChecker* status_change_checker_; 266 StatusChangeChecker* status_change_checker_;
275 267
276 DISALLOW_COPY_AND_ASSIGN(ProfileSyncServiceHarness); 268 DISALLOW_COPY_AND_ASSIGN(ProfileSyncServiceHarness);
277 }; 269 };
278 270
279 #endif // CHROME_BROWSER_SYNC_TEST_INTEGRATION_PROFILE_SYNC_SERVICE_HARNESS_H_ 271 #endif // CHROME_BROWSER_SYNC_TEST_INTEGRATION_PROFILE_SYNC_SERVICE_HARNESS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698