data_model_wrapper_unittest.cc revision c2e0dbddbe15c98d52c4786dac06cb8952a8ae6d
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 3// found in the LICENSE file. 4 5#include "base/memory/scoped_ptr.h" 6#include "base/strings/string_number_conversions.h" 7#include "chrome/browser/ui/autofill/autofill_dialog_models.h" 8#include "chrome/browser/ui/autofill/data_model_wrapper.h" 9#include "components/autofill/browser/credit_card.h" 10#include "components/autofill/browser/field_types.h" 11#include "components/autofill/browser/wallet/wallet_items.h" 12#include "components/autofill/browser/wallet/wallet_test_util.h" 13#include "testing/gtest/include/gtest/gtest.h" 14 15namespace autofill { 16 17TEST(AutofillCreditCardWrapperTest, GetInfoCreditCardExpMonth) { 18 CreditCard card; 19 MonthComboboxModel model; 20 for (int month = 1; month <= 12; ++month) { 21 card.SetRawInfo(CREDIT_CARD_EXP_MONTH, base::IntToString16(month)); 22 AutofillCreditCardWrapper wrapper(&card); 23 EXPECT_EQ(model.GetItemAt(month), wrapper.GetInfo(CREDIT_CARD_EXP_MONTH)); 24 } 25} 26 27TEST(AutofillCreditCardWrapperTest, GetDisplayTextEmptyWhenExpired) { 28 CreditCard card; 29 AutofillCreditCardWrapper wrapper(&card); 30 EXPECT_TRUE(wrapper.GetDisplayText().empty()); 31} 32 33TEST(WalletInstrumentWrapperTest, GetInfoCreditCardExpMonth) { 34 scoped_ptr<wallet::WalletItems::MaskedInstrument> instrument( 35 wallet::GetTestMaskedInstrument()); 36 MonthComboboxModel model; 37 for (int month = 1; month <= 12; ++month) { 38 instrument->expiration_month_ = month; 39 WalletInstrumentWrapper wrapper(instrument.get()); 40 EXPECT_EQ(model.GetItemAt(month), wrapper.GetInfo(CREDIT_CARD_EXP_MONTH)); 41 } 42} 43 44TEST(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 52} // autofill 53