| 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 587 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 598 base::HistogramTester histogram; | 598 base::HistogramTester histogram; |
| 599 IssueOnQuery(kQueryId); | 599 IssueOnQuery(kQueryId); |
| 600 IssueOnSuggestionsReturned(); | 600 IssueOnSuggestionsReturned(); |
| 601 external_delegate_->DidAcceptSuggestion(base::string16(), | 601 external_delegate_->DidAcceptSuggestion(base::string16(), |
| 602 POPUP_ITEM_ID_CLEAR_FORM, | 602 POPUP_ITEM_ID_CLEAR_FORM, |
| 603 0); | 603 0); |
| 604 histogram.ExpectTotalCount("Autofill.ScanCreditCardPrompt", 0); | 604 histogram.ExpectTotalCount("Autofill.ScanCreditCardPrompt", 0); |
| 605 } | 605 } |
| 606 } | 606 } |
| 607 | 607 |
| 608 MATCHER_P3(CreditCardMatches, | |
| 609 card_number, | |
| 610 expiration_month, | |
| 611 expiration_year, | |
| 612 "") { | |
| 613 return !arg.Compare( | |
| 614 CreditCard(card_number, expiration_month, expiration_year)); | |
| 615 } | |
| 616 | |
| 617 // Test that autofill client will start the signin flow after the user accepted | 608 // Test that autofill client will start the signin flow after the user accepted |
| 618 // the suggestion to sign in. | 609 // the suggestion to sign in. |
| 619 TEST_F(AutofillExternalDelegateUnitTest, SigninPromoMenuItem) { | 610 TEST_F(AutofillExternalDelegateUnitTest, SigninPromoMenuItem) { |
| 620 EXPECT_CALL(autofill_client_, StartSigninFlow()); | 611 EXPECT_CALL(autofill_client_, StartSigninFlow()); |
| 621 EXPECT_CALL(autofill_client_, HideAutofillPopup()); | 612 EXPECT_CALL(autofill_client_, HideAutofillPopup()); |
| 622 external_delegate_->DidAcceptSuggestion( | 613 external_delegate_->DidAcceptSuggestion( |
| 623 base::string16(), POPUP_ITEM_ID_CREDIT_CARD_SIGNIN_PROMO, 0); | 614 base::string16(), POPUP_ITEM_ID_CREDIT_CARD_SIGNIN_PROMO, 0); |
| 624 } | 615 } |
| 625 | 616 |
| 617 MATCHER_P(CreditCardMatches, card, "") { |
| 618 return !arg.Compare(card); |
| 619 } |
| 620 |
| 626 // Test that autofill manager will fill the credit card form after user scans a | 621 // Test that autofill manager will fill the credit card form after user scans a |
| 627 // credit card. | 622 // credit card. |
| 628 TEST_F(AutofillExternalDelegateUnitTest, FillCreditCardForm) { | 623 TEST_F(AutofillExternalDelegateUnitTest, FillCreditCardForm) { |
| 629 base::string16 card_number = base::ASCIIToUTF16("test"); | 624 CreditCard card(base::ASCIIToUTF16("test"), 1, 3000); |
| 630 int expiration_month = 1; | 625 card.SetRawInfo(CREDIT_CARD_NAME_FULL, base::ASCIIToUTF16("Alice")); |
| 631 int expiration_year = 3000; | |
| 632 EXPECT_CALL(*autofill_manager_, | 626 EXPECT_CALL(*autofill_manager_, |
| 633 FillCreditCardForm( | 627 FillCreditCardForm(_, _, _, CreditCardMatches(card), base::string16())); |
| 634 _, _, _, CreditCardMatches(card_number, expiration_month, | 628 external_delegate_->OnCreditCardScanned(card); |
| 635 expiration_year), | |
| 636 base::string16())); | |
| 637 external_delegate_->OnCreditCardScanned(card_number, expiration_month, | |
| 638 expiration_year); | |
| 639 } | 629 } |
| 640 | 630 |
| 641 TEST_F(AutofillExternalDelegateUnitTest, IgnoreAutocompleteOffForAutofill) { | 631 TEST_F(AutofillExternalDelegateUnitTest, IgnoreAutocompleteOffForAutofill) { |
| 642 const FormData form; | 632 const FormData form; |
| 643 FormFieldData field; | 633 FormFieldData field; |
| 644 field.is_focusable = true; | 634 field.is_focusable = true; |
| 645 field.should_autocomplete = false; | 635 field.should_autocomplete = false; |
| 646 | 636 |
| 647 external_delegate_->OnQuery(kQueryId, form, field, gfx::RectF()); | 637 external_delegate_->OnQuery(kQueryId, form, field, gfx::RectF()); |
| 648 | 638 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 664 RendererShouldFillFieldWithValue(dummy_string)); | 654 RendererShouldFillFieldWithValue(dummy_string)); |
| 665 base::HistogramTester histogram_tester; | 655 base::HistogramTester histogram_tester; |
| 666 external_delegate_->DidAcceptSuggestion(dummy_string, | 656 external_delegate_->DidAcceptSuggestion(dummy_string, |
| 667 POPUP_ITEM_ID_AUTOCOMPLETE_ENTRY, | 657 POPUP_ITEM_ID_AUTOCOMPLETE_ENTRY, |
| 668 0); | 658 0); |
| 669 histogram_tester.ExpectUniqueSample( | 659 histogram_tester.ExpectUniqueSample( |
| 670 "Autofill.SuggestionAcceptedIndex.Autocomplete", 0, 1); | 660 "Autofill.SuggestionAcceptedIndex.Autocomplete", 0, 1); |
| 671 } | 661 } |
| 672 | 662 |
| 673 } // namespace autofill | 663 } // namespace autofill |
| OLD | NEW |