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

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: Address feedback 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
86 // Blocks the caller until sync setup is complete for this client. Returns
87 // true if sync setup is complete.
88 bool AwaitSyncSetupCompletion();
89
96 // Blocks the caller until this harness has observed that the sync engine 90 // 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. 91 // has downloaded all the changes seen by the |partner| harness's client.
98 bool WaitUntilProgressMarkersMatch(ProfileSyncServiceHarness* partner); 92 bool WaitUntilProgressMarkersMatch(ProfileSyncServiceHarness* partner);
99 93
100 // Calling this acts as a barrier and blocks the caller until |this| and 94 // Calling this acts as a barrier and blocks the caller until |this| and
101 // |partner| have both completed a sync cycle. When calling this method, 95 // |partner| have both completed a sync cycle. When calling this method,
102 // the |partner| should be the passive responder who responds to the actions 96 // the |partner| should be the passive responder who responds to the actions
103 // of |this|. This method relies upon the synchronization of callbacks 97 // of |this|. This method relies upon the synchronization of callbacks
104 // from the message queue. Returns true if two sync cycles have completed. 98 // from the message queue. Returns true if two sync cycles have completed.
105 // Note: Use this method when exactly one client makes local change(s), and 99 // Note: Use this method when exactly one client makes local change(s), and
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 // Returns true if encryption is complete for all datatypes, and false 160 // Returns true if encryption is complete for all datatypes, and false
167 // otherwise. 161 // otherwise.
168 bool IsEncryptionComplete() const; 162 bool IsEncryptionComplete() const;
169 163
170 // Check if |type| is registered and the controller is running. 164 // Check if |type| is registered and the controller is running.
171 bool IsTypeRunning(syncer::ModelType type); 165 bool IsTypeRunning(syncer::ModelType type);
172 166
173 // Check if |type| is being synced. 167 // Check if |type| is being synced.
174 bool IsTypePreferred(syncer::ModelType type); 168 bool IsTypePreferred(syncer::ModelType type);
175 169
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 170 // Get the number of sync entries this client has. This includes all top
189 // level or permanent items, and can include recently deleted entries. 171 // level or permanent items, and can include recently deleted entries.
190 size_t GetNumEntries() const; 172 size_t GetNumEntries() const;
191 173
192 // Get the number of sync datatypes registered (ignoring whatever state 174 // Get the number of sync datatypes registered (ignoring whatever state
193 // they're in). 175 // they're in).
194 size_t GetNumDatatypes() const; 176 size_t GetNumDatatypes() const;
195 177
196 // Gets the |auto_start_enabled_| variable from the |service_|. 178 // Gets the |auto_start_enabled_| variable from the |service_|.
197 bool AutoStartEnabled(); 179 bool AutoStartEnabled();
(...skipping 12 matching lines...) Expand all
210 std::string GenerateFakeOAuth2RefreshTokenString(); 192 std::string GenerateFakeOAuth2RefreshTokenString();
211 193
212 // Returns a string with relevant info about client's sync state (if 194 // Returns a string with relevant info about client's sync state (if
213 // available), annotated with |message|. Useful for logging. 195 // available), annotated with |message|. Useful for logging.
214 std::string GetClientInfoString(const std::string& message) const; 196 std::string GetClientInfoString(const std::string& message) const;
215 197
216 // Returns true if this client has downloaded all the items that the 198 // Returns true if this client has downloaded all the items that the
217 // other client has. 199 // other client has.
218 bool MatchesPartnerClient() const; 200 bool MatchesPartnerClient() const;
219 201
220 // Returns true if there is a backend migration in progress.
221 bool HasPendingBackendMigration() const;
222
223 private: 202 private:
224 ProfileSyncServiceHarness( 203 ProfileSyncServiceHarness(
225 Profile* profile, 204 Profile* profile,
226 const std::string& username, 205 const std::string& username,
227 const std::string& password, 206 const std::string& password,
228 invalidation::P2PInvalidationService* invalidation_service); 207 invalidation::P2PInvalidationService* invalidation_service);
229 208
230 // Quits the current message loop. Called when the status change being waited 209 // Quits the current message loop. Called when the status change being waited
231 // on has occurred, or in the event of a timeout. 210 // on has occurred, or in the event of a timeout.
232 void QuitMessageLoop(); 211 void QuitMessageLoop();
233 212
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. 213 // Signals that sync setup is complete, and that PSS may begin syncing.
238 void FinishSyncSetup(); 214 void FinishSyncSetup();
239 215
240 // Gets the current progress marker of the current sync session for a 216 // 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 217 // particular datatype. Returns an empty string if the progress marker isn't
242 // found. 218 // found.
243 std::string GetSerializedProgressMarker(syncer::ModelType model_type) const; 219 std::string GetSerializedProgressMarker(syncer::ModelType model_type) const;
244 220
221 // Returns true if a client has nothing left to commit and its progress
222 // markers are up to date.
223 bool HasLatestProgressMarkers() const;
224
245 // Gets detailed status from |service_| in pretty-printable form. 225 // Gets detailed status from |service_| in pretty-printable form.
246 std::string GetServiceStatus(); 226 std::string GetServiceStatus();
247 227
248 // Sync profile associated with this sync client. 228 // Sync profile associated with this sync client.
249 Profile* profile_; 229 Profile* profile_;
250 230
251 // ProfileSyncService object associated with |profile_|. 231 // ProfileSyncService object associated with |profile_|.
252 ProfileSyncService* service_; 232 ProfileSyncService* service_;
253 233
254 // P2PInvalidationService associated with |profile_|. 234 // P2PInvalidationService associated with |profile_|.
(...skipping 15 matching lines...) Expand all
270 const std::string profile_debug_name_; 250 const std::string profile_debug_name_;
271 251
272 // Keeps track of the state change on which we are waiting. PSSHarness can 252 // Keeps track of the state change on which we are waiting. PSSHarness can
273 // wait on only one status change at a time. 253 // wait on only one status change at a time.
274 StatusChangeChecker* status_change_checker_; 254 StatusChangeChecker* status_change_checker_;
275 255
276 DISALLOW_COPY_AND_ASSIGN(ProfileSyncServiceHarness); 256 DISALLOW_COPY_AND_ASSIGN(ProfileSyncServiceHarness);
277 }; 257 };
278 258
279 #endif // CHROME_BROWSER_SYNC_TEST_INTEGRATION_PROFILE_SYNC_SERVICE_HARNESS_H_ 259 #endif // CHROME_BROWSER_SYNC_TEST_INTEGRATION_PROFILE_SYNC_SERVICE_HARNESS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698