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 "components/sync/api/sync_change.h" | 5 #include "components/sync/api/sync_change.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 TEST_F(SyncChangeTest, SyncerChanges) { | 82 TEST_F(SyncChangeTest, SyncerChanges) { |
83 SyncChangeList change_list; | 83 SyncChangeList change_list; |
84 | 84 |
85 // Create an update. | 85 // Create an update. |
86 sync_pb::EntitySpecifics update_specifics; | 86 sync_pb::EntitySpecifics update_specifics; |
87 sync_pb::PreferenceSpecifics* pref_specifics = | 87 sync_pb::PreferenceSpecifics* pref_specifics = |
88 update_specifics.mutable_preference(); | 88 update_specifics.mutable_preference(); |
89 pref_specifics->set_name("update"); | 89 pref_specifics->set_name("update"); |
90 change_list.push_back(SyncChange( | 90 change_list.push_back(SyncChange( |
91 FROM_HERE, SyncChange::ACTION_UPDATE, | 91 FROM_HERE, SyncChange::ACTION_UPDATE, |
92 SyncData::CreateRemoteData( | 92 SyncData::CreateRemoteData(1, update_specifics, base::Time(), |
93 1, update_specifics, base::Time(), syncer::AttachmentIdList(), | 93 AttachmentIdList(), |
94 syncer::AttachmentServiceProxyForTest::Create()))); | 94 AttachmentServiceProxyForTest::Create()))); |
95 | 95 |
96 // Create an add. | 96 // Create an add. |
97 sync_pb::EntitySpecifics add_specifics; | 97 sync_pb::EntitySpecifics add_specifics; |
98 pref_specifics = add_specifics.mutable_preference(); | 98 pref_specifics = add_specifics.mutable_preference(); |
99 pref_specifics->set_name("add"); | 99 pref_specifics->set_name("add"); |
100 change_list.push_back( | 100 change_list.push_back(SyncChange( |
101 SyncChange(FROM_HERE, SyncChange::ACTION_ADD, | 101 FROM_HERE, SyncChange::ACTION_ADD, |
102 SyncData::CreateRemoteData( | 102 SyncData::CreateRemoteData(2, add_specifics, base::Time(), |
103 2, add_specifics, base::Time(), syncer::AttachmentIdList(), | 103 AttachmentIdList(), |
104 syncer::AttachmentServiceProxyForTest::Create()))); | 104 AttachmentServiceProxyForTest::Create()))); |
105 | 105 |
106 // Create a delete. | 106 // Create a delete. |
107 sync_pb::EntitySpecifics delete_specifics; | 107 sync_pb::EntitySpecifics delete_specifics; |
108 pref_specifics = delete_specifics.mutable_preference(); | 108 pref_specifics = delete_specifics.mutable_preference(); |
109 pref_specifics->set_name("add"); | 109 pref_specifics->set_name("add"); |
110 change_list.push_back(SyncChange( | 110 change_list.push_back(SyncChange( |
111 FROM_HERE, SyncChange::ACTION_DELETE, | 111 FROM_HERE, SyncChange::ACTION_DELETE, |
112 SyncData::CreateRemoteData( | 112 SyncData::CreateRemoteData(3, delete_specifics, base::Time(), |
113 3, delete_specifics, base::Time(), syncer::AttachmentIdList(), | 113 AttachmentIdList(), |
114 syncer::AttachmentServiceProxyForTest::Create()))); | 114 AttachmentServiceProxyForTest::Create()))); |
115 | 115 |
116 ASSERT_EQ(3U, change_list.size()); | 116 ASSERT_EQ(3U, change_list.size()); |
117 | 117 |
118 // Verify update. | 118 // Verify update. |
119 SyncChange e = change_list[0]; | 119 SyncChange e = change_list[0]; |
120 EXPECT_EQ(SyncChange::ACTION_UPDATE, e.change_type()); | 120 EXPECT_EQ(SyncChange::ACTION_UPDATE, e.change_type()); |
121 EXPECT_EQ(PREFERENCES, e.sync_data().GetDataType()); | 121 EXPECT_EQ(PREFERENCES, e.sync_data().GetDataType()); |
122 std::unique_ptr<base::DictionaryValue> ref_spec( | 122 std::unique_ptr<base::DictionaryValue> ref_spec( |
123 EntitySpecificsToValue(update_specifics)); | 123 EntitySpecificsToValue(update_specifics)); |
124 std::unique_ptr<base::DictionaryValue> e_spec( | 124 std::unique_ptr<base::DictionaryValue> e_spec( |
(...skipping 13 matching lines...) Expand all Loading... |
138 EXPECT_EQ(SyncChange::ACTION_DELETE, e.change_type()); | 138 EXPECT_EQ(SyncChange::ACTION_DELETE, e.change_type()); |
139 EXPECT_EQ(PREFERENCES, e.sync_data().GetDataType()); | 139 EXPECT_EQ(PREFERENCES, e.sync_data().GetDataType()); |
140 ref_spec = EntitySpecificsToValue(delete_specifics); | 140 ref_spec = EntitySpecificsToValue(delete_specifics); |
141 e_spec = EntitySpecificsToValue(e.sync_data().GetSpecifics()); | 141 e_spec = EntitySpecificsToValue(e.sync_data().GetSpecifics()); |
142 EXPECT_TRUE(ref_spec->Equals(e_spec.get())); | 142 EXPECT_TRUE(ref_spec->Equals(e_spec.get())); |
143 } | 143 } |
144 | 144 |
145 } // namespace | 145 } // namespace |
146 | 146 |
147 } // namespace syncer | 147 } // namespace syncer |
OLD | NEW |