| OLD | NEW |
| 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 "base/location.h" | 5 #include "base/location.h" |
| 6 #include "sync/engine/verify_updates_command.h" | 6 #include "sync/engine/verify_updates_command.h" |
| 7 #include "sync/protocol/bookmark_specifics.pb.h" | 7 #include "sync/protocol/bookmark_specifics.pb.h" |
| 8 #include "sync/sessions/session_state.h" | 8 #include "sync/sessions/session_state.h" |
| 9 #include "sync/sessions/sync_session.h" | 9 #include "sync/sessions/sync_session.h" |
| 10 #include "sync/syncable/mutable_entry.h" | 10 #include "sync/syncable/mutable_entry.h" |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 | 45 |
| 46 entry.Put(syncable::BASE_VERSION, 1); | 46 entry.Put(syncable::BASE_VERSION, 1); |
| 47 entry.Put(syncable::SERVER_VERSION, 1); | 47 entry.Put(syncable::SERVER_VERSION, 1); |
| 48 entry.Put(syncable::NON_UNIQUE_NAME, item_id); | 48 entry.Put(syncable::NON_UNIQUE_NAME, item_id); |
| 49 entry.Put(syncable::PARENT_ID, Id::CreateFromServerId(parent_id)); | 49 entry.Put(syncable::PARENT_ID, Id::CreateFromServerId(parent_id)); |
| 50 sync_pb::EntitySpecifics default_specifics; | 50 sync_pb::EntitySpecifics default_specifics; |
| 51 AddDefaultFieldValue(type, &default_specifics); | 51 AddDefaultFieldValue(type, &default_specifics); |
| 52 entry.Put(syncable::SERVER_SPECIFICS, default_specifics); | 52 entry.Put(syncable::SERVER_SPECIFICS, default_specifics); |
| 53 } | 53 } |
| 54 | 54 |
| 55 void AddUpdate(GetUpdatesResponse* updates, | 55 void AddUpdate(sync_pb::GetUpdatesResponse* updates, |
| 56 const std::string& id, const std::string& parent, | 56 const std::string& id, const std::string& parent, |
| 57 const syncer::ModelType& type) { | 57 const syncer::ModelType& type) { |
| 58 sync_pb::SyncEntity* e = updates->add_entries(); | 58 sync_pb::SyncEntity* e = updates->add_entries(); |
| 59 e->set_id_string("b1"); | 59 e->set_id_string("b1"); |
| 60 e->set_parent_id_string(parent); | 60 e->set_parent_id_string(parent); |
| 61 e->set_non_unique_name("b1"); | 61 e->set_non_unique_name("b1"); |
| 62 e->set_name("b1"); | 62 e->set_name("b1"); |
| 63 AddDefaultFieldValue(type, e->mutable_specifics()); | 63 AddDefaultFieldValue(type, e->mutable_specifics()); |
| 64 } | 64 } |
| 65 | 65 |
| 66 VerifyUpdatesCommand command_; | 66 VerifyUpdatesCommand command_; |
| 67 | 67 |
| 68 }; | 68 }; |
| 69 | 69 |
| 70 TEST_F(VerifyUpdatesCommandTest, AllVerified) { | 70 TEST_F(VerifyUpdatesCommandTest, AllVerified) { |
| 71 string root = syncable::GetNullId().GetServerId(); | 71 string root = syncable::GetNullId().GetServerId(); |
| 72 | 72 |
| 73 CreateLocalItem("b1", root, syncer::BOOKMARKS); | 73 CreateLocalItem("b1", root, syncer::BOOKMARKS); |
| 74 CreateLocalItem("b2", root, syncer::BOOKMARKS); | 74 CreateLocalItem("b2", root, syncer::BOOKMARKS); |
| 75 CreateLocalItem("p1", root, syncer::PREFERENCES); | 75 CreateLocalItem("p1", root, syncer::PREFERENCES); |
| 76 CreateLocalItem("a1", root, syncer::AUTOFILL); | 76 CreateLocalItem("a1", root, syncer::AUTOFILL); |
| 77 | 77 |
| 78 ExpectNoGroupsToChange(command_); | 78 ExpectNoGroupsToChange(command_); |
| 79 | 79 |
| 80 GetUpdatesResponse* updates = session()->mutable_status_controller()-> | 80 sync_pb::GetUpdatesResponse* updates = |
| 81 session()->mutable_status_controller()-> |
| 81 mutable_updates_response()->mutable_get_updates(); | 82 mutable_updates_response()->mutable_get_updates(); |
| 82 AddUpdate(updates, "b1", root, syncer::BOOKMARKS); | 83 AddUpdate(updates, "b1", root, syncer::BOOKMARKS); |
| 83 AddUpdate(updates, "b2", root, syncer::BOOKMARKS); | 84 AddUpdate(updates, "b2", root, syncer::BOOKMARKS); |
| 84 AddUpdate(updates, "p1", root, syncer::PREFERENCES); | 85 AddUpdate(updates, "p1", root, syncer::PREFERENCES); |
| 85 AddUpdate(updates, "a1", root, syncer::AUTOFILL); | 86 AddUpdate(updates, "a1", root, syncer::AUTOFILL); |
| 86 | 87 |
| 87 ExpectGroupsToChange(command_, GROUP_UI, GROUP_DB); | 88 ExpectGroupsToChange(command_, GROUP_UI, GROUP_DB); |
| 88 | 89 |
| 89 command_.ExecuteImpl(session()); | 90 command_.ExecuteImpl(session()); |
| 90 | 91 |
| 91 StatusController* status = session()->mutable_status_controller(); | 92 StatusController* status = session()->mutable_status_controller(); |
| 92 { | 93 { |
| 93 sessions::ScopedModelSafeGroupRestriction r(status, GROUP_UI); | 94 sessions::ScopedModelSafeGroupRestriction r(status, GROUP_UI); |
| 94 ASSERT_TRUE(status->update_progress()); | 95 ASSERT_TRUE(status->update_progress()); |
| 95 EXPECT_EQ(3, status->update_progress()->VerifiedUpdatesSize()); | 96 EXPECT_EQ(3, status->update_progress()->VerifiedUpdatesSize()); |
| 96 } | 97 } |
| 97 { | 98 { |
| 98 sessions::ScopedModelSafeGroupRestriction r(status, GROUP_DB); | 99 sessions::ScopedModelSafeGroupRestriction r(status, GROUP_DB); |
| 99 ASSERT_TRUE(status->update_progress()); | 100 ASSERT_TRUE(status->update_progress()); |
| 100 EXPECT_EQ(1, status->update_progress()->VerifiedUpdatesSize()); | 101 EXPECT_EQ(1, status->update_progress()->VerifiedUpdatesSize()); |
| 101 } | 102 } |
| 102 { | 103 { |
| 103 sessions::ScopedModelSafeGroupRestriction r(status, GROUP_PASSIVE); | 104 sessions::ScopedModelSafeGroupRestriction r(status, GROUP_PASSIVE); |
| 104 EXPECT_FALSE(status->update_progress()); | 105 EXPECT_FALSE(status->update_progress()); |
| 105 } | 106 } |
| 106 } | 107 } |
| 107 | 108 |
| 108 } // namespace syncer | 109 } // namespace syncer |
| OLD | NEW |