| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 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 <string> | 5 #include <string> |
| 6 | 6 |
| 7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/files/file_util.h" | 9 #include "base/files/file_util.h" |
| 10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
| (...skipping 469 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 480 ASSERT_EQ(card, *personal_data_manager()->GetCreditCards()[0]); | 480 ASSERT_EQ(card, *personal_data_manager()->GetCreditCards()[0]); |
| 481 } | 481 } |
| 482 | 482 |
| 483 // Test credit card info with an invalid number is not aggregated. | 483 // Test credit card info with an invalid number is not aggregated. |
| 484 // When filling out a form with an invalid credit card number (one that does not | 484 // When filling out a form with an invalid credit card number (one that does not |
| 485 // pass the Luhn test) the credit card info should not be saved into Autofill | 485 // pass the Luhn test) the credit card info should not be saved into Autofill |
| 486 // preferences. | 486 // preferences. |
| 487 IN_PROC_BROWSER_TEST_F(AutofillTest, InvalidCreditCardNumberIsNotAggregated) { | 487 IN_PROC_BROWSER_TEST_F(AutofillTest, InvalidCreditCardNumberIsNotAggregated) { |
| 488 #if defined(OS_WIN) && defined(USE_ASH) | 488 #if defined(OS_WIN) && defined(USE_ASH) |
| 489 // Disable this test in Metro+Ash for now (http://crbug.com/262796). | 489 // Disable this test in Metro+Ash for now (http://crbug.com/262796). |
| 490 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kAshBrowserTests)) | 490 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 491 switches::kAshBrowserTests)) |
| 491 return; | 492 return; |
| 492 #endif | 493 #endif |
| 493 | 494 |
| 494 ASSERT_TRUE(test_server()->Start()); | 495 ASSERT_TRUE(test_server()->Start()); |
| 495 std::string card("4408 0412 3456 7890"); | 496 std::string card("4408 0412 3456 7890"); |
| 496 ASSERT_FALSE(autofill::IsValidCreditCardNumber(ASCIIToUTF16(card))); | 497 ASSERT_FALSE(autofill::IsValidCreditCardNumber(ASCIIToUTF16(card))); |
| 497 SubmitCreditCard("Bob Smith", card.c_str(), "12", "2014"); | 498 SubmitCreditCard("Bob Smith", card.c_str(), "12", "2014"); |
| 498 InfoBarService* infobar_service = InfoBarService::FromWebContents( | 499 InfoBarService* infobar_service = InfoBarService::FromWebContents( |
| 499 browser()->tab_strip_model()->GetActiveWebContents()); | 500 browser()->tab_strip_model()->GetActiveWebContents()); |
| 500 ASSERT_EQ(0u, infobar_service->infobar_count()); | 501 ASSERT_EQ(0u, infobar_service->infobar_count()); |
| 501 } | 502 } |
| 502 | 503 |
| 503 // Test whitespaces and separator chars are stripped for valid CC numbers. | 504 // Test whitespaces and separator chars are stripped for valid CC numbers. |
| 504 // The credit card numbers used in this test pass the Luhn test. For reference: | 505 // The credit card numbers used in this test pass the Luhn test. For reference: |
| 505 // http://www.merriampark.com/anatomycc.htm | 506 // http://www.merriampark.com/anatomycc.htm |
| 506 IN_PROC_BROWSER_TEST_F(AutofillTest, | 507 IN_PROC_BROWSER_TEST_F(AutofillTest, |
| 507 WhitespacesAndSeparatorCharsStrippedForValidCCNums) { | 508 WhitespacesAndSeparatorCharsStrippedForValidCCNums) { |
| 508 #if defined(OS_WIN) && defined(USE_ASH) | 509 #if defined(OS_WIN) && defined(USE_ASH) |
| 509 // Disable this test in Metro+Ash for now (http://crbug.com/262796). | 510 // Disable this test in Metro+Ash for now (http://crbug.com/262796). |
| 510 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kAshBrowserTests)) | 511 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 512 switches::kAshBrowserTests)) |
| 511 return; | 513 return; |
| 512 #endif | 514 #endif |
| 513 | 515 |
| 514 ASSERT_TRUE(test_server()->Start()); | 516 ASSERT_TRUE(test_server()->Start()); |
| 515 SubmitCreditCard("Bob Smith", "4408 0412 3456 7893", "12", "2014"); | 517 SubmitCreditCard("Bob Smith", "4408 0412 3456 7893", "12", "2014"); |
| 516 SubmitCreditCard("Jane Doe", "4417-1234-5678-9113", "10", "2013"); | 518 SubmitCreditCard("Jane Doe", "4417-1234-5678-9113", "10", "2013"); |
| 517 | 519 |
| 518 ASSERT_EQ(2u, personal_data_manager()->GetCreditCards().size()); | 520 ASSERT_EQ(2u, personal_data_manager()->GetCreditCards().size()); |
| 519 base::string16 cc1 = personal_data_manager()->GetCreditCards()[0]->GetRawInfo( | 521 base::string16 cc1 = personal_data_manager()->GetCreditCards()[0]->GetRawInfo( |
| 520 CREDIT_CARD_NUMBER); | 522 CREDIT_CARD_NUMBER); |
| (...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 762 } | 764 } |
| 763 } | 765 } |
| 764 | 766 |
| 765 // Test CC info not offered to be saved when autocomplete=off for CC field. | 767 // Test CC info not offered to be saved when autocomplete=off for CC field. |
| 766 // If the credit card number field has autocomplete turned off, then the credit | 768 // If the credit card number field has autocomplete turned off, then the credit |
| 767 // card infobar should not offer to save the credit card info. The credit card | 769 // card infobar should not offer to save the credit card info. The credit card |
| 768 // number must be a valid Luhn number. | 770 // number must be a valid Luhn number. |
| 769 IN_PROC_BROWSER_TEST_F(AutofillTest, CCInfoNotStoredWhenAutocompleteOff) { | 771 IN_PROC_BROWSER_TEST_F(AutofillTest, CCInfoNotStoredWhenAutocompleteOff) { |
| 770 #if defined(OS_WIN) && defined(USE_ASH) | 772 #if defined(OS_WIN) && defined(USE_ASH) |
| 771 // Disable this test in Metro+Ash for now (http://crbug.com/262796). | 773 // Disable this test in Metro+Ash for now (http://crbug.com/262796). |
| 772 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kAshBrowserTests)) | 774 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 775 switches::kAshBrowserTests)) |
| 773 return; | 776 return; |
| 774 #endif | 777 #endif |
| 775 | 778 |
| 776 ASSERT_TRUE(test_server()->Start()); | 779 ASSERT_TRUE(test_server()->Start()); |
| 777 FormMap data; | 780 FormMap data; |
| 778 data["CREDIT_CARD_NAME"] = "Bob Smith"; | 781 data["CREDIT_CARD_NAME"] = "Bob Smith"; |
| 779 data["CREDIT_CARD_NUMBER"] = "4408041234567893"; | 782 data["CREDIT_CARD_NUMBER"] = "4408041234567893"; |
| 780 data["CREDIT_CARD_EXP_MONTH"] = "12"; | 783 data["CREDIT_CARD_EXP_MONTH"] = "12"; |
| 781 data["CREDIT_CARD_EXP_4_DIGIT_YEAR"] = "2014"; | 784 data["CREDIT_CARD_EXP_4_DIGIT_YEAR"] = "2014"; |
| 782 FillFormAndSubmit("cc_autocomplete_off_test.html", data); | 785 FillFormAndSubmit("cc_autocomplete_off_test.html", data); |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 835 IN_PROC_BROWSER_TEST_F(AutofillTest, | 838 IN_PROC_BROWSER_TEST_F(AutofillTest, |
| 836 DISABLED_MergeAggregatedDuplicatedProfiles) { | 839 DISABLED_MergeAggregatedDuplicatedProfiles) { |
| 837 int num_of_profiles = | 840 int num_of_profiles = |
| 838 AggregateProfilesIntoAutofillPrefs("dataset_duplicated_profiles.txt"); | 841 AggregateProfilesIntoAutofillPrefs("dataset_duplicated_profiles.txt"); |
| 839 | 842 |
| 840 ASSERT_GT(num_of_profiles, | 843 ASSERT_GT(num_of_profiles, |
| 841 static_cast<int>(personal_data_manager()->GetProfiles().size())); | 844 static_cast<int>(personal_data_manager()->GetProfiles().size())); |
| 842 } | 845 } |
| 843 | 846 |
| 844 } // namespace autofill | 847 } // namespace autofill |
| OLD | NEW |