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

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

Issue 7281017: [Sync] Add RequestCleanupDisabledTypes() method to SyncManager (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 5 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) 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_host.h" 5 #include "chrome/browser/sync/glue/sync_backend_host.h"
6 6
7 #include <cstddef> 7 #include <cstddef>
8 8
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/message_loop.h" 10 #include "base/message_loop.h"
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 syncable::ModelTypeSet types; 117 syncable::ModelTypeSet types;
118 ModelSafeRoutingInfo routing_info; 118 ModelSafeRoutingInfo routing_info;
119 119
120 scoped_ptr<SyncBackendHost::PendingConfigureDataTypesState> 120 scoped_ptr<SyncBackendHost::PendingConfigureDataTypesState>
121 state(SyncBackendHost::MakePendingConfigModeState( 121 state(SyncBackendHost::MakePendingConfigModeState(
122 data_type_controllers, types, NULL, &routing_info, 122 data_type_controllers, types, NULL, &routing_info,
123 sync_api::CONFIGURE_REASON_RECONFIGURATION, false)); 123 sync_api::CONFIGURE_REASON_RECONFIGURATION, false));
124 EXPECT_TRUE(routing_info.empty()); 124 EXPECT_TRUE(routing_info.empty());
125 EXPECT_FALSE(state->ready_task.get()); 125 EXPECT_FALSE(state->ready_task.get());
126 EXPECT_EQ(types, state->initial_types); 126 EXPECT_EQ(types, state->initial_types);
127 EXPECT_FALSE(state->deleted_type);
128 EXPECT_TRUE(state->added_types.none()); 127 EXPECT_TRUE(state->added_types.none());
129 } 128 }
130 129
131 // No enabled types. 130 // No enabled types.
132 { 131 {
133 DataTypeController::TypeMap data_type_controllers; 132 DataTypeController::TypeMap data_type_controllers;
134 data_type_controllers[syncable::BOOKMARKS] = NULL; 133 data_type_controllers[syncable::BOOKMARKS] = NULL;
135 syncable::ModelTypeSet types; 134 syncable::ModelTypeSet types;
136 ModelSafeRoutingInfo routing_info; 135 ModelSafeRoutingInfo routing_info;
137 136
138 types.insert(syncable::NIGORI); 137 types.insert(syncable::NIGORI);
139 scoped_ptr<SyncBackendHost::PendingConfigureDataTypesState> 138 scoped_ptr<SyncBackendHost::PendingConfigureDataTypesState>
140 state(SyncBackendHost::MakePendingConfigModeState( 139 state(SyncBackendHost::MakePendingConfigModeState(
141 data_type_controllers, types, NULL, 140 data_type_controllers, types, NULL,
142 &routing_info, sync_api::CONFIGURE_REASON_RECONFIGURATION, true)); 141 &routing_info, sync_api::CONFIGURE_REASON_RECONFIGURATION, true));
143 EXPECT_TRUE(routing_info.empty()); 142 EXPECT_TRUE(routing_info.empty());
144 EXPECT_FALSE(state->ready_task.get()); 143 EXPECT_FALSE(state->ready_task.get());
145 EXPECT_EQ(types, state->initial_types); 144 EXPECT_EQ(types, state->initial_types);
146 EXPECT_TRUE(state->deleted_type);
147 EXPECT_TRUE(state->added_types.none()); 145 EXPECT_TRUE(state->added_types.none());
148 } 146 }
149 147
150 // Add type. 148 // Add type.
151 { 149 {
152 DataTypeController::TypeMap data_type_controllers; 150 DataTypeController::TypeMap data_type_controllers;
153 data_type_controllers[syncable::BOOKMARKS] = NULL; 151 data_type_controllers[syncable::BOOKMARKS] = NULL;
154 syncable::ModelTypeSet types; 152 syncable::ModelTypeSet types;
155 types.insert(syncable::BOOKMARKS); 153 types.insert(syncable::BOOKMARKS);
156 types.insert(syncable::NIGORI); 154 types.insert(syncable::NIGORI);
157 ModelSafeRoutingInfo routing_info; 155 ModelSafeRoutingInfo routing_info;
158 156
159 scoped_ptr<SyncBackendHost::PendingConfigureDataTypesState> 157 scoped_ptr<SyncBackendHost::PendingConfigureDataTypesState>
160 state(SyncBackendHost::MakePendingConfigModeState( 158 state(SyncBackendHost::MakePendingConfigModeState(
161 data_type_controllers, types, NULL, &routing_info, 159 data_type_controllers, types, NULL, &routing_info,
162 sync_api::CONFIGURE_REASON_RECONFIGURATION, true)); 160 sync_api::CONFIGURE_REASON_RECONFIGURATION, true));
163 161
164 ModelSafeRoutingInfo expected_routing_info; 162 ModelSafeRoutingInfo expected_routing_info;
165 expected_routing_info[syncable::BOOKMARKS] = GROUP_PASSIVE; 163 expected_routing_info[syncable::BOOKMARKS] = GROUP_PASSIVE;
166 EXPECT_EQ(expected_routing_info, routing_info); 164 EXPECT_EQ(expected_routing_info, routing_info);
167 EXPECT_FALSE(state->ready_task.get()); 165 EXPECT_FALSE(state->ready_task.get());
168 EXPECT_EQ(types, state->initial_types); 166 EXPECT_EQ(types, state->initial_types);
169 EXPECT_FALSE(state->deleted_type);
170 167
171 syncable::ModelTypeBitSet expected_added_types; 168 syncable::ModelTypeBitSet expected_added_types;
172 expected_added_types.set(syncable::BOOKMARKS); 169 expected_added_types.set(syncable::BOOKMARKS);
173 EXPECT_EQ(expected_added_types, state->added_types); 170 EXPECT_EQ(expected_added_types, state->added_types);
174 } 171 }
175 172
176 // Add existing type. 173 // Add existing type.
177 { 174 {
178 DataTypeController::TypeMap data_type_controllers; 175 DataTypeController::TypeMap data_type_controllers;
179 data_type_controllers[syncable::BOOKMARKS] = NULL; 176 data_type_controllers[syncable::BOOKMARKS] = NULL;
180 syncable::ModelTypeSet types; 177 syncable::ModelTypeSet types;
181 types.insert(syncable::BOOKMARKS); 178 types.insert(syncable::BOOKMARKS);
182 types.insert(syncable::NIGORI); 179 types.insert(syncable::NIGORI);
183 ModelSafeRoutingInfo routing_info; 180 ModelSafeRoutingInfo routing_info;
184 routing_info[syncable::BOOKMARKS] = GROUP_PASSIVE; 181 routing_info[syncable::BOOKMARKS] = GROUP_PASSIVE;
185 ModelSafeRoutingInfo expected_routing_info = routing_info; 182 ModelSafeRoutingInfo expected_routing_info = routing_info;
186 183
187 scoped_ptr<SyncBackendHost::PendingConfigureDataTypesState> 184 scoped_ptr<SyncBackendHost::PendingConfigureDataTypesState>
188 state(SyncBackendHost::MakePendingConfigModeState( 185 state(SyncBackendHost::MakePendingConfigModeState(
189 data_type_controllers, types, NULL, &routing_info, 186 data_type_controllers, types, NULL, &routing_info,
190 sync_api::CONFIGURE_REASON_RECONFIGURATION, true)); 187 sync_api::CONFIGURE_REASON_RECONFIGURATION, true));
191 188
192 EXPECT_EQ(expected_routing_info, routing_info); 189 EXPECT_EQ(expected_routing_info, routing_info);
193 EXPECT_FALSE(state->ready_task.get()); 190 EXPECT_FALSE(state->ready_task.get());
194 EXPECT_EQ(types, state->initial_types); 191 EXPECT_EQ(types, state->initial_types);
195 EXPECT_FALSE(state->deleted_type);
196 EXPECT_TRUE(state->added_types.none()); 192 EXPECT_TRUE(state->added_types.none());
197 } 193 }
198 194
199 // Delete type. 195 // Delete type.
200 { 196 {
201 DataTypeController::TypeMap data_type_controllers; 197 DataTypeController::TypeMap data_type_controllers;
202 data_type_controllers[syncable::BOOKMARKS] = NULL; 198 data_type_controllers[syncable::BOOKMARKS] = NULL;
203 syncable::ModelTypeSet types; 199 syncable::ModelTypeSet types;
204 types.insert(syncable::NIGORI); 200 types.insert(syncable::NIGORI);
205 ModelSafeRoutingInfo routing_info; 201 ModelSafeRoutingInfo routing_info;
206 routing_info[syncable::BOOKMARKS] = GROUP_PASSIVE; 202 routing_info[syncable::BOOKMARKS] = GROUP_PASSIVE;
207 203
208 scoped_ptr<SyncBackendHost::PendingConfigureDataTypesState> 204 scoped_ptr<SyncBackendHost::PendingConfigureDataTypesState>
209 state(SyncBackendHost::MakePendingConfigModeState( 205 state(SyncBackendHost::MakePendingConfigModeState(
210 data_type_controllers, types, NULL, &routing_info, 206 data_type_controllers, types, NULL, &routing_info,
211 sync_api::CONFIGURE_REASON_RECONFIGURATION, true)); 207 sync_api::CONFIGURE_REASON_RECONFIGURATION, true));
212 208
213 ModelSafeRoutingInfo expected_routing_info; 209 ModelSafeRoutingInfo expected_routing_info;
214 EXPECT_EQ(expected_routing_info, routing_info); 210 EXPECT_EQ(expected_routing_info, routing_info);
215 EXPECT_FALSE(state->ready_task.get()); 211 EXPECT_FALSE(state->ready_task.get());
216 EXPECT_EQ(types, state->initial_types); 212 EXPECT_EQ(types, state->initial_types);
217 EXPECT_TRUE(state->deleted_type);
218 EXPECT_TRUE(state->added_types.none()); 213 EXPECT_TRUE(state->added_types.none());
219 } 214 }
220 215
221 // Add Nigori. 216 // Add Nigori.
222 { 217 {
223 DataTypeController::TypeMap data_type_controllers; 218 DataTypeController::TypeMap data_type_controllers;
224 syncable::ModelTypeSet types; 219 syncable::ModelTypeSet types;
225 types.insert(syncable::NIGORI); 220 types.insert(syncable::NIGORI);
226 ModelSafeRoutingInfo routing_info; 221 ModelSafeRoutingInfo routing_info;
227 222
228 scoped_ptr<SyncBackendHost::PendingConfigureDataTypesState> 223 scoped_ptr<SyncBackendHost::PendingConfigureDataTypesState>
229 state(SyncBackendHost::MakePendingConfigModeState( 224 state(SyncBackendHost::MakePendingConfigModeState(
230 data_type_controllers, types, NULL, &routing_info, 225 data_type_controllers, types, NULL, &routing_info,
231 sync_api::CONFIGURE_REASON_RECONFIGURATION, false)); 226 sync_api::CONFIGURE_REASON_RECONFIGURATION, false));
232 227
233 ModelSafeRoutingInfo expected_routing_info; 228 ModelSafeRoutingInfo expected_routing_info;
234 expected_routing_info[syncable::NIGORI] = GROUP_PASSIVE; 229 expected_routing_info[syncable::NIGORI] = GROUP_PASSIVE;
235 EXPECT_EQ(expected_routing_info, routing_info); 230 EXPECT_EQ(expected_routing_info, routing_info);
236 EXPECT_FALSE(state->ready_task.get()); 231 EXPECT_FALSE(state->ready_task.get());
237 EXPECT_EQ(types, state->initial_types); 232 EXPECT_EQ(types, state->initial_types);
238 EXPECT_FALSE(state->deleted_type);
239 233
240 syncable::ModelTypeBitSet expected_added_types; 234 syncable::ModelTypeBitSet expected_added_types;
241 expected_added_types.set(syncable::NIGORI); 235 expected_added_types.set(syncable::NIGORI);
242 EXPECT_EQ(expected_added_types, state->added_types); 236 EXPECT_EQ(expected_added_types, state->added_types);
243 } 237 }
244 238
245 // Delete Nigori. 239 // Delete Nigori.
246 { 240 {
247 DataTypeController::TypeMap data_type_controllers; 241 DataTypeController::TypeMap data_type_controllers;
248 syncable::ModelTypeSet types; 242 syncable::ModelTypeSet types;
249 ModelSafeRoutingInfo routing_info; 243 ModelSafeRoutingInfo routing_info;
250 routing_info[syncable::NIGORI] = GROUP_PASSIVE; 244 routing_info[syncable::NIGORI] = GROUP_PASSIVE;
251 245
252 scoped_ptr<SyncBackendHost::PendingConfigureDataTypesState> 246 scoped_ptr<SyncBackendHost::PendingConfigureDataTypesState>
253 state(SyncBackendHost::MakePendingConfigModeState( 247 state(SyncBackendHost::MakePendingConfigModeState(
254 data_type_controllers, types, NULL, &routing_info, 248 data_type_controllers, types, NULL, &routing_info,
255 sync_api::CONFIGURE_REASON_RECONFIGURATION, true)); 249 sync_api::CONFIGURE_REASON_RECONFIGURATION, true));
256 250
257 ModelSafeRoutingInfo expected_routing_info; 251 ModelSafeRoutingInfo expected_routing_info;
258 EXPECT_EQ(expected_routing_info, routing_info); 252 EXPECT_EQ(expected_routing_info, routing_info);
259 EXPECT_FALSE(state->ready_task.get()); 253 EXPECT_FALSE(state->ready_task.get());
260 EXPECT_EQ(types, state->initial_types); 254 EXPECT_EQ(types, state->initial_types);
261 EXPECT_TRUE(state->deleted_type);
262 255
263 EXPECT_TRUE(state->added_types.none()); 256 EXPECT_TRUE(state->added_types.none());
264 } 257 }
265 } 258 }
266 259
267 // TODO(akalin): Write more SyncBackendHost unit tests. 260 // TODO(akalin): Write more SyncBackendHost unit tests.
268 261
269 } // namespace browser_sync 262 } // namespace browser_sync
OLDNEW
« chrome/browser/sync/engine/syncapi.cc ('K') | « chrome/browser/sync/glue/sync_backend_host.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698