OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 <stddef.h> | 5 #include <stddef.h> |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 namespace { | 61 namespace { |
62 | 62 |
63 const int kDefaultPageID = 137; | 63 const int kDefaultPageID = 137; |
64 | 64 |
65 class MockAutofillClient : public TestAutofillClient { | 65 class MockAutofillClient : public TestAutofillClient { |
66 public: | 66 public: |
67 MockAutofillClient() {} | 67 MockAutofillClient() {} |
68 | 68 |
69 ~MockAutofillClient() override {} | 69 ~MockAutofillClient() override {} |
70 | 70 |
71 MOCK_METHOD1(ConfirmSaveCreditCardLocally, | 71 MOCK_METHOD2(ConfirmSaveCreditCardLocally, |
72 void(const base::Closure& callback)); | 72 void(const CreditCard& card, const base::Closure& callback)); |
73 | 73 |
74 private: | 74 private: |
75 DISALLOW_COPY_AND_ASSIGN(MockAutofillClient); | 75 DISALLOW_COPY_AND_ASSIGN(MockAutofillClient); |
76 }; | 76 }; |
77 | 77 |
78 class TestPaymentsClient : public payments::PaymentsClient { | 78 class TestPaymentsClient : public payments::PaymentsClient { |
79 public: | 79 public: |
80 TestPaymentsClient(net::URLRequestContextGetter* context_getter, | 80 TestPaymentsClient(net::URLRequestContextGetter* context_getter, |
81 payments::PaymentsClientDelegate* delegate) | 81 payments::PaymentsClientDelegate* delegate) |
82 : PaymentsClient(context_getter, delegate), delegate_(delegate) {} | 82 : PaymentsClient(context_getter, delegate), delegate_(delegate) {} |
(...skipping 788 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
871 // Set up our form data. | 871 // Set up our form data. |
872 FormData form; | 872 FormData form; |
873 CreateTestCreditCardFormData(&form, is_https, false); | 873 CreateTestCreditCardFormData(&form, is_https, false); |
874 std::vector<FormData> forms(1, form); | 874 std::vector<FormData> forms(1, form); |
875 FormsSeen(forms); | 875 FormsSeen(forms); |
876 | 876 |
877 // Edit the data, and submit | 877 // Edit the data, and submit |
878 form.fields[1].value = ASCIIToUTF16("4111111111111111"); | 878 form.fields[1].value = ASCIIToUTF16("4111111111111111"); |
879 form.fields[2].value = ASCIIToUTF16("11"); | 879 form.fields[2].value = ASCIIToUTF16("11"); |
880 form.fields[3].value = ASCIIToUTF16("2017"); | 880 form.fields[3].value = ASCIIToUTF16("2017"); |
881 EXPECT_CALL(autofill_client_, ConfirmSaveCreditCardLocally(_)).Times(1); | 881 EXPECT_CALL(autofill_client_, ConfirmSaveCreditCardLocally(_, _)); |
882 FormSubmitted(form); | 882 FormSubmitted(form); |
883 } | 883 } |
884 | 884 |
885 void PrepareForRealPanResponse(FormData* form, CreditCard* card) { | 885 void PrepareForRealPanResponse(FormData* form, CreditCard* card) { |
886 // This line silences the warning from PaymentsClient about matching sync | 886 // This line silences the warning from PaymentsClient about matching sync |
887 // and Payments server types. | 887 // and Payments server types. |
888 base::CommandLine::ForCurrentProcess()->AppendSwitchASCII( | 888 base::CommandLine::ForCurrentProcess()->AppendSwitchASCII( |
889 "sync-url", "https://google.com"); | 889 "sync-url", "https://google.com"); |
890 | 890 |
891 CreateTestCreditCardFormData(form, true, false); | 891 CreateTestCreditCardFormData(form, true, false); |
892 FormsSeen(std::vector<FormData>(1, *form)); | 892 FormsSeen(std::vector<FormData>(1, *form)); |
893 *card = CreditCard(CreditCard::MASKED_SERVER_CARD, "a123"); | 893 *card = CreditCard(CreditCard::MASKED_SERVER_CARD, "a123"); |
894 test::SetCreditCardInfo(card, "John Dillinger", "1881" /* Visa */, "01", | 894 test::SetCreditCardInfo(card, "John Dillinger", "1881" /* Visa */, "01", |
895 "2017"); | 895 "2017"); |
896 card->SetTypeForMaskedCard(kVisaCard); | 896 card->SetTypeForMaskedCard(kVisaCard); |
897 | 897 |
898 EXPECT_CALL(autofill_client_, ConfirmSaveCreditCardLocally(_)).Times(0); | 898 EXPECT_CALL(autofill_client_, ConfirmSaveCreditCardLocally(_, _)).Times(0); |
899 EXPECT_CALL(*autofill_driver_, SendFormDataToRenderer(_, _, _)) | 899 EXPECT_CALL(*autofill_driver_, SendFormDataToRenderer(_, _, _)) |
900 .Times(AtLeast(1)); | 900 .Times(AtLeast(1)); |
901 autofill_manager_->FillOrPreviewCreditCardForm( | 901 autofill_manager_->FillOrPreviewCreditCardForm( |
902 AutofillDriver::FORM_DATA_ACTION_FILL, kDefaultPageID, *form, | 902 AutofillDriver::FORM_DATA_ACTION_FILL, kDefaultPageID, *form, |
903 form->fields[0], *card); | 903 form->fields[0], *card); |
904 | 904 |
905 #if defined(OS_IOS) | 905 #if defined(OS_IOS) |
906 // Filling out the entire form on iOS requires requesting autofill on each | 906 // Filling out the entire form on iOS requires requesting autofill on each |
907 // of the form fields. | 907 // of the form fields. |
908 autofill_manager_->FillOrPreviewCreditCardForm( | 908 autofill_manager_->FillOrPreviewCreditCardForm( |
(...skipping 1680 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2589 autofill_manager_->set_autofill_enabled(false); | 2589 autofill_manager_->set_autofill_enabled(false); |
2590 autofill_manager_->autocomplete_history_manager_.reset( | 2590 autofill_manager_->autocomplete_history_manager_.reset( |
2591 new MockAutocompleteHistoryManager(autofill_driver_.get(), &client)); | 2591 new MockAutocompleteHistoryManager(autofill_driver_.get(), &client)); |
2592 | 2592 |
2593 // Set up our form data. | 2593 // Set up our form data. |
2594 FormData form; | 2594 FormData form; |
2595 test::CreateTestAddressFormData(&form); | 2595 test::CreateTestAddressFormData(&form); |
2596 MockAutocompleteHistoryManager* m = static_cast< | 2596 MockAutocompleteHistoryManager* m = static_cast< |
2597 MockAutocompleteHistoryManager*>( | 2597 MockAutocompleteHistoryManager*>( |
2598 autofill_manager_->autocomplete_history_manager_.get()); | 2598 autofill_manager_->autocomplete_history_manager_.get()); |
2599 EXPECT_CALL(*m, OnWillSubmitForm(_)).Times(1); | 2599 EXPECT_CALL(*m, OnWillSubmitForm(_)); |
2600 FormSubmitted(form); | 2600 FormSubmitted(form); |
2601 } | 2601 } |
2602 | 2602 |
2603 // Test that when Autofill is disabled, Autocomplete suggestions are still | 2603 // Test that when Autofill is disabled, Autocomplete suggestions are still |
2604 // queried. | 2604 // queried. |
2605 TEST_F(AutofillManagerTest, AutocompleteSuggestions_SomeWhenAutofillDisabled) { | 2605 TEST_F(AutofillManagerTest, AutocompleteSuggestions_SomeWhenAutofillDisabled) { |
2606 TestAutofillClient client; | 2606 TestAutofillClient client; |
2607 autofill_manager_.reset( | 2607 autofill_manager_.reset( |
2608 new TestAutofillManager(autofill_driver_.get(), &client, NULL)); | 2608 new TestAutofillManager(autofill_driver_.get(), &client, NULL)); |
2609 autofill_manager_->set_autofill_enabled(false); | 2609 autofill_manager_->set_autofill_enabled(false); |
2610 autofill_manager_->SetExternalDelegate(external_delegate_.get()); | 2610 autofill_manager_->SetExternalDelegate(external_delegate_.get()); |
2611 | 2611 |
2612 // Set up our form data. | 2612 // Set up our form data. |
2613 FormData form; | 2613 FormData form; |
2614 test::CreateTestAddressFormData(&form); | 2614 test::CreateTestAddressFormData(&form); |
2615 std::vector<FormData> forms(1, form); | 2615 std::vector<FormData> forms(1, form); |
2616 FormsSeen(forms); | 2616 FormsSeen(forms); |
2617 const FormFieldData& field = form.fields[0]; | 2617 const FormFieldData& field = form.fields[0]; |
2618 | 2618 |
2619 // Expect Autocomplete manager to be called for suggestions. | 2619 // Expect Autocomplete manager to be called for suggestions. |
2620 autofill_manager_->autocomplete_history_manager_.reset( | 2620 autofill_manager_->autocomplete_history_manager_.reset( |
2621 new MockAutocompleteHistoryManager(autofill_driver_.get(), &client)); | 2621 new MockAutocompleteHistoryManager(autofill_driver_.get(), &client)); |
2622 MockAutocompleteHistoryManager* m = static_cast< | 2622 MockAutocompleteHistoryManager* m = static_cast< |
2623 MockAutocompleteHistoryManager*>( | 2623 MockAutocompleteHistoryManager*>( |
2624 autofill_manager_->autocomplete_history_manager_.get()); | 2624 autofill_manager_->autocomplete_history_manager_.get()); |
2625 EXPECT_CALL(*m, | 2625 EXPECT_CALL(*m, |
2626 OnGetAutocompleteSuggestions(_, _, _, _)).Times(1); | 2626 OnGetAutocompleteSuggestions(_, _, _, _)); |
2627 | 2627 |
2628 GetAutofillSuggestions(form, field); | 2628 GetAutofillSuggestions(form, field); |
2629 } | 2629 } |
2630 | 2630 |
2631 // Test that when Autofill is disabled and the field should not autocomplete, | 2631 // Test that when Autofill is disabled and the field should not autocomplete, |
2632 // autocomplete is not queried for suggestions. | 2632 // autocomplete is not queried for suggestions. |
2633 TEST_F(AutofillManagerTest, | 2633 TEST_F(AutofillManagerTest, |
2634 AutocompleteSuggestions_AutofillDisabledAndFieldShouldNotAutocomplete) { | 2634 AutocompleteSuggestions_AutofillDisabledAndFieldShouldNotAutocomplete) { |
2635 TestAutofillClient client; | 2635 TestAutofillClient client; |
2636 autofill_manager_.reset( | 2636 autofill_manager_.reset( |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2703 test::CreateTestFormField("Email", "email", "donkey", "email", &field); | 2703 test::CreateTestFormField("Email", "email", "donkey", "email", &field); |
2704 | 2704 |
2705 // Autocomplete manager is called for suggestions because Autofill is empty. | 2705 // Autocomplete manager is called for suggestions because Autofill is empty. |
2706 autofill_manager_->autocomplete_history_manager_.reset( | 2706 autofill_manager_->autocomplete_history_manager_.reset( |
2707 new MockAutocompleteHistoryManager(autofill_driver_.get(), | 2707 new MockAutocompleteHistoryManager(autofill_driver_.get(), |
2708 autofill_manager_->client())); | 2708 autofill_manager_->client())); |
2709 MockAutocompleteHistoryManager* m = static_cast< | 2709 MockAutocompleteHistoryManager* m = static_cast< |
2710 MockAutocompleteHistoryManager*>( | 2710 MockAutocompleteHistoryManager*>( |
2711 autofill_manager_->autocomplete_history_manager_.get()); | 2711 autofill_manager_->autocomplete_history_manager_.get()); |
2712 EXPECT_CALL(*m, | 2712 EXPECT_CALL(*m, |
2713 OnGetAutocompleteSuggestions(_, _, _, _)).Times(1); | 2713 OnGetAutocompleteSuggestions(_, _, _, _)); |
2714 | 2714 |
2715 GetAutofillSuggestions(form, field); | 2715 GetAutofillSuggestions(form, field); |
2716 } | 2716 } |
2717 | 2717 |
2718 // Test that we do not query for Autocomplete suggestions when there are no | 2718 // Test that we do not query for Autocomplete suggestions when there are no |
2719 // Autofill suggestions available, and that the field should not autocomplete. | 2719 // Autofill suggestions available, and that the field should not autocomplete. |
2720 TEST_F( | 2720 TEST_F( |
2721 AutofillManagerTest, | 2721 AutofillManagerTest, |
2722 AutocompleteSuggestions_NoneWhenAutofillEmptyFieldShouldNotAutocomplete) { | 2722 AutocompleteSuggestions_NoneWhenAutofillEmptyFieldShouldNotAutocomplete) { |
2723 // Set up our form data. | 2723 // Set up our form data. |
(...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3040 // Set "autocomplete=off" for cardnumber field. | 3040 // Set "autocomplete=off" for cardnumber field. |
3041 form.fields[1].should_autocomplete = false; | 3041 form.fields[1].should_autocomplete = false; |
3042 | 3042 |
3043 std::vector<FormData> forms(1, form); | 3043 std::vector<FormData> forms(1, form); |
3044 FormsSeen(forms); | 3044 FormsSeen(forms); |
3045 | 3045 |
3046 // Edit the data, and submit | 3046 // Edit the data, and submit |
3047 form.fields[1].value = ASCIIToUTF16("4111111111111111"); | 3047 form.fields[1].value = ASCIIToUTF16("4111111111111111"); |
3048 form.fields[2].value = ASCIIToUTF16("11"); | 3048 form.fields[2].value = ASCIIToUTF16("11"); |
3049 form.fields[3].value = ASCIIToUTF16("2017"); | 3049 form.fields[3].value = ASCIIToUTF16("2017"); |
3050 EXPECT_CALL(autofill_client_, ConfirmSaveCreditCardLocally(_)).Times(1); | 3050 EXPECT_CALL(autofill_client_, ConfirmSaveCreditCardLocally(_, _)); |
3051 FormSubmitted(form); | 3051 FormSubmitted(form); |
3052 } | 3052 } |
3053 | 3053 |
3054 // Tests that credit card data are not saved when CC number does not pass the | 3054 // Tests that credit card data are not saved when CC number does not pass the |
3055 // Luhn test. | 3055 // Luhn test. |
3056 TEST_F(AutofillManagerTest, InvalidCreditCardNumberIsNotSaved) { | 3056 TEST_F(AutofillManagerTest, InvalidCreditCardNumberIsNotSaved) { |
3057 // Set up our form data. | 3057 // Set up our form data. |
3058 FormData form; | 3058 FormData form; |
3059 CreateTestCreditCardFormData(&form, true, false); | 3059 CreateTestCreditCardFormData(&form, true, false); |
3060 std::vector<FormData> forms(1, form); | 3060 std::vector<FormData> forms(1, form); |
3061 FormsSeen(forms); | 3061 FormsSeen(forms); |
3062 | 3062 |
3063 // Edit the data, and submit. | 3063 // Edit the data, and submit. |
3064 std::string card("4408041234567890"); | 3064 std::string card("4408041234567890"); |
3065 ASSERT_FALSE(autofill::IsValidCreditCardNumber(ASCIIToUTF16(card))); | 3065 ASSERT_FALSE(autofill::IsValidCreditCardNumber(ASCIIToUTF16(card))); |
3066 form.fields[1].value = ASCIIToUTF16(card); | 3066 form.fields[1].value = ASCIIToUTF16(card); |
3067 form.fields[2].value = ASCIIToUTF16("11"); | 3067 form.fields[2].value = ASCIIToUTF16("11"); |
3068 form.fields[3].value = ASCIIToUTF16("2017"); | 3068 form.fields[3].value = ASCIIToUTF16("2017"); |
3069 EXPECT_CALL(autofill_client_, ConfirmSaveCreditCardLocally(_)).Times(0); | 3069 EXPECT_CALL(autofill_client_, ConfirmSaveCreditCardLocally(_, _)).Times(0); |
3070 FormSubmitted(form); | 3070 FormSubmitted(form); |
3071 } | 3071 } |
3072 | 3072 |
3073 // Tests that DeterminePossibleFieldTypesForUpload makes accurate matches. | 3073 // Tests that DeterminePossibleFieldTypesForUpload makes accurate matches. |
3074 TEST_F(AutofillManagerTest, DeterminePossibleFieldTypesForUpload) { | 3074 TEST_F(AutofillManagerTest, DeterminePossibleFieldTypesForUpload) { |
3075 // Set up the test profiles. | 3075 // Set up the test profiles. |
3076 std::vector<AutofillProfile> profiles; | 3076 std::vector<AutofillProfile> profiles; |
3077 AutofillProfile profile; | 3077 AutofillProfile profile; |
3078 test::SetProfileInfo(&profile, "Elvis", "Aaron", "Presley", | 3078 test::SetProfileInfo(&profile, "Elvis", "Aaron", "Presley", |
3079 "theking@gmail.com", "RCA", "3734 Elvis Presley Blvd.", | 3079 "theking@gmail.com", "RCA", "3734 Elvis Presley Blvd.", |
(...skipping 578 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3658 // Edit the data, and submit | 3658 // Edit the data, and submit |
3659 credit_card_form.fields[0].value = ASCIIToUTF16("Flo Master"); | 3659 credit_card_form.fields[0].value = ASCIIToUTF16("Flo Master"); |
3660 credit_card_form.fields[1].value = ASCIIToUTF16("4111111111111111"); | 3660 credit_card_form.fields[1].value = ASCIIToUTF16("4111111111111111"); |
3661 credit_card_form.fields[2].value = ASCIIToUTF16("11"); | 3661 credit_card_form.fields[2].value = ASCIIToUTF16("11"); |
3662 credit_card_form.fields[3].value = ASCIIToUTF16("2017"); | 3662 credit_card_form.fields[3].value = ASCIIToUTF16("2017"); |
3663 credit_card_form.fields[4].value = ASCIIToUTF16("123"); | 3663 credit_card_form.fields[4].value = ASCIIToUTF16("123"); |
3664 | 3664 |
3665 base::HistogramTester histogram_tester; | 3665 base::HistogramTester histogram_tester; |
3666 | 3666 |
3667 // The save prompt should be shown instead of doing an upload. | 3667 // The save prompt should be shown instead of doing an upload. |
3668 EXPECT_CALL(autofill_client_, ConfirmSaveCreditCardLocally(_)).Times(1); | 3668 EXPECT_CALL(autofill_client_, ConfirmSaveCreditCardLocally(_, _)); |
3669 FormSubmitted(credit_card_form); | 3669 FormSubmitted(credit_card_form); |
3670 EXPECT_FALSE(autofill_manager_->credit_card_was_uploaded()); | 3670 EXPECT_FALSE(autofill_manager_->credit_card_was_uploaded()); |
3671 | 3671 |
3672 // Verify that no histogram entry was logged called. | 3672 // Verify that no histogram entry was logged called. |
3673 histogram_tester.ExpectTotalCount("Autofill.CardUploadDecision", 0); | 3673 histogram_tester.ExpectTotalCount("Autofill.CardUploadDecision", 0); |
3674 } | 3674 } |
3675 | 3675 |
3676 TEST_F(AutofillManagerTest, DontUploadCreditCardIfCvcUnavailable) { | 3676 TEST_F(AutofillManagerTest, DontUploadCreditCardIfCvcUnavailable) { |
3677 autofill_manager_->set_credit_card_upload_enabled(true); | 3677 autofill_manager_->set_credit_card_upload_enabled(true); |
3678 | 3678 |
(...skipping 13 matching lines...) Expand all Loading... |
3692 // Edit the data, and submit | 3692 // Edit the data, and submit |
3693 credit_card_form.fields[0].value = ASCIIToUTF16("Flo Master"); | 3693 credit_card_form.fields[0].value = ASCIIToUTF16("Flo Master"); |
3694 credit_card_form.fields[1].value = ASCIIToUTF16("4111111111111111"); | 3694 credit_card_form.fields[1].value = ASCIIToUTF16("4111111111111111"); |
3695 credit_card_form.fields[2].value = ASCIIToUTF16("11"); | 3695 credit_card_form.fields[2].value = ASCIIToUTF16("11"); |
3696 credit_card_form.fields[3].value = ASCIIToUTF16("2017"); | 3696 credit_card_form.fields[3].value = ASCIIToUTF16("2017"); |
3697 credit_card_form.fields[4].value = ASCIIToUTF16(""); // CVC MISSING | 3697 credit_card_form.fields[4].value = ASCIIToUTF16(""); // CVC MISSING |
3698 | 3698 |
3699 base::HistogramTester histogram_tester; | 3699 base::HistogramTester histogram_tester; |
3700 | 3700 |
3701 // Neither a local save nor an upload should happen in this case. | 3701 // Neither a local save nor an upload should happen in this case. |
3702 EXPECT_CALL(autofill_client_, ConfirmSaveCreditCardLocally(_)).Times(0); | 3702 EXPECT_CALL(autofill_client_, ConfirmSaveCreditCardLocally(_, _)).Times(0); |
3703 FormSubmitted(credit_card_form); | 3703 FormSubmitted(credit_card_form); |
3704 EXPECT_FALSE(autofill_manager_->credit_card_was_uploaded()); | 3704 EXPECT_FALSE(autofill_manager_->credit_card_was_uploaded()); |
3705 | 3705 |
3706 // Verify that the correct histogram entry (and only that) was logged. | 3706 // Verify that the correct histogram entry (and only that) was logged. |
3707 histogram_tester.ExpectUniqueSample( | 3707 histogram_tester.ExpectUniqueSample( |
3708 "Autofill.CardUploadDecision", AutofillMetrics::UPLOAD_NOT_OFFERED_NO_CVC, | 3708 "Autofill.CardUploadDecision", AutofillMetrics::UPLOAD_NOT_OFFERED_NO_CVC, |
3709 1); | 3709 1); |
3710 } | 3710 } |
3711 | 3711 |
3712 TEST_F(AutofillManagerTest, DontUploadCreditCardIfNoMatchingProfileAvailable) { | 3712 TEST_F(AutofillManagerTest, DontUploadCreditCardIfNoMatchingProfileAvailable) { |
(...skipping 16 matching lines...) Expand all Loading... |
3729 // The address form has "Flo Master" but the credit card has "Bob Master". | 3729 // The address form has "Flo Master" but the credit card has "Bob Master". |
3730 credit_card_form.fields[0].value = ASCIIToUTF16("Bob Master"); | 3730 credit_card_form.fields[0].value = ASCIIToUTF16("Bob Master"); |
3731 credit_card_form.fields[1].value = ASCIIToUTF16("4111111111111111"); | 3731 credit_card_form.fields[1].value = ASCIIToUTF16("4111111111111111"); |
3732 credit_card_form.fields[2].value = ASCIIToUTF16("11"); | 3732 credit_card_form.fields[2].value = ASCIIToUTF16("11"); |
3733 credit_card_form.fields[3].value = ASCIIToUTF16("2017"); | 3733 credit_card_form.fields[3].value = ASCIIToUTF16("2017"); |
3734 credit_card_form.fields[4].value = ASCIIToUTF16("123"); | 3734 credit_card_form.fields[4].value = ASCIIToUTF16("123"); |
3735 | 3735 |
3736 base::HistogramTester histogram_tester; | 3736 base::HistogramTester histogram_tester; |
3737 | 3737 |
3738 // Neither a local save nor an upload should happen in this case. | 3738 // Neither a local save nor an upload should happen in this case. |
3739 EXPECT_CALL(autofill_client_, ConfirmSaveCreditCardLocally(_)).Times(0); | 3739 EXPECT_CALL(autofill_client_, ConfirmSaveCreditCardLocally(_, _)).Times(0); |
3740 FormSubmitted(credit_card_form); | 3740 FormSubmitted(credit_card_form); |
3741 EXPECT_FALSE(autofill_manager_->credit_card_was_uploaded()); | 3741 EXPECT_FALSE(autofill_manager_->credit_card_was_uploaded()); |
3742 | 3742 |
3743 // Verify that the correct histogram entry (and only that) was logged. | 3743 // Verify that the correct histogram entry (and only that) was logged. |
3744 histogram_tester.ExpectUniqueSample( | 3744 histogram_tester.ExpectUniqueSample( |
3745 "Autofill.CardUploadDecision", | 3745 "Autofill.CardUploadDecision", |
3746 AutofillMetrics::UPLOAD_NOT_OFFERED_NO_ADDRESS, 1); | 3746 AutofillMetrics::UPLOAD_NOT_OFFERED_NO_ADDRESS, 1); |
3747 } | 3747 } |
3748 | 3748 |
3749 TEST_F(AutofillManagerTest, DontUploadCreditCardIfUploadDetailsFails) { | 3749 TEST_F(AutofillManagerTest, DontUploadCreditCardIfUploadDetailsFails) { |
(...skipping 19 matching lines...) Expand all Loading... |
3769 // Edit the data, and submit | 3769 // Edit the data, and submit |
3770 credit_card_form.fields[0].value = ASCIIToUTF16("Flo Master"); | 3770 credit_card_form.fields[0].value = ASCIIToUTF16("Flo Master"); |
3771 credit_card_form.fields[1].value = ASCIIToUTF16("4111111111111111"); | 3771 credit_card_form.fields[1].value = ASCIIToUTF16("4111111111111111"); |
3772 credit_card_form.fields[2].value = ASCIIToUTF16("11"); | 3772 credit_card_form.fields[2].value = ASCIIToUTF16("11"); |
3773 credit_card_form.fields[3].value = ASCIIToUTF16("2017"); | 3773 credit_card_form.fields[3].value = ASCIIToUTF16("2017"); |
3774 credit_card_form.fields[4].value = ASCIIToUTF16("123"); | 3774 credit_card_form.fields[4].value = ASCIIToUTF16("123"); |
3775 | 3775 |
3776 base::HistogramTester histogram_tester; | 3776 base::HistogramTester histogram_tester; |
3777 | 3777 |
3778 // The save prompt should be shown instead of doing an upload. | 3778 // The save prompt should be shown instead of doing an upload. |
3779 EXPECT_CALL(autofill_client_, ConfirmSaveCreditCardLocally(_)).Times(1); | 3779 EXPECT_CALL(autofill_client_, ConfirmSaveCreditCardLocally(_, _)); |
3780 FormSubmitted(credit_card_form); | 3780 FormSubmitted(credit_card_form); |
3781 EXPECT_FALSE(autofill_manager_->credit_card_was_uploaded()); | 3781 EXPECT_FALSE(autofill_manager_->credit_card_was_uploaded()); |
3782 | 3782 |
3783 // Verify that the correct histogram entry (and only that) was logged. | 3783 // Verify that the correct histogram entry (and only that) was logged. |
3784 histogram_tester.ExpectUniqueSample( | 3784 histogram_tester.ExpectUniqueSample( |
3785 "Autofill.CardUploadDecision", | 3785 "Autofill.CardUploadDecision", |
3786 AutofillMetrics::UPLOAD_NOT_OFFERED_GET_UPLOAD_DETAILS_FAILED, 1); | 3786 AutofillMetrics::UPLOAD_NOT_OFFERED_GET_UPLOAD_DETAILS_FAILED, 1); |
3787 } | 3787 } |
3788 | 3788 |
3789 // Verify that typing "gmail" will match "theking@gmail.com" and | 3789 // Verify that typing "gmail" will match "theking@gmail.com" and |
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4056 FormsSeen(mixed_forms); | 4056 FormsSeen(mixed_forms); |
4057 | 4057 |
4058 // Suggestions should always be displayed. | 4058 // Suggestions should always be displayed. |
4059 for (const FormFieldData& field : mixed_form.fields) { | 4059 for (const FormFieldData& field : mixed_form.fields) { |
4060 GetAutofillSuggestions(mixed_form, field); | 4060 GetAutofillSuggestions(mixed_form, field); |
4061 EXPECT_TRUE(external_delegate_->on_suggestions_returned_seen()); | 4061 EXPECT_TRUE(external_delegate_->on_suggestions_returned_seen()); |
4062 } | 4062 } |
4063 } | 4063 } |
4064 | 4064 |
4065 } // namespace autofill | 4065 } // namespace autofill |
OLD | NEW |