| 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 <memory> | 5 #include <memory> |
| 6 #include <vector> | 6 #include <vector> |
| 7 | 7 |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 MOCK_METHOD2(ShouldShowScanCreditCard, | 91 MOCK_METHOD2(ShouldShowScanCreditCard, |
| 92 bool(const FormData& form, const FormFieldData& field)); | 92 bool(const FormData& form, const FormFieldData& field)); |
| 93 | 93 |
| 94 MOCK_METHOD5(FillOrPreviewForm, | 94 MOCK_METHOD5(FillOrPreviewForm, |
| 95 void(AutofillDriver::RendererFormDataAction action, | 95 void(AutofillDriver::RendererFormDataAction action, |
| 96 int query_id, | 96 int query_id, |
| 97 const FormData& form, | 97 const FormData& form, |
| 98 const FormFieldData& field, | 98 const FormFieldData& field, |
| 99 int unique_id)); | 99 int unique_id)); |
| 100 | 100 |
| 101 MOCK_METHOD4(FillCreditCardForm, | 101 MOCK_METHOD5(FillCreditCardForm, |
| 102 void(int query_id, | 102 void(int query_id, |
| 103 const FormData& form, | 103 const FormData& form, |
| 104 const FormFieldData& field, | 104 const FormFieldData& field, |
| 105 const CreditCard& credit_card)); | 105 const CreditCard& credit_card, |
| 106 const base::string16& cvc)); |
| 106 | 107 |
| 107 private: | 108 private: |
| 108 DISALLOW_COPY_AND_ASSIGN(MockAutofillManager); | 109 DISALLOW_COPY_AND_ASSIGN(MockAutofillManager); |
| 109 }; | 110 }; |
| 110 | 111 |
| 111 } // namespace | 112 } // namespace |
| 112 | 113 |
| 113 class AutofillExternalDelegateUnitTest : public testing::Test { | 114 class AutofillExternalDelegateUnitTest : public testing::Test { |
| 114 protected: | 115 protected: |
| 115 void SetUp() override { | 116 void SetUp() override { |
| (...skipping 450 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 566 | 567 |
| 567 // Test that autofill manager will fill the credit card form after user scans a | 568 // Test that autofill manager will fill the credit card form after user scans a |
| 568 // credit card. | 569 // credit card. |
| 569 TEST_F(AutofillExternalDelegateUnitTest, FillCreditCardForm) { | 570 TEST_F(AutofillExternalDelegateUnitTest, FillCreditCardForm) { |
| 570 base::string16 card_number = base::ASCIIToUTF16("test"); | 571 base::string16 card_number = base::ASCIIToUTF16("test"); |
| 571 int expiration_month = 1; | 572 int expiration_month = 1; |
| 572 int expiration_year = 3000; | 573 int expiration_year = 3000; |
| 573 EXPECT_CALL(*autofill_manager_, | 574 EXPECT_CALL(*autofill_manager_, |
| 574 FillCreditCardForm( | 575 FillCreditCardForm( |
| 575 _, _, _, CreditCardMatches(card_number, expiration_month, | 576 _, _, _, CreditCardMatches(card_number, expiration_month, |
| 576 expiration_year))); | 577 expiration_year), |
| 578 base::string16())); |
| 577 external_delegate_->OnCreditCardScanned(card_number, expiration_month, | 579 external_delegate_->OnCreditCardScanned(card_number, expiration_month, |
| 578 expiration_year); | 580 expiration_year); |
| 579 } | 581 } |
| 580 | 582 |
| 581 TEST_F(AutofillExternalDelegateUnitTest, IgnoreAutocompleteOffForAutofill) { | 583 TEST_F(AutofillExternalDelegateUnitTest, IgnoreAutocompleteOffForAutofill) { |
| 582 const FormData form; | 584 const FormData form; |
| 583 FormFieldData field; | 585 FormFieldData field; |
| 584 field.is_focusable = true; | 586 field.is_focusable = true; |
| 585 field.should_autocomplete = false; | 587 field.should_autocomplete = false; |
| 586 const gfx::RectF element_bounds; | 588 const gfx::RectF element_bounds; |
| (...skipping 18 matching lines...) Expand all Loading... |
| 605 RendererShouldFillFieldWithValue(dummy_string)); | 607 RendererShouldFillFieldWithValue(dummy_string)); |
| 606 base::HistogramTester histogram_tester; | 608 base::HistogramTester histogram_tester; |
| 607 external_delegate_->DidAcceptSuggestion(dummy_string, | 609 external_delegate_->DidAcceptSuggestion(dummy_string, |
| 608 POPUP_ITEM_ID_AUTOCOMPLETE_ENTRY, | 610 POPUP_ITEM_ID_AUTOCOMPLETE_ENTRY, |
| 609 0); | 611 0); |
| 610 histogram_tester.ExpectUniqueSample( | 612 histogram_tester.ExpectUniqueSample( |
| 611 "Autofill.SuggestionAcceptedIndex.Autocomplete", 0, 1); | 613 "Autofill.SuggestionAcceptedIndex.Autocomplete", 0, 1); |
| 612 } | 614 } |
| 613 | 615 |
| 614 } // namespace autofill | 616 } // namespace autofill |
| OLD | NEW |