| 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/sync/glue/sync_backend_registrar.h" | 5 #include "chrome/browser/sync/glue/sync_backend_registrar.h" |
| 6 | 6 |
| 7 #include "chrome/browser/sync/glue/change_processor_mock.h" | 7 #include "chrome/browser/sync/glue/change_processor_mock.h" |
| 8 #include "chrome/browser/sync/glue/ui_model_worker.h" | 8 #include "chrome/browser/sync/glue/ui_model_worker.h" |
| 9 #include "chrome/browser/sync/syncable/model_type.h" | 9 #include "chrome/browser/sync/syncable/model_type.h" |
| 10 #include "chrome/test/base/testing_profile.h" | 10 #include "chrome/test/base/testing_profile.h" |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 | 67 |
| 68 MessageLoop loop_; | 68 MessageLoop loop_; |
| 69 TestUserShare test_user_share_; | 69 TestUserShare test_user_share_; |
| 70 | 70 |
| 71 private: | 71 private: |
| 72 BrowserThread ui_thread_; | 72 BrowserThread ui_thread_; |
| 73 }; | 73 }; |
| 74 | 74 |
| 75 TEST_F(SyncBackendRegistrarTest, ConstructorEmpty) { | 75 TEST_F(SyncBackendRegistrarTest, ConstructorEmpty) { |
| 76 TestingProfile profile; | 76 TestingProfile profile; |
| 77 SyncBackendRegistrar registrar(ModelTypeSet(), | 77 SyncBackendRegistrar registrar(ModelTypeSet(), "test", &profile, &loop_); |
| 78 &profile, &loop_); | |
| 79 EXPECT_FALSE(registrar.IsNigoriEnabled()); | 78 EXPECT_FALSE(registrar.IsNigoriEnabled()); |
| 80 { | 79 { |
| 81 std::vector<ModelSafeWorker*> workers; | 80 std::vector<ModelSafeWorker*> workers; |
| 82 registrar.GetWorkers(&workers); | 81 registrar.GetWorkers(&workers); |
| 83 EXPECT_EQ(3u, workers.size()); | 82 EXPECT_EQ(3u, workers.size()); |
| 84 } | 83 } |
| 85 ExpectRoutingInfo(®istrar, ModelSafeRoutingInfo()); | 84 ExpectRoutingInfo(®istrar, ModelSafeRoutingInfo()); |
| 86 ExpectHasProcessorsForTypes(®istrar, ModelTypeSet()); | 85 ExpectHasProcessorsForTypes(®istrar, ModelTypeSet()); |
| 87 registrar.OnSyncerShutdownComplete(); | 86 registrar.OnSyncerShutdownComplete(); |
| 88 registrar.StopOnUIThread(); | 87 registrar.StopOnUIThread(); |
| 89 } | 88 } |
| 90 | 89 |
| 91 TEST_F(SyncBackendRegistrarTest, ConstructorNonEmpty) { | 90 TEST_F(SyncBackendRegistrarTest, ConstructorNonEmpty) { |
| 92 TestingProfile profile; | 91 TestingProfile profile; |
| 93 ModelTypeSet initial_types; | 92 ModelTypeSet initial_types; |
| 94 initial_types.insert(BOOKMARKS); | 93 initial_types.insert(BOOKMARKS); |
| 95 initial_types.insert(NIGORI); | 94 initial_types.insert(NIGORI); |
| 96 initial_types.insert(PASSWORDS); | 95 initial_types.insert(PASSWORDS); |
| 97 SyncBackendRegistrar registrar(initial_types, | 96 SyncBackendRegistrar registrar(initial_types, "test", &profile, &loop_); |
| 98 &profile, &loop_); | |
| 99 EXPECT_TRUE(registrar.IsNigoriEnabled()); | 97 EXPECT_TRUE(registrar.IsNigoriEnabled()); |
| 100 { | 98 { |
| 101 std::vector<ModelSafeWorker*> workers; | 99 std::vector<ModelSafeWorker*> workers; |
| 102 registrar.GetWorkers(&workers); | 100 registrar.GetWorkers(&workers); |
| 103 EXPECT_EQ(3u, workers.size()); | 101 EXPECT_EQ(3u, workers.size()); |
| 104 } | 102 } |
| 105 { | 103 { |
| 106 ModelSafeRoutingInfo expected_routing_info; | 104 ModelSafeRoutingInfo expected_routing_info; |
| 107 expected_routing_info[BOOKMARKS] = GROUP_PASSIVE; | 105 expected_routing_info[BOOKMARKS] = GROUP_PASSIVE; |
| 108 expected_routing_info[NIGORI] = GROUP_PASSIVE; | 106 expected_routing_info[NIGORI] = GROUP_PASSIVE; |
| 109 // Passwords dropped because of no password store. | 107 // Passwords dropped because of no password store. |
| 110 ExpectRoutingInfo(®istrar, expected_routing_info); | 108 ExpectRoutingInfo(®istrar, expected_routing_info); |
| 111 } | 109 } |
| 112 ExpectHasProcessorsForTypes(®istrar, ModelTypeSet()); | 110 ExpectHasProcessorsForTypes(®istrar, ModelTypeSet()); |
| 113 registrar.OnSyncerShutdownComplete(); | 111 registrar.OnSyncerShutdownComplete(); |
| 114 registrar.StopOnUIThread(); | 112 registrar.StopOnUIThread(); |
| 115 } | 113 } |
| 116 | 114 |
| 117 TEST_F(SyncBackendRegistrarTest, ConfigureDataTypes) { | 115 TEST_F(SyncBackendRegistrarTest, ConfigureDataTypes) { |
| 118 TestingProfile profile; | 116 TestingProfile profile; |
| 119 SyncBackendRegistrar registrar(ModelTypeSet(), | 117 SyncBackendRegistrar registrar(ModelTypeSet(), "test", &profile, &loop_); |
| 120 &profile, &loop_); | |
| 121 | 118 |
| 122 // Add. | 119 // Add. |
| 123 ModelTypeSet types1; | 120 ModelTypeSet types1; |
| 124 types1.insert(BOOKMARKS); | 121 types1.insert(BOOKMARKS); |
| 125 types1.insert(NIGORI); | 122 types1.insert(NIGORI); |
| 126 types1.insert(AUTOFILL); | 123 types1.insert(AUTOFILL); |
| 127 EXPECT_EQ(types1, registrar.ConfigureDataTypes(types1, ModelTypeSet())); | 124 EXPECT_EQ(types1, registrar.ConfigureDataTypes(types1, ModelTypeSet())); |
| 128 { | 125 { |
| 129 ModelSafeRoutingInfo expected_routing_info; | 126 ModelSafeRoutingInfo expected_routing_info; |
| 130 expected_routing_info[BOOKMARKS] = GROUP_PASSIVE; | 127 expected_routing_info[BOOKMARKS] = GROUP_PASSIVE; |
| (...skipping 21 matching lines...) Expand all Loading... |
| 152 ExpectRoutingInfo(®istrar, ModelSafeRoutingInfo()); | 149 ExpectRoutingInfo(®istrar, ModelSafeRoutingInfo()); |
| 153 ExpectHasProcessorsForTypes(®istrar, ModelTypeSet()); | 150 ExpectHasProcessorsForTypes(®istrar, ModelTypeSet()); |
| 154 | 151 |
| 155 registrar.OnSyncerShutdownComplete(); | 152 registrar.OnSyncerShutdownComplete(); |
| 156 registrar.StopOnUIThread(); | 153 registrar.StopOnUIThread(); |
| 157 } | 154 } |
| 158 | 155 |
| 159 TEST_F(SyncBackendRegistrarTest, ActivateDeactivateUIDataType) { | 156 TEST_F(SyncBackendRegistrarTest, ActivateDeactivateUIDataType) { |
| 160 InSequence in_sequence; | 157 InSequence in_sequence; |
| 161 TestingProfile profile; | 158 TestingProfile profile; |
| 162 SyncBackendRegistrar registrar(ModelTypeSet(), &profile, &loop_); | 159 SyncBackendRegistrar registrar(ModelTypeSet(), "test", &profile, &loop_); |
| 163 StrictMock<ChangeProcessorMock> change_processor_mock; | 160 StrictMock<ChangeProcessorMock> change_processor_mock; |
| 164 EXPECT_CALL(change_processor_mock, StartImpl(&profile)); | 161 EXPECT_CALL(change_processor_mock, StartImpl(&profile)); |
| 165 EXPECT_CALL(change_processor_mock, IsRunning()) | 162 EXPECT_CALL(change_processor_mock, IsRunning()) |
| 166 .WillRepeatedly(Return(true)); | 163 .WillRepeatedly(Return(true)); |
| 167 EXPECT_CALL(change_processor_mock, StopImpl()); | 164 EXPECT_CALL(change_processor_mock, StopImpl()); |
| 168 EXPECT_CALL(change_processor_mock, IsRunning()) | 165 EXPECT_CALL(change_processor_mock, IsRunning()) |
| 169 .WillRepeatedly(Return(false)); | 166 .WillRepeatedly(Return(false)); |
| 170 | 167 |
| 171 ModelTypeSet types; | 168 ModelTypeSet types; |
| 172 types.insert(BOOKMARKS); | 169 types.insert(BOOKMARKS); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 186 ExpectHasProcessorsForTypes(®istrar, ModelTypeSet()); | 183 ExpectHasProcessorsForTypes(®istrar, ModelTypeSet()); |
| 187 | 184 |
| 188 registrar.OnSyncerShutdownComplete(); | 185 registrar.OnSyncerShutdownComplete(); |
| 189 registrar.StopOnUIThread(); | 186 registrar.StopOnUIThread(); |
| 190 } | 187 } |
| 191 | 188 |
| 192 TEST_F(SyncBackendRegistrarTest, ActivateDeactivateNonUIDataType) { | 189 TEST_F(SyncBackendRegistrarTest, ActivateDeactivateNonUIDataType) { |
| 193 BrowserThread db_thread(BrowserThread::DB, &loop_); | 190 BrowserThread db_thread(BrowserThread::DB, &loop_); |
| 194 InSequence in_sequence; | 191 InSequence in_sequence; |
| 195 TestingProfile profile; | 192 TestingProfile profile; |
| 196 SyncBackendRegistrar registrar(ModelTypeSet(), &profile, &loop_); | 193 SyncBackendRegistrar registrar(ModelTypeSet(), "test", &profile, &loop_); |
| 197 StrictMock<ChangeProcessorMock> change_processor_mock; | 194 StrictMock<ChangeProcessorMock> change_processor_mock; |
| 198 EXPECT_CALL(change_processor_mock, StartImpl(&profile)); | 195 EXPECT_CALL(change_processor_mock, StartImpl(&profile)); |
| 199 EXPECT_CALL(change_processor_mock, IsRunning()) | 196 EXPECT_CALL(change_processor_mock, IsRunning()) |
| 200 .WillRepeatedly(Return(true)); | 197 .WillRepeatedly(Return(true)); |
| 201 EXPECT_CALL(change_processor_mock, StopImpl()); | 198 EXPECT_CALL(change_processor_mock, StopImpl()); |
| 202 EXPECT_CALL(change_processor_mock, IsRunning()) | 199 EXPECT_CALL(change_processor_mock, IsRunning()) |
| 203 .WillRepeatedly(Return(false)); | 200 .WillRepeatedly(Return(false)); |
| 204 | 201 |
| 205 ModelTypeSet types; | 202 ModelTypeSet types; |
| 206 types.insert(AUTOFILL); | 203 types.insert(AUTOFILL); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 222 registrar.OnSyncerShutdownComplete(); | 219 registrar.OnSyncerShutdownComplete(); |
| 223 registrar.StopOnUIThread(); | 220 registrar.StopOnUIThread(); |
| 224 } | 221 } |
| 225 | 222 |
| 226 // TODO(akalin): Add tests for non-UI non-passive data types (see | 223 // TODO(akalin): Add tests for non-UI non-passive data types (see |
| 227 // http://crbug.com/93456). | 224 // http://crbug.com/93456). |
| 228 | 225 |
| 229 } // namespace | 226 } // namespace |
| 230 | 227 |
| 231 } // namespace browser_sync | 228 } // namespace browser_sync |
| OLD | NEW |