| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "modules/payments/PaymentAddress.h" | 5 #include "modules/payments/PaymentAddress.h" |
| 6 | 6 |
| 7 #include "testing/gtest/include/gtest/gtest.h" | 7 #include "testing/gtest/include/gtest/gtest.h" |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 namespace blink { | 10 namespace blink { |
| 11 namespace { | 11 namespace { |
| 12 | 12 |
| 13 TEST(PaymentAddressTest, ValuesAreCopiedOver) | 13 TEST(PaymentAddressTest, ValuesAreCopiedOver) |
| 14 { | 14 { |
| 15 mojom::blink::PaymentAddressPtr input = mojom::blink::PaymentAddress::New(); | 15 mojom::blink::PaymentAddressPtr input = mojom::blink::PaymentAddress::New(); |
| 16 input->region_code = "US"; | 16 input->country = "US"; |
| 17 input->address_line = mojo::WTFArray<WTF::String>::New(3); | 17 input->address_line = mojo::WTFArray<WTF::String>::New(3); |
| 18 input->address_line[0] = "340 Main St"; | 18 input->address_line[0] = "340 Main St"; |
| 19 input->address_line[1] = "BIN1"; | 19 input->address_line[1] = "BIN1"; |
| 20 input->address_line[2] = "First floor"; | 20 input->address_line[2] = "First floor"; |
| 21 input->administrative_area = "CA"; | 21 input->region = "CA"; |
| 22 input->locality = "Los Angeles"; | 22 input->city = "Los Angeles"; |
| 23 input->dependent_locality = "Venice"; | 23 input->dependent_locality = "Venice"; |
| 24 input->postal_code = "90291"; | 24 input->postal_code = "90291"; |
| 25 input->sorting_code = "CEDEX"; | 25 input->sorting_code = "CEDEX"; |
| 26 input->language_code = "en"; | 26 input->language_code = "en"; |
| 27 input->script_code = "Latn"; | 27 input->script_code = "Latn"; |
| 28 input->organization = "Google"; | 28 input->organization = "Google"; |
| 29 input->recipient = "Jon Doe"; | 29 input->recipient = "Jon Doe"; |
| 30 input->careOf = ""; |
| 31 input->phone = "Phone Number"; |
| 30 | 32 |
| 31 PaymentAddress output(std::move(input)); | 33 PaymentAddress output(std::move(input)); |
| 32 | 34 |
| 33 EXPECT_EQ("US", output.regionCode()); | 35 EXPECT_EQ("US", output.country()); |
| 34 EXPECT_EQ(3U, output.addressLine().size()); | 36 EXPECT_EQ(3U, output.addressLine().size()); |
| 35 EXPECT_EQ("340 Main St", output.addressLine()[0]); | 37 EXPECT_EQ("340 Main St", output.addressLine()[0]); |
| 36 EXPECT_EQ("BIN1", output.addressLine()[1]); | 38 EXPECT_EQ("BIN1", output.addressLine()[1]); |
| 37 EXPECT_EQ("First floor", output.addressLine()[2]); | 39 EXPECT_EQ("First floor", output.addressLine()[2]); |
| 38 EXPECT_EQ("CA", output.administrativeArea()); | 40 EXPECT_EQ("CA", output.region()); |
| 39 EXPECT_EQ("Los Angeles", output.locality()); | 41 EXPECT_EQ("Los Angeles", output.city()); |
| 40 EXPECT_EQ("Venice", output.dependentLocality()); | 42 EXPECT_EQ("Venice", output.dependentLocality()); |
| 41 EXPECT_EQ("90291", output.postalCode()); | 43 EXPECT_EQ("90291", output.postalCode()); |
| 42 EXPECT_EQ("CEDEX", output.sortingCode()); | 44 EXPECT_EQ("CEDEX", output.sortingCode()); |
| 43 EXPECT_EQ("en-Latn", output.languageCode()); | 45 EXPECT_EQ("en-Latn", output.languageCode()); |
| 44 EXPECT_EQ("Google", output.organization()); | 46 EXPECT_EQ("Google", output.organization()); |
| 45 EXPECT_EQ("Jon Doe", output.recipient()); | 47 EXPECT_EQ("Jon Doe", output.recipient()); |
| 48 EXPECT_EQ("", output.careOf()); |
| 49 EXPECT_EQ("Phone Number", output.phone()); |
| 46 } | 50 } |
| 47 | 51 |
| 48 TEST(PaymentAddressTest, IgnoreScriptCodeWithEmptyLanguageCode) | 52 TEST(PaymentAddressTest, IgnoreScriptCodeWithEmptyLanguageCode) |
| 49 { | 53 { |
| 50 mojom::blink::PaymentAddressPtr input = mojom::blink::PaymentAddress::New(); | 54 mojom::blink::PaymentAddressPtr input = mojom::blink::PaymentAddress::New(); |
| 51 input->script_code = "Latn"; | 55 input->script_code = "Latn"; |
| 52 | 56 |
| 53 PaymentAddress output(std::move(input)); | 57 PaymentAddress output(std::move(input)); |
| 54 | 58 |
| 55 EXPECT_TRUE(output.languageCode().isEmpty()); | 59 EXPECT_TRUE(output.languageCode().isEmpty()); |
| 56 } | 60 } |
| 57 | 61 |
| 58 TEST(PaymentAddressTest, NoHyphenWithEmptyScriptCode) | 62 TEST(PaymentAddressTest, NoHyphenWithEmptyScriptCode) |
| 59 { | 63 { |
| 60 mojom::blink::PaymentAddressPtr input = mojom::blink::PaymentAddress::New(); | 64 mojom::blink::PaymentAddressPtr input = mojom::blink::PaymentAddress::New(); |
| 61 input->language_code = "en"; | 65 input->language_code = "en"; |
| 62 | 66 |
| 63 PaymentAddress output(std::move(input)); | 67 PaymentAddress output(std::move(input)); |
| 64 | 68 |
| 65 EXPECT_EQ("en", output.languageCode()); | 69 EXPECT_EQ("en", output.languageCode()); |
| 66 } | 70 } |
| 67 | 71 |
| 68 } // namespace | 72 } // namespace |
| 69 } // namespace blink | 73 } // namespace blink |
| OLD | NEW |