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

Side by Side Diff: chrome/browser/sync/test/integration/two_client_autofill_sync_test.cc

Issue 8787006: Delay autofill commits to reduce client to server traffic. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: for commit. Created 9 years 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 | Annotate | Revision Log
« no previous file with comments | « chrome/browser/sync/internal_api/syncapi_unittest.cc ('k') | no next file » | 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) 2011 The Chromium Authors. All rights reserved. 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 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 "base/utf_string_conversions.h" 5 #include "base/utf_string_conversions.h"
6 #include "chrome/browser/autofill/autofill_profile.h" 6 #include "chrome/browser/autofill/autofill_profile.h"
7 #include "chrome/browser/sync/profile_sync_service_harness.h" 7 #include "chrome/browser/sync/profile_sync_service_harness.h"
8 #include "chrome/browser/sync/test/integration/autofill_helper.h" 8 #include "chrome/browser/sync/test/integration/autofill_helper.h"
9 #include "chrome/browser/sync/test/integration/bookmarks_helper.h"
9 #include "chrome/browser/sync/test/integration/sync_test.h" 10 #include "chrome/browser/sync/test/integration/sync_test.h"
10 #include "chrome/browser/webdata/autofill_entry.h" 11 #include "chrome/browser/webdata/autofill_entry.h"
11 #include "chrome/browser/webdata/autofill_table.h" 12 #include "chrome/browser/webdata/autofill_table.h"
12 13
13 using autofill_helper::AddKeys; 14 using autofill_helper::AddKeys;
14 using autofill_helper::AddProfile; 15 using autofill_helper::AddProfile;
15 using autofill_helper::CreateAutofillProfile; 16 using autofill_helper::CreateAutofillProfile;
16 using autofill_helper::GetAllKeys; 17 using autofill_helper::GetAllKeys;
17 using autofill_helper::GetAllProfiles; 18 using autofill_helper::GetAllProfiles;
18 using autofill_helper::KeysMatch; 19 using autofill_helper::KeysMatch;
19 using autofill_helper::ProfilesMatch; 20 using autofill_helper::ProfilesMatch;
20 using autofill_helper::PROFILE_FRASIER; 21 using autofill_helper::PROFILE_FRASIER;
21 using autofill_helper::PROFILE_HOMER; 22 using autofill_helper::PROFILE_HOMER;
22 using autofill_helper::PROFILE_MARION; 23 using autofill_helper::PROFILE_MARION;
23 using autofill_helper::PROFILE_NULL; 24 using autofill_helper::PROFILE_NULL;
24 using autofill_helper::RemoveKey; 25 using autofill_helper::RemoveKey;
25 using autofill_helper::RemoveProfile; 26 using autofill_helper::RemoveProfile;
26 using autofill_helper::UpdateProfile; 27 using autofill_helper::UpdateProfile;
28 using bookmarks_helper::AddFolder;
29 using bookmarks_helper::AddURL;
30 using bookmarks_helper::IndexedURL;
31 using bookmarks_helper::IndexedURLTitle;
27 32
28 class TwoClientAutofillSyncTest : public SyncTest { 33 class TwoClientAutofillSyncTest : public SyncTest {
29 public: 34 public:
30 TwoClientAutofillSyncTest() : SyncTest(TWO_CLIENT) {} 35 TwoClientAutofillSyncTest() : SyncTest(TWO_CLIENT) { count = 0; }
31 virtual ~TwoClientAutofillSyncTest() {} 36 virtual ~TwoClientAutofillSyncTest() {}
32 37
38 // We do this so as to make a change that will trigger the autofill to sync.
39 // By default autofill does not sync unless there is some other change.
40 void MakeABookmarkChange(int profile) {
41 ASSERT_TRUE(
42 AddURL(profile, IndexedURLTitle(count), GURL(IndexedURL(count))));
43 ++count;
44 }
33 private: 45 private:
46 int count;
34 DISALLOW_COPY_AND_ASSIGN(TwoClientAutofillSyncTest); 47 DISALLOW_COPY_AND_ASSIGN(TwoClientAutofillSyncTest);
35 }; 48 };
36 49
37 // Flaky, http://crbug.com/102687 50 // Flaky, http://crbug.com/102687
38 IN_PROC_BROWSER_TEST_F(TwoClientAutofillSyncTest, FLAKY_WebDataServiceSanity) { 51 IN_PROC_BROWSER_TEST_F(TwoClientAutofillSyncTest, FLAKY_WebDataServiceSanity) {
39 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; 52 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
40 53
41 // Client0 adds a key. 54 // Client0 adds a key.
42 std::set<AutofillKey> keys; 55 std::set<AutofillKey> keys;
43 keys.insert(AutofillKey("name0", "value0")); 56 keys.insert(AutofillKey("name0", "value0"));
44 AddKeys(0, keys); 57 AddKeys(0, keys);
58 MakeABookmarkChange(0);
45 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); 59 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
46 ASSERT_TRUE(KeysMatch(0, 1)); 60 ASSERT_TRUE(KeysMatch(0, 1));
47 ASSERT_EQ(1U, GetAllKeys(0).size()); 61 ASSERT_EQ(1U, GetAllKeys(0).size());
48 62
49 // Client1 adds a key. 63 // Client1 adds a key.
50 keys.clear(); 64 keys.clear();
51 keys.insert(AutofillKey("name1", "value1-0")); 65 keys.insert(AutofillKey("name1", "value1-0"));
52 AddKeys(1, keys); 66 AddKeys(1, keys);
67 MakeABookmarkChange(1);
53 ASSERT_TRUE(GetClient(1)->AwaitMutualSyncCycleCompletion(GetClient(0))); 68 ASSERT_TRUE(GetClient(1)->AwaitMutualSyncCycleCompletion(GetClient(0)));
54 ASSERT_TRUE(KeysMatch(0, 1)); 69 ASSERT_TRUE(KeysMatch(0, 1));
55 ASSERT_EQ(2U, GetAllKeys(0).size()); 70 ASSERT_EQ(2U, GetAllKeys(0).size());
56 71
57 // Client0 adds a key with the same name. 72 // Client0 adds a key with the same name.
58 keys.clear(); 73 keys.clear();
59 keys.insert(AutofillKey("name1", "value1-1")); 74 keys.insert(AutofillKey("name1", "value1-1"));
60 AddKeys(0, keys); 75 AddKeys(0, keys);
76 MakeABookmarkChange(0);
61 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); 77 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
62 ASSERT_TRUE(KeysMatch(0, 1)); 78 ASSERT_TRUE(KeysMatch(0, 1));
63 ASSERT_EQ(3U, GetAllKeys(0).size()); 79 ASSERT_EQ(3U, GetAllKeys(0).size());
64 80
65 // Client1 removes a key. 81 // Client1 removes a key.
66 RemoveKey(1, AutofillKey("name1", "value1-0")); 82 RemoveKey(1, AutofillKey("name1", "value1-0"));
83 MakeABookmarkChange(1);
67 ASSERT_TRUE(GetClient(1)->AwaitMutualSyncCycleCompletion(GetClient(0))); 84 ASSERT_TRUE(GetClient(1)->AwaitMutualSyncCycleCompletion(GetClient(0)));
68 ASSERT_TRUE(KeysMatch(0, 1)); 85 ASSERT_TRUE(KeysMatch(0, 1));
69 ASSERT_EQ(2U, GetAllKeys(0).size()); 86 ASSERT_EQ(2U, GetAllKeys(0).size());
70 87
71 // Client0 removes the rest. 88 // Client0 removes the rest.
72 RemoveKey(0, AutofillKey("name0", "value0")); 89 RemoveKey(0, AutofillKey("name0", "value0"));
73 RemoveKey(0, AutofillKey("name1", "value1-1")); 90 RemoveKey(0, AutofillKey("name1", "value1-1"));
91 MakeABookmarkChange(0);
74 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); 92 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
75 ASSERT_TRUE(KeysMatch(0, 1)); 93 ASSERT_TRUE(KeysMatch(0, 1));
76 ASSERT_EQ(0U, GetAllKeys(0).size()); 94 ASSERT_EQ(0U, GetAllKeys(0).size());
77 } 95 }
78 96
79 // TCM ID - 3678296. 97 // TCM ID - 3678296.
80 IN_PROC_BROWSER_TEST_F(TwoClientAutofillSyncTest, AddUnicodeProfile) { 98 IN_PROC_BROWSER_TEST_F(TwoClientAutofillSyncTest, AddUnicodeProfile) {
81 ASSERT_TRUE(SetupClients()) << "SetupClients() failed."; 99 ASSERT_TRUE(SetupClients()) << "SetupClients() failed.";
82 100
83 std::set<AutofillKey> keys; 101 std::set<AutofillKey> keys;
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 ASSERT_TRUE(KeysMatch(0, 1)); 142 ASSERT_TRUE(KeysMatch(0, 1));
125 ASSERT_EQ(5U, GetAllKeys(0).size()); 143 ASSERT_EQ(5U, GetAllKeys(0).size());
126 } 144 }
127 145
128 IN_PROC_BROWSER_TEST_F(TwoClientAutofillSyncTest, 146 IN_PROC_BROWSER_TEST_F(TwoClientAutofillSyncTest,
129 PersonalDataManagerSanity) { 147 PersonalDataManagerSanity) {
130 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; 148 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
131 149
132 // Client0 adds a profile. 150 // Client0 adds a profile.
133 AddProfile(0, CreateAutofillProfile(PROFILE_HOMER)); 151 AddProfile(0, CreateAutofillProfile(PROFILE_HOMER));
152 MakeABookmarkChange(0);
134 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); 153 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
135 ASSERT_TRUE(ProfilesMatch(0, 1)); 154 ASSERT_TRUE(ProfilesMatch(0, 1));
136 ASSERT_EQ(1U, GetAllProfiles(0).size()); 155 ASSERT_EQ(1U, GetAllProfiles(0).size());
137 156
138 // Client1 adds a profile. 157 // Client1 adds a profile.
139 AddProfile(1, CreateAutofillProfile(PROFILE_MARION)); 158 AddProfile(1, CreateAutofillProfile(PROFILE_MARION));
159 MakeABookmarkChange(1);
140 ASSERT_TRUE(GetClient(1)->AwaitMutualSyncCycleCompletion(GetClient(0))); 160 ASSERT_TRUE(GetClient(1)->AwaitMutualSyncCycleCompletion(GetClient(0)));
141 ASSERT_TRUE(ProfilesMatch(0, 1)); 161 ASSERT_TRUE(ProfilesMatch(0, 1));
142 ASSERT_EQ(2U, GetAllProfiles(0).size()); 162 ASSERT_EQ(2U, GetAllProfiles(0).size());
143 163
144 // Client0 adds the same profile. 164 // Client0 adds the same profile.
145 AddProfile(0, CreateAutofillProfile(PROFILE_MARION)); 165 AddProfile(0, CreateAutofillProfile(PROFILE_MARION));
166 MakeABookmarkChange(0);
146 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); 167 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
147 ASSERT_TRUE(ProfilesMatch(0, 1)); 168 ASSERT_TRUE(ProfilesMatch(0, 1));
148 ASSERT_EQ(2U, GetAllProfiles(0).size()); 169 ASSERT_EQ(2U, GetAllProfiles(0).size());
149 170
150 // Client1 removes a profile. 171 // Client1 removes a profile.
151 RemoveProfile(1, GetAllProfiles(1)[0]->guid()); 172 RemoveProfile(1, GetAllProfiles(1)[0]->guid());
173 MakeABookmarkChange(1);
152 ASSERT_TRUE(GetClient(1)->AwaitMutualSyncCycleCompletion(GetClient(0))); 174 ASSERT_TRUE(GetClient(1)->AwaitMutualSyncCycleCompletion(GetClient(0)));
153 ASSERT_TRUE(ProfilesMatch(0, 1)); 175 ASSERT_TRUE(ProfilesMatch(0, 1));
154 ASSERT_EQ(1U, GetAllProfiles(0).size()); 176 ASSERT_EQ(1U, GetAllProfiles(0).size());
155 177
156 // Client0 updates a profile. 178 // Client0 updates a profile.
157 UpdateProfile(0, 179 UpdateProfile(0,
158 GetAllProfiles(0)[0]->guid(), 180 GetAllProfiles(0)[0]->guid(),
159 AutofillType(NAME_FIRST), 181 AutofillType(NAME_FIRST),
160 ASCIIToUTF16("Bart")); 182 ASCIIToUTF16("Bart"));
183 MakeABookmarkChange(0);
161 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); 184 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
162 ASSERT_TRUE(ProfilesMatch(0, 1)); 185 ASSERT_TRUE(ProfilesMatch(0, 1));
163 ASSERT_EQ(1U, GetAllProfiles(0).size()); 186 ASSERT_EQ(1U, GetAllProfiles(0).size());
164 187
165 // Client1 removes remaining profile. 188 // Client1 removes remaining profile.
166 RemoveProfile(1, GetAllProfiles(1)[0]->guid()); 189 RemoveProfile(1, GetAllProfiles(1)[0]->guid());
190 MakeABookmarkChange(1);
167 ASSERT_TRUE(GetClient(1)->AwaitMutualSyncCycleCompletion(GetClient(0))); 191 ASSERT_TRUE(GetClient(1)->AwaitMutualSyncCycleCompletion(GetClient(0)));
168 ASSERT_TRUE(ProfilesMatch(0, 1)); 192 ASSERT_TRUE(ProfilesMatch(0, 1));
169 ASSERT_EQ(0U, GetAllProfiles(0).size()); 193 ASSERT_EQ(0U, GetAllProfiles(0).size());
170 } 194 }
171 195
172 // TCM ID - 7261786. 196 // TCM ID - 7261786.
173 IN_PROC_BROWSER_TEST_F(TwoClientAutofillSyncTest, AddDuplicateProfiles) { 197 IN_PROC_BROWSER_TEST_F(TwoClientAutofillSyncTest, AddDuplicateProfiles) {
174 ASSERT_TRUE(SetupClients()) << "SetupClients() failed."; 198 ASSERT_TRUE(SetupClients()) << "SetupClients() failed.";
175 199
176 AddProfile(0, CreateAutofillProfile(PROFILE_HOMER)); 200 AddProfile(0, CreateAutofillProfile(PROFILE_HOMER));
(...skipping 28 matching lines...) Expand all
205 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); 229 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
206 ASSERT_TRUE(ProfilesMatch(0, 1)); 230 ASSERT_TRUE(ProfilesMatch(0, 1));
207 ASSERT_EQ(0U, GetAllProfiles(0).size()); 231 ASSERT_EQ(0U, GetAllProfiles(0).size());
208 } 232 }
209 233
210 // TCM ID - 3616283. 234 // TCM ID - 3616283.
211 IN_PROC_BROWSER_TEST_F(TwoClientAutofillSyncTest, AddProfile) { 235 IN_PROC_BROWSER_TEST_F(TwoClientAutofillSyncTest, AddProfile) {
212 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; 236 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
213 237
214 AddProfile(0, CreateAutofillProfile(PROFILE_HOMER)); 238 AddProfile(0, CreateAutofillProfile(PROFILE_HOMER));
239 MakeABookmarkChange(0);
215 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); 240 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
216 ASSERT_TRUE(ProfilesMatch(0, 1)); 241 ASSERT_TRUE(ProfilesMatch(0, 1));
217 ASSERT_EQ(1U, GetAllProfiles(0).size()); 242 ASSERT_EQ(1U, GetAllProfiles(0).size());
218 } 243 }
219 244
220 // TCM ID - 3632260. 245 // TCM ID - 3632260.
221 IN_PROC_BROWSER_TEST_F(TwoClientAutofillSyncTest, AddMultipleProfiles) { 246 IN_PROC_BROWSER_TEST_F(TwoClientAutofillSyncTest, AddMultipleProfiles) {
222 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; 247 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
223 248
224 AddProfile(0, CreateAutofillProfile(PROFILE_HOMER)); 249 AddProfile(0, CreateAutofillProfile(PROFILE_HOMER));
225 AddProfile(0, CreateAutofillProfile(PROFILE_MARION)); 250 AddProfile(0, CreateAutofillProfile(PROFILE_MARION));
226 AddProfile(0, CreateAutofillProfile(PROFILE_FRASIER)); 251 AddProfile(0, CreateAutofillProfile(PROFILE_FRASIER));
252 MakeABookmarkChange(0);
227 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); 253 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
228 ASSERT_TRUE(ProfilesMatch(0, 1)); 254 ASSERT_TRUE(ProfilesMatch(0, 1));
229 ASSERT_EQ(3U, GetAllProfiles(0).size()); 255 ASSERT_EQ(3U, GetAllProfiles(0).size());
230 } 256 }
231 257
232 // TCM ID - 3602257. 258 // TCM ID - 3602257.
233 IN_PROC_BROWSER_TEST_F(TwoClientAutofillSyncTest, DeleteProfile) { 259 IN_PROC_BROWSER_TEST_F(TwoClientAutofillSyncTest, DeleteProfile) {
234 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; 260 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
235 261
236 AddProfile(0, CreateAutofillProfile(PROFILE_HOMER)); 262 AddProfile(0, CreateAutofillProfile(PROFILE_HOMER));
263 MakeABookmarkChange(0);
237 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); 264 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
238 ASSERT_TRUE(ProfilesMatch(0, 1)); 265 ASSERT_TRUE(ProfilesMatch(0, 1));
239 ASSERT_EQ(1U, GetAllProfiles(0).size()); 266 ASSERT_EQ(1U, GetAllProfiles(0).size());
240 267
241 RemoveProfile(1, GetAllProfiles(1)[0]->guid()); 268 RemoveProfile(1, GetAllProfiles(1)[0]->guid());
269 MakeABookmarkChange(1);
242 ASSERT_TRUE(GetClient(1)->AwaitMutualSyncCycleCompletion(GetClient(0))); 270 ASSERT_TRUE(GetClient(1)->AwaitMutualSyncCycleCompletion(GetClient(0)));
243 ASSERT_TRUE(ProfilesMatch(0, 1)); 271 ASSERT_TRUE(ProfilesMatch(0, 1));
244 ASSERT_EQ(0U, GetAllProfiles(0).size()); 272 ASSERT_EQ(0U, GetAllProfiles(0).size());
245 } 273 }
246 274
247 // TCM ID - 3627300. 275 // TCM ID - 3627300.
248 IN_PROC_BROWSER_TEST_F(TwoClientAutofillSyncTest, MergeProfiles) { 276 IN_PROC_BROWSER_TEST_F(TwoClientAutofillSyncTest, MergeProfiles) {
249 ASSERT_TRUE(SetupClients()) << "SetupClients() failed."; 277 ASSERT_TRUE(SetupClients()) << "SetupClients() failed.";
250 278
251 AddProfile(0, CreateAutofillProfile(PROFILE_HOMER)); 279 AddProfile(0, CreateAutofillProfile(PROFILE_HOMER));
252 AddProfile(1, CreateAutofillProfile(PROFILE_MARION)); 280 AddProfile(1, CreateAutofillProfile(PROFILE_MARION));
253 AddProfile(1, CreateAutofillProfile(PROFILE_FRASIER)); 281 AddProfile(1, CreateAutofillProfile(PROFILE_FRASIER));
254 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; 282 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
255 ASSERT_TRUE(AwaitQuiescence()); 283 ASSERT_TRUE(AwaitQuiescence());
256 ASSERT_TRUE(ProfilesMatch(0, 1)); 284 ASSERT_TRUE(ProfilesMatch(0, 1));
257 ASSERT_EQ(3U, GetAllProfiles(0).size()); 285 ASSERT_EQ(3U, GetAllProfiles(0).size());
258 } 286 }
259 287
260 // TCM ID - 3665264. 288 // TCM ID - 3665264.
261 IN_PROC_BROWSER_TEST_F(TwoClientAutofillSyncTest, UpdateFields) { 289 IN_PROC_BROWSER_TEST_F(TwoClientAutofillSyncTest, UpdateFields) {
262 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; 290 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
263 291
264 AddProfile(0, CreateAutofillProfile(PROFILE_HOMER)); 292 AddProfile(0, CreateAutofillProfile(PROFILE_HOMER));
293 MakeABookmarkChange(0);
265 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); 294 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
266 ASSERT_TRUE(ProfilesMatch(0, 1)); 295 ASSERT_TRUE(ProfilesMatch(0, 1));
267 ASSERT_EQ(1U, GetAllProfiles(0).size()); 296 ASSERT_EQ(1U, GetAllProfiles(0).size());
268 297
269 UpdateProfile(0, 298 UpdateProfile(0,
270 GetAllProfiles(0)[0]->guid(), 299 GetAllProfiles(0)[0]->guid(),
271 AutofillType(NAME_FIRST), 300 AutofillType(NAME_FIRST),
272 ASCIIToUTF16("Lisa")); 301 ASCIIToUTF16("Lisa"));
273 UpdateProfile(0, 302 UpdateProfile(0,
274 GetAllProfiles(0)[0]->guid(), 303 GetAllProfiles(0)[0]->guid(),
275 AutofillType(EMAIL_ADDRESS), 304 AutofillType(EMAIL_ADDRESS),
276 ASCIIToUTF16("grrrl@TV.com")); 305 ASCIIToUTF16("grrrl@TV.com"));
306 MakeABookmarkChange(0);
277 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); 307 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
278 ASSERT_TRUE(ProfilesMatch(0, 1)); 308 ASSERT_TRUE(ProfilesMatch(0, 1));
279 ASSERT_EQ(1U, GetAllProfiles(0).size()); 309 ASSERT_EQ(1U, GetAllProfiles(0).size());
280 } 310 }
281 311
282 // TCM ID - 3628299. 312 // TCM ID - 3628299.
283 IN_PROC_BROWSER_TEST_F(TwoClientAutofillSyncTest, ConflictingFields) { 313 IN_PROC_BROWSER_TEST_F(TwoClientAutofillSyncTest, ConflictingFields) {
284 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; 314 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
285 315
286 AddProfile(0, CreateAutofillProfile(PROFILE_HOMER)); 316 AddProfile(0, CreateAutofillProfile(PROFILE_HOMER));
317 MakeABookmarkChange(0);
287 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); 318 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
288 ASSERT_TRUE(ProfilesMatch(0, 1)); 319 ASSERT_TRUE(ProfilesMatch(0, 1));
289 ASSERT_EQ(1U, GetAllProfiles(0).size()); 320 ASSERT_EQ(1U, GetAllProfiles(0).size());
290 UpdateProfile(0, 321 UpdateProfile(0,
291 GetAllProfiles(0)[0]->guid(), 322 GetAllProfiles(0)[0]->guid(),
292 AutofillType(NAME_FIRST), 323 AutofillType(NAME_FIRST),
293 ASCIIToUTF16("Lisa")); 324 ASCIIToUTF16("Lisa"));
325 MakeABookmarkChange(0);
294 UpdateProfile(1, 326 UpdateProfile(1,
295 GetAllProfiles(1)[0]->guid(), 327 GetAllProfiles(1)[0]->guid(),
296 AutofillType(NAME_FIRST), 328 AutofillType(NAME_FIRST),
297 ASCIIToUTF16("Bart")); 329 ASCIIToUTF16("Bart"));
330 MakeABookmarkChange(1);
298 ASSERT_TRUE(AwaitQuiescence()); 331 ASSERT_TRUE(AwaitQuiescence());
299 ASSERT_TRUE(ProfilesMatch(0, 1)); 332 ASSERT_TRUE(ProfilesMatch(0, 1));
300 ASSERT_EQ(1U, GetAllProfiles(0).size()); 333 ASSERT_EQ(1U, GetAllProfiles(0).size());
301 } 334 }
302 335
303 // TCM ID - 3663293. 336 // TCM ID - 3663293.
304 IN_PROC_BROWSER_TEST_F(TwoClientAutofillSyncTest, DisableAutofill) { 337 IN_PROC_BROWSER_TEST_F(TwoClientAutofillSyncTest, DisableAutofill) {
305 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; 338 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
306 339
307 AddProfile(0, CreateAutofillProfile(PROFILE_HOMER)); 340 AddProfile(0, CreateAutofillProfile(PROFILE_HOMER));
341 MakeABookmarkChange(0);
308 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); 342 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
309 ASSERT_TRUE(ProfilesMatch(0, 1)); 343 ASSERT_TRUE(ProfilesMatch(0, 1));
310 ASSERT_EQ(1U, GetAllProfiles(0).size()); 344 ASSERT_EQ(1U, GetAllProfiles(0).size());
311 345
312 ASSERT_TRUE(GetClient(0)->DisableSyncForDatatype(syncable::AUTOFILL)); 346 ASSERT_TRUE(GetClient(0)->DisableSyncForDatatype(syncable::AUTOFILL));
313 AddProfile(0, CreateAutofillProfile(PROFILE_FRASIER)); 347 AddProfile(0, CreateAutofillProfile(PROFILE_FRASIER));
348 MakeABookmarkChange(0);
314 ASSERT_TRUE(AwaitQuiescence()); 349 ASSERT_TRUE(AwaitQuiescence());
315 ASSERT_FALSE(ProfilesMatch(0, 1)); 350 ASSERT_FALSE(ProfilesMatch(0, 1));
316 ASSERT_EQ(2U, GetAllProfiles(0).size()); 351 ASSERT_EQ(2U, GetAllProfiles(0).size());
317 ASSERT_EQ(1U, GetAllProfiles(1).size()); 352 ASSERT_EQ(1U, GetAllProfiles(1).size());
318 353
319 ASSERT_TRUE(GetClient(0)->EnableSyncForDatatype(syncable::AUTOFILL)); 354 ASSERT_TRUE(GetClient(0)->EnableSyncForDatatype(syncable::AUTOFILL));
355 MakeABookmarkChange(0);
320 ASSERT_TRUE(AwaitQuiescence()); 356 ASSERT_TRUE(AwaitQuiescence());
321 ASSERT_TRUE(ProfilesMatch(0, 1)); 357 ASSERT_TRUE(ProfilesMatch(0, 1));
322 ASSERT_EQ(2U, GetAllProfiles(0).size()); 358 ASSERT_EQ(2U, GetAllProfiles(0).size());
323 } 359 }
324 360
325 // TCM ID - 3661291. 361 // TCM ID - 3661291.
326 IN_PROC_BROWSER_TEST_F(TwoClientAutofillSyncTest, DisableSync) { 362 IN_PROC_BROWSER_TEST_F(TwoClientAutofillSyncTest, DisableSync) {
327 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; 363 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
328 364
329 AddProfile(0, CreateAutofillProfile(PROFILE_HOMER)); 365 AddProfile(0, CreateAutofillProfile(PROFILE_HOMER));
366 MakeABookmarkChange(0);
330 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); 367 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
331 ASSERT_TRUE(ProfilesMatch(0, 1)); 368 ASSERT_TRUE(ProfilesMatch(0, 1));
332 ASSERT_EQ(1U, GetAllProfiles(0).size()); 369 ASSERT_EQ(1U, GetAllProfiles(0).size());
333 370
334 ASSERT_TRUE(GetClient(1)->DisableSyncForAllDatatypes()); 371 ASSERT_TRUE(GetClient(1)->DisableSyncForAllDatatypes());
335 AddProfile(0, CreateAutofillProfile(PROFILE_FRASIER)); 372 AddProfile(0, CreateAutofillProfile(PROFILE_FRASIER));
373 MakeABookmarkChange(0);
336 ASSERT_TRUE(GetClient(0)->AwaitFullSyncCompletion("Added a profile.")); 374 ASSERT_TRUE(GetClient(0)->AwaitFullSyncCompletion("Added a profile."));
337 ASSERT_FALSE(ProfilesMatch(0, 1)); 375 ASSERT_FALSE(ProfilesMatch(0, 1));
338 ASSERT_EQ(2U, GetAllProfiles(0).size()); 376 ASSERT_EQ(2U, GetAllProfiles(0).size());
339 ASSERT_EQ(1U, GetAllProfiles(1).size()); 377 ASSERT_EQ(1U, GetAllProfiles(1).size());
340 378
341 ASSERT_TRUE(GetClient(1)->EnableSyncForAllDatatypes()); 379 ASSERT_TRUE(GetClient(1)->EnableSyncForAllDatatypes());
342 ASSERT_TRUE(AwaitQuiescence()); 380 ASSERT_TRUE(AwaitQuiescence());
343 ASSERT_TRUE(ProfilesMatch(0, 1)); 381 ASSERT_TRUE(ProfilesMatch(0, 1));
344 ASSERT_EQ(2U, GetAllProfiles(0).size()); 382 ASSERT_EQ(2U, GetAllProfiles(0).size());
345 } 383 }
346 384
347 // TCM ID - 3608295. 385 // TCM ID - 3608295.
348 IN_PROC_BROWSER_TEST_F(TwoClientAutofillSyncTest, MaxLength) { 386 IN_PROC_BROWSER_TEST_F(TwoClientAutofillSyncTest, MaxLength) {
349 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; 387 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
350 388
351 AddProfile(0, CreateAutofillProfile(PROFILE_HOMER)); 389 AddProfile(0, CreateAutofillProfile(PROFILE_HOMER));
390 MakeABookmarkChange(0);
352 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); 391 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
353 ASSERT_TRUE(ProfilesMatch(0, 1)); 392 ASSERT_TRUE(ProfilesMatch(0, 1));
354 ASSERT_EQ(1U, GetAllProfiles(0).size()); 393 ASSERT_EQ(1U, GetAllProfiles(0).size());
355 394
356 string16 max_length_string(AutofillTable::kMaxDataLength, '.'); 395 string16 max_length_string(AutofillTable::kMaxDataLength, '.');
357 UpdateProfile(0, 396 UpdateProfile(0,
358 GetAllProfiles(0)[0]->guid(), 397 GetAllProfiles(0)[0]->guid(),
359 AutofillType(NAME_FIRST), 398 AutofillType(NAME_FIRST),
360 max_length_string); 399 max_length_string);
361 UpdateProfile(0, 400 UpdateProfile(0,
362 GetAllProfiles(0)[0]->guid(), 401 GetAllProfiles(0)[0]->guid(),
363 AutofillType(NAME_LAST), 402 AutofillType(NAME_LAST),
364 max_length_string); 403 max_length_string);
365 UpdateProfile(0, 404 UpdateProfile(0,
366 GetAllProfiles(0)[0]->guid(), 405 GetAllProfiles(0)[0]->guid(),
367 AutofillType(EMAIL_ADDRESS), 406 AutofillType(EMAIL_ADDRESS),
368 max_length_string); 407 max_length_string);
369 UpdateProfile(0, 408 UpdateProfile(0,
370 GetAllProfiles(0)[0]->guid(), 409 GetAllProfiles(0)[0]->guid(),
371 AutofillType(ADDRESS_HOME_LINE1), 410 AutofillType(ADDRESS_HOME_LINE1),
372 max_length_string); 411 max_length_string);
373 412
413 MakeABookmarkChange(0);
374 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); 414 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
375 ASSERT_TRUE(ProfilesMatch(0, 1)); 415 ASSERT_TRUE(ProfilesMatch(0, 1));
376 } 416 }
377 417
378 IN_PROC_BROWSER_TEST_F(TwoClientAutofillSyncTest, ExceedsMaxLength) { 418 IN_PROC_BROWSER_TEST_F(TwoClientAutofillSyncTest, ExceedsMaxLength) {
379 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; 419 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
380 420
381 AddProfile(0, CreateAutofillProfile(PROFILE_HOMER)); 421 AddProfile(0, CreateAutofillProfile(PROFILE_HOMER));
422 MakeABookmarkChange(0);
382 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); 423 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
383 ASSERT_TRUE(ProfilesMatch(0, 1)); 424 ASSERT_TRUE(ProfilesMatch(0, 1));
384 ASSERT_EQ(1U, GetAllProfiles(0).size()); 425 ASSERT_EQ(1U, GetAllProfiles(0).size());
385 426
386 string16 exceeds_max_length_string(AutofillTable::kMaxDataLength + 1, '.'); 427 string16 exceeds_max_length_string(AutofillTable::kMaxDataLength + 1, '.');
387 UpdateProfile(0, 428 UpdateProfile(0,
388 GetAllProfiles(0)[0]->guid(), 429 GetAllProfiles(0)[0]->guid(),
389 AutofillType(NAME_FIRST), 430 AutofillType(NAME_FIRST),
390 exceeds_max_length_string); 431 exceeds_max_length_string);
391 UpdateProfile(0, 432 UpdateProfile(0,
392 GetAllProfiles(0)[0]->guid(), 433 GetAllProfiles(0)[0]->guid(),
393 AutofillType(NAME_LAST), 434 AutofillType(NAME_LAST),
394 exceeds_max_length_string); 435 exceeds_max_length_string);
395 UpdateProfile(0, 436 UpdateProfile(0,
396 GetAllProfiles(0)[0]->guid(), 437 GetAllProfiles(0)[0]->guid(),
397 AutofillType(EMAIL_ADDRESS), 438 AutofillType(EMAIL_ADDRESS),
398 exceeds_max_length_string); 439 exceeds_max_length_string);
399 UpdateProfile(0, 440 UpdateProfile(0,
400 GetAllProfiles(0)[0]->guid(), 441 GetAllProfiles(0)[0]->guid(),
401 AutofillType(ADDRESS_HOME_LINE1), 442 AutofillType(ADDRESS_HOME_LINE1),
402 exceeds_max_length_string); 443 exceeds_max_length_string);
403 444
445 MakeABookmarkChange(0);
404 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); 446 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
405 ASSERT_FALSE(ProfilesMatch(0, 1)); 447 ASSERT_FALSE(ProfilesMatch(0, 1));
406 } 448 }
OLDNEW
« no previous file with comments | « chrome/browser/sync/internal_api/syncapi_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698