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

Side by Side Diff: chrome/browser/ui/autofill/data_model_wrapper_unittest.cc

Issue 22009003: [Autofill] Distinguish between native field types and potentially HTML field types. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 7 years, 4 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 | Annotate | Revision Log
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 "base/memory/scoped_ptr.h" 5 #include "base/memory/scoped_ptr.h"
6 #include "base/strings/string_number_conversions.h" 6 #include "base/strings/string_number_conversions.h"
7 #include "base/strings/utf_string_conversions.h" 7 #include "base/strings/utf_string_conversions.h"
8 #include "chrome/browser/ui/autofill/autofill_dialog_models.h" 8 #include "chrome/browser/ui/autofill/autofill_dialog_models.h"
9 #include "chrome/browser/ui/autofill/data_model_wrapper.h" 9 #include "chrome/browser/ui/autofill/data_model_wrapper.h"
10 #include "components/autofill/content/browser/wallet/wallet_items.h" 10 #include "components/autofill/content/browser/wallet/wallet_items.h"
11 #include "components/autofill/content/browser/wallet/wallet_test_util.h" 11 #include "components/autofill/content/browser/wallet/wallet_test_util.h"
12 #include "components/autofill/core/browser/autofill_common_test.h" 12 #include "components/autofill/core/browser/autofill_common_test.h"
13 #include "components/autofill/core/browser/autofill_profile.h" 13 #include "components/autofill/core/browser/autofill_profile.h"
14 #include "components/autofill/core/browser/credit_card.h" 14 #include "components/autofill/core/browser/credit_card.h"
15 #include "components/autofill/core/browser/field_types.h" 15 #include "components/autofill/core/browser/field_types.h"
16 #include "testing/gtest/include/gtest/gtest.h" 16 #include "testing/gtest/include/gtest/gtest.h"
17 17
18 namespace autofill { 18 namespace autofill {
19 19
20 TEST(AutofillCreditCardWrapperTest, GetInfoCreditCardExpMonth) { 20 TEST(AutofillCreditCardWrapperTest, GetInfoCreditCardExpMonth) {
21 CreditCard card; 21 CreditCard card;
22 MonthComboboxModel model; 22 MonthComboboxModel model;
23 for (int month = 1; month <= 12; ++month) { 23 for (int month = 1; month <= 12; ++month) {
24 card.SetRawInfo(CREDIT_CARD_EXP_MONTH, base::IntToString16(month)); 24 card.SetRawInfo(CREDIT_CARD_EXP_MONTH, base::IntToString16(month));
25 AutofillCreditCardWrapper wrapper(&card); 25 AutofillCreditCardWrapper wrapper(&card);
26 EXPECT_EQ(model.GetItemAt(month), wrapper.GetInfo(CREDIT_CARD_EXP_MONTH)); 26 EXPECT_EQ(model.GetItemAt(month),
27 wrapper.GetInfo(AutofillType(CREDIT_CARD_EXP_MONTH)));
27 } 28 }
28 } 29 }
29 30
30 TEST(AutofillCreditCardWrapperTest, GetDisplayTextEmptyWhenExpired) { 31 TEST(AutofillCreditCardWrapperTest, GetDisplayTextEmptyWhenExpired) {
31 CreditCard card; 32 CreditCard card;
32 card.SetRawInfo(CREDIT_CARD_EXP_MONTH, ASCIIToUTF16("1")); 33 card.SetRawInfo(CREDIT_CARD_EXP_MONTH, ASCIIToUTF16("1"));
33 card.SetRawInfo(CREDIT_CARD_EXP_4_DIGIT_YEAR, ASCIIToUTF16("2010")); 34 card.SetRawInfo(CREDIT_CARD_EXP_4_DIGIT_YEAR, ASCIIToUTF16("2010"));
34 card.SetRawInfo(CREDIT_CARD_NUMBER, ASCIIToUTF16("4111111111111111")); 35 card.SetRawInfo(CREDIT_CARD_NUMBER, ASCIIToUTF16("4111111111111111"));
35 AutofillCreditCardWrapper wrapper(&card); 36 AutofillCreditCardWrapper wrapper(&card);
36 EXPECT_TRUE(wrapper.GetDisplayText().empty()); 37 EXPECT_TRUE(wrapper.GetDisplayText().empty());
(...skipping 17 matching lines...) Expand all
54 EXPECT_FALSE(wrapper.GetDisplayText().empty()); 55 EXPECT_FALSE(wrapper.GetDisplayText().empty());
55 } 56 }
56 57
57 TEST(WalletInstrumentWrapperTest, GetInfoCreditCardExpMonth) { 58 TEST(WalletInstrumentWrapperTest, GetInfoCreditCardExpMonth) {
58 scoped_ptr<wallet::WalletItems::MaskedInstrument> instrument( 59 scoped_ptr<wallet::WalletItems::MaskedInstrument> instrument(
59 wallet::GetTestMaskedInstrument()); 60 wallet::GetTestMaskedInstrument());
60 MonthComboboxModel model; 61 MonthComboboxModel model;
61 for (int month = 1; month <= 12; ++month) { 62 for (int month = 1; month <= 12; ++month) {
62 instrument->expiration_month_ = month; 63 instrument->expiration_month_ = month;
63 WalletInstrumentWrapper wrapper(instrument.get()); 64 WalletInstrumentWrapper wrapper(instrument.get());
64 EXPECT_EQ(model.GetItemAt(month), wrapper.GetInfo(CREDIT_CARD_EXP_MONTH)); 65 EXPECT_EQ(model.GetItemAt(month),
66 wrapper.GetInfo(AutofillType(CREDIT_CARD_EXP_MONTH)));
65 } 67 }
66 } 68 }
67 69
68 TEST(WalletInstrumentWrapperTest, GetDisplayTextEmptyWhenExpired) { 70 TEST(WalletInstrumentWrapperTest, GetDisplayTextEmptyWhenExpired) {
69 scoped_ptr<wallet::WalletItems::MaskedInstrument> instrument( 71 scoped_ptr<wallet::WalletItems::MaskedInstrument> instrument(
70 wallet::GetTestMaskedInstrument()); 72 wallet::GetTestMaskedInstrument());
71 instrument->status_ = wallet::WalletItems::MaskedInstrument::EXPIRED; 73 instrument->status_ = wallet::WalletItems::MaskedInstrument::EXPIRED;
72 WalletInstrumentWrapper wrapper(instrument.get()); 74 WalletInstrumentWrapper wrapper(instrument.get());
73 EXPECT_TRUE(wrapper.GetDisplayText().empty()); 75 EXPECT_TRUE(wrapper.GetDisplayText().empty());
74 } 76 }
75 77
76 TEST(DataModelWrapperTest, GetDisplayTextEmptyWithoutPhone) { 78 TEST(DataModelWrapperTest, GetDisplayTextEmptyWithoutPhone) {
77 scoped_ptr<wallet::WalletItems::MaskedInstrument> instrument( 79 scoped_ptr<wallet::WalletItems::MaskedInstrument> instrument(
78 wallet::GetTestMaskedInstrument()); 80 wallet::GetTestMaskedInstrument());
79 81
80 WalletInstrumentWrapper instrument_wrapper(instrument.get()); 82 WalletInstrumentWrapper instrument_wrapper(instrument.get());
81 ASSERT_FALSE(instrument_wrapper.GetDisplayText().empty()); 83 ASSERT_FALSE(instrument_wrapper.GetDisplayText().empty());
82 84
83 WalletAddressWrapper address_wrapper(&instrument->address()); 85 WalletAddressWrapper address_wrapper(&instrument->address());
84 ASSERT_FALSE(address_wrapper.GetDisplayText().empty()); 86 ASSERT_FALSE(address_wrapper.GetDisplayText().empty());
85 87
86 const_cast<wallet::Address*>(&instrument->address())->set_phone_number( 88 const_cast<wallet::Address*>(&instrument->address())->set_phone_number(
87 string16()); 89 string16());
88 90
89 ASSERT_TRUE(instrument_wrapper.GetInfo(PHONE_HOME_WHOLE_NUMBER).empty()); 91 ASSERT_TRUE(
92 instrument_wrapper.GetInfo(
93 AutofillType(PHONE_HOME_WHOLE_NUMBER)).empty());
90 EXPECT_TRUE(instrument_wrapper.GetDisplayText().empty()); 94 EXPECT_TRUE(instrument_wrapper.GetDisplayText().empty());
91 95
92 ASSERT_TRUE(address_wrapper.GetInfo(PHONE_HOME_WHOLE_NUMBER).empty()); 96 ASSERT_TRUE(
97 address_wrapper.GetInfo(AutofillType(PHONE_HOME_WHOLE_NUMBER)).empty());
93 EXPECT_TRUE(address_wrapper.GetDisplayText().empty()); 98 EXPECT_TRUE(address_wrapper.GetDisplayText().empty());
94 } 99 }
95 100
96 } // namespace autofill 101 } // namespace autofill
OLDNEW
« no previous file with comments | « chrome/browser/ui/autofill/data_model_wrapper.cc ('k') | chrome/browser/ui/autofill/mock_autofill_dialog_view_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698