Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(637)

Side by Side Diff: components/autofill/core/browser/personal_data_manager_unittest.cc

Issue 622773002: [Autofill] Autofill fails to show suggestions for credit card split across fields. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added unit-tests. Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 <algorithm> 5 #include <algorithm>
6 #include <string> 6 #include <string>
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/files/scoped_temp_dir.h" 10 #include "base/files/scoped_temp_dir.h"
(...skipping 2728 matching lines...) Expand 10 before | Expand all | Expand 10 after
2739 EXPECT_TRUE(personal_data_->ShouldShowAccessAddressBookSuggestion(type)); 2739 EXPECT_TRUE(personal_data_->ShouldShowAccessAddressBookSuggestion(type));
2740 2740
2741 prefs_->SetInteger(prefs::kAutofillMacAddressBookShowedCount, 4); 2741 prefs_->SetInteger(prefs::kAutofillMacAddressBookShowedCount, 4);
2742 EXPECT_TRUE(personal_data_->ShouldShowAccessAddressBookSuggestion(type)); 2742 EXPECT_TRUE(personal_data_->ShouldShowAccessAddressBookSuggestion(type));
2743 2743
2744 prefs_->SetInteger(prefs::kAutofillMacAddressBookShowedCount, 6); 2744 prefs_->SetInteger(prefs::kAutofillMacAddressBookShowedCount, 6);
2745 EXPECT_FALSE(personal_data_->ShouldShowAccessAddressBookSuggestion(type)); 2745 EXPECT_FALSE(personal_data_->ShouldShowAccessAddressBookSuggestion(type));
2746 } 2746 }
2747 #endif // defined(OS_MACOSX) && !defined(OS_IOS) 2747 #endif // defined(OS_MACOSX) && !defined(OS_IOS)
2748 2748
2749 TEST_F(PersonalDataManagerTest, AppendCreditCardSuggetions) {
2750 // These GUIDs are alphabetical to make validating expectations easier.
2751 CreditCard credit_card[3];
2752 CreditCard credit_card0("087151C8-6AB1-487C-9095-28E80BE5DA15",
2753 "https://www.example.com");
2754 test::SetCreditCardInfo(&credit_card0,
2755 "Clyde Barrow",
2756 "347666888555" /* American Express */,
2757 "04",
2758 "2015");
2759 personal_data_->AddCreditCard(credit_card0);
2760
2761 CreditCard credit_card1("6141084B-72D7-4B73-90CF-3D6AC154673B",
2762 "https://www.example.com");
2763 test::SetCreditCardInfo(&credit_card1, "John Dillinger", "", "01", "2010");
2764 personal_data_->AddCreditCard(credit_card1);
2765
2766 CreditCard credit_card2("702149C1-EE28-4213-A3B9-DA243FFF021B",
2767 "https://www.example.com");
2768 test::SetCreditCardInfo(
2769 &credit_card2, "Bonnie Parker", "518765432109" /* Mastercard */, "", "");
2770 personal_data_->AddCreditCard(credit_card2);
2771
2772 // Add cards to list.
2773 credit_card[0] = credit_card0;
2774 credit_card[1] = credit_card1;
2775 credit_card[2] = credit_card2;
2776
2777 EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged())
2778 .WillOnce(QuitMainMessageLoop());
2779 base::MessageLoop::current()->Run();
2780
2781 std::vector<base::string16> values;
2782 std::vector<base::string16> labels;
2783 std::vector<base::string16> icons;
2784 std::vector<PersonalDataManager::GUIDPair> guid_pairs;
2785 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(credit_card); ++i)
2786 personal_data_->AppendCreditCardSuggetions(&credit_card[i],
2787 AutofillType(CREDIT_CARD_NUMBER),
2788 base::string16(),
2789 &values,
2790 &labels,
2791 &icons,
2792 &guid_pairs);
2793
2794 ASSERT_EQ(2U, values.size());
2795 ASSERT_EQ(values.size(), labels.size());
2796 EXPECT_EQ(ASCIIToUTF16("********8555"), values[0]);
2797 EXPECT_EQ(ASCIIToUTF16("04/15"), labels[0]);
2798 EXPECT_EQ(ASCIIToUTF16("********2109"), values[1]);
2799 EXPECT_EQ(base::string16(), labels[1]);
2800 }
2801
2749 } // namespace autofill 2802 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698