| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "components/autofill/content/browser/wallet/wallet_test_util.h" | 5 #include "components/autofill/content/browser/wallet/wallet_test_util.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/strings/string16.h" | 10 #include "base/strings/string16.h" |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 return 3000; | 27 return 3000; |
| 28 } | 28 } |
| 29 | 29 |
| 30 } // namespace | 30 } // namespace |
| 31 | 31 |
| 32 scoped_ptr<WalletItems::MaskedInstrument> GetTestMaskedInstrumentWithDetails( | 32 scoped_ptr<WalletItems::MaskedInstrument> GetTestMaskedInstrumentWithDetails( |
| 33 const std::string& id, | 33 const std::string& id, |
| 34 scoped_ptr<Address> address, | 34 scoped_ptr<Address> address, |
| 35 WalletItems::MaskedInstrument::Type type, | 35 WalletItems::MaskedInstrument::Type type, |
| 36 WalletItems::MaskedInstrument::Status status) { | 36 WalletItems::MaskedInstrument::Status status) { |
| 37 return scoped_ptr<WalletItems::MaskedInstrument>( | 37 return make_scoped_ptr( |
| 38 new WalletItems::MaskedInstrument(ASCIIToUTF16("descriptive_name"), | 38 new WalletItems::MaskedInstrument(ASCIIToUTF16("descriptive_name"), |
| 39 type, | 39 type, |
| 40 std::vector<base::string16>(), | 40 std::vector<base::string16>(), |
| 41 ASCIIToUTF16("1111"), | 41 ASCIIToUTF16("1111"), |
| 42 12, | 42 12, |
| 43 FutureYear(), | 43 FutureYear(), |
| 44 address.Pass(), | 44 address.Pass(), |
| 45 status, | 45 status, |
| 46 id)); | 46 id)); |
| 47 } | 47 } |
| (...skipping 11 matching lines...) Expand all Loading... |
| 59 GetTestMaskedInstrumentWithIdAndAddress( | 59 GetTestMaskedInstrumentWithIdAndAddress( |
| 60 const std::string& id, scoped_ptr<Address> address) { | 60 const std::string& id, scoped_ptr<Address> address) { |
| 61 return GetTestMaskedInstrumentWithDetails( | 61 return GetTestMaskedInstrumentWithDetails( |
| 62 id, | 62 id, |
| 63 address.Pass(), | 63 address.Pass(), |
| 64 WalletItems::MaskedInstrument::VISA, | 64 WalletItems::MaskedInstrument::VISA, |
| 65 WalletItems::MaskedInstrument::VALID); | 65 WalletItems::MaskedInstrument::VALID); |
| 66 } | 66 } |
| 67 | 67 |
| 68 scoped_ptr<GaiaAccount> GetTestGaiaAccount() { | 68 scoped_ptr<GaiaAccount> GetTestGaiaAccount() { |
| 69 return scoped_ptr<GaiaAccount>(GaiaAccount::CreateForTesting( | 69 return GaiaAccount::CreateForTesting("user@chromium.org", |
| 70 "user@chromium.org", "obfuscated_id", 0, true)); | 70 "obfuscated_id", |
| 71 0, |
| 72 true); |
| 71 } | 73 } |
| 72 | 74 |
| 73 scoped_ptr<Address> GetTestAddress() { | 75 scoped_ptr<Address> GetTestAddress() { |
| 74 return scoped_ptr<Address>(new Address("US", | 76 return make_scoped_ptr(new Address("US", |
| 75 ASCIIToUTF16("recipient_name"), | 77 ASCIIToUTF16("recipient_name"), |
| 76 ASCIIToUTF16("address_line_1"), | 78 ASCIIToUTF16("address_line_1"), |
| 77 ASCIIToUTF16("address_line_2"), | 79 ASCIIToUTF16("address_line_2"), |
| 78 ASCIIToUTF16("locality_name"), | 80 ASCIIToUTF16("locality_name"), |
| 79 ASCIIToUTF16("admin_area_name"), | 81 ASCIIToUTF16("admin_area_name"), |
| 80 ASCIIToUTF16("postal_code_number"), | 82 ASCIIToUTF16("postal_code_number"), |
| 81 ASCIIToUTF16("phone_number"), | 83 ASCIIToUTF16("phone_number"), |
| 82 std::string())); | 84 std::string())); |
| 83 } | 85 } |
| 84 | 86 |
| 85 scoped_ptr<Address> GetTestMinimalAddress() { | 87 scoped_ptr<Address> GetTestMinimalAddress() { |
| 86 scoped_ptr<Address> address = GetTestAddress(); | 88 scoped_ptr<Address> address = GetTestAddress(); |
| 87 address->set_is_complete_address(false); | 89 address->set_is_complete_address(false); |
| 88 return address.Pass(); | 90 return address.Pass(); |
| 89 } | 91 } |
| 90 | 92 |
| 91 scoped_ptr<FullWallet> GetTestFullWallet() { | 93 scoped_ptr<FullWallet> GetTestFullWallet() { |
| 92 return GetTestFullWalletWithRequiredActions(std::vector<RequiredAction>()); | 94 return GetTestFullWalletWithRequiredActions(std::vector<RequiredAction>()); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 115 GetTestAddress(), | 117 GetTestAddress(), |
| 116 scoped_ptr<Address>(), | 118 scoped_ptr<Address>(), |
| 117 std::vector<RequiredAction>())); | 119 std::vector<RequiredAction>())); |
| 118 std::vector<uint8> one_time_pad; | 120 std::vector<uint8> one_time_pad; |
| 119 base::HexStringToBytes("5F04A8704183", &one_time_pad); | 121 base::HexStringToBytes("5F04A8704183", &one_time_pad); |
| 120 wallet->set_one_time_pad(one_time_pad); | 122 wallet->set_one_time_pad(one_time_pad); |
| 121 return wallet.Pass(); | 123 return wallet.Pass(); |
| 122 } | 124 } |
| 123 | 125 |
| 124 scoped_ptr<Instrument> GetTestInstrument() { | 126 scoped_ptr<Instrument> GetTestInstrument() { |
| 125 return scoped_ptr<Instrument>(new Instrument(ASCIIToUTF16("4444444444444448"), | 127 return make_scoped_ptr(new Instrument(ASCIIToUTF16("4444444444444448"), |
| 126 ASCIIToUTF16("123"), | 128 ASCIIToUTF16("123"), |
| 127 12, | 129 12, |
| 128 FutureYear(), | 130 FutureYear(), |
| 129 Instrument::VISA, | 131 Instrument::VISA, |
| 130 GetTestAddress())); | 132 GetTestAddress())); |
| 131 } | 133 } |
| 132 | 134 |
| 133 scoped_ptr<Instrument> GetTestAddressUpgradeInstrument() { | 135 scoped_ptr<Instrument> GetTestAddressUpgradeInstrument() { |
| 134 scoped_ptr<Instrument> instrument(new Instrument(base::string16(), | 136 return make_scoped_ptr(new Instrument(base::string16(), |
| 135 base::string16(), | 137 base::string16(), |
| 136 0, | 138 12, |
| 137 0, | 139 FutureYear(), |
| 138 Instrument::UNKNOWN, | 140 Instrument::UNKNOWN, |
| 139 GetTestAddress())); | 141 GetTestAddress())); |
| 140 instrument->set_object_id("instrument_id"); | |
| 141 return instrument.Pass(); | |
| 142 } | 142 } |
| 143 | 143 |
| 144 scoped_ptr<Instrument> GetTestExpirationDateChangeInstrument() { | 144 scoped_ptr<Instrument> GetTestExpirationDateChangeInstrument() { |
| 145 scoped_ptr<Instrument> instrument(new Instrument(base::string16(), | 145 return make_scoped_ptr(new Instrument(base::string16(), |
| 146 ASCIIToUTF16("123"), | 146 ASCIIToUTF16("123"), |
| 147 12, | 147 12, |
| 148 FutureYear(), | 148 FutureYear() + 1, |
| 149 Instrument::UNKNOWN, | 149 Instrument::UNKNOWN, |
| 150 scoped_ptr<Address>())); | 150 scoped_ptr<Address>())); |
| 151 instrument->set_object_id("instrument_id"); | |
| 152 return instrument.Pass(); | |
| 153 } | 151 } |
| 154 | 152 |
| 155 scoped_ptr<Instrument> GetTestAddressNameChangeInstrument() { | 153 scoped_ptr<Instrument> GetTestAddressNameChangeInstrument() { |
| 156 scoped_ptr<Instrument> instrument(new Instrument(base::string16(), | 154 return make_scoped_ptr(new Instrument(base::string16(), |
| 157 ASCIIToUTF16("123"), | 155 ASCIIToUTF16("123"), |
| 158 0, | 156 12, |
| 159 0, | 157 FutureYear(), |
| 160 Instrument::UNKNOWN, | 158 Instrument::UNKNOWN, |
| 161 GetTestAddress())); | 159 GetTestAddress())); |
| 162 instrument->set_object_id("instrument_id"); | |
| 163 return instrument.Pass(); | |
| 164 } | 160 } |
| 165 | 161 |
| 166 scoped_ptr<WalletItems::LegalDocument> GetTestLegalDocument() { | 162 scoped_ptr<WalletItems::LegalDocument> GetTestLegalDocument() { |
| 167 base::DictionaryValue dict; | 163 base::DictionaryValue dict; |
| 168 dict.SetString("legal_document_id", "document_id"); | 164 dict.SetString("legal_document_id", "document_id"); |
| 169 dict.SetString("display_name", "display_name"); | 165 dict.SetString("display_name", "display_name"); |
| 170 return wallet::WalletItems::LegalDocument::CreateLegalDocument(dict); | 166 return wallet::WalletItems::LegalDocument::CreateLegalDocument(dict); |
| 171 } | 167 } |
| 172 | 168 |
| 173 scoped_ptr<WalletItems::MaskedInstrument> GetTestMaskedInstrument() { | 169 scoped_ptr<WalletItems::MaskedInstrument> GetTestMaskedInstrument() { |
| (...skipping 15 matching lines...) Expand all Loading... |
| 189 WalletItems::MaskedInstrument::VISA, | 185 WalletItems::MaskedInstrument::VISA, |
| 190 WalletItems::MaskedInstrument::DECLINED); | 186 WalletItems::MaskedInstrument::DECLINED); |
| 191 } | 187 } |
| 192 | 188 |
| 193 scoped_ptr<WalletItems::MaskedInstrument> GetTestMaskedInstrumentAmex( | 189 scoped_ptr<WalletItems::MaskedInstrument> GetTestMaskedInstrumentAmex( |
| 194 AmexPermission amex_permission) { | 190 AmexPermission amex_permission) { |
| 195 return GetTestMaskedInstrumentWithDetails( | 191 return GetTestMaskedInstrumentWithDetails( |
| 196 "default_instrument_id", | 192 "default_instrument_id", |
| 197 GetTestAddress(), | 193 GetTestAddress(), |
| 198 WalletItems::MaskedInstrument::AMEX, | 194 WalletItems::MaskedInstrument::AMEX, |
| 199 (amex_permission == AMEX_ALLOWED) | 195 amex_permission == AMEX_ALLOWED ? |
| 200 ? WalletItems::MaskedInstrument::VALID | 196 WalletItems::MaskedInstrument::VALID : |
| 201 : WalletItems::MaskedInstrument::AMEX_NOT_SUPPORTED); | 197 WalletItems::MaskedInstrument::AMEX_NOT_SUPPORTED); |
| 202 } | 198 } |
| 203 | 199 |
| 204 scoped_ptr<WalletItems::MaskedInstrument> GetTestNonDefaultMaskedInstrument() { | 200 scoped_ptr<WalletItems::MaskedInstrument> GetTestNonDefaultMaskedInstrument() { |
| 205 return GetTestMaskedInstrumentWithId("instrument_id"); | 201 return GetTestMaskedInstrumentWithId("instrument_id"); |
| 206 } | 202 } |
| 207 | 203 |
| 208 scoped_ptr<Address> GetTestSaveableAddress() { | 204 scoped_ptr<Address> GetTestSaveableAddress() { |
| 209 return scoped_ptr<Address>(new Address( | 205 return make_scoped_ptr(new Address("US", |
| 210 "US", | 206 ASCIIToUTF16("save_recipient_name"), |
| 211 ASCIIToUTF16("save_recipient_name"), | 207 ASCIIToUTF16("save_address_line_1"), |
| 212 ASCIIToUTF16("save_address_line_1"), | 208 ASCIIToUTF16("save_address_line_2"), |
| 213 ASCIIToUTF16("save_address_line_2"), | 209 ASCIIToUTF16("save_locality_name"), |
| 214 ASCIIToUTF16("save_locality_name"), | 210 ASCIIToUTF16("save_admin_area_name"), |
| 215 ASCIIToUTF16("save_admin_area_name"), | 211 ASCIIToUTF16("save_postal_code_number"), |
| 216 ASCIIToUTF16("save_postal_code_number"), | 212 ASCIIToUTF16("save_phone_number"), |
| 217 ASCIIToUTF16("save_phone_number"), | 213 std::string())); |
| 218 std::string())); | |
| 219 } | 214 } |
| 220 | 215 |
| 221 scoped_ptr<Address> GetTestShippingAddress() { | 216 scoped_ptr<Address> GetTestShippingAddress() { |
| 222 return scoped_ptr<Address>(new Address( | 217 return make_scoped_ptr(new Address("US", |
| 223 "US", | 218 ASCIIToUTF16("ship_recipient_name"), |
| 224 ASCIIToUTF16("ship_recipient_name"), | 219 ASCIIToUTF16("ship_address_line_1"), |
| 225 ASCIIToUTF16("ship_address_line_1"), | 220 ASCIIToUTF16("ship_address_line_2"), |
| 226 ASCIIToUTF16("ship_address_line_2"), | 221 ASCIIToUTF16("ship_locality_name"), |
| 227 ASCIIToUTF16("ship_locality_name"), | 222 ASCIIToUTF16("ship_admin_area_name"), |
| 228 ASCIIToUTF16("ship_admin_area_name"), | 223 ASCIIToUTF16("ship_postal_code_number"), |
| 229 ASCIIToUTF16("ship_postal_code_number"), | 224 ASCIIToUTF16("ship_phone_number"), |
| 230 ASCIIToUTF16("ship_phone_number"), | 225 "default_address_id")); |
| 231 "default_address_id")); | |
| 232 } | 226 } |
| 233 | 227 |
| 234 scoped_ptr<Address> GetTestNonDefaultShippingAddress() { | 228 scoped_ptr<Address> GetTestNonDefaultShippingAddress() { |
| 235 scoped_ptr<Address> address = GetTestShippingAddress(); | 229 scoped_ptr<Address> address = GetTestShippingAddress(); |
| 236 address->set_object_id("address_id"); | 230 address->set_object_id("address_id"); |
| 237 return address.Pass(); | 231 return address.Pass(); |
| 238 } | 232 } |
| 239 | 233 |
| 240 scoped_ptr<WalletItems> GetTestWalletItems( | 234 scoped_ptr<WalletItems> GetTestWalletItems( |
| 241 const std::vector<RequiredAction>& required_actions, | 235 const std::vector<RequiredAction>& required_actions, |
| 242 const std::string& default_instrument_id, | 236 const std::string& default_instrument_id, |
| 243 const std::string& default_address_id, | 237 const std::string& default_address_id, |
| 244 AmexPermission amex_permission) { | 238 AmexPermission amex_permission) { |
| 245 return scoped_ptr<WalletItems>( | 239 return make_scoped_ptr(new wallet::WalletItems(required_actions, |
| 246 new wallet::WalletItems(required_actions, | 240 "google_transaction_id", |
| 247 "google_transaction_id", | 241 default_instrument_id, |
| 248 default_instrument_id, | 242 default_address_id, |
| 249 default_address_id, | 243 amex_permission)); |
| 250 amex_permission)); | |
| 251 } | 244 } |
| 252 | 245 |
| 253 scoped_ptr<WalletItems> GetTestWalletItemsWithRequiredAction( | 246 scoped_ptr<WalletItems> GetTestWalletItemsWithRequiredAction( |
| 254 RequiredAction action) { | 247 RequiredAction action) { |
| 255 std::vector<RequiredAction> required_actions(1, action); | 248 std::vector<RequiredAction> required_actions(1, action); |
| 256 scoped_ptr<WalletItems> items = | 249 scoped_ptr<WalletItems> items = |
| 257 GetTestWalletItems(required_actions, | 250 GetTestWalletItems(required_actions, |
| 258 "default_instrument_id", | 251 "default_instrument_id", |
| 259 "default_address_id", | 252 "default_address_id", |
| 260 AMEX_ALLOWED); | 253 AMEX_ALLOWED); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 294 GetTestWalletItems(std::vector<RequiredAction>(), | 287 GetTestWalletItems(std::vector<RequiredAction>(), |
| 295 default_instrument_id, | 288 default_instrument_id, |
| 296 default_address_id, | 289 default_address_id, |
| 297 amex_permission); | 290 amex_permission); |
| 298 items->AddAccount(GetTestGaiaAccount()); | 291 items->AddAccount(GetTestGaiaAccount()); |
| 299 return items.Pass(); | 292 return items.Pass(); |
| 300 } | 293 } |
| 301 | 294 |
| 302 } // namespace wallet | 295 } // namespace wallet |
| 303 } // namespace autofill | 296 } // namespace autofill |
| OLD | NEW |