| 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" |
| 11 #include "base/message_loop/message_loop.h" | 11 #include "base/message_loop/message_loop.h" |
| 12 #include "base/strings/string16.h" | 12 #include "base/strings/string16.h" |
| 13 #include "base/strings/utf_string_conversions.h" | 13 #include "base/strings/utf_string_conversions.h" |
| 14 #include "base/test/histogram_tester.h" | 14 #include "base/test/histogram_tester.h" |
| 15 #include "base/test/user_action_tester.h" | 15 #include "base/test/user_action_tester.h" |
| 16 #include "build/build_config.h" | 16 #include "build/build_config.h" |
| 17 #include "components/autofill/core/browser/autofill_manager.h" | 17 #include "components/autofill/core/browser/autofill_manager.h" |
| 18 #include "components/autofill/core/browser/autofill_metrics.h" | 18 #include "components/autofill/core/browser/autofill_metrics.h" |
| 19 #include "components/autofill/core/browser/autofill_test_utils.h" |
| 19 #include "components/autofill/core/browser/popup_item_ids.h" | 20 #include "components/autofill/core/browser/popup_item_ids.h" |
| 20 #include "components/autofill/core/browser/suggestion_test_helpers.h" | 21 #include "components/autofill/core/browser/suggestion_test_helpers.h" |
| 21 #include "components/autofill/core/browser/test_autofill_client.h" | 22 #include "components/autofill/core/browser/test_autofill_client.h" |
| 22 #include "components/autofill/core/browser/test_autofill_driver.h" | 23 #include "components/autofill/core/browser/test_autofill_driver.h" |
| 23 #include "components/autofill/core/browser/test_autofill_external_delegate.h" | 24 #include "components/autofill/core/browser/test_autofill_external_delegate.h" |
| 24 #include "components/autofill/core/common/autofill_switches.h" | 25 #include "components/autofill/core/common/autofill_switches.h" |
| 25 #include "components/autofill/core/common/form_data.h" | 26 #include "components/autofill/core/common/form_data.h" |
| 26 #include "components/autofill/core/common/form_field_data.h" | 27 #include "components/autofill/core/common/form_field_data.h" |
| 27 #include "components/autofill/core/common/password_form_fill_data.h" | 28 #include "components/autofill/core/common/password_form_fill_data.h" |
| 28 #include "testing/gmock/include/gmock/gmock.h" | 29 #include "testing/gmock/include/gmock/gmock.h" |
| (...skipping 585 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 614 base::string16(), POPUP_ITEM_ID_CREDIT_CARD_SIGNIN_PROMO, 0); | 615 base::string16(), POPUP_ITEM_ID_CREDIT_CARD_SIGNIN_PROMO, 0); |
| 615 } | 616 } |
| 616 | 617 |
| 617 MATCHER_P(CreditCardMatches, card, "") { | 618 MATCHER_P(CreditCardMatches, card, "") { |
| 618 return !arg.Compare(card); | 619 return !arg.Compare(card); |
| 619 } | 620 } |
| 620 | 621 |
| 621 // Test that autofill manager will fill the credit card form after user scans a | 622 // Test that autofill manager will fill the credit card form after user scans a |
| 622 // credit card. | 623 // credit card. |
| 623 TEST_F(AutofillExternalDelegateUnitTest, FillCreditCardForm) { | 624 TEST_F(AutofillExternalDelegateUnitTest, FillCreditCardForm) { |
| 624 CreditCard card(base::ASCIIToUTF16("test"), 1, 3000); | 625 CreditCard card; |
| 625 card.SetRawInfo(CREDIT_CARD_NAME_FULL, base::ASCIIToUTF16("Alice")); | 626 test::SetCreditCardInfo(&card, "Alice", "4111", "1", "3000"); |
| 626 EXPECT_CALL(*autofill_manager_, | 627 EXPECT_CALL(*autofill_manager_, |
| 627 FillCreditCardForm(_, _, _, CreditCardMatches(card), base::string16())); | 628 FillCreditCardForm(_, _, _, CreditCardMatches(card), base::string16())); |
| 628 external_delegate_->OnCreditCardScanned(card); | 629 external_delegate_->OnCreditCardScanned(card); |
| 629 } | 630 } |
| 630 | 631 |
| 631 TEST_F(AutofillExternalDelegateUnitTest, IgnoreAutocompleteOffForAutofill) { | 632 TEST_F(AutofillExternalDelegateUnitTest, IgnoreAutocompleteOffForAutofill) { |
| 632 const FormData form; | 633 const FormData form; |
| 633 FormFieldData field; | 634 FormFieldData field; |
| 634 field.is_focusable = true; | 635 field.is_focusable = true; |
| 635 field.should_autocomplete = false; | 636 field.should_autocomplete = false; |
| (...skipping 18 matching lines...) Expand all Loading... |
| 654 RendererShouldFillFieldWithValue(dummy_string)); | 655 RendererShouldFillFieldWithValue(dummy_string)); |
| 655 base::HistogramTester histogram_tester; | 656 base::HistogramTester histogram_tester; |
| 656 external_delegate_->DidAcceptSuggestion(dummy_string, | 657 external_delegate_->DidAcceptSuggestion(dummy_string, |
| 657 POPUP_ITEM_ID_AUTOCOMPLETE_ENTRY, | 658 POPUP_ITEM_ID_AUTOCOMPLETE_ENTRY, |
| 658 0); | 659 0); |
| 659 histogram_tester.ExpectUniqueSample( | 660 histogram_tester.ExpectUniqueSample( |
| 660 "Autofill.SuggestionAcceptedIndex.Autocomplete", 0, 1); | 661 "Autofill.SuggestionAcceptedIndex.Autocomplete", 0, 1); |
| 661 } | 662 } |
| 662 | 663 |
| 663 } // namespace autofill | 664 } // namespace autofill |
| OLD | NEW |