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

Side by Side Diff: chrome/browser/autofill/wallet/wallet_items_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: class -> namespace 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/required_action.h"
9 #include "chrome/browser/autofill/wallet/wallet_items.h" 10 #include "chrome/browser/autofill/wallet/wallet_items.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 kMaskedInstrument[] = 15 const char kMaskedInstrument[] =
15 "{" 16 "{"
16 " \"descriptive_name\":\"descriptive_name\"," 17 " \"descriptive_name\":\"descriptive_name\","
17 " \"type\":\"VISA\"," 18 " \"type\":\"VISA\","
18 " \"supported_currency\":" 19 " \"supported_currency\":"
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 "{" 207 "{"
207 " \"legal_document_id\":\"doc_id\"," 208 " \"legal_document_id\":\"doc_id\","
208 " \"display_name\":\"display_name\"" 209 " \"display_name\":\"display_name\""
209 "}"; 210 "}";
210 211
211 const char kWalletItemsWithRequiredActions[] = 212 const char kWalletItemsWithRequiredActions[] =
212 "{" 213 "{"
213 " \"google_transaction_id\":\"google_transaction_id\"," 214 " \"google_transaction_id\":\"google_transaction_id\","
214 " \"required_action\":" 215 " \"required_action\":"
215 " [" 216 " ["
216 " \"required_action\"" 217 " \" setup_wallet\","
218 " \"AcCePt_ToS \","
219 " \" \\tGAIA_auth \\n\\r\","
220 " \"INVALID_form_field\","
221 " \"cvc_risk_CHALLENGE\"," // Here and below don't apply to WalletItems.
222 " \"UPGRADE_MIN_ADDRESS\","
223 " \"update_EXPIRATION_date\","
224 " \" 忍者の正体 \""
217 " ]" 225 " ]"
218 "}"; 226 "}";
219 227
220 const char kWalletItems[] = 228 const char kWalletItems[] =
221 "{" 229 "{"
222 " \"required_action\":" 230 " \"required_action\":"
223 " [" 231 " ["
224 " ]," 232 " ],"
225 " \"google_transaction_id\":\"google_transaction_id\"," 233 " \"google_transaction_id\":\"google_transaction_id\","
226 " \"instrument\":" 234 " \"instrument\":"
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
378 386
379 TEST_F(WalletItemsTest, CreateLegalDocument) { 387 TEST_F(WalletItemsTest, CreateLegalDocument) {
380 SetUpDictionary(kLegalDocument); 388 SetUpDictionary(kLegalDocument);
381 WalletItems::LegalDocument expected("doc_id", "display_name", "doc_body"); 389 WalletItems::LegalDocument expected("doc_id", "display_name", "doc_body");
382 ASSERT_EQ(expected, 390 ASSERT_EQ(expected,
383 *WalletItems::LegalDocument::CreateLegalDocument(*dict)); 391 *WalletItems::LegalDocument::CreateLegalDocument(*dict));
384 } 392 }
385 393
386 TEST_F(WalletItemsTest, CreateWalletItemsWithRequiredActions) { 394 TEST_F(WalletItemsTest, CreateWalletItemsWithRequiredActions) {
387 SetUpDictionary(kWalletItemsWithRequiredActions); 395 SetUpDictionary(kWalletItemsWithRequiredActions);
388 std::vector<std::string> required_actions; 396
389 required_actions.push_back("required_action"); 397 std::vector<RequiredAction> required_actions;
398 required_actions.push_back(SETUP_WALLET);
399 required_actions.push_back(ACCEPT_TOS);
400 required_actions.push_back(GAIA_AUTH);
401 required_actions.push_back(INVALID_FORM_FIELD);
402
390 WalletItems expected(required_actions, "google_transaction_id", "", ""); 403 WalletItems expected(required_actions, "google_transaction_id", "", "");
391 ASSERT_EQ(expected, *WalletItems::CreateWalletItems(*dict)); 404 ASSERT_EQ(expected, *WalletItems::CreateWalletItems(*dict));
392 } 405 }
393 406
394 TEST_F(WalletItemsTest, CreateWalletItems) { 407 TEST_F(WalletItemsTest, CreateWalletItems) {
395 SetUpDictionary(kWalletItems); 408 SetUpDictionary(kWalletItems);
396 std::vector<std::string> required_actions; 409 std::vector<RequiredAction> required_actions;
397 WalletItems expected(required_actions, 410 WalletItems expected(required_actions,
398 "google_transaction_id", 411 "google_transaction_id",
399 "default_instrument_id", 412 "default_instrument_id",
400 "default_address_id"); 413 "default_address_id");
401 414
402 scoped_ptr<Address> billing_address(new Address("country_code", 415 scoped_ptr<Address> billing_address(new Address("country_code",
403 "name", 416 "name",
404 "address1", 417 "address1",
405 "address2", 418 "address2",
406 "city", 419 "city",
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
438 new WalletItems::LegalDocument("doc_id", 451 new WalletItems::LegalDocument("doc_id",
439 "display_name", 452 "display_name",
440 "doc_body")); 453 "doc_body"));
441 expected.AddLegalDocument(legal_document.Pass()); 454 expected.AddLegalDocument(legal_document.Pass());
442 455
443 ASSERT_EQ(expected, *WalletItems::CreateWalletItems(*dict)); 456 ASSERT_EQ(expected, *WalletItems::CreateWalletItems(*dict));
444 } 457 }
445 458
446 } // namespace wallet 459 } // namespace wallet
447 460
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698