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

Side by Side Diff: sync/api/sync_change_unittest.cc

Issue 213003004: Replace calls to 3-arg SyncData::CreateLocalData with 5-arg version. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@syncapi
Patch Set: Apply feedback from review Created 6 years, 8 months 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
« no previous file with comments | « sync/api/attachments/attachment_service_proxy_for_test.cc ('k') | sync/api/sync_data.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "sync/api/sync_change.h" 5 #include "sync/api/sync_change.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/message_loop/message_loop.h"
10 #include "base/time/time.h" 11 #include "base/time/time.h"
11 #include "base/values.h" 12 #include "base/values.h"
13 #include "sync/api/attachments/attachment_id.h"
14 #include "sync/api/attachments/attachment_service_proxy_for_test.h"
12 #include "sync/protocol/preference_specifics.pb.h" 15 #include "sync/protocol/preference_specifics.pb.h"
13 #include "sync/protocol/proto_value_conversions.h" 16 #include "sync/protocol/proto_value_conversions.h"
14 #include "sync/protocol/sync.pb.h" 17 #include "sync/protocol/sync.pb.h"
15 #include "testing/gtest/include/gtest/gtest.h" 18 #include "testing/gtest/include/gtest/gtest.h"
16 19
17 namespace syncer { 20 namespace syncer {
18 21
19 // Ordered list of SyncChange's. 22 // Ordered list of SyncChange's.
20 typedef std::vector<SyncChange> SyncChangeList; 23 typedef std::vector<SyncChange> SyncChangeList;
21 24
22 namespace { 25 namespace {
23 26
24 typedef testing::Test SyncChangeTest; 27 class SyncChangeTest : public testing::Test {
28 private:
29 base::MessageLoop message_loop;
30 };
25 31
26 TEST_F(SyncChangeTest, LocalDelete) { 32 TEST_F(SyncChangeTest, LocalDelete) {
27 SyncChange::SyncChangeType change_type = SyncChange::ACTION_DELETE; 33 SyncChange::SyncChangeType change_type = SyncChange::ACTION_DELETE;
28 std::string tag = "client_tag"; 34 std::string tag = "client_tag";
29 SyncChange e(FROM_HERE, 35 SyncChange e(FROM_HERE,
30 change_type, 36 change_type,
31 SyncData::CreateLocalDelete(tag, PREFERENCES)); 37 SyncData::CreateLocalDelete(tag, PREFERENCES));
32 EXPECT_EQ(change_type, e.change_type()); 38 EXPECT_EQ(change_type, e.change_type());
33 EXPECT_EQ(tag, SyncDataLocal(e.sync_data()).GetTag()); 39 EXPECT_EQ(tag, SyncDataLocal(e.sync_data()).GetTag());
34 EXPECT_EQ(PREFERENCES, e.sync_data().GetDataType()); 40 EXPECT_EQ(PREFERENCES, e.sync_data().GetDataType());
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 } 81 }
76 82
77 TEST_F(SyncChangeTest, SyncerChanges) { 83 TEST_F(SyncChangeTest, SyncerChanges) {
78 SyncChangeList change_list; 84 SyncChangeList change_list;
79 85
80 // Create an update. 86 // Create an update.
81 sync_pb::EntitySpecifics update_specifics; 87 sync_pb::EntitySpecifics update_specifics;
82 sync_pb::PreferenceSpecifics* pref_specifics = 88 sync_pb::PreferenceSpecifics* pref_specifics =
83 update_specifics.mutable_preference(); 89 update_specifics.mutable_preference();
84 pref_specifics->set_name("update"); 90 pref_specifics->set_name("update");
85 change_list.push_back(SyncChange( 91 change_list.push_back(
86 FROM_HERE, 92 SyncChange(FROM_HERE,
87 SyncChange::ACTION_UPDATE, 93 SyncChange::ACTION_UPDATE,
88 SyncData::CreateRemoteData(1, update_specifics, base::Time()))); 94 SyncData::CreateRemoteData(
95 1,
96 update_specifics,
97 base::Time(),
98 syncer::AttachmentIdList(),
99 syncer::AttachmentServiceProxyForTest::Create())));
89 100
90 // Create an add. 101 // Create an add.
91 sync_pb::EntitySpecifics add_specifics; 102 sync_pb::EntitySpecifics add_specifics;
92 pref_specifics = add_specifics.mutable_preference(); 103 pref_specifics = add_specifics.mutable_preference();
93 pref_specifics->set_name("add"); 104 pref_specifics->set_name("add");
94 change_list.push_back(SyncChange( 105 change_list.push_back(
95 FROM_HERE, 106 SyncChange(FROM_HERE,
96 SyncChange::ACTION_ADD, 107 SyncChange::ACTION_ADD,
97 SyncData::CreateRemoteData(2, add_specifics, base::Time()))); 108 SyncData::CreateRemoteData(
109 2,
110 add_specifics,
111 base::Time(),
112 syncer::AttachmentIdList(),
113 syncer::AttachmentServiceProxyForTest::Create())));
98 114
99 // Create a delete. 115 // Create a delete.
100 sync_pb::EntitySpecifics delete_specifics; 116 sync_pb::EntitySpecifics delete_specifics;
101 pref_specifics = delete_specifics.mutable_preference(); 117 pref_specifics = delete_specifics.mutable_preference();
102 pref_specifics->set_name("add"); 118 pref_specifics->set_name("add");
103 change_list.push_back(SyncChange( 119 change_list.push_back(
104 FROM_HERE, 120 SyncChange(FROM_HERE,
105 SyncChange::ACTION_DELETE, 121 SyncChange::ACTION_DELETE,
106 SyncData::CreateRemoteData(3, delete_specifics, base::Time()))); 122 SyncData::CreateRemoteData(
123 3,
124 delete_specifics,
125 base::Time(),
126 syncer::AttachmentIdList(),
127 syncer::AttachmentServiceProxyForTest::Create())));
107 128
108 ASSERT_EQ(3U, change_list.size()); 129 ASSERT_EQ(3U, change_list.size());
109 130
110 // Verify update. 131 // Verify update.
111 SyncChange e = change_list[0]; 132 SyncChange e = change_list[0];
112 EXPECT_EQ(SyncChange::ACTION_UPDATE, e.change_type()); 133 EXPECT_EQ(SyncChange::ACTION_UPDATE, e.change_type());
113 EXPECT_EQ(PREFERENCES, e.sync_data().GetDataType()); 134 EXPECT_EQ(PREFERENCES, e.sync_data().GetDataType());
114 scoped_ptr<base::DictionaryValue> ref_spec(EntitySpecificsToValue( 135 scoped_ptr<base::DictionaryValue> ref_spec(EntitySpecificsToValue(
115 update_specifics)); 136 update_specifics));
116 scoped_ptr<base::DictionaryValue> e_spec(EntitySpecificsToValue( 137 scoped_ptr<base::DictionaryValue> e_spec(EntitySpecificsToValue(
(...skipping 13 matching lines...) Expand all
130 EXPECT_EQ(SyncChange::ACTION_DELETE, e.change_type()); 151 EXPECT_EQ(SyncChange::ACTION_DELETE, e.change_type());
131 EXPECT_EQ(PREFERENCES, e.sync_data().GetDataType()); 152 EXPECT_EQ(PREFERENCES, e.sync_data().GetDataType());
132 ref_spec.reset(EntitySpecificsToValue(delete_specifics)); 153 ref_spec.reset(EntitySpecificsToValue(delete_specifics));
133 e_spec.reset(EntitySpecificsToValue(e.sync_data().GetSpecifics())); 154 e_spec.reset(EntitySpecificsToValue(e.sync_data().GetSpecifics()));
134 EXPECT_TRUE(ref_spec->Equals(e_spec.get())); 155 EXPECT_TRUE(ref_spec->Equals(e_spec.get()));
135 } 156 }
136 157
137 } // namespace 158 } // namespace
138 159
139 } // namespace syncer 160 } // namespace syncer
OLDNEW
« no previous file with comments | « sync/api/attachments/attachment_service_proxy_for_test.cc ('k') | sync/api/sync_data.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698