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