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.
5 #include "base/strings/utf_string_conversions.h"
6 #include "base/values.h"
7 #include "components/autofill/content/browser/wallet/instrument.h"
8 #include "components/autofill/content/browser/wallet/wallet_address.h"
9 #include "components/autofill/content/browser/wallet/wallet_test_util.h"
10 #include "testing/gtest/include/gtest/gtest.h"
14 const char kPrimaryAccountNumber[] = "4444444444444448";
15 const char kCardVerificationNumber[] = "123";
16 const char kLastFourDigits[] = "4448";
23 TEST(Instrument, LastFourDigits) {
24 Instrument instrument(ASCIIToUTF16(kPrimaryAccountNumber),
25 ASCIIToUTF16(kCardVerificationNumber),
29 GetTestShippingAddress().Pass());
31 EXPECT_EQ(ASCIIToUTF16(kLastFourDigits), instrument.last_four_digits());
34 TEST(Instrument, ToDictionary) {
35 base::DictionaryValue expected;
36 expected.SetString("type", "CREDIT_CARD");
37 expected.SetInteger("credit_card.exp_month", 12);
38 expected.SetInteger("credit_card.exp_year", 2015);
39 expected.SetString("credit_card.last_4_digits", kLastFourDigits);
40 expected.SetString("credit_card.fop_type", "VISA");
41 expected.SetString("credit_card.address.country_name_code", "US");
42 expected.SetString("credit_card.address.recipient_name",
43 "ship_recipient_name");
44 expected.SetString("credit_card.address.locality_name",
45 "ship_locality_name");
46 expected.SetString("credit_card.address.administrative_area_name",
47 "ship_admin_area_name");
48 expected.SetString("credit_card.address.postal_code_number",
49 "ship_postal_code_number");
50 base::ListValue* address_lines = new base::ListValue();
51 address_lines->AppendString("ship_address_line_1");
52 address_lines->AppendString("ship_address_line_2");
53 expected.Set("credit_card.address.address_line", address_lines);
55 Instrument instrument(ASCIIToUTF16(kPrimaryAccountNumber),
56 ASCIIToUTF16(kCardVerificationNumber),
60 GetTestShippingAddress().Pass());
62 EXPECT_TRUE(expected.Equals(instrument.ToDictionary().get()));
66 } // namespace autofill