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

Side by Side Diff: chrome/browser/sync/glue/sync_backend_registrar_unittest.cc

Issue 10520010: Not for review: Support sync init with missing or corrupt store (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Documentation Created 8 years, 6 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 66
67 MessageLoop loop_; 67 MessageLoop loop_;
68 TestUserShare test_user_share_; 68 TestUserShare test_user_share_;
69 69
70 private: 70 private:
71 content::TestBrowserThread ui_thread_; 71 content::TestBrowserThread ui_thread_;
72 }; 72 };
73 73
74 TEST_F(SyncBackendRegistrarTest, ConstructorEmpty) { 74 TEST_F(SyncBackendRegistrarTest, ConstructorEmpty) {
75 TestingProfile profile; 75 TestingProfile profile;
76 SyncBackendRegistrar registrar(ModelTypeSet(), "test", &profile, &loop_); 76 SyncBackendRegistrar registrar("test", &profile, &loop_);
77 registrar.SetInitialTypes(ModelTypeSet());
77 EXPECT_FALSE(registrar.IsNigoriEnabled()); 78 EXPECT_FALSE(registrar.IsNigoriEnabled());
78 { 79 {
79 std::vector<ModelSafeWorker*> workers; 80 std::vector<ModelSafeWorker*> workers;
80 registrar.GetWorkers(&workers); 81 registrar.GetWorkers(&workers);
81 EXPECT_EQ(4u, workers.size()); 82 EXPECT_EQ(4u, workers.size());
82 } 83 }
83 ExpectRoutingInfo(&registrar, ModelSafeRoutingInfo()); 84 ExpectRoutingInfo(&registrar, ModelSafeRoutingInfo());
84 ExpectHasProcessorsForTypes(registrar, ModelTypeSet()); 85 ExpectHasProcessorsForTypes(registrar, ModelTypeSet());
85 registrar.OnSyncerShutdownComplete(); 86 registrar.OnSyncerShutdownComplete();
86 registrar.StopOnUIThread(); 87 registrar.StopOnUIThread();
87 } 88 }
88 89
89 TEST_F(SyncBackendRegistrarTest, ConstructorNonEmpty) { 90 TEST_F(SyncBackendRegistrarTest, ConstructorNonEmpty) {
90 TestingProfile profile; 91 TestingProfile profile;
91 const ModelTypeSet initial_types(BOOKMARKS, NIGORI, PASSWORDS); 92 const ModelTypeSet initial_types(BOOKMARKS, NIGORI, PASSWORDS);
92 SyncBackendRegistrar registrar(initial_types, "test", &profile, &loop_); 93 SyncBackendRegistrar registrar("test", &profile, &loop_);
94 registrar.SetInitialTypes(initial_types);
93 EXPECT_TRUE(registrar.IsNigoriEnabled()); 95 EXPECT_TRUE(registrar.IsNigoriEnabled());
94 { 96 {
95 std::vector<ModelSafeWorker*> workers; 97 std::vector<ModelSafeWorker*> workers;
96 registrar.GetWorkers(&workers); 98 registrar.GetWorkers(&workers);
97 EXPECT_EQ(4u, workers.size()); 99 EXPECT_EQ(4u, workers.size());
98 } 100 }
99 { 101 {
100 ModelSafeRoutingInfo expected_routing_info; 102 ModelSafeRoutingInfo expected_routing_info;
101 expected_routing_info[BOOKMARKS] = GROUP_PASSIVE; 103 expected_routing_info[BOOKMARKS] = GROUP_PASSIVE;
102 expected_routing_info[NIGORI] = GROUP_PASSIVE; 104 expected_routing_info[NIGORI] = GROUP_PASSIVE;
103 // Passwords dropped because of no password store. 105 // Passwords dropped because of no password store.
104 ExpectRoutingInfo(&registrar, expected_routing_info); 106 ExpectRoutingInfo(&registrar, expected_routing_info);
105 } 107 }
106 ExpectHasProcessorsForTypes(registrar, ModelTypeSet()); 108 ExpectHasProcessorsForTypes(registrar, ModelTypeSet());
107 registrar.OnSyncerShutdownComplete(); 109 registrar.OnSyncerShutdownComplete();
108 registrar.StopOnUIThread(); 110 registrar.StopOnUIThread();
109 } 111 }
110 112
111 TEST_F(SyncBackendRegistrarTest, ConfigureDataTypes) { 113 TEST_F(SyncBackendRegistrarTest, ConfigureDataTypes) {
112 TestingProfile profile; 114 TestingProfile profile;
113 SyncBackendRegistrar registrar(ModelTypeSet(), "test", &profile, &loop_); 115 SyncBackendRegistrar registrar("test", &profile, &loop_);
116 registrar.SetInitialTypes(ModelTypeSet());
114 117
115 // Add. 118 // Add.
116 const ModelTypeSet types1(BOOKMARKS, NIGORI, AUTOFILL); 119 const ModelTypeSet types1(BOOKMARKS, NIGORI, AUTOFILL);
117 EXPECT_TRUE( 120 EXPECT_TRUE(
118 registrar.ConfigureDataTypes(types1, ModelTypeSet()).Equals(types1)); 121 registrar.ConfigureDataTypes(types1, ModelTypeSet()).Equals(types1));
119 { 122 {
120 ModelSafeRoutingInfo expected_routing_info; 123 ModelSafeRoutingInfo expected_routing_info;
121 expected_routing_info[BOOKMARKS] = GROUP_PASSIVE; 124 expected_routing_info[BOOKMARKS] = GROUP_PASSIVE;
122 expected_routing_info[NIGORI] = GROUP_PASSIVE; 125 expected_routing_info[NIGORI] = GROUP_PASSIVE;
123 expected_routing_info[AUTOFILL] = GROUP_PASSIVE; 126 expected_routing_info[AUTOFILL] = GROUP_PASSIVE;
(...skipping 23 matching lines...) Expand all
147 150
148 void TriggerChanges(SyncBackendRegistrar* registrar, ModelType type) { 151 void TriggerChanges(SyncBackendRegistrar* registrar, ModelType type) {
149 registrar->OnChangesApplied(type, NULL, 152 registrar->OnChangesApplied(type, NULL,
150 sync_api::ImmutableChangeRecordList()); 153 sync_api::ImmutableChangeRecordList());
151 registrar->OnChangesComplete(type); 154 registrar->OnChangesComplete(type);
152 } 155 }
153 156
154 TEST_F(SyncBackendRegistrarTest, ActivateDeactivateUIDataType) { 157 TEST_F(SyncBackendRegistrarTest, ActivateDeactivateUIDataType) {
155 InSequence in_sequence; 158 InSequence in_sequence;
156 TestingProfile profile; 159 TestingProfile profile;
157 SyncBackendRegistrar registrar(ModelTypeSet(), "test", &profile, &loop_); 160 SyncBackendRegistrar registrar("test", &profile, &loop_);
161 registrar.SetInitialTypes(ModelTypeSet());
158 162
159 // Should do nothing. 163 // Should do nothing.
160 TriggerChanges(&registrar, BOOKMARKS); 164 TriggerChanges(&registrar, BOOKMARKS);
161 165
162 StrictMock<ChangeProcessorMock> change_processor_mock; 166 StrictMock<ChangeProcessorMock> change_processor_mock;
163 EXPECT_CALL(change_processor_mock, StartImpl(&profile)); 167 EXPECT_CALL(change_processor_mock, StartImpl(&profile));
164 EXPECT_CALL(change_processor_mock, IsRunning()) 168 EXPECT_CALL(change_processor_mock, IsRunning())
165 .WillRepeatedly(Return(true)); 169 .WillRepeatedly(Return(true));
166 EXPECT_CALL(change_processor_mock, ApplyChangesFromSyncModel(NULL, _)); 170 EXPECT_CALL(change_processor_mock, ApplyChangesFromSyncModel(NULL, _));
167 EXPECT_CALL(change_processor_mock, IsRunning()) 171 EXPECT_CALL(change_processor_mock, IsRunning())
(...skipping 26 matching lines...) Expand all
194 TriggerChanges(&registrar, BOOKMARKS); 198 TriggerChanges(&registrar, BOOKMARKS);
195 199
196 registrar.OnSyncerShutdownComplete(); 200 registrar.OnSyncerShutdownComplete();
197 registrar.StopOnUIThread(); 201 registrar.StopOnUIThread();
198 } 202 }
199 203
200 TEST_F(SyncBackendRegistrarTest, ActivateDeactivateNonUIDataType) { 204 TEST_F(SyncBackendRegistrarTest, ActivateDeactivateNonUIDataType) {
201 content::TestBrowserThread db_thread(BrowserThread::DB, &loop_); 205 content::TestBrowserThread db_thread(BrowserThread::DB, &loop_);
202 InSequence in_sequence; 206 InSequence in_sequence;
203 TestingProfile profile; 207 TestingProfile profile;
204 SyncBackendRegistrar registrar(ModelTypeSet(), "test", &profile, &loop_); 208 SyncBackendRegistrar registrar("test", &profile, &loop_);
209 registrar.SetInitialTypes(ModelTypeSet());
205 210
206 // Should do nothing. 211 // Should do nothing.
207 TriggerChanges(&registrar, AUTOFILL); 212 TriggerChanges(&registrar, AUTOFILL);
208 213
209 StrictMock<ChangeProcessorMock> change_processor_mock; 214 StrictMock<ChangeProcessorMock> change_processor_mock;
210 EXPECT_CALL(change_processor_mock, StartImpl(&profile)); 215 EXPECT_CALL(change_processor_mock, StartImpl(&profile));
211 EXPECT_CALL(change_processor_mock, IsRunning()) 216 EXPECT_CALL(change_processor_mock, IsRunning())
212 .WillRepeatedly(Return(true)); 217 .WillRepeatedly(Return(true));
213 EXPECT_CALL(change_processor_mock, ApplyChangesFromSyncModel(NULL, _)); 218 EXPECT_CALL(change_processor_mock, ApplyChangesFromSyncModel(NULL, _));
214 EXPECT_CALL(change_processor_mock, IsRunning()) 219 EXPECT_CALL(change_processor_mock, IsRunning())
(...skipping 25 matching lines...) Expand all
240 // Should do nothing. 245 // Should do nothing.
241 TriggerChanges(&registrar, AUTOFILL); 246 TriggerChanges(&registrar, AUTOFILL);
242 247
243 registrar.OnSyncerShutdownComplete(); 248 registrar.OnSyncerShutdownComplete();
244 registrar.StopOnUIThread(); 249 registrar.StopOnUIThread();
245 } 250 }
246 251
247 } // namespace 252 } // namespace
248 253
249 } // namespace browser_sync 254 } // namespace browser_sync
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698