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