Chromium Code Reviews| 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/guid.h" | |
| 10 #include "base/macros.h" | 11 #include "base/macros.h" |
| 11 #include "base/message_loop/message_loop.h" | 12 #include "base/message_loop/message_loop.h" |
| 12 #include "base/strings/string16.h" | 13 #include "base/strings/string16.h" |
| 13 #include "base/strings/utf_string_conversions.h" | 14 #include "base/strings/utf_string_conversions.h" |
| 14 #include "base/test/histogram_tester.h" | 15 #include "base/test/histogram_tester.h" |
| 15 #include "base/test/user_action_tester.h" | 16 #include "base/test/user_action_tester.h" |
| 16 #include "build/build_config.h" | 17 #include "build/build_config.h" |
| 17 #include "components/autofill/core/browser/autofill_manager.h" | 18 #include "components/autofill/core/browser/autofill_manager.h" |
| 18 #include "components/autofill/core/browser/autofill_metrics.h" | 19 #include "components/autofill/core/browser/autofill_metrics.h" |
| 19 #include "components/autofill/core/browser/popup_item_ids.h" | 20 #include "components/autofill/core/browser/popup_item_ids.h" |
| (...skipping 594 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(base::GenerateGUID(), std::string()); |
|
Evan Stade
2016/08/18 00:48:55
I'd suggest adding something to autofill_test_util
please use gerrit instead
2016/08/19 23:05:49
There's already autofill::test::SetCreditCardInfo(
| |
| 625 card.SetRawInfo(CREDIT_CARD_NAME_FULL, base::ASCIIToUTF16("Alice")); | 626 card.SetRawInfo(CREDIT_CARD_NAME_FULL, base::ASCIIToUTF16("Alice")); |
| 627 card.SetNumber(base::ASCIIToUTF16("4111")); | |
| 628 card.SetExpirationMonth(1); | |
| 629 card.SetExpirationYear(3000); | |
| 626 EXPECT_CALL(*autofill_manager_, | 630 EXPECT_CALL(*autofill_manager_, |
| 627 FillCreditCardForm(_, _, _, CreditCardMatches(card), base::string16())); | 631 FillCreditCardForm(_, _, _, CreditCardMatches(card), base::string16())); |
| 628 external_delegate_->OnCreditCardScanned(card); | 632 external_delegate_->OnCreditCardScanned(card); |
| 629 } | 633 } |
| 630 | 634 |
| 631 TEST_F(AutofillExternalDelegateUnitTest, IgnoreAutocompleteOffForAutofill) { | 635 TEST_F(AutofillExternalDelegateUnitTest, IgnoreAutocompleteOffForAutofill) { |
| 632 const FormData form; | 636 const FormData form; |
| 633 FormFieldData field; | 637 FormFieldData field; |
| 634 field.is_focusable = true; | 638 field.is_focusable = true; |
| 635 field.should_autocomplete = false; | 639 field.should_autocomplete = false; |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 654 RendererShouldFillFieldWithValue(dummy_string)); | 658 RendererShouldFillFieldWithValue(dummy_string)); |
| 655 base::HistogramTester histogram_tester; | 659 base::HistogramTester histogram_tester; |
| 656 external_delegate_->DidAcceptSuggestion(dummy_string, | 660 external_delegate_->DidAcceptSuggestion(dummy_string, |
| 657 POPUP_ITEM_ID_AUTOCOMPLETE_ENTRY, | 661 POPUP_ITEM_ID_AUTOCOMPLETE_ENTRY, |
| 658 0); | 662 0); |
| 659 histogram_tester.ExpectUniqueSample( | 663 histogram_tester.ExpectUniqueSample( |
| 660 "Autofill.SuggestionAcceptedIndex.Autocomplete", 0, 1); | 664 "Autofill.SuggestionAcceptedIndex.Autocomplete", 0, 1); |
| 661 } | 665 } |
| 662 | 666 |
| 663 } // namespace autofill | 667 } // namespace autofill |
| OLD | NEW |