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 base::Closure& callback, const CreditCard& card)); |
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 1682 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2591 autofill_manager_->set_autofill_enabled(false); | 2591 autofill_manager_->set_autofill_enabled(false); |
2592 autofill_manager_->autocomplete_history_manager_.reset( | 2592 autofill_manager_->autocomplete_history_manager_.reset( |
2593 new MockAutocompleteHistoryManager(autofill_driver_.get(), &client)); | 2593 new MockAutocompleteHistoryManager(autofill_driver_.get(), &client)); |
2594 | 2594 |
2595 // Set up our form data. | 2595 // Set up our form data. |
2596 FormData form; | 2596 FormData form; |
2597 test::CreateTestAddressFormData(&form); | 2597 test::CreateTestAddressFormData(&form); |
2598 MockAutocompleteHistoryManager* m = static_cast< | 2598 MockAutocompleteHistoryManager* m = static_cast< |
2599 MockAutocompleteHistoryManager*>( | 2599 MockAutocompleteHistoryManager*>( |
2600 autofill_manager_->autocomplete_history_manager_.get()); | 2600 autofill_manager_->autocomplete_history_manager_.get()); |
2601 EXPECT_CALL(*m, OnWillSubmitForm(_)).Times(1); | 2601 EXPECT_CALL(*m, OnWillSubmitForm(_)); |
2602 FormSubmitted(form); | 2602 FormSubmitted(form); |
2603 } | 2603 } |
2604 | 2604 |
2605 // Test that when Autofill is disabled, Autocomplete suggestions are still | 2605 // Test that when Autofill is disabled, Autocomplete suggestions are still |
2606 // queried. | 2606 // queried. |
2607 TEST_F(AutofillManagerTest, AutocompleteSuggestions_SomeWhenAutofillDisabled) { | 2607 TEST_F(AutofillManagerTest, AutocompleteSuggestions_SomeWhenAutofillDisabled) { |
2608 TestAutofillClient client; | 2608 TestAutofillClient client; |
2609 autofill_manager_.reset( | 2609 autofill_manager_.reset( |
2610 new TestAutofillManager(autofill_driver_.get(), &client, NULL)); | 2610 new TestAutofillManager(autofill_driver_.get(), &client, NULL)); |
2611 autofill_manager_->set_autofill_enabled(false); | 2611 autofill_manager_->set_autofill_enabled(false); |
2612 autofill_manager_->SetExternalDelegate(external_delegate_.get()); | 2612 autofill_manager_->SetExternalDelegate(external_delegate_.get()); |
2613 | 2613 |
2614 // Set up our form data. | 2614 // Set up our form data. |
2615 FormData form; | 2615 FormData form; |
2616 test::CreateTestAddressFormData(&form); | 2616 test::CreateTestAddressFormData(&form); |
2617 std::vector<FormData> forms(1, form); | 2617 std::vector<FormData> forms(1, form); |
2618 FormsSeen(forms); | 2618 FormsSeen(forms); |
2619 const FormFieldData& field = form.fields[0]; | 2619 const FormFieldData& field = form.fields[0]; |
2620 | 2620 |
2621 // Expect Autocomplete manager to be called for suggestions. | 2621 // Expect Autocomplete manager to be called for suggestions. |
2622 autofill_manager_->autocomplete_history_manager_.reset( | 2622 autofill_manager_->autocomplete_history_manager_.reset( |
2623 new MockAutocompleteHistoryManager(autofill_driver_.get(), &client)); | 2623 new MockAutocompleteHistoryManager(autofill_driver_.get(), &client)); |
2624 MockAutocompleteHistoryManager* m = static_cast< | 2624 MockAutocompleteHistoryManager* m = static_cast< |
2625 MockAutocompleteHistoryManager*>( | 2625 MockAutocompleteHistoryManager*>( |
2626 autofill_manager_->autocomplete_history_manager_.get()); | 2626 autofill_manager_->autocomplete_history_manager_.get()); |
2627 EXPECT_CALL(*m, | 2627 EXPECT_CALL(*m, |
2628 OnGetAutocompleteSuggestions(_, _, _, _)).Times(1); | 2628 OnGetAutocompleteSuggestions(_, _, _, _)); |
2629 | 2629 |
2630 GetAutofillSuggestions(form, field); | 2630 GetAutofillSuggestions(form, field); |
2631 } | 2631 } |
2632 | 2632 |
2633 // Test that when Autofill is disabled and the field should not autocomplete, | 2633 // Test that when Autofill is disabled and the field should not autocomplete, |
2634 // autocomplete is not queried for suggestions. | 2634 // autocomplete is not queried for suggestions. |
2635 TEST_F(AutofillManagerTest, | 2635 TEST_F(AutofillManagerTest, |
2636 AutocompleteSuggestions_AutofillDisabledAndFieldShouldNotAutocomplete) { | 2636 AutocompleteSuggestions_AutofillDisabledAndFieldShouldNotAutocomplete) { |
2637 TestAutofillClient client; | 2637 TestAutofillClient client; |
2638 autofill_manager_.reset( | 2638 autofill_manager_.reset( |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2705 test::CreateTestFormField("Email", "email", "donkey", "email", &field); | 2705 test::CreateTestFormField("Email", "email", "donkey", "email", &field); |
2706 | 2706 |
2707 // Autocomplete manager is called for suggestions because Autofill is empty. | 2707 // Autocomplete manager is called for suggestions because Autofill is empty. |
2708 autofill_manager_->autocomplete_history_manager_.reset( | 2708 autofill_manager_->autocomplete_history_manager_.reset( |
2709 new MockAutocompleteHistoryManager(autofill_driver_.get(), | 2709 new MockAutocompleteHistoryManager(autofill_driver_.get(), |
2710 autofill_manager_->client())); | 2710 autofill_manager_->client())); |
2711 MockAutocompleteHistoryManager* m = static_cast< | 2711 MockAutocompleteHistoryManager* m = static_cast< |
2712 MockAutocompleteHistoryManager*>( | 2712 MockAutocompleteHistoryManager*>( |
2713 autofill_manager_->autocomplete_history_manager_.get()); | 2713 autofill_manager_->autocomplete_history_manager_.get()); |
2714 EXPECT_CALL(*m, | 2714 EXPECT_CALL(*m, |
2715 OnGetAutocompleteSuggestions(_, _, _, _)).Times(1); | 2715 OnGetAutocompleteSuggestions(_, _, _, _)); |
2716 | 2716 |
2717 GetAutofillSuggestions(form, field); | 2717 GetAutofillSuggestions(form, field); |
2718 } | 2718 } |
2719 | 2719 |
2720 // Test that we do not query for Autocomplete suggestions when there are no | 2720 // Test that we do not query for Autocomplete suggestions when there are no |
2721 // Autofill suggestions available, and that the field should not autocomplete. | 2721 // Autofill suggestions available, and that the field should not autocomplete. |
2722 TEST_F( | 2722 TEST_F( |
2723 AutofillManagerTest, | 2723 AutofillManagerTest, |
2724 AutocompleteSuggestions_NoneWhenAutofillEmptyFieldShouldNotAutocomplete) { | 2724 AutocompleteSuggestions_NoneWhenAutofillEmptyFieldShouldNotAutocomplete) { |
2725 // Set up our form data. | 2725 // Set up our form data. |
(...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3042 // Set "autocomplete=off" for cardnumber field. | 3042 // Set "autocomplete=off" for cardnumber field. |
3043 form.fields[1].should_autocomplete = false; | 3043 form.fields[1].should_autocomplete = false; |
3044 | 3044 |
3045 std::vector<FormData> forms(1, form); | 3045 std::vector<FormData> forms(1, form); |
3046 FormsSeen(forms); | 3046 FormsSeen(forms); |
3047 | 3047 |
3048 // Edit the data, and submit | 3048 // Edit the data, and submit |
3049 form.fields[1].value = ASCIIToUTF16("4111111111111111"); | 3049 form.fields[1].value = ASCIIToUTF16("4111111111111111"); |
3050 form.fields[2].value = ASCIIToUTF16("11"); | 3050 form.fields[2].value = ASCIIToUTF16("11"); |
3051 form.fields[3].value = ASCIIToUTF16("2017"); | 3051 form.fields[3].value = ASCIIToUTF16("2017"); |
3052 EXPECT_CALL(autofill_client_, ConfirmSaveCreditCardLocally(_)).Times(1); | 3052 EXPECT_CALL(autofill_client_, ConfirmSaveCreditCardLocally(_, _)); |
3053 FormSubmitted(form); | 3053 FormSubmitted(form); |
3054 } | 3054 } |
3055 | 3055 |
3056 // Tests that credit card data are not saved when CC number does not pass the | 3056 // Tests that credit card data are not saved when CC number does not pass the |
3057 // Luhn test. | 3057 // Luhn test. |
3058 TEST_F(AutofillManagerTest, InvalidCreditCardNumberIsNotSaved) { | 3058 TEST_F(AutofillManagerTest, InvalidCreditCardNumberIsNotSaved) { |
3059 // Set up our form data. | 3059 // Set up our form data. |
3060 FormData form; | 3060 FormData form; |
3061 CreateTestCreditCardFormData(&form, true, false); | 3061 CreateTestCreditCardFormData(&form, true, false); |
3062 std::vector<FormData> forms(1, form); | 3062 std::vector<FormData> forms(1, form); |
3063 FormsSeen(forms); | 3063 FormsSeen(forms); |
3064 | 3064 |
3065 // Edit the data, and submit. | 3065 // Edit the data, and submit. |
3066 std::string card("4408041234567890"); | 3066 std::string card("4408041234567890"); |
3067 ASSERT_FALSE(autofill::IsValidCreditCardNumber(ASCIIToUTF16(card))); | 3067 ASSERT_FALSE(autofill::IsValidCreditCardNumber(ASCIIToUTF16(card))); |
3068 form.fields[1].value = ASCIIToUTF16(card); | 3068 form.fields[1].value = ASCIIToUTF16(card); |
3069 form.fields[2].value = ASCIIToUTF16("11"); | 3069 form.fields[2].value = ASCIIToUTF16("11"); |
3070 form.fields[3].value = ASCIIToUTF16("2017"); | 3070 form.fields[3].value = ASCIIToUTF16("2017"); |
3071 EXPECT_CALL(autofill_client_, ConfirmSaveCreditCardLocally(_)).Times(0); | 3071 EXPECT_CALL(autofill_client_, ConfirmSaveCreditCardLocally(_, _)).Times(0); |
3072 FormSubmitted(form); | 3072 FormSubmitted(form); |
3073 } | 3073 } |
3074 | 3074 |
3075 // Tests that DeterminePossibleFieldTypesForUpload makes accurate matches. | 3075 // Tests that DeterminePossibleFieldTypesForUpload makes accurate matches. |
3076 TEST_F(AutofillManagerTest, DeterminePossibleFieldTypesForUpload) { | 3076 TEST_F(AutofillManagerTest, DeterminePossibleFieldTypesForUpload) { |
3077 // Set up the test profiles. | 3077 // Set up the test profiles. |
3078 std::vector<AutofillProfile> profiles; | 3078 std::vector<AutofillProfile> profiles; |
3079 AutofillProfile profile; | 3079 AutofillProfile profile; |
3080 test::SetProfileInfo(&profile, "Elvis", "Aaron", "Presley", | 3080 test::SetProfileInfo(&profile, "Elvis", "Aaron", "Presley", |
3081 "theking@gmail.com", "RCA", "3734 Elvis Presley Blvd.", | 3081 "theking@gmail.com", "RCA", "3734 Elvis Presley Blvd.", |
(...skipping 579 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3661 // Edit the data, and submit | 3661 // Edit the data, and submit |
3662 credit_card_form.fields[0].value = ASCIIToUTF16("Flo Master"); | 3662 credit_card_form.fields[0].value = ASCIIToUTF16("Flo Master"); |
3663 credit_card_form.fields[1].value = ASCIIToUTF16("4111111111111111"); | 3663 credit_card_form.fields[1].value = ASCIIToUTF16("4111111111111111"); |
3664 credit_card_form.fields[2].value = ASCIIToUTF16("11"); | 3664 credit_card_form.fields[2].value = ASCIIToUTF16("11"); |
3665 credit_card_form.fields[3].value = ASCIIToUTF16("2017"); | 3665 credit_card_form.fields[3].value = ASCIIToUTF16("2017"); |
3666 credit_card_form.fields[4].value = ASCIIToUTF16("123"); | 3666 credit_card_form.fields[4].value = ASCIIToUTF16("123"); |
3667 | 3667 |
3668 base::HistogramTester histogram_tester; | 3668 base::HistogramTester histogram_tester; |
3669 | 3669 |
3670 // The save prompt should be shown instead of doing an upload. | 3670 // The save prompt should be shown instead of doing an upload. |
3671 EXPECT_CALL(autofill_client_, ConfirmSaveCreditCardLocally(_)).Times(1); | 3671 EXPECT_CALL(autofill_client_, ConfirmSaveCreditCardLocally(_, _)); |
3672 FormSubmitted(credit_card_form); | 3672 FormSubmitted(credit_card_form); |
3673 EXPECT_FALSE(autofill_manager_->credit_card_was_uploaded()); | 3673 EXPECT_FALSE(autofill_manager_->credit_card_was_uploaded()); |
3674 | 3674 |
3675 // Verify that no histogram entry was logged called. | 3675 // Verify that no histogram entry was logged called. |
3676 histogram_tester.ExpectTotalCount("Autofill.CardUploadDecision", 0); | 3676 histogram_tester.ExpectTotalCount("Autofill.CardUploadDecision", 0); |
3677 } | 3677 } |
3678 | 3678 |
3679 TEST_F(AutofillManagerTest, DontUploadCreditCardIfCvcUnavailable) { | 3679 TEST_F(AutofillManagerTest, DontUploadCreditCardIfCvcUnavailable) { |
3680 autofill_manager_->set_credit_card_upload_enabled(true); | 3680 autofill_manager_->set_credit_card_upload_enabled(true); |
3681 | 3681 |
(...skipping 13 matching lines...) Expand all Loading... |
3695 // Edit the data, and submit | 3695 // Edit the data, and submit |
3696 credit_card_form.fields[0].value = ASCIIToUTF16("Flo Master"); | 3696 credit_card_form.fields[0].value = ASCIIToUTF16("Flo Master"); |
3697 credit_card_form.fields[1].value = ASCIIToUTF16("4111111111111111"); | 3697 credit_card_form.fields[1].value = ASCIIToUTF16("4111111111111111"); |
3698 credit_card_form.fields[2].value = ASCIIToUTF16("11"); | 3698 credit_card_form.fields[2].value = ASCIIToUTF16("11"); |
3699 credit_card_form.fields[3].value = ASCIIToUTF16("2017"); | 3699 credit_card_form.fields[3].value = ASCIIToUTF16("2017"); |
3700 credit_card_form.fields[4].value = ASCIIToUTF16(""); // CVC MISSING | 3700 credit_card_form.fields[4].value = ASCIIToUTF16(""); // CVC MISSING |
3701 | 3701 |
3702 base::HistogramTester histogram_tester; | 3702 base::HistogramTester histogram_tester; |
3703 | 3703 |
3704 // Neither a local save nor an upload should happen in this case. | 3704 // Neither a local save nor an upload should happen in this case. |
3705 EXPECT_CALL(autofill_client_, ConfirmSaveCreditCardLocally(_)).Times(0); | 3705 EXPECT_CALL(autofill_client_, ConfirmSaveCreditCardLocally(_, _)).Times(0); |
3706 FormSubmitted(credit_card_form); | 3706 FormSubmitted(credit_card_form); |
3707 EXPECT_FALSE(autofill_manager_->credit_card_was_uploaded()); | 3707 EXPECT_FALSE(autofill_manager_->credit_card_was_uploaded()); |
3708 | 3708 |
3709 // Verify that the correct histogram entry (and only that) was logged. | 3709 // Verify that the correct histogram entry (and only that) was logged. |
3710 histogram_tester.ExpectUniqueSample( | 3710 histogram_tester.ExpectUniqueSample( |
3711 "Autofill.CardUploadDecision", AutofillMetrics::UPLOAD_NOT_OFFERED_NO_CVC, | 3711 "Autofill.CardUploadDecision", AutofillMetrics::UPLOAD_NOT_OFFERED_NO_CVC, |
3712 1); | 3712 1); |
3713 } | 3713 } |
3714 | 3714 |
3715 TEST_F(AutofillManagerTest, DontUploadCreditCardIfNoMatchingProfileAvailable) { | 3715 TEST_F(AutofillManagerTest, DontUploadCreditCardIfNoMatchingProfileAvailable) { |
(...skipping 16 matching lines...) Expand all Loading... |
3732 // The address form has "Flo Master" but the credit card has "Bob Master". | 3732 // The address form has "Flo Master" but the credit card has "Bob Master". |
3733 credit_card_form.fields[0].value = ASCIIToUTF16("Bob Master"); | 3733 credit_card_form.fields[0].value = ASCIIToUTF16("Bob Master"); |
3734 credit_card_form.fields[1].value = ASCIIToUTF16("4111111111111111"); | 3734 credit_card_form.fields[1].value = ASCIIToUTF16("4111111111111111"); |
3735 credit_card_form.fields[2].value = ASCIIToUTF16("11"); | 3735 credit_card_form.fields[2].value = ASCIIToUTF16("11"); |
3736 credit_card_form.fields[3].value = ASCIIToUTF16("2017"); | 3736 credit_card_form.fields[3].value = ASCIIToUTF16("2017"); |
3737 credit_card_form.fields[4].value = ASCIIToUTF16("123"); | 3737 credit_card_form.fields[4].value = ASCIIToUTF16("123"); |
3738 | 3738 |
3739 base::HistogramTester histogram_tester; | 3739 base::HistogramTester histogram_tester; |
3740 | 3740 |
3741 // Neither a local save nor an upload should happen in this case. | 3741 // Neither a local save nor an upload should happen in this case. |
3742 EXPECT_CALL(autofill_client_, ConfirmSaveCreditCardLocally(_)).Times(0); | 3742 EXPECT_CALL(autofill_client_, ConfirmSaveCreditCardLocally(_, _)).Times(0); |
3743 FormSubmitted(credit_card_form); | 3743 FormSubmitted(credit_card_form); |
3744 EXPECT_FALSE(autofill_manager_->credit_card_was_uploaded()); | 3744 EXPECT_FALSE(autofill_manager_->credit_card_was_uploaded()); |
3745 | 3745 |
3746 // Verify that the correct histogram entry (and only that) was logged. | 3746 // Verify that the correct histogram entry (and only that) was logged. |
3747 histogram_tester.ExpectUniqueSample( | 3747 histogram_tester.ExpectUniqueSample( |
3748 "Autofill.CardUploadDecision", | 3748 "Autofill.CardUploadDecision", |
3749 AutofillMetrics::UPLOAD_NOT_OFFERED_NO_ADDRESS, 1); | 3749 AutofillMetrics::UPLOAD_NOT_OFFERED_NO_ADDRESS, 1); |
3750 } | 3750 } |
3751 | 3751 |
3752 TEST_F(AutofillManagerTest, DontUploadCreditCardIfUploadDetailsFails) { | 3752 TEST_F(AutofillManagerTest, DontUploadCreditCardIfUploadDetailsFails) { |
(...skipping 19 matching lines...) Expand all Loading... |
3772 // Edit the data, and submit | 3772 // Edit the data, and submit |
3773 credit_card_form.fields[0].value = ASCIIToUTF16("Flo Master"); | 3773 credit_card_form.fields[0].value = ASCIIToUTF16("Flo Master"); |
3774 credit_card_form.fields[1].value = ASCIIToUTF16("4111111111111111"); | 3774 credit_card_form.fields[1].value = ASCIIToUTF16("4111111111111111"); |
3775 credit_card_form.fields[2].value = ASCIIToUTF16("11"); | 3775 credit_card_form.fields[2].value = ASCIIToUTF16("11"); |
3776 credit_card_form.fields[3].value = ASCIIToUTF16("2017"); | 3776 credit_card_form.fields[3].value = ASCIIToUTF16("2017"); |
3777 credit_card_form.fields[4].value = ASCIIToUTF16("123"); | 3777 credit_card_form.fields[4].value = ASCIIToUTF16("123"); |
3778 | 3778 |
3779 base::HistogramTester histogram_tester; | 3779 base::HistogramTester histogram_tester; |
3780 | 3780 |
3781 // The save prompt should be shown instead of doing an upload. | 3781 // The save prompt should be shown instead of doing an upload. |
3782 EXPECT_CALL(autofill_client_, ConfirmSaveCreditCardLocally(_)).Times(1); | 3782 EXPECT_CALL(autofill_client_, ConfirmSaveCreditCardLocally(_, _)); |
3783 FormSubmitted(credit_card_form); | 3783 FormSubmitted(credit_card_form); |
3784 EXPECT_FALSE(autofill_manager_->credit_card_was_uploaded()); | 3784 EXPECT_FALSE(autofill_manager_->credit_card_was_uploaded()); |
3785 | 3785 |
3786 // Verify that the correct histogram entry (and only that) was logged. | 3786 // Verify that the correct histogram entry (and only that) was logged. |
3787 histogram_tester.ExpectUniqueSample( | 3787 histogram_tester.ExpectUniqueSample( |
3788 "Autofill.CardUploadDecision", | 3788 "Autofill.CardUploadDecision", |
3789 AutofillMetrics::UPLOAD_NOT_OFFERED_GET_UPLOAD_DETAILS_FAILED, 1); | 3789 AutofillMetrics::UPLOAD_NOT_OFFERED_GET_UPLOAD_DETAILS_FAILED, 1); |
3790 } | 3790 } |
3791 | 3791 |
3792 // Verify that typing "gmail" will match "theking@gmail.com" and | 3792 // Verify that typing "gmail" will match "theking@gmail.com" and |
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4059 FormsSeen(mixed_forms); | 4059 FormsSeen(mixed_forms); |
4060 | 4060 |
4061 // Suggestions should always be displayed. | 4061 // Suggestions should always be displayed. |
4062 for (const FormFieldData& field : mixed_form.fields) { | 4062 for (const FormFieldData& field : mixed_form.fields) { |
4063 GetAutofillSuggestions(mixed_form, field); | 4063 GetAutofillSuggestions(mixed_form, field); |
4064 EXPECT_TRUE(external_delegate_->on_suggestions_returned_seen()); | 4064 EXPECT_TRUE(external_delegate_->on_suggestions_returned_seen()); |
4065 } | 4065 } |
4066 } | 4066 } |
4067 | 4067 |
4068 } // namespace autofill | 4068 } // namespace autofill |
OLD | NEW |