| 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/required_action.h" | 9 #include "chrome/browser/autofill/wallet/required_action.h" |
| 10 #include "chrome/browser/autofill/wallet/wallet_items.h" | 10 #include "chrome/browser/autofill/wallet/wallet_items.h" |
| (...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 211 | 211 |
| 212 const char kWalletItemsWithRequiredActions[] = | 212 const char kWalletItemsWithRequiredActions[] = |
| 213 "{" | 213 "{" |
| 214 " \"google_transaction_id\":\"google_transaction_id\"," | 214 " \"google_transaction_id\":\"google_transaction_id\"," |
| 215 " \"obfuscated_gaia_id\":\"\"," | 215 " \"obfuscated_gaia_id\":\"\"," |
| 216 " \"required_action\":" | 216 " \"required_action\":" |
| 217 " [" | 217 " [" |
| 218 " \" setup_wallet\"," | 218 " \" setup_wallet\"," |
| 219 " \"AcCePt_ToS \"," | 219 " \"AcCePt_ToS \"," |
| 220 " \" \\tGAIA_auth \\n\\r\"," | 220 " \" \\tGAIA_auth \\n\\r\"," |
| 221 " \"INVALID_form_field\"" | 221 " \"INVALID_form_field\"," |
| 222 " \" pAsSiVe_GAIA_auth \"" |
| 222 " ]" | 223 " ]" |
| 223 "}"; | 224 "}"; |
| 224 | 225 |
| 225 const char kWalletItemsWithInvalidRequiredActions[] = | 226 const char kWalletItemsWithInvalidRequiredActions[] = |
| 226 "{" | 227 "{" |
| 227 " \"google_transaction_id\":\"google_transaction_id\"," | 228 " \"google_transaction_id\":\"google_transaction_id\"," |
| 228 " \"obfuscated_gaia_id\":\"\"," | 229 " \"obfuscated_gaia_id\":\"\"," |
| 229 " \"required_action\":" | 230 " \"required_action\":" |
| 230 " [" | 231 " [" |
| 231 " \"cvc_risk_CHALLENGE\"," | 232 " \"cvc_risk_CHALLENGE\"," |
| (...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 403 } | 404 } |
| 404 | 405 |
| 405 TEST_F(WalletItemsTest, CreateWalletItemsWithRequiredActions) { | 406 TEST_F(WalletItemsTest, CreateWalletItemsWithRequiredActions) { |
| 406 SetUpDictionary(kWalletItemsWithRequiredActions); | 407 SetUpDictionary(kWalletItemsWithRequiredActions); |
| 407 | 408 |
| 408 std::vector<RequiredAction> required_actions; | 409 std::vector<RequiredAction> required_actions; |
| 409 required_actions.push_back(SETUP_WALLET); | 410 required_actions.push_back(SETUP_WALLET); |
| 410 required_actions.push_back(ACCEPT_TOS); | 411 required_actions.push_back(ACCEPT_TOS); |
| 411 required_actions.push_back(GAIA_AUTH); | 412 required_actions.push_back(GAIA_AUTH); |
| 412 required_actions.push_back(INVALID_FORM_FIELD); | 413 required_actions.push_back(INVALID_FORM_FIELD); |
| 414 required_actions.push_back(PASSIVE_GAIA_AUTH); |
| 413 | 415 |
| 414 WalletItems expected(required_actions, "google_transaction_id", "", "", ""); | 416 WalletItems expected(required_actions, "google_transaction_id", "", "", ""); |
| 415 ASSERT_EQ(expected, *WalletItems::CreateWalletItems(*dict)); | 417 ASSERT_EQ(expected, *WalletItems::CreateWalletItems(*dict)); |
| 416 | 418 |
| 417 DCHECK(!required_actions.empty()); | 419 DCHECK(!required_actions.empty()); |
| 418 required_actions.pop_back(); | 420 required_actions.pop_back(); |
| 419 WalletItems different_required_actions( | 421 WalletItems different_required_actions( |
| 420 required_actions, "google_transaction_id", "", "", ""); | 422 required_actions, "google_transaction_id", "", "", ""); |
| 421 ASSERT_NE(expected, different_required_actions); | 423 ASSERT_NE(expected, different_required_actions); |
| 422 } | 424 } |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 474 new WalletItems::LegalDocument("doc_id", | 476 new WalletItems::LegalDocument("doc_id", |
| 475 "display_name", | 477 "display_name", |
| 476 "doc_body")); | 478 "doc_body")); |
| 477 expected.AddLegalDocument(legal_document.Pass()); | 479 expected.AddLegalDocument(legal_document.Pass()); |
| 478 | 480 |
| 479 ASSERT_EQ(expected, *WalletItems::CreateWalletItems(*dict)); | 481 ASSERT_EQ(expected, *WalletItems::CreateWalletItems(*dict)); |
| 480 } | 482 } |
| 481 | 483 |
| 482 } // namespace wallet | 484 } // namespace wallet |
| 483 | 485 |
| OLD | NEW |