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

Side by Side Diff: chrome/browser/sync/engine/syncer_proto_util_unittest.cc

Issue 2844037: Fix handling of undeletion within the syncer. (Closed) Base URL: http://src.chromium.org/git/chromium.git
Patch Set: Whitespace. Created 10 years, 5 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
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 "chrome/browser/sync/engine/syncer_proto_util.h" 5 #include "chrome/browser/sync/engine/syncer_proto_util.h"
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "chrome/browser/sync/engine/syncproto.h" 8 #include "chrome/browser/sync/engine/syncproto.h"
9 #include "chrome/browser/sync/syncable/blob.h" 9 #include "chrome/browser/sync/syncable/blob.h"
10 #include "chrome/browser/sync/syncable/directory_manager.h" 10 #include "chrome/browser/sync/syncable/directory_manager.h"
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 SyncEntity one_name_entity; 80 SyncEntity one_name_entity;
81 CommitResponse_EntryResponse one_name_response; 81 CommitResponse_EntryResponse one_name_response;
82 82
83 const std::string one_name_string("Eggheadednesses"); 83 const std::string one_name_string("Eggheadednesses");
84 one_name_entity.set_name(one_name_string); 84 one_name_entity.set_name(one_name_string);
85 one_name_response.set_name(one_name_string); 85 one_name_response.set_name(one_name_string);
86 86
87 const std::string name_a = 87 const std::string name_a =
88 SyncerProtoUtil::NameFromSyncEntity(one_name_entity); 88 SyncerProtoUtil::NameFromSyncEntity(one_name_entity);
89 EXPECT_EQ(one_name_string, name_a); 89 EXPECT_EQ(one_name_string, name_a);
90
91 const std::string name_b =
92 SyncerProtoUtil::NameFromCommitEntryResponse(one_name_response);
93 EXPECT_EQ(one_name_string, name_b);
94 EXPECT_TRUE(name_a == name_b);
95 } 90 }
96 91
97 TEST(SyncerProtoUtil, NameExtractionOneUniqueName) { 92 TEST(SyncerProtoUtil, NameExtractionOneUniqueName) {
98 SyncEntity one_name_entity; 93 SyncEntity one_name_entity;
99 CommitResponse_EntryResponse one_name_response; 94 CommitResponse_EntryResponse one_name_response;
100 95
101 const std::string one_name_string("Eggheadednesses"); 96 const std::string one_name_string("Eggheadednesses");
102 97
103 one_name_entity.set_non_unique_name(one_name_string); 98 one_name_entity.set_non_unique_name(one_name_string);
104 one_name_response.set_non_unique_name(one_name_string); 99 one_name_response.set_non_unique_name(one_name_string);
105 100
106 const std::string name_a = 101 const std::string name_a =
107 SyncerProtoUtil::NameFromSyncEntity(one_name_entity); 102 SyncerProtoUtil::NameFromSyncEntity(one_name_entity);
108 EXPECT_EQ(one_name_string, name_a); 103 EXPECT_EQ(one_name_string, name_a);
109
110 const std::string name_b =
111 SyncerProtoUtil::NameFromCommitEntryResponse(one_name_response);
112 EXPECT_EQ(one_name_string, name_b);
113 EXPECT_TRUE(name_a == name_b);
114 } 104 }
115 105
116 // Tests NameFromSyncEntity and NameFromCommitEntryResponse when both the name 106 // Tests NameFromSyncEntity and NameFromCommitEntryResponse when both the name
117 // field and the non_unique_name fields are provided. 107 // field and the non_unique_name fields are provided.
118 // Should prioritize non_unique_name. 108 // Should prioritize non_unique_name.
119 TEST(SyncerProtoUtil, NameExtractionTwoNames) { 109 TEST(SyncerProtoUtil, NameExtractionTwoNames) {
120 SyncEntity two_name_entity; 110 SyncEntity two_name_entity;
121 CommitResponse_EntryResponse two_name_response; 111 CommitResponse_EntryResponse two_name_response;
122 112
123 const std::string neuro("Neuroanatomists"); 113 const std::string neuro("Neuroanatomists");
124 const std::string oxyphen("Oxyphenbutazone"); 114 const std::string oxyphen("Oxyphenbutazone");
125 115
126 two_name_entity.set_name(oxyphen); 116 two_name_entity.set_name(oxyphen);
127 two_name_entity.set_non_unique_name(neuro); 117 two_name_entity.set_non_unique_name(neuro);
128 118
129 two_name_response.set_name(oxyphen); 119 two_name_response.set_name(oxyphen);
130 two_name_response.set_non_unique_name(neuro); 120 two_name_response.set_non_unique_name(neuro);
131 121
132 const std::string name_a = 122 const std::string name_a =
133 SyncerProtoUtil::NameFromSyncEntity(two_name_entity); 123 SyncerProtoUtil::NameFromSyncEntity(two_name_entity);
134 EXPECT_EQ(neuro, name_a); 124 EXPECT_EQ(neuro, name_a);
135
136 const std::string name_b =
137 SyncerProtoUtil::NameFromCommitEntryResponse(two_name_response);
138 EXPECT_EQ(neuro, name_b);
139
140 EXPECT_TRUE(name_a == name_b);
141 } 125 }
142 126
143 class SyncerProtoUtilTest : public testing::Test { 127 class SyncerProtoUtilTest : public testing::Test {
144 public: 128 public:
145 virtual void SetUp() { 129 virtual void SetUp() {
146 setter_upper_.SetUp(); 130 setter_upper_.SetUp();
147 } 131 }
148 132
149 virtual void TearDown() { 133 virtual void TearDown() {
150 setter_upper_.TearDown(); 134 setter_upper_.TearDown();
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
230 214
231 TEST_F(SyncerProtoUtilTest, PostAndProcessHeaders) { 215 TEST_F(SyncerProtoUtilTest, PostAndProcessHeaders) {
232 DummyConnectionManager dcm; 216 DummyConnectionManager dcm;
233 ClientToServerMessage msg; 217 ClientToServerMessage msg;
234 msg.set_share("required"); 218 msg.set_share("required");
235 msg.set_message_contents(ClientToServerMessage::GET_UPDATES); 219 msg.set_message_contents(ClientToServerMessage::GET_UPDATES);
236 ClientToServerResponse response; 220 ClientToServerResponse response;
237 221
238 dcm.set_send_error(true); 222 dcm.set_send_error(true);
239 EXPECT_FALSE(SyncerProtoUtil::PostAndProcessHeaders(&dcm, NULL, 223 EXPECT_FALSE(SyncerProtoUtil::PostAndProcessHeaders(&dcm, NULL,
240 &msg, &response)); 224 msg, &response));
241 225
242 dcm.set_send_error(false); 226 dcm.set_send_error(false);
243 EXPECT_TRUE(SyncerProtoUtil::PostAndProcessHeaders(&dcm, NULL, 227 EXPECT_TRUE(SyncerProtoUtil::PostAndProcessHeaders(&dcm, NULL,
244 &msg, &response)); 228 msg, &response));
245 229
246 dcm.set_access_denied(true); 230 dcm.set_access_denied(true);
247 EXPECT_FALSE(SyncerProtoUtil::PostAndProcessHeaders(&dcm, NULL, 231 EXPECT_FALSE(SyncerProtoUtil::PostAndProcessHeaders(&dcm, NULL,
248 &msg, &response)); 232 msg, &response));
249 } 233 }
250 234
251 } // namespace browser_sync 235 } // namespace browser_sync
OLDNEW
« no previous file with comments | « chrome/browser/sync/engine/syncer_proto_util.cc ('k') | chrome/browser/sync/engine/syncer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698