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

Side by Side Diff: chrome/test/live_sync/two_client_live_autofill_sync_test.cc

Issue 3037019: Fixing broken Integration tests. (Closed)
Patch Set: Adding periods after comments. Created 10 years, 4 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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/test/live_sync/live_autofill_sync_test.h" 5 #include "chrome/test/live_sync/live_autofill_sync_test.h"
6 6
7 IN_PROC_BROWSER_TEST_F(TwoClientLiveAutofillSyncTest, Client1HasData) { 7 IN_PROC_BROWSER_TEST_F(TwoClientLiveAutofillSyncTest, Client1HasData) {
8 ASSERT_TRUE(SetupClients()) << "SetupClients() failed."; 8 ASSERT_TRUE(SetupClients()) << "SetupClients() failed.";
9 9
10 AutofillKeys keys; 10 AutofillKeys keys;
11 keys.insert(AutofillKey("name0", "value0")); 11 keys.insert(AutofillKey("name0", "value0"));
12 keys.insert(AutofillKey("name0", "value1")); 12 keys.insert(AutofillKey("name0", "value1"));
13 keys.insert(AutofillKey("name1", "value2")); 13 keys.insert(AutofillKey("name1", "value2"));
14 keys.insert(AutofillKey(WideToUTF16(L"Sigur R\u00F3s"), 14 keys.insert(AutofillKey(WideToUTF16(L"Sigur R\u00F3s"),
15 WideToUTF16(L"\u00C1g\u00E6tis byrjun"))); 15 WideToUTF16(L"\u00C1g\u00E6tis byrjun")));
16 AddFormFieldsToWebData(GetWebDataService(0), keys); 16 AddFormFieldsToWebData(GetWebDataService(0), keys);
17 17
18 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; 18 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
19 ASSERT_TRUE(ProfileSyncServiceTestHarness::AwaitQuiescence(clients()));
19 20
20 AutofillKeys wd1_keys; 21 AutofillKeys wd1_keys;
21 GetAllAutofillKeys(GetWebDataService(1), &wd1_keys); 22 GetAllAutofillKeys(GetWebDataService(1), &wd1_keys);
22 EXPECT_EQ(keys, wd1_keys); 23 EXPECT_EQ(keys, wd1_keys);
23 } 24 }
24 25
25 IN_PROC_BROWSER_TEST_F(TwoClientLiveAutofillSyncTest, BothHaveData) { 26 IN_PROC_BROWSER_TEST_F(TwoClientLiveAutofillSyncTest, BothHaveData) {
26 ASSERT_TRUE(SetupClients()) << "SetupClients() failed."; 27 ASSERT_TRUE(SetupClients()) << "SetupClients() failed.";
27 28
28 AutofillKeys keys1; 29 AutofillKeys keys1;
29 keys1.insert(AutofillKey("name0", "value0")); 30 keys1.insert(AutofillKey("name0", "value0"));
30 keys1.insert(AutofillKey("name0", "value1")); 31 keys1.insert(AutofillKey("name0", "value1"));
31 keys1.insert(AutofillKey("name1", "value2")); 32 keys1.insert(AutofillKey("name1", "value2"));
32 AddFormFieldsToWebData(GetWebDataService(0), keys1); 33 AddFormFieldsToWebData(GetWebDataService(0), keys1);
33 34
34 AutofillKeys keys2; 35 AutofillKeys keys2;
35 keys2.insert(AutofillKey("name0", "value1")); 36 keys2.insert(AutofillKey("name0", "value1"));
36 keys2.insert(AutofillKey("name1", "value2")); 37 keys2.insert(AutofillKey("name1", "value2"));
37 keys2.insert(AutofillKey("name2", "value3")); 38 keys2.insert(AutofillKey("name2", "value3"));
38 keys2.insert(AutofillKey("name3", "value3")); 39 keys2.insert(AutofillKey("name3", "value3"));
39 AddFormFieldsToWebData(GetWebDataService(1), keys2); 40 AddFormFieldsToWebData(GetWebDataService(1), keys2);
40 41
41 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; 42 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
42 // Wait for client1 to get the new keys from client2. 43 EXPECT_TRUE(ProfileSyncServiceTestHarness::AwaitQuiescence(clients()));
43 EXPECT_TRUE(GetClient(0)->AwaitSyncCycleCompletion("sync cycle"));
44 44
45 AutofillKeys expected_keys; 45 AutofillKeys expected_keys;
46 expected_keys.insert(AutofillKey("name0", "value0")); 46 expected_keys.insert(AutofillKey("name0", "value0"));
47 expected_keys.insert(AutofillKey("name0", "value1")); 47 expected_keys.insert(AutofillKey("name0", "value1"));
48 expected_keys.insert(AutofillKey("name1", "value2")); 48 expected_keys.insert(AutofillKey("name1", "value2"));
49 expected_keys.insert(AutofillKey("name2", "value3")); 49 expected_keys.insert(AutofillKey("name2", "value3"));
50 expected_keys.insert(AutofillKey("name3", "value3")); 50 expected_keys.insert(AutofillKey("name3", "value3"));
51 51
52 AutofillKeys wd0_keys; 52 AutofillKeys wd0_keys;
53 GetAllAutofillKeys(GetWebDataService(0), &wd0_keys); 53 GetAllAutofillKeys(GetWebDataService(0), &wd0_keys);
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 135
136 AutoFillProfiles expected_profiles; 136 AutoFillProfiles expected_profiles;
137 expected_profiles.push_back(new AutoFillProfile(string16(), 0)); 137 expected_profiles.push_back(new AutoFillProfile(string16(), 0));
138 FillProfile(MARION, expected_profiles[0]); 138 FillProfile(MARION, expected_profiles[0]);
139 expected_profiles.push_back(new AutoFillProfile(string16(), 0)); 139 expected_profiles.push_back(new AutoFillProfile(string16(), 0));
140 FillProfile(HOMER, expected_profiles[1]); 140 FillProfile(HOMER, expected_profiles[1]);
141 AddProfile(GetPersonalDataManager(0), *expected_profiles[0]); 141 AddProfile(GetPersonalDataManager(0), *expected_profiles[0]);
142 AddProfile(GetPersonalDataManager(0), *expected_profiles[1]); 142 AddProfile(GetPersonalDataManager(0), *expected_profiles[1]);
143 143
144 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; 144 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
145 ASSERT_TRUE(ProfileSyncServiceTestHarness::AwaitQuiescence(clients()));
145 146
146 EXPECT_TRUE(CompareAutoFillProfiles(expected_profiles, 147 EXPECT_TRUE(CompareAutoFillProfiles(expected_profiles,
147 GetAllAutoFillProfiles(GetPersonalDataManager(0)))); 148 GetAllAutoFillProfiles(GetPersonalDataManager(0))));
148 EXPECT_TRUE(CompareAutoFillProfiles(expected_profiles, 149 EXPECT_TRUE(CompareAutoFillProfiles(expected_profiles,
149 GetAllAutoFillProfiles(GetPersonalDataManager(1)))); 150 GetAllAutoFillProfiles(GetPersonalDataManager(1))));
150 STLDeleteElements(&expected_profiles); 151 STLDeleteElements(&expected_profiles);
151 } 152 }
152 153
153 IN_PROC_BROWSER_TEST_F(TwoClientLiveAutofillSyncTest, 154 IN_PROC_BROWSER_TEST_F(TwoClientLiveAutofillSyncTest,
154 ProfileSameLabelOnDifferentClients) { 155 ProfileSameLabelOnDifferentClients) {
155 ASSERT_TRUE(SetupClients()) << "SetupClients() failed."; 156 ASSERT_TRUE(SetupClients()) << "SetupClients() failed.";
156 157
157 AutoFillProfiles profiles1; 158 AutoFillProfiles profiles1;
158 profiles1.push_back(new AutoFillProfile(string16(), 0)); 159 profiles1.push_back(new AutoFillProfile(string16(), 0));
159 FillProfile(HOMER, profiles1[0]); 160 FillProfile(HOMER, profiles1[0]);
160 161
161 AutoFillProfiles profiles2; 162 AutoFillProfiles profiles2;
162 profiles2.push_back(new AutoFillProfile(string16(), 0)); 163 profiles2.push_back(new AutoFillProfile(string16(), 0));
163 FillProfile(MARION, profiles2[0]); 164 FillProfile(MARION, profiles2[0]);
164 profiles2[0]->set_label(ASCIIToUTF16("Shipping")); 165 profiles2[0]->set_label(ASCIIToUTF16("Shipping"));
165 166
166 AddProfile(GetPersonalDataManager(0), *profiles1[0]); 167 AddProfile(GetPersonalDataManager(0), *profiles1[0]);
167 AddProfile(GetPersonalDataManager(1), *profiles2[0]); 168 AddProfile(GetPersonalDataManager(1), *profiles2[0]);
168 169
169 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; 170 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
171 ASSERT_TRUE(ProfileSyncServiceTestHarness::AwaitQuiescence(clients()));
170 172
171 // Since client1 associates first, client2's "Shipping" profile will 173 // Since client1 associates first, client2's "Shipping" profile will
172 // be overwritten by the one stored in the cloud by profile1. 174 // be overwritten by the one stored in the cloud by profile1.
173 EXPECT_TRUE(CompareAutoFillProfiles(profiles1, 175 EXPECT_TRUE(CompareAutoFillProfiles(profiles1,
174 GetAllAutoFillProfiles(GetPersonalDataManager(0)))); 176 GetAllAutoFillProfiles(GetPersonalDataManager(0))));
175 EXPECT_TRUE(CompareAutoFillProfiles(profiles1, 177 EXPECT_TRUE(CompareAutoFillProfiles(profiles1,
176 GetAllAutoFillProfiles(GetPersonalDataManager(1)))); 178 GetAllAutoFillProfiles(GetPersonalDataManager(1))));
177 STLDeleteElements(&profiles1); 179 STLDeleteElements(&profiles1);
178 STLDeleteElements(&profiles2); 180 STLDeleteElements(&profiles2);
179 } 181 }
180 182
181 IN_PROC_BROWSER_TEST_F(TwoClientLiveAutofillSyncTest, 183 IN_PROC_BROWSER_TEST_F(TwoClientLiveAutofillSyncTest,
182 ProfileSameLabelOnClient1) { 184 ProfileSameLabelOnClient1) {
183 ASSERT_TRUE(SetupClients()) << "SetupClients() failed."; 185 ASSERT_TRUE(SetupClients()) << "SetupClients() failed.";
184 186
185 AutoFillProfiles expected_profiles; 187 AutoFillProfiles expected_profiles;
186 expected_profiles.push_back(new AutoFillProfile(string16(), 0)); 188 expected_profiles.push_back(new AutoFillProfile(string16(), 0));
187 FillProfile(HOMER, expected_profiles[0]); 189 FillProfile(HOMER, expected_profiles[0]);
188 expected_profiles.push_back(new AutoFillProfile(string16(), 0)); 190 expected_profiles.push_back(new AutoFillProfile(string16(), 0));
189 FillProfile(HOMER, expected_profiles[1]); 191 FillProfile(HOMER, expected_profiles[1]);
190 192
191 AddProfile(GetPersonalDataManager(0), *expected_profiles[0]); 193 AddProfile(GetPersonalDataManager(0), *expected_profiles[0]);
192 AddProfile(GetPersonalDataManager(0), *expected_profiles[1]); 194 AddProfile(GetPersonalDataManager(0), *expected_profiles[1]);
193 195
194 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; 196 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
197 ASSERT_TRUE(ProfileSyncServiceTestHarness::AwaitQuiescence(clients()));
195 198
196 // One of the duplicate profiles will have its label renamed to 199 // One of the duplicate profiles will have its label renamed to
197 // "Shipping2". 200 // "Shipping2".
198 expected_profiles[0]->set_label(ASCIIToUTF16("Shipping2")); 201 expected_profiles[0]->set_label(ASCIIToUTF16("Shipping2"));
199 202
200 EXPECT_TRUE(CompareAutoFillProfiles(expected_profiles, 203 EXPECT_TRUE(CompareAutoFillProfiles(expected_profiles,
201 GetAllAutoFillProfiles(GetPersonalDataManager(0)))); 204 GetAllAutoFillProfiles(GetPersonalDataManager(0))));
202 EXPECT_TRUE(CompareAutoFillProfiles(expected_profiles, 205 EXPECT_TRUE(CompareAutoFillProfiles(expected_profiles,
203 GetAllAutoFillProfiles(GetPersonalDataManager(1)))); 206 GetAllAutoFillProfiles(GetPersonalDataManager(1))));
204 STLDeleteElements(&expected_profiles); 207 STLDeleteElements(&expected_profiles);
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
273 STLDeleteElements(&expected_profiles); 276 STLDeleteElements(&expected_profiles);
274 RemoveProfile(GetPersonalDataManager(1), ASCIIToUTF16("Billing")); 277 RemoveProfile(GetPersonalDataManager(1), ASCIIToUTF16("Billing"));
275 RemoveProfile(GetPersonalDataManager(1), ASCIIToUTF16("Billing2")); 278 RemoveProfile(GetPersonalDataManager(1), ASCIIToUTF16("Billing2"));
276 EXPECT_TRUE(GetClient(1)->AwaitMutualSyncCycleCompletion(GetClient(0))); 279 EXPECT_TRUE(GetClient(1)->AwaitMutualSyncCycleCompletion(GetClient(0)));
277 280
278 EXPECT_TRUE(CompareAutoFillProfiles(expected_profiles, 281 EXPECT_TRUE(CompareAutoFillProfiles(expected_profiles,
279 GetAllAutoFillProfiles(GetPersonalDataManager(0)))); 282 GetAllAutoFillProfiles(GetPersonalDataManager(0))));
280 EXPECT_TRUE(CompareAutoFillProfiles(expected_profiles, 283 EXPECT_TRUE(CompareAutoFillProfiles(expected_profiles,
281 GetAllAutoFillProfiles(GetPersonalDataManager(1)))); 284 GetAllAutoFillProfiles(GetPersonalDataManager(1))));
282 } 285 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698