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

Unified Diff: chrome/browser/autofill/wallet/full_wallet_unittest.cc

Issue 12434004: Move remaining Autofill code to //components/autofill. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix long lines Created 7 years, 9 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
« no previous file with comments | « chrome/browser/autofill/wallet/full_wallet.cc ('k') | chrome/browser/autofill/wallet/instrument.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/autofill/wallet/full_wallet_unittest.cc
diff --git a/chrome/browser/autofill/wallet/full_wallet_unittest.cc b/chrome/browser/autofill/wallet/full_wallet_unittest.cc
deleted file mode 100644
index adea7f0db5198752f6e0f5e99a2dd1a3fb566cb9..0000000000000000000000000000000000000000
--- a/chrome/browser/autofill/wallet/full_wallet_unittest.cc
+++ /dev/null
@@ -1,465 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "base/json/json_reader.h"
-#include "base/logging.h"
-#include "base/memory/scoped_ptr.h"
-#include "base/utf_string_conversions.h"
-#include "base/values.h"
-#include "chrome/browser/autofill/wallet/full_wallet.h"
-#include "chrome/browser/autofill/wallet/required_action.h"
-#include "testing/gtest/include/gtest/gtest.h"
-
-namespace {
-
-const char kFullWalletValidResponse[] =
- "{"
- " \"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\","
- " \"postal_code_number\":\"postal_code_number\","
- " \"country_name_code\":\"country_name_code\""
- " }"
- " },"
- " \"shipping_address\":"
- " {"
- " \"id\":\"ship_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\""
- " }"
- " },"
- " \"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\""
- " }"
- " },"
- " \"shipping_address\":"
- " {"
- " \"id\":\"ship_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\""
- " }"
- " },"
- " \"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\""
- " }"
- " },"
- " \"shipping_address\":"
- " {"
- " \"id\":\"ship_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\""
- " }"
- " },"
- " \"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\""
- " }"
- " },"
- " \"shipping_address\":"
- " {"
- " \"id\":\"ship_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\""
- " }"
- " },"
- " \"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\""
- " }"
- " },"
- " \"shipping_address\":"
- " {"
- " \"id\":\"ship_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\""
- " }"
- " },"
- " \"required_action\":"
- " ["
- " ]"
- "}";
-
-const char kFullWalletMissingBillingAddress[] =
- "{"
- " \"expiration_month\":12,"
- " \"expiration_year\":2012,"
- " \"iin\":\"iin\","
- " \"rest\":\"rest\","
- " \"shipping_address\":"
- " {"
- " \"id\":\"ship_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\""
- " }"
- " },"
- " \"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\":\"ship_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\""
- " }"
- " },"
- " \"required_action\":"
- " ["
- " ]"
- "}";
-
-} // anonymous namespace
-
-namespace autofill {
-namespace wallet {
-
-class FullWalletTest : public testing::Test {
- public:
- FullWalletTest() {}
- protected:
- void SetUpDictionary(const std::string& json) {
- scoped_ptr<Value> value(base::JSONReader::Read(json));
- ASSERT_TRUE(value.get());
- ASSERT_TRUE(value->IsType(Value::TYPE_DICTIONARY));
- dict.reset(static_cast<DictionaryValue*>(value.release()));
- }
- scoped_ptr<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,
- "",
- "",
- 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,
- "",
- "",
- 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);
- // NOTE: FullWallet billing address doesn't require an ID.
- scoped_ptr<Address> billing_address(new Address(
- "country_name_code",
- ASCIIToUTF16("recipient_name"),
- ASCIIToUTF16("address_line_1"),
- ASCIIToUTF16("address_line_2"),
- ASCIIToUTF16("locality_name"),
- ASCIIToUTF16("administrative_area_name"),
- ASCIIToUTF16("postal_code_number"),
- ASCIIToUTF16("phone_number"),
- ""));
- scoped_ptr<Address> shipping_address(new Address(
- "ship_country_name_code",
- ASCIIToUTF16("ship_recipient_name"),
- ASCIIToUTF16("ship_address_line_1"),
- ASCIIToUTF16("ship_address_line_2"),
- ASCIIToUTF16("ship_locality_name"),
- ASCIIToUTF16("ship_admin_area_name"),
- ASCIIToUTF16("ship_postal_code_number"),
- ASCIIToUTF16("ship_phone_number"),
- "ship_id"));
- std::vector<RequiredAction> required_actions;
- FullWallet full_wallet(12,
- 2012,
- "iin",
- "rest",
- billing_address.Pass(),
- shipping_address.Pass(),
- required_actions);
- EXPECT_EQ(full_wallet, *FullWallet::CreateFullWallet(*dict));
-}
-
-// TODO(ahutter): Add tests for GetPan and GetCvn.
-
-} // namespace wallet
-} // namespace autofill
« no previous file with comments | « chrome/browser/autofill/wallet/full_wallet.cc ('k') | chrome/browser/autofill/wallet/instrument.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698