OLD | NEW |
---|---|
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 <vector> | 5 #include <vector> |
6 | 6 |
7 #include "app/l10n_util.h" | 7 #include "app/l10n_util.h" |
8 #include "base/ref_counted.h" | 8 #include "base/ref_counted.h" |
9 #include "base/scoped_ptr.h" | 9 #include "base/scoped_ptr.h" |
10 #include "base/scoped_vector.h" | 10 #include "base/scoped_vector.h" |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
80 } | 80 } |
81 | 81 |
82 void ClearAutoFillProfiles() { | 82 void ClearAutoFillProfiles() { |
83 web_profiles_.reset(); | 83 web_profiles_.reset(); |
84 } | 84 } |
85 | 85 |
86 void ClearCreditCards() { | 86 void ClearCreditCards() { |
87 credit_cards_.reset(); | 87 credit_cards_.reset(); |
88 } | 88 } |
89 | 89 |
90 void CreateTestCreditCardsYearMonth() { | |
Ilya Sherman
2011/01/10 20:08:48
As long as you're unrolling the loops, it would be
honten.org
2011/01/25 05:19:24
Done.
| |
91 ClearCreditCards(); | |
92 // Create four credit cards with year month combination as following, | |
93 // 1. year empty, month empty | |
94 CreditCard* credit_card = new CreditCard; | |
95 autofill_test::SetCreditCardInfo(credit_card, "Miku0", "Miku Hatsune", | |
96 "4234567890654321", // Visa | |
97 "", ""); | |
98 credit_card->set_guid("00000000-0000-0000-0000-000000000007"); | |
99 credit_cards_->push_back(credit_card); | |
100 // 2. year empty, month non-empty | |
101 credit_card = new CreditCard; | |
102 autofill_test::SetCreditCardInfo(credit_card, "Miku1", "Miku Hatsune", | |
103 "4234567890654321", // Visa | |
104 "04", ""); | |
105 credit_card->set_guid("00000000-0000-0000-0000-000000000008"); | |
106 credit_cards_->push_back(credit_card); | |
107 // 3. year non-empty, month empty | |
108 credit_card = new CreditCard; | |
109 autofill_test::SetCreditCardInfo(credit_card, "Miku2", "Miku Hatsune", | |
110 "4234567890654321", // Visa | |
111 "", "2012"); | |
112 credit_card->set_guid("00000000-0000-0000-0000-000000000009"); | |
113 credit_cards_->push_back(credit_card); | |
114 // 4. both non-empty | |
115 credit_card = new CreditCard; | |
116 autofill_test::SetCreditCardInfo(credit_card, "Miku3", "Miku Hatsune", | |
117 "4234567890654321", // Visa | |
118 "04", "2012"); | |
119 credit_card->set_guid("00000000-0000-0000-0000-000000000010"); | |
120 credit_cards_->push_back(credit_card); | |
121 } | |
122 | |
90 private: | 123 private: |
91 void CreateTestAutoFillProfiles(ScopedVector<AutoFillProfile>* profiles) { | 124 void CreateTestAutoFillProfiles(ScopedVector<AutoFillProfile>* profiles) { |
92 AutoFillProfile* profile = new AutoFillProfile; | 125 AutoFillProfile* profile = new AutoFillProfile; |
93 autofill_test::SetProfileInfo(profile, "Home", "Elvis", "Aaron", | 126 autofill_test::SetProfileInfo(profile, "Home", "Elvis", "Aaron", |
94 "Presley", "theking@gmail.com", "RCA", | 127 "Presley", "theking@gmail.com", "RCA", |
95 "3734 Elvis Presley Blvd.", "Apt. 10", | 128 "3734 Elvis Presley Blvd.", "Apt. 10", |
96 "Memphis", "Tennessee", "38116", "USA", | 129 "Memphis", "Tennessee", "38116", "USA", |
97 "12345678901", ""); | 130 "12345678901", ""); |
98 profile->set_guid("00000000-0000-0000-0000-000000000001"); | 131 profile->set_guid("00000000-0000-0000-0000-000000000001"); |
99 profiles->push_back(profile); | 132 profiles->push_back(profile); |
100 profile = new AutoFillProfile; | 133 profile = new AutoFillProfile; |
101 autofill_test::SetProfileInfo(profile, "Work", "Charles", "Hardin", | 134 autofill_test::SetProfileInfo(profile, "Work", "Charles", "Hardin", |
102 "Holley", "buddy@gmail.com", "Decca", | 135 "Holley", "buddy@gmail.com", "Decca", |
103 "123 Apple St.", "unit 6", "Lubbock", | 136 "123 Apple St.", "unit 6", "Lubbock", |
104 "Texas", "79401", "USA", "23456789012", | 137 "Texas", "79401", "USA", "23456789012", |
105 ""); | 138 ""); |
106 profile->set_guid("00000000-0000-0000-0000-000000000002"); | 139 profile->set_guid("00000000-0000-0000-0000-000000000002"); |
107 profiles->push_back(profile); | 140 profiles->push_back(profile); |
108 profile = new AutoFillProfile; | 141 profile = new AutoFillProfile; |
109 autofill_test::SetProfileInfo(profile, "Empty", "", "", "", "", "", "", "", | 142 autofill_test::SetProfileInfo(profile, "Empty", "", "", "", "", "", "", "", |
110 "", "", "", "", "", ""); | 143 "", "", "", "", "", ""); |
111 profile->set_guid("00000000-0000-0000-0000-000000000003"); | 144 profile->set_guid("00000000-0000-0000-0000-000000000003"); |
112 profiles->push_back(profile); | 145 profiles->push_back(profile); |
113 } | 146 } |
114 | 147 |
115 void CreateTestCreditCards(ScopedVector<CreditCard>* credit_cards) { | 148 void CreateTestCreditCards(ScopedVector<CreditCard>* credit_cards) { |
116 CreditCard* credit_card = new CreditCard; | 149 CreditCard* credit_card = new CreditCard; |
117 autofill_test::SetCreditCardInfo(credit_card, "First", "Elvis Presley", | 150 autofill_test::SetCreditCardInfo(credit_card, "First", "Elvis Presley", |
118 "4234567890123456", // Visa | 151 "4234567890123456", // Visa |
119 "04", "2012"); | 152 "04", "2012"); |
Ilya Sherman
2011/01/10 20:08:48
nit: The indentation here was correct previously (
honten.org
2011/01/25 05:19:24
Done.
| |
120 credit_card->set_guid("00000000-0000-0000-0000-000000000004"); | 153 credit_card->set_guid("00000000-0000-0000-0000-000000000004"); |
121 credit_cards->push_back(credit_card); | 154 credit_cards->push_back(credit_card); |
122 credit_card = new CreditCard; | 155 credit_card = new CreditCard; |
123 autofill_test::SetCreditCardInfo(credit_card, "Second", "Buddy Holly", | 156 autofill_test::SetCreditCardInfo(credit_card, "Second", "Buddy Holly", |
124 "5187654321098765", // Mastercard | 157 "5187654321098765", // Mastercard |
125 "10", "2014"); | 158 "10", "2014"); |
126 credit_card->set_guid("00000000-0000-0000-0000-000000000005"); | 159 credit_card->set_guid("00000000-0000-0000-0000-000000000005"); |
127 credit_cards->push_back(credit_card); | 160 credit_cards->push_back(credit_card); |
128 credit_card = new CreditCard; | 161 credit_card = new CreditCard; |
129 autofill_test::SetCreditCardInfo(credit_card, "Empty", "", "", "", ""); | 162 autofill_test::SetCreditCardInfo(credit_card, "Empty", "", "", "", ""); |
130 credit_card->set_guid("00000000-0000-0000-0000-000000000006"); | 163 credit_card->set_guid("00000000-0000-0000-0000-000000000006"); |
131 credit_cards->push_back(credit_card); | 164 credit_cards->push_back(credit_card); |
132 } | 165 } |
133 | 166 |
134 DISALLOW_COPY_AND_ASSIGN(TestPersonalDataManager); | 167 DISALLOW_COPY_AND_ASSIGN(TestPersonalDataManager); |
135 }; | 168 }; |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
174 form->fields.push_back(field); | 207 form->fields.push_back(field); |
175 autofill_test::CreateTestFormField( | 208 autofill_test::CreateTestFormField( |
176 "Phone Number", "phonenumber", "", "text", &field); | 209 "Phone Number", "phonenumber", "", "text", &field); |
177 form->fields.push_back(field); | 210 form->fields.push_back(field); |
178 autofill_test::CreateTestFormField( | 211 autofill_test::CreateTestFormField( |
179 "Fax", "fax", "", "text", &field); | 212 "Fax", "fax", "", "text", &field); |
180 form->fields.push_back(field); | 213 form->fields.push_back(field); |
181 autofill_test::CreateTestFormField( | 214 autofill_test::CreateTestFormField( |
182 "Email", "email", "", "text", &field); | 215 "Email", "email", "", "text", &field); |
183 form->fields.push_back(field); | 216 form->fields.push_back(field); |
184 } | 217 autofill_test::CreateTestFormField( |
218 "Email", "email2", "", "email", &field); | |
219 form->fields.push_back(field); | |
220 autofill_test::CreateTestFormField( | |
221 "Phone Number", "phonenumber2", "", "tel", &field); | |
222 form->fields.push_back(field); | |
223 } | |
185 | 224 |
186 // Populates |form| with data corresponding to a simple credit card form. | 225 // Populates |form| with data corresponding to a simple credit card form. |
187 // Note that this actually appends fields to the form data, which can be useful | 226 // Note that this actually appends fields to the form data, which can be useful |
188 // for building up more complex test forms. | 227 // for building up more complex test forms. |
189 void CreateTestCreditCardFormData(FormData* form, bool is_https) { | 228 void CreateTestCreditCardFormData(FormData* form, |
229 bool is_https, | |
230 bool use_month_type) { | |
190 form->name = ASCIIToUTF16("MyForm"); | 231 form->name = ASCIIToUTF16("MyForm"); |
191 form->method = ASCIIToUTF16("POST"); | 232 form->method = ASCIIToUTF16("POST"); |
192 if (is_https) { | 233 if (is_https) { |
193 form->origin = GURL("https://myform.com/form.html"); | 234 form->origin = GURL("https://myform.com/form.html"); |
194 form->action = GURL("https://myform.com/submit.html"); | 235 form->action = GURL("https://myform.com/submit.html"); |
195 } else { | 236 } else { |
196 form->origin = GURL("http://myform.com/form.html"); | 237 form->origin = GURL("http://myform.com/form.html"); |
197 form->action = GURL("http://myform.com/submit.html"); | 238 form->action = GURL("http://myform.com/submit.html"); |
198 } | 239 } |
199 form->user_submitted = true; | 240 form->user_submitted = true; |
200 | 241 |
201 FormField field; | 242 FormField field; |
202 autofill_test::CreateTestFormField( | 243 autofill_test::CreateTestFormField( |
203 "Name on Card", "nameoncard", "", "text", &field); | 244 "Name on Card", "nameoncard", "", "text", &field); |
204 form->fields.push_back(field); | 245 form->fields.push_back(field); |
205 autofill_test::CreateTestFormField( | 246 autofill_test::CreateTestFormField( |
206 "Card Number", "cardnumber", "", "text", &field); | 247 "Card Number", "cardnumber", "", "text", &field); |
207 form->fields.push_back(field); | 248 form->fields.push_back(field); |
208 autofill_test::CreateTestFormField( | 249 if (use_month_type) { |
209 "Expiration Date", "ccmonth", "", "text", &field); | 250 autofill_test::CreateTestFormField( |
210 form->fields.push_back(field); | 251 "Expiration Date", "ccmonth", "", "month", &field); |
211 autofill_test::CreateTestFormField( | 252 form->fields.push_back(field); |
212 "", "ccyear", "", "text", &field); | 253 } else { |
213 form->fields.push_back(field); | 254 autofill_test::CreateTestFormField( |
255 "Expiration Date", "ccmonth", "", "text", &field); | |
256 form->fields.push_back(field); | |
257 autofill_test::CreateTestFormField( | |
258 "", "ccyear", "", "text", &field); | |
259 form->fields.push_back(field); | |
260 } | |
214 } | 261 } |
215 | 262 |
216 void ExpectSuggestions(int page_id, | 263 void ExpectSuggestions(int page_id, |
217 const std::vector<string16>& values, | 264 const std::vector<string16>& values, |
218 const std::vector<string16>& labels, | 265 const std::vector<string16>& labels, |
219 const std::vector<string16>& icons, | 266 const std::vector<string16>& icons, |
220 const std::vector<int>& unique_ids, | 267 const std::vector<int>& unique_ids, |
221 int expected_page_id, | 268 int expected_page_id, |
222 size_t expected_num_suggestions, | 269 size_t expected_num_suggestions, |
223 const string16 expected_values[], | 270 const string16 expected_values[], |
(...skipping 10 matching lines...) Expand all Loading... | |
234 EXPECT_EQ(expected_values[i], values[i]); | 281 EXPECT_EQ(expected_values[i], values[i]); |
235 EXPECT_EQ(expected_labels[i], labels[i]); | 282 EXPECT_EQ(expected_labels[i], labels[i]); |
236 EXPECT_EQ(expected_icons[i], icons[i]); | 283 EXPECT_EQ(expected_icons[i], icons[i]); |
237 EXPECT_EQ(expected_unique_ids[i], unique_ids[i]); | 284 EXPECT_EQ(expected_unique_ids[i], unique_ids[i]); |
238 } | 285 } |
239 } | 286 } |
240 | 287 |
241 // Verifies that the |filled_form| has been filled with the given data. | 288 // Verifies that the |filled_form| has been filled with the given data. |
242 // Verifies address fields if |has_address_fields| is true, and verifies | 289 // Verifies address fields if |has_address_fields| is true, and verifies |
243 // credit card fields if |has_credit_card_fields| is true. Verifies both if both | 290 // credit card fields if |has_credit_card_fields| is true. Verifies both if both |
244 // are true. | 291 // are true. |use_month_type| is used for credit card input month type. |
245 void ExpectFilledForm(int page_id, | 292 void ExpectFilledForm(int page_id, |
246 const FormData& filled_form, | 293 const FormData& filled_form, |
247 int expected_page_id, | 294 int expected_page_id, |
248 const char* first, | 295 const char* first, |
249 const char* middle, | 296 const char* middle, |
250 const char* last, | 297 const char* last, |
251 const char* address1, | 298 const char* address1, |
252 const char* address2, | 299 const char* address2, |
253 const char* city, | 300 const char* city, |
254 const char* state, | 301 const char* state, |
255 const char* postal_code, | 302 const char* postal_code, |
256 const char* country, | 303 const char* country, |
257 const char* phone, | 304 const char* phone, |
258 const char* fax, | 305 const char* fax, |
259 const char* email, | 306 const char* email, |
260 const char* name_on_card, | 307 const char* name_on_card, |
261 const char* card_number, | 308 const char* card_number, |
262 const char* expiration_month, | 309 const char* expiration_month, |
263 const char* expiration_year, | 310 const char* expiration_year, |
264 bool has_address_fields, | 311 bool has_address_fields, |
265 bool has_credit_card_fields) { | 312 bool has_credit_card_fields, |
313 bool use_month_type) { | |
266 // The number of fields in the address and credit card forms created above. | 314 // The number of fields in the address and credit card forms created above. |
267 const size_t kAddressFormSize = 12; | 315 const size_t kAddressFormSize = 14; |
268 const size_t kCreditCardFormSize = 4; | 316 const size_t kCreditCardFormSize = use_month_type ? 3 : 4; |
269 | 317 |
270 EXPECT_EQ(expected_page_id, page_id); | 318 EXPECT_EQ(expected_page_id, page_id); |
271 EXPECT_EQ(ASCIIToUTF16("MyForm"), filled_form.name); | 319 EXPECT_EQ(ASCIIToUTF16("MyForm"), filled_form.name); |
272 EXPECT_EQ(ASCIIToUTF16("POST"), filled_form.method); | 320 EXPECT_EQ(ASCIIToUTF16("POST"), filled_form.method); |
273 if (has_credit_card_fields) { | 321 if (has_credit_card_fields) { |
274 EXPECT_EQ(GURL("https://myform.com/form.html"), filled_form.origin); | 322 EXPECT_EQ(GURL("https://myform.com/form.html"), filled_form.origin); |
275 EXPECT_EQ(GURL("https://myform.com/submit.html"), filled_form.action); | 323 EXPECT_EQ(GURL("https://myform.com/submit.html"), filled_form.action); |
276 } else { | 324 } else { |
277 EXPECT_EQ(GURL("http://myform.com/form.html"), filled_form.origin); | 325 EXPECT_EQ(GURL("http://myform.com/form.html"), filled_form.origin); |
278 EXPECT_EQ(GURL("http://myform.com/submit.html"), filled_form.action); | 326 EXPECT_EQ(GURL("http://myform.com/submit.html"), filled_form.action); |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
317 EXPECT_TRUE(field.StrictlyEqualsHack(filled_form.fields[8])); | 365 EXPECT_TRUE(field.StrictlyEqualsHack(filled_form.fields[8])); |
318 autofill_test::CreateTestFormField( | 366 autofill_test::CreateTestFormField( |
319 "Phone Number", "phonenumber", phone, "text", &field); | 367 "Phone Number", "phonenumber", phone, "text", &field); |
320 EXPECT_TRUE(field.StrictlyEqualsHack(filled_form.fields[9])); | 368 EXPECT_TRUE(field.StrictlyEqualsHack(filled_form.fields[9])); |
321 autofill_test::CreateTestFormField( | 369 autofill_test::CreateTestFormField( |
322 "Fax", "fax", fax, "text", &field); | 370 "Fax", "fax", fax, "text", &field); |
323 EXPECT_TRUE(field.StrictlyEqualsHack(filled_form.fields[10])); | 371 EXPECT_TRUE(field.StrictlyEqualsHack(filled_form.fields[10])); |
324 autofill_test::CreateTestFormField( | 372 autofill_test::CreateTestFormField( |
325 "Email", "email", email, "text", &field); | 373 "Email", "email", email, "text", &field); |
326 EXPECT_TRUE(field.StrictlyEqualsHack(filled_form.fields[11])); | 374 EXPECT_TRUE(field.StrictlyEqualsHack(filled_form.fields[11])); |
327 } | 375 autofill_test::CreateTestFormField( |
376 "Email", "email2", email, "email", &field); | |
377 EXPECT_TRUE(field.StrictlyEqualsHack(filled_form.fields[12])); | |
378 autofill_test::CreateTestFormField( | |
379 "Phone Number", "phonenumber2", phone, "tel", &field); | |
380 EXPECT_TRUE(field.StrictlyEqualsHack(filled_form.fields[13])); | |
381 } | |
328 | 382 |
329 if (has_credit_card_fields) { | 383 if (has_credit_card_fields) { |
330 size_t offset = has_address_fields? kAddressFormSize : 0; | 384 size_t offset = has_address_fields? kAddressFormSize : 0; |
331 autofill_test::CreateTestFormField( | 385 autofill_test::CreateTestFormField( |
332 "Name on Card", "nameoncard", name_on_card, "text", &field); | 386 "Name on Card", "nameoncard", name_on_card, "text", &field); |
333 EXPECT_TRUE(field.StrictlyEqualsHack(filled_form.fields[offset + 0])); | 387 EXPECT_TRUE(field.StrictlyEqualsHack(filled_form.fields[offset + 0])); |
334 autofill_test::CreateTestFormField( | 388 autofill_test::CreateTestFormField( |
335 "Card Number", "cardnumber", card_number, "text", &field); | 389 "Card Number", "cardnumber", card_number, "text", &field); |
336 EXPECT_TRUE(field.StrictlyEqualsHack(filled_form.fields[offset + 1])); | 390 EXPECT_TRUE(field.StrictlyEqualsHack(filled_form.fields[offset + 1])); |
337 autofill_test::CreateTestFormField( | 391 if (use_month_type) { |
338 "Expiration Date", "ccmonth", expiration_month, "text", &field); | 392 std::string exp_year = expiration_year; |
339 EXPECT_TRUE(field.StrictlyEqualsHack(filled_form.fields[offset + 2])); | 393 std::string exp_month = expiration_month; |
340 autofill_test::CreateTestFormField( | 394 std::string date; |
341 "", "ccyear", expiration_year, "text", &field); | 395 if (!exp_year.empty() && !exp_month.empty()) |
342 EXPECT_TRUE(field.StrictlyEqualsHack(filled_form.fields[offset + 3])); | 396 date = exp_year + "-" + exp_month; |
397 autofill_test::CreateTestFormField("Expiration Date", "ccmonth", | |
398 date.c_str(), "month", &field); | |
Ilya Sherman
2011/01/10 20:08:48
nit: Please use the same style as elsewhere in thi
honten.org
2011/01/25 05:19:24
Done.
| |
399 EXPECT_TRUE(field.StrictlyEqualsHack(filled_form.fields[offset + 2])); | |
400 } else { | |
401 autofill_test::CreateTestFormField( | |
402 "Expiration Date", "ccmonth", expiration_month, "text", &field); | |
403 EXPECT_TRUE(field.StrictlyEqualsHack(filled_form.fields[offset + 2])); | |
404 autofill_test::CreateTestFormField( | |
405 "", "ccyear", expiration_year, "text", &field); | |
406 EXPECT_TRUE(field.StrictlyEqualsHack(filled_form.fields[offset + 3])); | |
407 } | |
343 } | 408 } |
344 } | 409 } |
345 | 410 |
346 void ExpectFilledAddressFormElvis(int page_id, | 411 void ExpectFilledAddressFormElvis(int page_id, |
347 const FormData& filled_form, | 412 const FormData& filled_form, |
348 int expected_page_id, | 413 int expected_page_id, |
349 bool has_credit_card_fields) { | 414 bool has_credit_card_fields) { |
350 ExpectFilledForm(page_id, filled_form, expected_page_id, "Elvis", "Aaron", | 415 ExpectFilledForm(page_id, filled_form, expected_page_id, "Elvis", "Aaron", |
351 "Presley", "3734 Elvis Presley Blvd.", "Apt. 10", "Memphis", | 416 "Presley", "3734 Elvis Presley Blvd.", "Apt. 10", "Memphis", |
352 "Tennessee", "38116", "USA", "12345678901", "", | 417 "Tennessee", "38116", "USA", "12345678901", "", |
353 "theking@gmail.com", "", "", "", "", true, | 418 "theking@gmail.com", "", "", "", "", true, |
354 has_credit_card_fields); | 419 has_credit_card_fields, false); |
355 } | 420 } |
356 | 421 |
357 void ExpectFilledCreditCardFormElvis(int page_id, | 422 void ExpectFilledCreditCardFormElvis(int page_id, |
358 const FormData& filled_form, | 423 const FormData& filled_form, |
359 int expected_page_id, | 424 int expected_page_id, |
360 bool has_address_fields) { | 425 bool has_address_fields) { |
361 ExpectFilledForm(page_id, filled_form, expected_page_id, | 426 ExpectFilledForm(page_id, filled_form, expected_page_id, |
362 "", "", "", "", "", "", "", "", "", "", "", "", | 427 "", "", "", "", "", "", "", "", "", "", "", "", |
363 "Elvis Presley", "4234567890123456", "04", "2012", | 428 "Elvis Presley", "4234567890123456", "04", "2012", |
364 has_address_fields, true); | 429 has_address_fields, true, false); |
430 } | |
431 | |
432 void ExpectFilledCreditCardYearMonthWithYearMonth(int page_id, | |
433 const FormData& filled_form, | |
434 int expected_page_id, | |
435 bool has_address_fields, | |
436 const char* year, | |
437 const char* month) { | |
438 ExpectFilledForm(page_id, filled_form, expected_page_id, | |
439 "", "", "", "", "", "", "", "", "", "", "", "", | |
440 "Miku Hatsune", "4234567890654321", month, year, | |
441 has_address_fields, true, true); | |
365 } | 442 } |
366 | 443 |
367 class TestAutoFillManager : public AutoFillManager { | 444 class TestAutoFillManager : public AutoFillManager { |
368 public: | 445 public: |
369 TestAutoFillManager(TabContents* tab_contents, | 446 TestAutoFillManager(TabContents* tab_contents, |
370 TestPersonalDataManager* personal_manager) | 447 TestPersonalDataManager* personal_manager) |
371 : AutoFillManager(tab_contents, personal_manager), | 448 : AutoFillManager(tab_contents, personal_manager), |
372 autofill_enabled_(true) { | 449 autofill_enabled_(true) { |
373 test_personal_data_ = personal_manager; | 450 test_personal_data_ = personal_manager; |
374 } | 451 } |
(...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
726 // Now clear the test profiles and try again -- we shouldn't return a warning. | 803 // Now clear the test profiles and try again -- we shouldn't return a warning. |
727 test_personal_data_->ClearAutoFillProfiles(); | 804 test_personal_data_->ClearAutoFillProfiles(); |
728 EXPECT_FALSE(autofill_manager_->GetAutoFillSuggestions(form, field)); | 805 EXPECT_FALSE(autofill_manager_->GetAutoFillSuggestions(form, field)); |
729 } | 806 } |
730 | 807 |
731 // Test that we return all credit card profile suggestions when all form fields | 808 // Test that we return all credit card profile suggestions when all form fields |
732 // are empty. | 809 // are empty. |
733 TEST_F(AutoFillManagerTest, GetCreditCardSuggestionsEmptyValue) { | 810 TEST_F(AutoFillManagerTest, GetCreditCardSuggestionsEmptyValue) { |
734 // Set up our form data. | 811 // Set up our form data. |
735 FormData form; | 812 FormData form; |
736 CreateTestCreditCardFormData(&form, true); | 813 CreateTestCreditCardFormData(&form, true, false); |
737 std::vector<FormData> forms(1, form); | 814 std::vector<FormData> forms(1, form); |
738 autofill_manager_->FormsSeen(forms); | 815 autofill_manager_->FormsSeen(forms); |
739 | 816 |
740 FormField field = form.fields[1]; | 817 FormField field = form.fields[1]; |
741 rvh()->ResetAutoFillState(kDefaultPageID); | 818 rvh()->ResetAutoFillState(kDefaultPageID); |
742 EXPECT_TRUE(autofill_manager_->GetAutoFillSuggestions(form, field)); | 819 EXPECT_TRUE(autofill_manager_->GetAutoFillSuggestions(form, field)); |
743 | 820 |
744 // No suggestions provided, so send an empty vector as the results. | 821 // No suggestions provided, so send an empty vector as the results. |
745 // This triggers the combined message send. | 822 // This triggers the combined message send. |
746 rvh()->AutocompleteSuggestionsReturned(std::vector<string16>()); | 823 rvh()->AutocompleteSuggestionsReturned(std::vector<string16>()); |
(...skipping 23 matching lines...) Expand all Loading... | |
770 ExpectSuggestions(page_id, values, labels, icons, unique_ids, | 847 ExpectSuggestions(page_id, values, labels, icons, unique_ids, |
771 kDefaultPageID, arraysize(expected_values), expected_values, | 848 kDefaultPageID, arraysize(expected_values), expected_values, |
772 expected_labels, expected_icons, expected_unique_ids); | 849 expected_labels, expected_icons, expected_unique_ids); |
773 } | 850 } |
774 | 851 |
775 // Test that we return only matching credit card profile suggestions when the | 852 // Test that we return only matching credit card profile suggestions when the |
776 // selected form field has been partially filled out. | 853 // selected form field has been partially filled out. |
777 TEST_F(AutoFillManagerTest, GetCreditCardSuggestionsMatchCharacter) { | 854 TEST_F(AutoFillManagerTest, GetCreditCardSuggestionsMatchCharacter) { |
778 // Set up our form data. | 855 // Set up our form data. |
779 FormData form; | 856 FormData form; |
780 CreateTestCreditCardFormData(&form, true); | 857 CreateTestCreditCardFormData(&form, true, false); |
781 std::vector<FormData> forms(1, form); | 858 std::vector<FormData> forms(1, form); |
782 autofill_manager_->FormsSeen(forms); | 859 autofill_manager_->FormsSeen(forms); |
783 | 860 |
784 FormField field; | 861 FormField field; |
785 autofill_test::CreateTestFormField( | 862 autofill_test::CreateTestFormField( |
786 "Card Number", "cardnumber", "4", "text", &field); | 863 "Card Number", "cardnumber", "4", "text", &field); |
787 rvh()->ResetAutoFillState(kDefaultPageID); | 864 rvh()->ResetAutoFillState(kDefaultPageID); |
788 EXPECT_TRUE(autofill_manager_->GetAutoFillSuggestions(form, field)); | 865 EXPECT_TRUE(autofill_manager_->GetAutoFillSuggestions(form, field)); |
789 | 866 |
790 // No suggestions provided, so send an empty vector as the results. | 867 // No suggestions provided, so send an empty vector as the results. |
(...skipping 16 matching lines...) Expand all Loading... | |
807 ExpectSuggestions(page_id, values, labels, icons, unique_ids, | 884 ExpectSuggestions(page_id, values, labels, icons, unique_ids, |
808 kDefaultPageID, arraysize(expected_values), expected_values, | 885 kDefaultPageID, arraysize(expected_values), expected_values, |
809 expected_labels, expected_icons, expected_unique_ids); | 886 expected_labels, expected_icons, expected_unique_ids); |
810 } | 887 } |
811 | 888 |
812 // Test that we return credit card profile suggestions when the selected form | 889 // Test that we return credit card profile suggestions when the selected form |
813 // field is not the credit card number field. | 890 // field is not the credit card number field. |
814 TEST_F(AutoFillManagerTest, GetCreditCardSuggestionsNonCCNumber) { | 891 TEST_F(AutoFillManagerTest, GetCreditCardSuggestionsNonCCNumber) { |
815 // Set up our form data. | 892 // Set up our form data. |
816 FormData form; | 893 FormData form; |
817 CreateTestCreditCardFormData(&form, true); | 894 CreateTestCreditCardFormData(&form, true, false); |
818 std::vector<FormData> forms(1, form); | 895 std::vector<FormData> forms(1, form); |
819 autofill_manager_->FormsSeen(forms); | 896 autofill_manager_->FormsSeen(forms); |
820 | 897 |
821 const FormField& field = form.fields[0]; | 898 const FormField& field = form.fields[0]; |
822 rvh()->ResetAutoFillState(kDefaultPageID); | 899 rvh()->ResetAutoFillState(kDefaultPageID); |
823 EXPECT_TRUE(autofill_manager_->GetAutoFillSuggestions(form, field)); | 900 EXPECT_TRUE(autofill_manager_->GetAutoFillSuggestions(form, field)); |
824 | 901 |
825 // No suggestions provided, so send an empty vector as the results. | 902 // No suggestions provided, so send an empty vector as the results. |
826 // This triggers the combined message send. | 903 // This triggers the combined message send. |
827 rvh()->AutocompleteSuggestionsReturned(std::vector<string16>()); | 904 rvh()->AutocompleteSuggestionsReturned(std::vector<string16>()); |
(...skipping 23 matching lines...) Expand all Loading... | |
851 ExpectSuggestions(page_id, values, labels, icons, unique_ids, | 928 ExpectSuggestions(page_id, values, labels, icons, unique_ids, |
852 kDefaultPageID, arraysize(expected_values), expected_values, | 929 kDefaultPageID, arraysize(expected_values), expected_values, |
853 expected_labels, expected_icons, expected_unique_ids); | 930 expected_labels, expected_icons, expected_unique_ids); |
854 } | 931 } |
855 | 932 |
856 // Test that we return a warning explaining that credit card profile suggestions | 933 // Test that we return a warning explaining that credit card profile suggestions |
857 // are unavailable when the form is not https. | 934 // are unavailable when the form is not https. |
858 TEST_F(AutoFillManagerTest, GetCreditCardSuggestionsNonHTTPS) { | 935 TEST_F(AutoFillManagerTest, GetCreditCardSuggestionsNonHTTPS) { |
859 // Set up our form data. | 936 // Set up our form data. |
860 FormData form; | 937 FormData form; |
861 CreateTestCreditCardFormData(&form, false); | 938 CreateTestCreditCardFormData(&form, false, false); |
862 std::vector<FormData> forms(1, form); | 939 std::vector<FormData> forms(1, form); |
863 autofill_manager_->FormsSeen(forms); | 940 autofill_manager_->FormsSeen(forms); |
864 | 941 |
865 const FormField& field = form.fields[0]; | 942 const FormField& field = form.fields[0]; |
866 rvh()->ResetAutoFillState(kDefaultPageID); | 943 rvh()->ResetAutoFillState(kDefaultPageID); |
867 EXPECT_TRUE(autofill_manager_->GetAutoFillSuggestions(form, field)); | 944 EXPECT_TRUE(autofill_manager_->GetAutoFillSuggestions(form, field)); |
868 | 945 |
869 // No suggestions provided, so send an empty vector as the results. | 946 // No suggestions provided, so send an empty vector as the results. |
870 // This triggers the combined message send. | 947 // This triggers the combined message send. |
871 rvh()->AutocompleteSuggestionsReturned(std::vector<string16>()); | 948 rvh()->AutocompleteSuggestionsReturned(std::vector<string16>()); |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
918 // Clear the test credit cards and try again -- we shouldn't return a warning. | 995 // Clear the test credit cards and try again -- we shouldn't return a warning. |
919 test_personal_data_->ClearCreditCards(); | 996 test_personal_data_->ClearCreditCards(); |
920 EXPECT_FALSE(autofill_manager_->GetAutoFillSuggestions(form, field)); | 997 EXPECT_FALSE(autofill_manager_->GetAutoFillSuggestions(form, field)); |
921 } | 998 } |
922 | 999 |
923 // Test that we return profile and credit card suggestions for combined forms. | 1000 // Test that we return profile and credit card suggestions for combined forms. |
924 TEST_F(AutoFillManagerTest, GetAddressAndCreditCardSuggestions) { | 1001 TEST_F(AutoFillManagerTest, GetAddressAndCreditCardSuggestions) { |
925 // Set up our form data. | 1002 // Set up our form data. |
926 FormData form; | 1003 FormData form; |
927 CreateTestAddressFormData(&form); | 1004 CreateTestAddressFormData(&form); |
928 CreateTestCreditCardFormData(&form, true); | 1005 CreateTestCreditCardFormData(&form, true, false); |
929 std::vector<FormData> forms(1, form); | 1006 std::vector<FormData> forms(1, form); |
930 autofill_manager_->FormsSeen(forms); | 1007 autofill_manager_->FormsSeen(forms); |
931 | 1008 |
932 FormField field = form.fields[0]; | 1009 FormField field = form.fields[0]; |
933 rvh()->ResetAutoFillState(kDefaultPageID); | 1010 rvh()->ResetAutoFillState(kDefaultPageID); |
934 EXPECT_TRUE(autofill_manager_->GetAutoFillSuggestions(form, field)); | 1011 EXPECT_TRUE(autofill_manager_->GetAutoFillSuggestions(form, field)); |
935 | 1012 |
936 // No suggestions provided, so send an empty vector as the results. | 1013 // No suggestions provided, so send an empty vector as the results. |
937 // This triggers the combined message send. | 1014 // This triggers the combined message send. |
938 rvh()->AutocompleteSuggestionsReturned(std::vector<string16>()); | 1015 rvh()->AutocompleteSuggestionsReturned(std::vector<string16>()); |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
995 } | 1072 } |
996 | 1073 |
997 // Test that for non-https forms with both address and credit card fields, we | 1074 // Test that for non-https forms with both address and credit card fields, we |
998 // only return address suggestions. Instead of credit card suggestions, we | 1075 // only return address suggestions. Instead of credit card suggestions, we |
999 // should return a warning explaining that credit card profile suggestions are | 1076 // should return a warning explaining that credit card profile suggestions are |
1000 // unavailable when the form is not https. | 1077 // unavailable when the form is not https. |
1001 TEST_F(AutoFillManagerTest, GetAddressAndCreditCardSuggestionsNonHttps) { | 1078 TEST_F(AutoFillManagerTest, GetAddressAndCreditCardSuggestionsNonHttps) { |
1002 // Set up our form data. | 1079 // Set up our form data. |
1003 FormData form; | 1080 FormData form; |
1004 CreateTestAddressFormData(&form); | 1081 CreateTestAddressFormData(&form); |
1005 CreateTestCreditCardFormData(&form, false); | 1082 CreateTestCreditCardFormData(&form, false, false); |
1006 std::vector<FormData> forms(1, form); | 1083 std::vector<FormData> forms(1, form); |
1007 autofill_manager_->FormsSeen(forms); | 1084 autofill_manager_->FormsSeen(forms); |
1008 | 1085 |
1009 FormField field = form.fields[0]; | 1086 FormField field = form.fields[0]; |
1010 rvh()->ResetAutoFillState(kDefaultPageID); | 1087 rvh()->ResetAutoFillState(kDefaultPageID); |
1011 EXPECT_TRUE(autofill_manager_->GetAutoFillSuggestions(form, field)); | 1088 EXPECT_TRUE(autofill_manager_->GetAutoFillSuggestions(form, field)); |
1012 | 1089 |
1013 // No suggestions provided, so send an empty vector as the results. | 1090 // No suggestions provided, so send an empty vector as the results. |
1014 // This triggers the combined message send. | 1091 // This triggers the combined message send. |
1015 rvh()->AutocompleteSuggestionsReturned(std::vector<string16>()); | 1092 rvh()->AutocompleteSuggestionsReturned(std::vector<string16>()); |
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1261 int page_id = 0; | 1338 int page_id = 0; |
1262 FormData results; | 1339 FormData results; |
1263 EXPECT_TRUE(GetAutoFillFormDataFilledMessage(&page_id, &results)); | 1340 EXPECT_TRUE(GetAutoFillFormDataFilledMessage(&page_id, &results)); |
1264 ExpectFilledAddressFormElvis(page_id, results, kDefaultPageID, false); | 1341 ExpectFilledAddressFormElvis(page_id, results, kDefaultPageID, false); |
1265 } | 1342 } |
1266 | 1343 |
1267 // Test that we correctly fill a credit card form. | 1344 // Test that we correctly fill a credit card form. |
1268 TEST_F(AutoFillManagerTest, FillCreditCardForm) { | 1345 TEST_F(AutoFillManagerTest, FillCreditCardForm) { |
1269 // Set up our form data. | 1346 // Set up our form data. |
1270 FormData form; | 1347 FormData form; |
1271 CreateTestCreditCardFormData(&form, true); | 1348 CreateTestCreditCardFormData(&form, true, false); |
1272 std::vector<FormData> forms(1, form); | 1349 std::vector<FormData> forms(1, form); |
1273 autofill_manager_->FormsSeen(forms); | 1350 autofill_manager_->FormsSeen(forms); |
1274 | 1351 |
1275 std::string guid = autofill_manager_->GetLabeledCreditCard("First")->guid(); | 1352 std::string guid = autofill_manager_->GetLabeledCreditCard("First")->guid(); |
1276 EXPECT_TRUE(autofill_manager_->FillAutoFillFormData( | 1353 EXPECT_TRUE(autofill_manager_->FillAutoFillFormData( |
1277 kDefaultPageID, form, *form.fields.begin(), | 1354 kDefaultPageID, form, *form.fields.begin(), |
1278 autofill_manager_->PackGUIDs(guid, std::string()))); | 1355 autofill_manager_->PackGUIDs(guid, std::string()))); |
1279 | 1356 |
1280 int page_id = 0; | 1357 int page_id = 0; |
1281 FormData results; | 1358 FormData results; |
1282 EXPECT_TRUE(GetAutoFillFormDataFilledMessage(&page_id, &results)); | 1359 EXPECT_TRUE(GetAutoFillFormDataFilledMessage(&page_id, &results)); |
1283 ExpectFilledCreditCardFormElvis(page_id, results, kDefaultPageID, false); | 1360 ExpectFilledCreditCardFormElvis(page_id, results, kDefaultPageID, false); |
1284 } | 1361 } |
1285 | 1362 |
1363 // Test that we correctly fill a credit card form with month input type. | |
1364 // 1. year empty, month empty | |
1365 TEST_F(AutoFillManagerTest, FillCreditCardFormNoYearNoMonth) { | |
1366 // Replace test credit cards to generate 4 credit cards with year month | |
1367 // combination. | |
1368 test_personal_data_->CreateTestCreditCardsYearMonth(); | |
Ilya Sherman
2011/01/10 20:08:48
Rather than creating all four cards within CreateT
honten.org
2011/01/25 05:19:24
Done.
| |
1369 // Set up our form data. | |
1370 FormData form; | |
1371 CreateTestCreditCardFormData(&form, true, true); | |
1372 std::vector<FormData> forms(1, form); | |
1373 autofill_manager_->FormsSeen(forms); | |
1374 | |
1375 std::string guid = autofill_manager_->GetLabeledCreditCard("Miku0")->guid(); | |
1376 EXPECT_TRUE(autofill_manager_->FillAutoFillFormData( | |
1377 kDefaultPageID, form, *form.fields.begin(), | |
1378 autofill_manager_->PackGUIDs(guid, std::string()))); | |
Ilya Sherman
2011/01/10 20:08:48
nit: Each of these lines should be indented four s
honten.org
2011/01/25 05:19:24
Done.
| |
1379 | |
1380 int page_id = 0; | |
1381 FormData results; | |
1382 EXPECT_TRUE(GetAutoFillFormDataFilledMessage(&page_id, &results)); | |
1383 ExpectFilledCreditCardYearMonthWithYearMonth(page_id, results, | |
1384 kDefaultPageID, false, "", ""); | |
1385 } | |
1386 | |
1387 // Test that we correctly fill a credit card form with month input type. | |
1388 // 2. year empty, month non-empty | |
1389 TEST_F(AutoFillManagerTest, FillCreditCardFormNoYearMonth) { | |
1390 // Same as the SetUp(), but generate 4 credit cards with year month | |
1391 // combination. | |
1392 test_personal_data_->CreateTestCreditCardsYearMonth(); | |
1393 // Set up our form data. | |
1394 FormData form; | |
1395 CreateTestCreditCardFormData(&form, true, true); | |
1396 std::vector<FormData> forms(1, form); | |
1397 autofill_manager_->FormsSeen(forms); | |
1398 | |
1399 std::string guid = autofill_manager_->GetLabeledCreditCard("Miku1")->guid(); | |
1400 EXPECT_TRUE(autofill_manager_->FillAutoFillFormData( | |
1401 kDefaultPageID, form, *form.fields.begin(), | |
1402 autofill_manager_->PackGUIDs(guid, std::string()))); | |
1403 | |
1404 int page_id = 0; | |
1405 FormData results; | |
1406 EXPECT_TRUE(GetAutoFillFormDataFilledMessage(&page_id, &results)); | |
1407 ExpectFilledCreditCardYearMonthWithYearMonth(page_id, results, | |
1408 kDefaultPageID, false, "", "04"); | |
1409 } | |
1410 | |
1411 // Test that we correctly fill a credit card form with month input type. | |
1412 // 3. year non-empty, month empty | |
1413 TEST_F(AutoFillManagerTest, FillCreditCardFormYearNoMonth) { | |
1414 // Same as the SetUp(), but generate 4 credit cards with year month | |
1415 // combination. | |
1416 test_personal_data_->CreateTestCreditCardsYearMonth(); | |
1417 // Set up our form data. | |
1418 FormData form; | |
1419 CreateTestCreditCardFormData(&form, true, true); | |
1420 std::vector<FormData> forms(1, form); | |
1421 autofill_manager_->FormsSeen(forms); | |
1422 | |
1423 std::string guid = autofill_manager_->GetLabeledCreditCard("Miku2")->guid(); | |
1424 EXPECT_TRUE(autofill_manager_->FillAutoFillFormData( | |
1425 kDefaultPageID, form, *form.fields.begin(), | |
1426 autofill_manager_->PackGUIDs(guid, std::string()))); | |
1427 | |
1428 int page_id = 0; | |
1429 FormData results; | |
1430 EXPECT_TRUE(GetAutoFillFormDataFilledMessage(&page_id, &results)); | |
1431 ExpectFilledCreditCardYearMonthWithYearMonth(page_id, results, | |
1432 kDefaultPageID, false, "2012", ""); | |
1433 } | |
1434 | |
1435 // Test that we correctly fill a credit card form with month input type. | |
1436 // 4. year non-empty, month empty | |
1437 TEST_F(AutoFillManagerTest, FillCreditCardFormYearMonth) { | |
1438 // Same as the SetUp(), but generate 4 credit cards with year month | |
1439 // combination. | |
1440 test_personal_data_->ClearCreditCards(); | |
1441 test_personal_data_->CreateTestCreditCardsYearMonth(); | |
1442 // Set up our form data. | |
1443 FormData form; | |
1444 CreateTestCreditCardFormData(&form, true, true); | |
1445 std::vector<FormData> forms(1, form); | |
1446 autofill_manager_->FormsSeen(forms); | |
1447 | |
1448 std::string guid = autofill_manager_->GetLabeledCreditCard("Miku3")->guid(); | |
1449 EXPECT_TRUE(autofill_manager_->FillAutoFillFormData( | |
1450 kDefaultPageID, form, *form.fields.begin(), | |
1451 autofill_manager_->PackGUIDs(guid, std::string()))); | |
1452 | |
1453 int page_id = 0; | |
1454 FormData results; | |
1455 EXPECT_TRUE(GetAutoFillFormDataFilledMessage(&page_id, &results)); | |
1456 ExpectFilledCreditCardYearMonthWithYearMonth(page_id, results, | |
1457 kDefaultPageID, false, "2012", "04"); | |
1458 } | |
1459 | |
1286 // Test that we correctly fill a combined address and credit card form. | 1460 // Test that we correctly fill a combined address and credit card form. |
1287 TEST_F(AutoFillManagerTest, FillAddressAndCreditCardForm) { | 1461 TEST_F(AutoFillManagerTest, FillAddressAndCreditCardForm) { |
1288 // Set up our form data. | 1462 // Set up our form data. |
1289 FormData form; | 1463 FormData form; |
1290 CreateTestAddressFormData(&form); | 1464 CreateTestAddressFormData(&form); |
1291 CreateTestCreditCardFormData(&form, true); | 1465 CreateTestCreditCardFormData(&form, true, false); |
1292 std::vector<FormData> forms(1, form); | 1466 std::vector<FormData> forms(1, form); |
1293 autofill_manager_->FormsSeen(forms); | 1467 autofill_manager_->FormsSeen(forms); |
1294 | 1468 |
1295 // First fill the address data. | 1469 // First fill the address data. |
1296 std::string guid = autofill_manager_->GetLabeledProfile("Home")->guid(); | 1470 std::string guid = autofill_manager_->GetLabeledProfile("Home")->guid(); |
1297 EXPECT_TRUE(autofill_manager_->FillAutoFillFormData( | 1471 EXPECT_TRUE(autofill_manager_->FillAutoFillFormData( |
1298 kDefaultPageID, form, form.fields[0], | 1472 kDefaultPageID, form, form.fields[0], |
1299 autofill_manager_->PackGUIDs(std::string(), guid))); | 1473 autofill_manager_->PackGUIDs(std::string(), guid))); |
1300 | 1474 |
1301 int page_id = 0; | 1475 int page_id = 0; |
(...skipping 20 matching lines...) Expand all Loading... | |
1322 } | 1496 } |
1323 } | 1497 } |
1324 | 1498 |
1325 // Test that we correctly fill a previously auto-filled form. | 1499 // Test that we correctly fill a previously auto-filled form. |
1326 TEST_F(AutoFillManagerTest, FillAutoFilledForm) { | 1500 TEST_F(AutoFillManagerTest, FillAutoFilledForm) { |
1327 // Set up our form data. | 1501 // Set up our form data. |
1328 FormData form; | 1502 FormData form; |
1329 CreateTestAddressFormData(&form); | 1503 CreateTestAddressFormData(&form); |
1330 // Mark one of the address fields as autofilled. | 1504 // Mark one of the address fields as autofilled. |
1331 form.fields[4].set_autofilled(true); | 1505 form.fields[4].set_autofilled(true); |
1332 CreateTestCreditCardFormData(&form, true); | 1506 CreateTestCreditCardFormData(&form, true, false); |
1333 std::vector<FormData> forms(1, form); | 1507 std::vector<FormData> forms(1, form); |
1334 autofill_manager_->FormsSeen(forms); | 1508 autofill_manager_->FormsSeen(forms); |
1335 | 1509 |
1336 // First fill the address data. | 1510 // First fill the address data. |
1337 std::string guid = autofill_manager_->GetLabeledProfile("Home")->guid(); | 1511 std::string guid = autofill_manager_->GetLabeledProfile("Home")->guid(); |
1338 EXPECT_TRUE(autofill_manager_->FillAutoFillFormData( | 1512 EXPECT_TRUE(autofill_manager_->FillAutoFillFormData( |
1339 kDefaultPageID, form, *form.fields.begin(), | 1513 kDefaultPageID, form, *form.fields.begin(), |
1340 autofill_manager_->PackGUIDs(std::string(), guid))); | 1514 autofill_manager_->PackGUIDs(std::string(), guid))); |
1341 | 1515 |
1342 int page_id = 0; | 1516 int page_id = 0; |
1343 FormData results; | 1517 FormData results; |
1344 EXPECT_TRUE(GetAutoFillFormDataFilledMessage(&page_id, &results)); | 1518 EXPECT_TRUE(GetAutoFillFormDataFilledMessage(&page_id, &results)); |
1345 { | 1519 { |
1346 SCOPED_TRACE("Address"); | 1520 SCOPED_TRACE("Address"); |
1347 ExpectFilledForm(page_id, results, kDefaultPageID, | 1521 ExpectFilledForm(page_id, results, kDefaultPageID, |
1348 "Elvis", "", "", "", "", "", "", "", "", "", "", "", | 1522 "Elvis", "", "", "", "", "", "", "", "", "", "", "", |
1349 "", "", "", "", true, true); | 1523 "", "", "", "", true, true, false); |
1350 } | 1524 } |
1351 | 1525 |
1352 // Now fill the credit card data. | 1526 // Now fill the credit card data. |
1353 process()->sink().ClearMessages(); | 1527 process()->sink().ClearMessages(); |
1354 const int kPageID2 = 2; | 1528 const int kPageID2 = 2; |
1355 guid = autofill_manager_->GetLabeledCreditCard("First")->guid(); | 1529 guid = autofill_manager_->GetLabeledCreditCard("First")->guid(); |
1356 EXPECT_TRUE(autofill_manager_->FillAutoFillFormData( | 1530 EXPECT_TRUE(autofill_manager_->FillAutoFillFormData( |
1357 kPageID2, form, form.fields.back(), | 1531 kPageID2, form, form.fields.back(), |
1358 autofill_manager_->PackGUIDs(guid, std::string()))); | 1532 autofill_manager_->PackGUIDs(guid, std::string()))); |
1359 | 1533 |
(...skipping 17 matching lines...) Expand all Loading... | |
1377 EXPECT_TRUE(autofill_manager_->FillAutoFillFormData( | 1551 EXPECT_TRUE(autofill_manager_->FillAutoFillFormData( |
1378 kPageID3, form, *form.fields.rbegin(), | 1552 kPageID3, form, *form.fields.rbegin(), |
1379 autofill_manager_->PackGUIDs(guid, std::string()))); | 1553 autofill_manager_->PackGUIDs(guid, std::string()))); |
1380 | 1554 |
1381 page_id = 0; | 1555 page_id = 0; |
1382 EXPECT_TRUE(GetAutoFillFormDataFilledMessage(&page_id, &results)); | 1556 EXPECT_TRUE(GetAutoFillFormDataFilledMessage(&page_id, &results)); |
1383 { | 1557 { |
1384 SCOPED_TRACE("Credit card 2"); | 1558 SCOPED_TRACE("Credit card 2"); |
1385 ExpectFilledForm(page_id, results, kPageID3, | 1559 ExpectFilledForm(page_id, results, kPageID3, |
1386 "", "", "", "", "", "", "", "", "", "", "", "", | 1560 "", "", "", "", "", "", "", "", "", "", "", "", |
1387 "", "", "", "2012", true, true); | 1561 "", "", "", "2012", true, true, false); |
1388 } | 1562 } |
1389 } | 1563 } |
1390 | 1564 |
1391 // Test that we correctly fill a phone number split across multiple fields. | 1565 // Test that we correctly fill a phone number split across multiple fields. |
1392 TEST_F(AutoFillManagerTest, FillPhoneNumber) { | 1566 TEST_F(AutoFillManagerTest, FillPhoneNumber) { |
1393 // Set up our form data. | 1567 // Set up our form data. |
1394 FormData form; | 1568 FormData form; |
1395 form.name = ASCIIToUTF16("MyPhoneForm"); | 1569 form.name = ASCIIToUTF16("MyPhoneForm"); |
1396 form.method = ASCIIToUTF16("POST"); | 1570 form.method = ASCIIToUTF16("POST"); |
1397 form.origin = GURL("http://myform.com/phone_form.html"); | 1571 form.origin = GURL("http://myform.com/phone_form.html"); |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1563 ASSERT_FALSE(profile()->GetPrefs()->GetBoolean( | 1737 ASSERT_FALSE(profile()->GetPrefs()->GetBoolean( |
1564 prefs::kAutoFillAuxiliaryProfilesEnabled)); | 1738 prefs::kAutoFillAuxiliaryProfilesEnabled)); |
1565 profile()->GetPrefs()->SetBoolean( | 1739 profile()->GetPrefs()->SetBoolean( |
1566 prefs::kAutoFillAuxiliaryProfilesEnabled, true); | 1740 prefs::kAutoFillAuxiliaryProfilesEnabled, true); |
1567 profile()->GetPrefs()->ClearPref(prefs::kAutoFillAuxiliaryProfilesEnabled); | 1741 profile()->GetPrefs()->ClearPref(prefs::kAutoFillAuxiliaryProfilesEnabled); |
1568 ASSERT_FALSE(profile()->GetPrefs()->GetBoolean( | 1742 ASSERT_FALSE(profile()->GetPrefs()->GetBoolean( |
1569 prefs::kAutoFillAuxiliaryProfilesEnabled)); | 1743 prefs::kAutoFillAuxiliaryProfilesEnabled)); |
1570 #endif | 1744 #endif |
1571 } | 1745 } |
1572 | 1746 |
OLD | NEW |