| 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 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 " \"locality_name\":\"locality_name\"," | 81 " \"locality_name\":\"locality_name\"," |
| 82 " \"administrative_area_name\":\"administrative_area_name\"," | 82 " \"administrative_area_name\":\"administrative_area_name\"," |
| 83 " \"country_name_code\":\"country_name_code\"" | 83 " \"country_name_code\":\"country_name_code\"" |
| 84 " }" | 84 " }" |
| 85 "}"; | 85 "}"; |
| 86 | 86 |
| 87 const char kValidAddress[] = | 87 const char kValidAddress[] = |
| 88 "{" | 88 "{" |
| 89 " \"id\":\"id\"," | 89 " \"id\":\"id\"," |
| 90 " \"phone_number\":\"phone_number\"," | 90 " \"phone_number\":\"phone_number\"," |
| 91 " \"is_minimal_address\":\"true\"," |
| 91 " \"postal_address\":" | 92 " \"postal_address\":" |
| 92 " {" | 93 " {" |
| 93 " \"recipient_name\":\"recipient_name\"," | 94 " \"recipient_name\":\"recipient_name\"," |
| 94 " \"address_line\":" | 95 " \"address_line\":" |
| 95 " [" | 96 " [" |
| 96 " \"address_line_1\"," | 97 " \"address_line_1\"," |
| 97 " \"address_line_2\"" | 98 " \"address_line_2\"" |
| 98 " ]," | 99 " ]," |
| 99 " \"locality_name\":\"locality_name\"," | 100 " \"locality_name\":\"locality_name\"," |
| 100 " \"administrative_area_name\":\"administrative_area_name\"," | 101 " \"administrative_area_name\":\"administrative_area_name\"," |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 138 | 139 |
| 139 const char kClientValidAddress[] = | 140 const char kClientValidAddress[] = |
| 140 "{" | 141 "{" |
| 141 " \"name\":\"name\"," | 142 " \"name\":\"name\"," |
| 142 " \"address1\":\"address1\"," | 143 " \"address1\":\"address1\"," |
| 143 " \"address2\":\"address2\"," | 144 " \"address2\":\"address2\"," |
| 144 " \"city\":\"city\"," | 145 " \"city\":\"city\"," |
| 145 " \"state\":\"state\"," | 146 " \"state\":\"state\"," |
| 146 " \"postal_code\":\"postal_code\"," | 147 " \"postal_code\":\"postal_code\"," |
| 147 " \"phone_number\":\"phone_number\"," | 148 " \"phone_number\":\"phone_number\"," |
| 148 " \"country_code\":\"country_code\"" | 149 " \"country_code\":\"country_code\"," |
| 150 " \"type\":\"FULL\"" |
| 149 "}"; | 151 "}"; |
| 150 | 152 |
| 151 } // anonymous namespace | 153 } // anonymous namespace |
| 152 | 154 |
| 153 namespace autofill { | 155 namespace autofill { |
| 154 namespace wallet { | 156 namespace wallet { |
| 155 | 157 |
| 156 class WalletAddressTest : public testing::Test { | 158 class WalletAddressTest : public testing::Test { |
| 157 public: | 159 public: |
| 158 WalletAddressTest() {} | 160 WalletAddressTest() {} |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 207 SetUpDictionary(kValidAddress); | 209 SetUpDictionary(kValidAddress); |
| 208 Address address("country_name_code", | 210 Address address("country_name_code", |
| 209 ASCIIToUTF16("recipient_name"), | 211 ASCIIToUTF16("recipient_name"), |
| 210 ASCIIToUTF16("address_line_1"), | 212 ASCIIToUTF16("address_line_1"), |
| 211 ASCIIToUTF16("address_line_2"), | 213 ASCIIToUTF16("address_line_2"), |
| 212 ASCIIToUTF16("locality_name"), | 214 ASCIIToUTF16("locality_name"), |
| 213 ASCIIToUTF16("administrative_area_name"), | 215 ASCIIToUTF16("administrative_area_name"), |
| 214 ASCIIToUTF16("postal_code_number"), | 216 ASCIIToUTF16("postal_code_number"), |
| 215 ASCIIToUTF16("phone_number"), | 217 ASCIIToUTF16("phone_number"), |
| 216 "id"); | 218 "id"); |
| 219 address.set_is_complete_address(false); |
| 217 ASSERT_EQ(address, *Address::CreateAddress(*dict_)); | 220 ASSERT_EQ(address, *Address::CreateAddress(*dict_)); |
| 218 ASSERT_EQ(address, *Address::CreateAddressWithID(*dict_)); | 221 ASSERT_EQ(address, *Address::CreateAddressWithID(*dict_)); |
| 219 } | 222 } |
| 220 | 223 |
| 221 TEST_F(WalletAddressTest, CreateDisplayAddressMissingCountryNameCode) { | 224 TEST_F(WalletAddressTest, CreateDisplayAddressMissingCountryNameCode) { |
| 222 SetUpDictionary(kClientAddressMissingCountryCode); | 225 SetUpDictionary(kClientAddressMissingCountryCode); |
| 223 ASSERT_EQ(NULL, Address::CreateDisplayAddress(*dict_).get()); | 226 ASSERT_EQ(NULL, Address::CreateDisplayAddress(*dict_).get()); |
| 224 } | 227 } |
| 225 | 228 |
| 226 TEST_F(WalletAddressTest, CreateDisplayAddressMissingName) { | 229 TEST_F(WalletAddressTest, CreateDisplayAddressMissingName) { |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 304 ASCIIToUTF16("administrative_area_name"), | 307 ASCIIToUTF16("administrative_area_name"), |
| 305 ASCIIToUTF16("postal_code_number"), | 308 ASCIIToUTF16("postal_code_number"), |
| 306 ASCIIToUTF16("phone_number"), | 309 ASCIIToUTF16("phone_number"), |
| 307 "id"); | 310 "id"); |
| 308 | 311 |
| 309 EXPECT_TRUE(expected.Equals(address.ToDictionaryWithID().get())); | 312 EXPECT_TRUE(expected.Equals(address.ToDictionaryWithID().get())); |
| 310 } | 313 } |
| 311 | 314 |
| 312 } // namespace wallet | 315 } // namespace wallet |
| 313 } // namespace autofill | 316 } // namespace autofill |
| OLD | NEW |