| 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 26 matching lines...) Expand all Loading... |
| 37 // | 37 // |
| 38 // Update processing is what occurs when we first download updates. It converts | 38 // Update processing is what occurs when we first download updates. It converts |
| 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 ~DirectoryUpdateHandlerProcessUpdateTest() override {} |
| 48 | 48 |
| 49 virtual void SetUp() override { | 49 void SetUp() override { dir_maker_.SetUp(); } |
| 50 dir_maker_.SetUp(); | |
| 51 } | |
| 52 | 50 |
| 53 virtual void TearDown() override { | 51 void TearDown() override { dir_maker_.TearDown(); } |
| 54 dir_maker_.TearDown(); | |
| 55 } | |
| 56 | 52 |
| 57 syncable::Directory* dir() { | 53 syncable::Directory* dir() { |
| 58 return dir_maker_.directory(); | 54 return dir_maker_.directory(); |
| 59 } | 55 } |
| 60 | 56 |
| 61 protected: | 57 protected: |
| 62 scoped_ptr<sync_pb::SyncEntity> CreateUpdate( | 58 scoped_ptr<sync_pb::SyncEntity> CreateUpdate( |
| 63 const std::string& id, | 59 const std::string& id, |
| 64 const std::string& parent, | 60 const std::string& parent, |
| 65 const ModelType& type); | 61 const ModelType& type); |
| (...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 479 public: | 475 public: |
| 480 DirectoryUpdateHandlerApplyUpdateTest() | 476 DirectoryUpdateHandlerApplyUpdateTest() |
| 481 : ui_worker_(new FakeModelWorker(GROUP_UI)), | 477 : ui_worker_(new FakeModelWorker(GROUP_UI)), |
| 482 password_worker_(new FakeModelWorker(GROUP_PASSWORD)), | 478 password_worker_(new FakeModelWorker(GROUP_PASSWORD)), |
| 483 passive_worker_(new FakeModelWorker(GROUP_PASSIVE)), | 479 passive_worker_(new FakeModelWorker(GROUP_PASSIVE)), |
| 484 bookmarks_emitter_(BOOKMARKS, &type_observers_), | 480 bookmarks_emitter_(BOOKMARKS, &type_observers_), |
| 485 passwords_emitter_(PASSWORDS, &type_observers_), | 481 passwords_emitter_(PASSWORDS, &type_observers_), |
| 486 articles_emitter_(ARTICLES, &type_observers_), | 482 articles_emitter_(ARTICLES, &type_observers_), |
| 487 update_handler_map_deleter_(&update_handler_map_) {} | 483 update_handler_map_deleter_(&update_handler_map_) {} |
| 488 | 484 |
| 489 virtual void SetUp() override { | 485 void SetUp() override { |
| 490 dir_maker_.SetUp(); | 486 dir_maker_.SetUp(); |
| 491 entry_factory_.reset(new TestEntryFactory(directory())); | 487 entry_factory_.reset(new TestEntryFactory(directory())); |
| 492 | 488 |
| 493 update_handler_map_.insert(std::make_pair( | 489 update_handler_map_.insert(std::make_pair( |
| 494 BOOKMARKS, | 490 BOOKMARKS, |
| 495 new DirectoryUpdateHandler(directory(), BOOKMARKS, | 491 new DirectoryUpdateHandler(directory(), BOOKMARKS, |
| 496 ui_worker_, &bookmarks_emitter_))); | 492 ui_worker_, &bookmarks_emitter_))); |
| 497 update_handler_map_.insert(std::make_pair( | 493 update_handler_map_.insert(std::make_pair( |
| 498 PASSWORDS, | 494 PASSWORDS, |
| 499 new DirectoryUpdateHandler(directory(), | 495 new DirectoryUpdateHandler(directory(), |
| 500 PASSWORDS, | 496 PASSWORDS, |
| 501 password_worker_, | 497 password_worker_, |
| 502 &passwords_emitter_))); | 498 &passwords_emitter_))); |
| 503 update_handler_map_.insert(std::make_pair( | 499 update_handler_map_.insert(std::make_pair( |
| 504 ARTICLES, | 500 ARTICLES, |
| 505 new DirectoryUpdateHandler( | 501 new DirectoryUpdateHandler( |
| 506 directory(), ARTICLES, ui_worker_, &articles_emitter_))); | 502 directory(), ARTICLES, ui_worker_, &articles_emitter_))); |
| 507 } | 503 } |
| 508 | 504 |
| 509 virtual void TearDown() override { | 505 void TearDown() override { dir_maker_.TearDown(); } |
| 510 dir_maker_.TearDown(); | |
| 511 } | |
| 512 | 506 |
| 513 const UpdateCounters& GetBookmarksUpdateCounters() { | 507 const UpdateCounters& GetBookmarksUpdateCounters() { |
| 514 return bookmarks_emitter_.GetUpdateCounters(); | 508 return bookmarks_emitter_.GetUpdateCounters(); |
| 515 } | 509 } |
| 516 | 510 |
| 517 const UpdateCounters& GetPasswordsUpdateCounters() { | 511 const UpdateCounters& GetPasswordsUpdateCounters() { |
| 518 return passwords_emitter_.GetUpdateCounters(); | 512 return passwords_emitter_.GetUpdateCounters(); |
| 519 } | 513 } |
| 520 | 514 |
| 521 const UpdateCounters& GetArticlesUpdateCounters() { | 515 const UpdateCounters& GetArticlesUpdateCounters() { |
| (...skipping 661 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1183 const UpdateCounters& counters = GetArticlesUpdateCounters(); | 1177 const UpdateCounters& counters = GetArticlesUpdateCounters(); |
| 1184 EXPECT_EQ(1, counters.num_updates_applied); | 1178 EXPECT_EQ(1, counters.num_updates_applied); |
| 1185 EXPECT_EQ(1, counters.num_local_overwrites); | 1179 EXPECT_EQ(1, counters.num_local_overwrites); |
| 1186 EXPECT_EQ(0, counters.num_server_overwrites); | 1180 EXPECT_EQ(0, counters.num_server_overwrites); |
| 1187 local_metadata = entry_factory()->GetLocalAttachmentMetadataForItem(handle); | 1181 local_metadata = entry_factory()->GetLocalAttachmentMetadataForItem(handle); |
| 1188 EXPECT_EQ(server_metadata.SerializeAsString(), | 1182 EXPECT_EQ(server_metadata.SerializeAsString(), |
| 1189 local_metadata.SerializeAsString()); | 1183 local_metadata.SerializeAsString()); |
| 1190 } | 1184 } |
| 1191 | 1185 |
| 1192 } // namespace syncer | 1186 } // namespace syncer |
| OLD | NEW |