OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #include "base/prefs/pref_member.h" | 5 #include "base/prefs/pref_member.h" |
6 #include "base/prefs/pref_service.h" | 6 #include "base/prefs/pref_service.h" |
7 #include "base/run_loop.h" | 7 #include "base/run_loop.h" |
8 #include "chrome/browser/sync/profile_sync_service.h" | 8 #include "chrome/browser/sync/profile_sync_service.h" |
9 #include "chrome/browser/sync/test/integration/bookmarks_helper.h" | 9 #include "chrome/browser/sync/test/integration/bookmarks_helper.h" |
10 #include "chrome/browser/sync/test/integration/passwords_helper.h" | 10 #include "chrome/browser/sync/test/integration/passwords_helper.h" |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 | 69 |
70 class SyncErrorTest : public SyncTest { | 70 class SyncErrorTest : public SyncTest { |
71 public: | 71 public: |
72 SyncErrorTest() : SyncTest(SINGLE_CLIENT) {} | 72 SyncErrorTest() : SyncTest(SINGLE_CLIENT) {} |
73 virtual ~SyncErrorTest() {} | 73 virtual ~SyncErrorTest() {} |
74 | 74 |
75 private: | 75 private: |
76 DISALLOW_COPY_AND_ASSIGN(SyncErrorTest); | 76 DISALLOW_COPY_AND_ASSIGN(SyncErrorTest); |
77 }; | 77 }; |
78 | 78 |
79 // TODO(pvalenzuela): Remove this class when all tests here are converted to | |
80 // use FakeServer. | |
81 class LegacySyncErrorTest : public SyncTest { | |
82 public: | |
83 LegacySyncErrorTest() : SyncTest(SINGLE_CLIENT_LEGACY) {} | |
84 virtual ~LegacySyncErrorTest() {} | |
85 | |
86 private: | |
87 DISALLOW_COPY_AND_ASSIGN(LegacySyncErrorTest); | |
88 }; | |
89 | |
90 // Helper class that waits until the sync engine has hit an actionable error. | 79 // Helper class that waits until the sync engine has hit an actionable error. |
91 class ActionableErrorChecker : public SingleClientStatusChangeChecker { | 80 class ActionableErrorChecker : public SingleClientStatusChangeChecker { |
92 public: | 81 public: |
93 explicit ActionableErrorChecker(ProfileSyncService* service) | 82 explicit ActionableErrorChecker(ProfileSyncService* service) |
94 : SingleClientStatusChangeChecker(service) {} | 83 : SingleClientStatusChangeChecker(service) {} |
95 | 84 |
96 virtual ~ActionableErrorChecker() {} | 85 virtual ~ActionableErrorChecker() {} |
97 | 86 |
98 // Checks if an actionable error has been hit. Called repeatedly each time PSS | 87 // Checks if an actionable error has been hit. Called repeatedly each time PSS |
99 // notifies observers of a state change. | 88 // notifies observers of a state change. |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
152 ASSERT_FALSE(actionable_error_checker.TimedOut()); | 141 ASSERT_FALSE(actionable_error_checker.TimedOut()); |
153 | 142 |
154 ProfileSyncService::Status status; | 143 ProfileSyncService::Status status; |
155 GetSyncService((0))->QueryDetailedSyncStatus(&status); | 144 GetSyncService((0))->QueryDetailedSyncStatus(&status); |
156 ASSERT_EQ(status.sync_protocol_error.error_type, syncer::TRANSIENT_ERROR); | 145 ASSERT_EQ(status.sync_protocol_error.error_type, syncer::TRANSIENT_ERROR); |
157 ASSERT_EQ(status.sync_protocol_error.action, syncer::UPGRADE_CLIENT); | 146 ASSERT_EQ(status.sync_protocol_error.action, syncer::UPGRADE_CLIENT); |
158 ASSERT_EQ(status.sync_protocol_error.url, url); | 147 ASSERT_EQ(status.sync_protocol_error.url, url); |
159 ASSERT_EQ(status.sync_protocol_error.error_description, description); | 148 ASSERT_EQ(status.sync_protocol_error.error_description, description); |
160 } | 149 } |
161 | 150 |
162 // Disabled, http://crbug.com/351160 . | 151 // TODO(sync): Fix failing test on Chrome OS: http://crbug.com/351160 |
163 IN_PROC_BROWSER_TEST_F(LegacySyncErrorTest, DISABLED_ErrorWhileSettingUp) { | 152 IN_PROC_BROWSER_TEST_F(SyncErrorTest, DISABLED_ErrorWhileSettingUpAutoStart) { |
164 ASSERT_TRUE(SetupClients()); | 153 ASSERT_TRUE(SetupClients()); |
| 154 ASSERT_TRUE(GetSyncService(0)->auto_start_enabled()); |
165 | 155 |
166 syncer::SyncProtocolError protocol_error; | 156 // In auto start enabled platforms like chrome os we should be |
167 protocol_error.error_type = syncer::TRANSIENT_ERROR; | 157 // able to set up even if the first sync while setting up fails. |
168 protocol_error.error_description = "Not My Fault"; | 158 EXPECT_TRUE(GetFakeServer()->TriggerError( |
169 protocol_error.url = "www.google.com"; | 159 sync_pb::SyncEnums::TRANSIENT_ERROR)); |
170 | 160 EXPECT_TRUE(GetFakeServer()->EnableAlternatingTriggeredErrors()); |
171 if (GetSyncService(0)->auto_start_enabled()) { | 161 // Now setup sync and it should succeed. |
172 // In auto start enabled platforms like chrome os we should be | 162 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; |
173 // able to set up even if the first sync while setting up fails. | |
174 // Trigger error on every 2 out of 3 requests. | |
175 TriggerSyncError(protocol_error, SyncTest::ERROR_FREQUENCY_TWO_THIRDS); | |
176 // Now setup sync and it should succeed. | |
177 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; | |
178 } else { | |
179 // In Non auto start enabled environments if the setup sync fails then | |
180 // the setup would fail. So setup sync normally. | |
181 ASSERT_TRUE(SetupSync()) << "Setup sync failed"; | |
182 ASSERT_TRUE(GetClient(0)->DisableSyncForDatatype(syncer::AUTOFILL)); | |
183 | |
184 // Trigger error on every 2 out of 3 requests. | |
185 TriggerSyncError(protocol_error, SyncTest::ERROR_FREQUENCY_TWO_THIRDS); | |
186 | |
187 // Now enable a datatype, whose first 2 syncs would fail, but we should | |
188 // recover and setup succesfully on the third attempt. | |
189 ASSERT_TRUE(GetClient(0)->EnableSyncForDatatype(syncer::AUTOFILL)); | |
190 } | |
191 } | 163 } |
192 | 164 |
193 IN_PROC_BROWSER_TEST_F(LegacySyncErrorTest, | 165 #if defined(OS_CHROMEOS) |
194 DISABLED_BirthdayErrorUsingActionableErrorTest) { | 166 #define MAYBE_ErrorWhileSettingUp DISABLED_ErrorWhileSettingUp |
| 167 #else |
| 168 #define MAYBE_ErrorWhileSettingUp ErrorWhileSettingUp |
| 169 #endif |
| 170 IN_PROC_BROWSER_TEST_F(SyncErrorTest, MAYBE_ErrorWhileSettingUp) { |
| 171 ASSERT_TRUE(SetupClients()); |
| 172 ASSERT_FALSE(GetSyncService(0)->auto_start_enabled()); |
| 173 |
| 174 // In Non auto start enabled environments if the setup sync fails then |
| 175 // the setup would fail. So setup sync normally. |
| 176 ASSERT_TRUE(SetupSync()) << "Setup sync failed"; |
| 177 ASSERT_TRUE(GetClient(0)->DisableSyncForDatatype(syncer::AUTOFILL)); |
| 178 |
| 179 EXPECT_TRUE(GetFakeServer()->TriggerError( |
| 180 sync_pb::SyncEnums::TRANSIENT_ERROR)); |
| 181 EXPECT_TRUE(GetFakeServer()->EnableAlternatingTriggeredErrors()); |
| 182 |
| 183 // Now enable a datatype, whose first 2 syncs would fail, but we should |
| 184 // recover and setup succesfully on the third attempt. |
| 185 ASSERT_TRUE(GetClient(0)->EnableSyncForDatatype(syncer::AUTOFILL)); |
| 186 } |
| 187 |
| 188 IN_PROC_BROWSER_TEST_F(SyncErrorTest, BirthdayErrorUsingActionableErrorTest) { |
195 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; | 189 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; |
196 | 190 |
197 const BookmarkNode* node1 = AddFolder(0, 0, "title1"); | 191 const BookmarkNode* node1 = AddFolder(0, 0, "title1"); |
198 SetTitle(0, node1, "new_title1"); | 192 SetTitle(0, node1, "new_title1"); |
199 ASSERT_TRUE(AwaitCommitActivityCompletion(GetSyncService((0)))); | 193 ASSERT_TRUE(AwaitCommitActivityCompletion(GetSyncService((0)))); |
200 | 194 |
201 syncer::SyncProtocolError protocol_error; | 195 std::string description = "Not My Fault"; |
202 protocol_error.error_type = syncer::NOT_MY_BIRTHDAY; | 196 std::string url = "www.google.com"; |
203 protocol_error.action = syncer::DISABLE_SYNC_ON_CLIENT; | 197 EXPECT_TRUE(GetFakeServer()->TriggerActionableError( |
204 protocol_error.error_description = "Not My Fault"; | 198 sync_pb::SyncEnums::NOT_MY_BIRTHDAY, |
205 protocol_error.url = "www.google.com"; | 199 description, |
206 TriggerSyncError(protocol_error, SyncTest::ERROR_FREQUENCY_ALWAYS); | 200 url, |
| 201 sync_pb::SyncEnums::DISABLE_SYNC_ON_CLIENT)); |
207 | 202 |
208 // Now make one more change so we will do another sync. | 203 // Now make one more change so we will do another sync. |
209 const BookmarkNode* node2 = AddFolder(0, 0, "title2"); | 204 const BookmarkNode* node2 = AddFolder(0, 0, "title2"); |
210 SetTitle(0, node2, "new_title2"); | 205 SetTitle(0, node2, "new_title2"); |
211 ASSERT_TRUE(AwaitSyncDisabled(GetSyncService((0)))); | 206 ASSERT_TRUE(AwaitSyncDisabled(GetSyncService((0)))); |
212 ProfileSyncService::Status status; | 207 ProfileSyncService::Status status; |
213 GetSyncService((0))->QueryDetailedSyncStatus(&status); | 208 GetSyncService((0))->QueryDetailedSyncStatus(&status); |
214 ASSERT_EQ(status.sync_protocol_error.error_type, protocol_error.error_type); | 209 ASSERT_EQ(status.sync_protocol_error.error_type, syncer::NOT_MY_BIRTHDAY); |
215 ASSERT_EQ(status.sync_protocol_error.action, protocol_error.action); | 210 ASSERT_EQ(status.sync_protocol_error.action, syncer::DISABLE_SYNC_ON_CLIENT); |
216 ASSERT_EQ(status.sync_protocol_error.url, protocol_error.url); | 211 ASSERT_EQ(status.sync_protocol_error.url, url); |
217 ASSERT_EQ(status.sync_protocol_error.error_description, | 212 ASSERT_EQ(status.sync_protocol_error.error_description, description); |
218 protocol_error.error_description); | |
219 } | 213 } |
220 | 214 |
221 IN_PROC_BROWSER_TEST_F(SyncErrorTest, DisableDatatypeWhileRunning) { | 215 IN_PROC_BROWSER_TEST_F(SyncErrorTest, DisableDatatypeWhileRunning) { |
222 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; | 216 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; |
223 syncer::ModelTypeSet synced_datatypes = | 217 syncer::ModelTypeSet synced_datatypes = |
224 GetSyncService((0))->GetActiveDataTypes(); | 218 GetSyncService((0))->GetActiveDataTypes(); |
225 ASSERT_TRUE(synced_datatypes.Has(syncer::TYPED_URLS)); | 219 ASSERT_TRUE(synced_datatypes.Has(syncer::TYPED_URLS)); |
226 ASSERT_TRUE(synced_datatypes.Has(syncer::SESSIONS)); | 220 ASSERT_TRUE(synced_datatypes.Has(syncer::SESSIONS)); |
227 GetProfile(0)->GetPrefs()->SetBoolean( | 221 GetProfile(0)->GetPrefs()->SetBoolean( |
228 prefs::kSavingBrowserHistoryDisabled, true); | 222 prefs::kSavingBrowserHistoryDisabled, true); |
229 | 223 |
230 // Wait for reconfigurations. | 224 // Wait for reconfigurations. |
231 ASSERT_TRUE(AwaitTypeDisabled(GetSyncService(0), syncer::TYPED_URLS)); | 225 ASSERT_TRUE(AwaitTypeDisabled(GetSyncService(0), syncer::TYPED_URLS)); |
232 ASSERT_TRUE(AwaitTypeDisabled(GetSyncService(0), syncer::SESSIONS)); | 226 ASSERT_TRUE(AwaitTypeDisabled(GetSyncService(0), syncer::SESSIONS)); |
233 | 227 |
234 const BookmarkNode* node1 = AddFolder(0, 0, "title1"); | 228 const BookmarkNode* node1 = AddFolder(0, 0, "title1"); |
235 SetTitle(0, node1, "new_title1"); | 229 SetTitle(0, node1, "new_title1"); |
236 ASSERT_TRUE(AwaitCommitActivityCompletion(GetSyncService((0)))); | 230 ASSERT_TRUE(AwaitCommitActivityCompletion(GetSyncService((0)))); |
237 // TODO(lipalani)" Verify initial sync ended for typed url is false. | 231 // TODO(lipalani)" Verify initial sync ended for typed url is false. |
238 } | 232 } |
239 | 233 |
240 } // namespace | 234 } // namespace |
OLD | NEW |