| 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/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/test/base/testing_profile.h" | 9 #include "chrome/test/base/testing_profile.h" |
| 10 #include "content/public/test/test_browser_thread.h" | 10 #include "content/public/test/test_browser_thread.h" |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 }; | 73 }; |
| 74 | 74 |
| 75 TEST_F(SyncBackendRegistrarTest, ConstructorEmpty) { | 75 TEST_F(SyncBackendRegistrarTest, ConstructorEmpty) { |
| 76 TestingProfile profile; | 76 TestingProfile profile; |
| 77 SyncBackendRegistrar registrar("test", &profile, &loop_); | 77 SyncBackendRegistrar registrar("test", &profile, &loop_); |
| 78 registrar.SetInitialTypes(ModelTypeSet()); | 78 registrar.SetInitialTypes(ModelTypeSet()); |
| 79 EXPECT_FALSE(registrar.IsNigoriEnabled()); | 79 EXPECT_FALSE(registrar.IsNigoriEnabled()); |
| 80 { | 80 { |
| 81 std::vector<syncer::ModelSafeWorker*> workers; | 81 std::vector<syncer::ModelSafeWorker*> workers; |
| 82 registrar.GetWorkers(&workers); | 82 registrar.GetWorkers(&workers); |
| 83 EXPECT_EQ(4u, workers.size()); | 83 EXPECT_EQ(5u, workers.size()); |
| 84 } | 84 } |
| 85 ExpectRoutingInfo(®istrar, syncer::ModelSafeRoutingInfo()); | 85 ExpectRoutingInfo(®istrar, syncer::ModelSafeRoutingInfo()); |
| 86 ExpectHasProcessorsForTypes(registrar, ModelTypeSet()); | 86 ExpectHasProcessorsForTypes(registrar, ModelTypeSet()); |
| 87 registrar.OnSyncerShutdownComplete(); | 87 registrar.OnSyncerShutdownComplete(); |
| 88 registrar.StopOnUIThread(); | 88 registrar.StopOnUIThread(); |
| 89 } | 89 } |
| 90 | 90 |
| 91 TEST_F(SyncBackendRegistrarTest, ConstructorNonEmpty) { | 91 TEST_F(SyncBackendRegistrarTest, ConstructorNonEmpty) { |
| 92 TestingProfile profile; | 92 TestingProfile profile; |
| 93 const ModelTypeSet initial_types(BOOKMARKS, NIGORI, PASSWORDS); | 93 const ModelTypeSet initial_types(BOOKMARKS, NIGORI, PASSWORDS); |
| 94 SyncBackendRegistrar registrar("test", &profile, &loop_); | 94 SyncBackendRegistrar registrar("test", &profile, &loop_); |
| 95 registrar.SetInitialTypes(initial_types); | 95 registrar.SetInitialTypes(initial_types); |
| 96 EXPECT_TRUE(registrar.IsNigoriEnabled()); | 96 EXPECT_TRUE(registrar.IsNigoriEnabled()); |
| 97 { | 97 { |
| 98 std::vector<syncer::ModelSafeWorker*> workers; | 98 std::vector<syncer::ModelSafeWorker*> workers; |
| 99 registrar.GetWorkers(&workers); | 99 registrar.GetWorkers(&workers); |
| 100 EXPECT_EQ(4u, workers.size()); | 100 EXPECT_EQ(5u, workers.size()); |
| 101 } | 101 } |
| 102 { | 102 { |
| 103 syncer::ModelSafeRoutingInfo expected_routing_info; | 103 syncer::ModelSafeRoutingInfo expected_routing_info; |
| 104 expected_routing_info[BOOKMARKS] = syncer::GROUP_PASSIVE; | 104 expected_routing_info[BOOKMARKS] = syncer::GROUP_PASSIVE; |
| 105 expected_routing_info[NIGORI] = syncer::GROUP_PASSIVE; | 105 expected_routing_info[NIGORI] = syncer::GROUP_CONTROL; |
| 106 // Passwords dropped because of no password store. | 106 // Passwords dropped because of no password store. |
| 107 ExpectRoutingInfo(®istrar, expected_routing_info); | 107 ExpectRoutingInfo(®istrar, expected_routing_info); |
| 108 } | 108 } |
| 109 ExpectHasProcessorsForTypes(registrar, ModelTypeSet()); | 109 ExpectHasProcessorsForTypes(registrar, ModelTypeSet()); |
| 110 registrar.OnSyncerShutdownComplete(); | 110 registrar.OnSyncerShutdownComplete(); |
| 111 registrar.StopOnUIThread(); | 111 registrar.StopOnUIThread(); |
| 112 } | 112 } |
| 113 | 113 |
| 114 TEST_F(SyncBackendRegistrarTest, ConfigureDataTypes) { | 114 TEST_F(SyncBackendRegistrarTest, ConfigureDataTypes) { |
| 115 TestingProfile profile; | 115 TestingProfile profile; |
| 116 SyncBackendRegistrar registrar("test", &profile, &loop_); | 116 SyncBackendRegistrar registrar("test", &profile, &loop_); |
| 117 registrar.SetInitialTypes(ModelTypeSet()); | 117 registrar.SetInitialTypes(ModelTypeSet()); |
| 118 | 118 |
| 119 // Add. | 119 // Add. |
| 120 const ModelTypeSet types1(BOOKMARKS, NIGORI, AUTOFILL); | 120 const ModelTypeSet types1(BOOKMARKS, NIGORI, AUTOFILL); |
| 121 EXPECT_TRUE( | 121 EXPECT_TRUE( |
| 122 registrar.ConfigureDataTypes(types1, ModelTypeSet()).Equals(types1)); | 122 registrar.ConfigureDataTypes(types1, ModelTypeSet()).Equals(types1)); |
| 123 { | 123 { |
| 124 syncer::ModelSafeRoutingInfo expected_routing_info; | 124 syncer::ModelSafeRoutingInfo expected_routing_info; |
| 125 expected_routing_info[BOOKMARKS] = syncer::GROUP_PASSIVE; | 125 expected_routing_info[BOOKMARKS] = syncer::GROUP_PASSIVE; |
| 126 expected_routing_info[NIGORI] = syncer::GROUP_PASSIVE; | |
| 127 expected_routing_info[AUTOFILL] = syncer::GROUP_PASSIVE; | 126 expected_routing_info[AUTOFILL] = syncer::GROUP_PASSIVE; |
| 127 expected_routing_info[NIGORI] = syncer::GROUP_CONTROL; |
| 128 ExpectRoutingInfo(®istrar, expected_routing_info); | 128 ExpectRoutingInfo(®istrar, expected_routing_info); |
| 129 } | 129 } |
| 130 ExpectHasProcessorsForTypes(registrar, ModelTypeSet()); | 130 ExpectHasProcessorsForTypes(registrar, ModelTypeSet()); |
| 131 | 131 |
| 132 // Add and remove. | 132 // Add and remove. |
| 133 const ModelTypeSet types2(PREFERENCES, THEMES); | 133 const ModelTypeSet types2(PREFERENCES, THEMES); |
| 134 EXPECT_TRUE(registrar.ConfigureDataTypes(types2, types1).Equals(types2)); | 134 EXPECT_TRUE(registrar.ConfigureDataTypes(types2, types1).Equals(types2)); |
| 135 { | 135 { |
| 136 syncer::ModelSafeRoutingInfo expected_routing_info; | 136 syncer::ModelSafeRoutingInfo expected_routing_info; |
| 137 expected_routing_info[PREFERENCES] = syncer::GROUP_PASSIVE; | 137 expected_routing_info[PREFERENCES] = syncer::GROUP_PASSIVE; |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 246 // Should do nothing. | 246 // Should do nothing. |
| 247 TriggerChanges(®istrar, AUTOFILL); | 247 TriggerChanges(®istrar, AUTOFILL); |
| 248 | 248 |
| 249 registrar.OnSyncerShutdownComplete(); | 249 registrar.OnSyncerShutdownComplete(); |
| 250 registrar.StopOnUIThread(); | 250 registrar.StopOnUIThread(); |
| 251 } | 251 } |
| 252 | 252 |
| 253 } // namespace | 253 } // namespace |
| 254 | 254 |
| 255 } // namespace browser_sync | 255 } // namespace browser_sync |
| OLD | NEW |