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

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

Issue 2376123003: [Sync] Move //components/sync to the syncer namespace. (Closed)
Patch Set: Rebase. Created 4 years, 3 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 a545673130670dee566c1168c5f4e7a5d6db1879..529d8e46b71034a14ec3eae4643645952fdd2b8a 100644
--- a/components/sync/driver/backend_migrator_unittest.cc
+++ b/components/sync/driver/backend_migrator_unittest.cc
@@ -22,12 +22,8 @@ using ::testing::Eq;
using ::testing::Mock;
using ::testing::NiceMock;
using ::testing::Return;
-using sync_driver::DataTypeManager;
-using sync_driver::DataTypeManagerMock;
-namespace browser_sync {
-
-using syncer::SyncCycleSnapshot;
+namespace syncer {
class SyncBackendMigratorTest : public testing::Test {
public:
@@ -37,14 +33,14 @@ class SyncBackendMigratorTest : public testing::Test {
virtual void SetUp() {
test_user_share_.SetUp();
Mock::VerifyAndClear(manager());
- preferred_types_.Put(syncer::BOOKMARKS);
- preferred_types_.Put(syncer::PREFERENCES);
- preferred_types_.Put(syncer::AUTOFILL);
+ preferred_types_.Put(BOOKMARKS);
+ preferred_types_.Put(PREFERENCES);
+ preferred_types_.Put(AUTOFILL);
migrator_.reset(new BackendMigrator("Profile0",
test_user_share_.user_share(),
service(), manager(), base::Closure()));
- SetUnsyncedTypes(syncer::ModelTypeSet());
+ SetUnsyncedTypes(ModelTypeSet());
}
virtual void TearDown() {
@@ -54,11 +50,10 @@ class SyncBackendMigratorTest : public testing::Test {
// Marks all types in |unsynced_types| as unsynced and all other
// types as synced.
- 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);
+ 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);
sync_pb::DataTypeProgressMarker progress_marker;
if (!unsynced_types.Has(type)) {
progress_marker.set_token("dummy");
@@ -68,7 +63,7 @@ class SyncBackendMigratorTest : public testing::Test {
}
void SendConfigureDone(DataTypeManager::ConfigureStatus status,
- syncer::ModelTypeSet requested_types) {
+ ModelTypeSet requested_types) {
if (status == DataTypeManager::OK) {
DataTypeManager::ConfigureResult result(status, requested_types);
migrator_->OnConfigureDone(result);
@@ -80,20 +75,18 @@ class SyncBackendMigratorTest : public testing::Test {
run_loop.RunUntilIdle();
}
- sync_driver::SyncService* service() { return &service_; }
+ SyncService* service() { return &service_; }
DataTypeManagerMock* manager() { return &manager_; }
- syncer::ModelTypeSet preferred_types() { return preferred_types_; }
+ ModelTypeSet preferred_types() { return preferred_types_; }
BackendMigrator* migrator() { return migrator_.get(); }
- void RemovePreferredType(syncer::ModelType type) {
- preferred_types_.Remove(type);
- }
+ void RemovePreferredType(ModelType type) { preferred_types_.Remove(type); }
private:
base::MessageLoop message_loop_;
- syncer::ModelTypeSet preferred_types_;
- sync_driver::FakeSyncService service_;
+ ModelTypeSet preferred_types_;
+ FakeSyncService service_;
NiceMock<DataTypeManagerMock> manager_;
- syncer::TestUserShare test_user_share_;
+ TestUserShare test_user_share_;
std::unique_ptr<BackendMigrator> migrator_;
};
@@ -111,18 +104,16 @@ TEST_F(SyncBackendMigratorTest, Sanity) {
migrator()->AddMigrationObserver(&migration_observer);
EXPECT_CALL(migration_observer, OnMigrationStateChange()).Times(4);
- syncer::ModelTypeSet to_migrate, difference;
- to_migrate.Put(syncer::PREFERENCES);
- difference.Put(syncer::AUTOFILL);
- difference.Put(syncer::BOOKMARKS);
+ ModelTypeSet to_migrate, difference;
+ to_migrate.Put(PREFERENCES);
+ difference.Put(AUTOFILL);
+ difference.Put(BOOKMARKS);
EXPECT_CALL(*manager(), state())
.WillOnce(Return(DataTypeManager::CONFIGURED));
- EXPECT_CALL(*manager(),
- PurgeForMigration(_, syncer::CONFIGURE_REASON_MIGRATION))
- .Times(1);
- EXPECT_CALL(*manager(), Configure(_, syncer::CONFIGURE_REASON_MIGRATION))
+ EXPECT_CALL(*manager(), PurgeForMigration(_, 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());
@@ -131,7 +122,7 @@ TEST_F(SyncBackendMigratorTest, Sanity) {
SendConfigureDone(DataTypeManager::OK, difference);
EXPECT_EQ(BackendMigrator::REENABLING_TYPES, migrator()->state());
- SetUnsyncedTypes(syncer::ModelTypeSet());
+ SetUnsyncedTypes(ModelTypeSet());
SendConfigureDone(DataTypeManager::OK, preferred_types());
EXPECT_EQ(BackendMigrator::IDLE, migrator()->state());
@@ -141,16 +132,15 @@ 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) {
- syncer::ModelTypeSet to_migrate, difference;
- to_migrate.Put(syncer::NIGORI);
- difference.Put(syncer::AUTOFILL);
- difference.Put(syncer::BOOKMARKS);
+ ModelTypeSet to_migrate, difference;
+ to_migrate.Put(NIGORI);
+ difference.Put(AUTOFILL);
+ difference.Put(BOOKMARKS);
EXPECT_CALL(*manager(), state())
.WillOnce(Return(DataTypeManager::CONFIGURED));
- EXPECT_CALL(*manager(),
- PurgeForMigration(_, syncer::CONFIGURE_REASON_MIGRATION));
+ EXPECT_CALL(*manager(), PurgeForMigration(_, CONFIGURE_REASON_MIGRATION));
migrator()->MigrateTypes(to_migrate);
EXPECT_EQ(BackendMigrator::DISABLING_TYPES, migrator()->state());
@@ -159,7 +149,7 @@ TEST_F(SyncBackendMigratorTest, MigrateNigori) {
SendConfigureDone(DataTypeManager::OK, difference);
EXPECT_EQ(BackendMigrator::REENABLING_TYPES, migrator()->state());
- SetUnsyncedTypes(syncer::ModelTypeSet());
+ SetUnsyncedTypes(ModelTypeSet());
SendConfigureDone(DataTypeManager::OK, preferred_types());
EXPECT_EQ(BackendMigrator::IDLE, migrator()->state());
}
@@ -167,8 +157,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) {
- syncer::ModelTypeSet to_migrate;
- to_migrate.Put(syncer::PREFERENCES);
+ ModelTypeSet to_migrate;
+ to_migrate.Put(PREFERENCES);
EXPECT_CALL(*manager(), state())
.WillOnce(Return(DataTypeManager::CONFIGURING));
@@ -179,10 +169,9 @@ TEST_F(SyncBackendMigratorTest, WaitToStart) {
Mock::VerifyAndClearExpectations(manager());
EXPECT_CALL(*manager(), state())
.WillOnce(Return(DataTypeManager::CONFIGURED));
- EXPECT_CALL(*manager(),
- PurgeForMigration(_, syncer::CONFIGURE_REASON_MIGRATION));
- SetUnsyncedTypes(syncer::ModelTypeSet());
- SendConfigureDone(DataTypeManager::OK, syncer::ModelTypeSet());
+ EXPECT_CALL(*manager(), PurgeForMigration(_, CONFIGURE_REASON_MIGRATION));
+ SetUnsyncedTypes(ModelTypeSet());
+ SendConfigureDone(DataTypeManager::OK, ModelTypeSet());
EXPECT_EQ(BackendMigrator::DISABLING_TYPES, migrator()->state());
}
@@ -190,32 +179,28 @@ TEST_F(SyncBackendMigratorTest, WaitToStart) {
// Test that the migrator can cope with a migration request while a migration
// is in progress.
TEST_F(SyncBackendMigratorTest, RestartMigration) {
- 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);
+ 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);
EXPECT_CALL(*manager(), state())
.WillOnce(Return(DataTypeManager::CONFIGURED));
- EXPECT_CALL(*manager(),
- PurgeForMigration(_, syncer::CONFIGURE_REASON_MIGRATION))
+ EXPECT_CALL(*manager(), PurgeForMigration(_, CONFIGURE_REASON_MIGRATION))
.Times(2);
migrator()->MigrateTypes(to_migrate1);
EXPECT_EQ(BackendMigrator::DISABLING_TYPES, migrator()->state());
migrator()->MigrateTypes(to_migrate2);
- const syncer::ModelTypeSet difference1 =
- Difference(preferred_types(), to_migrate1);
+ const ModelTypeSet difference1 = Difference(preferred_types(), to_migrate1);
Mock::VerifyAndClearExpectations(manager());
- EXPECT_CALL(*manager(),
- PurgeForMigration(_, syncer::CONFIGURE_REASON_MIGRATION))
- .Times(1);
- EXPECT_CALL(*manager(), Configure(_, syncer::CONFIGURE_REASON_MIGRATION))
+ EXPECT_CALL(*manager(), PurgeForMigration(_, 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());
@@ -228,25 +213,23 @@ TEST_F(SyncBackendMigratorTest, RestartMigration) {
// Test that an external invocation of Configure(...) during a migration results
// in a migration reattempt.
TEST_F(SyncBackendMigratorTest, InterruptedWhileDisablingTypes) {
- syncer::ModelTypeSet to_migrate;
- syncer::ModelTypeSet difference;
- to_migrate.Put(syncer::PREFERENCES);
- difference.Put(syncer::AUTOFILL);
- difference.Put(syncer::BOOKMARKS);
+ ModelTypeSet to_migrate;
+ ModelTypeSet difference;
+ to_migrate.Put(PREFERENCES);
+ difference.Put(AUTOFILL);
+ difference.Put(BOOKMARKS);
EXPECT_CALL(*manager(), state())
.WillOnce(Return(DataTypeManager::CONFIGURED));
- EXPECT_CALL(*manager(),
- PurgeForMigration(HasModelTypes(to_migrate),
- syncer::CONFIGURE_REASON_MIGRATION));
+ EXPECT_CALL(*manager(), PurgeForMigration(HasModelTypes(to_migrate),
+ CONFIGURE_REASON_MIGRATION));
migrator()->MigrateTypes(to_migrate);
EXPECT_EQ(BackendMigrator::DISABLING_TYPES, migrator()->state());
Mock::VerifyAndClearExpectations(manager());
- EXPECT_CALL(*manager(),
- PurgeForMigration(HasModelTypes(to_migrate),
- syncer::CONFIGURE_REASON_MIGRATION));
- SetUnsyncedTypes(syncer::ModelTypeSet());
+ EXPECT_CALL(*manager(), PurgeForMigration(HasModelTypes(to_migrate),
+ CONFIGURE_REASON_MIGRATION));
+ SetUnsyncedTypes(ModelTypeSet());
SendConfigureDone(DataTypeManager::OK, preferred_types());
EXPECT_EQ(BackendMigrator::DISABLING_TYPES, migrator()->state());
@@ -256,18 +239,16 @@ TEST_F(SyncBackendMigratorTest, InterruptedWhileDisablingTypes) {
// migrator while it's waiting for disabled types to have been purged
// from the sync db.
TEST_F(SyncBackendMigratorTest, WaitingForPurge) {
- syncer::ModelTypeSet to_migrate, difference;
- to_migrate.Put(syncer::PREFERENCES);
- to_migrate.Put(syncer::AUTOFILL);
- difference.Put(syncer::BOOKMARKS);
+ ModelTypeSet to_migrate, difference;
+ to_migrate.Put(PREFERENCES);
+ to_migrate.Put(AUTOFILL);
+ difference.Put(BOOKMARKS);
EXPECT_CALL(*manager(), state())
.WillOnce(Return(DataTypeManager::CONFIGURED));
- EXPECT_CALL(*manager(),
- PurgeForMigration(_, syncer::CONFIGURE_REASON_MIGRATION))
- .Times(1);
- EXPECT_CALL(*manager(), Configure(_, syncer::CONFIGURE_REASON_MIGRATION))
+ EXPECT_CALL(*manager(), PurgeForMigration(_, 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());
@@ -275,8 +256,8 @@ TEST_F(SyncBackendMigratorTest, WaitingForPurge) {
SendConfigureDone(DataTypeManager::OK, difference);
EXPECT_EQ(BackendMigrator::DISABLING_TYPES, migrator()->state());
- syncer::ModelTypeSet prefs;
- prefs.Put(syncer::PREFERENCES);
+ ModelTypeSet prefs;
+ prefs.Put(PREFERENCES);
SetUnsyncedTypes(prefs);
SendConfigureDone(DataTypeManager::OK, difference);
EXPECT_EQ(BackendMigrator::DISABLING_TYPES, migrator()->state());
@@ -287,39 +268,36 @@ TEST_F(SyncBackendMigratorTest, WaitingForPurge) {
}
TEST_F(SyncBackendMigratorTest, MigratedTypeDisabledByUserDuringMigration) {
- syncer::ModelTypeSet to_migrate;
- to_migrate.Put(syncer::PREFERENCES);
+ ModelTypeSet to_migrate;
+ to_migrate.Put(PREFERENCES);
EXPECT_CALL(*manager(), state())
.WillOnce(Return(DataTypeManager::CONFIGURED));
- EXPECT_CALL(*manager(),
- PurgeForMigration(_, syncer::CONFIGURE_REASON_MIGRATION))
- .Times(1);
- EXPECT_CALL(*manager(), Configure(_, syncer::CONFIGURE_REASON_MIGRATION))
+ EXPECT_CALL(*manager(), PurgeForMigration(_, CONFIGURE_REASON_MIGRATION))
.Times(1);
+ EXPECT_CALL(*manager(), Configure(_, CONFIGURE_REASON_MIGRATION)).Times(1);
migrator()->MigrateTypes(to_migrate);
- RemovePreferredType(syncer::PREFERENCES);
+ RemovePreferredType(PREFERENCES);
SetUnsyncedTypes(to_migrate);
SendConfigureDone(DataTypeManager::OK, preferred_types());
EXPECT_EQ(BackendMigrator::REENABLING_TYPES, migrator()->state());
- SetUnsyncedTypes(syncer::ModelTypeSet());
+ SetUnsyncedTypes(ModelTypeSet());
SendConfigureDone(DataTypeManager::OK, preferred_types());
EXPECT_EQ(BackendMigrator::IDLE, migrator()->state());
}
TEST_F(SyncBackendMigratorTest, ConfigureFailure) {
- syncer::ModelTypeSet to_migrate;
- to_migrate.Put(syncer::PREFERENCES);
+ ModelTypeSet to_migrate;
+ to_migrate.Put(PREFERENCES);
EXPECT_CALL(*manager(), state())
.WillOnce(Return(DataTypeManager::CONFIGURED));
- EXPECT_CALL(*manager(),
- PurgeForMigration(_, syncer::CONFIGURE_REASON_MIGRATION))
+ EXPECT_CALL(*manager(), PurgeForMigration(_, CONFIGURE_REASON_MIGRATION))
.Times(1);
migrator()->MigrateTypes(to_migrate);
- SetUnsyncedTypes(syncer::ModelTypeSet());
- SendConfigureDone(DataTypeManager::ABORTED, syncer::ModelTypeSet());
+ SetUnsyncedTypes(ModelTypeSet());
+ SendConfigureDone(DataTypeManager::ABORTED, 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