OLD | NEW |
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 Loading... |
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 Loading... |
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(UPGRADE_MIN_ADDRESS); |
| 387 required_actions.push_back(UPDATE_EXPIRATION_DATE); |
| 388 required_actions.push_back(INVALID_FORM_FIELD); |
| 389 required_actions.push_back(CVC_RISK_CHALLENGE); |
| 390 |
378 FullWallet full_wallet(-1, | 391 FullWallet full_wallet(-1, |
379 -1, | 392 -1, |
380 "", | 393 "", |
381 "", | 394 "", |
382 scoped_ptr<Address>(), | 395 scoped_ptr<Address>(), |
383 scoped_ptr<Address>(), | 396 scoped_ptr<Address>(), |
384 required_actions); | 397 required_actions); |
385 ASSERT_EQ(full_wallet, *FullWallet::CreateFullWallet(*dict)); | 398 ASSERT_EQ(full_wallet, *FullWallet::CreateFullWallet(*dict)); |
386 } | 399 } |
387 | 400 |
(...skipping 10 matching lines...) Expand all Loading... |
398 "id")); | 411 "id")); |
399 scoped_ptr<Address> shipping_address(new Address("ship_country_name_code", | 412 scoped_ptr<Address> shipping_address(new Address("ship_country_name_code", |
400 "ship_recipient_name", | 413 "ship_recipient_name", |
401 "ship_address_line_1", | 414 "ship_address_line_1", |
402 "ship_address_line_2", | 415 "ship_address_line_2", |
403 "ship_locality_name", | 416 "ship_locality_name", |
404 "ship_admin_area_name", | 417 "ship_admin_area_name", |
405 "ship_postal_code_number", | 418 "ship_postal_code_number", |
406 "ship_phone_number", | 419 "ship_phone_number", |
407 "ship_id")); | 420 "ship_id")); |
408 std::vector<std::string> required_actions; | 421 std::vector<RequiredAction> required_actions; |
409 FullWallet full_wallet(12, | 422 FullWallet full_wallet(12, |
410 2012, | 423 2012, |
411 "iin", | 424 "iin", |
412 "rest", | 425 "rest", |
413 billing_address.Pass(), | 426 billing_address.Pass(), |
414 shipping_address.Pass(), | 427 shipping_address.Pass(), |
415 required_actions); | 428 required_actions); |
416 ASSERT_EQ(full_wallet, *FullWallet::CreateFullWallet(*dict)); | 429 ASSERT_EQ(full_wallet, *FullWallet::CreateFullWallet(*dict)); |
417 } | 430 } |
418 | 431 |
419 } // namespace wallet | 432 } // namespace wallet |
420 | 433 |
OLD | NEW |