Chromium Code Reviews| 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 30 matching lines...) Expand all Loading... | |
| 41 const int kDefaultPageID = 137; | 41 const int kDefaultPageID = 137; |
| 42 | 42 |
| 43 typedef Tuple5<int, | 43 typedef Tuple5<int, |
| 44 std::vector<string16>, | 44 std::vector<string16>, |
| 45 std::vector<string16>, | 45 std::vector<string16>, |
| 46 std::vector<string16>, | 46 std::vector<string16>, |
| 47 std::vector<int> > AutoFillParam; | 47 std::vector<int> > AutoFillParam; |
| 48 | 48 |
| 49 class TestPersonalDataManager : public PersonalDataManager { | 49 class TestPersonalDataManager : public PersonalDataManager { |
| 50 public: | 50 public: |
| 51 TestPersonalDataManager() { | 51 explicit TestPersonalDataManager(bool four_credit_cards_with_year_month) { |
|
Ilya Sherman
2011/01/07 07:28:28
Rather than adding a boolean here, please add an |
| |
| 52 CreateTestAutoFillProfiles(&web_profiles_); | 52 CreateTestAutoFillProfiles(&web_profiles_); |
| 53 CreateTestCreditCards(&credit_cards_); | 53 if (four_credit_cards_with_year_month) |
| 54 CreateTestCreditCardsYearMonth(&credit_cards_); | |
| 55 else | |
| 56 CreateTestCreditCards(&credit_cards_); | |
| 54 } | 57 } |
| 55 | 58 |
| 56 virtual void InitializeIfNeeded() {} | 59 virtual void InitializeIfNeeded() {} |
| 57 virtual void SaveImportedFormData() {} | 60 virtual void SaveImportedFormData() {} |
| 58 virtual bool IsDataLoaded() const { return true; } | 61 virtual bool IsDataLoaded() const { return true; } |
| 59 | 62 |
| 60 AutoFillProfile* GetLabeledProfile(const char* label) { | 63 AutoFillProfile* GetLabeledProfile(const char* label) { |
| 61 for (std::vector<AutoFillProfile *>::iterator it = web_profiles_.begin(); | 64 for (std::vector<AutoFillProfile *>::iterator it = web_profiles_.begin(); |
| 62 it != web_profiles_.end(); ++it) { | 65 it != web_profiles_.end(); ++it) { |
| 63 if (!(*it)->Label().compare(ASCIIToUTF16(label))) | 66 if (!(*it)->Label().compare(ASCIIToUTF16(label))) |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 124 "5187654321098765", // Mastercard | 127 "5187654321098765", // Mastercard |
| 125 "10", "2014"); | 128 "10", "2014"); |
| 126 credit_card->set_guid("00000000-0000-0000-0000-000000000005"); | 129 credit_card->set_guid("00000000-0000-0000-0000-000000000005"); |
| 127 credit_cards->push_back(credit_card); | 130 credit_cards->push_back(credit_card); |
| 128 credit_card = new CreditCard; | 131 credit_card = new CreditCard; |
| 129 autofill_test::SetCreditCardInfo(credit_card, "Empty", "", "", "", ""); | 132 autofill_test::SetCreditCardInfo(credit_card, "Empty", "", "", "", ""); |
| 130 credit_card->set_guid("00000000-0000-0000-0000-000000000006"); | 133 credit_card->set_guid("00000000-0000-0000-0000-000000000006"); |
| 131 credit_cards->push_back(credit_card); | 134 credit_cards->push_back(credit_card); |
| 132 } | 135 } |
| 133 | 136 |
| 137 void CreateTestCreditCardsYearMonth(ScopedVector<CreditCard>* credit_cards) { | |
| 138 // Create four credit cards with year month combination as following, | |
| 139 // 1. year empty, month empty | |
| 140 // 2. year empty, month non-empty | |
| 141 // 3. year non-empty, month empty | |
| 142 // 4. both non-empty | |
| 143 for (int i = 0; i < 4; i++) { | |
|
dhollowa
2011/01/07 03:47:15
I'm a lazy reader. It'd be easier on me if we unr
| |
| 144 const char* year = i%2 ? "" : "2012"; | |
| 145 const char* month = i/2 ? "" : "04"; | |
| 146 std::string name = base::StringPrintf("Miku%d",i); | |
| 147 CreditCard* credit_card = new CreditCard; | |
| 148 autofill_test::SetCreditCardInfo(credit_card, name.c_str(), | |
| 149 "Miku Hatsune", | |
| 150 "4234567890654321", // Visa | |
| 151 month, year); | |
| 152 credit_card->set_guid("00000000-0000-0000-0000-" + | |
| 153 base::StringPrintf("%012d", 7 + i)); | |
| 154 credit_cards->push_back(credit_card); | |
| 155 } | |
| 156 } | |
|
honten.org
2011/01/06 07:04:54
Make four credit cards for year month combination
| |
| 157 | |
| 134 DISALLOW_COPY_AND_ASSIGN(TestPersonalDataManager); | 158 DISALLOW_COPY_AND_ASSIGN(TestPersonalDataManager); |
| 135 }; | 159 }; |
| 136 | 160 |
| 137 // Populates |form| with data corresponding to a simple address form. | 161 // Populates |form| with data corresponding to a simple address form. |
| 138 // Note that this actually appends fields to the form data, which can be useful | 162 // Note that this actually appends fields to the form data, which can be useful |
| 139 // for building up more complex test forms. | 163 // for building up more complex test forms. |
| 140 void CreateTestAddressFormData(FormData* form) { | 164 void CreateTestAddressFormData(FormData* form) { |
| 141 form->name = ASCIIToUTF16("MyForm"); | 165 form->name = ASCIIToUTF16("MyForm"); |
| 142 form->method = ASCIIToUTF16("POST"); | 166 form->method = ASCIIToUTF16("POST"); |
| 143 form->origin = GURL("http://myform.com/form.html"); | 167 form->origin = GURL("http://myform.com/form.html"); |
| (...skipping 30 matching lines...) Expand all Loading... | |
| 174 form->fields.push_back(field); | 198 form->fields.push_back(field); |
| 175 autofill_test::CreateTestFormField( | 199 autofill_test::CreateTestFormField( |
| 176 "Phone Number", "phonenumber", "", "text", &field); | 200 "Phone Number", "phonenumber", "", "text", &field); |
| 177 form->fields.push_back(field); | 201 form->fields.push_back(field); |
| 178 autofill_test::CreateTestFormField( | 202 autofill_test::CreateTestFormField( |
| 179 "Fax", "fax", "", "text", &field); | 203 "Fax", "fax", "", "text", &field); |
| 180 form->fields.push_back(field); | 204 form->fields.push_back(field); |
| 181 autofill_test::CreateTestFormField( | 205 autofill_test::CreateTestFormField( |
| 182 "Email", "email", "", "text", &field); | 206 "Email", "email", "", "text", &field); |
| 183 form->fields.push_back(field); | 207 form->fields.push_back(field); |
| 184 } | 208 autofill_test::CreateTestFormField( |
| 209 "Email", "email2", "", "email", &field); | |
| 210 form->fields.push_back(field); | |
| 211 autofill_test::CreateTestFormField( | |
| 212 "Phone Number", "phonenumber2", "", "tel", &field); | |
| 213 form->fields.push_back(field); | |
| 214 } | |
| 185 | 215 |
| 186 // Populates |form| with data corresponding to a simple credit card form. | 216 // 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 | 217 // Note that this actually appends fields to the form data, which can be useful |
| 188 // for building up more complex test forms. | 218 // for building up more complex test forms. |
| 189 void CreateTestCreditCardFormData(FormData* form, bool is_https) { | 219 void CreateTestCreditCardFormData(FormData* form, |
| 220 bool is_https, | |
| 221 bool use_month_type) { | |
| 190 form->name = ASCIIToUTF16("MyForm"); | 222 form->name = ASCIIToUTF16("MyForm"); |
| 191 form->method = ASCIIToUTF16("POST"); | 223 form->method = ASCIIToUTF16("POST"); |
| 192 if (is_https) { | 224 if (is_https) { |
| 193 form->origin = GURL("https://myform.com/form.html"); | 225 form->origin = GURL("https://myform.com/form.html"); |
| 194 form->action = GURL("https://myform.com/submit.html"); | 226 form->action = GURL("https://myform.com/submit.html"); |
| 195 } else { | 227 } else { |
| 196 form->origin = GURL("http://myform.com/form.html"); | 228 form->origin = GURL("http://myform.com/form.html"); |
| 197 form->action = GURL("http://myform.com/submit.html"); | 229 form->action = GURL("http://myform.com/submit.html"); |
| 198 } | 230 } |
| 199 form->user_submitted = true; | 231 form->user_submitted = true; |
| 200 | 232 |
| 201 FormField field; | 233 FormField field; |
| 202 autofill_test::CreateTestFormField( | 234 autofill_test::CreateTestFormField( |
| 203 "Name on Card", "nameoncard", "", "text", &field); | 235 "Name on Card", "nameoncard", "", "text", &field); |
| 204 form->fields.push_back(field); | 236 form->fields.push_back(field); |
| 205 autofill_test::CreateTestFormField( | 237 autofill_test::CreateTestFormField( |
| 206 "Card Number", "cardnumber", "", "text", &field); | 238 "Card Number", "cardnumber", "", "text", &field); |
| 207 form->fields.push_back(field); | 239 form->fields.push_back(field); |
| 208 autofill_test::CreateTestFormField( | 240 if (use_month_type) { |
| 209 "Expiration Date", "ccmonth", "", "text", &field); | 241 autofill_test::CreateTestFormField( |
| 210 form->fields.push_back(field); | 242 "Expiration Date", "ccmonth", "", "month", &field); |
| 211 autofill_test::CreateTestFormField( | 243 form->fields.push_back(field); |
| 212 "", "ccyear", "", "text", &field); | 244 } else { |
| 213 form->fields.push_back(field); | 245 autofill_test::CreateTestFormField( |
| 246 "Expiration Date", "ccmonth", "", "text", &field); | |
| 247 form->fields.push_back(field); | |
| 248 autofill_test::CreateTestFormField( | |
| 249 "", "ccyear", "", "text", &field); | |
| 250 form->fields.push_back(field); | |
| 251 } | |
| 214 } | 252 } |
| 215 | 253 |
| 216 void ExpectSuggestions(int page_id, | 254 void ExpectSuggestions(int page_id, |
| 217 const std::vector<string16>& values, | 255 const std::vector<string16>& values, |
| 218 const std::vector<string16>& labels, | 256 const std::vector<string16>& labels, |
| 219 const std::vector<string16>& icons, | 257 const std::vector<string16>& icons, |
| 220 const std::vector<int>& unique_ids, | 258 const std::vector<int>& unique_ids, |
| 221 int expected_page_id, | 259 int expected_page_id, |
| 222 size_t expected_num_suggestions, | 260 size_t expected_num_suggestions, |
| 223 const string16 expected_values[], | 261 const string16 expected_values[], |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 234 EXPECT_EQ(expected_values[i], values[i]); | 272 EXPECT_EQ(expected_values[i], values[i]); |
| 235 EXPECT_EQ(expected_labels[i], labels[i]); | 273 EXPECT_EQ(expected_labels[i], labels[i]); |
| 236 EXPECT_EQ(expected_icons[i], icons[i]); | 274 EXPECT_EQ(expected_icons[i], icons[i]); |
| 237 EXPECT_EQ(expected_unique_ids[i], unique_ids[i]); | 275 EXPECT_EQ(expected_unique_ids[i], unique_ids[i]); |
| 238 } | 276 } |
| 239 } | 277 } |
| 240 | 278 |
| 241 // Verifies that the |filled_form| has been filled with the given data. | 279 // Verifies that the |filled_form| has been filled with the given data. |
| 242 // Verifies address fields if |has_address_fields| is true, and verifies | 280 // 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 | 281 // credit card fields if |has_credit_card_fields| is true. Verifies both if both |
| 244 // are true. | 282 // are true. |use_month_type| is used for credit card input month type. |
| 245 void ExpectFilledForm(int page_id, | 283 void ExpectFilledForm(int page_id, |
| 246 const FormData& filled_form, | 284 const FormData& filled_form, |
| 247 int expected_page_id, | 285 int expected_page_id, |
| 248 const char* first, | 286 const char* first, |
| 249 const char* middle, | 287 const char* middle, |
| 250 const char* last, | 288 const char* last, |
| 251 const char* address1, | 289 const char* address1, |
| 252 const char* address2, | 290 const char* address2, |
| 253 const char* city, | 291 const char* city, |
| 254 const char* state, | 292 const char* state, |
| 255 const char* postal_code, | 293 const char* postal_code, |
| 256 const char* country, | 294 const char* country, |
| 257 const char* phone, | 295 const char* phone, |
| 258 const char* fax, | 296 const char* fax, |
| 259 const char* email, | 297 const char* email, |
| 260 const char* name_on_card, | 298 const char* name_on_card, |
| 261 const char* card_number, | 299 const char* card_number, |
| 262 const char* expiration_month, | 300 const char* expiration_month, |
| 263 const char* expiration_year, | 301 const char* expiration_year, |
| 264 bool has_address_fields, | 302 bool has_address_fields, |
| 265 bool has_credit_card_fields) { | 303 bool has_credit_card_fields, |
| 304 int use_month_type) { | |
|
Ilya Sherman
2011/01/07 07:28:28
nit: bool rather than int
| |
| 266 // The number of fields in the address and credit card forms created above. | 305 // The number of fields in the address and credit card forms created above. |
| 267 const size_t kAddressFormSize = 12; | 306 const size_t kAddressFormSize = 14; |
| 268 const size_t kCreditCardFormSize = 4; | 307 const size_t kCreditCardFormSize = use_month_type ? 3 : 4; |
| 269 | 308 |
| 270 EXPECT_EQ(expected_page_id, page_id); | 309 EXPECT_EQ(expected_page_id, page_id); |
| 271 EXPECT_EQ(ASCIIToUTF16("MyForm"), filled_form.name); | 310 EXPECT_EQ(ASCIIToUTF16("MyForm"), filled_form.name); |
| 272 EXPECT_EQ(ASCIIToUTF16("POST"), filled_form.method); | 311 EXPECT_EQ(ASCIIToUTF16("POST"), filled_form.method); |
| 273 if (has_credit_card_fields) { | 312 if (has_credit_card_fields) { |
| 274 EXPECT_EQ(GURL("https://myform.com/form.html"), filled_form.origin); | 313 EXPECT_EQ(GURL("https://myform.com/form.html"), filled_form.origin); |
| 275 EXPECT_EQ(GURL("https://myform.com/submit.html"), filled_form.action); | 314 EXPECT_EQ(GURL("https://myform.com/submit.html"), filled_form.action); |
| 276 } else { | 315 } else { |
| 277 EXPECT_EQ(GURL("http://myform.com/form.html"), filled_form.origin); | 316 EXPECT_EQ(GURL("http://myform.com/form.html"), filled_form.origin); |
| 278 EXPECT_EQ(GURL("http://myform.com/submit.html"), filled_form.action); | 317 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])); | 356 EXPECT_TRUE(field.StrictlyEqualsHack(filled_form.fields[8])); |
| 318 autofill_test::CreateTestFormField( | 357 autofill_test::CreateTestFormField( |
| 319 "Phone Number", "phonenumber", phone, "text", &field); | 358 "Phone Number", "phonenumber", phone, "text", &field); |
| 320 EXPECT_TRUE(field.StrictlyEqualsHack(filled_form.fields[9])); | 359 EXPECT_TRUE(field.StrictlyEqualsHack(filled_form.fields[9])); |
| 321 autofill_test::CreateTestFormField( | 360 autofill_test::CreateTestFormField( |
| 322 "Fax", "fax", fax, "text", &field); | 361 "Fax", "fax", fax, "text", &field); |
| 323 EXPECT_TRUE(field.StrictlyEqualsHack(filled_form.fields[10])); | 362 EXPECT_TRUE(field.StrictlyEqualsHack(filled_form.fields[10])); |
| 324 autofill_test::CreateTestFormField( | 363 autofill_test::CreateTestFormField( |
| 325 "Email", "email", email, "text", &field); | 364 "Email", "email", email, "text", &field); |
| 326 EXPECT_TRUE(field.StrictlyEqualsHack(filled_form.fields[11])); | 365 EXPECT_TRUE(field.StrictlyEqualsHack(filled_form.fields[11])); |
| 327 } | 366 autofill_test::CreateTestFormField( |
| 367 "Email", "email2", email, "email", &field); | |
| 368 EXPECT_TRUE(field.StrictlyEqualsHack(filled_form.fields[12])); | |
| 369 autofill_test::CreateTestFormField( | |
| 370 "Phone Number", "phonenumber2", phone, "tel", &field); | |
| 371 EXPECT_TRUE(field.StrictlyEqualsHack(filled_form.fields[13])); | |
| 372 } | |
| 328 | 373 |
| 329 if (has_credit_card_fields) { | 374 if (has_credit_card_fields) { |
| 330 size_t offset = has_address_fields? kAddressFormSize : 0; | 375 size_t offset = has_address_fields? kAddressFormSize : 0; |
| 331 autofill_test::CreateTestFormField( | 376 autofill_test::CreateTestFormField( |
| 332 "Name on Card", "nameoncard", name_on_card, "text", &field); | 377 "Name on Card", "nameoncard", name_on_card, "text", &field); |
| 333 EXPECT_TRUE(field.StrictlyEqualsHack(filled_form.fields[offset + 0])); | 378 EXPECT_TRUE(field.StrictlyEqualsHack(filled_form.fields[offset + 0])); |
| 334 autofill_test::CreateTestFormField( | 379 autofill_test::CreateTestFormField( |
| 335 "Card Number", "cardnumber", card_number, "text", &field); | 380 "Card Number", "cardnumber", card_number, "text", &field); |
| 336 EXPECT_TRUE(field.StrictlyEqualsHack(filled_form.fields[offset + 1])); | 381 EXPECT_TRUE(field.StrictlyEqualsHack(filled_form.fields[offset + 1])); |
| 337 autofill_test::CreateTestFormField( | 382 if (use_month_type) { |
| 338 "Expiration Date", "ccmonth", expiration_month, "text", &field); | 383 std::string exp_year = expiration_year; |
| 339 EXPECT_TRUE(field.StrictlyEqualsHack(filled_form.fields[offset + 2])); | 384 std::string exp_month = expiration_month; |
| 340 autofill_test::CreateTestFormField( | 385 std::string year_month; |
|
Ilya Sherman
2011/01/07 07:28:28
nit: "date" might be a better name
| |
| 341 "", "ccyear", expiration_year, "text", &field); | 386 if (!exp_year.empty() && !exp_month.empty()) |
| 342 EXPECT_TRUE(field.StrictlyEqualsHack(filled_form.fields[offset + 3])); | 387 year_month = exp_year + "-" + exp_month; |
| 388 autofill_test::CreateTestFormField("Expiration Date", "ccmonth", | |
| 389 year_month.c_str(), "month", &field); | |
| 390 EXPECT_TRUE(field.StrictlyEqualsHack(filled_form.fields[offset + 2])); | |
| 391 } else { | |
| 392 autofill_test::CreateTestFormField( | |
| 393 "Expiration Date", "ccmonth", expiration_month, "text", &field); | |
| 394 EXPECT_TRUE(field.StrictlyEqualsHack(filled_form.fields[offset + 2])); | |
| 395 autofill_test::CreateTestFormField( | |
| 396 "", "ccyear", expiration_year, "text", &field); | |
| 397 EXPECT_TRUE(field.StrictlyEqualsHack(filled_form.fields[offset + 3])); | |
| 398 } | |
| 343 } | 399 } |
| 344 } | 400 } |
| 345 | 401 |
| 346 void ExpectFilledAddressFormElvis(int page_id, | 402 void ExpectFilledAddressFormElvis(int page_id, |
| 347 const FormData& filled_form, | 403 const FormData& filled_form, |
| 348 int expected_page_id, | 404 int expected_page_id, |
| 349 bool has_credit_card_fields) { | 405 bool has_credit_card_fields) { |
| 350 ExpectFilledForm(page_id, filled_form, expected_page_id, "Elvis", "Aaron", | 406 ExpectFilledForm(page_id, filled_form, expected_page_id, "Elvis", "Aaron", |
| 351 "Presley", "3734 Elvis Presley Blvd.", "Apt. 10", "Memphis", | 407 "Presley", "3734 Elvis Presley Blvd.", "Apt. 10", "Memphis", |
| 352 "Tennessee", "38116", "USA", "12345678901", "", | 408 "Tennessee", "38116", "USA", "12345678901", "", |
| 353 "theking@gmail.com", "", "", "", "", true, | 409 "theking@gmail.com", "", "", "", "", true, |
| 354 has_credit_card_fields); | 410 has_credit_card_fields, false); |
| 355 } | 411 } |
| 356 | 412 |
| 357 void ExpectFilledCreditCardFormElvis(int page_id, | 413 void ExpectFilledCreditCardFormElvis(int page_id, |
| 358 const FormData& filled_form, | 414 const FormData& filled_form, |
| 359 int expected_page_id, | 415 int expected_page_id, |
| 360 bool has_address_fields) { | 416 bool has_address_fields) { |
| 361 ExpectFilledForm(page_id, filled_form, expected_page_id, | 417 ExpectFilledForm(page_id, filled_form, expected_page_id, |
| 362 "", "", "", "", "", "", "", "", "", "", "", "", | 418 "", "", "", "", "", "", "", "", "", "", "", "", |
| 363 "Elvis Presley", "4234567890123456", "04", "2012", | 419 "Elvis Presley", "4234567890123456", "04", "2012", |
| 364 has_address_fields, true); | 420 has_address_fields, true, false); |
| 421 } | |
| 422 | |
| 423 void ExpectFilledCreditCardYearMonthWithIndex(int page_id, | |
| 424 const FormData& filled_form, | |
| 425 int expected_page_id, | |
| 426 bool has_address_fields, | |
| 427 int i) { | |
| 428 const char* year = i%2 ? "" : "2012"; | |
| 429 const char* month = i/2 ? "" : "04"; | |
| 430 ExpectFilledForm(page_id, filled_form, expected_page_id, | |
| 431 "", "", "", "", "", "", "", "", "", "", "", "", | |
| 432 "Miku Hatsune", "4234567890654321", month, year, | |
| 433 has_address_fields, true, true); | |
| 365 } | 434 } |
| 366 | 435 |
| 367 class TestAutoFillManager : public AutoFillManager { | 436 class TestAutoFillManager : public AutoFillManager { |
| 368 public: | 437 public: |
| 369 TestAutoFillManager(TabContents* tab_contents, | 438 TestAutoFillManager(TabContents* tab_contents, |
| 370 TestPersonalDataManager* personal_manager) | 439 TestPersonalDataManager* personal_manager) |
| 371 : AutoFillManager(tab_contents, personal_manager), | 440 : AutoFillManager(tab_contents, personal_manager), |
| 372 autofill_enabled_(true) { | 441 autofill_enabled_(true) { |
| 373 test_personal_data_ = personal_manager; | 442 test_personal_data_ = personal_manager; |
| 374 } | 443 } |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 426 AutoFillManagerTest() {} | 495 AutoFillManagerTest() {} |
| 427 virtual ~AutoFillManagerTest() { | 496 virtual ~AutoFillManagerTest() { |
| 428 // Order of destruction is important as AutoFillManager relies on | 497 // Order of destruction is important as AutoFillManager relies on |
| 429 // PersonalDataManager to be around when it gets destroyed. | 498 // PersonalDataManager to be around when it gets destroyed. |
| 430 autofill_manager_.reset(NULL); | 499 autofill_manager_.reset(NULL); |
| 431 test_personal_data_ = NULL; | 500 test_personal_data_ = NULL; |
| 432 } | 501 } |
| 433 | 502 |
| 434 virtual void SetUp() { | 503 virtual void SetUp() { |
| 435 RenderViewHostTestHarness::SetUp(); | 504 RenderViewHostTestHarness::SetUp(); |
| 436 test_personal_data_ = new TestPersonalDataManager(); | 505 test_personal_data_ = new TestPersonalDataManager(false); |
| 437 autofill_manager_.reset(new TestAutoFillManager(contents(), | 506 autofill_manager_.reset(new TestAutoFillManager(contents(), |
| 438 test_personal_data_.get())); | 507 test_personal_data_.get())); |
| 439 } | 508 } |
| 440 | 509 |
| 441 Profile* profile() { return contents()->profile(); } | 510 Profile* profile() { return contents()->profile(); } |
| 442 | 511 |
| 443 bool GetAutoFillSuggestionsMessage(int* page_id, | 512 bool GetAutoFillSuggestionsMessage(int* page_id, |
| 444 std::vector<string16>* values, | 513 std::vector<string16>* values, |
| 445 std::vector<string16>* labels, | 514 std::vector<string16>* labels, |
| 446 std::vector<string16>* icons, | 515 std::vector<string16>* icons, |
| (...skipping 279 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. | 795 // Now clear the test profiles and try again -- we shouldn't return a warning. |
| 727 test_personal_data_->ClearAutoFillProfiles(); | 796 test_personal_data_->ClearAutoFillProfiles(); |
| 728 EXPECT_FALSE(autofill_manager_->GetAutoFillSuggestions(form, field)); | 797 EXPECT_FALSE(autofill_manager_->GetAutoFillSuggestions(form, field)); |
| 729 } | 798 } |
| 730 | 799 |
| 731 // Test that we return all credit card profile suggestions when all form fields | 800 // Test that we return all credit card profile suggestions when all form fields |
| 732 // are empty. | 801 // are empty. |
| 733 TEST_F(AutoFillManagerTest, GetCreditCardSuggestionsEmptyValue) { | 802 TEST_F(AutoFillManagerTest, GetCreditCardSuggestionsEmptyValue) { |
| 734 // Set up our form data. | 803 // Set up our form data. |
| 735 FormData form; | 804 FormData form; |
| 736 CreateTestCreditCardFormData(&form, true); | 805 CreateTestCreditCardFormData(&form, true, false); |
| 737 std::vector<FormData> forms(1, form); | 806 std::vector<FormData> forms(1, form); |
| 738 autofill_manager_->FormsSeen(forms); | 807 autofill_manager_->FormsSeen(forms); |
| 739 | 808 |
| 740 FormField field = form.fields[1]; | 809 FormField field = form.fields[1]; |
| 741 rvh()->ResetAutoFillState(kDefaultPageID); | 810 rvh()->ResetAutoFillState(kDefaultPageID); |
| 742 EXPECT_TRUE(autofill_manager_->GetAutoFillSuggestions(form, field)); | 811 EXPECT_TRUE(autofill_manager_->GetAutoFillSuggestions(form, field)); |
| 743 | 812 |
| 744 // No suggestions provided, so send an empty vector as the results. | 813 // No suggestions provided, so send an empty vector as the results. |
| 745 // This triggers the combined message send. | 814 // This triggers the combined message send. |
| 746 rvh()->AutocompleteSuggestionsReturned(std::vector<string16>()); | 815 rvh()->AutocompleteSuggestionsReturned(std::vector<string16>()); |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 770 ExpectSuggestions(page_id, values, labels, icons, unique_ids, | 839 ExpectSuggestions(page_id, values, labels, icons, unique_ids, |
| 771 kDefaultPageID, arraysize(expected_values), expected_values, | 840 kDefaultPageID, arraysize(expected_values), expected_values, |
| 772 expected_labels, expected_icons, expected_unique_ids); | 841 expected_labels, expected_icons, expected_unique_ids); |
| 773 } | 842 } |
| 774 | 843 |
| 775 // Test that we return only matching credit card profile suggestions when the | 844 // Test that we return only matching credit card profile suggestions when the |
| 776 // selected form field has been partially filled out. | 845 // selected form field has been partially filled out. |
| 777 TEST_F(AutoFillManagerTest, GetCreditCardSuggestionsMatchCharacter) { | 846 TEST_F(AutoFillManagerTest, GetCreditCardSuggestionsMatchCharacter) { |
| 778 // Set up our form data. | 847 // Set up our form data. |
| 779 FormData form; | 848 FormData form; |
| 780 CreateTestCreditCardFormData(&form, true); | 849 CreateTestCreditCardFormData(&form, true, false); |
| 781 std::vector<FormData> forms(1, form); | 850 std::vector<FormData> forms(1, form); |
| 782 autofill_manager_->FormsSeen(forms); | 851 autofill_manager_->FormsSeen(forms); |
| 783 | 852 |
| 784 FormField field; | 853 FormField field; |
| 785 autofill_test::CreateTestFormField( | 854 autofill_test::CreateTestFormField( |
| 786 "Card Number", "cardnumber", "4", "text", &field); | 855 "Card Number", "cardnumber", "4", "text", &field); |
| 787 rvh()->ResetAutoFillState(kDefaultPageID); | 856 rvh()->ResetAutoFillState(kDefaultPageID); |
| 788 EXPECT_TRUE(autofill_manager_->GetAutoFillSuggestions(form, field)); | 857 EXPECT_TRUE(autofill_manager_->GetAutoFillSuggestions(form, field)); |
| 789 | 858 |
| 790 // No suggestions provided, so send an empty vector as the results. | 859 // 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, | 876 ExpectSuggestions(page_id, values, labels, icons, unique_ids, |
| 808 kDefaultPageID, arraysize(expected_values), expected_values, | 877 kDefaultPageID, arraysize(expected_values), expected_values, |
| 809 expected_labels, expected_icons, expected_unique_ids); | 878 expected_labels, expected_icons, expected_unique_ids); |
| 810 } | 879 } |
| 811 | 880 |
| 812 // Test that we return credit card profile suggestions when the selected form | 881 // Test that we return credit card profile suggestions when the selected form |
| 813 // field is not the credit card number field. | 882 // field is not the credit card number field. |
| 814 TEST_F(AutoFillManagerTest, GetCreditCardSuggestionsNonCCNumber) { | 883 TEST_F(AutoFillManagerTest, GetCreditCardSuggestionsNonCCNumber) { |
| 815 // Set up our form data. | 884 // Set up our form data. |
| 816 FormData form; | 885 FormData form; |
| 817 CreateTestCreditCardFormData(&form, true); | 886 CreateTestCreditCardFormData(&form, true, false); |
| 818 std::vector<FormData> forms(1, form); | 887 std::vector<FormData> forms(1, form); |
| 819 autofill_manager_->FormsSeen(forms); | 888 autofill_manager_->FormsSeen(forms); |
| 820 | 889 |
| 821 const FormField& field = form.fields[0]; | 890 const FormField& field = form.fields[0]; |
| 822 rvh()->ResetAutoFillState(kDefaultPageID); | 891 rvh()->ResetAutoFillState(kDefaultPageID); |
| 823 EXPECT_TRUE(autofill_manager_->GetAutoFillSuggestions(form, field)); | 892 EXPECT_TRUE(autofill_manager_->GetAutoFillSuggestions(form, field)); |
| 824 | 893 |
| 825 // No suggestions provided, so send an empty vector as the results. | 894 // No suggestions provided, so send an empty vector as the results. |
| 826 // This triggers the combined message send. | 895 // This triggers the combined message send. |
| 827 rvh()->AutocompleteSuggestionsReturned(std::vector<string16>()); | 896 rvh()->AutocompleteSuggestionsReturned(std::vector<string16>()); |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 851 ExpectSuggestions(page_id, values, labels, icons, unique_ids, | 920 ExpectSuggestions(page_id, values, labels, icons, unique_ids, |
| 852 kDefaultPageID, arraysize(expected_values), expected_values, | 921 kDefaultPageID, arraysize(expected_values), expected_values, |
| 853 expected_labels, expected_icons, expected_unique_ids); | 922 expected_labels, expected_icons, expected_unique_ids); |
| 854 } | 923 } |
| 855 | 924 |
| 856 // Test that we return a warning explaining that credit card profile suggestions | 925 // Test that we return a warning explaining that credit card profile suggestions |
| 857 // are unavailable when the form is not https. | 926 // are unavailable when the form is not https. |
| 858 TEST_F(AutoFillManagerTest, GetCreditCardSuggestionsNonHTTPS) { | 927 TEST_F(AutoFillManagerTest, GetCreditCardSuggestionsNonHTTPS) { |
| 859 // Set up our form data. | 928 // Set up our form data. |
| 860 FormData form; | 929 FormData form; |
| 861 CreateTestCreditCardFormData(&form, false); | 930 CreateTestCreditCardFormData(&form, false, false); |
| 862 std::vector<FormData> forms(1, form); | 931 std::vector<FormData> forms(1, form); |
| 863 autofill_manager_->FormsSeen(forms); | 932 autofill_manager_->FormsSeen(forms); |
| 864 | 933 |
| 865 const FormField& field = form.fields[0]; | 934 const FormField& field = form.fields[0]; |
| 866 rvh()->ResetAutoFillState(kDefaultPageID); | 935 rvh()->ResetAutoFillState(kDefaultPageID); |
| 867 EXPECT_TRUE(autofill_manager_->GetAutoFillSuggestions(form, field)); | 936 EXPECT_TRUE(autofill_manager_->GetAutoFillSuggestions(form, field)); |
| 868 | 937 |
| 869 // No suggestions provided, so send an empty vector as the results. | 938 // No suggestions provided, so send an empty vector as the results. |
| 870 // This triggers the combined message send. | 939 // This triggers the combined message send. |
| 871 rvh()->AutocompleteSuggestionsReturned(std::vector<string16>()); | 940 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. | 987 // Clear the test credit cards and try again -- we shouldn't return a warning. |
| 919 test_personal_data_->ClearCreditCards(); | 988 test_personal_data_->ClearCreditCards(); |
| 920 EXPECT_FALSE(autofill_manager_->GetAutoFillSuggestions(form, field)); | 989 EXPECT_FALSE(autofill_manager_->GetAutoFillSuggestions(form, field)); |
| 921 } | 990 } |
| 922 | 991 |
| 923 // Test that we return profile and credit card suggestions for combined forms. | 992 // Test that we return profile and credit card suggestions for combined forms. |
| 924 TEST_F(AutoFillManagerTest, GetAddressAndCreditCardSuggestions) { | 993 TEST_F(AutoFillManagerTest, GetAddressAndCreditCardSuggestions) { |
| 925 // Set up our form data. | 994 // Set up our form data. |
| 926 FormData form; | 995 FormData form; |
| 927 CreateTestAddressFormData(&form); | 996 CreateTestAddressFormData(&form); |
| 928 CreateTestCreditCardFormData(&form, true); | 997 CreateTestCreditCardFormData(&form, true, false); |
| 929 std::vector<FormData> forms(1, form); | 998 std::vector<FormData> forms(1, form); |
| 930 autofill_manager_->FormsSeen(forms); | 999 autofill_manager_->FormsSeen(forms); |
| 931 | 1000 |
| 932 FormField field = form.fields[0]; | 1001 FormField field = form.fields[0]; |
| 933 rvh()->ResetAutoFillState(kDefaultPageID); | 1002 rvh()->ResetAutoFillState(kDefaultPageID); |
| 934 EXPECT_TRUE(autofill_manager_->GetAutoFillSuggestions(form, field)); | 1003 EXPECT_TRUE(autofill_manager_->GetAutoFillSuggestions(form, field)); |
| 935 | 1004 |
| 936 // No suggestions provided, so send an empty vector as the results. | 1005 // No suggestions provided, so send an empty vector as the results. |
| 937 // This triggers the combined message send. | 1006 // This triggers the combined message send. |
| 938 rvh()->AutocompleteSuggestionsReturned(std::vector<string16>()); | 1007 rvh()->AutocompleteSuggestionsReturned(std::vector<string16>()); |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 995 } | 1064 } |
| 996 | 1065 |
| 997 // Test that for non-https forms with both address and credit card fields, we | 1066 // 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 | 1067 // only return address suggestions. Instead of credit card suggestions, we |
| 999 // should return a warning explaining that credit card profile suggestions are | 1068 // should return a warning explaining that credit card profile suggestions are |
| 1000 // unavailable when the form is not https. | 1069 // unavailable when the form is not https. |
| 1001 TEST_F(AutoFillManagerTest, GetAddressAndCreditCardSuggestionsNonHttps) { | 1070 TEST_F(AutoFillManagerTest, GetAddressAndCreditCardSuggestionsNonHttps) { |
| 1002 // Set up our form data. | 1071 // Set up our form data. |
| 1003 FormData form; | 1072 FormData form; |
| 1004 CreateTestAddressFormData(&form); | 1073 CreateTestAddressFormData(&form); |
| 1005 CreateTestCreditCardFormData(&form, false); | 1074 CreateTestCreditCardFormData(&form, false, false); |
| 1006 std::vector<FormData> forms(1, form); | 1075 std::vector<FormData> forms(1, form); |
| 1007 autofill_manager_->FormsSeen(forms); | 1076 autofill_manager_->FormsSeen(forms); |
| 1008 | 1077 |
| 1009 FormField field = form.fields[0]; | 1078 FormField field = form.fields[0]; |
| 1010 rvh()->ResetAutoFillState(kDefaultPageID); | 1079 rvh()->ResetAutoFillState(kDefaultPageID); |
| 1011 EXPECT_TRUE(autofill_manager_->GetAutoFillSuggestions(form, field)); | 1080 EXPECT_TRUE(autofill_manager_->GetAutoFillSuggestions(form, field)); |
| 1012 | 1081 |
| 1013 // No suggestions provided, so send an empty vector as the results. | 1082 // No suggestions provided, so send an empty vector as the results. |
| 1014 // This triggers the combined message send. | 1083 // This triggers the combined message send. |
| 1015 rvh()->AutocompleteSuggestionsReturned(std::vector<string16>()); | 1084 rvh()->AutocompleteSuggestionsReturned(std::vector<string16>()); |
| (...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1261 int page_id = 0; | 1330 int page_id = 0; |
| 1262 FormData results; | 1331 FormData results; |
| 1263 EXPECT_TRUE(GetAutoFillFormDataFilledMessage(&page_id, &results)); | 1332 EXPECT_TRUE(GetAutoFillFormDataFilledMessage(&page_id, &results)); |
| 1264 ExpectFilledAddressFormElvis(page_id, results, kDefaultPageID, false); | 1333 ExpectFilledAddressFormElvis(page_id, results, kDefaultPageID, false); |
| 1265 } | 1334 } |
| 1266 | 1335 |
| 1267 // Test that we correctly fill a credit card form. | 1336 // Test that we correctly fill a credit card form. |
| 1268 TEST_F(AutoFillManagerTest, FillCreditCardForm) { | 1337 TEST_F(AutoFillManagerTest, FillCreditCardForm) { |
| 1269 // Set up our form data. | 1338 // Set up our form data. |
| 1270 FormData form; | 1339 FormData form; |
| 1271 CreateTestCreditCardFormData(&form, true); | 1340 CreateTestCreditCardFormData(&form, true, false); |
| 1272 std::vector<FormData> forms(1, form); | 1341 std::vector<FormData> forms(1, form); |
| 1273 autofill_manager_->FormsSeen(forms); | 1342 autofill_manager_->FormsSeen(forms); |
| 1274 | 1343 |
| 1275 std::string guid = autofill_manager_->GetLabeledCreditCard("First")->guid(); | 1344 std::string guid = autofill_manager_->GetLabeledCreditCard("First")->guid(); |
| 1276 EXPECT_TRUE(autofill_manager_->FillAutoFillFormData( | 1345 EXPECT_TRUE(autofill_manager_->FillAutoFillFormData( |
| 1277 kDefaultPageID, form, *form.fields.begin(), | 1346 kDefaultPageID, form, *form.fields.begin(), |
| 1278 autofill_manager_->PackGUIDs(guid, std::string()))); | 1347 autofill_manager_->PackGUIDs(guid, std::string()))); |
| 1279 | 1348 |
| 1280 int page_id = 0; | 1349 int page_id = 0; |
| 1281 FormData results; | 1350 FormData results; |
| 1282 EXPECT_TRUE(GetAutoFillFormDataFilledMessage(&page_id, &results)); | 1351 EXPECT_TRUE(GetAutoFillFormDataFilledMessage(&page_id, &results)); |
| 1283 ExpectFilledCreditCardFormElvis(page_id, results, kDefaultPageID, false); | 1352 ExpectFilledCreditCardFormElvis(page_id, results, kDefaultPageID, false); |
| 1284 } | 1353 } |
| 1285 | 1354 |
| 1355 // Test that we correctly fill a credit card form with month input type. | |
| 1356 TEST_F(AutoFillManagerTest, FillCreditCardFormWithMonthInput) { | |
| 1357 for (int i = 0; i < 4; ++i) { | |
|
dhollowa
2011/01/07 03:47:15
Same here. I'd prefer to unroll the loop with the
Ilya Sherman
2011/01/07 07:28:28
I think it's reasonable to preserve the loop, but
honten.org
2011/01/07 08:06:17
I see... I'll change it again.
On 2011/01/07 07:2
dhollowa
2011/01/07 18:44:13
No, don't! No loops!
On 2011/01/07 08:06:17, hon
honten.org
2011/01/07 18:45:52
So... which should I choose????
Could you discuss
honten.org
2011/01/07 18:48:31
BTW, if the no-loop is fine, is my latest change O
dhollowa
2011/01/07 18:54:18
Yes, I like the latest unrolled version. Thanks.
Ilya Sherman
2011/01/10 20:08:48
Unrolled is fine. I prefer loops to extra boilerp
| |
| 1358 // Same as the SetUp(), but generate 4 credit cards with year month | |
| 1359 // combination. | |
| 1360 RenderViewHostTestHarness::SetUp(); | |
| 1361 test_personal_data_ = new TestPersonalDataManager(true); | |
| 1362 autofill_manager_.reset(new TestAutoFillManager(contents(), | |
| 1363 test_personal_data_.get())); | |
| 1364 | |
| 1365 // Set up our form data. | |
| 1366 FormData form; | |
| 1367 CreateTestCreditCardFormData(&form, true, true); | |
| 1368 std::vector<FormData> forms(1, form); | |
| 1369 autofill_manager_->FormsSeen(forms); | |
| 1370 | |
| 1371 std::string guid = autofill_manager_->GetLabeledCreditCard( | |
| 1372 base::StringPrintf("Miku%d", i).c_str())->guid(); | |
| 1373 EXPECT_TRUE(autofill_manager_->FillAutoFillFormData( | |
| 1374 kDefaultPageID, form, *form.fields.begin(), | |
| 1375 autofill_manager_->PackGUIDs(guid, std::string()))); | |
| 1376 | |
| 1377 int page_id = 0; | |
| 1378 FormData results; | |
| 1379 EXPECT_TRUE(GetAutoFillFormDataFilledMessage(&page_id, &results)); | |
| 1380 ExpectFilledCreditCardYearMonthWithIndex(page_id, results, kDefaultPageID, | |
| 1381 false, i); | |
| 1382 } | |
| 1383 } | |
| 1384 | |
| 1286 // Test that we correctly fill a combined address and credit card form. | 1385 // Test that we correctly fill a combined address and credit card form. |
| 1287 TEST_F(AutoFillManagerTest, FillAddressAndCreditCardForm) { | 1386 TEST_F(AutoFillManagerTest, FillAddressAndCreditCardForm) { |
| 1288 // Set up our form data. | 1387 // Set up our form data. |
| 1289 FormData form; | 1388 FormData form; |
| 1290 CreateTestAddressFormData(&form); | 1389 CreateTestAddressFormData(&form); |
| 1291 CreateTestCreditCardFormData(&form, true); | 1390 CreateTestCreditCardFormData(&form, true, false); |
| 1292 std::vector<FormData> forms(1, form); | 1391 std::vector<FormData> forms(1, form); |
| 1293 autofill_manager_->FormsSeen(forms); | 1392 autofill_manager_->FormsSeen(forms); |
| 1294 | 1393 |
| 1295 // First fill the address data. | 1394 // First fill the address data. |
| 1296 std::string guid = autofill_manager_->GetLabeledProfile("Home")->guid(); | 1395 std::string guid = autofill_manager_->GetLabeledProfile("Home")->guid(); |
| 1297 EXPECT_TRUE(autofill_manager_->FillAutoFillFormData( | 1396 EXPECT_TRUE(autofill_manager_->FillAutoFillFormData( |
| 1298 kDefaultPageID, form, form.fields[0], | 1397 kDefaultPageID, form, form.fields[0], |
| 1299 autofill_manager_->PackGUIDs(std::string(), guid))); | 1398 autofill_manager_->PackGUIDs(std::string(), guid))); |
| 1300 | 1399 |
| 1301 int page_id = 0; | 1400 int page_id = 0; |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 1322 } | 1421 } |
| 1323 } | 1422 } |
| 1324 | 1423 |
| 1325 // Test that we correctly fill a previously auto-filled form. | 1424 // Test that we correctly fill a previously auto-filled form. |
| 1326 TEST_F(AutoFillManagerTest, FillAutoFilledForm) { | 1425 TEST_F(AutoFillManagerTest, FillAutoFilledForm) { |
| 1327 // Set up our form data. | 1426 // Set up our form data. |
| 1328 FormData form; | 1427 FormData form; |
| 1329 CreateTestAddressFormData(&form); | 1428 CreateTestAddressFormData(&form); |
| 1330 // Mark one of the address fields as autofilled. | 1429 // Mark one of the address fields as autofilled. |
| 1331 form.fields[4].set_autofilled(true); | 1430 form.fields[4].set_autofilled(true); |
| 1332 CreateTestCreditCardFormData(&form, true); | 1431 CreateTestCreditCardFormData(&form, true, false); |
| 1333 std::vector<FormData> forms(1, form); | 1432 std::vector<FormData> forms(1, form); |
| 1334 autofill_manager_->FormsSeen(forms); | 1433 autofill_manager_->FormsSeen(forms); |
| 1335 | 1434 |
| 1336 // First fill the address data. | 1435 // First fill the address data. |
| 1337 std::string guid = autofill_manager_->GetLabeledProfile("Home")->guid(); | 1436 std::string guid = autofill_manager_->GetLabeledProfile("Home")->guid(); |
| 1338 EXPECT_TRUE(autofill_manager_->FillAutoFillFormData( | 1437 EXPECT_TRUE(autofill_manager_->FillAutoFillFormData( |
| 1339 kDefaultPageID, form, *form.fields.begin(), | 1438 kDefaultPageID, form, *form.fields.begin(), |
| 1340 autofill_manager_->PackGUIDs(std::string(), guid))); | 1439 autofill_manager_->PackGUIDs(std::string(), guid))); |
| 1341 | 1440 |
| 1342 int page_id = 0; | 1441 int page_id = 0; |
| 1343 FormData results; | 1442 FormData results; |
| 1344 EXPECT_TRUE(GetAutoFillFormDataFilledMessage(&page_id, &results)); | 1443 EXPECT_TRUE(GetAutoFillFormDataFilledMessage(&page_id, &results)); |
| 1345 { | 1444 { |
| 1346 SCOPED_TRACE("Address"); | 1445 SCOPED_TRACE("Address"); |
| 1347 ExpectFilledForm(page_id, results, kDefaultPageID, | 1446 ExpectFilledForm(page_id, results, kDefaultPageID, |
| 1348 "Elvis", "", "", "", "", "", "", "", "", "", "", "", | 1447 "Elvis", "", "", "", "", "", "", "", "", "", "", "", |
| 1349 "", "", "", "", true, true); | 1448 "", "", "", "", true, true, false); |
| 1350 } | 1449 } |
| 1351 | 1450 |
| 1352 // Now fill the credit card data. | 1451 // Now fill the credit card data. |
| 1353 process()->sink().ClearMessages(); | 1452 process()->sink().ClearMessages(); |
| 1354 const int kPageID2 = 2; | 1453 const int kPageID2 = 2; |
| 1355 guid = autofill_manager_->GetLabeledCreditCard("First")->guid(); | 1454 guid = autofill_manager_->GetLabeledCreditCard("First")->guid(); |
| 1356 EXPECT_TRUE(autofill_manager_->FillAutoFillFormData( | 1455 EXPECT_TRUE(autofill_manager_->FillAutoFillFormData( |
| 1357 kPageID2, form, form.fields.back(), | 1456 kPageID2, form, form.fields.back(), |
| 1358 autofill_manager_->PackGUIDs(guid, std::string()))); | 1457 autofill_manager_->PackGUIDs(guid, std::string()))); |
| 1359 | 1458 |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 1377 EXPECT_TRUE(autofill_manager_->FillAutoFillFormData( | 1476 EXPECT_TRUE(autofill_manager_->FillAutoFillFormData( |
| 1378 kPageID3, form, *form.fields.rbegin(), | 1477 kPageID3, form, *form.fields.rbegin(), |
| 1379 autofill_manager_->PackGUIDs(guid, std::string()))); | 1478 autofill_manager_->PackGUIDs(guid, std::string()))); |
| 1380 | 1479 |
| 1381 page_id = 0; | 1480 page_id = 0; |
| 1382 EXPECT_TRUE(GetAutoFillFormDataFilledMessage(&page_id, &results)); | 1481 EXPECT_TRUE(GetAutoFillFormDataFilledMessage(&page_id, &results)); |
| 1383 { | 1482 { |
| 1384 SCOPED_TRACE("Credit card 2"); | 1483 SCOPED_TRACE("Credit card 2"); |
| 1385 ExpectFilledForm(page_id, results, kPageID3, | 1484 ExpectFilledForm(page_id, results, kPageID3, |
| 1386 "", "", "", "", "", "", "", "", "", "", "", "", | 1485 "", "", "", "", "", "", "", "", "", "", "", "", |
| 1387 "", "", "", "2012", true, true); | 1486 "", "", "", "2012", true, true, false); |
| 1388 } | 1487 } |
| 1389 } | 1488 } |
| 1390 | 1489 |
| 1391 // Test that we correctly fill a phone number split across multiple fields. | 1490 // Test that we correctly fill a phone number split across multiple fields. |
| 1392 TEST_F(AutoFillManagerTest, FillPhoneNumber) { | 1491 TEST_F(AutoFillManagerTest, FillPhoneNumber) { |
| 1393 // Set up our form data. | 1492 // Set up our form data. |
| 1394 FormData form; | 1493 FormData form; |
| 1395 form.name = ASCIIToUTF16("MyPhoneForm"); | 1494 form.name = ASCIIToUTF16("MyPhoneForm"); |
| 1396 form.method = ASCIIToUTF16("POST"); | 1495 form.method = ASCIIToUTF16("POST"); |
| 1397 form.origin = GURL("http://myform.com/phone_form.html"); | 1496 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( | 1662 ASSERT_FALSE(profile()->GetPrefs()->GetBoolean( |
| 1564 prefs::kAutoFillAuxiliaryProfilesEnabled)); | 1663 prefs::kAutoFillAuxiliaryProfilesEnabled)); |
| 1565 profile()->GetPrefs()->SetBoolean( | 1664 profile()->GetPrefs()->SetBoolean( |
| 1566 prefs::kAutoFillAuxiliaryProfilesEnabled, true); | 1665 prefs::kAutoFillAuxiliaryProfilesEnabled, true); |
| 1567 profile()->GetPrefs()->ClearPref(prefs::kAutoFillAuxiliaryProfilesEnabled); | 1666 profile()->GetPrefs()->ClearPref(prefs::kAutoFillAuxiliaryProfilesEnabled); |
| 1568 ASSERT_FALSE(profile()->GetPrefs()->GetBoolean( | 1667 ASSERT_FALSE(profile()->GetPrefs()->GetBoolean( |
| 1569 prefs::kAutoFillAuxiliaryProfilesEnabled)); | 1668 prefs::kAutoFillAuxiliaryProfilesEnabled)); |
| 1570 #endif | 1669 #endif |
| 1571 } | 1670 } |
| 1572 | 1671 |
| OLD | NEW |