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 <string> | 5 #include <string> |
6 | 6 |
7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/files/scoped_temp_dir.h" | 8 #include "base/files/scoped_temp_dir.h" |
9 #include "base/guid.h" | 9 #include "base/guid.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 2597 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2608 base::Bind(ReturnTrue), | 2608 base::Bind(ReturnTrue), |
2609 &values, | 2609 &values, |
2610 &labels, | 2610 &labels, |
2611 &icons, | 2611 &icons, |
2612 &guid_pairs); | 2612 &guid_pairs); |
2613 ASSERT_FALSE(values.empty()); | 2613 ASSERT_FALSE(values.empty()); |
2614 EXPECT_EQ(values[0], | 2614 EXPECT_EQ(values[0], |
2615 base::UTF8ToUTF16("123 Zoo St., Second Line, Third line, unit 5")); | 2615 base::UTF8ToUTF16("123 Zoo St., Second Line, Third line, unit 5")); |
2616 } | 2616 } |
2617 | 2617 |
| 2618 TEST_F(PersonalDataManagerTest, GetCreditCardSuggestions) { |
| 2619 CreditCard credit_card0(base::GenerateGUID(), "https://www.example.com"); |
| 2620 test::SetCreditCardInfo(&credit_card0, |
| 2621 "Clyde Barrow", "347666888555" /* American Express */, "04", "2015"); |
| 2622 personal_data_->AddCreditCard(credit_card0); |
| 2623 |
| 2624 CreditCard credit_card1(base::GenerateGUID(), "https://www.example.com"); |
| 2625 test::SetCreditCardInfo(&credit_card1, "John Dillinger", "", "01", "2010"); |
| 2626 personal_data_->AddCreditCard(credit_card1); |
| 2627 |
| 2628 CreditCard credit_card2(base::GenerateGUID(), "https://www.example.com"); |
| 2629 test::SetCreditCardInfo(&credit_card2, |
| 2630 "Bonnie Parker", "518765432109" /* Mastercard */, "", ""); |
| 2631 personal_data_->AddCreditCard(credit_card2); |
| 2632 |
| 2633 EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) |
| 2634 .WillOnce(QuitMainMessageLoop()); |
| 2635 base::MessageLoop::current()->Run(); |
| 2636 |
| 2637 // Sublabel is card number when filling name. |
| 2638 std::vector<base::string16> values; |
| 2639 std::vector<base::string16> labels; |
| 2640 std::vector<base::string16> icons; |
| 2641 std::vector<PersonalDataManager::GUIDPair> guid_pairs; |
| 2642 personal_data_->GetCreditCardSuggestions( |
| 2643 AutofillType(CREDIT_CARD_NAME), |
| 2644 base::string16(), |
| 2645 &values, |
| 2646 &labels, |
| 2647 &icons, |
| 2648 &guid_pairs); |
| 2649 ASSERT_EQ(3U, values.size()); |
| 2650 ASSERT_EQ(values.size(), labels.size()); |
| 2651 EXPECT_EQ(ASCIIToUTF16("Clyde Barrow"), values[0]); |
| 2652 EXPECT_EQ(ASCIIToUTF16("*8555"), labels[0]); |
| 2653 EXPECT_EQ(ASCIIToUTF16("John Dillinger"), values[1]); |
| 2654 EXPECT_EQ(base::string16(), labels[1]); |
| 2655 EXPECT_EQ(ASCIIToUTF16("Bonnie Parker"), values[2]); |
| 2656 EXPECT_EQ(ASCIIToUTF16("*2109"), labels[2]); |
| 2657 |
| 2658 // Sublabel is expiration date when filling card number. |
| 2659 values.clear(); |
| 2660 labels.clear(); |
| 2661 icons.clear(); |
| 2662 guid_pairs.clear(); |
| 2663 personal_data_->GetCreditCardSuggestions( |
| 2664 AutofillType(CREDIT_CARD_NUMBER), |
| 2665 base::string16(), |
| 2666 &values, |
| 2667 &labels, |
| 2668 &icons, |
| 2669 &guid_pairs); |
| 2670 ASSERT_EQ(2U, values.size()); |
| 2671 ASSERT_EQ(values.size(), labels.size()); |
| 2672 EXPECT_EQ(ASCIIToUTF16("********8555"), values[0]); |
| 2673 EXPECT_EQ(ASCIIToUTF16("04/15"), labels[0]); |
| 2674 EXPECT_EQ(ASCIIToUTF16("********2109"), values[1]); |
| 2675 EXPECT_EQ(base::string16(), labels[1]); |
| 2676 } |
| 2677 |
2618 } // namespace autofill | 2678 } // namespace autofill |
OLD | NEW |