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 #include "chrome/browser/prefs/scoped_user_pref_update.h" | 5 #include "chrome/browser/prefs/scoped_user_pref_update.h" |
6 #include "chrome/browser/profiles/profile.h" | 6 #include "chrome/browser/profiles/profile.h" |
7 #include "chrome/browser/sync/profile_sync_service_harness.h" | 7 #include "chrome/browser/sync/profile_sync_service_harness.h" |
8 #include "chrome/browser/translate/translate_prefs.h" | 8 #include "chrome/browser/translate/translate_prefs.h" |
9 #include "chrome/common/pref_names.h" | 9 #include "chrome/common/pref_names.h" |
10 #include "chrome/test/base/ui_test_utils.h" | 10 #include "chrome/test/base/ui_test_utils.h" |
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
272 // Phase 3: Modify a bookmark and wait for it to sync. | 272 // Phase 3: Modify a bookmark and wait for it to sync. |
273 ASSERT_TRUE(AddURL(0, IndexedURLTitle(0), GURL(IndexedURL(0))) != NULL); | 273 ASSERT_TRUE(AddURL(0, IndexedURLTitle(0), GURL(IndexedURL(0))) != NULL); |
274 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); | 274 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); |
275 | 275 |
276 // Phase 4: Verify that preferences can still be synchronized. | 276 // Phase 4: Verify that preferences can still be synchronized. |
277 ASSERT_TRUE(BooleanPrefMatches(prefs::kShowHomeButton)); | 277 ASSERT_TRUE(BooleanPrefMatches(prefs::kShowHomeButton)); |
278 ChangeBooleanPref(0, prefs::kShowHomeButton); | 278 ChangeBooleanPref(0, prefs::kShowHomeButton); |
279 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); | 279 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); |
280 ASSERT_TRUE(BooleanPrefMatches(prefs::kShowHomeButton)); | 280 ASSERT_TRUE(BooleanPrefMatches(prefs::kShowHomeButton)); |
281 } | 281 } |
| 282 |
| 283 class MigrationReconfigureTest : public LiveSyncTest { |
| 284 public: |
| 285 MigrationReconfigureTest() : LiveSyncTest(TWO_CLIENT) {} |
| 286 |
| 287 virtual void SetUpCommandLine(CommandLine* cl) OVERRIDE { |
| 288 AddTestSwitches(cl); |
| 289 // Do not add optional datatypes. |
| 290 } |
| 291 |
| 292 virtual ~MigrationReconfigureTest() {} |
| 293 |
| 294 private: |
| 295 DISALLOW_COPY_AND_ASSIGN(MigrationReconfigureTest); |
| 296 }; |
| 297 |
| 298 IN_PROC_BROWSER_TEST_F(MigrationReconfigureTest, SetSyncTabs) { |
| 299 if (!ServerSupportsErrorTriggering()) { |
| 300 LOG(WARNING) << "Test skipped in this server environment."; |
| 301 return; |
| 302 } |
| 303 |
| 304 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; |
| 305 ASSERT_FALSE(GetClient(0)->IsTypeRegistered(syncable::SESSIONS)); |
| 306 ASSERT_FALSE(GetClient(0)->IsTypePreferred(syncable::SESSIONS)); |
| 307 |
| 308 // Phase 1: Before migrating anything, create & sync a preference. |
| 309 ASSERT_TRUE(BooleanPrefMatches(prefs::kShowHomeButton)); |
| 310 ChangeBooleanPref(0, prefs::kShowHomeButton); |
| 311 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); |
| 312 ASSERT_TRUE(BooleanPrefMatches(prefs::kShowHomeButton)); |
| 313 |
| 314 // Phase 2: Trigger setting the sync_tabs field. |
| 315 TriggerSetSyncTabs(); |
| 316 |
| 317 // Phase 3: Modify a bookmark and wait for it to sync. |
| 318 ASSERT_TRUE(AddURL(0, IndexedURLTitle(0), GURL(IndexedURL(0))) != NULL); |
| 319 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); |
| 320 |
| 321 // Phase 4: Verify that preferences can still be synchronized. |
| 322 ASSERT_TRUE(BooleanPrefMatches(prefs::kShowHomeButton)); |
| 323 ChangeBooleanPref(0, prefs::kShowHomeButton); |
| 324 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); |
| 325 ASSERT_TRUE(BooleanPrefMatches(prefs::kShowHomeButton)); |
| 326 |
| 327 // Phase 5: Verify that sessions are registered and enabled. |
| 328 ASSERT_TRUE(GetClient(0)->IsTypeRegistered(syncable::SESSIONS)); |
| 329 ASSERT_TRUE(GetClient(0)->IsTypePreferred(syncable::SESSIONS)); |
| 330 } |
| 331 |
| 332 IN_PROC_BROWSER_TEST_F(MigrationReconfigureTest, SetSyncTabsAndMigrate) { |
| 333 if (!ServerSupportsErrorTriggering()) { |
| 334 LOG(WARNING) << "Test skipped in this server environment."; |
| 335 return; |
| 336 } |
| 337 |
| 338 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; |
| 339 ASSERT_FALSE(GetClient(0)->IsTypeRegistered(syncable::SESSIONS)); |
| 340 ASSERT_FALSE(GetClient(0)->IsTypePreferred(syncable::SESSIONS)); |
| 341 |
| 342 // Phase 1: Before migrating anything, create & sync a preference. |
| 343 ASSERT_TRUE(BooleanPrefMatches(prefs::kShowHomeButton)); |
| 344 ChangeBooleanPref(0, prefs::kShowHomeButton); |
| 345 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); |
| 346 ASSERT_TRUE(BooleanPrefMatches(prefs::kShowHomeButton)); |
| 347 |
| 348 // Phase 2: Trigger setting the sync_tabs field. |
| 349 TriggerSetSyncTabs(); |
| 350 |
| 351 // Phase 3: Trigger a preference migration on the server. |
| 352 syncable::ModelTypeSet migrate_types; |
| 353 migrate_types.insert(syncable::PREFERENCES); |
| 354 TriggerMigrationDoneError(migrate_types); |
| 355 |
| 356 // Phase 4: Modify a bookmark and wait for it to sync. |
| 357 ASSERT_TRUE(AddURL(0, IndexedURLTitle(0), GURL(IndexedURL(0))) != NULL); |
| 358 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); |
| 359 |
| 360 // Phase 5: Verify that preferences can still be synchronized. |
| 361 ASSERT_TRUE(BooleanPrefMatches(prefs::kShowHomeButton)); |
| 362 ChangeBooleanPref(0, prefs::kShowHomeButton); |
| 363 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); |
| 364 ASSERT_TRUE(BooleanPrefMatches(prefs::kShowHomeButton)); |
| 365 |
| 366 // Phase 6: Verify that sessions are registered and enabled. |
| 367 ASSERT_TRUE(GetClient(0)->IsTypeRegistered(syncable::SESSIONS)); |
| 368 ASSERT_TRUE(GetClient(0)->IsTypePreferred(syncable::SESSIONS)); |
| 369 } |
OLD | NEW |