| 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/utf_string_conversions.h" | 8 #include "base/utf_string_conversions.h" |
| 9 #include "base/values.h" | 9 #include "base/values.h" |
| 10 #include "components/autofill/browser/wallet/wallet_address.h" | 10 #include "components/autofill/browser/wallet/wallet_address.h" |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 169 TEST_F(WalletAddressTest, CreateAddressMissingObjectId) { | 169 TEST_F(WalletAddressTest, CreateAddressMissingObjectId) { |
| 170 SetUpDictionary(kAddressMissingObjectId); | 170 SetUpDictionary(kAddressMissingObjectId); |
| 171 Address address("country_name_code", | 171 Address address("country_name_code", |
| 172 ASCIIToUTF16("recipient_name"), | 172 ASCIIToUTF16("recipient_name"), |
| 173 ASCIIToUTF16("address_line_1"), | 173 ASCIIToUTF16("address_line_1"), |
| 174 ASCIIToUTF16("address_line_2"), | 174 ASCIIToUTF16("address_line_2"), |
| 175 ASCIIToUTF16("locality_name"), | 175 ASCIIToUTF16("locality_name"), |
| 176 ASCIIToUTF16("administrative_area_name"), | 176 ASCIIToUTF16("administrative_area_name"), |
| 177 ASCIIToUTF16("postal_code_number"), | 177 ASCIIToUTF16("postal_code_number"), |
| 178 ASCIIToUTF16("phone_number"), | 178 ASCIIToUTF16("phone_number"), |
| 179 ""); | 179 std::string()); |
| 180 ASSERT_EQ(address, *Address::CreateAddress(*dict_)); | 180 ASSERT_EQ(address, *Address::CreateAddress(*dict_)); |
| 181 } | 181 } |
| 182 | 182 |
| 183 TEST_F(WalletAddressTest, CreateAddressWithIDMissingObjectId) { | 183 TEST_F(WalletAddressTest, CreateAddressWithIDMissingObjectId) { |
| 184 SetUpDictionary(kAddressMissingObjectId); | 184 SetUpDictionary(kAddressMissingObjectId); |
| 185 ASSERT_EQ(NULL, Address::CreateAddressWithID(*dict_).get()); | 185 ASSERT_EQ(NULL, Address::CreateAddressWithID(*dict_).get()); |
| 186 } | 186 } |
| 187 | 187 |
| 188 TEST_F(WalletAddressTest, CreateAddressMissingCountryNameCode) { | 188 TEST_F(WalletAddressTest, CreateAddressMissingCountryNameCode) { |
| 189 SetUpDictionary(kAddressMissingCountryNameCode); | 189 SetUpDictionary(kAddressMissingCountryNameCode); |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 236 TEST_F(WalletAddressTest, CreateDisplayAddress) { | 236 TEST_F(WalletAddressTest, CreateDisplayAddress) { |
| 237 SetUpDictionary(kClientValidAddress); | 237 SetUpDictionary(kClientValidAddress); |
| 238 Address address("country_code", | 238 Address address("country_code", |
| 239 ASCIIToUTF16("name"), | 239 ASCIIToUTF16("name"), |
| 240 ASCIIToUTF16("address1"), | 240 ASCIIToUTF16("address1"), |
| 241 ASCIIToUTF16("address2"), | 241 ASCIIToUTF16("address2"), |
| 242 ASCIIToUTF16("city"), | 242 ASCIIToUTF16("city"), |
| 243 ASCIIToUTF16("state"), | 243 ASCIIToUTF16("state"), |
| 244 ASCIIToUTF16("postal_code"), | 244 ASCIIToUTF16("postal_code"), |
| 245 ASCIIToUTF16("phone_number"), | 245 ASCIIToUTF16("phone_number"), |
| 246 ""); | 246 std::string()); |
| 247 ASSERT_EQ(address, *Address::CreateDisplayAddress(*dict_)); | 247 ASSERT_EQ(address, *Address::CreateDisplayAddress(*dict_)); |
| 248 } | 248 } |
| 249 | 249 |
| 250 TEST_F(WalletAddressTest, ToDictionaryWithoutID) { | 250 TEST_F(WalletAddressTest, ToDictionaryWithoutID) { |
| 251 base::DictionaryValue expected; | 251 base::DictionaryValue expected; |
| 252 expected.SetString("country_name_code", | 252 expected.SetString("country_name_code", |
| 253 "country_name_code"); | 253 "country_name_code"); |
| 254 expected.SetString("recipient_name", | 254 expected.SetString("recipient_name", |
| 255 "recipient_name"); | 255 "recipient_name"); |
| 256 expected.SetString("locality_name", | 256 expected.SetString("locality_name", |
| 257 "locality_name"); | 257 "locality_name"); |
| 258 expected.SetString("administrative_area_name", | 258 expected.SetString("administrative_area_name", |
| 259 "administrative_area_name"); | 259 "administrative_area_name"); |
| 260 expected.SetString("postal_code_number", | 260 expected.SetString("postal_code_number", |
| 261 "postal_code_number"); | 261 "postal_code_number"); |
| 262 base::ListValue* address_lines = new base::ListValue(); | 262 base::ListValue* address_lines = new base::ListValue(); |
| 263 address_lines->AppendString("address_line_1"); | 263 address_lines->AppendString("address_line_1"); |
| 264 address_lines->AppendString("address_line_2"); | 264 address_lines->AppendString("address_line_2"); |
| 265 expected.Set("address_line", address_lines); | 265 expected.Set("address_line", address_lines); |
| 266 | 266 |
| 267 Address address("country_name_code", | 267 Address address("country_name_code", |
| 268 ASCIIToUTF16("recipient_name"), | 268 ASCIIToUTF16("recipient_name"), |
| 269 ASCIIToUTF16("address_line_1"), | 269 ASCIIToUTF16("address_line_1"), |
| 270 ASCIIToUTF16("address_line_2"), | 270 ASCIIToUTF16("address_line_2"), |
| 271 ASCIIToUTF16("locality_name"), | 271 ASCIIToUTF16("locality_name"), |
| 272 ASCIIToUTF16("administrative_area_name"), | 272 ASCIIToUTF16("administrative_area_name"), |
| 273 ASCIIToUTF16("postal_code_number"), | 273 ASCIIToUTF16("postal_code_number"), |
| 274 ASCIIToUTF16("phone_number"), | 274 ASCIIToUTF16("phone_number"), |
| 275 ""); | 275 std::string()); |
| 276 | 276 |
| 277 EXPECT_TRUE(expected.Equals(address.ToDictionaryWithoutID().get())); | 277 EXPECT_TRUE(expected.Equals(address.ToDictionaryWithoutID().get())); |
| 278 } | 278 } |
| 279 | 279 |
| 280 TEST_F(WalletAddressTest, ToDictionaryWithID) { | 280 TEST_F(WalletAddressTest, ToDictionaryWithID) { |
| 281 base::DictionaryValue expected; | 281 base::DictionaryValue expected; |
| 282 expected.SetString("id", "id"); | 282 expected.SetString("id", "id"); |
| 283 expected.SetString("phone_number", "phone_number"); | 283 expected.SetString("phone_number", "phone_number"); |
| 284 expected.SetString("postal_address.country_name_code", | 284 expected.SetString("postal_address.country_name_code", |
| 285 "country_name_code"); | 285 "country_name_code"); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 304 ASCIIToUTF16("administrative_area_name"), | 304 ASCIIToUTF16("administrative_area_name"), |
| 305 ASCIIToUTF16("postal_code_number"), | 305 ASCIIToUTF16("postal_code_number"), |
| 306 ASCIIToUTF16("phone_number"), | 306 ASCIIToUTF16("phone_number"), |
| 307 "id"); | 307 "id"); |
| 308 | 308 |
| 309 EXPECT_TRUE(expected.Equals(address.ToDictionaryWithID().get())); | 309 EXPECT_TRUE(expected.Equals(address.ToDictionaryWithID().get())); |
| 310 } | 310 } |
| 311 | 311 |
| 312 } // namespace wallet | 312 } // namespace wallet |
| 313 } // namespace autofill | 313 } // namespace autofill |
| OLD | NEW |