OLD | NEW |
| (Empty) |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #include "base/utf_string_conversions.h" | |
6 #include "chrome/browser/sync/profile_sync_service_harness.h" | |
7 #include "chrome/browser/webdata/autofill_entry.h" | |
8 #include "chrome/test/live_sync/live_autofill_sync_test.h" | |
9 | |
10 // Autofill entry length is limited to 1024. See http://crbug.com/49332. | |
11 const size_t kMaxDataLength = 1024; | |
12 | |
13 IN_PROC_BROWSER_TEST_F(TwoClientLiveAutofillSyncTest, WebDataServiceSanity) { | |
14 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; | |
15 | |
16 // Client0 adds a key. | |
17 std::set<AutofillKey> keys; | |
18 keys.insert(AutofillKey("name0", "value0")); | |
19 AddKeys(0, keys); | |
20 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); | |
21 ASSERT_TRUE(KeysMatch(0, 1)); | |
22 ASSERT_EQ(1U, GetAllKeys(0).size()); | |
23 | |
24 // Client1 adds a key. | |
25 keys.clear(); | |
26 keys.insert(AutofillKey("name1", "value1-0")); | |
27 AddKeys(1, keys); | |
28 ASSERT_TRUE(GetClient(1)->AwaitMutualSyncCycleCompletion(GetClient(0))); | |
29 ASSERT_TRUE(KeysMatch(0, 1)); | |
30 ASSERT_EQ(2U, GetAllKeys(0).size()); | |
31 | |
32 // Client0 adds a key with the same name. | |
33 keys.clear(); | |
34 keys.insert(AutofillKey("name1", "value1-1")); | |
35 AddKeys(0, keys); | |
36 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); | |
37 ASSERT_TRUE(KeysMatch(0, 1)); | |
38 ASSERT_EQ(3U, GetAllKeys(0).size()); | |
39 | |
40 // Client1 removes a key. | |
41 RemoveKey(1, AutofillKey("name1", "value1-0")); | |
42 ASSERT_TRUE(GetClient(1)->AwaitMutualSyncCycleCompletion(GetClient(0))); | |
43 ASSERT_TRUE(KeysMatch(0, 1)); | |
44 ASSERT_EQ(2U, GetAllKeys(0).size()); | |
45 | |
46 // Client0 removes the rest. | |
47 RemoveKey(0, AutofillKey("name0", "value0")); | |
48 RemoveKey(0, AutofillKey("name1", "value1-1")); | |
49 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); | |
50 ASSERT_TRUE(KeysMatch(0, 1)); | |
51 ASSERT_EQ(0U, GetAllKeys(0).size()); | |
52 } | |
53 | |
54 // TCM ID - 3678296. | |
55 IN_PROC_BROWSER_TEST_F(TwoClientLiveAutofillSyncTest, AddUnicodeProfile) { | |
56 ASSERT_TRUE(SetupClients()) << "SetupClients() failed."; | |
57 | |
58 std::set<AutofillKey> keys; | |
59 keys.insert(AutofillKey(WideToUTF16(L"Sigur R\u00F3s"), | |
60 WideToUTF16(L"\u00C1g\u00E6tis byrjun"))); | |
61 AddKeys(0, keys); | |
62 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; | |
63 ASSERT_TRUE(AwaitQuiescence()); | |
64 ASSERT_TRUE(KeysMatch(0, 1)); | |
65 } | |
66 | |
67 IN_PROC_BROWSER_TEST_F(TwoClientLiveAutofillSyncTest, | |
68 AddDuplicateNamesToSameProfile) { | |
69 ASSERT_TRUE(SetupClients()) << "SetupClients() failed."; | |
70 | |
71 std::set<AutofillKey> keys; | |
72 keys.insert(AutofillKey("name0", "value0-0")); | |
73 keys.insert(AutofillKey("name0", "value0-1")); | |
74 keys.insert(AutofillKey("name1", "value1")); | |
75 AddKeys(0, keys); | |
76 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; | |
77 ASSERT_TRUE(AwaitQuiescence()); | |
78 ASSERT_TRUE(KeysMatch(0, 1)); | |
79 ASSERT_EQ(2U, GetAllKeys(0).size()); | |
80 } | |
81 | |
82 IN_PROC_BROWSER_TEST_F(TwoClientLiveAutofillSyncTest, | |
83 AddDuplicateNamesToDifferentProfiles) { | |
84 ASSERT_TRUE(SetupClients()) << "SetupClients() failed."; | |
85 | |
86 std::set<AutofillKey> keys0; | |
87 keys0.insert(AutofillKey("name0", "value0-0")); | |
88 keys0.insert(AutofillKey("name1", "value1")); | |
89 AddKeys(0, keys0); | |
90 | |
91 std::set<AutofillKey> keys1; | |
92 keys1.insert(AutofillKey("name0", "value0-1")); | |
93 keys1.insert(AutofillKey("name2", "value2")); | |
94 keys1.insert(AutofillKey("name3", "value3")); | |
95 AddKeys(1, keys1); | |
96 | |
97 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; | |
98 ASSERT_TRUE(AwaitQuiescence()); | |
99 ASSERT_TRUE(KeysMatch(0, 1)); | |
100 ASSERT_EQ(5U, GetAllKeys(0).size()); | |
101 } | |
102 | |
103 IN_PROC_BROWSER_TEST_F(TwoClientLiveAutofillSyncTest, | |
104 PersonalDataManagerSanity) { | |
105 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; | |
106 | |
107 // Client0 adds a profile. | |
108 AddProfile(0, CreateAutofillProfile(LiveAutofillSyncTest::PROFILE_HOMER)); | |
109 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); | |
110 ASSERT_TRUE(ProfilesMatch(0,1)); | |
111 ASSERT_EQ(1U, GetAllProfiles(0).size()); | |
112 | |
113 // Client1 adds a profile. | |
114 AddProfile(1, CreateAutofillProfile(LiveAutofillSyncTest::PROFILE_MARION)); | |
115 ASSERT_TRUE(GetClient(1)->AwaitMutualSyncCycleCompletion(GetClient(0))); | |
116 ASSERT_TRUE(ProfilesMatch(0,1)); | |
117 ASSERT_EQ(2U, GetAllProfiles(0).size()); | |
118 | |
119 // Client0 adds the same profile. | |
120 AddProfile(0, CreateAutofillProfile(LiveAutofillSyncTest::PROFILE_MARION)); | |
121 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); | |
122 ASSERT_TRUE(ProfilesMatch(0,1)); | |
123 ASSERT_EQ(2U, GetAllProfiles(0).size()); | |
124 | |
125 // Client1 removes a profile. | |
126 RemoveProfile(1, GetAllProfiles(1)[0]->guid()); | |
127 ASSERT_TRUE(GetClient(1)->AwaitMutualSyncCycleCompletion(GetClient(0))); | |
128 ASSERT_TRUE(ProfilesMatch(0,1)); | |
129 ASSERT_EQ(1U, GetAllProfiles(0).size()); | |
130 | |
131 // Client0 updates a profile. | |
132 UpdateProfile(0, GetAllProfiles(0)[0]->guid(), AutofillType(NAME_FIRST), | |
133 ASCIIToUTF16("Bart")); | |
134 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); | |
135 ASSERT_TRUE(ProfilesMatch(0,1)); | |
136 ASSERT_EQ(1U, GetAllProfiles(0).size()); | |
137 | |
138 // Client1 removes remaining profile. | |
139 RemoveProfile(1, GetAllProfiles(1)[0]->guid()); | |
140 ASSERT_TRUE(GetClient(1)->AwaitMutualSyncCycleCompletion(GetClient(0))); | |
141 ASSERT_TRUE(ProfilesMatch(0,1)); | |
142 ASSERT_EQ(0U, GetAllProfiles(0).size()); | |
143 } | |
144 | |
145 // TCM ID - 7261786. | |
146 IN_PROC_BROWSER_TEST_F(TwoClientLiveAutofillSyncTest, AddDuplicateProfiles) { | |
147 ASSERT_TRUE(SetupClients()) << "SetupClients() failed."; | |
148 | |
149 AddProfile(0, CreateAutofillProfile(LiveAutofillSyncTest::PROFILE_HOMER)); | |
150 AddProfile(0, CreateAutofillProfile(LiveAutofillSyncTest::PROFILE_HOMER)); | |
151 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; | |
152 ASSERT_TRUE(AwaitQuiescence()); | |
153 ASSERT_TRUE(ProfilesMatch(0,1)); | |
154 ASSERT_EQ(1U, GetAllProfiles(0).size()); | |
155 } | |
156 | |
157 // TCM ID - 3636294. | |
158 IN_PROC_BROWSER_TEST_F(TwoClientLiveAutofillSyncTest, SameProfileWithConflict) { | |
159 ASSERT_TRUE(SetupClients()) << "SetupClients() failed."; | |
160 | |
161 AutofillProfile profile0 = | |
162 CreateAutofillProfile(LiveAutofillSyncTest::PROFILE_HOMER); | |
163 AutofillProfile profile1 = | |
164 CreateAutofillProfile(LiveAutofillSyncTest::PROFILE_HOMER); | |
165 profile1.SetInfo(PHONE_FAX_WHOLE_NUMBER, ASCIIToUTF16("1234567890")); | |
166 | |
167 AddProfile(0, profile0); | |
168 AddProfile(1, profile1); | |
169 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; | |
170 ASSERT_TRUE(AwaitQuiescence()); | |
171 ASSERT_TRUE(ProfilesMatch(0,1)); | |
172 ASSERT_EQ(1U, GetAllProfiles(0).size()); | |
173 } | |
174 | |
175 // TCM ID - 3626291. | |
176 IN_PROC_BROWSER_TEST_F(TwoClientLiveAutofillSyncTest, AddEmptyProfile) { | |
177 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; | |
178 | |
179 AddProfile(0, CreateAutofillProfile(LiveAutofillSyncTest::PROFILE_NULL)); | |
180 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); | |
181 ASSERT_TRUE(ProfilesMatch(0,1)); | |
182 ASSERT_EQ(0U, GetAllProfiles(0).size()); | |
183 } | |
184 | |
185 // TCM ID - 3616283. | |
186 IN_PROC_BROWSER_TEST_F(TwoClientLiveAutofillSyncTest, AddProfile) { | |
187 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; | |
188 | |
189 AddProfile(0, CreateAutofillProfile(LiveAutofillSyncTest::PROFILE_HOMER)); | |
190 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); | |
191 ASSERT_TRUE(ProfilesMatch(0,1)); | |
192 ASSERT_EQ(1U, GetAllProfiles(0).size()); | |
193 } | |
194 | |
195 // TCM ID - 3632260. | |
196 IN_PROC_BROWSER_TEST_F(TwoClientLiveAutofillSyncTest, AddMultipleProfiles) { | |
197 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; | |
198 | |
199 AddProfile(0, CreateAutofillProfile(LiveAutofillSyncTest::PROFILE_HOMER)); | |
200 AddProfile(0, CreateAutofillProfile(LiveAutofillSyncTest::PROFILE_MARION)); | |
201 AddProfile(0, CreateAutofillProfile(LiveAutofillSyncTest::PROFILE_FRASIER)); | |
202 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); | |
203 ASSERT_TRUE(ProfilesMatch(0,1)); | |
204 ASSERT_EQ(3U, GetAllProfiles(0).size()); | |
205 } | |
206 | |
207 // TCM ID - 3602257. | |
208 IN_PROC_BROWSER_TEST_F(TwoClientLiveAutofillSyncTest, DeleteProfile) { | |
209 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; | |
210 | |
211 AddProfile(0, CreateAutofillProfile(LiveAutofillSyncTest::PROFILE_HOMER)); | |
212 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); | |
213 ASSERT_TRUE(ProfilesMatch(0,1)); | |
214 ASSERT_EQ(1U, GetAllProfiles(0).size()); | |
215 | |
216 RemoveProfile(1, GetAllProfiles(1)[0]->guid()); | |
217 ASSERT_TRUE(GetClient(1)->AwaitMutualSyncCycleCompletion(GetClient(0))); | |
218 ASSERT_TRUE(ProfilesMatch(0,1)); | |
219 ASSERT_EQ(0U, GetAllProfiles(0).size()); | |
220 } | |
221 | |
222 // TCM ID - 3627300. | |
223 IN_PROC_BROWSER_TEST_F(TwoClientLiveAutofillSyncTest, MergeProfiles) { | |
224 ASSERT_TRUE(SetupClients()) << "SetupClients() failed."; | |
225 | |
226 AddProfile(0, CreateAutofillProfile(LiveAutofillSyncTest::PROFILE_HOMER)); | |
227 AddProfile(1, CreateAutofillProfile(LiveAutofillSyncTest::PROFILE_MARION)); | |
228 AddProfile(1, CreateAutofillProfile(LiveAutofillSyncTest::PROFILE_FRASIER)); | |
229 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; | |
230 ASSERT_TRUE(AwaitQuiescence()); | |
231 ASSERT_TRUE(ProfilesMatch(0,1)); | |
232 ASSERT_EQ(3U, GetAllProfiles(0).size()); | |
233 } | |
234 | |
235 // TCM ID - 3665264. | |
236 IN_PROC_BROWSER_TEST_F(TwoClientLiveAutofillSyncTest, UpdateFields) { | |
237 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; | |
238 | |
239 AddProfile(0, CreateAutofillProfile(LiveAutofillSyncTest::PROFILE_HOMER)); | |
240 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); | |
241 ASSERT_TRUE(ProfilesMatch(0,1)); | |
242 ASSERT_EQ(1U, GetAllProfiles(0).size()); | |
243 | |
244 UpdateProfile(0, GetAllProfiles(0)[0]->guid(), AutofillType(NAME_FIRST), | |
245 ASCIIToUTF16("Lisa")); | |
246 UpdateProfile(0, GetAllProfiles(0)[0]->guid(), AutofillType(EMAIL_ADDRESS), | |
247 ASCIIToUTF16("grrrl@TV.com")); | |
248 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); | |
249 ASSERT_TRUE(ProfilesMatch(0,1)); | |
250 ASSERT_EQ(1U, GetAllProfiles(0).size()); | |
251 } | |
252 | |
253 // TCM ID - 3628299. | |
254 IN_PROC_BROWSER_TEST_F(TwoClientLiveAutofillSyncTest, ConflictingFields) { | |
255 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; | |
256 | |
257 AddProfile(0, CreateAutofillProfile(LiveAutofillSyncTest::PROFILE_HOMER)); | |
258 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); | |
259 ASSERT_TRUE(ProfilesMatch(0,1)); | |
260 ASSERT_EQ(1U, GetAllProfiles(0).size()); | |
261 UpdateProfile(0, GetAllProfiles(0)[0]->guid(), AutofillType(NAME_FIRST), | |
262 ASCIIToUTF16("Lisa")); | |
263 UpdateProfile(1, GetAllProfiles(1)[0]->guid(), AutofillType(NAME_FIRST), | |
264 ASCIIToUTF16("Bart")); | |
265 ASSERT_TRUE(AwaitQuiescence()); | |
266 ASSERT_TRUE(ProfilesMatch(0,1)); | |
267 ASSERT_EQ(1U, GetAllProfiles(0).size()); | |
268 } | |
269 | |
270 // TCM ID - 3663293. | |
271 IN_PROC_BROWSER_TEST_F(TwoClientLiveAutofillSyncTest, DisableAutofill) { | |
272 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; | |
273 | |
274 AddProfile(0, CreateAutofillProfile(LiveAutofillSyncTest::PROFILE_HOMER)); | |
275 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); | |
276 ASSERT_TRUE(ProfilesMatch(0, 1)); | |
277 ASSERT_EQ(1U, GetAllProfiles(0).size()); | |
278 | |
279 ASSERT_TRUE(GetClient(0)->DisableSyncForDatatype(syncable::AUTOFILL)); | |
280 AddProfile(0, CreateAutofillProfile(LiveAutofillSyncTest::PROFILE_FRASIER)); | |
281 ASSERT_TRUE(AwaitQuiescence()); | |
282 ASSERT_FALSE(ProfilesMatch(0, 1)); | |
283 ASSERT_EQ(2U, GetAllProfiles(0).size()); | |
284 ASSERT_EQ(1U, GetAllProfiles(1).size()); | |
285 | |
286 ASSERT_TRUE(GetClient(0)->EnableSyncForDatatype(syncable::AUTOFILL)); | |
287 ASSERT_TRUE(AwaitQuiescence()); | |
288 ASSERT_TRUE(ProfilesMatch(0, 1)); | |
289 ASSERT_EQ(2U, GetAllProfiles(0).size()); | |
290 } | |
291 | |
292 // TCM ID - 3661291. | |
293 IN_PROC_BROWSER_TEST_F(TwoClientLiveAutofillSyncTest, DisableSync) { | |
294 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; | |
295 | |
296 AddProfile(0, CreateAutofillProfile(LiveAutofillSyncTest::PROFILE_HOMER)); | |
297 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); | |
298 ASSERT_TRUE(ProfilesMatch(0, 1)); | |
299 ASSERT_EQ(1U, GetAllProfiles(0).size()); | |
300 | |
301 ASSERT_TRUE(GetClient(1)->DisableSyncForAllDatatypes()); | |
302 AddProfile(0, CreateAutofillProfile(LiveAutofillSyncTest::PROFILE_FRASIER)); | |
303 ASSERT_TRUE(GetClient(0)->AwaitSyncCycleCompletion("Added a profile.")); | |
304 ASSERT_FALSE(ProfilesMatch(0, 1)); | |
305 ASSERT_EQ(2U, GetAllProfiles(0).size()); | |
306 ASSERT_EQ(1U, GetAllProfiles(1).size()); | |
307 | |
308 ASSERT_TRUE(GetClient(1)->EnableSyncForAllDatatypes()); | |
309 ASSERT_TRUE(AwaitQuiescence()); | |
310 ASSERT_TRUE(ProfilesMatch(0, 1)); | |
311 ASSERT_EQ(2U, GetAllProfiles(0).size()); | |
312 } | |
313 | |
314 // TCM ID - 3608295. | |
315 IN_PROC_BROWSER_TEST_F(TwoClientLiveAutofillSyncTest, MaxLength) { | |
316 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; | |
317 | |
318 AddProfile(0, CreateAutofillProfile(LiveAutofillSyncTest::PROFILE_HOMER)); | |
319 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); | |
320 ASSERT_TRUE(ProfilesMatch(0, 1)); | |
321 ASSERT_EQ(1U, GetAllProfiles(0).size()); | |
322 | |
323 string16 max_length_string(kMaxDataLength, '.'); | |
324 UpdateProfile(0, GetAllProfiles(0)[0]->guid(), | |
325 AutofillType(NAME_FIRST), max_length_string); | |
326 UpdateProfile(0, GetAllProfiles(0)[0]->guid(), | |
327 AutofillType(NAME_LAST), max_length_string); | |
328 UpdateProfile(0, GetAllProfiles(0)[0]->guid(), | |
329 AutofillType(EMAIL_ADDRESS), max_length_string); | |
330 UpdateProfile(0, GetAllProfiles(0)[0]->guid(), | |
331 AutofillType(ADDRESS_HOME_LINE1), max_length_string); | |
332 | |
333 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); | |
334 ASSERT_TRUE(ProfilesMatch(0, 1)); | |
335 } | |
336 | |
337 // See http://crbug.com/85769. | |
338 // TODO(braffert): Remove FAILS annotation when bug 85769 is resolved. | |
339 // TCM ID - 7735472. | |
340 IN_PROC_BROWSER_TEST_F(TwoClientLiveAutofillSyncTest, FAILS_ExceedsMaxLength) { | |
341 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; | |
342 | |
343 AddProfile(0, CreateAutofillProfile(LiveAutofillSyncTest::PROFILE_HOMER)); | |
344 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); | |
345 ASSERT_TRUE(ProfilesMatch(0, 1)); | |
346 ASSERT_EQ(1U, GetAllProfiles(0).size()); | |
347 | |
348 string16 exceeds_max_length_string(kMaxDataLength + 1, '.'); | |
349 UpdateProfile(0, GetAllProfiles(0)[0]->guid(), | |
350 AutofillType(NAME_FIRST), exceeds_max_length_string); | |
351 UpdateProfile(0, GetAllProfiles(0)[0]->guid(), | |
352 AutofillType(NAME_LAST), exceeds_max_length_string); | |
353 UpdateProfile(0, GetAllProfiles(0)[0]->guid(), | |
354 AutofillType(EMAIL_ADDRESS), exceeds_max_length_string); | |
355 UpdateProfile(0, GetAllProfiles(0)[0]->guid(), | |
356 AutofillType(ADDRESS_HOME_LINE1), exceeds_max_length_string); | |
357 | |
358 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); | |
359 ASSERT_FALSE(ProfilesMatch(0, 1)); | |
360 } | |
OLD | NEW |