Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(932)

Unified Diff: components/sync/driver/backend_migrator_unittest.cc

Issue 2388673002: Revert of [Sync] Move //components/sync to the syncer namespace. (patchset #5 id:40001 of https://co (Closed)
Patch Set: Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « components/sync/driver/backend_migrator.cc ('k') | components/sync/driver/change_processor.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/sync/driver/backend_migrator_unittest.cc
diff --git a/components/sync/driver/backend_migrator_unittest.cc b/components/sync/driver/backend_migrator_unittest.cc
index 529d8e46b71034a14ec3eae4643645952fdd2b8a..a545673130670dee566c1168c5f4e7a5d6db1879 100644
--- a/components/sync/driver/backend_migrator_unittest.cc
+++ b/components/sync/driver/backend_migrator_unittest.cc
@@ -22,8 +22,12 @@ using ::testing::Eq;
using ::testing::Mock;
using ::testing::NiceMock;
using ::testing::Return;
+using sync_driver::DataTypeManager;
+using sync_driver::DataTypeManagerMock;
-namespace syncer {
+namespace browser_sync {
+
+using syncer::SyncCycleSnapshot;
class SyncBackendMigratorTest : public testing::Test {
public:
@@ -33,14 +37,14 @@ class SyncBackendMigratorTest : public testing::Test {
virtual void SetUp() {
test_user_share_.SetUp();
Mock::VerifyAndClear(manager());
- preferred_types_.Put(BOOKMARKS);
- preferred_types_.Put(PREFERENCES);
- preferred_types_.Put(AUTOFILL);
+ preferred_types_.Put(syncer::BOOKMARKS);
+ preferred_types_.Put(syncer::PREFERENCES);
+ preferred_types_.Put(syncer::AUTOFILL);
migrator_.reset(new BackendMigrator("Profile0",
test_user_share_.user_share(),
service(), manager(), base::Closure()));
- SetUnsyncedTypes(ModelTypeSet());
+ SetUnsyncedTypes(syncer::ModelTypeSet());
}
virtual void TearDown() {
@@ -50,10 +54,11 @@ class SyncBackendMigratorTest : public testing::Test {
// Marks all types in |unsynced_types| as unsynced and all other
// types as synced.
- void SetUnsyncedTypes(ModelTypeSet unsynced_types) {
- WriteTransaction trans(FROM_HERE, test_user_share_.user_share());
- for (int i = FIRST_REAL_MODEL_TYPE; i < MODEL_TYPE_COUNT; ++i) {
- ModelType type = ModelTypeFromInt(i);
+ void SetUnsyncedTypes(syncer::ModelTypeSet unsynced_types) {
+ syncer::WriteTransaction trans(FROM_HERE, test_user_share_.user_share());
+ for (int i = syncer::FIRST_REAL_MODEL_TYPE; i < syncer::MODEL_TYPE_COUNT;
+ ++i) {
+ syncer::ModelType type = syncer::ModelTypeFromInt(i);
sync_pb::DataTypeProgressMarker progress_marker;
if (!unsynced_types.Has(type)) {
progress_marker.set_token("dummy");
@@ -63,7 +68,7 @@ class SyncBackendMigratorTest : public testing::Test {
}
void SendConfigureDone(DataTypeManager::ConfigureStatus status,
- ModelTypeSet requested_types) {
+ syncer::ModelTypeSet requested_types) {
if (status == DataTypeManager::OK) {
DataTypeManager::ConfigureResult result(status, requested_types);
migrator_->OnConfigureDone(result);
@@ -75,18 +80,20 @@ class SyncBackendMigratorTest : public testing::Test {
run_loop.RunUntilIdle();
}
- SyncService* service() { return &service_; }
+ sync_driver::SyncService* service() { return &service_; }
DataTypeManagerMock* manager() { return &manager_; }
- ModelTypeSet preferred_types() { return preferred_types_; }
+ syncer::ModelTypeSet preferred_types() { return preferred_types_; }
BackendMigrator* migrator() { return migrator_.get(); }
- void RemovePreferredType(ModelType type) { preferred_types_.Remove(type); }
+ void RemovePreferredType(syncer::ModelType type) {
+ preferred_types_.Remove(type);
+ }
private:
base::MessageLoop message_loop_;
- ModelTypeSet preferred_types_;
- FakeSyncService service_;
+ syncer::ModelTypeSet preferred_types_;
+ sync_driver::FakeSyncService service_;
NiceMock<DataTypeManagerMock> manager_;
- TestUserShare test_user_share_;
+ syncer::TestUserShare test_user_share_;
std::unique_ptr<BackendMigrator> migrator_;
};
@@ -104,16 +111,18 @@ TEST_F(SyncBackendMigratorTest, Sanity) {
migrator()->AddMigrationObserver(&migration_observer);
EXPECT_CALL(migration_observer, OnMigrationStateChange()).Times(4);
- ModelTypeSet to_migrate, difference;
- to_migrate.Put(PREFERENCES);
- difference.Put(AUTOFILL);
- difference.Put(BOOKMARKS);
+ syncer::ModelTypeSet to_migrate, difference;
+ to_migrate.Put(syncer::PREFERENCES);
+ difference.Put(syncer::AUTOFILL);
+ difference.Put(syncer::BOOKMARKS);
EXPECT_CALL(*manager(), state())
.WillOnce(Return(DataTypeManager::CONFIGURED));
- EXPECT_CALL(*manager(), PurgeForMigration(_, CONFIGURE_REASON_MIGRATION))
+ EXPECT_CALL(*manager(),
+ PurgeForMigration(_, syncer::CONFIGURE_REASON_MIGRATION))
+ .Times(1);
+ EXPECT_CALL(*manager(), Configure(_, syncer::CONFIGURE_REASON_MIGRATION))
.Times(1);
- EXPECT_CALL(*manager(), Configure(_, CONFIGURE_REASON_MIGRATION)).Times(1);
migrator()->MigrateTypes(to_migrate);
EXPECT_EQ(BackendMigrator::DISABLING_TYPES, migrator()->state());
@@ -122,7 +131,7 @@ TEST_F(SyncBackendMigratorTest, Sanity) {
SendConfigureDone(DataTypeManager::OK, difference);
EXPECT_EQ(BackendMigrator::REENABLING_TYPES, migrator()->state());
- SetUnsyncedTypes(ModelTypeSet());
+ SetUnsyncedTypes(syncer::ModelTypeSet());
SendConfigureDone(DataTypeManager::OK, preferred_types());
EXPECT_EQ(BackendMigrator::IDLE, migrator()->state());
@@ -132,15 +141,16 @@ TEST_F(SyncBackendMigratorTest, Sanity) {
// Test that in the normal case with Nigori a migration transitions through
// each state and wind up back in IDLE.
TEST_F(SyncBackendMigratorTest, MigrateNigori) {
- ModelTypeSet to_migrate, difference;
- to_migrate.Put(NIGORI);
- difference.Put(AUTOFILL);
- difference.Put(BOOKMARKS);
+ syncer::ModelTypeSet to_migrate, difference;
+ to_migrate.Put(syncer::NIGORI);
+ difference.Put(syncer::AUTOFILL);
+ difference.Put(syncer::BOOKMARKS);
EXPECT_CALL(*manager(), state())
.WillOnce(Return(DataTypeManager::CONFIGURED));
- EXPECT_CALL(*manager(), PurgeForMigration(_, CONFIGURE_REASON_MIGRATION));
+ EXPECT_CALL(*manager(),
+ PurgeForMigration(_, syncer::CONFIGURE_REASON_MIGRATION));
migrator()->MigrateTypes(to_migrate);
EXPECT_EQ(BackendMigrator::DISABLING_TYPES, migrator()->state());
@@ -149,7 +159,7 @@ TEST_F(SyncBackendMigratorTest, MigrateNigori) {
SendConfigureDone(DataTypeManager::OK, difference);
EXPECT_EQ(BackendMigrator::REENABLING_TYPES, migrator()->state());
- SetUnsyncedTypes(ModelTypeSet());
+ SetUnsyncedTypes(syncer::ModelTypeSet());
SendConfigureDone(DataTypeManager::OK, preferred_types());
EXPECT_EQ(BackendMigrator::IDLE, migrator()->state());
}
@@ -157,8 +167,8 @@ TEST_F(SyncBackendMigratorTest, MigrateNigori) {
// Test that the migrator waits for the data type manager to be idle before
// starting a migration.
TEST_F(SyncBackendMigratorTest, WaitToStart) {
- ModelTypeSet to_migrate;
- to_migrate.Put(PREFERENCES);
+ syncer::ModelTypeSet to_migrate;
+ to_migrate.Put(syncer::PREFERENCES);
EXPECT_CALL(*manager(), state())
.WillOnce(Return(DataTypeManager::CONFIGURING));
@@ -169,9 +179,10 @@ TEST_F(SyncBackendMigratorTest, WaitToStart) {
Mock::VerifyAndClearExpectations(manager());
EXPECT_CALL(*manager(), state())
.WillOnce(Return(DataTypeManager::CONFIGURED));
- EXPECT_CALL(*manager(), PurgeForMigration(_, CONFIGURE_REASON_MIGRATION));
- SetUnsyncedTypes(ModelTypeSet());
- SendConfigureDone(DataTypeManager::OK, ModelTypeSet());
+ EXPECT_CALL(*manager(),
+ PurgeForMigration(_, syncer::CONFIGURE_REASON_MIGRATION));
+ SetUnsyncedTypes(syncer::ModelTypeSet());
+ SendConfigureDone(DataTypeManager::OK, syncer::ModelTypeSet());
EXPECT_EQ(BackendMigrator::DISABLING_TYPES, migrator()->state());
}
@@ -179,28 +190,32 @@ TEST_F(SyncBackendMigratorTest, WaitToStart) {
// Test that the migrator can cope with a migration request while a migration
// is in progress.
TEST_F(SyncBackendMigratorTest, RestartMigration) {
- ModelTypeSet to_migrate1, to_migrate2, to_migrate_union, bookmarks;
- to_migrate1.Put(PREFERENCES);
- to_migrate2.Put(AUTOFILL);
- to_migrate_union.Put(PREFERENCES);
- to_migrate_union.Put(AUTOFILL);
- bookmarks.Put(BOOKMARKS);
+ syncer::ModelTypeSet to_migrate1, to_migrate2, to_migrate_union, bookmarks;
+ to_migrate1.Put(syncer::PREFERENCES);
+ to_migrate2.Put(syncer::AUTOFILL);
+ to_migrate_union.Put(syncer::PREFERENCES);
+ to_migrate_union.Put(syncer::AUTOFILL);
+ bookmarks.Put(syncer::BOOKMARKS);
EXPECT_CALL(*manager(), state())
.WillOnce(Return(DataTypeManager::CONFIGURED));
- EXPECT_CALL(*manager(), PurgeForMigration(_, CONFIGURE_REASON_MIGRATION))
+ EXPECT_CALL(*manager(),
+ PurgeForMigration(_, syncer::CONFIGURE_REASON_MIGRATION))
.Times(2);
migrator()->MigrateTypes(to_migrate1);
EXPECT_EQ(BackendMigrator::DISABLING_TYPES, migrator()->state());
migrator()->MigrateTypes(to_migrate2);
- const ModelTypeSet difference1 = Difference(preferred_types(), to_migrate1);
+ const syncer::ModelTypeSet difference1 =
+ Difference(preferred_types(), to_migrate1);
Mock::VerifyAndClearExpectations(manager());
- EXPECT_CALL(*manager(), PurgeForMigration(_, CONFIGURE_REASON_MIGRATION))
+ EXPECT_CALL(*manager(),
+ PurgeForMigration(_, syncer::CONFIGURE_REASON_MIGRATION))
+ .Times(1);
+ EXPECT_CALL(*manager(), Configure(_, syncer::CONFIGURE_REASON_MIGRATION))
.Times(1);
- EXPECT_CALL(*manager(), Configure(_, CONFIGURE_REASON_MIGRATION)).Times(1);
SetUnsyncedTypes(to_migrate1);
SendConfigureDone(DataTypeManager::OK, difference1);
EXPECT_EQ(BackendMigrator::DISABLING_TYPES, migrator()->state());
@@ -213,23 +228,25 @@ TEST_F(SyncBackendMigratorTest, RestartMigration) {
// Test that an external invocation of Configure(...) during a migration results
// in a migration reattempt.
TEST_F(SyncBackendMigratorTest, InterruptedWhileDisablingTypes) {
- ModelTypeSet to_migrate;
- ModelTypeSet difference;
- to_migrate.Put(PREFERENCES);
- difference.Put(AUTOFILL);
- difference.Put(BOOKMARKS);
+ syncer::ModelTypeSet to_migrate;
+ syncer::ModelTypeSet difference;
+ to_migrate.Put(syncer::PREFERENCES);
+ difference.Put(syncer::AUTOFILL);
+ difference.Put(syncer::BOOKMARKS);
EXPECT_CALL(*manager(), state())
.WillOnce(Return(DataTypeManager::CONFIGURED));
- EXPECT_CALL(*manager(), PurgeForMigration(HasModelTypes(to_migrate),
- CONFIGURE_REASON_MIGRATION));
+ EXPECT_CALL(*manager(),
+ PurgeForMigration(HasModelTypes(to_migrate),
+ syncer::CONFIGURE_REASON_MIGRATION));
migrator()->MigrateTypes(to_migrate);
EXPECT_EQ(BackendMigrator::DISABLING_TYPES, migrator()->state());
Mock::VerifyAndClearExpectations(manager());
- EXPECT_CALL(*manager(), PurgeForMigration(HasModelTypes(to_migrate),
- CONFIGURE_REASON_MIGRATION));
- SetUnsyncedTypes(ModelTypeSet());
+ EXPECT_CALL(*manager(),
+ PurgeForMigration(HasModelTypes(to_migrate),
+ syncer::CONFIGURE_REASON_MIGRATION));
+ SetUnsyncedTypes(syncer::ModelTypeSet());
SendConfigureDone(DataTypeManager::OK, preferred_types());
EXPECT_EQ(BackendMigrator::DISABLING_TYPES, migrator()->state());
@@ -239,16 +256,18 @@ TEST_F(SyncBackendMigratorTest, InterruptedWhileDisablingTypes) {
// migrator while it's waiting for disabled types to have been purged
// from the sync db.
TEST_F(SyncBackendMigratorTest, WaitingForPurge) {
- ModelTypeSet to_migrate, difference;
- to_migrate.Put(PREFERENCES);
- to_migrate.Put(AUTOFILL);
- difference.Put(BOOKMARKS);
+ syncer::ModelTypeSet to_migrate, difference;
+ to_migrate.Put(syncer::PREFERENCES);
+ to_migrate.Put(syncer::AUTOFILL);
+ difference.Put(syncer::BOOKMARKS);
EXPECT_CALL(*manager(), state())
.WillOnce(Return(DataTypeManager::CONFIGURED));
- EXPECT_CALL(*manager(), PurgeForMigration(_, CONFIGURE_REASON_MIGRATION))
+ EXPECT_CALL(*manager(),
+ PurgeForMigration(_, syncer::CONFIGURE_REASON_MIGRATION))
+ .Times(1);
+ EXPECT_CALL(*manager(), Configure(_, syncer::CONFIGURE_REASON_MIGRATION))
.Times(1);
- EXPECT_CALL(*manager(), Configure(_, CONFIGURE_REASON_MIGRATION)).Times(1);
migrator()->MigrateTypes(to_migrate);
EXPECT_EQ(BackendMigrator::DISABLING_TYPES, migrator()->state());
@@ -256,8 +275,8 @@ TEST_F(SyncBackendMigratorTest, WaitingForPurge) {
SendConfigureDone(DataTypeManager::OK, difference);
EXPECT_EQ(BackendMigrator::DISABLING_TYPES, migrator()->state());
- ModelTypeSet prefs;
- prefs.Put(PREFERENCES);
+ syncer::ModelTypeSet prefs;
+ prefs.Put(syncer::PREFERENCES);
SetUnsyncedTypes(prefs);
SendConfigureDone(DataTypeManager::OK, difference);
EXPECT_EQ(BackendMigrator::DISABLING_TYPES, migrator()->state());
@@ -268,36 +287,39 @@ TEST_F(SyncBackendMigratorTest, WaitingForPurge) {
}
TEST_F(SyncBackendMigratorTest, MigratedTypeDisabledByUserDuringMigration) {
- ModelTypeSet to_migrate;
- to_migrate.Put(PREFERENCES);
+ syncer::ModelTypeSet to_migrate;
+ to_migrate.Put(syncer::PREFERENCES);
EXPECT_CALL(*manager(), state())
.WillOnce(Return(DataTypeManager::CONFIGURED));
- EXPECT_CALL(*manager(), PurgeForMigration(_, CONFIGURE_REASON_MIGRATION))
+ EXPECT_CALL(*manager(),
+ PurgeForMigration(_, syncer::CONFIGURE_REASON_MIGRATION))
+ .Times(1);
+ EXPECT_CALL(*manager(), Configure(_, syncer::CONFIGURE_REASON_MIGRATION))
.Times(1);
- EXPECT_CALL(*manager(), Configure(_, CONFIGURE_REASON_MIGRATION)).Times(1);
migrator()->MigrateTypes(to_migrate);
- RemovePreferredType(PREFERENCES);
+ RemovePreferredType(syncer::PREFERENCES);
SetUnsyncedTypes(to_migrate);
SendConfigureDone(DataTypeManager::OK, preferred_types());
EXPECT_EQ(BackendMigrator::REENABLING_TYPES, migrator()->state());
- SetUnsyncedTypes(ModelTypeSet());
+ SetUnsyncedTypes(syncer::ModelTypeSet());
SendConfigureDone(DataTypeManager::OK, preferred_types());
EXPECT_EQ(BackendMigrator::IDLE, migrator()->state());
}
TEST_F(SyncBackendMigratorTest, ConfigureFailure) {
- ModelTypeSet to_migrate;
- to_migrate.Put(PREFERENCES);
+ syncer::ModelTypeSet to_migrate;
+ to_migrate.Put(syncer::PREFERENCES);
EXPECT_CALL(*manager(), state())
.WillOnce(Return(DataTypeManager::CONFIGURED));
- EXPECT_CALL(*manager(), PurgeForMigration(_, CONFIGURE_REASON_MIGRATION))
+ EXPECT_CALL(*manager(),
+ PurgeForMigration(_, syncer::CONFIGURE_REASON_MIGRATION))
.Times(1);
migrator()->MigrateTypes(to_migrate);
- SetUnsyncedTypes(ModelTypeSet());
- SendConfigureDone(DataTypeManager::ABORTED, ModelTypeSet());
+ SetUnsyncedTypes(syncer::ModelTypeSet());
+ SendConfigureDone(DataTypeManager::ABORTED, syncer::ModelTypeSet());
EXPECT_EQ(BackendMigrator::IDLE, migrator()->state());
}
« no previous file with comments | « components/sync/driver/backend_migrator.cc ('k') | components/sync/driver/change_processor.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698