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

Unified Diff: components/autofill/content/browser/wallet/full_wallet_unittest.cc

Issue 1288093004: rAc Wallet extirpation round 4: clean out RPC code (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix gn Created 5 years, 4 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 side-by-side diff with in-line comments
Download patch
Index: components/autofill/content/browser/wallet/full_wallet_unittest.cc
diff --git a/components/autofill/content/browser/wallet/full_wallet_unittest.cc b/components/autofill/content/browser/wallet/full_wallet_unittest.cc
index 1b38c92f8ad95f4045d4c43069a9c0c314199b3f..990bdcd6b21282fd63fb9dfc70a7b37739bb0095 100644
--- a/components/autofill/content/browser/wallet/full_wallet_unittest.cc
+++ b/components/autofill/content/browser/wallet/full_wallet_unittest.cc
@@ -8,7 +8,6 @@
#include "base/strings/utf_string_conversions.h"
#include "base/values.h"
#include "components/autofill/content/browser/wallet/full_wallet.h"
-#include "components/autofill/content/browser/wallet/required_action.h"
#include "components/autofill/content/browser/wallet/wallet_test_util.h"
#include "components/autofill/core/browser/autofill_type.h"
#include "components/autofill/core/browser/field_types.h"
@@ -16,457 +15,20 @@
using base::ASCIIToUTF16;
-namespace {
-
-const char kFullWalletValidResponse[] =
- "{"
- " \"expiration_month\":12,"
- " \"expiration_year\":3000,"
- " \"iin\":\"iin\","
- " \"rest\":\"rest\","
- " \"billing_address\":"
- " {"
- " \"phone_number\":\"phone_number\","
- " \"postal_address\":"
- " {"
- " \"recipient_name\":\"recipient_name\","
- " \"address_line\":"
- " ["
- " \"address_line_1\","
- " \"address_line_2\""
- " ],"
- " \"locality_name\":\"locality_name\","
- " \"dependent_locality_name\":\"dependent_locality_name\","
- " \"administrative_area_name\":\"admin_area_name\","
- " \"postal_code_number\":\"postal_code_number\","
- " \"sorting_code\":\"sorting_code\","
- " \"country_name_code\":\"US\","
- " \"language_code\":\"language_code\""
- " }"
- " },"
- " \"shipping_address\":"
- " {"
- " \"id\":\"address_id\","
- " \"phone_number\":\"ship_phone_number\","
- " \"postal_address\":"
- " {"
- " \"recipient_name\":\"ship_recipient_name\","
- " \"address_line\":"
- " ["
- " \"ship_address_line_1\","
- " \"ship_address_line_2\""
- " ],"
- " \"locality_name\":\"ship_locality_name\","
- " \"dependent_locality_name\":\"ship_dependent_locality_name\","
- " \"administrative_area_name\":\"ship_admin_area_name\","
- " \"postal_code_number\":\"ship_postal_code_number\","
- " \"sorting_code\":\"ship_sorting_code\","
- " \"country_name_code\":\"US\","
- " \"language_code\":\"ship_language_code\""
- " }"
- " },"
- " \"required_action\":"
- " ["
- " ]"
- "}";
-
-const char kFullWalletMissingExpirationMonth[] =
- "{"
- " \"expiration_year\":2012,"
- " \"iin\":\"iin\","
- " \"rest\":\"rest\","
- " \"billing_address\":"
- " {"
- " \"id\":\"id\","
- " \"phone_number\":\"phone_number\","
- " \"postal_address\":"
- " {"
- " \"recipient_name\":\"recipient_name\","
- " \"address_line\":"
- " ["
- " \"address_line_1\","
- " \"address_line_2\""
- " ],"
- " \"locality_name\":\"locality_name\","
- " \"administrative_area_name\":\"administrative_area_name\","
- " \"postal_code_number\":\"postal_code_number\","
- " \"country_name_code\":\"country_name_code\","
- " \"language_code\":\"language_code\""
- " }"
- " },"
- " \"shipping_address\":"
- " {"
- " \"id\":\"address_id\","
- " \"phone_number\":\"ship_phone_number\","
- " \"postal_address\":"
- " {"
- " \"recipient_name\":\"ship_recipient_name\","
- " \"address_line\":"
- " ["
- " \"ship_address_line_1\","
- " \"ship_address_line_2\""
- " ],"
- " \"locality_name\":\"ship_locality_name\","
- " \"administrative_area_name\":\"ship_admin_area_name\","
- " \"postal_code_number\":\"ship_postal_code_number\","
- " \"country_name_code\":\"ship_country_name_code\","
- " \"language_code\":\"ship_language_code\""
- " }"
- " },"
- " \"required_action\":"
- " ["
- " ]"
- "}";
-
-const char kFullWalletMissingExpirationYear[] =
- "{"
- " \"expiration_month\":12,"
- " \"iin\":\"iin\","
- " \"rest\":\"rest\","
- " \"billing_address\":"
- " {"
- " \"id\":\"id\","
- " \"phone_number\":\"phone_number\","
- " \"postal_address\":"
- " {"
- " \"recipient_name\":\"recipient_name\","
- " \"address_line\":"
- " ["
- " \"address_line_1\","
- " \"address_line_2\""
- " ],"
- " \"locality_name\":\"locality_name\","
- " \"administrative_area_name\":\"administrative_area_name\","
- " \"postal_code_number\":\"postal_code_number\","
- " \"country_name_code\":\"country_name_code\","
- " \"language_code\":\"language_code\""
- " }"
- " },"
- " \"shipping_address\":"
- " {"
- " \"id\":\"address_id\","
- " \"phone_number\":\"ship_phone_number\","
- " \"postal_address\":"
- " {"
- " \"recipient_name\":\"ship_recipient_name\","
- " \"address_line\":"
- " ["
- " \"ship_address_line_1\","
- " \"ship_address_line_2\""
- " ],"
- " \"locality_name\":\"ship_locality_name\","
- " \"administrative_area_name\":\"ship_admin_area_name\","
- " \"postal_code_number\":\"ship_postal_code_number\","
- " \"country_name_code\":\"ship_country_name_code\","
- " \"language_code\":\"ship_language_code\""
- " }"
- " },"
- " \"required_action\":"
- " ["
- " ]"
- "}";
-
-const char kFullWalletMissingIin[] =
- "{"
- " \"expiration_month\":12,"
- " \"expiration_year\":2012,"
- " \"rest\":\"rest\","
- " \"billing_address\":"
- " {"
- " \"id\":\"id\","
- " \"phone_number\":\"phone_number\","
- " \"postal_address\":"
- " {"
- " \"recipient_name\":\"recipient_name\","
- " \"address_line\":"
- " ["
- " \"address_line_1\","
- " \"address_line_2\""
- " ],"
- " \"locality_name\":\"locality_name\","
- " \"administrative_area_name\":\"administrative_area_name\","
- " \"postal_code_number\":\"postal_code_number\","
- " \"country_name_code\":\"country_name_code\","
- " \"language_code\":\"language_code\""
- " }"
- " },"
- " \"shipping_address\":"
- " {"
- " \"id\":\"address_id\","
- " \"phone_number\":\"ship_phone_number\","
- " \"postal_address\":"
- " {"
- " \"recipient_name\":\"ship_recipient_name\","
- " \"address_line\":"
- " ["
- " \"ship_address_line_1\","
- " \"ship_address_line_2\""
- " ],"
- " \"locality_name\":\"ship_locality_name\","
- " \"administrative_area_name\":\"ship_admin_area_name\","
- " \"postal_code_number\":\"ship_postal_code_number\","
- " \"country_name_code\":\"ship_country_name_code\","
- " \"language_code\":\"language_code\""
- " }"
- " },"
- " \"required_action\":"
- " ["
- " ]"
- "}";
-
-const char kFullWalletMissingRest[] =
- "{"
- " \"expiration_month\":12,"
- " \"expiration_year\":2012,"
- " \"iin\":\"iin\","
- " \"billing_address\":"
- " {"
- " \"id\":\"id\","
- " \"phone_number\":\"phone_number\","
- " \"postal_address\":"
- " {"
- " \"recipient_name\":\"recipient_name\","
- " \"address_line\":"
- " ["
- " \"address_line_1\","
- " \"address_line_2\""
- " ],"
- " \"locality_name\":\"locality_name\","
- " \"administrative_area_name\":\"administrative_area_name\","
- " \"postal_code_number\":\"postal_code_number\","
- " \"country_name_code\":\"country_name_code\","
- " \"language_code\":\"language_code\""
- " }"
- " },"
- " \"shipping_address\":"
- " {"
- " \"id\":\"address_id\","
- " \"phone_number\":\"ship_phone_number\","
- " \"postal_address\":"
- " {"
- " \"recipient_name\":\"ship_recipient_name\","
- " \"address_line\":"
- " ["
- " \"ship_address_line_1\","
- " \"ship_address_line_2\""
- " ],"
- " \"locality_name\":\"ship_locality_name\","
- " \"administrative_area_name\":\"ship_admin_area_name\","
- " \"postal_code_number\":\"ship_postal_code_number\","
- " \"country_name_code\":\"ship_country_name_code\","
- " \"language_code\":\"ship_language_code\""
- " }"
- " },"
- " \"required_action\":"
- " ["
- " ]"
- "}";
-
-const char kFullWalletMissingBillingAddress[] =
- "{"
- " \"expiration_month\":12,"
- " \"expiration_year\":2012,"
- " \"iin\":\"iin\","
- " \"rest\":\"rest\","
- " \"shipping_address\":"
- " {"
- " \"id\":\"address_id\","
- " \"phone_number\":\"ship_phone_number\","
- " \"postal_address\":"
- " {"
- " \"recipient_name\":\"ship_recipient_name\","
- " \"address_line\":"
- " ["
- " \"ship_address_line_1\","
- " \"ship_address_line_2\""
- " ],"
- " \"locality_name\":\"ship_locality_name\","
- " \"administrative_area_name\":\"ship_admin_area_name\","
- " \"postal_code_number\":\"ship_postal_code_number\","
- " \"country_name_code\":\"ship_country_name_code\","
- " \"language_code\":\"ship_language_code\""
- " }"
- " },"
- " \"required_action\":"
- " ["
- " ]"
- "}";
-
-const char kFullWalletWithRequiredActions[] =
- "{"
- " \"required_action\":"
- " ["
- " \"CHOOSE_ANOTHER_INSTRUMENT_OR_ADDRESS\","
- " \"update_EXPIRATION_date\","
- " \"verify_CVV\","
- " \" REQuIrE_PHONE_NumBER\t\n\r \""
- " ]"
- "}";
-
-const char kFullWalletWithInvalidRequiredActions[] =
- "{"
- " \"required_action\":"
- " ["
- " \" setup_wallet\","
- " \"AcCePt_ToS \","
- " \"UPGRADE_MIN_ADDRESS\","
- " \"INVALID_form_field\","
- " \" \\tGAIA_auth \\n\\r\","
- " \"PASSIVE_GAIA_AUTH\","
- " \" 忍者の正体 \""
- " ]"
- "}";
-
-const char kFullWalletMalformedBillingAddress[] =
- "{"
- " \"expiration_month\":12,"
- " \"expiration_year\":2012,"
- " \"iin\":\"iin\","
- " \"rest\":\"rest\","
- " \"billing_address\":"
- " {"
- " \"phone_number\":\"phone_number\","
- " \"postal_address\":"
- " {"
- " \"recipient_name\":\"recipient_name\","
- " \"address_line\":"
- " ["
- " \"address_line_1\","
- " \"address_line_2\""
- " ],"
- " \"locality_name\":\"locality_name\","
- " \"administrative_area_name\":\"administrative_area_name\""
- " }"
- " },"
- " \"shipping_address\":"
- " {"
- " \"id\":\"address_id\","
- " \"phone_number\":\"ship_phone_number\","
- " \"postal_address\":"
- " {"
- " \"recipient_name\":\"ship_recipient_name\","
- " \"address_line\":"
- " ["
- " \"ship_address_line_1\","
- " \"ship_address_line_2\""
- " ],"
- " \"locality_name\":\"ship_locality_name\","
- " \"administrative_area_name\":\"ship_admin_area_name\","
- " \"postal_code_number\":\"ship_postal_code_number\","
- " \"country_name_code\":\"ship_country_name_code\","
- " \"language_code\":\"ship_language_code\""
- " }"
- " },"
- " \"required_action\":"
- " ["
- " ]"
- "}";
-
-} // anonymous namespace
-
namespace autofill {
namespace wallet {
class FullWalletTest : public testing::Test {
public:
FullWalletTest() {}
- protected:
- void SetUpDictionary(const std::string& json) {
- scoped_ptr<base::Value> value = base::JSONReader::Read(json);
- ASSERT_TRUE(value.get());
- ASSERT_TRUE(value->IsType(base::Value::TYPE_DICTIONARY));
- dict.reset(static_cast<base::DictionaryValue*>(value.release()));
- }
- scoped_ptr<base::DictionaryValue> dict;
-};
-
-TEST_F(FullWalletTest, CreateFullWalletMissingExpirationMonth) {
- SetUpDictionary(kFullWalletMissingExpirationMonth);
- EXPECT_EQ(NULL, FullWallet::CreateFullWallet(*dict).get());
-}
-
-TEST_F(FullWalletTest, CreateFullWalletMissingExpirationYear) {
- SetUpDictionary(kFullWalletMissingExpirationYear);
- EXPECT_EQ(NULL, FullWallet::CreateFullWallet(*dict).get());
-}
-TEST_F(FullWalletTest, CreateFullWalletMissingIin) {
- SetUpDictionary(kFullWalletMissingIin);
- EXPECT_EQ(NULL, FullWallet::CreateFullWallet(*dict).get());
-}
-
-TEST_F(FullWalletTest, CreateFullWalletMissingRest) {
- SetUpDictionary(kFullWalletMissingRest);
- EXPECT_EQ(NULL, FullWallet::CreateFullWallet(*dict).get());
-}
-
-TEST_F(FullWalletTest, CreateFullWalletMissingBillingAddress) {
- SetUpDictionary(kFullWalletMissingBillingAddress);
- EXPECT_EQ(NULL, FullWallet::CreateFullWallet(*dict).get());
-}
-
-TEST_F(FullWalletTest, CreateFullWalletMalformedBillingAddress) {
- SetUpDictionary(kFullWalletMalformedBillingAddress);
- EXPECT_EQ(NULL, FullWallet::CreateFullWallet(*dict).get());
-}
-
-TEST_F(FullWalletTest, CreateFullWalletWithRequiredActions) {
- SetUpDictionary(kFullWalletWithRequiredActions);
-
- std::vector<RequiredAction> required_actions;
- required_actions.push_back(CHOOSE_ANOTHER_INSTRUMENT_OR_ADDRESS);
- required_actions.push_back(UPDATE_EXPIRATION_DATE);
- required_actions.push_back(VERIFY_CVV);
- required_actions.push_back(REQUIRE_PHONE_NUMBER);
-
- FullWallet full_wallet(-1,
- -1,
- std::string(),
- std::string(),
- scoped_ptr<Address>(),
- scoped_ptr<Address>(),
- required_actions);
- EXPECT_EQ(full_wallet, *FullWallet::CreateFullWallet(*dict));
-
- ASSERT_FALSE(required_actions.empty());
- required_actions.pop_back();
- FullWallet different_required_actions(-1,
- -1,
- std::string(),
- std::string(),
- scoped_ptr<Address>(),
- scoped_ptr<Address>(),
- required_actions);
- EXPECT_NE(full_wallet, different_required_actions);
-}
-
-TEST_F(FullWalletTest, CreateFullWalletWithInvalidRequiredActions) {
- SetUpDictionary(kFullWalletWithInvalidRequiredActions);
- EXPECT_EQ(NULL, FullWallet::CreateFullWallet(*dict).get());
-}
-
-TEST_F(FullWalletTest, CreateFullWallet) {
- SetUpDictionary(kFullWalletValidResponse);
- std::vector<RequiredAction> required_actions;
- FullWallet full_wallet(12,
- 3000,
- "iin",
- "rest",
- GetTestAddress(),
- GetTestNonDefaultShippingAddress(),
- required_actions);
- EXPECT_EQ(full_wallet, *FullWallet::CreateFullWallet(*dict));
-}
+ private:
+ DISALLOW_COPY_AND_ASSIGN(FullWalletTest);
+};
TEST_F(FullWalletTest, RestLengthCorrectDecryptionTest) {
- std::vector<RequiredAction> required_actions;
- FullWallet full_wallet(12,
- 2012,
- "528512",
- "5ec4feecf9d6",
- GetTestAddress(),
- GetTestShippingAddress(),
- required_actions);
+ FullWallet full_wallet(12, 2012, "528512", "5ec4feecf9d6", GetTestAddress(),
+ GetTestShippingAddress());
std::vector<uint8> one_time_pad;
EXPECT_TRUE(base::HexStringToBytes("5F04A8704183", &one_time_pad));
full_wallet.set_one_time_pad(one_time_pad);
@@ -478,14 +40,8 @@ TEST_F(FullWalletTest, RestLengthCorrectDecryptionTest) {
}
TEST_F(FullWalletTest, RestLengthUnderDecryptionTest) {
- std::vector<RequiredAction> required_actions;
- FullWallet full_wallet(12,
- 2012,
- "528512",
- "4c567667e6",
- GetTestAddress(),
- GetTestShippingAddress(),
- required_actions);
+ FullWallet full_wallet(12, 2012, "528512", "4c567667e6", GetTestAddress(),
+ GetTestShippingAddress());
std::vector<uint8> one_time_pad;
EXPECT_TRUE(base::HexStringToBytes("063AD35324BF", &one_time_pad));
full_wallet.set_one_time_pad(one_time_pad);
@@ -497,14 +53,8 @@ TEST_F(FullWalletTest, RestLengthUnderDecryptionTest) {
}
TEST_F(FullWalletTest, GetCreditCardInfo) {
- std::vector<RequiredAction> required_actions;
- FullWallet full_wallet(12,
- 2015,
- "528512",
- "1a068673eb0",
- GetTestAddress(),
- GetTestShippingAddress(),
- required_actions);
+ FullWallet full_wallet(12, 2015, "528512", "1a068673eb0", GetTestAddress(),
+ GetTestShippingAddress());
EXPECT_EQ(ASCIIToUTF16("15"),
full_wallet.GetInfo(
« no previous file with comments | « components/autofill/content/browser/wallet/full_wallet.cc ('k') | components/autofill/content/browser/wallet/gaia_account.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698