| 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 "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 "chrome/browser/ui/autofill/autofill_dialog_models.h" | 7 #include "chrome/browser/ui/autofill/autofill_dialog_models.h" |
| 8 #include "chrome/browser/ui/autofill/data_model_wrapper.h" | 8 #include "chrome/browser/ui/autofill/data_model_wrapper.h" |
| 9 #include "components/autofill/browser/credit_card.h" | 9 #include "components/autofill/browser/credit_card.h" |
| 10 #include "components/autofill/browser/field_types.h" | 10 #include "components/autofill/browser/field_types.h" |
| 11 #include "components/autofill/browser/wallet/wallet_items.h" | 11 #include "components/autofill/browser/wallet/wallet_items.h" |
| 12 #include "components/autofill/browser/wallet/wallet_test_util.h" | 12 #include "components/autofill/browser/wallet/wallet_test_util.h" |
| 13 #include "testing/gtest/include/gtest/gtest.h" | 13 #include "testing/gtest/include/gtest/gtest.h" |
| 14 | 14 |
| 15 namespace autofill { | 15 namespace autofill { |
| 16 | 16 |
| 17 TEST(AutofillCreditCardWrapperTest, GetInfoCreditCardExpMonth) { | 17 TEST(AutofillCreditCardWrapperTest, GetInfoCreditCardExpMonth) { |
| 18 CreditCard card; | 18 CreditCard card; |
| 19 MonthComboboxModel model; | 19 MonthComboboxModel model; |
| 20 for (int month = 1; month <= 12; ++month) { | 20 for (int month = 1; month <= 12; ++month) { |
| 21 card.SetRawInfo(CREDIT_CARD_EXP_MONTH, base::IntToString16(month)); | 21 card.SetRawInfo(CREDIT_CARD_EXP_MONTH, base::IntToString16(month)); |
| 22 AutofillCreditCardWrapper wrapper(&card); | 22 AutofillCreditCardWrapper wrapper(&card); |
| 23 EXPECT_EQ(model.GetItemAt(month), wrapper.GetInfo(CREDIT_CARD_EXP_MONTH)); | 23 EXPECT_EQ(model.GetItemAt(month), wrapper.GetInfo(CREDIT_CARD_EXP_MONTH)); |
| 24 } | 24 } |
| 25 } | 25 } |
| 26 | 26 |
| 27 TEST(AutofillCreditCardWrapperTest, GetDisplayTextEmptyWhenExpired) { |
| 28 CreditCard card; |
| 29 AutofillCreditCardWrapper wrapper(&card); |
| 30 EXPECT_TRUE(wrapper.GetDisplayText().empty()); |
| 31 } |
| 32 |
| 27 TEST(WalletInstrumentWrapperTest, GetInfoCreditCardExpMonth) { | 33 TEST(WalletInstrumentWrapperTest, GetInfoCreditCardExpMonth) { |
| 28 scoped_ptr<wallet::WalletItems::MaskedInstrument> instrument( | 34 scoped_ptr<wallet::WalletItems::MaskedInstrument> instrument( |
| 29 wallet::GetTestMaskedInstrument()); | 35 wallet::GetTestMaskedInstrument()); |
| 30 MonthComboboxModel model; | 36 MonthComboboxModel model; |
| 31 for (int month = 1; month <= 12; ++month) { | 37 for (int month = 1; month <= 12; ++month) { |
| 32 instrument->expiration_month_ = month; | 38 instrument->expiration_month_ = month; |
| 33 WalletInstrumentWrapper wrapper(instrument.get()); | 39 WalletInstrumentWrapper wrapper(instrument.get()); |
| 34 EXPECT_EQ(model.GetItemAt(month), wrapper.GetInfo(CREDIT_CARD_EXP_MONTH)); | 40 EXPECT_EQ(model.GetItemAt(month), wrapper.GetInfo(CREDIT_CARD_EXP_MONTH)); |
| 35 } | 41 } |
| 36 } | 42 } |
| 37 | 43 |
| 44 TEST(WalletInstrumentWrapperTest, GetDisplayTextEmptyWhenExpired) { |
| 45 scoped_ptr<wallet::WalletItems::MaskedInstrument> instrument( |
| 46 wallet::GetTestMaskedInstrument()); |
| 47 instrument->status_ = wallet::WalletItems::MaskedInstrument::EXPIRED; |
| 48 WalletInstrumentWrapper wrapper(instrument.get()); |
| 49 EXPECT_TRUE(wrapper.GetDisplayText().empty()); |
| 50 } |
| 51 |
| 38 } // autofill | 52 } // autofill |
| OLD | NEW |