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

Side by Side Diff: chrome/browser/autofill/wallet/full_wallet_unittest.cc

Issue 11777007: Adds wallet::RequiredAction for when we start interacting with Online Wallet. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: comment fix Created 7 years, 11 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "base/json/json_reader.h" 5 #include "base/json/json_reader.h"
6 #include "base/logging.h" 6 #include "base/logging.h"
7 #include "base/memory/scoped_ptr.h" 7 #include "base/memory/scoped_ptr.h"
8 #include "base/values.h" 8 #include "base/values.h"
9 #include "chrome/browser/autofill/wallet/full_wallet.h" 9 #include "chrome/browser/autofill/wallet/full_wallet.h"
10 #include "chrome/browser/autofill/wallet/required_action.h"
10 #include "testing/gtest/include/gtest/gtest.h" 11 #include "testing/gtest/include/gtest/gtest.h"
11 12
12 namespace { 13 namespace {
13 14
14 const char kFullWalletValidResponse[] = 15 const char kFullWalletValidResponse[] =
15 "{" 16 "{"
16 " \"expiration_month\":12," 17 " \"expiration_month\":12,"
17 " \"expiration_year\":2012," 18 " \"expiration_year\":2012,"
18 " \"iin\":\"iin\"," 19 " \"iin\":\"iin\","
19 " \"rest\":\"rest\"," 20 " \"rest\":\"rest\","
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after
268 " }," 269 " },"
269 " \"required_action\":" 270 " \"required_action\":"
270 " [" 271 " ["
271 " ]" 272 " ]"
272 "}"; 273 "}";
273 274
274 const char kFullWalletWithRequiredActions[] = 275 const char kFullWalletWithRequiredActions[] =
275 "{" 276 "{"
276 " \"required_action\":" 277 " \"required_action\":"
277 " [" 278 " ["
278 " \"required_action\"" 279 " \"UPGRADE_MIN_ADDRESS\","
280 " \"update_EXPIRATION_date\","
281 " \"INVALID_form_field\","
282 " \"cvc_risk_CHALLENGE\","
283 " \" setup_wallet\"," // Here and below don't apply to FullWallet.
284 " \"AcCePt_ToS \","
285 " \" \\tGAIA_auth \\n\\r\","
286 " \" 忍者の正体 \""
279 " ]" 287 " ]"
280 "}"; 288 "}";
281 289
282 const char kFullWalletMalformedBillingAddress[] = 290 const char kFullWalletMalformedBillingAddress[] =
283 "{" 291 "{"
284 " \"expiration_month\":12," 292 " \"expiration_month\":12,"
285 " \"expiration_year\":2012," 293 " \"expiration_year\":2012,"
286 " \"iin\":\"iin\"," 294 " \"iin\":\"iin\","
287 " \"rest\":\"rest\"," 295 " \"rest\":\"rest\","
288 " \"billing_address\":" 296 " \"billing_address\":"
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
366 ASSERT_EQ(NULL, FullWallet::CreateFullWallet(*dict).get()); 374 ASSERT_EQ(NULL, FullWallet::CreateFullWallet(*dict).get());
367 } 375 }
368 376
369 TEST_F(FullWalletTest, CreateFullWalletMalformedBillingAddress) { 377 TEST_F(FullWalletTest, CreateFullWalletMalformedBillingAddress) {
370 SetUpDictionary(kFullWalletMalformedBillingAddress); 378 SetUpDictionary(kFullWalletMalformedBillingAddress);
371 ASSERT_EQ(NULL, FullWallet::CreateFullWallet(*dict).get()); 379 ASSERT_EQ(NULL, FullWallet::CreateFullWallet(*dict).get());
372 } 380 }
373 381
374 TEST_F(FullWalletTest, CreateFullWalletWithRequiredActions) { 382 TEST_F(FullWalletTest, CreateFullWalletWithRequiredActions) {
375 SetUpDictionary(kFullWalletWithRequiredActions); 383 SetUpDictionary(kFullWalletWithRequiredActions);
376 std::vector<std::string> required_actions; 384
377 required_actions.push_back("required_action"); 385 std::vector<RequiredAction> required_actions;
386 required_actions.push_back(
387 RequiredAction(RequiredAction::UPGRADE_MIN_ADDRESS));
388 required_actions.push_back(
389 RequiredAction(RequiredAction::UPDATE_EXPIRATION_DATE));
390 required_actions.push_back(
391 RequiredAction(RequiredAction::INVALID_FORM_FIELD));
392 required_actions.push_back(
393 RequiredAction(RequiredAction::CVC_RISK_CHALLENGE));
394
378 FullWallet full_wallet(-1, 395 FullWallet full_wallet(-1,
379 -1, 396 -1,
380 "", 397 "",
381 "", 398 "",
382 scoped_ptr<Address>(), 399 scoped_ptr<Address>(),
383 scoped_ptr<Address>(), 400 scoped_ptr<Address>(),
384 required_actions); 401 required_actions);
385 ASSERT_EQ(full_wallet, *FullWallet::CreateFullWallet(*dict)); 402 ASSERT_EQ(full_wallet, *FullWallet::CreateFullWallet(*dict));
386 } 403 }
387 404
(...skipping 10 matching lines...) Expand all
398 "id")); 415 "id"));
399 scoped_ptr<Address> shipping_address(new Address("ship_country_name_code", 416 scoped_ptr<Address> shipping_address(new Address("ship_country_name_code",
400 "ship_recipient_name", 417 "ship_recipient_name",
401 "ship_address_line_1", 418 "ship_address_line_1",
402 "ship_address_line_2", 419 "ship_address_line_2",
403 "ship_locality_name", 420 "ship_locality_name",
404 "ship_admin_area_name", 421 "ship_admin_area_name",
405 "ship_postal_code_number", 422 "ship_postal_code_number",
406 "ship_phone_number", 423 "ship_phone_number",
407 "ship_id")); 424 "ship_id"));
408 std::vector<std::string> required_actions; 425 std::vector<RequiredAction> required_actions;
409 FullWallet full_wallet(12, 426 FullWallet full_wallet(12,
410 2012, 427 2012,
411 "iin", 428 "iin",
412 "rest", 429 "rest",
413 billing_address.Pass(), 430 billing_address.Pass(),
414 shipping_address.Pass(), 431 shipping_address.Pass(),
415 required_actions); 432 required_actions);
416 ASSERT_EQ(full_wallet, *FullWallet::CreateFullWallet(*dict)); 433 ASSERT_EQ(full_wallet, *FullWallet::CreateFullWallet(*dict));
417 } 434 }
418 435
419 } // namespace wallet 436 } // namespace wallet
420 437
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698