OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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_TEST_LIVE_SYNC_PROFILE_SYNC_SERVICE_TEST_HARNESS_H_ | 5 #ifndef CHROME_TEST_LIVE_SYNC_PROFILE_SYNC_SERVICE_TEST_HARNESS_H_ |
6 #define CHROME_TEST_LIVE_SYNC_PROFILE_SYNC_SERVICE_TEST_HARNESS_H_ | 6 #define CHROME_TEST_LIVE_SYNC_PROFILE_SYNC_SERVICE_TEST_HARNESS_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 13 matching lines...) Expand all Loading... |
24 class ProfileSyncServiceTestHarness : public ProfileSyncServiceObserver { | 24 class ProfileSyncServiceTestHarness : public ProfileSyncServiceObserver { |
25 public: | 25 public: |
26 ProfileSyncServiceTestHarness(Profile* p, const std::string& username, | 26 ProfileSyncServiceTestHarness(Profile* p, const std::string& username, |
27 const std::string& password); | 27 const std::string& password); |
28 | 28 |
29 // Creates a ProfileSyncService for the profile passed at construction and | 29 // Creates a ProfileSyncService for the profile passed at construction and |
30 // enables sync. Returns true only after sync has been fully initialized and | 30 // enables sync. Returns true only after sync has been fully initialized and |
31 // authenticated, and we are ready to process changes. | 31 // authenticated, and we are ready to process changes. |
32 bool SetupSync(); | 32 bool SetupSync(); |
33 | 33 |
| 34 // Retries a sync setup when the previous attempt was aborted by an |
| 35 // authentication failure. |
| 36 bool RetryAuthentication(); |
| 37 |
34 // ProfileSyncServiceObserver implementation. | 38 // ProfileSyncServiceObserver implementation. |
35 virtual void OnStateChanged(); | 39 virtual void OnStateChanged(); |
36 | 40 |
37 // Blocks the caller until this harness has completed a single sync cycle | 41 // Blocks the caller until this harness has completed a single sync cycle |
38 // since the previous one. Returns true if a sync cycle has completed. | 42 // since the previous one. Returns true if a sync cycle has completed. |
39 bool AwaitSyncCycleCompletion(const std::string& reason); | 43 bool AwaitSyncCycleCompletion(const std::string& reason); |
40 | 44 |
41 // Blocks the caller until this harness has observed that the sync engine | 45 // Blocks the caller until this harness has observed that the sync engine |
42 // has "synced" up to at least the specified local timestamp. | 46 // has "synced" up to at least the specified local timestamp. |
43 bool WaitUntilTimestampIsAtLeast(int64 timestamp, const std::string& reason); | 47 bool WaitUntilTimestampIsAtLeast(int64 timestamp, const std::string& reason); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 // The sync client awaits the OnBackendInitialized() callback. | 84 // The sync client awaits the OnBackendInitialized() callback. |
81 WAITING_FOR_ON_BACKEND_INITIALIZED, | 85 WAITING_FOR_ON_BACKEND_INITIALIZED, |
82 // The sync client is waiting for notifications_enabled to become true. | 86 // The sync client is waiting for notifications_enabled to become true. |
83 WAITING_FOR_NOTIFICATIONS_ENABLED, | 87 WAITING_FOR_NOTIFICATIONS_ENABLED, |
84 // The sync client is waiting for an ongoing sync cycle to complete. | 88 // The sync client is waiting for an ongoing sync cycle to complete. |
85 WAITING_FOR_SYNC_TO_FINISH, | 89 WAITING_FOR_SYNC_TO_FINISH, |
86 // The sync client anticipates incoming updates leading to a new sync cycle. | 90 // The sync client anticipates incoming updates leading to a new sync cycle. |
87 WAITING_FOR_UPDATES, | 91 WAITING_FOR_UPDATES, |
88 // The sync client is fully synced and there are no pending updates. | 92 // The sync client is fully synced and there are no pending updates. |
89 FULLY_SYNCED, | 93 FULLY_SYNCED, |
90 NUMBER_OF_STATES | 94 // An authentication error has occurred. |
| 95 AUTH_ERROR, |
| 96 NUMBER_OF_STATES, |
91 }; | 97 }; |
92 | 98 |
93 // Called from the observer when the current wait state has been completed. | 99 // Called from the observer when the current wait state has been completed. |
94 void SignalStateCompleteWithNextState(WaitState next_state); | 100 void SignalStateCompleteWithNextState(WaitState next_state); |
95 void SignalStateComplete(); | 101 void SignalStateComplete(); |
96 | 102 |
97 // Finite state machine for controlling state. Returns true only if a state | 103 // Finite state machine for controlling state. Returns true only if a state |
98 // change has taken place. | 104 // change has taken place. |
99 bool RunStateChangeMachine(); | 105 bool RunStateChangeMachine(); |
100 | 106 |
101 // Returns true if a status change took place, false on timeout. | 107 // Returns true if a status change took place, false on timeout. |
102 virtual bool AwaitStatusChangeWithTimeout(int timeout_seconds, | 108 virtual bool AwaitStatusChangeWithTimeout(int timeout_seconds, |
103 const std::string& reason); | 109 const std::string& reason); |
104 | 110 |
105 // Returns true if the service initialized correctly. | 111 // Returns true if the service initialized correctly. Set |
106 bool WaitForServiceInit(); | 112 // is_auth_retry to true when calling this method second time after |
| 113 // an autentication failure. |
| 114 bool WaitForServiceInit(bool is_auth_retry); |
107 | 115 |
108 WaitState wait_state_; | 116 WaitState wait_state_; |
109 | 117 |
110 Profile* profile_; | 118 Profile* profile_; |
111 ProfileSyncService* service_; | 119 ProfileSyncService* service_; |
112 | 120 |
113 // Returns a snapshot of the current sync session. | 121 // Returns a snapshot of the current sync session. |
114 const SyncSessionSnapshot* GetLastSessionSnapshot() const; | 122 const SyncSessionSnapshot* GetLastSessionSnapshot() const; |
115 | 123 |
116 // State tracking. Used for debugging and tracking of state. | 124 // State tracking. Used for debugging and tracking of state. |
(...skipping 10 matching lines...) Expand all Loading... |
127 int64 min_timestamp_needed_; | 135 int64 min_timestamp_needed_; |
128 | 136 |
129 // Credentials used for GAIA authentication. | 137 // Credentials used for GAIA authentication. |
130 std::string username_; | 138 std::string username_; |
131 std::string password_; | 139 std::string password_; |
132 | 140 |
133 DISALLOW_COPY_AND_ASSIGN(ProfileSyncServiceTestHarness); | 141 DISALLOW_COPY_AND_ASSIGN(ProfileSyncServiceTestHarness); |
134 }; | 142 }; |
135 | 143 |
136 #endif // CHROME_TEST_LIVE_SYNC_PROFILE_SYNC_SERVICE_TEST_HARNESS_H_ | 144 #endif // CHROME_TEST_LIVE_SYNC_PROFILE_SYNC_SERVICE_TEST_HARNESS_H_ |
OLD | NEW |