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

Side by Side Diff: chrome/browser/sync/sessions/sync_session_unittest.cc

Issue 8625005: [Sync] Make ModelSafeWorker a true interface (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Sync to head Created 9 years, 1 month 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/sessions/sync_session.h" 5 #include "chrome/browser/sync/sessions/sync_session.h"
6 6
7 #include "base/compiler_specific.h" 7 #include "base/compiler_specific.h"
8 #include "base/location.h" 8 #include "base/location.h"
9 #include "base/memory/ref_counted.h" 9 #include "base/memory/ref_counted.h"
10 #include "base/message_loop.h" 10 #include "base/message_loop.h"
11 #include "chrome/browser/sync/engine/conflict_resolver.h" 11 #include "chrome/browser/sync/engine/conflict_resolver.h"
12 #include "chrome/browser/sync/engine/mock_model_safe_workers.h"
13 #include "chrome/browser/sync/engine/syncer_types.h" 12 #include "chrome/browser/sync/engine/syncer_types.h"
14 #include "chrome/browser/sync/syncable/directory_manager.h" 13 #include "chrome/browser/sync/syncable/directory_manager.h"
15 #include "chrome/browser/sync/syncable/model_type.h" 14 #include "chrome/browser/sync/syncable/model_type.h"
16 #include "chrome/browser/sync/syncable/syncable.h" 15 #include "chrome/browser/sync/syncable/syncable.h"
16 #include "chrome/browser/sync/test/engine/fake_model_worker.h"
17 #include "chrome/browser/sync/test/engine/test_directory_setter_upper.h" 17 #include "chrome/browser/sync/test/engine/test_directory_setter_upper.h"
18 #include "testing/gtest/include/gtest/gtest.h" 18 #include "testing/gtest/include/gtest/gtest.h"
19 19
20 using syncable::WriteTransaction; 20 using syncable::WriteTransaction;
21 21
22 namespace browser_sync { 22 namespace browser_sync {
23 namespace sessions { 23 namespace sessions {
24 namespace { 24 namespace {
25 25
26 class SyncSessionTest : public testing::Test, 26 class SyncSessionTest : public testing::Test,
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after
281 syncable::ModelTypePayloadMapFromBitSet( 281 syncable::ModelTypePayloadMapFromBitSet(
282 ParamsMeaningJustOneEnabledType(), 282 ParamsMeaningJustOneEnabledType(),
283 std::string()); 283 std::string());
284 syncable::ModelTypePayloadMap all_types = 284 syncable::ModelTypePayloadMap all_types =
285 syncable::ModelTypePayloadMapFromBitSet( 285 syncable::ModelTypePayloadMapFromBitSet(
286 ParamsMeaningAllEnabledTypes(), 286 ParamsMeaningAllEnabledTypes(),
287 std::string()); 287 std::string());
288 SyncSourceInfo source_one(sync_pb::GetUpdatesCallerInfo::PERIODIC, one_type); 288 SyncSourceInfo source_one(sync_pb::GetUpdatesCallerInfo::PERIODIC, one_type);
289 SyncSourceInfo source_two(sync_pb::GetUpdatesCallerInfo::LOCAL, all_types); 289 SyncSourceInfo source_two(sync_pb::GetUpdatesCallerInfo::LOCAL, all_types);
290 290
291 scoped_refptr<MockDBModelWorker> db_worker(new MockDBModelWorker()); 291 scoped_refptr<ModelSafeWorker> db_worker(new FakeModelWorker(GROUP_DB));
292 scoped_refptr<MockUIModelWorker> ui_worker(new MockUIModelWorker()); 292 scoped_refptr<ModelSafeWorker> ui_worker(new FakeModelWorker(GROUP_UI));
293 workers_one.push_back(db_worker); 293 workers_one.push_back(db_worker);
294 workers_two.push_back(db_worker); 294 workers_two.push_back(db_worker);
295 workers_two.push_back(ui_worker); 295 workers_two.push_back(ui_worker);
296 routes_one[syncable::AUTOFILL] = GROUP_DB; 296 routes_one[syncable::AUTOFILL] = GROUP_DB;
297 routes_two[syncable::AUTOFILL] = GROUP_DB; 297 routes_two[syncable::AUTOFILL] = GROUP_DB;
298 routes_two[syncable::BOOKMARKS] = GROUP_UI; 298 routes_two[syncable::BOOKMARKS] = GROUP_UI;
299 SyncSession one(context_.get(), this, source_one, routes_one, workers_one); 299 SyncSession one(context_.get(), this, source_one, routes_one, workers_one);
300 SyncSession two(context_.get(), this, source_two, routes_two, workers_two); 300 SyncSession two(context_.get(), this, source_two, routes_two, workers_two);
301 301
302 one.Coalesce(two); 302 one.Coalesce(two);
(...skipping 16 matching lines...) Expand all
319 syncable::ModelTypePayloadMapFromBitSet( 319 syncable::ModelTypePayloadMapFromBitSet(
320 ParamsMeaningJustOneEnabledType(), 320 ParamsMeaningJustOneEnabledType(),
321 std::string()); 321 std::string());
322 syncable::ModelTypePayloadMap all_types = 322 syncable::ModelTypePayloadMap all_types =
323 syncable::ModelTypePayloadMapFromBitSet( 323 syncable::ModelTypePayloadMapFromBitSet(
324 ParamsMeaningAllEnabledTypes(), 324 ParamsMeaningAllEnabledTypes(),
325 std::string()); 325 std::string());
326 SyncSourceInfo source_one(sync_pb::GetUpdatesCallerInfo::PERIODIC, one_type); 326 SyncSourceInfo source_one(sync_pb::GetUpdatesCallerInfo::PERIODIC, one_type);
327 SyncSourceInfo source_two(sync_pb::GetUpdatesCallerInfo::LOCAL, all_types); 327 SyncSourceInfo source_two(sync_pb::GetUpdatesCallerInfo::LOCAL, all_types);
328 328
329 scoped_refptr<MockDBModelWorker> db_worker(new MockDBModelWorker()); 329 scoped_refptr<ModelSafeWorker> db_worker(new FakeModelWorker(GROUP_DB));
330 scoped_refptr<MockUIModelWorker> ui_worker(new MockUIModelWorker()); 330 scoped_refptr<ModelSafeWorker> ui_worker(new FakeModelWorker(GROUP_UI));
331 workers_one.push_back(db_worker); 331 workers_one.push_back(db_worker);
332 workers_two.push_back(db_worker); 332 workers_two.push_back(db_worker);
333 workers_two.push_back(ui_worker); 333 workers_two.push_back(ui_worker);
334 routes_one[syncable::AUTOFILL] = GROUP_DB; 334 routes_one[syncable::AUTOFILL] = GROUP_DB;
335 routes_two[syncable::AUTOFILL] = GROUP_UI; 335 routes_two[syncable::AUTOFILL] = GROUP_UI;
336 routes_two[syncable::BOOKMARKS] = GROUP_UI; 336 routes_two[syncable::BOOKMARKS] = GROUP_UI;
337 SyncSession one(context_.get(), this, source_one, routes_one, workers_one); 337 SyncSession one(context_.get(), this, source_one, routes_one, workers_one);
338 SyncSession two(context_.get(), this, source_two, routes_two, workers_two); 338 SyncSession two(context_.get(), this, source_two, routes_two, workers_two);
339 339
340 two.RebaseRoutingInfoWithLatest(&one); 340 two.RebaseRoutingInfoWithLatest(&one);
(...skipping 27 matching lines...) Expand all
368 ModelSafeRoutingInfo routes_first, routes_second; 368 ModelSafeRoutingInfo routes_first, routes_second;
369 syncable::ModelTypePayloadMap all_types = 369 syncable::ModelTypePayloadMap all_types =
370 syncable::ModelTypePayloadMapFromBitSet( 370 syncable::ModelTypePayloadMapFromBitSet(
371 ParamsMeaningAllEnabledTypes(), 371 ParamsMeaningAllEnabledTypes(),
372 std::string()); 372 std::string());
373 SyncSourceInfo source_first(sync_pb::GetUpdatesCallerInfo::PERIODIC, 373 SyncSourceInfo source_first(sync_pb::GetUpdatesCallerInfo::PERIODIC,
374 all_types); 374 all_types);
375 SyncSourceInfo source_second(sync_pb::GetUpdatesCallerInfo::LOCAL, 375 SyncSourceInfo source_second(sync_pb::GetUpdatesCallerInfo::LOCAL,
376 all_types); 376 all_types);
377 377
378 scoped_refptr<MockDBModelWorker> db_worker(new MockDBModelWorker()); 378 scoped_refptr<FakeModelWorker> db_worker(new FakeModelWorker(GROUP_DB));
379 scoped_refptr<MockUIModelWorker> ui_worker(new MockUIModelWorker()); 379 scoped_refptr<FakeModelWorker> ui_worker(new FakeModelWorker(GROUP_UI));
380 workers_first.push_back(db_worker); 380 workers_first.push_back(db_worker);
381 workers_first.push_back(ui_worker); 381 workers_first.push_back(ui_worker);
382 workers_second.push_back(db_worker); 382 workers_second.push_back(db_worker);
383 workers_second.push_back(ui_worker); 383 workers_second.push_back(ui_worker);
384 routes_first[syncable::AUTOFILL] = GROUP_DB; 384 routes_first[syncable::AUTOFILL] = GROUP_DB;
385 routes_first[syncable::BOOKMARKS] = GROUP_UI; 385 routes_first[syncable::BOOKMARKS] = GROUP_UI;
386 routes_second[syncable::AUTOFILL] = GROUP_DB; 386 routes_second[syncable::AUTOFILL] = GROUP_DB;
387 routes_second[syncable::BOOKMARKS] = GROUP_UI; 387 routes_second[syncable::BOOKMARKS] = GROUP_UI;
388 SyncSession first(context_.get(), this, source_first, routes_first, 388 SyncSession first(context_.get(), this, source_first, routes_first,
389 workers_first); 389 workers_first);
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
478 EXPECT_EQ(empty_payload, original[syncable::BOOKMARKS]); 478 EXPECT_EQ(empty_payload, original[syncable::BOOKMARKS]);
479 EXPECT_EQ(payload1, original[syncable::PASSWORDS]); 479 EXPECT_EQ(payload1, original[syncable::PASSWORDS]);
480 EXPECT_EQ(payload1, original[syncable::AUTOFILL]); 480 EXPECT_EQ(payload1, original[syncable::AUTOFILL]);
481 EXPECT_EQ(payload2, original[syncable::SESSIONS]); 481 EXPECT_EQ(payload2, original[syncable::SESSIONS]);
482 EXPECT_EQ(payload3, original[syncable::THEMES]); 482 EXPECT_EQ(payload3, original[syncable::THEMES]);
483 } 483 }
484 484
485 } // namespace 485 } // namespace
486 } // namespace sessions 486 } // namespace sessions
487 } // namespace browser_sync 487 } // namespace browser_sync
OLDNEW
« no previous file with comments | « chrome/browser/sync/glue/sync_backend_registrar.cc ('k') | chrome/browser/sync/test/engine/fake_model_safe_worker_registrar.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698