Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(38)

Side by Side Diff: third_party/WebKit/Source/modules/payments/PaymentAddressTest.cpp

Issue 2352513002: PaymentRequest: Deprecate careOf attribute in PaymentAddress. (Closed)
Patch Set: PaymentRequest: Deprecate careOf attribute in PaymentAddress. Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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->country = "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->region = "CA"; 21 input->region = "CA";
22 input->city = "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 input->phone = "Phone Number";
32 31
33 PaymentAddress output(std::move(input)); 32 PaymentAddress output(std::move(input));
34 33
35 EXPECT_EQ("US", output.country()); 34 EXPECT_EQ("US", output.country());
36 EXPECT_EQ(3U, output.addressLine().size()); 35 EXPECT_EQ(3U, output.addressLine().size());
37 EXPECT_EQ("340 Main St", output.addressLine()[0]); 36 EXPECT_EQ("340 Main St", output.addressLine()[0]);
38 EXPECT_EQ("BIN1", output.addressLine()[1]); 37 EXPECT_EQ("BIN1", output.addressLine()[1]);
39 EXPECT_EQ("First floor", output.addressLine()[2]); 38 EXPECT_EQ("First floor", output.addressLine()[2]);
40 EXPECT_EQ("CA", output.region()); 39 EXPECT_EQ("CA", output.region());
41 EXPECT_EQ("Los Angeles", output.city()); 40 EXPECT_EQ("Los Angeles", output.city());
42 EXPECT_EQ("Venice", output.dependentLocality()); 41 EXPECT_EQ("Venice", output.dependentLocality());
43 EXPECT_EQ("90291", output.postalCode()); 42 EXPECT_EQ("90291", output.postalCode());
44 EXPECT_EQ("CEDEX", output.sortingCode()); 43 EXPECT_EQ("CEDEX", output.sortingCode());
45 EXPECT_EQ("en-Latn", output.languageCode()); 44 EXPECT_EQ("en-Latn", output.languageCode());
46 EXPECT_EQ("Google", output.organization()); 45 EXPECT_EQ("Google", output.organization());
47 EXPECT_EQ("Jon Doe", output.recipient()); 46 EXPECT_EQ("Jon Doe", output.recipient());
48 EXPECT_EQ("", output.careOf());
49 EXPECT_EQ("Phone Number", output.phone()); 47 EXPECT_EQ("Phone Number", output.phone());
50 } 48 }
51 49
52 TEST(PaymentAddressTest, IgnoreScriptCodeWithEmptyLanguageCode) 50 TEST(PaymentAddressTest, IgnoreScriptCodeWithEmptyLanguageCode)
53 { 51 {
54 mojom::blink::PaymentAddressPtr input = mojom::blink::PaymentAddress::New(); 52 mojom::blink::PaymentAddressPtr input = mojom::blink::PaymentAddress::New();
55 input->script_code = "Latn"; 53 input->script_code = "Latn";
56 54
57 PaymentAddress output(std::move(input)); 55 PaymentAddress output(std::move(input));
58 56
59 EXPECT_TRUE(output.languageCode().isEmpty()); 57 EXPECT_TRUE(output.languageCode().isEmpty());
60 } 58 }
61 59
62 TEST(PaymentAddressTest, NoHyphenWithEmptyScriptCode) 60 TEST(PaymentAddressTest, NoHyphenWithEmptyScriptCode)
63 { 61 {
64 mojom::blink::PaymentAddressPtr input = mojom::blink::PaymentAddress::New(); 62 mojom::blink::PaymentAddressPtr input = mojom::blink::PaymentAddress::New();
65 input->language_code = "en"; 63 input->language_code = "en";
66 64
67 PaymentAddress output(std::move(input)); 65 PaymentAddress output(std::move(input));
68 66
69 EXPECT_EQ("en", output.languageCode()); 67 EXPECT_EQ("en", output.languageCode());
70 } 68 }
71 69
72 } // namespace 70 } // namespace
73 } // namespace blink 71 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698