| 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 <memory> | 8 #include <memory> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| 11 | 11 |
| 12 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
| 13 #include "base/macros.h" | 13 #include "base/macros.h" |
| 14 #include "components/sync/base/model_type.h" | 14 #include "components/sync/base/model_type.h" |
| 15 #include "components/sync/engine/cycle/sync_cycle_snapshot.h" | 15 #include "components/sync/engine/cycle/sync_cycle_snapshot.h" |
| 16 | 16 |
| 17 class Profile; | 17 class Profile; |
| 18 | 18 |
| 19 namespace browser_sync { | 19 namespace browser_sync { |
| 20 class ProfileSyncService; | 20 class ProfileSyncService; |
| 21 } // namespace browser_sync | 21 } // namespace browser_sync |
| 22 | 22 |
| 23 namespace syncer { | |
| 24 class SyncSetupInProgressHandle; | |
| 25 } // namespace syncer | |
| 26 | |
| 27 // An instance of this class is basically our notion of a "sync client" for | 23 // An instance of this class is basically our notion of a "sync client" for |
| 28 // automation purposes. It harnesses the ProfileSyncService member of the | 24 // automation purposes. It harnesses the ProfileSyncService member of the |
| 29 // profile passed to it on construction and automates certain things like setup | 25 // profile passed to it on construction and automates certain things like setup |
| 30 // and authentication. It provides ways to "wait" adequate periods of time for | 26 // and authentication. It provides ways to "wait" adequate periods of time for |
| 31 // several clients to get to the same state. | 27 // several clients to get to the same state. |
| 32 class ProfileSyncServiceHarness { | 28 class ProfileSyncServiceHarness { |
| 33 public: | 29 public: |
| 34 // The type of profile signin method to authenticate a profile. | 30 // The type of profile signin method to authenticate a profile. |
| 35 enum class SigninType { | 31 enum class SigninType { |
| 36 // Fakes user signin process. | 32 // Fakes user signin process. |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 119 | 115 |
| 120 // Returns a string that can be used as the value of an oauth2 refresh token. | 116 // Returns a string that can be used as the value of an oauth2 refresh token. |
| 121 // This function guarantees that a different string is returned each time | 117 // This function guarantees that a different string is returned each time |
| 122 // it is called. | 118 // it is called. |
| 123 std::string GenerateFakeOAuth2RefreshTokenString(); | 119 std::string GenerateFakeOAuth2RefreshTokenString(); |
| 124 | 120 |
| 125 // Returns a string with relevant info about client's sync state (if | 121 // Returns a string with relevant info about client's sync state (if |
| 126 // available), annotated with |message|. Useful for logging. | 122 // available), annotated with |message|. Useful for logging. |
| 127 std::string GetClientInfoString(const std::string& message) const; | 123 std::string GetClientInfoString(const std::string& message) const; |
| 128 | 124 |
| 129 // Signals that sync setup is complete, and that PSS may begin syncing. | |
| 130 void FinishSyncSetup(); | |
| 131 | |
| 132 private: | 125 private: |
| 133 ProfileSyncServiceHarness( | 126 ProfileSyncServiceHarness( |
| 134 Profile* profile, | 127 Profile* profile, |
| 135 const std::string& username, | 128 const std::string& username, |
| 136 const std::string& password, | 129 const std::string& password, |
| 137 SigninType signin_type); | 130 SigninType signin_type); |
| 138 | 131 |
| 139 // Gets detailed status from |service_| in pretty-printable form. | 132 // Gets detailed status from |service_| in pretty-printable form. |
| 140 std::string GetServiceStatus(); | 133 std::string GetServiceStatus(); |
| 141 | 134 |
| 142 // Returns true if sync is disabled for this client. | 135 // Returns true if sync is disabled for this client. |
| 143 bool IsSyncDisabled() const; | 136 bool IsSyncDisabled() const; |
| 144 | 137 |
| 145 // Sync profile associated with this sync client. | 138 // Sync profile associated with this sync client. |
| 146 Profile* profile_; | 139 Profile* profile_; |
| 147 | 140 |
| 148 // ProfileSyncService object associated with |profile_|. | 141 // ProfileSyncService object associated with |profile_|. |
| 149 browser_sync::ProfileSyncService* service_; | 142 browser_sync::ProfileSyncService* service_; |
| 150 | 143 |
| 151 // Prevents Sync from running until configuration is complete. | |
| 152 std::unique_ptr<syncer::SyncSetupInProgressHandle> sync_blocker_; | |
| 153 | |
| 154 // Credentials used for GAIA authentication. | 144 // Credentials used for GAIA authentication. |
| 155 std::string username_; | 145 std::string username_; |
| 156 std::string password_; | 146 std::string password_; |
| 157 | 147 |
| 158 // Used to decide what method of profile signin to use. | 148 // Used to decide what method of profile signin to use. |
| 159 const SigninType signin_type_; | 149 const SigninType signin_type_; |
| 160 | 150 |
| 161 // Number used by GenerateFakeOAuth2RefreshTokenString() to make sure that | 151 // Number used by GenerateFakeOAuth2RefreshTokenString() to make sure that |
| 162 // all refresh tokens used in the tests are different. | 152 // all refresh tokens used in the tests are different. |
| 163 int oauth2_refesh_token_number_; | 153 int oauth2_refesh_token_number_; |
| 164 | 154 |
| 165 // Used for logging. | 155 // Used for logging. |
| 166 const std::string profile_debug_name_; | 156 const std::string profile_debug_name_; |
| 167 | 157 |
| 168 DISALLOW_COPY_AND_ASSIGN(ProfileSyncServiceHarness); | 158 DISALLOW_COPY_AND_ASSIGN(ProfileSyncServiceHarness); |
| 169 }; | 159 }; |
| 170 | 160 |
| 171 #endif // CHROME_BROWSER_SYNC_TEST_INTEGRATION_PROFILE_SYNC_SERVICE_HARNESS_H_ | 161 #endif // CHROME_BROWSER_SYNC_TEST_INTEGRATION_PROFILE_SYNC_SERVICE_HARNESS_H_ |
| OLD | NEW |