| 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 "components/autofill/content/browser/wallet/full_wallet.h" |
| 6 |
| 5 #include <stdint.h> | 7 #include <stdint.h> |
| 6 | 8 |
| 9 #include <memory> |
| 10 |
| 7 #include "base/json/json_reader.h" | 11 #include "base/json/json_reader.h" |
| 8 #include "base/macros.h" | 12 #include "base/macros.h" |
| 9 #include "base/memory/scoped_ptr.h" | |
| 10 #include "base/strings/string_number_conversions.h" | 13 #include "base/strings/string_number_conversions.h" |
| 11 #include "base/strings/utf_string_conversions.h" | 14 #include "base/strings/utf_string_conversions.h" |
| 12 #include "base/values.h" | 15 #include "base/values.h" |
| 13 #include "components/autofill/content/browser/wallet/full_wallet.h" | |
| 14 #include "components/autofill/content/browser/wallet/wallet_test_util.h" | 16 #include "components/autofill/content/browser/wallet/wallet_test_util.h" |
| 15 #include "components/autofill/core/browser/autofill_type.h" | 17 #include "components/autofill/core/browser/autofill_type.h" |
| 16 #include "components/autofill/core/browser/field_types.h" | 18 #include "components/autofill/core/browser/field_types.h" |
| 17 #include "testing/gtest/include/gtest/gtest.h" | 19 #include "testing/gtest/include/gtest/gtest.h" |
| 18 | 20 |
| 19 using base::ASCIIToUTF16; | 21 using base::ASCIIToUTF16; |
| 20 | 22 |
| 21 namespace autofill { | 23 namespace autofill { |
| 22 namespace wallet { | 24 namespace wallet { |
| 23 | 25 |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 "", AutofillType(CREDIT_CARD_EXP_DATE_4_DIGIT_YEAR))); | 74 "", AutofillType(CREDIT_CARD_EXP_DATE_4_DIGIT_YEAR))); |
| 73 | 75 |
| 74 std::vector<uint8_t> one_time_pad; | 76 std::vector<uint8_t> one_time_pad; |
| 75 EXPECT_TRUE(base::HexStringToBytes("075DA779F98B", &one_time_pad)); | 77 EXPECT_TRUE(base::HexStringToBytes("075DA779F98B", &one_time_pad)); |
| 76 full_wallet.set_one_time_pad(one_time_pad); | 78 full_wallet.set_one_time_pad(one_time_pad); |
| 77 EXPECT_EQ(ASCIIToUTF16("MasterCard"), | 79 EXPECT_EQ(ASCIIToUTF16("MasterCard"), |
| 78 full_wallet.GetInfo("", AutofillType(CREDIT_CARD_TYPE))); | 80 full_wallet.GetInfo("", AutofillType(CREDIT_CARD_TYPE))); |
| 79 } | 81 } |
| 80 | 82 |
| 81 TEST_F(FullWalletTest, CreateFullWalletFromClearTextData) { | 83 TEST_F(FullWalletTest, CreateFullWalletFromClearTextData) { |
| 82 scoped_ptr<FullWallet> full_wallet = | 84 std::unique_ptr<FullWallet> full_wallet = |
| 83 FullWallet::CreateFullWalletFromClearText( | 85 FullWallet::CreateFullWalletFromClearText(11, 2012, "5555555555554444", |
| 84 11, 2012, | 86 "123", GetTestAddress(), |
| 85 "5555555555554444", "123", | 87 GetTestShippingAddress()); |
| 86 GetTestAddress(), GetTestShippingAddress()); | |
| 87 EXPECT_EQ(ASCIIToUTF16("5555555555554444"), | 88 EXPECT_EQ(ASCIIToUTF16("5555555555554444"), |
| 88 full_wallet->GetInfo("", AutofillType(CREDIT_CARD_NUMBER))); | 89 full_wallet->GetInfo("", AutofillType(CREDIT_CARD_NUMBER))); |
| 89 EXPECT_EQ(ASCIIToUTF16("MasterCard"), | 90 EXPECT_EQ(ASCIIToUTF16("MasterCard"), |
| 90 full_wallet->GetInfo("", AutofillType(CREDIT_CARD_TYPE))); | 91 full_wallet->GetInfo("", AutofillType(CREDIT_CARD_TYPE))); |
| 91 EXPECT_EQ(ASCIIToUTF16("123"), | 92 EXPECT_EQ(ASCIIToUTF16("123"), |
| 92 full_wallet->GetInfo( | 93 full_wallet->GetInfo( |
| 93 "", AutofillType(CREDIT_CARD_VERIFICATION_CODE))); | 94 "", AutofillType(CREDIT_CARD_VERIFICATION_CODE))); |
| 94 EXPECT_EQ(ASCIIToUTF16("11/12"), | 95 EXPECT_EQ(ASCIIToUTF16("11/12"), |
| 95 full_wallet->GetInfo( | 96 full_wallet->GetInfo( |
| 96 "", AutofillType(CREDIT_CARD_EXP_DATE_2_DIGIT_YEAR))); | 97 "", AutofillType(CREDIT_CARD_EXP_DATE_2_DIGIT_YEAR))); |
| 97 EXPECT_TRUE(GetTestAddress()->EqualsIgnoreID( | 98 EXPECT_TRUE(GetTestAddress()->EqualsIgnoreID( |
| 98 *full_wallet->billing_address())); | 99 *full_wallet->billing_address())); |
| 99 EXPECT_TRUE(GetTestShippingAddress()->EqualsIgnoreID( | 100 EXPECT_TRUE(GetTestShippingAddress()->EqualsIgnoreID( |
| 100 *full_wallet->shipping_address())); | 101 *full_wallet->shipping_address())); |
| 101 } | 102 } |
| 102 | 103 |
| 103 } // namespace wallet | 104 } // namespace wallet |
| 104 } // namespace autofill | 105 } // namespace autofill |
| OLD | NEW |