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"
12 using base::ASCIIToUTF16;
16 const char kPrimaryAccountNumber[] = "4444444444444448";
17 const char kCardVerificationNumber[] = "123";
18 const char kLastFourDigits[] = "4448";
25 TEST(Instrument, LastFourDigits) {
26 Instrument instrument(ASCIIToUTF16(kPrimaryAccountNumber),
27 ASCIIToUTF16(kCardVerificationNumber),
31 GetTestShippingAddress().Pass());
33 EXPECT_EQ(ASCIIToUTF16(kLastFourDigits), instrument.last_four_digits());
36 TEST(Instrument, ToDictionary) {
37 base::DictionaryValue expected;
38 expected.SetString("type", "CREDIT_CARD");
39 expected.SetInteger("credit_card.exp_month", 12);
40 expected.SetInteger("credit_card.exp_year", 2015);
41 expected.SetString("credit_card.last_4_digits", kLastFourDigits);
42 expected.SetString("credit_card.fop_type", "VISA");
43 expected.SetString("credit_card.address.country_name_code", "US");
44 expected.SetString("credit_card.address.recipient_name",
45 "ship_recipient_name");
46 expected.SetString("credit_card.address.locality_name",
47 "ship_locality_name");
48 expected.SetString("credit_card.address.administrative_area_name",
49 "ship_admin_area_name");
50 expected.SetString("credit_card.address.postal_code_number",
51 "ship_postal_code_number");
52 base::ListValue* address_lines = new base::ListValue();
53 address_lines->AppendString("ship_address_line_1");
54 address_lines->AppendString("ship_address_line_2");
55 expected.Set("credit_card.address.address_line", address_lines);
57 Instrument instrument(ASCIIToUTF16(kPrimaryAccountNumber),
58 ASCIIToUTF16(kCardVerificationNumber),
62 GetTestShippingAddress().Pass());
64 EXPECT_TRUE(expected.Equals(instrument.ToDictionary().get()));
68 } // namespace autofill