| 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/compiler_specific.h" | 5 #include "base/compiler_specific.h" |
| 6 #include "base/memory/scoped_vector.h" | 6 #include "base/memory/scoped_vector.h" |
| 7 #include "base/prefs/scoped_user_pref_update.h" | 7 #include "base/prefs/scoped_user_pref_update.h" |
| 8 #include "chrome/browser/profiles/profile.h" | 8 #include "chrome/browser/profiles/profile.h" |
| 9 #include "chrome/browser/sync/backend_migrator.h" | 9 #include "chrome/browser/sync/backend_migrator.h" |
| 10 #include "chrome/browser/sync/test/integration/bookmarks_helper.h" | 10 #include "chrome/browser/sync/test/integration/bookmarks_helper.h" |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 88 // migration is complete for all data types in |expected_types_|. | 88 // migration is complete for all data types in |expected_types_|. |
| 89 virtual bool IsExitConditionSatisfied() OVERRIDE { | 89 virtual bool IsExitConditionSatisfied() OVERRIDE { |
| 90 DCHECK(!expected_types_.Empty()); | 90 DCHECK(!expected_types_.Empty()); |
| 91 bool all_expected_types_migrated = migrated_types_.HasAll(expected_types_); | 91 bool all_expected_types_migrated = migrated_types_.HasAll(expected_types_); |
| 92 DVLOG(1) << harness_->profile_debug_name() << ": Migrated types " | 92 DVLOG(1) << harness_->profile_debug_name() << ": Migrated types " |
| 93 << syncer::ModelTypeSetToString(migrated_types_) | 93 << syncer::ModelTypeSetToString(migrated_types_) |
| 94 << (all_expected_types_migrated ? " contains " : | 94 << (all_expected_types_migrated ? " contains " : |
| 95 " does not contain ") | 95 " does not contain ") |
| 96 << syncer::ModelTypeSetToString(expected_types_); | 96 << syncer::ModelTypeSetToString(expected_types_); |
| 97 return all_expected_types_migrated && | 97 return all_expected_types_migrated && |
| 98 !harness_->HasPendingBackendMigration(); | 98 !HasPendingBackendMigration(); |
| 99 } |
| 100 |
| 101 bool HasPendingBackendMigration() const { |
| 102 browser_sync::BackendMigrator* migrator = |
| 103 harness_->service()->GetBackendMigratorForTest(); |
| 104 return migrator && migrator->state() != browser_sync::BackendMigrator::IDLE; |
| 99 } | 105 } |
| 100 | 106 |
| 101 void set_expected_types(syncer::ModelTypeSet expected_types) { | 107 void set_expected_types(syncer::ModelTypeSet expected_types) { |
| 102 expected_types_ = expected_types; | 108 expected_types_ = expected_types; |
| 103 } | 109 } |
| 104 | 110 |
| 105 syncer::ModelTypeSet migrated_types() const { | 111 syncer::ModelTypeSet migrated_types() const { |
| 106 return migrated_types_; | 112 return migrated_types_; |
| 107 } | 113 } |
| 108 | 114 |
| 109 virtual void OnMigrationStateChange() OVERRIDE { | 115 virtual void OnMigrationStateChange() OVERRIDE { |
| 110 if (harness_->HasPendingBackendMigration()) { | 116 if (HasPendingBackendMigration()) { |
| 111 // A new bunch of data types are in the process of being migrated. Merge | 117 // A new bunch of data types are in the process of being migrated. Merge |
| 112 // them into |pending_types_|. | 118 // them into |pending_types_|. |
| 113 pending_types_.PutAll( | 119 pending_types_.PutAll( |
| 114 harness_->service()->GetBackendMigratorForTest()-> | 120 harness_->service()->GetBackendMigratorForTest()-> |
| 115 GetPendingMigrationTypesForTest()); | 121 GetPendingMigrationTypesForTest()); |
| 116 DVLOG(1) << harness_->profile_debug_name() | 122 DVLOG(1) << harness_->profile_debug_name() |
| 117 << ": new pending migration types " | 123 << ": new pending migration types " |
| 118 << syncer::ModelTypeSetToString(pending_types_); | 124 << syncer::ModelTypeSetToString(pending_types_); |
| 119 } else { | 125 } else { |
| 120 // Migration just finished for a bunch of data types. Merge them into | 126 // Migration just finished for a bunch of data types. Merge them into |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 222 } | 228 } |
| 223 | 229 |
| 224 // Block until all clients have completed migration for the given | 230 // Block until all clients have completed migration for the given |
| 225 // types. | 231 // types. |
| 226 void AwaitMigration(syncer::ModelTypeSet migrate_types) { | 232 void AwaitMigration(syncer::ModelTypeSet migrate_types) { |
| 227 for (int i = 0; i < num_clients(); ++i) { | 233 for (int i = 0; i < num_clients(); ++i) { |
| 228 MigrationChecker* checker = migration_checkers_[i]; | 234 MigrationChecker* checker = migration_checkers_[i]; |
| 229 checker->set_expected_types(migrate_types); | 235 checker->set_expected_types(migrate_types); |
| 230 if (!checker->IsExitConditionSatisfied()) | 236 if (!checker->IsExitConditionSatisfied()) |
| 231 ASSERT_TRUE(GetClient(i)->AwaitStatusChange(checker, "AwaitMigration")); | 237 ASSERT_TRUE(GetClient(i)->AwaitStatusChange(checker, "AwaitMigration")); |
| 232 // We must use AwaitDataSyncCompletion rather than the more common | |
| 233 // AwaitFullSyncCompletion. As long as crbug.com/97780 is open, we will | |
| 234 // rely on self-notifications to ensure that progress markers are updated, | |
| 235 // which allows AwaitFullSyncCompletion to return. However, in some | |
| 236 // migration tests these notifications are completely disabled, so the | |
| 237 // progress markers do not get updated. This is why we must use the less | |
| 238 // strict condition, AwaitDataSyncCompletion. | |
| 239 ASSERT_TRUE(GetClient(i)->AwaitDataSyncCompletion()); | |
| 240 } | 238 } |
| 241 } | 239 } |
| 242 | 240 |
| 243 bool ShouldRunMigrationTest() const { | 241 bool ShouldRunMigrationTest() const { |
| 244 if (!ServerSupportsNotificationControl() || | 242 if (!ServerSupportsNotificationControl() || |
| 245 !ServerSupportsErrorTriggering()) { | 243 !ServerSupportsErrorTriggering()) { |
| 246 LOG(WARNING) << "Test skipped in this server environment."; | 244 LOG(WARNING) << "Test skipped in this server environment."; |
| 247 return false; | 245 return false; |
| 248 } | 246 } |
| 249 return true; | 247 return true; |
| (...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 518 // Do not add optional datatypes. | 516 // Do not add optional datatypes. |
| 519 } | 517 } |
| 520 | 518 |
| 521 virtual ~MigrationReconfigureTest() {} | 519 virtual ~MigrationReconfigureTest() {} |
| 522 | 520 |
| 523 private: | 521 private: |
| 524 DISALLOW_COPY_AND_ASSIGN(MigrationReconfigureTest); | 522 DISALLOW_COPY_AND_ASSIGN(MigrationReconfigureTest); |
| 525 }; | 523 }; |
| 526 | 524 |
| 527 } // namespace | 525 } // namespace |
| OLD | NEW |