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 android.support.test.filters.MediumTest; | 7 import android.support.test.filters.MediumTest; |
8 | 8 |
9 import org.chromium.base.test.util.Feature; | 9 import org.chromium.base.test.util.Feature; |
10 import org.chromium.chrome.R; | 10 import org.chromium.chrome.R; |
11 import org.chromium.chrome.browser.autofill.AutofillTestHelper; | 11 import org.chromium.chrome.browser.autofill.AutofillTestHelper; |
12 import org.chromium.chrome.browser.autofill.PersonalDataManager.AutofillProfile; | 12 import org.chromium.chrome.browser.autofill.PersonalDataManager.AutofillProfile; |
13 import org.chromium.chrome.browser.autofill.PersonalDataManager.CreditCard; | 13 import org.chromium.chrome.browser.autofill.PersonalDataManager.CreditCard; |
14 | 14 |
15 import java.util.concurrent.ExecutionException; | 15 import java.util.concurrent.ExecutionException; |
16 import java.util.concurrent.TimeoutException; | 16 import java.util.concurrent.TimeoutException; |
17 | 17 |
18 /** | 18 /** |
19 * A payment integration test for biling addresses. | 19 * A payment integration test for biling addresses. |
20 */ | 20 */ |
21 public class PaymentRequestBillingAddressTest extends PaymentRequestTestBase { | 21 public class PaymentRequestBillingAddressTest extends PaymentRequestTestBase { |
22 /* | 22 /* |
23 * The index at which the option to add a billing address is located in the
billing address | 23 * The index at which the option to add a billing address is located in the
billing address |
24 * selection dropdown. | 24 * selection dropdown. |
25 */ | 25 */ |
26 private static final int ADD_BILLING_ADDRESS = 3; | 26 private static final int ADD_BILLING_ADDRESS = 7; |
27 | 27 |
28 /** The index of the billing address dropdown in the card editor. */ | 28 /** The index of the billing address dropdown in the card editor. */ |
29 private static final int BILLING_ADDRESS_DROPDOWN_INDEX = 2; | 29 private static final int BILLING_ADDRESS_DROPDOWN_INDEX = 2; |
30 | 30 |
31 public PaymentRequestBillingAddressTest() { | 31 public PaymentRequestBillingAddressTest() { |
32 super("payment_request_free_shipping_test.html"); | 32 super("payment_request_free_shipping_test.html"); |
33 } | 33 } |
34 | 34 |
35 @Override | 35 @Override |
36 public void onMainActivityStarted() | 36 public void onMainActivityStarted() |
37 throws InterruptedException, ExecutionException, TimeoutException { | 37 throws InterruptedException, ExecutionException, TimeoutException { |
38 AutofillTestHelper helper = new AutofillTestHelper(); | 38 AutofillTestHelper helper = new AutofillTestHelper(); |
39 String profile1 = helper.setProfile(new AutofillProfile("", "https://exa
mple.com", true, | 39 String profile1 = helper.setProfile(new AutofillProfile("", "https://exa
mple.com", true, |
40 "Jon Doe", "Google", "340 Main St", "CA", "Los Angeles", "", "90
291", "", "US", | 40 "Jon Doe", "Google", "340 Main St", "CA", "Los Angeles", "", "90
291", "", "US", |
41 "310-310-6000", "jon.doe@gmail.com", "en-US")); | 41 "310-310-6000", "jon.doe@gmail.com", "en-US")); |
42 helper.setCreditCard(new CreditCard("", "https://example.com", true, tru
e, "Jon Doe", | 42 helper.setCreditCard(new CreditCard("", "https://example.com", true, tru
e, "Jon Doe", |
43 "4111111111111111", "1111", "12", "2050", "visa", R.drawable.pr_
visa, profile1, | 43 "4111111111111111", "1111", "12", "2050", "visa", R.drawable.pr_
visa, profile1, |
44 "" /* serverId */)); | 44 "" /* serverId */)); |
45 String profile2 = helper.setProfile(new AutofillProfile("", "https://exa
mple.com", true, | 45 String profile2 = helper.setProfile(new AutofillProfile("", "https://exa
mple.com", true, |
46 "Rob Doe", "Google", "340 Main St", "CA", "Los Angeles", "", "90
291", "", "US", | 46 "Rob Doe", "Google", "340 Main St", "CA", "Los Angeles", "", "90
291", "", "US", |
47 "310-310-6000", "jon.doe@gmail.com", "en-US")); | 47 "310-310-6000", "jon.doe@gmail.com", "en-US")); |
48 String profile3 = helper.setProfile(new AutofillProfile("", "https://exa
mple.com", true, | 48 String profile3 = helper.setProfile(new AutofillProfile("", "https://exa
mple.com", true, |
49 "Tom Doe", "Google", "340 Main St", "CA", "Los Angeles", "", "90
291", "", "US", | 49 "Tom Doe", "Google", "340 Main St", "CA", "Los Angeles", "", "90
291", "", "US", |
50 "310-310-6000", "jon.doe@gmail.com", "en-US")); | 50 "310-310-6000", "jon.doe@gmail.com", "en-US")); |
| 51 |
| 52 // Incomplete profile (invalid address). |
| 53 String profile4 = helper.setProfile(new AutofillProfile("", "https://exa
mple.com", true, |
| 54 "Bart Doe", "Google", "340 Main St", "CA", "", "", "90291", "",
"US", |
| 55 "310-310-6000", "jon.doe@gmail.com", "en-US")); |
| 56 |
| 57 // Incomplete profile (missing phone number) |
| 58 String profile5 = helper.setProfile(new AutofillProfile("", "https://exa
mple.com", true, |
| 59 "Lisa Doe", "Google", "340 Main St", "CA", "Los Angeles", "", "9
0291", "", "US", "", |
| 60 "jon.doe@gmail.com", "en-US")); |
| 61 |
| 62 // Incomplete profile (missing recipient). |
| 63 String profile6 = helper.setProfile(new AutofillProfile("", "https://exa
mple.com", true, "", |
| 64 "Google", "340 Main St", "CA", "Los Angeles", "", "90291", "", "
US", "310-310-6000", |
| 65 "jon.doe@gmail.com", "en-US")); |
| 66 |
| 67 // Incomplete profile (need more information). |
| 68 String profile7 = helper.setProfile(new AutofillProfile("", "https://exa
mple.com", true, |
| 69 "Maggie Doe", "Google", "340 Main St", "CA", "", "", "90291", ""
, "US", "", |
| 70 "jon.doe@gmail.com", "en-US")); |
| 71 |
51 // This card has no billing address selected. | 72 // This card has no billing address selected. |
52 helper.setCreditCard(new CreditCard("", "https://example.com", true, tru
e, "Jane Doe", | 73 helper.setCreditCard(new CreditCard("", "https://example.com", true, tru
e, "Jane Doe", |
53 "4242424242424242", "1111", "12", "2050", "visa", R.drawable.pr_
visa, | 74 "4242424242424242", "1111", "12", "2050", "visa", R.drawable.pr_
visa, profile5, |
54 "" /* billingAddressId */, "" /* serverId */)); | 75 "" /* serverId */)); |
55 | 76 |
56 // Assign use stats so that profile2 has the highest frecency and profil
e3 has the lowest. | 77 // Assign use stats so that incomplete profiles have the highest frecenc
y, profile2 has the |
| 78 // highest frecency and profile3 has the lowest among the complete profi
les, and profile5 |
| 79 // has the highest frecency and profile4 has the lowest among the incomp
lete profiles. |
57 helper.setProfileUseStatsForTesting(profile1, 5, 5); | 80 helper.setProfileUseStatsForTesting(profile1, 5, 5); |
58 helper.setProfileUseStatsForTesting(profile2, 10, 10); | 81 helper.setProfileUseStatsForTesting(profile2, 10, 10); |
59 helper.setProfileUseStatsForTesting(profile3, 1, 1); | 82 helper.setProfileUseStatsForTesting(profile3, 1, 1); |
| 83 helper.setProfileUseStatsForTesting(profile4, 15, 15); |
| 84 helper.setProfileUseStatsForTesting(profile5, 30, 30); |
| 85 helper.setProfileUseStatsForTesting(profile6, 25, 25); |
| 86 helper.setProfileUseStatsForTesting(profile7, 20, 20); |
60 } | 87 } |
61 | 88 |
62 /** Verifies the format of the billing address suggestions when adding a new
credit card. */ | 89 /** Verifies the format of the billing address suggestions when adding a new
credit card. */ |
63 @MediumTest | 90 @MediumTest |
64 @Feature({"Payments"}) | 91 @Feature({"Payments"}) |
65 public void testNewCardBillingAddressFormat() | 92 public void testNewCardBillingAddressFormat() |
66 throws InterruptedException, ExecutionException, TimeoutException { | 93 throws InterruptedException, ExecutionException, TimeoutException { |
67 triggerUIAndWait(mReadyToPay); | 94 triggerUIAndWait(mReadyToPay); |
68 clickInPaymentMethodAndWait(R.id.payments_section, mReadyForInput); | 95 clickInPaymentMethodAndWait(R.id.payments_section, mReadyForInput); |
69 clickInPaymentMethodAndWait(R.id.payments_add_option_button, mReadyToEdi
t); | 96 clickInPaymentMethodAndWait(R.id.payments_add_option_button, mReadyToEdi
t); |
70 setTextInCardEditorAndWait(new String[] {"5454-5454-5454-5454", "Bob"},
mEditorTextUpdate); | 97 setTextInCardEditorAndWait(new String[] {"5454-5454-5454-5454", "Bob"},
mEditorTextUpdate); |
71 setSpinnerSelectionsInCardEditorAndWait( | 98 setSpinnerSelectionsInCardEditorAndWait( |
72 new int[] {DECEMBER, NEXT_YEAR, FIRST_BILLING_ADDRESS}, | 99 new int[] {DECEMBER, NEXT_YEAR, FIRST_BILLING_ADDRESS}, |
73 mBillingAddressChangeProcessed); | 100 mBillingAddressChangeProcessed); |
74 // The billing address suggestions should include only the name, address
, city, state and | 101 // The billing address suggestions should include only the name, address
, city, state and |
75 // zip code of the profile. | 102 // zip code of the profile. |
76 assertTrue(getSpinnerSelectionTextInCardEditor(BILLING_ADDRESS_DROPDOWN_
INDEX) | 103 assertTrue(getSpinnerSelectionTextInCardEditor(BILLING_ADDRESS_DROPDOWN_
INDEX) |
77 .equals("Rob Doe, 340 Main St, Los Angeles, CA 90291"
)); | 104 .equals("Rob Doe, 340 Main St, Los Angeles, CA 90291")); |
78 } | 105 } |
79 | 106 |
80 /** | 107 /** |
81 * Verifies that the correct number of billing address suggestions are shown
when adding a new | 108 * Verifies that the correct number of billing address suggestions are shown
when adding a new |
82 * credit card. | 109 * credit card. |
83 */ | 110 */ |
84 @MediumTest | 111 @MediumTest |
85 @Feature({"Payments"}) | 112 @Feature({"Payments"}) |
86 public void testNumberOfBillingAddressSuggestions() | 113 public void testNumberOfBillingAddressSuggestions() |
87 throws InterruptedException, ExecutionException, TimeoutException { | 114 throws InterruptedException, ExecutionException, TimeoutException { |
88 triggerUIAndWait(mReadyToPay); | 115 triggerUIAndWait(mReadyToPay); |
89 clickInPaymentMethodAndWait(R.id.payments_section, mReadyForInput); | 116 clickInPaymentMethodAndWait(R.id.payments_section, mReadyForInput); |
90 clickInPaymentMethodAndWait(R.id.payments_add_option_button, mReadyToEdi
t); | 117 clickInPaymentMethodAndWait(R.id.payments_add_option_button, mReadyToEdi
t); |
91 | 118 |
92 // There should only be 4 suggestions, the 3 saved addresses and the opt
ion to add a new | 119 // There should only be 8 suggestions, the 7 saved addresses and the opt
ion to add a new |
93 // address. | 120 // address. |
94 assertEquals(4, getSpinnerItemCountInCardEditor(BILLING_ADDRESS_DROPDOWN
_INDEX)); | 121 assertEquals(8, getSpinnerItemCountInCardEditor(BILLING_ADDRESS_DROPDOWN
_INDEX)); |
95 } | 122 } |
96 | 123 |
97 /** | 124 /** |
98 * Verifies that the correct number of billing address suggestions are shown
when adding a new | 125 * Verifies that the correct number of billing address suggestions are shown
when adding a new |
99 * credit card, even after cancelling out of adding a new billing address. | 126 * credit card, even after cancelling out of adding a new billing address. |
100 */ | 127 */ |
101 @MediumTest | 128 @MediumTest |
102 @Feature({"Payments"}) | 129 @Feature({"Payments"}) |
103 public void testNumberOfBillingAddressSuggestions_AfterCancellingNewBillingA
ddress() | 130 public void testNumberOfBillingAddressSuggestions_AfterCancellingNewBillingA
ddress() |
104 throws InterruptedException, ExecutionException, TimeoutException { | 131 throws InterruptedException, ExecutionException, TimeoutException { |
105 // Add a payment method and add a new billing address. | 132 // Add a payment method and add a new billing address. |
106 triggerUIAndWait(mReadyToPay); | 133 triggerUIAndWait(mReadyToPay); |
107 clickInPaymentMethodAndWait(R.id.payments_section, mReadyForInput); | 134 clickInPaymentMethodAndWait(R.id.payments_section, mReadyForInput); |
108 clickInPaymentMethodAndWait(R.id.payments_add_option_button, mReadyToEdi
t); | 135 clickInPaymentMethodAndWait(R.id.payments_add_option_button, mReadyToEdi
t); |
109 | 136 |
110 // Select the "+ ADD ADDRESS" option for the billing address. | 137 // Select the "+ ADD ADDRESS" option for the billing address. |
111 setSpinnerSelectionsInCardEditorAndWait( | 138 setSpinnerSelectionsInCardEditorAndWait( |
112 new int[] {DECEMBER, NEXT_YEAR, ADD_BILLING_ADDRESS}, mReadyToEd
it); | 139 new int[] {DECEMBER, NEXT_YEAR, ADD_BILLING_ADDRESS}, mReadyToEd
it); |
113 | 140 |
114 // Cancel the creation of a new billing address. | 141 // Cancel the creation of a new billing address. |
115 clickInEditorAndWait(R.id.payments_edit_cancel_button, mReadyToEdit); | 142 clickInEditorAndWait(R.id.payments_edit_cancel_button, mReadyToEdit); |
116 | 143 |
117 // There should still only be 4 suggestions, the 3 saved addresses and t
he option to add a | 144 // There should still only be 8 suggestions, the 7 saved addresses and t
he option to add a |
118 // new address. | 145 // new address. |
119 assertEquals(4, getSpinnerItemCountInCardEditor(BILLING_ADDRESS_DROPDOWN
_INDEX)); | 146 assertEquals(8, getSpinnerItemCountInCardEditor(BILLING_ADDRESS_DROPDOWN
_INDEX)); |
120 } | 147 } |
121 | 148 |
122 /** | 149 /** |
123 * Tests that for a card that already has a billing address, adding a new on
e and cancelling | 150 * Tests that for a card that already has a billing address, adding a new on
e and cancelling |
124 * maintains the previous selection. */ | 151 * maintains the previous selection. */ |
125 @MediumTest | 152 @MediumTest |
126 @Feature({"Payments"}) | 153 @Feature({"Payments"}) |
127 public void testAddBillingAddressOnCardAndCancel_MaintainsPreviousSelection(
) | 154 public void testAddBillingAddressOnCardAndCancel_MaintainsPreviousSelection(
) |
128 throws InterruptedException, ExecutionException, TimeoutException { | 155 throws InterruptedException, ExecutionException, TimeoutException { |
129 triggerUIAndWait(mReadyToPay); | 156 triggerUIAndWait(mReadyToPay); |
130 // Edit the only card. | 157 // Edit the only card. |
131 clickInPaymentMethodAndWait(R.id.payments_section, mReadyForInput); | 158 clickInPaymentMethodAndWait(R.id.payments_section, mReadyForInput); |
132 clickInPaymentMethodAndWait(R.id.payments_open_editor_pencil_button, mRe
adyToEdit); | 159 clickInPaymentMethodAndWait(R.id.payments_open_editor_pencil_button, mRe
adyToEdit); |
133 | 160 |
134 // Jon Doe is selected as the billing address. | 161 // Jon Doe is selected as the billing address. |
135 assertTrue(getSpinnerSelectionTextInCardEditor(BILLING_ADDRESS_DROPDOWN_
INDEX) | 162 assertTrue(getSpinnerSelectionTextInCardEditor(BILLING_ADDRESS_DROPDOWN_
INDEX) |
136 .equals("Jon Doe, 340 Main St, Los Angeles, CA 90291"
)); | 163 .equals("Jon Doe, 340 Main St, Los Angeles, CA 90291")); |
137 | 164 |
138 // Select the "+ ADD ADDRESS" option for the billing address. | 165 // Select the "+ ADD ADDRESS" option for the billing address. |
139 setSpinnerSelectionsInCardEditorAndWait( | 166 setSpinnerSelectionsInCardEditorAndWait( |
140 new int[] {DECEMBER, NEXT_YEAR, ADD_BILLING_ADDRESS}, mReadyToEd
it); | 167 new int[] {DECEMBER, NEXT_YEAR, ADD_BILLING_ADDRESS}, mReadyToEd
it); |
141 | 168 |
142 // Cancel the creation of a new billing address. | 169 // Cancel the creation of a new billing address. |
143 clickInEditorAndWait(R.id.payments_edit_cancel_button, mReadyToEdit); | 170 clickInEditorAndWait(R.id.payments_edit_cancel_button, mReadyToEdit); |
144 | 171 |
145 // Jon Doe is STILL selected as the billing address. | 172 // Jon Doe is STILL selected as the billing address. |
146 assertTrue(getSpinnerSelectionTextInCardEditor(BILLING_ADDRESS_DROPDOWN_
INDEX) | 173 assertTrue(getSpinnerSelectionTextInCardEditor(BILLING_ADDRESS_DROPDOWN_
INDEX) |
147 .equals("Jon Doe, 340 Main St, Los Angeles, CA 90291"
)); | 174 .equals("Jon Doe, 340 Main St, Los Angeles, CA 90291")); |
148 } | 175 } |
149 | 176 |
150 /** | 177 /** |
151 * Tests that adding a billing address for a card that has none, and cancell
ing then returns | 178 * Tests that adding a billing address for a card that has none, and cancell
ing then returns |
152 * to the proper selection (Select...). | 179 * to the proper selection (Select...). |
153 */ | 180 */ |
154 @MediumTest | 181 @MediumTest |
155 @Feature({"Payments"}) | 182 @Feature({"Payments"}) |
156 public void testAddBillingAddressOnCardWithNoBillingAndCancel_MaintainsPrevi
ousSelection() | 183 public void testAddBillingAddressOnCardWithNoBillingAndCancel_MaintainsPrevi
ousSelection() |
157 throws InterruptedException, ExecutionException, TimeoutException { | 184 throws InterruptedException, ExecutionException, TimeoutException { |
158 triggerUIAndWait(mReadyToPay); | 185 triggerUIAndWait(mReadyToPay); |
159 // Edit the second card. | 186 // Edit the second card. |
160 clickInPaymentMethodAndWait(R.id.payments_section, mReadyForInput); | 187 clickInPaymentMethodAndWait(R.id.payments_section, mReadyForInput); |
161 clickOnPaymentMethodSuggestionOptionAndWait(1, mReadyForInput); | 188 clickOnPaymentMethodSuggestionOptionAndWait(1, mReadyForInput); |
162 | 189 |
163 // Now in Card Editor to add a billing address. "Select" is selected in
the dropdown. | 190 // Now in Card Editor to add a billing address. "Select" is selected in
the dropdown. |
164 assertTrue(getSpinnerSelectionTextInCardEditor(BILLING_ADDRESS_DROPDOWN_
INDEX) | 191 assertTrue(getSpinnerSelectionTextInCardEditor(BILLING_ADDRESS_DROPDOWN_
INDEX) |
165 .equals("Select")); | 192 .equals("Select")); |
166 | 193 |
167 // Select the "+ ADD ADDRESS" option for the billing address. | 194 // Select the "+ ADD ADDRESS" option for the billing address. |
168 setSpinnerSelectionsInCardEditorAndWait( | 195 setSpinnerSelectionsInCardEditorAndWait( |
169 new int[] {DECEMBER, NEXT_YEAR, ADD_BILLING_ADDRESS}, mReadyToEd
it); | 196 new int[] {DECEMBER, NEXT_YEAR, ADD_BILLING_ADDRESS}, mReadyToEd
it); |
170 | 197 |
171 // Cancel the creation of a new billing address. | 198 // Cancel the creation of a new billing address. |
172 clickInEditorAndWait(R.id.payments_edit_cancel_button, mReadyToEdit); | 199 clickInEditorAndWait(R.id.payments_edit_cancel_button, mReadyToEdit); |
173 | 200 |
174 // "Select" is STILL selected as the billing address. | 201 // "Select" is STILL selected as the billing address. |
175 assertTrue(getSpinnerSelectionTextInCardEditor(BILLING_ADDRESS_DROPDOWN_
INDEX) | 202 assertTrue(getSpinnerSelectionTextInCardEditor(BILLING_ADDRESS_DROPDOWN_
INDEX) |
176 .equals("Select")); | 203 .equals("Select")); |
177 } | 204 } |
178 | 205 |
179 /** | 206 /** |
180 * Verifies that the billing address suggestions are ordered by frecency. | 207 * Verifies that the billing address suggestions are ordered by frecency. |
181 */ | 208 */ |
182 @MediumTest | 209 @MediumTest |
183 @Feature({"Payments"}) | 210 @Feature({"Payments"}) |
184 public void testBillingAddressSortedByFrecency() | 211 public void testBillingAddressSortedByFrecency() |
185 throws InterruptedException, ExecutionException, TimeoutException { | 212 throws InterruptedException, ExecutionException, TimeoutException { |
186 // Add a payment method. | 213 // Add a payment method. |
187 triggerUIAndWait(mReadyToPay); | 214 triggerUIAndWait(mReadyToPay); |
188 clickInPaymentMethodAndWait(R.id.payments_section, mReadyForInput); | 215 clickInPaymentMethodAndWait(R.id.payments_section, mReadyForInput); |
189 clickInPaymentMethodAndWait(R.id.payments_add_option_button, mReadyToEdi
t); | 216 clickInPaymentMethodAndWait(R.id.payments_add_option_button, mReadyToEdi
t); |
190 | 217 |
191 // There should be 4 suggestions, the 3 saved addresses and the option t
o add a new address. | 218 // There should be 8 suggestions, the 7 saved addresses and the option t
o add a new address. |
192 assertEquals(4, getSpinnerItemCountInCardEditor(BILLING_ADDRESS_DROPDOWN
_INDEX)); | 219 assertEquals(8, getSpinnerItemCountInCardEditor(BILLING_ADDRESS_DROPDOWN
_INDEX)); |
193 | 220 |
194 // The billing address suggestions should be ordered by frecency. | 221 // The billing address suggestions should be ordered by frecency. |
195 assertTrue(getSpinnerTextAtPositionInCardEditor(BILLING_ADDRESS_DROPDOWN
_INDEX, | 222 assertTrue(getSpinnerTextAtPositionInCardEditor(BILLING_ADDRESS_DROPDOWN
_INDEX, |
196 0).equals("Rob Doe, 340 Main St, Los Angeles, CA 90291")); | 223 0).equals("Rob Doe, 340 Main St, Los Angeles, CA 90291")); |
197 assertTrue(getSpinnerTextAtPositionInCardEditor(BILLING_ADDRESS_DROPDOWN
_INDEX, | 224 assertTrue(getSpinnerTextAtPositionInCardEditor(BILLING_ADDRESS_DROPDOWN
_INDEX, |
198 1).equals("Jon Doe, 340 Main St, Los Angeles, CA 90291")); | 225 1).equals("Jon Doe, 340 Main St, Los Angeles, CA 90291")); |
199 assertTrue(getSpinnerTextAtPositionInCardEditor(BILLING_ADDRESS_DROPDOWN
_INDEX, | 226 assertTrue(getSpinnerTextAtPositionInCardEditor(BILLING_ADDRESS_DROPDOWN
_INDEX, |
200 2).equals("Tom Doe, 340 Main St, Los Angeles, CA 90291")); | 227 2).equals("Tom Doe, 340 Main St, Los Angeles, CA 90291")); |
201 assertTrue(getSpinnerTextAtPositionInCardEditor(BILLING_ADDRESS_DROPDOWN
_INDEX, | 228 assertTrue(getSpinnerTextAtPositionInCardEditor(BILLING_ADDRESS_DROPDOWN
_INDEX, |
202 3).equals("Add address")); | 229 7).equals("Add address")); |
203 } | 230 } |
204 | 231 |
205 /** | 232 /** |
206 * Verifies that the billing address suggestions are ordered by frecency, ex
cept for a newly | 233 * Verifies that the billing address suggestions are ordered by frecency, ex
cept for a newly |
207 * created address which should be suggested first. | 234 * created address which should be suggested first. |
208 */ | 235 */ |
209 @MediumTest | 236 @MediumTest |
210 @Feature({"Payments"}) | 237 @Feature({"Payments"}) |
211 public void testBillingAddressSortedByFrecency_AddNewAddress() | 238 public void testBillingAddressSortedByFrecency_AddNewAddress() |
212 throws InterruptedException, ExecutionException, TimeoutException { | 239 throws InterruptedException, ExecutionException, TimeoutException { |
213 // Add a payment method. | 240 // Add a payment method. |
214 triggerUIAndWait(mReadyToPay); | 241 triggerUIAndWait(mReadyToPay); |
215 clickInPaymentMethodAndWait(R.id.payments_section, mReadyForInput); | 242 clickInPaymentMethodAndWait(R.id.payments_section, mReadyForInput); |
216 clickInPaymentMethodAndWait(R.id.payments_add_option_button, mReadyToEdi
t); | 243 clickInPaymentMethodAndWait(R.id.payments_add_option_button, mReadyToEdi
t); |
217 | 244 |
218 // Add a new billing address. | 245 // Add a new billing address. |
219 setSpinnerSelectionsInCardEditorAndWait( | 246 setSpinnerSelectionsInCardEditorAndWait( |
220 new int[] {DECEMBER, NEXT_YEAR, ADD_BILLING_ADDRESS}, mReadyToEd
it); | 247 new int[] {DECEMBER, NEXT_YEAR, ADD_BILLING_ADDRESS}, mReadyToEd
it); |
221 setTextInEditorAndWait(new String[] {"Seb Doe", "Google", "340 Main St",
"Los Angeles", | 248 setTextInEditorAndWait(new String[] {"Seb Doe", "Google", "340 Main St",
"Los Angeles", |
222 "CA", "90291", "999-999-9999"}, mEditorTextUpdate); | 249 "CA", "90291", "999-999-9999"}, mEditorTextUpdate); |
223 clickInEditorAndWait(R.id.payments_edit_done_button, mReadyToEdit); | 250 clickInEditorAndWait(R.id.payments_edit_done_button, mReadyToEdit); |
224 | 251 |
225 // There should be 5 suggestions, the 3 initial addresses, the newly add
ed address and the | 252 // There should be 9 suggestions, the 7 initial addresses, the newly add
ed address and the |
226 // option to add a new address. | 253 // option to add a new address. |
227 assertEquals(5, getSpinnerItemCountInCardEditor(BILLING_ADDRESS_DROPDOWN
_INDEX)); | 254 assertEquals(9, getSpinnerItemCountInCardEditor(BILLING_ADDRESS_DROPDOWN
_INDEX)); |
228 | 255 |
229 // The fist suggestion should be the newly added address. | 256 // The fist suggestion should be the newly added address. |
230 assertTrue(getSpinnerTextAtPositionInCardEditor(BILLING_ADDRESS_DROPDOWN
_INDEX, | 257 assertTrue(getSpinnerTextAtPositionInCardEditor(BILLING_ADDRESS_DROPDOWN
_INDEX, |
231 0).equals("Seb Doe, 340 Main St, Los Angeles, CA 90291")); | 258 0).equals("Seb Doe, 340 Main St, Los Angeles, CA 90291")); |
232 | 259 |
233 // The rest of the billing address suggestions should be ordered by frec
ency. | 260 // The rest of the billing address suggestions should be ordered by frec
ency. |
234 assertTrue(getSpinnerTextAtPositionInCardEditor(BILLING_ADDRESS_DROPDOWN
_INDEX, | 261 assertTrue(getSpinnerTextAtPositionInCardEditor(BILLING_ADDRESS_DROPDOWN
_INDEX, |
235 1).equals("Rob Doe, 340 Main St, Los Angeles, CA 90291")); | 262 1).equals("Rob Doe, 340 Main St, Los Angeles, CA 90291")); |
236 assertTrue(getSpinnerTextAtPositionInCardEditor(BILLING_ADDRESS_DROPDOWN
_INDEX, | 263 assertTrue(getSpinnerTextAtPositionInCardEditor(BILLING_ADDRESS_DROPDOWN
_INDEX, |
237 2).equals("Jon Doe, 340 Main St, Los Angeles, CA 90291")); | 264 2).equals("Jon Doe, 340 Main St, Los Angeles, CA 90291")); |
238 assertTrue(getSpinnerTextAtPositionInCardEditor(BILLING_ADDRESS_DROPDOWN
_INDEX, | 265 assertTrue(getSpinnerTextAtPositionInCardEditor(BILLING_ADDRESS_DROPDOWN
_INDEX, |
239 3).equals("Tom Doe, 340 Main St, Los Angeles, CA 90291")); | 266 3).equals("Tom Doe, 340 Main St, Los Angeles, CA 90291")); |
240 assertTrue(getSpinnerTextAtPositionInCardEditor(BILLING_ADDRESS_DROPDOWN
_INDEX, | 267 assertTrue(getSpinnerTextAtPositionInCardEditor(BILLING_ADDRESS_DROPDOWN
_INDEX, |
241 4).equals("Add address")); | 268 8).equals("Add address")); |
242 } | 269 } |
243 | 270 |
244 /** | 271 /** |
245 * Verifies that a newly created shipping address is offered as the first bi
lling address | 272 * Verifies that a newly created shipping address is offered as the first bi
lling address |
246 * suggestion. | 273 * suggestion. |
247 */ | 274 */ |
248 @MediumTest | 275 @MediumTest |
249 @Feature({"Payments"}) | 276 @Feature({"Payments"}) |
250 public void testNewShippingAddressSuggestedFirst() | 277 public void testNewShippingAddressSuggestedFirst() |
251 throws InterruptedException, ExecutionException, TimeoutException { | 278 throws InterruptedException, ExecutionException, TimeoutException { |
252 triggerUIAndWait(mReadyToPay); | 279 triggerUIAndWait(mReadyToPay); |
253 | 280 |
254 // Add a shipping address. | 281 // Add a shipping address. |
255 clickInShippingSummaryAndWait(R.id.payments_section, mReadyForInput); | 282 clickInShippingSummaryAndWait(R.id.payments_section, mReadyForInput); |
256 clickInShippingAddressAndWait(R.id.payments_add_option_button, mReadyToE
dit); | 283 clickInShippingAddressAndWait(R.id.payments_add_option_button, mReadyToE
dit); |
257 setTextInEditorAndWait(new String[] {"Seb Doe", "Google", "340 Main St",
"Los Angeles", | 284 setTextInEditorAndWait(new String[] {"Seb Doe", "Google", "340 Main St",
"Los Angeles", |
258 "CA", "90291", "999-999-9999"}, mEditorTextUpdate); | 285 "CA", "90291", "999-999-9999"}, mEditorTextUpdate); |
259 clickInEditorAndWait(R.id.payments_edit_done_button, mReadyToPay); | 286 clickInEditorAndWait(R.id.payments_edit_done_button, mReadyToPay); |
260 | 287 |
261 // Navigate to the card editor UI. | 288 // Navigate to the card editor UI. |
262 clickInPaymentMethodAndWait(R.id.payments_section, mReadyForInput); | 289 clickInPaymentMethodAndWait(R.id.payments_section, mReadyForInput); |
263 clickInPaymentMethodAndWait(R.id.payments_add_option_button, mReadyToEdi
t); | 290 clickInPaymentMethodAndWait(R.id.payments_add_option_button, mReadyToEdi
t); |
264 | 291 |
265 // There should be 5 suggestions, the 3 initial addresses, the newly add
ed address and the | 292 // There should be 9 suggestions, the 7 initial addresses, the newly add
ed address and the |
266 // option to add a new address. | 293 // option to add a new address. |
267 assertEquals(5, getSpinnerItemCountInCardEditor(BILLING_ADDRESS_DROPDOWN
_INDEX)); | 294 assertEquals(9, getSpinnerItemCountInCardEditor(BILLING_ADDRESS_DROPDOWN
_INDEX)); |
268 | 295 |
269 // The new address should be suggested first. | 296 // The new address should be suggested first. |
270 assertTrue(getSpinnerTextAtPositionInCardEditor(BILLING_ADDRESS_DROPDOWN
_INDEX, | 297 assertTrue(getSpinnerTextAtPositionInCardEditor(BILLING_ADDRESS_DROPDOWN
_INDEX, |
271 0).equals("Seb Doe, 340 Main St, Los Angeles, CA 90291")); | 298 0).equals("Seb Doe, 340 Main St, Los Angeles, CA 90291")); |
272 } | 299 } |
| 300 |
| 301 @MediumTest |
| 302 @Feature({"Payments"}) |
| 303 public void testSelectIncompleteBillingAddress_EditComplete() |
| 304 throws InterruptedException, ExecutionException, TimeoutException { |
| 305 triggerUIAndWait(mReadyToPay); |
| 306 // Edit the second card. |
| 307 clickInPaymentMethodAndWait(R.id.payments_section, mReadyForInput); |
| 308 clickOnPaymentMethodSuggestionOptionAndWait(1, mReadyForInput); |
| 309 |
| 310 // Now "Select" is selected in the dropdown. |
| 311 assertTrue(getSpinnerSelectionTextInCardEditor(BILLING_ADDRESS_DROPDOWN_
INDEX) |
| 312 .equals("Select")); |
| 313 |
| 314 // The incomplete addresses in the dropdown contain edit required messag
es. |
| 315 assertTrue(getSpinnerTextAtPositionInCardEditor(BILLING_ADDRESS_DROPDOWN
_INDEX, |
| 316 3).endsWith("Phone number required")); |
| 317 assertTrue(getSpinnerTextAtPositionInCardEditor(BILLING_ADDRESS_DROPDOWN
_INDEX, |
| 318 4).endsWith("Recipient required")); |
| 319 assertTrue(getSpinnerTextAtPositionInCardEditor(BILLING_ADDRESS_DROPDOWN
_INDEX, |
| 320 5).endsWith("More information required")); |
| 321 assertTrue(getSpinnerTextAtPositionInCardEditor(BILLING_ADDRESS_DROPDOWN
_INDEX, |
| 322 6).endsWith("Invalid address")); |
| 323 |
| 324 // Selects the fourth billing addresss that misses phone number brings u
p the address |
| 325 // editor. |
| 326 setSpinnerSelectionsInCardEditorAndWait(new int[] {DECEMBER, NEXT_YEAR,
3}, mReadyToEdit); |
| 327 setTextInEditorAndWait(new String[] {"Lisa Doe", "Google", "340 Main St"
, "Los Angeles", |
| 328 "CA", "90291", "999-999-9999"}, mEditorTextUpdate); |
| 329 clickInEditorAndWait(R.id.payments_edit_done_button, mReadyToEdit); |
| 330 |
| 331 // The newly completed address must be selected and put at the top of th
e dropdown. |
| 332 assertTrue(getSpinnerSelectionTextInCardEditor(BILLING_ADDRESS_DROPDOWN_
INDEX) |
| 333 .equals("Lisa Doe, 340 Main St, Los Angeles, CA 90291")); |
| 334 assertTrue(getSpinnerTextAtPositionInCardEditor(BILLING_ADDRESS_DROPDOWN
_INDEX, |
| 335 0).equals("Lisa Doe, 340 Main St, Los Angeles, CA 90291")); |
| 336 } |
| 337 |
| 338 @MediumTest |
| 339 @Feature({"Payments"}) |
| 340 public void testSelectIncompleteBillingAddress_EditCancel() |
| 341 throws InterruptedException, ExecutionException, TimeoutException { |
| 342 triggerUIAndWait(mReadyToPay); |
| 343 // Edit the only complete card. |
| 344 clickInPaymentMethodAndWait(R.id.payments_section, mReadyForInput); |
| 345 clickInPaymentMethodAndWait(R.id.payments_open_editor_pencil_button, mRe
adyToEdit); |
| 346 |
| 347 // Jon Doe is selected as the billing address. |
| 348 assertTrue(getSpinnerSelectionTextInCardEditor(BILLING_ADDRESS_DROPDOWN_
INDEX) |
| 349 .equals("Jon Doe, 340 Main St, Los Angeles, CA 90291")); |
| 350 |
| 351 // The incomplete addresses in the dropdown contain edit required messag
es. |
| 352 assertTrue(getSpinnerTextAtPositionInCardEditor(BILLING_ADDRESS_DROPDOWN
_INDEX, |
| 353 3).endsWith("Phone number required")); |
| 354 assertTrue(getSpinnerTextAtPositionInCardEditor(BILLING_ADDRESS_DROPDOWN
_INDEX, |
| 355 4).endsWith("Recipient required")); |
| 356 assertTrue(getSpinnerTextAtPositionInCardEditor(BILLING_ADDRESS_DROPDOWN
_INDEX, |
| 357 5).endsWith("More information required")); |
| 358 assertTrue(getSpinnerTextAtPositionInCardEditor(BILLING_ADDRESS_DROPDOWN
_INDEX, |
| 359 6).endsWith("Invalid address")); |
| 360 |
| 361 // Selects the fifth billing addresss that misses recipient name brings
up the address |
| 362 // editor. |
| 363 setSpinnerSelectionsInCardEditorAndWait(new int[] {DECEMBER, NEXT_YEAR,
4}, mReadyToEdit); |
| 364 clickInEditorAndWait(R.id.payments_edit_cancel_button, mReadyToEdit); |
| 365 |
| 366 // The previous selected address should be selected after canceling out
from edit. |
| 367 assertTrue(getSpinnerSelectionTextInCardEditor(BILLING_ADDRESS_DROPDOWN_
INDEX) |
| 368 .equals("Jon Doe, 340 Main St, Los Angeles, CA 90291")); |
| 369 } |
273 } | 370 } |
OLD | NEW |