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

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

Issue 2379433002: [Sync] Refactoring of sync integration test checkers to remove boilerplate await methods. (Closed)
Patch Set: Rebase Created 4 years, 2 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
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 2 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 3 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 4 // found in the LICENSE file.
4 5
5 #include "base/macros.h" 6 #include "base/macros.h"
6 #include "base/strings/utf_string_conversions.h" 7 #include "base/strings/utf_string_conversions.h"
7 #include "chrome/browser/sync/test/integration/autofill_helper.h" 8 #include "chrome/browser/sync/test/integration/autofill_helper.h"
8 #include "chrome/browser/sync/test/integration/bookmarks_helper.h" 9 #include "chrome/browser/sync/test/integration/bookmarks_helper.h"
9 #include "chrome/browser/sync/test/integration/profile_sync_service_harness.h" 10 #include "chrome/browser/sync/test/integration/profile_sync_service_harness.h"
10 #include "chrome/browser/sync/test/integration/sync_integration_test_util.h"
11 #include "chrome/browser/sync/test/integration/sync_test.h" 11 #include "chrome/browser/sync/test/integration/sync_test.h"
12 #include "components/autofill/core/browser/autofill_profile.h" 12 #include "components/autofill/core/browser/autofill_profile.h"
13 #include "components/autofill/core/browser/credit_card.h" 13 #include "components/autofill/core/browser/credit_card.h"
14 #include "components/autofill/core/browser/personal_data_manager.h" 14 #include "components/autofill/core/browser/personal_data_manager.h"
15 #include "components/autofill/core/browser/webdata/autofill_entry.h" 15 #include "components/autofill/core/browser/webdata/autofill_entry.h"
16 #include "components/autofill/core/browser/webdata/autofill_table.h" 16 #include "components/autofill/core/browser/webdata/autofill_table.h"
17 17
18
19 using autofill::AutofillKey; 18 using autofill::AutofillKey;
20 using autofill::AutofillTable; 19 using autofill::AutofillTable;
21 using autofill::AutofillProfile; 20 using autofill::AutofillProfile;
22 using autofill::AutofillType; 21 using autofill::AutofillType;
23 using autofill::CreditCard; 22 using autofill::CreditCard;
24 using autofill::PersonalDataManager; 23 using autofill::PersonalDataManager;
25 using autofill_helper::AddKeys; 24 using autofill_helper::AddKeys;
26 using autofill_helper::AddProfile; 25 using autofill_helper::AddProfile;
27 using autofill_helper::AwaitKeysMatch;
28 using autofill_helper::AwaitProfilesMatch;
29 using autofill_helper::CreateAutofillProfile; 26 using autofill_helper::CreateAutofillProfile;
30 using autofill_helper::CreateUniqueAutofillProfile; 27 using autofill_helper::CreateUniqueAutofillProfile;
31 using autofill_helper::GetAllAutoFillProfiles; 28 using autofill_helper::GetAllAutoFillProfiles;
32 using autofill_helper::GetAllKeys; 29 using autofill_helper::GetAllKeys;
33 using autofill_helper::GetPersonalDataManager; 30 using autofill_helper::GetPersonalDataManager;
34 using autofill_helper::GetProfileCount; 31 using autofill_helper::GetProfileCount;
35 using autofill_helper::KeysMatch; 32 using autofill_helper::KeysMatch;
36 using autofill_helper::ProfilesMatch; 33 using autofill_helper::ProfilesMatch;
37 using autofill_helper::PROFILE_FRASIER; 34 using autofill_helper::PROFILE_FRASIER;
38 using autofill_helper::PROFILE_HOMER; 35 using autofill_helper::PROFILE_HOMER;
39 using autofill_helper::PROFILE_MARION; 36 using autofill_helper::PROFILE_MARION;
40 using autofill_helper::PROFILE_NULL; 37 using autofill_helper::PROFILE_NULL;
41 using autofill_helper::RemoveKey; 38 using autofill_helper::RemoveKey;
42 using autofill_helper::RemoveProfile; 39 using autofill_helper::RemoveProfile;
43 using autofill_helper::SetCreditCards; 40 using autofill_helper::SetCreditCards;
44 using autofill_helper::UpdateProfile; 41 using autofill_helper::UpdateProfile;
45 using bookmarks_helper::AddFolder; 42 using bookmarks_helper::AddFolder;
46 using bookmarks_helper::AddURL; 43 using bookmarks_helper::AddURL;
47 using bookmarks_helper::IndexedURL; 44 using bookmarks_helper::IndexedURL;
48 using bookmarks_helper::IndexedURLTitle; 45 using bookmarks_helper::IndexedURLTitle;
49 using sync_integration_test_util::AwaitCommitActivityCompletion;
50 46
51 class TwoClientAutofillSyncTest : public SyncTest { 47 class TwoClientAutofillSyncTest : public SyncTest {
52 public: 48 public:
53 TwoClientAutofillSyncTest() : SyncTest(TWO_CLIENT) { count = 0; } 49 TwoClientAutofillSyncTest() : SyncTest(TWO_CLIENT) { count = 0; }
54 ~TwoClientAutofillSyncTest() override {} 50 ~TwoClientAutofillSyncTest() override {}
55 51
56 bool TestUsesSelfNotifications() override { return false; } 52 bool TestUsesSelfNotifications() override { return false; }
57 53
58 // We do this so as to make a change that will trigger the autofill to sync. 54 // We do this so as to make a change that will trigger the autofill to sync.
59 // By default autofill does not sync unless there is some other change. 55 // By default autofill does not sync unless there is some other change.
60 void MakeABookmarkChange(int profile) { 56 void MakeABookmarkChange(int profile) {
61 ASSERT_TRUE( 57 ASSERT_TRUE(
62 AddURL(profile, IndexedURLTitle(count), GURL(IndexedURL(count)))); 58 AddURL(profile, IndexedURLTitle(count), GURL(IndexedURL(count))));
63 ++count; 59 ++count;
64 } 60 }
65 private: 61 private:
66 int count; 62 int count;
67 DISALLOW_COPY_AND_ASSIGN(TwoClientAutofillSyncTest); 63 DISALLOW_COPY_AND_ASSIGN(TwoClientAutofillSyncTest);
68 }; 64 };
69 65
70 IN_PROC_BROWSER_TEST_F(TwoClientAutofillSyncTest, WebDataServiceSanity) { 66 IN_PROC_BROWSER_TEST_F(TwoClientAutofillSyncTest, WebDataServiceSanity) {
71 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; 67 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
72 68
73 // Client0 adds a key. 69 // Client0 adds a key.
74 std::set<AutofillKey> keys; 70 std::set<AutofillKey> keys;
75 keys.insert(AutofillKey("name0", "value0")); 71 keys.insert(AutofillKey("name0", "value0"));
76 AddKeys(0, keys); 72 AddKeys(0, keys);
77 MakeABookmarkChange(0); 73 MakeABookmarkChange(0);
78 ASSERT_TRUE(AwaitKeysMatch(0, 1)); 74 ASSERT_TRUE(AutofillKeysChecker(0, 1).Wait());
79 ASSERT_EQ(1U, GetAllKeys(0).size()); 75 ASSERT_EQ(1U, GetAllKeys(0).size());
80 76
81 // Client1 adds a key. 77 // Client1 adds a key.
82 keys.clear(); 78 keys.clear();
83 keys.insert(AutofillKey("name1", "value1-0")); 79 keys.insert(AutofillKey("name1", "value1-0"));
84 AddKeys(1, keys); 80 AddKeys(1, keys);
85 MakeABookmarkChange(1); 81 MakeABookmarkChange(1);
86 ASSERT_TRUE(AwaitKeysMatch(0, 1)); 82 ASSERT_TRUE(AutofillKeysChecker(0, 1).Wait());
87 ASSERT_EQ(2U, GetAllKeys(0).size()); 83 ASSERT_EQ(2U, GetAllKeys(0).size());
88 84
89 // Client0 adds a key with the same name. 85 // Client0 adds a key with the same name.
90 keys.clear(); 86 keys.clear();
91 keys.insert(AutofillKey("name1", "value1-1")); 87 keys.insert(AutofillKey("name1", "value1-1"));
92 AddKeys(0, keys); 88 AddKeys(0, keys);
93 MakeABookmarkChange(0); 89 MakeABookmarkChange(0);
94 ASSERT_TRUE(AwaitKeysMatch(0, 1)); 90 ASSERT_TRUE(AutofillKeysChecker(0, 1).Wait());
95 ASSERT_EQ(3U, GetAllKeys(0).size()); 91 ASSERT_EQ(3U, GetAllKeys(0).size());
96 92
97 // Client1 removes a key. 93 // Client1 removes a key.
98 RemoveKey(1, AutofillKey("name1", "value1-0")); 94 RemoveKey(1, AutofillKey("name1", "value1-0"));
99 MakeABookmarkChange(1); 95 MakeABookmarkChange(1);
100 ASSERT_TRUE(AwaitKeysMatch(0, 1)); 96 ASSERT_TRUE(AutofillKeysChecker(0, 1).Wait());
101 ASSERT_EQ(2U, GetAllKeys(0).size()); 97 ASSERT_EQ(2U, GetAllKeys(0).size());
102 98
103 // Client0 removes the rest. 99 // Client0 removes the rest.
104 RemoveKey(0, AutofillKey("name0", "value0")); 100 RemoveKey(0, AutofillKey("name0", "value0"));
105 RemoveKey(0, AutofillKey("name1", "value1-1")); 101 RemoveKey(0, AutofillKey("name1", "value1-1"));
106 MakeABookmarkChange(0); 102 MakeABookmarkChange(0);
107 ASSERT_TRUE(AwaitKeysMatch(0, 1)); 103 ASSERT_TRUE(AutofillKeysChecker(0, 1).Wait());
108 ASSERT_EQ(0U, GetAllKeys(0).size()); 104 ASSERT_EQ(0U, GetAllKeys(0).size());
109 } 105 }
110 106
111 // TCM ID - 3678296. 107 // TCM ID - 3678296.
112 IN_PROC_BROWSER_TEST_F(TwoClientAutofillSyncTest, AddUnicodeProfile) { 108 IN_PROC_BROWSER_TEST_F(TwoClientAutofillSyncTest, AddUnicodeProfile) {
113 ASSERT_TRUE(SetupClients()) << "SetupClients() failed."; 109 ASSERT_TRUE(SetupClients()) << "SetupClients() failed.";
114 110
115 std::set<AutofillKey> keys; 111 std::set<AutofillKey> keys;
116 keys.insert(AutofillKey(base::WideToUTF16(L"Sigur R\u00F3s"), 112 keys.insert(AutofillKey(base::WideToUTF16(L"Sigur R\u00F3s"),
117 base::WideToUTF16(L"\u00C1g\u00E6tis byrjun"))); 113 base::WideToUTF16(L"\u00C1g\u00E6tis byrjun")));
118 AddKeys(0, keys); 114 AddKeys(0, keys);
119 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; 115 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
120 ASSERT_TRUE(AwaitKeysMatch(0, 1)); 116 ASSERT_TRUE(AutofillKeysChecker(0, 1).Wait());
121 } 117 }
122 118
123 IN_PROC_BROWSER_TEST_F(TwoClientAutofillSyncTest, 119 IN_PROC_BROWSER_TEST_F(TwoClientAutofillSyncTest,
124 AddDuplicateNamesToSameProfile) { 120 AddDuplicateNamesToSameProfile) {
125 ASSERT_TRUE(SetupClients()) << "SetupClients() failed."; 121 ASSERT_TRUE(SetupClients()) << "SetupClients() failed.";
126 122
127 std::set<AutofillKey> keys; 123 std::set<AutofillKey> keys;
128 keys.insert(AutofillKey("name0", "value0-0")); 124 keys.insert(AutofillKey("name0", "value0-0"));
129 keys.insert(AutofillKey("name0", "value0-1")); 125 keys.insert(AutofillKey("name0", "value0-1"));
130 keys.insert(AutofillKey("name1", "value1")); 126 keys.insert(AutofillKey("name1", "value1"));
131 AddKeys(0, keys); 127 AddKeys(0, keys);
132 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; 128 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
133 ASSERT_TRUE(AwaitKeysMatch(0, 1)); 129 ASSERT_TRUE(AutofillKeysChecker(0, 1).Wait());
134 ASSERT_EQ(2U, GetAllKeys(0).size()); 130 ASSERT_EQ(2U, GetAllKeys(0).size());
135 } 131 }
136 132
137 IN_PROC_BROWSER_TEST_F(TwoClientAutofillSyncTest, 133 IN_PROC_BROWSER_TEST_F(TwoClientAutofillSyncTest,
138 AddDuplicateNamesToDifferentProfiles) { 134 AddDuplicateNamesToDifferentProfiles) {
139 ASSERT_TRUE(SetupClients()) << "SetupClients() failed."; 135 ASSERT_TRUE(SetupClients()) << "SetupClients() failed.";
140 136
141 std::set<AutofillKey> keys0; 137 std::set<AutofillKey> keys0;
142 keys0.insert(AutofillKey("name0", "value0-0")); 138 keys0.insert(AutofillKey("name0", "value0-0"));
143 keys0.insert(AutofillKey("name1", "value1")); 139 keys0.insert(AutofillKey("name1", "value1"));
144 AddKeys(0, keys0); 140 AddKeys(0, keys0);
145 141
146 std::set<AutofillKey> keys1; 142 std::set<AutofillKey> keys1;
147 keys1.insert(AutofillKey("name0", "value0-1")); 143 keys1.insert(AutofillKey("name0", "value0-1"));
148 keys1.insert(AutofillKey("name2", "value2")); 144 keys1.insert(AutofillKey("name2", "value2"));
149 keys1.insert(AutofillKey("name3", "value3")); 145 keys1.insert(AutofillKey("name3", "value3"));
150 AddKeys(1, keys1); 146 AddKeys(1, keys1);
151 147
152 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; 148 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
153 ASSERT_TRUE(AwaitKeysMatch(0, 1)); 149 ASSERT_TRUE(AutofillKeysChecker(0, 1).Wait());
154 ASSERT_EQ(5U, GetAllKeys(0).size()); 150 ASSERT_EQ(5U, GetAllKeys(0).size());
155 } 151 }
156 152
157 IN_PROC_BROWSER_TEST_F(TwoClientAutofillSyncTest, 153 IN_PROC_BROWSER_TEST_F(TwoClientAutofillSyncTest,
158 PersonalDataManagerSanity) { 154 PersonalDataManagerSanity) {
159 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; 155 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
160 156
161 // Client0 adds a profile. 157 // Client0 adds a profile.
162 AddProfile(0, CreateAutofillProfile(PROFILE_HOMER)); 158 AddProfile(0, CreateAutofillProfile(PROFILE_HOMER));
163 MakeABookmarkChange(0); 159 MakeABookmarkChange(0);
164 ASSERT_TRUE(AwaitProfilesMatch(0, 1)); 160 ASSERT_TRUE(AutofillProfileChecker(0, 1).Wait());
165 ASSERT_EQ(1U, GetAllAutoFillProfiles(0).size()); 161 ASSERT_EQ(1U, GetAllAutoFillProfiles(0).size());
166 162
167 // Client1 adds a profile. 163 // Client1 adds a profile.
168 AddProfile(1, CreateAutofillProfile(PROFILE_MARION)); 164 AddProfile(1, CreateAutofillProfile(PROFILE_MARION));
169 MakeABookmarkChange(1); 165 MakeABookmarkChange(1);
170 ASSERT_TRUE(AwaitProfilesMatch(0, 1)); 166 ASSERT_TRUE(AutofillProfileChecker(0, 1).Wait());
171 ASSERT_EQ(2U, GetAllAutoFillProfiles(0).size()); 167 ASSERT_EQ(2U, GetAllAutoFillProfiles(0).size());
172 168
173 // Client0 adds the same profile. 169 // Client0 adds the same profile.
174 AddProfile(0, CreateAutofillProfile(PROFILE_MARION)); 170 AddProfile(0, CreateAutofillProfile(PROFILE_MARION));
175 MakeABookmarkChange(0); 171 MakeABookmarkChange(0);
176 ASSERT_TRUE(AwaitProfilesMatch(0, 1)); 172 ASSERT_TRUE(AutofillProfileChecker(0, 1).Wait());
177 ASSERT_EQ(2U, GetAllAutoFillProfiles(0).size()); 173 ASSERT_EQ(2U, GetAllAutoFillProfiles(0).size());
178 174
179 // Client1 removes a profile. 175 // Client1 removes a profile.
180 RemoveProfile(1, GetAllAutoFillProfiles(1)[0]->guid()); 176 RemoveProfile(1, GetAllAutoFillProfiles(1)[0]->guid());
181 MakeABookmarkChange(1); 177 MakeABookmarkChange(1);
182 ASSERT_TRUE(AwaitProfilesMatch(0, 1)); 178 ASSERT_TRUE(AutofillProfileChecker(0, 1).Wait());
183 ASSERT_EQ(1U, GetAllAutoFillProfiles(0).size()); 179 ASSERT_EQ(1U, GetAllAutoFillProfiles(0).size());
184 180
185 // Client0 updates a profile. 181 // Client0 updates a profile.
186 UpdateProfile(0, 182 UpdateProfile(0,
187 GetAllAutoFillProfiles(0)[0]->guid(), 183 GetAllAutoFillProfiles(0)[0]->guid(),
188 AutofillType(autofill::NAME_FIRST), 184 AutofillType(autofill::NAME_FIRST),
189 base::ASCIIToUTF16("Bart")); 185 base::ASCIIToUTF16("Bart"));
190 MakeABookmarkChange(0); 186 MakeABookmarkChange(0);
191 ASSERT_TRUE(AwaitProfilesMatch(0, 1)); 187 ASSERT_TRUE(AutofillProfileChecker(0, 1).Wait());
192 ASSERT_EQ(1U, GetAllAutoFillProfiles(0).size()); 188 ASSERT_EQ(1U, GetAllAutoFillProfiles(0).size());
193 189
194 // Client1 removes remaining profile. 190 // Client1 removes remaining profile.
195 RemoveProfile(1, GetAllAutoFillProfiles(1)[0]->guid()); 191 RemoveProfile(1, GetAllAutoFillProfiles(1)[0]->guid());
196 MakeABookmarkChange(1); 192 MakeABookmarkChange(1);
197 ASSERT_TRUE(AwaitProfilesMatch(0, 1)); 193 ASSERT_TRUE(AutofillProfileChecker(0, 1).Wait());
198 ASSERT_EQ(0U, GetAllAutoFillProfiles(0).size()); 194 ASSERT_EQ(0U, GetAllAutoFillProfiles(0).size());
199 } 195 }
200 196
201 // TCM ID - 7261786. 197 // TCM ID - 7261786.
202 IN_PROC_BROWSER_TEST_F(TwoClientAutofillSyncTest, AddDuplicateProfiles) { 198 IN_PROC_BROWSER_TEST_F(TwoClientAutofillSyncTest, AddDuplicateProfiles) {
203 ASSERT_TRUE(SetupClients()) << "SetupClients() failed."; 199 ASSERT_TRUE(SetupClients()) << "SetupClients() failed.";
204 200
205 AddProfile(0, CreateAutofillProfile(PROFILE_HOMER)); 201 AddProfile(0, CreateAutofillProfile(PROFILE_HOMER));
206 AddProfile(0, CreateAutofillProfile(PROFILE_HOMER)); 202 AddProfile(0, CreateAutofillProfile(PROFILE_HOMER));
207 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; 203 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
208 ASSERT_TRUE(AwaitProfilesMatch(0, 1)); 204 ASSERT_TRUE(AutofillProfileChecker(0, 1).Wait());
209 ASSERT_EQ(1U, GetAllAutoFillProfiles(0).size()); 205 ASSERT_EQ(1U, GetAllAutoFillProfiles(0).size());
210 } 206 }
211 207
212 // TCM ID - 3636294. 208 // TCM ID - 3636294.
213 IN_PROC_BROWSER_TEST_F(TwoClientAutofillSyncTest, SameProfileWithConflict) { 209 IN_PROC_BROWSER_TEST_F(TwoClientAutofillSyncTest, SameProfileWithConflict) {
214 ASSERT_TRUE(SetupClients()) << "SetupClients() failed."; 210 ASSERT_TRUE(SetupClients()) << "SetupClients() failed.";
215 211
216 AutofillProfile profile0 = CreateAutofillProfile(PROFILE_HOMER); 212 AutofillProfile profile0 = CreateAutofillProfile(PROFILE_HOMER);
217 AutofillProfile profile1 = CreateAutofillProfile(PROFILE_HOMER); 213 AutofillProfile profile1 = CreateAutofillProfile(PROFILE_HOMER);
218 profile1.SetRawInfo(autofill::PHONE_HOME_WHOLE_NUMBER, 214 profile1.SetRawInfo(autofill::PHONE_HOME_WHOLE_NUMBER,
219 base::ASCIIToUTF16("1234567890")); 215 base::ASCIIToUTF16("1234567890"));
220 216
221 AddProfile(0, profile0); 217 AddProfile(0, profile0);
222 AddProfile(1, profile1); 218 AddProfile(1, profile1);
223 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; 219 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
224 ASSERT_TRUE(AwaitProfilesMatch(0, 1)); 220 ASSERT_TRUE(AutofillProfileChecker(0, 1).Wait());
225 ASSERT_EQ(1U, GetAllAutoFillProfiles(0).size()); 221 ASSERT_EQ(1U, GetAllAutoFillProfiles(0).size());
226 } 222 }
227 223
228 // TCM ID - 3626291. 224 // TCM ID - 3626291.
229 IN_PROC_BROWSER_TEST_F(TwoClientAutofillSyncTest, AddEmptyProfile) { 225 IN_PROC_BROWSER_TEST_F(TwoClientAutofillSyncTest, AddEmptyProfile) {
230 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; 226 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
231 227
232 AddProfile(0, CreateAutofillProfile(PROFILE_NULL)); 228 AddProfile(0, CreateAutofillProfile(PROFILE_NULL));
233 ASSERT_TRUE(AwaitProfilesMatch(0, 1)); 229 ASSERT_TRUE(AutofillProfileChecker(0, 1).Wait());
234 ASSERT_EQ(0U, GetAllAutoFillProfiles(0).size()); 230 ASSERT_EQ(0U, GetAllAutoFillProfiles(0).size());
235 } 231 }
236 232
237 // TCM ID - 3616283. 233 // TCM ID - 3616283.
238 IN_PROC_BROWSER_TEST_F(TwoClientAutofillSyncTest, AddProfile) { 234 IN_PROC_BROWSER_TEST_F(TwoClientAutofillSyncTest, AddProfile) {
239 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; 235 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
240 236
241 AddProfile(0, CreateAutofillProfile(PROFILE_HOMER)); 237 AddProfile(0, CreateAutofillProfile(PROFILE_HOMER));
242 MakeABookmarkChange(0); 238 MakeABookmarkChange(0);
243 ASSERT_TRUE(AwaitProfilesMatch(0, 1)); 239 ASSERT_TRUE(AutofillProfileChecker(0, 1).Wait());
244 ASSERT_EQ(1U, GetAllAutoFillProfiles(0).size()); 240 ASSERT_EQ(1U, GetAllAutoFillProfiles(0).size());
245 } 241 }
246 242
247 // TCM ID - 3632260. 243 // TCM ID - 3632260.
248 IN_PROC_BROWSER_TEST_F(TwoClientAutofillSyncTest, AddMultipleProfiles) { 244 IN_PROC_BROWSER_TEST_F(TwoClientAutofillSyncTest, AddMultipleProfiles) {
249 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; 245 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
250 246
251 AddProfile(0, CreateAutofillProfile(PROFILE_HOMER)); 247 AddProfile(0, CreateAutofillProfile(PROFILE_HOMER));
252 AddProfile(0, CreateAutofillProfile(PROFILE_MARION)); 248 AddProfile(0, CreateAutofillProfile(PROFILE_MARION));
253 AddProfile(0, CreateAutofillProfile(PROFILE_FRASIER)); 249 AddProfile(0, CreateAutofillProfile(PROFILE_FRASIER));
254 MakeABookmarkChange(0); 250 MakeABookmarkChange(0);
255 ASSERT_TRUE(AwaitProfilesMatch(0, 1)); 251 ASSERT_TRUE(AutofillProfileChecker(0, 1).Wait());
256 ASSERT_EQ(3U, GetAllAutoFillProfiles(0).size()); 252 ASSERT_EQ(3U, GetAllAutoFillProfiles(0).size());
257 } 253 }
258 254
259 // TCM ID - 3602257. 255 // TCM ID - 3602257.
260 IN_PROC_BROWSER_TEST_F(TwoClientAutofillSyncTest, DeleteProfile) { 256 IN_PROC_BROWSER_TEST_F(TwoClientAutofillSyncTest, DeleteProfile) {
261 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; 257 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
262 258
263 AddProfile(0, CreateAutofillProfile(PROFILE_HOMER)); 259 AddProfile(0, CreateAutofillProfile(PROFILE_HOMER));
264 MakeABookmarkChange(0); 260 MakeABookmarkChange(0);
265 ASSERT_TRUE(AwaitProfilesMatch(0, 1)); 261 ASSERT_TRUE(AutofillProfileChecker(0, 1).Wait());
266 ASSERT_EQ(1U, GetAllAutoFillProfiles(0).size()); 262 ASSERT_EQ(1U, GetAllAutoFillProfiles(0).size());
267 263
268 RemoveProfile(1, GetAllAutoFillProfiles(1)[0]->guid()); 264 RemoveProfile(1, GetAllAutoFillProfiles(1)[0]->guid());
269 MakeABookmarkChange(1); 265 MakeABookmarkChange(1);
270 ASSERT_TRUE(AwaitProfilesMatch(0, 1)); 266 ASSERT_TRUE(AutofillProfileChecker(0, 1).Wait());
271 ASSERT_EQ(0U, GetAllAutoFillProfiles(0).size()); 267 ASSERT_EQ(0U, GetAllAutoFillProfiles(0).size());
272 } 268 }
273 269
274 // TCM ID - 3627300. 270 // TCM ID - 3627300.
275 IN_PROC_BROWSER_TEST_F(TwoClientAutofillSyncTest, MergeProfiles) { 271 IN_PROC_BROWSER_TEST_F(TwoClientAutofillSyncTest, MergeProfiles) {
276 ASSERT_TRUE(SetupClients()) << "SetupClients() failed."; 272 ASSERT_TRUE(SetupClients()) << "SetupClients() failed.";
277 273
278 AddProfile(0, CreateAutofillProfile(PROFILE_HOMER)); 274 AddProfile(0, CreateAutofillProfile(PROFILE_HOMER));
279 AddProfile(1, CreateAutofillProfile(PROFILE_MARION)); 275 AddProfile(1, CreateAutofillProfile(PROFILE_MARION));
280 AddProfile(1, CreateAutofillProfile(PROFILE_FRASIER)); 276 AddProfile(1, CreateAutofillProfile(PROFILE_FRASIER));
281 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; 277 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
282 ASSERT_TRUE(AwaitProfilesMatch(0, 1)); 278 ASSERT_TRUE(AutofillProfileChecker(0, 1).Wait());
283 ASSERT_EQ(3U, GetAllAutoFillProfiles(0).size()); 279 ASSERT_EQ(3U, GetAllAutoFillProfiles(0).size());
284 } 280 }
285 281
286 // TCM ID - 3665264. 282 // TCM ID - 3665264.
287 IN_PROC_BROWSER_TEST_F(TwoClientAutofillSyncTest, UpdateFields) { 283 IN_PROC_BROWSER_TEST_F(TwoClientAutofillSyncTest, UpdateFields) {
288 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; 284 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
289 285
290 AddProfile(0, CreateAutofillProfile(PROFILE_HOMER)); 286 AddProfile(0, CreateAutofillProfile(PROFILE_HOMER));
291 MakeABookmarkChange(0); 287 MakeABookmarkChange(0);
292 ASSERT_TRUE(AwaitProfilesMatch(0, 1)); 288 ASSERT_TRUE(AutofillProfileChecker(0, 1).Wait());
293 ASSERT_EQ(1U, GetAllAutoFillProfiles(0).size()); 289 ASSERT_EQ(1U, GetAllAutoFillProfiles(0).size());
294 290
295 UpdateProfile(0, 291 UpdateProfile(0,
296 GetAllAutoFillProfiles(0)[0]->guid(), 292 GetAllAutoFillProfiles(0)[0]->guid(),
297 AutofillType(autofill::NAME_FIRST), 293 AutofillType(autofill::NAME_FIRST),
298 base::ASCIIToUTF16("Lisa")); 294 base::ASCIIToUTF16("Lisa"));
299 UpdateProfile(0, 295 UpdateProfile(0,
300 GetAllAutoFillProfiles(0)[0]->guid(), 296 GetAllAutoFillProfiles(0)[0]->guid(),
301 AutofillType(autofill::EMAIL_ADDRESS), 297 AutofillType(autofill::EMAIL_ADDRESS),
302 base::ASCIIToUTF16("grrrl@TV.com")); 298 base::ASCIIToUTF16("grrrl@TV.com"));
303 MakeABookmarkChange(0); 299 MakeABookmarkChange(0);
304 ASSERT_TRUE(AwaitProfilesMatch(0, 1)); 300 ASSERT_TRUE(AutofillProfileChecker(0, 1).Wait());
305 ASSERT_EQ(1U, GetAllAutoFillProfiles(0).size()); 301 ASSERT_EQ(1U, GetAllAutoFillProfiles(0).size());
306 } 302 }
307 303
308 // TCM ID - 3628299. 304 // TCM ID - 3628299.
309 IN_PROC_BROWSER_TEST_F(TwoClientAutofillSyncTest, ConflictingFields) { 305 IN_PROC_BROWSER_TEST_F(TwoClientAutofillSyncTest, ConflictingFields) {
310 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; 306 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
311 307
312 AddProfile(0, CreateAutofillProfile(PROFILE_HOMER)); 308 AddProfile(0, CreateAutofillProfile(PROFILE_HOMER));
313 MakeABookmarkChange(0); 309 MakeABookmarkChange(0);
314 ASSERT_TRUE(AwaitProfilesMatch(0, 1)); 310 ASSERT_TRUE(AutofillProfileChecker(0, 1).Wait());
315 ASSERT_EQ(1U, GetAllAutoFillProfiles(0).size()); 311 ASSERT_EQ(1U, GetAllAutoFillProfiles(0).size());
316 UpdateProfile(0, 312 UpdateProfile(0,
317 GetAllAutoFillProfiles(0)[0]->guid(), 313 GetAllAutoFillProfiles(0)[0]->guid(),
318 AutofillType(autofill::NAME_FIRST), 314 AutofillType(autofill::NAME_FIRST),
319 base::ASCIIToUTF16("Lisa")); 315 base::ASCIIToUTF16("Lisa"));
320 MakeABookmarkChange(0); 316 MakeABookmarkChange(0);
321 UpdateProfile(1, 317 UpdateProfile(1,
322 GetAllAutoFillProfiles(1)[0]->guid(), 318 GetAllAutoFillProfiles(1)[0]->guid(),
323 AutofillType(autofill::NAME_FIRST), 319 AutofillType(autofill::NAME_FIRST),
324 base::ASCIIToUTF16("Bart")); 320 base::ASCIIToUTF16("Bart"));
325 MakeABookmarkChange(1); 321 MakeABookmarkChange(1);
326 ASSERT_TRUE(AwaitProfilesMatch(0, 1)); 322 ASSERT_TRUE(AutofillProfileChecker(0, 1).Wait());
327 ASSERT_EQ(1U, GetAllAutoFillProfiles(0).size()); 323 ASSERT_EQ(1U, GetAllAutoFillProfiles(0).size());
328 } 324 }
329 325
330 // TCM ID - 3608295. 326 // TCM ID - 3608295.
331 IN_PROC_BROWSER_TEST_F(TwoClientAutofillSyncTest, MaxLength) { 327 IN_PROC_BROWSER_TEST_F(TwoClientAutofillSyncTest, MaxLength) {
332 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; 328 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
333 329
334 AddProfile(0, CreateAutofillProfile(PROFILE_HOMER)); 330 AddProfile(0, CreateAutofillProfile(PROFILE_HOMER));
335 MakeABookmarkChange(0); 331 MakeABookmarkChange(0);
336 ASSERT_TRUE(AwaitProfilesMatch(0, 1)); 332 ASSERT_TRUE(AutofillProfileChecker(0, 1).Wait());
337 ASSERT_EQ(1U, GetAllAutoFillProfiles(0).size()); 333 ASSERT_EQ(1U, GetAllAutoFillProfiles(0).size());
338 334
339 base::string16 max_length_string(AutofillTable::kMaxDataLength, '.'); 335 base::string16 max_length_string(AutofillTable::kMaxDataLength, '.');
340 UpdateProfile(0, 336 UpdateProfile(0,
341 GetAllAutoFillProfiles(0)[0]->guid(), 337 GetAllAutoFillProfiles(0)[0]->guid(),
342 AutofillType(autofill::NAME_FULL), 338 AutofillType(autofill::NAME_FULL),
343 max_length_string); 339 max_length_string);
344 UpdateProfile(0, 340 UpdateProfile(0,
345 GetAllAutoFillProfiles(0)[0]->guid(), 341 GetAllAutoFillProfiles(0)[0]->guid(),
346 AutofillType(autofill::EMAIL_ADDRESS), 342 AutofillType(autofill::EMAIL_ADDRESS),
347 max_length_string); 343 max_length_string);
348 UpdateProfile(0, 344 UpdateProfile(0,
349 GetAllAutoFillProfiles(0)[0]->guid(), 345 GetAllAutoFillProfiles(0)[0]->guid(),
350 AutofillType(autofill::ADDRESS_HOME_LINE1), 346 AutofillType(autofill::ADDRESS_HOME_LINE1),
351 max_length_string); 347 max_length_string);
352 348
353 MakeABookmarkChange(0); 349 MakeABookmarkChange(0);
354 ASSERT_TRUE(AwaitProfilesMatch(0, 1)); 350 ASSERT_TRUE(AutofillProfileChecker(0, 1).Wait());
355 } 351 }
356 352
357 IN_PROC_BROWSER_TEST_F(TwoClientAutofillSyncTest, ExceedsMaxLength) { 353 IN_PROC_BROWSER_TEST_F(TwoClientAutofillSyncTest, ExceedsMaxLength) {
358 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; 354 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
359 355
360 AddProfile(0, CreateAutofillProfile(PROFILE_HOMER)); 356 AddProfile(0, CreateAutofillProfile(PROFILE_HOMER));
361 MakeABookmarkChange(0); 357 MakeABookmarkChange(0);
362 ASSERT_TRUE(AwaitProfilesMatch(0, 1)); 358 ASSERT_TRUE(AutofillProfileChecker(0, 1).Wait());
363 ASSERT_EQ(1U, GetAllAutoFillProfiles(0).size()); 359 ASSERT_EQ(1U, GetAllAutoFillProfiles(0).size());
364 360
365 base::string16 exceeds_max_length_string( 361 base::string16 exceeds_max_length_string(
366 AutofillTable::kMaxDataLength + 1, '.'); 362 AutofillTable::kMaxDataLength + 1, '.');
367 UpdateProfile(0, 363 UpdateProfile(0,
368 GetAllAutoFillProfiles(0)[0]->guid(), 364 GetAllAutoFillProfiles(0)[0]->guid(),
369 AutofillType(autofill::NAME_FIRST), 365 AutofillType(autofill::NAME_FIRST),
370 exceeds_max_length_string); 366 exceeds_max_length_string);
371 UpdateProfile(0, 367 UpdateProfile(0,
372 GetAllAutoFillProfiles(0)[0]->guid(), 368 GetAllAutoFillProfiles(0)[0]->guid(),
373 AutofillType(autofill::NAME_LAST), 369 AutofillType(autofill::NAME_LAST),
374 exceeds_max_length_string); 370 exceeds_max_length_string);
375 UpdateProfile(0, 371 UpdateProfile(0,
376 GetAllAutoFillProfiles(0)[0]->guid(), 372 GetAllAutoFillProfiles(0)[0]->guid(),
377 AutofillType(autofill::EMAIL_ADDRESS), 373 AutofillType(autofill::EMAIL_ADDRESS),
378 exceeds_max_length_string); 374 exceeds_max_length_string);
379 UpdateProfile(0, 375 UpdateProfile(0,
380 GetAllAutoFillProfiles(0)[0]->guid(), 376 GetAllAutoFillProfiles(0)[0]->guid(),
381 AutofillType(autofill::ADDRESS_HOME_LINE1), 377 AutofillType(autofill::ADDRESS_HOME_LINE1),
382 exceeds_max_length_string); 378 exceeds_max_length_string);
383 379
384 MakeABookmarkChange(0); 380 MakeABookmarkChange(0);
385 ASSERT_TRUE(bookmarks_helper::AwaitAllModelsMatch()); 381 ASSERT_TRUE(BookmarksMatchChecker().Wait());
386 EXPECT_FALSE(ProfilesMatch(0, 1)); 382 EXPECT_FALSE(ProfilesMatch(0, 1));
387 } 383 }
388 384
389 // Test credit cards don't sync. 385 // Test credit cards don't sync.
390 IN_PROC_BROWSER_TEST_F(TwoClientAutofillSyncTest, NoCreditCardSync) { 386 IN_PROC_BROWSER_TEST_F(TwoClientAutofillSyncTest, NoCreditCardSync) {
391 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; 387 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
392 388
393 AddProfile(0, CreateAutofillProfile(PROFILE_HOMER)); 389 AddProfile(0, CreateAutofillProfile(PROFILE_HOMER));
394 390
395 CreditCard card; 391 CreditCard card;
396 card.SetRawInfo(autofill::CREDIT_CARD_NUMBER, 392 card.SetRawInfo(autofill::CREDIT_CARD_NUMBER,
397 base::ASCIIToUTF16("6011111111111117")); 393 base::ASCIIToUTF16("6011111111111117"));
398 std::vector<CreditCard> credit_cards; 394 std::vector<CreditCard> credit_cards;
399 credit_cards.push_back(card); 395 credit_cards.push_back(card);
400 SetCreditCards(0, &credit_cards); 396 SetCreditCards(0, &credit_cards);
401 397
402 MakeABookmarkChange(0); 398 MakeABookmarkChange(0);
403 ASSERT_TRUE(AwaitProfilesMatch(0, 1)); 399 ASSERT_TRUE(AutofillProfileChecker(0, 1).Wait());
404 ASSERT_EQ(1U, GetAllAutoFillProfiles(0).size()); 400 ASSERT_EQ(1U, GetAllAutoFillProfiles(0).size());
405 401
406 PersonalDataManager* pdm = GetPersonalDataManager(1); 402 PersonalDataManager* pdm = GetPersonalDataManager(1);
407 ASSERT_EQ(0U, pdm->GetCreditCards().size()); 403 ASSERT_EQ(0U, pdm->GetCreditCards().size());
408 } 404 }
409 405
410 IN_PROC_BROWSER_TEST_F(TwoClientAutofillSyncTest, 406 IN_PROC_BROWSER_TEST_F(TwoClientAutofillSyncTest,
411 E2E_ONLY(TwoClientsAddAutofillProfiles)) { 407 E2E_ONLY(TwoClientsAddAutofillProfiles)) {
412 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; 408 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
413 409
414 // All profiles should sync same autofill profiles. 410 // All profiles should sync same autofill profiles.
415 ASSERT_TRUE(AwaitProfilesMatch(0, 1)) << 411 ASSERT_TRUE(AutofillProfileChecker(0, 1).Wait())
416 "Initial autofill profiles did not match for all profiles."; 412 << "Initial autofill profiles did not match for all profiles.";
417 413
418 // For clean profiles, the autofill profiles count should be zero. We are not 414 // For clean profiles, the autofill profiles count should be zero. We are not
419 // enforcing this, we only check that the final count is equal to initial 415 // enforcing this, we only check that the final count is equal to initial
420 // count plus new autofill profiles count. 416 // count plus new autofill profiles count.
421 int init_autofill_profiles_count = GetProfileCount(0); 417 int init_autofill_profiles_count = GetProfileCount(0);
422 418
423 // Add a new autofill profile to the first client. 419 // Add a new autofill profile to the first client.
424 AddProfile(0, CreateUniqueAutofillProfile()); 420 AddProfile(0, CreateUniqueAutofillProfile());
425 421
426 ASSERT_TRUE(AwaitProfilesMatch(0, 1)); 422 ASSERT_TRUE(AutofillProfileChecker(0, 1).Wait());
427 423
428 // Check that the total number of autofill profiles is as expected 424 // Check that the total number of autofill profiles is as expected
429 for (int i = 0; i < num_clients(); ++i) { 425 for (int i = 0; i < num_clients(); ++i) {
430 ASSERT_EQ(GetProfileCount(i), init_autofill_profiles_count + 1) << 426 ASSERT_EQ(GetProfileCount(i), init_autofill_profiles_count + 1) <<
431 "Total autofill profile count is wrong."; 427 "Total autofill profile count is wrong.";
432 } 428 }
433 } 429 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698