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 package org.chromium.chrome.browser.payments; | 5 package org.chromium.chrome.browser.payments; |
6 | 6 |
7 import org.chromium.chrome.browser.autofill.PersonalDataManager.AutofillProfile; | 7 import org.chromium.chrome.browser.autofill.PersonalDataManager.AutofillProfile; |
8 import org.chromium.mojom.payments.PaymentAddress; | 8 import org.chromium.mojom.payments.PaymentAddress; |
9 import org.chromium.testing.local.LocalRobolectricTestRunner; | 9 import org.chromium.testing.local.LocalRobolectricTestRunner; |
10 import org.junit.Assert; | 10 import org.junit.Assert; |
(...skipping 22 matching lines...) Expand all Loading... |
33 Assert.assertFalse(pattern.matcher("").matches()); | 33 Assert.assertFalse(pattern.matcher("").matches()); |
34 } | 34 } |
35 | 35 |
36 @Test | 36 @Test |
37 public void testToPaymentAddress() { | 37 public void testToPaymentAddress() { |
38 AutofillAddress input = new AutofillAddress(new AutofillProfile("guid",
"origin", | 38 AutofillAddress input = new AutofillAddress(new AutofillProfile("guid",
"origin", |
39 true /* isLocal */, "full name", "company name", "street\naddres
s", "region", | 39 true /* isLocal */, "full name", "company name", "street\naddres
s", "region", |
40 "locality", "dependent locality", "postal code", "sorting code",
"US", | 40 "locality", "dependent locality", "postal code", "sorting code",
"US", |
41 "phone number", "email@address.com", "en-Latn-US")); | 41 "phone number", "email@address.com", "en-Latn-US")); |
42 PaymentAddress output = input.toPaymentAddress(); | 42 PaymentAddress output = input.toPaymentAddress(); |
43 Assert.assertEquals("US", output.regionCode); | 43 Assert.assertEquals("US", output.country); |
44 Assert.assertArrayEquals(new String[]{"street", "address"}, output.addre
ssLine); | 44 Assert.assertArrayEquals(new String[]{"street", "address"}, output.addre
ssLine); |
45 Assert.assertEquals("region", output.administrativeArea); | 45 Assert.assertEquals("region", output.region); |
46 Assert.assertEquals("locality", output.locality); | 46 Assert.assertEquals("locality", output.city); |
47 Assert.assertEquals("dependent locality", output.dependentLocality); | 47 Assert.assertEquals("dependent locality", output.dependentLocality); |
48 Assert.assertEquals("postal code", output.postalCode); | 48 Assert.assertEquals("postal code", output.postalCode); |
49 Assert.assertEquals("sorting code", output.sortingCode); | 49 Assert.assertEquals("sorting code", output.sortingCode); |
50 Assert.assertEquals("company name", output.organization); | 50 Assert.assertEquals("company name", output.organization); |
51 Assert.assertEquals("full name", output.recipient); | 51 Assert.assertEquals("full name", output.recipient); |
52 Assert.assertEquals("en", output.languageCode); | 52 Assert.assertEquals("en", output.languageCode); |
53 Assert.assertEquals("Latn", output.scriptCode); | 53 Assert.assertEquals("Latn", output.scriptCode); |
| 54 Assert.assertEquals("", output.careOf); |
| 55 Assert.assertEquals("phone number", output.phone); |
54 } | 56 } |
55 | 57 |
56 @Test | 58 @Test |
57 public void testToPaymentAddressWithoutMatchingLanguageScriptCode() { | 59 public void testToPaymentAddressWithoutMatchingLanguageScriptCode() { |
58 AutofillAddress input = new AutofillAddress(new AutofillProfile("guid",
"origin", | 60 AutofillAddress input = new AutofillAddress(new AutofillProfile("guid",
"origin", |
59 true /* isLocal */, "full name", "company name", "street\naddres
s", "region", | 61 true /* isLocal */, "full name", "company name", "street\naddres
s", "region", |
60 "locality", "dependent locality", "postal code", "sorting code",
"US", | 62 "locality", "dependent locality", "postal code", "sorting code",
"US", |
61 "phone number", "email@address.com", "language-code")); | 63 "phone number", "email@address.com", "language-code")); |
62 PaymentAddress output = input.toPaymentAddress(); | 64 PaymentAddress output = input.toPaymentAddress(); |
63 Assert.assertEquals("", output.languageCode); | 65 Assert.assertEquals("", output.languageCode); |
(...skipping 29 matching lines...) Expand all Loading... |
93 "locality", "dependent locality", "postal code", "sorting code",
"US", | 95 "locality", "dependent locality", "postal code", "sorting code",
"US", |
94 "phone number", "email@address.com", "en-Latn")); | 96 "phone number", "email@address.com", "en-Latn")); |
95 PaymentAddress output1 = input.toPaymentAddress(); | 97 PaymentAddress output1 = input.toPaymentAddress(); |
96 PaymentAddress output2 = input.toPaymentAddress(); | 98 PaymentAddress output2 = input.toPaymentAddress(); |
97 Assert.assertEquals("en", output1.languageCode); | 99 Assert.assertEquals("en", output1.languageCode); |
98 Assert.assertEquals("en", output2.languageCode); | 100 Assert.assertEquals("en", output2.languageCode); |
99 Assert.assertEquals("Latn", output1.scriptCode); | 101 Assert.assertEquals("Latn", output1.scriptCode); |
100 Assert.assertEquals("Latn", output2.scriptCode); | 102 Assert.assertEquals("Latn", output2.scriptCode); |
101 } | 103 } |
102 } | 104 } |
OLD | NEW |