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 "chrome/browser/sync/backend_migrator.h" | 5 #include "chrome/browser/sync/backend_migrator.h" |
6 | 6 |
7 #include "base/message_loop/message_loop.h" | 7 #include "base/message_loop/message_loop.h" |
8 #include "base/run_loop.h" | |
8 #include "base/tracked_objects.h" | 9 #include "base/tracked_objects.h" |
9 #include "chrome/browser/chrome_notification_types.h" | 10 #include "chrome/browser/chrome_notification_types.h" |
10 #include "chrome/browser/sync/profile_sync_service_mock.h" | 11 #include "chrome/browser/sync/profile_sync_service_mock.h" |
11 #include "components/sync_driver/data_type_manager_mock.h" | 12 #include "components/sync_driver/data_type_manager_mock.h" |
13 #include "content/public/test/test_browser_thread_bundle.h" | |
12 #include "sync/internal_api/public/base/model_type_test_util.h" | 14 #include "sync/internal_api/public/base/model_type_test_util.h" |
13 #include "sync/internal_api/public/test/test_user_share.h" | 15 #include "sync/internal_api/public/test/test_user_share.h" |
14 #include "sync/internal_api/public/write_transaction.h" | 16 #include "sync/internal_api/public/write_transaction.h" |
15 #include "sync/protocol/sync.pb.h" | 17 #include "sync/protocol/sync.pb.h" |
16 #include "sync/syncable/directory.h" // TODO(tim): Remove. Bug 131130. | 18 #include "sync/syncable/directory.h" // TODO(tim): Remove. Bug 131130. |
17 #include "testing/gmock/include/gmock/gmock.h" | 19 #include "testing/gmock/include/gmock/gmock.h" |
18 #include "testing/gtest/include/gtest/gtest.h" | 20 #include "testing/gtest/include/gtest/gtest.h" |
19 | 21 |
20 using ::testing::_; | 22 using ::testing::_; |
21 using ::testing::Eq; | 23 using ::testing::Eq; |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
77 syncer::ModelTypeSet requested_types) { | 79 syncer::ModelTypeSet requested_types) { |
78 if (status == DataTypeManager::OK) { | 80 if (status == DataTypeManager::OK) { |
79 DataTypeManager::ConfigureResult result(status, requested_types); | 81 DataTypeManager::ConfigureResult result(status, requested_types); |
80 migrator_->OnConfigureDone(result); | 82 migrator_->OnConfigureDone(result); |
81 } else { | 83 } else { |
82 DataTypeManager::ConfigureResult result( | 84 DataTypeManager::ConfigureResult result( |
83 status, | 85 status, |
84 requested_types); | 86 requested_types); |
85 migrator_->OnConfigureDone(result); | 87 migrator_->OnConfigureDone(result); |
86 } | 88 } |
87 message_loop_.RunUntilIdle(); | 89 base::RunLoop run_loop; |
90 run_loop.RunUntilIdle(); | |
88 } | 91 } |
89 | 92 |
90 ProfileSyncService* service() { return &service_; } | 93 ProfileSyncService* service() { return &service_; } |
91 DataTypeManagerMock* manager() { return &manager_; } | 94 DataTypeManagerMock* manager() { return &manager_; } |
92 syncer::ModelTypeSet preferred_types() { return preferred_types_; } | 95 syncer::ModelTypeSet preferred_types() { return preferred_types_; } |
93 BackendMigrator* migrator() { return migrator_.get(); } | 96 BackendMigrator* migrator() { return migrator_.get(); } |
94 void RemovePreferredType(syncer::ModelType type) { | 97 void RemovePreferredType(syncer::ModelType type) { |
95 preferred_types_.Remove(type); | 98 preferred_types_.Remove(type); |
96 Mock::VerifyAndClear(&service_); | 99 Mock::VerifyAndClear(&service_); |
97 ON_CALL(service_, GetPreferredDataTypes()). | 100 ON_CALL(service_, GetPreferredDataTypes()). |
98 WillByDefault(Return(preferred_types_)); | 101 WillByDefault(Return(preferred_types_)); |
99 } | 102 } |
100 | 103 |
101 private: | 104 private: |
102 scoped_ptr<SyncSessionSnapshot> snap_; | 105 scoped_ptr<SyncSessionSnapshot> snap_; |
103 base::MessageLoop message_loop_; | 106 content::TestBrowserThreadBundle thread_bundle_; |
maniscalco
2015/02/18 17:03:00
nit: can you see about making thread_bundle_ the f
maxbogue
2015/02/18 19:00:06
Deleted it and the tests still pass.
| |
104 syncer::ModelTypeSet preferred_types_; | 107 syncer::ModelTypeSet preferred_types_; |
105 TestingProfile profile_; | 108 TestingProfile profile_; |
106 NiceMock<ProfileSyncServiceMock> service_; | 109 NiceMock<ProfileSyncServiceMock> service_; |
107 NiceMock<DataTypeManagerMock> manager_; | 110 NiceMock<DataTypeManagerMock> manager_; |
108 syncer::TestUserShare test_user_share_; | 111 syncer::TestUserShare test_user_share_; |
109 scoped_ptr<BackendMigrator> migrator_; | 112 scoped_ptr<BackendMigrator> migrator_; |
110 }; | 113 }; |
111 | 114 |
112 class MockMigrationObserver : public MigrationObserver { | 115 class MockMigrationObserver : public MigrationObserver { |
113 public: | 116 public: |
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
331 EXPECT_CALL( | 334 EXPECT_CALL( |
332 *manager(), | 335 *manager(), |
333 PurgeForMigration(_, syncer::CONFIGURE_REASON_MIGRATION)).Times(1); | 336 PurgeForMigration(_, syncer::CONFIGURE_REASON_MIGRATION)).Times(1); |
334 migrator()->MigrateTypes(to_migrate); | 337 migrator()->MigrateTypes(to_migrate); |
335 SetUnsyncedTypes(syncer::ModelTypeSet()); | 338 SetUnsyncedTypes(syncer::ModelTypeSet()); |
336 SendConfigureDone(DataTypeManager::ABORTED, syncer::ModelTypeSet()); | 339 SendConfigureDone(DataTypeManager::ABORTED, syncer::ModelTypeSet()); |
337 EXPECT_EQ(BackendMigrator::IDLE, migrator()->state()); | 340 EXPECT_EQ(BackendMigrator::IDLE, migrator()->state()); |
338 } | 341 } |
339 | 342 |
340 }; // namespace browser_sync | 343 }; // namespace browser_sync |
OLD | NEW |