OLD | NEW |
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 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 bool AwaitCommitActivityCompletion(); | 81 bool AwaitCommitActivityCompletion(); |
82 | 82 |
83 // Blocks the caller until sync has been disabled for this client. Returns | 83 // Blocks the caller until sync has been disabled for this client. Returns |
84 // true if sync is disabled. | 84 // true if sync is disabled. |
85 bool AwaitSyncDisabled(); | 85 bool AwaitSyncDisabled(); |
86 | 86 |
87 // Blocks the caller until sync setup is complete for this client. Returns | 87 // Blocks the caller until sync setup is complete for this client. Returns |
88 // true if sync setup is complete. | 88 // true if sync setup is complete. |
89 bool AwaitSyncSetupCompletion(); | 89 bool AwaitSyncSetupCompletion(); |
90 | 90 |
91 // Blocks the caller until this harness has observed that the sync engine | |
92 // has downloaded all the changes seen by the |partner| harness's client. | |
93 bool WaitUntilProgressMarkersMatch(ProfileSyncServiceHarness* partner); | |
94 | |
95 // Calling this acts as a barrier and blocks the caller until |this| and | 91 // Calling this acts as a barrier and blocks the caller until |this| and |
96 // |partner| have both completed a sync cycle. When calling this method, | 92 // |partner| have both completed a sync cycle. When calling this method, |
97 // the |partner| should be the passive responder who responds to the actions | 93 // the |partner| should be the passive responder who responds to the actions |
98 // of |this|. This method relies upon the synchronization of callbacks | 94 // of |this|. This method relies upon the synchronization of callbacks |
99 // from the message queue. Returns true if two sync cycles have completed. | 95 // from the message queue. Returns true if two sync cycles have completed. |
100 // Note: Use this method when exactly one client makes local change(s), and | 96 // Note: Use this method when exactly one client makes local change(s), and |
101 // exactly one client is waiting to receive those changes. | 97 // exactly one client is waiting to receive those changes. |
102 bool AwaitMutualSyncCycleCompletion(ProfileSyncServiceHarness* partner); | 98 bool AwaitMutualSyncCycleCompletion(ProfileSyncServiceHarness* partner); |
103 | 99 |
104 // Blocks the caller until |this| completes its ongoing sync cycle and every | 100 // Blocks the caller until |this| completes its ongoing sync cycle and every |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
180 | 176 |
181 // Returns a string that can be used as the value of an oauth2 refresh token. | 177 // Returns a string that can be used as the value of an oauth2 refresh token. |
182 // This function guarantees that a different string is returned each time | 178 // This function guarantees that a different string is returned each time |
183 // it is called. | 179 // it is called. |
184 std::string GenerateFakeOAuth2RefreshTokenString(); | 180 std::string GenerateFakeOAuth2RefreshTokenString(); |
185 | 181 |
186 // Returns a string with relevant info about client's sync state (if | 182 // Returns a string with relevant info about client's sync state (if |
187 // available), annotated with |message|. Useful for logging. | 183 // available), annotated with |message|. Useful for logging. |
188 std::string GetClientInfoString(const std::string& message) const; | 184 std::string GetClientInfoString(const std::string& message) const; |
189 | 185 |
190 // Returns true if this client has downloaded all the items that the | |
191 // other client has. | |
192 bool MatchesPartnerClient() const; | |
193 | |
194 private: | 186 private: |
195 ProfileSyncServiceHarness( | 187 ProfileSyncServiceHarness( |
196 Profile* profile, | 188 Profile* profile, |
197 const std::string& username, | 189 const std::string& username, |
198 const std::string& password, | 190 const std::string& password, |
199 invalidation::P2PInvalidationService* invalidation_service); | 191 invalidation::P2PInvalidationService* invalidation_service); |
200 | 192 |
201 // Quits the current message loop. Called when the status change being waited | 193 // Quits the current message loop. Called when the status change being waited |
202 // on has occurred, or in the event of a timeout. | 194 // on has occurred, or in the event of a timeout. |
203 void QuitMessageLoop(); | 195 void QuitMessageLoop(); |
204 | 196 |
205 // Signals that sync setup is complete, and that PSS may begin syncing. | 197 // Signals that sync setup is complete, and that PSS may begin syncing. |
206 void FinishSyncSetup(); | 198 void FinishSyncSetup(); |
207 | 199 |
208 // Gets the current progress marker of the current sync session for a | 200 // Gets the current progress marker of the current sync session for a |
209 // particular datatype. Returns an empty string if the progress marker isn't | 201 // particular datatype. Returns an empty string if the progress marker isn't |
210 // found. | 202 // found. |
211 std::string GetSerializedProgressMarker(syncer::ModelType model_type) const; | 203 std::string GetSerializedProgressMarker(syncer::ModelType model_type) const; |
212 | 204 |
213 // Returns true if a client has nothing left to commit and its progress | |
214 // markers are up to date. | |
215 bool HasLatestProgressMarkers() const; | |
216 | |
217 // Gets detailed status from |service_| in pretty-printable form. | 205 // Gets detailed status from |service_| in pretty-printable form. |
218 std::string GetServiceStatus(); | 206 std::string GetServiceStatus(); |
219 | 207 |
220 // Sync profile associated with this sync client. | 208 // Sync profile associated with this sync client. |
221 Profile* profile_; | 209 Profile* profile_; |
222 | 210 |
223 // ProfileSyncService object associated with |profile_|. | 211 // ProfileSyncService object associated with |profile_|. |
224 ProfileSyncService* service_; | 212 ProfileSyncService* service_; |
225 | 213 |
226 // An bridge between the ProfileSyncService and P2PInvalidationService. | 214 // An bridge between the ProfileSyncService and P2PInvalidationService. |
227 scoped_ptr<P2PInvalidationForwarder> p2p_invalidation_forwarder_; | 215 scoped_ptr<P2PInvalidationForwarder> p2p_invalidation_forwarder_; |
228 | 216 |
229 // The harness of the client whose update progress marker we're expecting | |
230 // eventually match. | |
231 ProfileSyncServiceHarness* progress_marker_partner_; | |
232 | |
233 // Credentials used for GAIA authentication. | 217 // Credentials used for GAIA authentication. |
234 std::string username_; | 218 std::string username_; |
235 std::string password_; | 219 std::string password_; |
236 | 220 |
237 // Number used by GenerateFakeOAuth2RefreshTokenString() to make sure that | 221 // Number used by GenerateFakeOAuth2RefreshTokenString() to make sure that |
238 // all refresh tokens used in the tests are different. | 222 // all refresh tokens used in the tests are different. |
239 int oauth2_refesh_token_number_; | 223 int oauth2_refesh_token_number_; |
240 | 224 |
241 // Used for logging. | 225 // Used for logging. |
242 const std::string profile_debug_name_; | 226 const std::string profile_debug_name_; |
243 | 227 |
244 // Keeps track of the state change on which we are waiting. PSSHarness can | 228 // Keeps track of the state change on which we are waiting. PSSHarness can |
245 // wait on only one status change at a time. | 229 // wait on only one status change at a time. |
246 StatusChangeChecker* status_change_checker_; | 230 StatusChangeChecker* status_change_checker_; |
247 | 231 |
248 DISALLOW_COPY_AND_ASSIGN(ProfileSyncServiceHarness); | 232 DISALLOW_COPY_AND_ASSIGN(ProfileSyncServiceHarness); |
249 }; | 233 }; |
250 | 234 |
251 #endif // CHROME_BROWSER_SYNC_TEST_INTEGRATION_PROFILE_SYNC_SERVICE_HARNESS_H_ | 235 #endif // CHROME_BROWSER_SYNC_TEST_INTEGRATION_PROFILE_SYNC_SERVICE_HARNESS_H_ |
OLD | NEW |