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

Side by Side Diff: chrome/android/junit/src/org/chromium/chrome/browser/payments/AutofillAddressTest.java

Issue 2020913002: PaymentRequest: Rename ShippingAddress to PaymentAddress. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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 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.ShippingAddress; 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;
11 import org.junit.Test; 11 import org.junit.Test;
12 import org.junit.runner.RunWith; 12 import org.junit.runner.RunWith;
13 import org.robolectric.annotation.Config; 13 import org.robolectric.annotation.Config;
14 14
15 import java.util.regex.Pattern; 15 import java.util.regex.Pattern;
16 16
17 /** 17 /**
18 * Unit tests for the AutofillAddress class. 18 * Unit tests for the AutofillAddress class.
19 */ 19 */
20 @RunWith(LocalRobolectricTestRunner.class) 20 @RunWith(LocalRobolectricTestRunner.class)
21 @Config(manifest = Config.NONE) 21 @Config(manifest = Config.NONE)
22 public class AutofillAddressTest { 22 public class AutofillAddressTest {
23 @Test 23 @Test
24 public void testRegionCodePattern() { 24 public void testRegionCodePattern() {
25 Pattern pattern = Pattern.compile(AutofillAddress.REGION_CODE_PATTERN); 25 Pattern pattern = Pattern.compile(AutofillAddress.REGION_CODE_PATTERN);
26 26
27 Assert.assertTrue(pattern.matcher("US").matches()); 27 Assert.assertTrue(pattern.matcher("US").matches());
28 Assert.assertTrue(pattern.matcher("GB").matches()); 28 Assert.assertTrue(pattern.matcher("GB").matches());
29 29
30 Assert.assertFalse(pattern.matcher("USA").matches()); 30 Assert.assertFalse(pattern.matcher("USA").matches());
31 Assert.assertFalse(pattern.matcher("gb").matches()); 31 Assert.assertFalse(pattern.matcher("gb").matches());
32 Assert.assertFalse(pattern.matcher("U2").matches()); 32 Assert.assertFalse(pattern.matcher("U2").matches());
33 Assert.assertFalse(pattern.matcher("").matches()); 33 Assert.assertFalse(pattern.matcher("").matches());
34 } 34 }
35 35
36 @Test 36 @Test
37 public void testToShippingAddress() { 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 ShippingAddress output = input.toShippingAddress(); 42 PaymentAddress output = input.toPaymentAddress();
43 Assert.assertEquals("US", output.regionCode); 43 Assert.assertEquals("US", output.regionCode);
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.administrativeArea);
46 Assert.assertEquals("locality", output.locality); 46 Assert.assertEquals("locality", output.locality);
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 } 54 }
55 55
56 @Test 56 @Test
57 public void testToShippingAddressWithoutMatchingLanguageScriptCode() { 57 public void testToPaymentAddressWithoutMatchingLanguageScriptCode() {
58 AutofillAddress input = new AutofillAddress(new AutofillProfile("guid", "origin", 58 AutofillAddress input = new AutofillAddress(new AutofillProfile("guid", "origin",
59 true /* isLocal */, "full name", "company name", "street\naddres s", "region", 59 true /* isLocal */, "full name", "company name", "street\naddres s", "region",
60 "locality", "dependent locality", "postal code", "sorting code", "US", 60 "locality", "dependent locality", "postal code", "sorting code", "US",
61 "phone number", "email@address.com", "language-code")); 61 "phone number", "email@address.com", "language-code"));
62 ShippingAddress output = input.toShippingAddress(); 62 PaymentAddress output = input.toPaymentAddress();
63 Assert.assertEquals("", output.languageCode); 63 Assert.assertEquals("", output.languageCode);
64 Assert.assertEquals("", output.scriptCode); 64 Assert.assertEquals("", output.scriptCode);
65 } 65 }
66 66
67 @Test 67 @Test
68 public void testToShippingAddressWithoutAnyLanguageScriptCode() { 68 public void testToPaymentAddressWithoutAnyLanguageScriptCode() {
69 AutofillAddress input = new AutofillAddress(new AutofillProfile("guid", "origin", 69 AutofillAddress input = new AutofillAddress(new AutofillProfile("guid", "origin",
70 true /* isLocal */, "full name", "company name", "street\naddres s", "region", 70 true /* isLocal */, "full name", "company name", "street\naddres s", "region",
71 "locality", "dependent locality", "postal code", "sorting code", "US", 71 "locality", "dependent locality", "postal code", "sorting code", "US",
72 "phone number", "email@address.com", "")); 72 "phone number", "email@address.com", ""));
73 ShippingAddress output = input.toShippingAddress(); 73 PaymentAddress output = input.toPaymentAddress();
74 Assert.assertEquals("", output.languageCode); 74 Assert.assertEquals("", output.languageCode);
75 Assert.assertEquals("", output.scriptCode); 75 Assert.assertEquals("", output.scriptCode);
76 } 76 }
77 77
78 @Test 78 @Test
79 public void testToShippingAddressWithNullLanguageScriptCode() { 79 public void testToPaymentAddressWithNullLanguageScriptCode() {
80 AutofillAddress input = new AutofillAddress(new AutofillProfile("guid", "origin", 80 AutofillAddress input = new AutofillAddress(new AutofillProfile("guid", "origin",
81 true /* isLocal */, "full name", "company name", "street\naddres s", "region", 81 true /* isLocal */, "full name", "company name", "street\naddres s", "region",
82 "locality", "dependent locality", "postal code", "sorting code", "US", 82 "locality", "dependent locality", "postal code", "sorting code", "US",
83 "phone number", "email@address.com", null)); 83 "phone number", "email@address.com", null));
84 ShippingAddress output = input.toShippingAddress(); 84 PaymentAddress output = input.toPaymentAddress();
85 Assert.assertEquals("", output.languageCode); 85 Assert.assertEquals("", output.languageCode);
86 Assert.assertEquals("", output.scriptCode); 86 Assert.assertEquals("", output.scriptCode);
87 } 87 }
88 88
89 @Test 89 @Test
90 public void testToShippingAddressTwice() { 90 public void testToPaymentAddressTwice() {
91 AutofillAddress input = new AutofillAddress(new AutofillProfile("guid", "origin", 91 AutofillAddress input = new AutofillAddress(new AutofillProfile("guid", "origin",
92 true /* isLocal */, "full name", "company name", "street\naddres s", "region", 92 true /* isLocal */, "full name", "company name", "street\naddres s", "region",
93 "locality", "dependent locality", "postal code", "sorting code", "US", 93 "locality", "dependent locality", "postal code", "sorting code", "US",
94 "phone number", "email@address.com", "en-Latn")); 94 "phone number", "email@address.com", "en-Latn"));
95 ShippingAddress output1 = input.toShippingAddress(); 95 PaymentAddress output1 = input.toPaymentAddress();
96 ShippingAddress output2 = input.toShippingAddress(); 96 PaymentAddress output2 = input.toPaymentAddress();
97 Assert.assertEquals("en", output1.languageCode); 97 Assert.assertEquals("en", output1.languageCode);
98 Assert.assertEquals("en", output2.languageCode); 98 Assert.assertEquals("en", output2.languageCode);
99 Assert.assertEquals("Latn", output1.scriptCode); 99 Assert.assertEquals("Latn", output1.scriptCode);
100 Assert.assertEquals("Latn", output2.scriptCode); 100 Assert.assertEquals("Latn", output2.scriptCode);
101 } 101 }
102 } 102 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698