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 <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); | |
|
Ilya Sherman
2014/08/06 23:32:09
Please also test with a card where the expiration
Evan Stade
2014/08/07 00:05:01
Done.
| |
| 2627 | |
| 2628 EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) | |
| 2629 .WillOnce(QuitMainMessageLoop()); | |
| 2630 base::MessageLoop::current()->Run(); | |
| 2631 | |
| 2632 // Sublabel is card number when filling name. | |
| 2633 std::vector<base::string16> values; | |
| 2634 std::vector<base::string16> labels; | |
| 2635 std::vector<base::string16> icons; | |
| 2636 std::vector<PersonalDataManager::GUIDPair> guid_pairs; | |
| 2637 personal_data_->GetCreditCardSuggestions( | |
| 2638 AutofillType(CREDIT_CARD_NAME), | |
| 2639 base::string16(), | |
| 2640 &values, | |
| 2641 &labels, | |
| 2642 &icons, | |
| 2643 &guid_pairs); | |
| 2644 ASSERT_EQ(2U, values.size()); | |
| 2645 ASSERT_EQ(values.size(), labels.size()); | |
| 2646 EXPECT_EQ(ASCIIToUTF16("Clyde Barrow"), values[0]); | |
| 2647 EXPECT_EQ(ASCIIToUTF16("*8555"), labels[0]); | |
| 2648 EXPECT_EQ(ASCIIToUTF16("John Dillinger"), values[1]); | |
| 2649 EXPECT_EQ(base::string16(), labels[1]); | |
| 2650 | |
| 2651 // Sublabel is expiration date when filling card number. | |
| 2652 values.clear(); | |
| 2653 labels.clear(); | |
| 2654 icons.clear(); | |
| 2655 guid_pairs.clear(); | |
| 2656 personal_data_->GetCreditCardSuggestions( | |
| 2657 AutofillType(CREDIT_CARD_NUMBER), | |
| 2658 base::string16(), | |
| 2659 &values, | |
| 2660 &labels, | |
| 2661 &icons, | |
| 2662 &guid_pairs); | |
| 2663 ASSERT_EQ(1U, values.size()); | |
| 2664 ASSERT_EQ(values.size(), labels.size()); | |
| 2665 EXPECT_EQ(ASCIIToUTF16("********8555"), values[0]); | |
| 2666 EXPECT_EQ(ASCIIToUTF16("04/15"), labels[0]); | |
| 2667 } | |
| 2668 | |
| 2618 } // namespace autofill | 2669 } // namespace autofill |
| OLD | NEW |