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

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

Issue 371029: Remove unique naming. (Closed)
Patch Set: Ready and about to go in! Created 11 years, 1 month 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/syncable.h" 10 #include "chrome/browser/sync/syncable/syncable.h"
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 EXPECT_TRUE(SyncerProtoUtil::ProtoBytesEqualsBlob(message2_copy, 68 EXPECT_TRUE(SyncerProtoUtil::ProtoBytesEqualsBlob(message2_copy,
69 test_blob2)); 69 test_blob2));
70 } 70 }
71 71
72 // Tests NameFromSyncEntity and NameFromCommitEntryResponse when only the name 72 // Tests NameFromSyncEntity and NameFromCommitEntryResponse when only the name
73 // field is provided. 73 // field is provided.
74 TEST(SyncerProtoUtil, NameExtractionOneName) { 74 TEST(SyncerProtoUtil, NameExtractionOneName) {
75 SyncEntity one_name_entity; 75 SyncEntity one_name_entity;
76 CommitResponse_EntryResponse one_name_response; 76 CommitResponse_EntryResponse one_name_response;
77 77
78 PathString one_name_string(PSTR("Eggheadednesses")); 78 const std::string one_name_string("Eggheadednesses");
79 one_name_entity.set_name("Eggheadednesses"); 79 one_name_entity.set_name(one_name_string);
80 one_name_response.set_name("Eggheadednesses"); 80 one_name_response.set_name(one_name_string);
81 81
82 SyncName name_a = SyncerProtoUtil::NameFromSyncEntity(one_name_entity); 82 const std::string name_a =
83 EXPECT_EQ(one_name_string, name_a.value()); 83 SyncerProtoUtil::NameFromSyncEntity(one_name_entity);
84 EXPECT_EQ(one_name_string, name_a.non_unique_value()); 84 EXPECT_EQ(one_name_string, name_a);
85 85
86 SyncName name_b = 86 const std::string name_b =
87 SyncerProtoUtil::NameFromCommitEntryResponse(one_name_response); 87 SyncerProtoUtil::NameFromCommitEntryResponse(one_name_response);
88 EXPECT_EQ(one_name_string, name_b.value()); 88 EXPECT_EQ(one_name_string, name_b);
89 EXPECT_EQ(one_name_string, name_b.non_unique_value()); 89 EXPECT_TRUE(name_a == name_b);
90 }
90 91
92 TEST(SyncerProtoUtil, NameExtractionOneUniqueName) {
93 SyncEntity one_name_entity;
94 CommitResponse_EntryResponse one_name_response;
95
96 const std::string one_name_string("Eggheadednesses");
97
98 one_name_entity.set_non_unique_name(one_name_string);
99 one_name_response.set_non_unique_name(one_name_string);
100
101 const std::string name_a =
102 SyncerProtoUtil::NameFromSyncEntity(one_name_entity);
103 EXPECT_EQ(one_name_string, name_a);
104
105 const std::string name_b =
106 SyncerProtoUtil::NameFromCommitEntryResponse(one_name_response);
107 EXPECT_EQ(one_name_string, name_b);
91 EXPECT_TRUE(name_a == name_b); 108 EXPECT_TRUE(name_a == name_b);
92 } 109 }
93 110
94 // Tests NameFromSyncEntity and NameFromCommitEntryResponse when both the name 111 // Tests NameFromSyncEntity and NameFromCommitEntryResponse when both the name
95 // field and the non_unique_name fields are provided. 112 // field and the non_unique_name fields are provided.
113 // Should prioritize non_unique_name.
96 TEST(SyncerProtoUtil, NameExtractionTwoNames) { 114 TEST(SyncerProtoUtil, NameExtractionTwoNames) {
97 SyncEntity two_name_entity; 115 SyncEntity two_name_entity;
98 CommitResponse_EntryResponse two_name_response; 116 CommitResponse_EntryResponse two_name_response;
99 117
100 PathString two_name_string_unique(PSTR("Oxyphenbutazone")); 118 const std::string neuro("Neuroanatomists");
101 two_name_entity.set_name("Oxyphenbutazone"); 119 const std::string oxyphen("Oxyphenbutazone");
102 two_name_response.set_name("Oxyphenbutazone");
103 PathString two_name_string(PSTR("Neuroanatomists"));
104 two_name_entity.set_non_unique_name("Neuroanatomists");
105 two_name_response.set_non_unique_name("Neuroanatomists");
106 120
107 SyncName name_a = SyncerProtoUtil::NameFromSyncEntity(two_name_entity); 121 two_name_entity.set_name(oxyphen);
108 EXPECT_EQ(two_name_string_unique, name_a.value()); 122 two_name_entity.set_non_unique_name(neuro);
109 EXPECT_EQ(two_name_string, name_a.non_unique_value());
110 123
111 SyncName name_b = 124 two_name_response.set_name(oxyphen);
125 two_name_response.set_non_unique_name(neuro);
126
127 const std::string name_a =
128 SyncerProtoUtil::NameFromSyncEntity(two_name_entity);
129 EXPECT_EQ(neuro, name_a);
130
131 const std::string name_b =
112 SyncerProtoUtil::NameFromCommitEntryResponse(two_name_response); 132 SyncerProtoUtil::NameFromCommitEntryResponse(two_name_response);
113 EXPECT_EQ(two_name_string_unique, name_b.value()); 133 EXPECT_EQ(neuro, name_b);
114 EXPECT_EQ(two_name_string, name_b.non_unique_value());
115 134
116 EXPECT_TRUE(name_a == name_b); 135 EXPECT_TRUE(name_a == name_b);
117 } 136 }
118 137
119 } // namespace browser_sync 138 } // namespace browser_sync
OLDNEW
« no previous file with comments | « chrome/browser/sync/engine/syncer_proto_util.cc ('k') | chrome/browser/sync/engine/syncer_types.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698