OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_PROFILE_SYNC_SERVICE_HARNESS_H_ | 5 #ifndef CHROME_BROWSER_SYNC_PROFILE_SYNC_SERVICE_HARNESS_H_ |
6 #define CHROME_BROWSER_SYNC_PROFILE_SYNC_SERVICE_HARNESS_H_ | 6 #define CHROME_BROWSER_SYNC_PROFILE_SYNC_SERVICE_HARNESS_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 14 matching lines...) Expand all Loading... |
25 | 25 |
26 // An instance of this class is basically our notion of a "sync client" for | 26 // An instance of this class is basically our notion of a "sync client" for |
27 // automation purposes. It harnesses the ProfileSyncService member of the | 27 // automation purposes. It harnesses the ProfileSyncService member of the |
28 // profile passed to it on construction and automates certain things like setup | 28 // profile passed to it on construction and automates certain things like setup |
29 // and authentication. It provides ways to "wait" adequate periods of time for | 29 // and authentication. It provides ways to "wait" adequate periods of time for |
30 // several clients to get to the same state. | 30 // several clients to get to the same state. |
31 class ProfileSyncServiceHarness : public ProfileSyncServiceObserver { | 31 class ProfileSyncServiceHarness : public ProfileSyncServiceObserver { |
32 public: | 32 public: |
33 ProfileSyncServiceHarness(Profile* profile, | 33 ProfileSyncServiceHarness(Profile* profile, |
34 const std::string& username, | 34 const std::string& username, |
35 const std::string& password, | 35 const std::string& password); |
36 bool expected_notifications_enabled); | |
37 | 36 |
38 virtual ~ProfileSyncServiceHarness(); | 37 virtual ~ProfileSyncServiceHarness(); |
39 | 38 |
40 // Creates a ProfileSyncServiceHarness object and attaches it to |profile|, a | 39 // Creates a ProfileSyncServiceHarness object and attaches it to |profile|, a |
41 // profile that is assumed to have been signed into sync in the past. Caller | 40 // profile that is assumed to have been signed into sync in the past. Caller |
42 // takes ownership. | 41 // takes ownership. |
43 static ProfileSyncServiceHarness* CreateAndAttach(Profile* profile); | 42 static ProfileSyncServiceHarness* CreateAndAttach(Profile* profile); |
44 | 43 |
45 // Sets the GAIA credentials with which to sign in to sync. | 44 // Sets the GAIA credentials with which to sign in to sync. |
46 void SetCredentials(const std::string& username, const std::string& password); | 45 void SetCredentials(const std::string& username, const std::string& password); |
(...skipping 20 matching lines...) Expand all Loading... |
67 | 66 |
68 // Blocks the caller until the datatype manager is configured and sync has | 67 // Blocks the caller until the datatype manager is configured and sync has |
69 // been initialized (for example, after a browser restart). Returns true if | 68 // been initialized (for example, after a browser restart). Returns true if |
70 // the wait was successful. | 69 // the wait was successful. |
71 bool AwaitSyncRestart(); | 70 bool AwaitSyncRestart(); |
72 | 71 |
73 // Blocks the caller until this harness has completed a single sync cycle | 72 // Blocks the caller until this harness has completed a single sync cycle |
74 // since the previous one. Returns true if a sync cycle has completed. | 73 // since the previous one. Returns true if a sync cycle has completed. |
75 bool AwaitSyncCycleCompletion(const std::string& reason); | 74 bool AwaitSyncCycleCompletion(const std::string& reason); |
76 | 75 |
| 76 // Blocks the caller until this harness has completed a single sync |
| 77 // cycle, even if we're already synced. Returns true if a sync |
| 78 // cycle has completed. |
| 79 // |
| 80 // TODO(akalin): This is only used by some migration tests, pending |
| 81 // the fix for http://crbug.com/92928. Remove this once that is |
| 82 // fixed. |
| 83 bool AwaitNextSyncCycleCompletion(const std::string& reason); |
| 84 |
77 // Blocks the caller until the sync has been disabled for this client. Returns | 85 // Blocks the caller until the sync has been disabled for this client. Returns |
78 // true if sync is disabled. | 86 // true if sync is disabled. |
79 bool AwaitSyncDisabled(const std::string& reason); | 87 bool AwaitSyncDisabled(const std::string& reason); |
80 | 88 |
81 // Blocks the caller until exponential backoff has been verified to happen. | 89 // Blocks the caller until exponential backoff has been verified to happen. |
82 bool AwaitExponentialBackoffVerification(); | 90 bool AwaitExponentialBackoffVerification(); |
83 | 91 |
84 // Blocks the caller until this harness has observed that the sync engine | 92 // Blocks the caller until this harness has observed that the sync engine |
85 // has downloaded all the changes seen by the |partner| harness's client. | 93 // has downloaded all the changes seen by the |partner| harness's client. |
86 bool WaitUntilTimestampMatches( | 94 bool WaitUntilTimestampMatches( |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
231 void SignalStateComplete(); | 239 void SignalStateComplete(); |
232 | 240 |
233 // Finite state machine for controlling state. Returns true only if a state | 241 // Finite state machine for controlling state. Returns true only if a state |
234 // change has taken place. | 242 // change has taken place. |
235 bool RunStateChangeMachine(); | 243 bool RunStateChangeMachine(); |
236 | 244 |
237 // Returns true if a status change took place, false on timeout. | 245 // Returns true if a status change took place, false on timeout. |
238 bool AwaitStatusChangeWithTimeout(int timeout_milliseconds, | 246 bool AwaitStatusChangeWithTimeout(int timeout_milliseconds, |
239 const std::string& reason); | 247 const std::string& reason); |
240 | 248 |
| 249 // Used by AwaitSyncCycleCompletion() and |
| 250 // AwaitNextSyncCycleCompletion(). |
| 251 bool AwaitSyncCycleCompletionHelper(const std::string& reason); |
| 252 |
241 // Returns true if the sync client has no unsynced items. | 253 // Returns true if the sync client has no unsynced items. |
242 bool IsSynced(); | 254 bool IsSynced(); |
243 | 255 |
244 // Returns true if this client has downloaded all the items that the | 256 // Returns true if this client has downloaded all the items that the |
245 // other client has. | 257 // other client has. |
246 bool MatchesOtherClient(ProfileSyncServiceHarness* partner); | 258 bool MatchesOtherClient(ProfileSyncServiceHarness* partner); |
247 | 259 |
248 // Returns a string with relevant info about client's sync state (if | 260 // Returns a string with relevant info about client's sync state (if |
249 // available), annotated with |message|. Useful for logging. | 261 // available), annotated with |message|. Useful for logging. |
250 std::string GetClientInfoString(const std::string& message); | 262 std::string GetClientInfoString(const std::string& message); |
(...skipping 20 matching lines...) Expand all Loading... |
271 ProfileSyncService* service_; | 283 ProfileSyncService* service_; |
272 | 284 |
273 // The harness of the client whose update progress marker we're expecting | 285 // The harness of the client whose update progress marker we're expecting |
274 // eventually match. | 286 // eventually match. |
275 ProfileSyncServiceHarness* timestamp_match_partner_; | 287 ProfileSyncServiceHarness* timestamp_match_partner_; |
276 | 288 |
277 // Credentials used for GAIA authentication. | 289 // Credentials used for GAIA authentication. |
278 std::string username_; | 290 std::string username_; |
279 std::string password_; | 291 std::string password_; |
280 | 292 |
281 // The expected value of GetStatus().notifications_enabled. | |
282 bool expected_notifications_enabled_; | |
283 | |
284 // Used for logging. | 293 // Used for logging. |
285 const std::string profile_debug_name_; | 294 const std::string profile_debug_name_; |
286 | 295 |
287 // Keeps track of the number of attempts at exponential backoff and its | 296 // Keeps track of the number of attempts at exponential backoff and its |
288 // related bookkeeping information for verification. | 297 // related bookkeeping information for verification. |
289 browser_sync::RetryVerifier retry_verifier_; | 298 browser_sync::RetryVerifier retry_verifier_; |
290 | 299 |
291 DISALLOW_COPY_AND_ASSIGN(ProfileSyncServiceHarness); | 300 DISALLOW_COPY_AND_ASSIGN(ProfileSyncServiceHarness); |
292 }; | 301 }; |
293 | 302 |
294 #endif // CHROME_BROWSER_SYNC_PROFILE_SYNC_SERVICE_HARNESS_H_ | 303 #endif // CHROME_BROWSER_SYNC_PROFILE_SYNC_SERVICE_HARNESS_H_ |
OLD | NEW |