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

Side by Side Diff: components/autofill/content/browser/wallet/full_wallet_unittest.cc

Issue 1931043002: Remove requestAutocomplete (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 7 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
OLDNEW
(Empty)
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 "components/autofill/content/browser/wallet/full_wallet.h"
6
7 #include <stdint.h>
8
9 #include <memory>
10
11 #include "base/json/json_reader.h"
12 #include "base/macros.h"
13 #include "base/strings/string_number_conversions.h"
14 #include "base/strings/utf_string_conversions.h"
15 #include "base/values.h"
16 #include "components/autofill/content/browser/wallet/wallet_test_util.h"
17 #include "components/autofill/core/browser/autofill_type.h"
18 #include "components/autofill/core/browser/field_types.h"
19 #include "testing/gtest/include/gtest/gtest.h"
20
21 using base::ASCIIToUTF16;
22
23 namespace autofill {
24 namespace wallet {
25
26 class FullWalletTest : public testing::Test {
27 public:
28 FullWalletTest() {}
29
30 private:
31 DISALLOW_COPY_AND_ASSIGN(FullWalletTest);
32 };
33
34 TEST_F(FullWalletTest, RestLengthCorrectDecryptionTest) {
35 FullWallet full_wallet(12, 2012, "528512", "5ec4feecf9d6", GetTestAddress(),
36 GetTestShippingAddress());
37 std::vector<uint8_t> one_time_pad;
38 EXPECT_TRUE(base::HexStringToBytes("5F04A8704183", &one_time_pad));
39 full_wallet.set_one_time_pad(one_time_pad);
40 EXPECT_EQ(ASCIIToUTF16("5285121925598459"),
41 full_wallet.GetInfo("", AutofillType(CREDIT_CARD_NUMBER)));
42 EXPECT_EQ(ASCIIToUTF16("989"),
43 full_wallet.GetInfo(
44 "", AutofillType(CREDIT_CARD_VERIFICATION_CODE)));
45 }
46
47 TEST_F(FullWalletTest, RestLengthUnderDecryptionTest) {
48 FullWallet full_wallet(12, 2012, "528512", "4c567667e6", GetTestAddress(),
49 GetTestShippingAddress());
50 std::vector<uint8_t> one_time_pad;
51 EXPECT_TRUE(base::HexStringToBytes("063AD35324BF", &one_time_pad));
52 full_wallet.set_one_time_pad(one_time_pad);
53 EXPECT_EQ(ASCIIToUTF16("5285127106109719"),
54 full_wallet.GetInfo("", AutofillType(CREDIT_CARD_NUMBER)));
55 EXPECT_EQ(ASCIIToUTF16("385"),
56 full_wallet.GetInfo(
57 "", AutofillType(CREDIT_CARD_VERIFICATION_CODE)));
58 }
59
60 TEST_F(FullWalletTest, GetCreditCardInfo) {
61 FullWallet full_wallet(12, 2015, "528512", "1a068673eb0", GetTestAddress(),
62 GetTestShippingAddress());
63
64 EXPECT_EQ(ASCIIToUTF16("15"),
65 full_wallet.GetInfo(
66 "", AutofillType(CREDIT_CARD_EXP_2_DIGIT_YEAR)));
67
68 EXPECT_EQ(ASCIIToUTF16("12/15"),
69 full_wallet.GetInfo(
70 "", AutofillType(CREDIT_CARD_EXP_DATE_2_DIGIT_YEAR)));
71
72 EXPECT_EQ(ASCIIToUTF16("12/2015"),
73 full_wallet.GetInfo(
74 "", AutofillType(CREDIT_CARD_EXP_DATE_4_DIGIT_YEAR)));
75
76 std::vector<uint8_t> one_time_pad;
77 EXPECT_TRUE(base::HexStringToBytes("075DA779F98B", &one_time_pad));
78 full_wallet.set_one_time_pad(one_time_pad);
79 EXPECT_EQ(ASCIIToUTF16("MasterCard"),
80 full_wallet.GetInfo("", AutofillType(CREDIT_CARD_TYPE)));
81 }
82
83 TEST_F(FullWalletTest, CreateFullWalletFromClearTextData) {
84 std::unique_ptr<FullWallet> full_wallet =
85 FullWallet::CreateFullWalletFromClearText(11, 2012, "5555555555554444",
86 "123", GetTestAddress(),
87 GetTestShippingAddress());
88 EXPECT_EQ(ASCIIToUTF16("5555555555554444"),
89 full_wallet->GetInfo("", AutofillType(CREDIT_CARD_NUMBER)));
90 EXPECT_EQ(ASCIIToUTF16("MasterCard"),
91 full_wallet->GetInfo("", AutofillType(CREDIT_CARD_TYPE)));
92 EXPECT_EQ(ASCIIToUTF16("123"),
93 full_wallet->GetInfo(
94 "", AutofillType(CREDIT_CARD_VERIFICATION_CODE)));
95 EXPECT_EQ(ASCIIToUTF16("11/12"),
96 full_wallet->GetInfo(
97 "", AutofillType(CREDIT_CARD_EXP_DATE_2_DIGIT_YEAR)));
98 EXPECT_TRUE(GetTestAddress()->EqualsIgnoreID(
99 *full_wallet->billing_address()));
100 EXPECT_TRUE(GetTestShippingAddress()->EqualsIgnoreID(
101 *full_wallet->shipping_address()));
102 }
103
104 } // namespace wallet
105 } // namespace autofill
OLDNEW
« no previous file with comments | « components/autofill/content/browser/wallet/full_wallet.cc ('k') | components/autofill/content/browser/wallet/wallet_address.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698