OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "sync/engine/directory_update_handler.h" | 5 #include "sync/engine/directory_update_handler.h" |
6 | 6 |
7 #include "base/compiler_specific.h" | 7 #include "base/compiler_specific.h" |
8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
9 #include "base/stl_util.h" | 9 #include "base/stl_util.h" |
10 #include "sync/engine/syncer_proto_util.h" | 10 #include "sync/engine/syncer_proto_util.h" |
(...skipping 28 matching lines...) Expand all Loading... |
39 // the received protobuf message into information in the syncable::Directory. | 39 // the received protobuf message into information in the syncable::Directory. |
40 // Any invalid or redundant updates will be dropped at this point. | 40 // Any invalid or redundant updates will be dropped at this point. |
41 class DirectoryUpdateHandlerProcessUpdateTest : public ::testing::Test { | 41 class DirectoryUpdateHandlerProcessUpdateTest : public ::testing::Test { |
42 public: | 42 public: |
43 DirectoryUpdateHandlerProcessUpdateTest() | 43 DirectoryUpdateHandlerProcessUpdateTest() |
44 : ui_worker_(new FakeModelWorker(GROUP_UI)) { | 44 : ui_worker_(new FakeModelWorker(GROUP_UI)) { |
45 } | 45 } |
46 | 46 |
47 virtual ~DirectoryUpdateHandlerProcessUpdateTest() {} | 47 virtual ~DirectoryUpdateHandlerProcessUpdateTest() {} |
48 | 48 |
49 virtual void SetUp() OVERRIDE { | 49 virtual void SetUp() override { |
50 dir_maker_.SetUp(); | 50 dir_maker_.SetUp(); |
51 } | 51 } |
52 | 52 |
53 virtual void TearDown() OVERRIDE { | 53 virtual void TearDown() override { |
54 dir_maker_.TearDown(); | 54 dir_maker_.TearDown(); |
55 } | 55 } |
56 | 56 |
57 syncable::Directory* dir() { | 57 syncable::Directory* dir() { |
58 return dir_maker_.directory(); | 58 return dir_maker_.directory(); |
59 } | 59 } |
60 | 60 |
61 protected: | 61 protected: |
62 scoped_ptr<sync_pb::SyncEntity> CreateUpdate( | 62 scoped_ptr<sync_pb::SyncEntity> CreateUpdate( |
63 const std::string& id, | 63 const std::string& id, |
(...skipping 415 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
479 public: | 479 public: |
480 DirectoryUpdateHandlerApplyUpdateTest() | 480 DirectoryUpdateHandlerApplyUpdateTest() |
481 : ui_worker_(new FakeModelWorker(GROUP_UI)), | 481 : ui_worker_(new FakeModelWorker(GROUP_UI)), |
482 password_worker_(new FakeModelWorker(GROUP_PASSWORD)), | 482 password_worker_(new FakeModelWorker(GROUP_PASSWORD)), |
483 passive_worker_(new FakeModelWorker(GROUP_PASSIVE)), | 483 passive_worker_(new FakeModelWorker(GROUP_PASSIVE)), |
484 bookmarks_emitter_(BOOKMARKS, &type_observers_), | 484 bookmarks_emitter_(BOOKMARKS, &type_observers_), |
485 passwords_emitter_(PASSWORDS, &type_observers_), | 485 passwords_emitter_(PASSWORDS, &type_observers_), |
486 articles_emitter_(ARTICLES, &type_observers_), | 486 articles_emitter_(ARTICLES, &type_observers_), |
487 update_handler_map_deleter_(&update_handler_map_) {} | 487 update_handler_map_deleter_(&update_handler_map_) {} |
488 | 488 |
489 virtual void SetUp() OVERRIDE { | 489 virtual void SetUp() override { |
490 dir_maker_.SetUp(); | 490 dir_maker_.SetUp(); |
491 entry_factory_.reset(new TestEntryFactory(directory())); | 491 entry_factory_.reset(new TestEntryFactory(directory())); |
492 | 492 |
493 update_handler_map_.insert(std::make_pair( | 493 update_handler_map_.insert(std::make_pair( |
494 BOOKMARKS, | 494 BOOKMARKS, |
495 new DirectoryUpdateHandler(directory(), BOOKMARKS, | 495 new DirectoryUpdateHandler(directory(), BOOKMARKS, |
496 ui_worker_, &bookmarks_emitter_))); | 496 ui_worker_, &bookmarks_emitter_))); |
497 update_handler_map_.insert(std::make_pair( | 497 update_handler_map_.insert(std::make_pair( |
498 PASSWORDS, | 498 PASSWORDS, |
499 new DirectoryUpdateHandler(directory(), | 499 new DirectoryUpdateHandler(directory(), |
500 PASSWORDS, | 500 PASSWORDS, |
501 password_worker_, | 501 password_worker_, |
502 &passwords_emitter_))); | 502 &passwords_emitter_))); |
503 update_handler_map_.insert(std::make_pair( | 503 update_handler_map_.insert(std::make_pair( |
504 ARTICLES, | 504 ARTICLES, |
505 new DirectoryUpdateHandler( | 505 new DirectoryUpdateHandler( |
506 directory(), ARTICLES, ui_worker_, &articles_emitter_))); | 506 directory(), ARTICLES, ui_worker_, &articles_emitter_))); |
507 } | 507 } |
508 | 508 |
509 virtual void TearDown() OVERRIDE { | 509 virtual void TearDown() override { |
510 dir_maker_.TearDown(); | 510 dir_maker_.TearDown(); |
511 } | 511 } |
512 | 512 |
513 const UpdateCounters& GetBookmarksUpdateCounters() { | 513 const UpdateCounters& GetBookmarksUpdateCounters() { |
514 return bookmarks_emitter_.GetUpdateCounters(); | 514 return bookmarks_emitter_.GetUpdateCounters(); |
515 } | 515 } |
516 | 516 |
517 const UpdateCounters& GetPasswordsUpdateCounters() { | 517 const UpdateCounters& GetPasswordsUpdateCounters() { |
518 return passwords_emitter_.GetUpdateCounters(); | 518 return passwords_emitter_.GetUpdateCounters(); |
519 } | 519 } |
(...skipping 663 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1183 const UpdateCounters& counters = GetArticlesUpdateCounters(); | 1183 const UpdateCounters& counters = GetArticlesUpdateCounters(); |
1184 EXPECT_EQ(1, counters.num_updates_applied); | 1184 EXPECT_EQ(1, counters.num_updates_applied); |
1185 EXPECT_EQ(1, counters.num_local_overwrites); | 1185 EXPECT_EQ(1, counters.num_local_overwrites); |
1186 EXPECT_EQ(0, counters.num_server_overwrites); | 1186 EXPECT_EQ(0, counters.num_server_overwrites); |
1187 local_metadata = entry_factory()->GetLocalAttachmentMetadataForItem(handle); | 1187 local_metadata = entry_factory()->GetLocalAttachmentMetadataForItem(handle); |
1188 EXPECT_EQ(server_metadata.SerializeAsString(), | 1188 EXPECT_EQ(server_metadata.SerializeAsString(), |
1189 local_metadata.SerializeAsString()); | 1189 local_metadata.SerializeAsString()); |
1190 } | 1190 } |
1191 | 1191 |
1192 } // namespace syncer | 1192 } // namespace syncer |
OLD | NEW |