| 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.content.DialogInterface; | 7 import android.content.DialogInterface; |
| 8 import android.test.suitebuilder.annotation.MediumTest; | 8 import android.test.suitebuilder.annotation.MediumTest; |
| 9 | 9 |
| 10 import org.chromium.base.ThreadUtils; | 10 import org.chromium.base.ThreadUtils; |
| 11 import org.chromium.base.metrics.RecordHistogram; | 11 import org.chromium.base.metrics.RecordHistogram; |
| 12 import org.chromium.base.test.util.Feature; | 12 import org.chromium.base.test.util.Feature; |
| 13 import org.chromium.base.test.util.FlakyTest; | 13 import org.chromium.base.test.util.FlakyTest; |
| 14 import org.chromium.base.test.util.RetryOnFailure; | |
| 15 import org.chromium.chrome.R; | 14 import org.chromium.chrome.R; |
| 16 import org.chromium.chrome.browser.autofill.AutofillTestHelper; | 15 import org.chromium.chrome.browser.autofill.AutofillTestHelper; |
| 17 import org.chromium.chrome.browser.autofill.PersonalDataManager.AutofillProfile; | 16 import org.chromium.chrome.browser.autofill.PersonalDataManager.AutofillProfile; |
| 18 import org.chromium.chrome.browser.autofill.PersonalDataManager.CreditCard; | 17 import org.chromium.chrome.browser.autofill.PersonalDataManager.CreditCard; |
| 19 | 18 |
| 20 import java.util.concurrent.ExecutionException; | 19 import java.util.concurrent.ExecutionException; |
| 21 import java.util.concurrent.TimeoutException; | 20 import java.util.concurrent.TimeoutException; |
| 22 | 21 |
| 23 /** | 22 /** |
| 24 * A payment integration test for a merchant that does not require shipping addr
ess. | 23 * A payment integration test for a merchant that does not require shipping addr
ess. |
| (...skipping 15 matching lines...) Expand all Loading... |
| 40 true, "Jon Doe", "Google", "340 Main St", "CA", "Los Angeles", "
", "90291", "", | 39 true, "Jon Doe", "Google", "340 Main St", "CA", "Los Angeles", "
", "90291", "", |
| 41 "US", "310-310-6000", "jon.doe@gmail.com", "en-US")); | 40 "US", "310-310-6000", "jon.doe@gmail.com", "en-US")); |
| 42 helper.setCreditCard(new CreditCard("", "https://example.com", true, tru
e, "Jon Doe", | 41 helper.setCreditCard(new CreditCard("", "https://example.com", true, tru
e, "Jon Doe", |
| 43 "4111111111111111", "1111", "12", "2050", "visa", R.drawable.pr_
visa, | 42 "4111111111111111", "1111", "12", "2050", "visa", R.drawable.pr_
visa, |
| 44 billingAddressId, "" /* serverId */)); | 43 billingAddressId, "" /* serverId */)); |
| 45 } | 44 } |
| 46 | 45 |
| 47 /** Click [X] to cancel payment. */ | 46 /** Click [X] to cancel payment. */ |
| 48 @MediumTest | 47 @MediumTest |
| 49 @Feature({"Payments"}) | 48 @Feature({"Payments"}) |
| 50 @RetryOnFailure | |
| 51 public void testCloseDialog() throws InterruptedException, ExecutionExceptio
n, | 49 public void testCloseDialog() throws InterruptedException, ExecutionExceptio
n, |
| 52 TimeoutException { | 50 TimeoutException { |
| 53 triggerUIAndWait(mReadyForInput); | 51 triggerUIAndWait(mReadyForInput); |
| 54 clickAndWait(R.id.close_button, mDismissed); | 52 clickAndWait(R.id.close_button, mDismissed); |
| 55 expectResultContains(new String[] {"Request cancelled"}); | 53 expectResultContains(new String[] {"Request cancelled"}); |
| 56 } | 54 } |
| 57 | 55 |
| 58 /** Click [EDIT] to expand the dialog, then click [X] to cancel payment. */ | 56 /** Click [EDIT] to expand the dialog, then click [X] to cancel payment. */ |
| 59 @MediumTest | 57 @MediumTest |
| 60 @Feature({"Payments"}) | 58 @Feature({"Payments"}) |
| 61 @RetryOnFailure | |
| 62 public void testEditAndCloseDialog() throws InterruptedException, ExecutionE
xception, | 59 public void testEditAndCloseDialog() throws InterruptedException, ExecutionE
xception, |
| 63 TimeoutException { | 60 TimeoutException { |
| 64 triggerUIAndWait(mReadyForInput); | 61 triggerUIAndWait(mReadyForInput); |
| 65 clickAndWait(R.id.button_secondary, mReadyForInput); | 62 clickAndWait(R.id.button_secondary, mReadyForInput); |
| 66 clickAndWait(R.id.close_button, mDismissed); | 63 clickAndWait(R.id.close_button, mDismissed); |
| 67 expectResultContains(new String[] {"Request cancelled"}); | 64 expectResultContains(new String[] {"Request cancelled"}); |
| 68 } | 65 } |
| 69 | 66 |
| 70 /** Click [EDIT] to expand the dialog, then click [CANCEL] to cancel payment
. */ | 67 /** Click [EDIT] to expand the dialog, then click [CANCEL] to cancel payment
. */ |
| 71 @MediumTest | 68 @MediumTest |
| 72 @Feature({"Payments"}) | 69 @Feature({"Payments"}) |
| 73 @RetryOnFailure | |
| 74 public void testEditAndCancelDialog() throws InterruptedException, Execution
Exception, | 70 public void testEditAndCancelDialog() throws InterruptedException, Execution
Exception, |
| 75 TimeoutException { | 71 TimeoutException { |
| 76 triggerUIAndWait(mReadyForInput); | 72 triggerUIAndWait(mReadyForInput); |
| 77 clickAndWait(R.id.button_secondary, mReadyForInput); | 73 clickAndWait(R.id.button_secondary, mReadyForInput); |
| 78 clickAndWait(R.id.button_secondary, mDismissed); | 74 clickAndWait(R.id.button_secondary, mDismissed); |
| 79 expectResultContains(new String[] {"Request cancelled"}); | 75 expectResultContains(new String[] {"Request cancelled"}); |
| 80 } | 76 } |
| 81 | 77 |
| 82 /** Click [PAY] and dismiss the card unmask dialog. */ | 78 /** Click [PAY] and dismiss the card unmask dialog. */ |
| 83 @MediumTest | 79 @MediumTest |
| 84 @Feature({"Payments"}) | 80 @Feature({"Payments"}) |
| 85 @RetryOnFailure | |
| 86 public void testPay() throws InterruptedException, ExecutionException, Timeo
utException { | 81 public void testPay() throws InterruptedException, ExecutionException, Timeo
utException { |
| 87 triggerUIAndWait(mReadyToPay); | 82 triggerUIAndWait(mReadyToPay); |
| 88 clickAndWait(R.id.button_primary, mReadyForUnmaskInput); | 83 clickAndWait(R.id.button_primary, mReadyForUnmaskInput); |
| 89 setTextInCardUnmaskDialogAndWait(R.id.card_unmask_input, "123", mReadyTo
Unmask); | 84 setTextInCardUnmaskDialogAndWait(R.id.card_unmask_input, "123", mReadyTo
Unmask); |
| 90 clickCardUnmaskButtonAndWait(DialogInterface.BUTTON_POSITIVE, mDismissed
); | 85 clickCardUnmaskButtonAndWait(DialogInterface.BUTTON_POSITIVE, mDismissed
); |
| 91 expectResultContains(new String[] {"Jon Doe", "4111111111111111", "12",
"2050", "visa", | 86 expectResultContains(new String[] {"Jon Doe", "4111111111111111", "12",
"2050", "visa", |
| 92 "123"}); | 87 "123"}); |
| 93 } | 88 } |
| 94 | 89 |
| 95 /** Click [PAY], type in "123" into the CVC dialog, then submit the payment.
*/ | 90 /** Click [PAY], type in "123" into the CVC dialog, then submit the payment.
*/ |
| 96 @MediumTest | 91 @MediumTest |
| 97 @Feature({"Payments"}) | 92 @Feature({"Payments"}) |
| 98 @RetryOnFailure | |
| 99 public void testCancelUnmaskAndRetry() | 93 public void testCancelUnmaskAndRetry() |
| 100 throws InterruptedException, ExecutionException, TimeoutException { | 94 throws InterruptedException, ExecutionException, TimeoutException { |
| 101 triggerUIAndWait(mReadyToPay); | 95 triggerUIAndWait(mReadyToPay); |
| 102 clickAndWait(R.id.button_primary, mReadyForUnmaskInput); | 96 clickAndWait(R.id.button_primary, mReadyForUnmaskInput); |
| 103 clickCardUnmaskButtonAndWait(DialogInterface.BUTTON_NEGATIVE, mReadyToPa
y); | 97 clickCardUnmaskButtonAndWait(DialogInterface.BUTTON_NEGATIVE, mReadyToPa
y); |
| 104 clickAndWait(R.id.button_primary, mReadyForUnmaskInput); | 98 clickAndWait(R.id.button_primary, mReadyForUnmaskInput); |
| 105 setTextInCardUnmaskDialogAndWait(R.id.card_unmask_input, "123", mReadyTo
Unmask); | 99 setTextInCardUnmaskDialogAndWait(R.id.card_unmask_input, "123", mReadyTo
Unmask); |
| 106 clickCardUnmaskButtonAndWait(DialogInterface.BUTTON_POSITIVE, mDismissed
); | 100 clickCardUnmaskButtonAndWait(DialogInterface.BUTTON_POSITIVE, mDismissed
); |
| 107 expectResultContains(new String[] {"Jon Doe", "4111111111111111", "12",
"2050", "visa", | 101 expectResultContains(new String[] {"Jon Doe", "4111111111111111", "12",
"2050", "visa", |
| 108 "123"}); | 102 "123"}); |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 144 fillNewCardForm("5454-5454-5454-5454", "", DECEMBER, NEXT_YEAR, FIRST_BI
LLING_ADDRESS); | 138 fillNewCardForm("5454-5454-5454-5454", "", DECEMBER, NEXT_YEAR, FIRST_BI
LLING_ADDRESS); |
| 145 clickInCardEditorAndWait(R.id.payments_edit_done_button, mEditorValidati
onError); | 139 clickInCardEditorAndWait(R.id.payments_edit_done_button, mEditorValidati
onError); |
| 146 clickInCardEditorAndWait(R.id.payments_edit_cancel_button, mReadyForInpu
t); | 140 clickInCardEditorAndWait(R.id.payments_edit_cancel_button, mReadyForInpu
t); |
| 147 clickAndWait(R.id.close_button, mDismissed); | 141 clickAndWait(R.id.close_button, mDismissed); |
| 148 expectResultContains(new String[] {"Request cancelled"}); | 142 expectResultContains(new String[] {"Request cancelled"}); |
| 149 } | 143 } |
| 150 | 144 |
| 151 /** Save a new card on disk and pay. */ | 145 /** Save a new card on disk and pay. */ |
| 152 @MediumTest | 146 @MediumTest |
| 153 @Feature({"Payments"}) | 147 @Feature({"Payments"}) |
| 154 @RetryOnFailure | |
| 155 public void testSaveNewCardAndPay() | 148 public void testSaveNewCardAndPay() |
| 156 throws InterruptedException, ExecutionException, TimeoutException { | 149 throws InterruptedException, ExecutionException, TimeoutException { |
| 157 fillNewCardForm("5454-5454-5454-5454", "Bob", DECEMBER, NEXT_YEAR, FIRST
_BILLING_ADDRESS); | 150 fillNewCardForm("5454-5454-5454-5454", "Bob", DECEMBER, NEXT_YEAR, FIRST
_BILLING_ADDRESS); |
| 158 clickInCardEditorAndWait(R.id.payments_edit_done_button, mReadyToPay); | 151 clickInCardEditorAndWait(R.id.payments_edit_done_button, mReadyToPay); |
| 159 clickAndWait(R.id.button_primary, mReadyForUnmaskInput); | 152 clickAndWait(R.id.button_primary, mReadyForUnmaskInput); |
| 160 setTextInCardUnmaskDialogAndWait(R.id.card_unmask_input, "123", mReadyTo
Unmask); | 153 setTextInCardUnmaskDialogAndWait(R.id.card_unmask_input, "123", mReadyTo
Unmask); |
| 161 clickCardUnmaskButtonAndWait(DialogInterface.BUTTON_POSITIVE, mDismissed
); | 154 clickCardUnmaskButtonAndWait(DialogInterface.BUTTON_POSITIVE, mDismissed
); |
| 162 expectResultContains(new String[] {"5454545454545454", "12", "Bob"}); | 155 expectResultContains(new String[] {"5454545454545454", "12", "Bob"}); |
| 163 } | 156 } |
| 164 | 157 |
| 165 /** Use a temporary credit card to complete payment. */ | 158 /** Use a temporary credit card to complete payment. */ |
| 166 @MediumTest | 159 @MediumTest |
| 167 @Feature({"Payments"}) | 160 @Feature({"Payments"}) |
| 168 @RetryOnFailure | |
| 169 public void testAddTemporaryCardAndPay() | 161 public void testAddTemporaryCardAndPay() |
| 170 throws InterruptedException, ExecutionException, TimeoutException { | 162 throws InterruptedException, ExecutionException, TimeoutException { |
| 171 fillNewCardForm("5454-5454-5454-5454", "Bob", DECEMBER, NEXT_YEAR, FIRST
_BILLING_ADDRESS); | 163 fillNewCardForm("5454-5454-5454-5454", "Bob", DECEMBER, NEXT_YEAR, FIRST
_BILLING_ADDRESS); |
| 172 | 164 |
| 173 // Uncheck the "Save this card on this device" checkbox, so the card is
temporary. | 165 // Uncheck the "Save this card on this device" checkbox, so the card is
temporary. |
| 174 selectCheckboxAndWait(R.id.payments_edit_checkbox, false, mReadyToEdit); | 166 selectCheckboxAndWait(R.id.payments_edit_checkbox, false, mReadyToEdit); |
| 175 | 167 |
| 176 clickInCardEditorAndWait(R.id.payments_edit_done_button, mReadyToPay); | 168 clickInCardEditorAndWait(R.id.payments_edit_done_button, mReadyToPay); |
| 177 clickAndWait(R.id.button_primary, mReadyForUnmaskInput); | 169 clickAndWait(R.id.button_primary, mReadyForUnmaskInput); |
| 178 setTextInCardUnmaskDialogAndWait(R.id.card_unmask_input, "123", mReadyTo
Unmask); | 170 setTextInCardUnmaskDialogAndWait(R.id.card_unmask_input, "123", mReadyTo
Unmask); |
| 179 clickCardUnmaskButtonAndWait(DialogInterface.BUTTON_POSITIVE, mDismissed
); | 171 clickCardUnmaskButtonAndWait(DialogInterface.BUTTON_POSITIVE, mDismissed
); |
| 180 expectResultContains(new String[] {"5454545454545454", "12", "Bob"}); | 172 expectResultContains(new String[] {"5454545454545454", "12", "Bob"}); |
| 181 } | 173 } |
| 182 | 174 |
| 183 /** Add a new card together with a new billing address and pay. */ | 175 /** Add a new card together with a new billing address and pay. */ |
| 184 @MediumTest | 176 @MediumTest |
| 185 @Feature({"Payments"}) | 177 @Feature({"Payments"}) |
| 186 @RetryOnFailure | |
| 187 public void testSaveNewCardAndNewBillingAddressAndPay() | 178 public void testSaveNewCardAndNewBillingAddressAndPay() |
| 188 throws InterruptedException, ExecutionException, TimeoutException { | 179 throws InterruptedException, ExecutionException, TimeoutException { |
| 189 triggerUIAndWait(mReadyToPay); | 180 triggerUIAndWait(mReadyToPay); |
| 190 clickInPaymentMethodAndWait(R.id.payments_section, mReadyForInput); | 181 clickInPaymentMethodAndWait(R.id.payments_section, mReadyForInput); |
| 191 clickInPaymentMethodAndWait(R.id.payments_add_option_button, mReadyToEdi
t); | 182 clickInPaymentMethodAndWait(R.id.payments_add_option_button, mReadyToEdi
t); |
| 192 setTextInCardEditorAndWait(new String[] {"5454 5454 5454 5454", "Bob"},
mEditorTextUpdate); | 183 setTextInCardEditorAndWait(new String[] {"5454 5454 5454 5454", "Bob"},
mEditorTextUpdate); |
| 193 | 184 |
| 194 // Select December of next year for expiration and [Add address] in the
billing address | 185 // Select December of next year for expiration and [Add address] in the
billing address |
| 195 // dropdown. | 186 // dropdown. |
| 196 int december = 11; | 187 int december = 11; |
| (...skipping 10 matching lines...) Expand all Loading... |
| 207 clickAndWait(R.id.button_primary, mReadyForUnmaskInput); | 198 clickAndWait(R.id.button_primary, mReadyForUnmaskInput); |
| 208 setTextInCardUnmaskDialogAndWait(R.id.card_unmask_input, "123", mReadyTo
Unmask); | 199 setTextInCardUnmaskDialogAndWait(R.id.card_unmask_input, "123", mReadyTo
Unmask); |
| 209 clickCardUnmaskButtonAndWait(DialogInterface.BUTTON_POSITIVE, mDismissed
); | 200 clickCardUnmaskButtonAndWait(DialogInterface.BUTTON_POSITIVE, mDismissed
); |
| 210 expectResultContains(new String[] {"5454545454545454", "12", "Bob", "Goo
gle", | 201 expectResultContains(new String[] {"5454545454545454", "12", "Bob", "Goo
gle", |
| 211 "1600 Amphitheatre Pkwy", "Mountain View", "CA", "94043", "999-9
99-9999"}); | 202 "1600 Amphitheatre Pkwy", "Mountain View", "CA", "94043", "999-9
99-9999"}); |
| 212 } | 203 } |
| 213 | 204 |
| 214 /** Quickly pressing on "add card" and then [X] should not crash. */ | 205 /** Quickly pressing on "add card" and then [X] should not crash. */ |
| 215 @MediumTest | 206 @MediumTest |
| 216 @Feature({"Payments"}) | 207 @Feature({"Payments"}) |
| 217 @RetryOnFailure | |
| 218 public void testQuickAddCardAndCloseShouldNotCrash() | 208 public void testQuickAddCardAndCloseShouldNotCrash() |
| 219 throws InterruptedException, ExecutionException, TimeoutException { | 209 throws InterruptedException, ExecutionException, TimeoutException { |
| 220 triggerUIAndWait(mReadyToPay); | 210 triggerUIAndWait(mReadyToPay); |
| 221 clickInPaymentMethodAndWait(R.id.payments_section, mReadyForInput); | 211 clickInPaymentMethodAndWait(R.id.payments_section, mReadyForInput); |
| 222 | 212 |
| 223 // Quickly press on "add card" and then [X]. | 213 // Quickly press on "add card" and then [X]. |
| 224 int callCount = mReadyToEdit.getCallCount(); | 214 int callCount = mReadyToEdit.getCallCount(); |
| 225 ThreadUtils.runOnUiThreadBlocking(new Runnable() { | 215 ThreadUtils.runOnUiThreadBlocking(new Runnable() { |
| 226 @Override | 216 @Override |
| 227 public void run() { | 217 public void run() { |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 307 | 297 |
| 308 expectResultContains(new String[] {"Request cancelled"}); | 298 expectResultContains(new String[] {"Request cancelled"}); |
| 309 } | 299 } |
| 310 | 300 |
| 311 /** | 301 /** |
| 312 * Quickly dismissing the dialog (via Android's back button, for example) an
d then pressing on | 302 * Quickly dismissing the dialog (via Android's back button, for example) an
d then pressing on |
| 313 * "pay" should not crash. | 303 * "pay" should not crash. |
| 314 */ | 304 */ |
| 315 @MediumTest | 305 @MediumTest |
| 316 @Feature({"Payments"}) | 306 @Feature({"Payments"}) |
| 317 @RetryOnFailure | |
| 318 public void testQuickDismissAndPayShouldNotCrash() | 307 public void testQuickDismissAndPayShouldNotCrash() |
| 319 throws InterruptedException, ExecutionException, TimeoutException { | 308 throws InterruptedException, ExecutionException, TimeoutException { |
| 320 triggerUIAndWait(mReadyToPay); | 309 triggerUIAndWait(mReadyToPay); |
| 321 | 310 |
| 322 // Quickly dismiss and then press on "pay." | 311 // Quickly dismiss and then press on "pay." |
| 323 int callCount = mDismissed.getCallCount(); | 312 int callCount = mDismissed.getCallCount(); |
| 324 ThreadUtils.runOnUiThreadBlocking(new Runnable() { | 313 ThreadUtils.runOnUiThreadBlocking(new Runnable() { |
| 325 @Override | 314 @Override |
| 326 public void run() { | 315 public void run() { |
| 327 mUI.getDialogForTest().onBackPressed(); | 316 mUI.getDialogForTest().onBackPressed(); |
| 328 mUI.getDialogForTest().findViewById(R.id.button_primary).perform
Click(); | 317 mUI.getDialogForTest().findViewById(R.id.button_primary).perform
Click(); |
| 329 } | 318 } |
| 330 }); | 319 }); |
| 331 mDismissed.waitForCallback(callCount); | 320 mDismissed.waitForCallback(callCount); |
| 332 | 321 |
| 333 expectResultContains(new String[] {"Request cancelled"}); | 322 expectResultContains(new String[] {"Request cancelled"}); |
| 334 } | 323 } |
| 335 | 324 |
| 336 /** | 325 /** |
| 337 * Quickly dismissing the dialog (via Android's back button, for example) an
d then pressing on | 326 * Quickly dismissing the dialog (via Android's back button, for example) an
d then pressing on |
| 338 * [X] should not crash. | 327 * [X] should not crash. |
| 339 */ | 328 */ |
| 340 @MediumTest | 329 @MediumTest |
| 341 @Feature({"Payments"}) | 330 @Feature({"Payments"}) |
| 342 @RetryOnFailure | |
| 343 public void testQuickDismissAndCloseShouldNotCrash() | 331 public void testQuickDismissAndCloseShouldNotCrash() |
| 344 throws InterruptedException, ExecutionException, TimeoutException { | 332 throws InterruptedException, ExecutionException, TimeoutException { |
| 345 triggerUIAndWait(mReadyToPay); | 333 triggerUIAndWait(mReadyToPay); |
| 346 | 334 |
| 347 // Quickly dismiss and then press on [X]. | 335 // Quickly dismiss and then press on [X]. |
| 348 int callCount = mDismissed.getCallCount(); | 336 int callCount = mDismissed.getCallCount(); |
| 349 ThreadUtils.runOnUiThreadBlocking(new Runnable() { | 337 ThreadUtils.runOnUiThreadBlocking(new Runnable() { |
| 350 @Override | 338 @Override |
| 351 public void run() { | 339 public void run() { |
| 352 mUI.getDialogForTest().onBackPressed(); | 340 mUI.getDialogForTest().onBackPressed(); |
| 353 mUI.getDialogForTest().findViewById(R.id.close_button).performCl
ick(); | 341 mUI.getDialogForTest().findViewById(R.id.close_button).performCl
ick(); |
| 354 } | 342 } |
| 355 }); | 343 }); |
| 356 mDismissed.waitForCallback(callCount); | 344 mDismissed.waitForCallback(callCount); |
| 357 | 345 |
| 358 expectResultContains(new String[] {"Request cancelled"}); | 346 expectResultContains(new String[] {"Request cancelled"}); |
| 359 } | 347 } |
| 360 | 348 |
| 361 /** | 349 /** |
| 362 * Quickly pressing on [X] and then dismissing the dialog (via Android's bac
k button, for | 350 * Quickly pressing on [X] and then dismissing the dialog (via Android's bac
k button, for |
| 363 * example) should not crash. | 351 * example) should not crash. |
| 364 */ | 352 */ |
| 365 @MediumTest | 353 @MediumTest |
| 366 @Feature({"Payments"}) | 354 @Feature({"Payments"}) |
| 367 @RetryOnFailure | |
| 368 public void testQuickCloseAndDismissShouldNotCrash() | 355 public void testQuickCloseAndDismissShouldNotCrash() |
| 369 throws InterruptedException, ExecutionException, TimeoutException { | 356 throws InterruptedException, ExecutionException, TimeoutException { |
| 370 triggerUIAndWait(mReadyToPay); | 357 triggerUIAndWait(mReadyToPay); |
| 371 | 358 |
| 372 // Quickly press on [X] and then dismiss. | 359 // Quickly press on [X] and then dismiss. |
| 373 int callCount = mDismissed.getCallCount(); | 360 int callCount = mDismissed.getCallCount(); |
| 374 ThreadUtils.runOnUiThreadBlocking(new Runnable() { | 361 ThreadUtils.runOnUiThreadBlocking(new Runnable() { |
| 375 @Override | 362 @Override |
| 376 public void run() { | 363 public void run() { |
| 377 mUI.getDialogForTest().findViewById(R.id.close_button).performCl
ick(); | 364 mUI.getDialogForTest().findViewById(R.id.close_button).performCl
ick(); |
| 378 mUI.getDialogForTest().onBackPressed(); | 365 mUI.getDialogForTest().onBackPressed(); |
| 379 } | 366 } |
| 380 }); | 367 }); |
| 381 mDismissed.waitForCallback(callCount); | 368 mDismissed.waitForCallback(callCount); |
| 382 | 369 |
| 383 expectResultContains(new String[] {"Request cancelled"}); | 370 expectResultContains(new String[] {"Request cancelled"}); |
| 384 } | 371 } |
| 385 | 372 |
| 386 /** | 373 /** |
| 387 * Test that starting a payment request that requires user information excep
t for the payment | 374 * Test that starting a payment request that requires user information excep
t for the payment |
| 388 * results in the appropriate metric being logged in the PaymentRequest.Requ
estedInformation | 375 * results in the appropriate metric being logged in the PaymentRequest.Requ
estedInformation |
| 389 * histogram. | 376 * histogram. |
| 390 */ | 377 */ |
| 391 @MediumTest | 378 @MediumTest |
| 392 @Feature({"Payments"}) | 379 @Feature({"Payments"}) |
| 393 @RetryOnFailure | |
| 394 public void testRequestedInformationMetric() throws InterruptedException, Ex
ecutionException, | 380 public void testRequestedInformationMetric() throws InterruptedException, Ex
ecutionException, |
| 395 TimeoutException { | 381 TimeoutException { |
| 396 // Start the Payment Request. | 382 // Start the Payment Request. |
| 397 triggerUIAndWait(mReadyToPay); | 383 triggerUIAndWait(mReadyToPay); |
| 398 | 384 |
| 399 // Make sure that only the appropriate enum value was logged. | 385 // Make sure that only the appropriate enum value was logged. |
| 400 for (int i = 0; i < PaymentRequestMetrics.REQUESTED_INFORMATION_MAX; ++i
) { | 386 for (int i = 0; i < PaymentRequestMetrics.REQUESTED_INFORMATION_MAX; ++i
) { |
| 401 assertEquals((i == PaymentRequestMetrics.REQUESTED_INFORMATION_NONE
? 1 : 0), | 387 assertEquals((i == PaymentRequestMetrics.REQUESTED_INFORMATION_NONE
? 1 : 0), |
| 402 RecordHistogram.getHistogramValueCountForTesting( | 388 RecordHistogram.getHistogramValueCountForTesting( |
| 403 "PaymentRequest.RequestedInformation", i)); | 389 "PaymentRequest.RequestedInformation", i)); |
| 404 } | 390 } |
| 405 } | 391 } |
| 406 | 392 |
| 407 /** Verifies the format of the billing address suggestions when adding a new
credit card. */ | 393 /** Verifies the format of the billing address suggestions when adding a new
credit card. */ |
| 408 @MediumTest | 394 @MediumTest |
| 409 @Feature({"Payments"}) | 395 @Feature({"Payments"}) |
| 410 @RetryOnFailure | |
| 411 public void testNewCardBillingAddressFormat() | 396 public void testNewCardBillingAddressFormat() |
| 412 throws InterruptedException, ExecutionException, TimeoutException { | 397 throws InterruptedException, ExecutionException, TimeoutException { |
| 413 fillNewCardForm("5454-5454-5454-5454", "Bob", DECEMBER, NEXT_YEAR, FIRST
_BILLING_ADDRESS); | 398 fillNewCardForm("5454-5454-5454-5454", "Bob", DECEMBER, NEXT_YEAR, FIRST
_BILLING_ADDRESS); |
| 414 assertTrue(getSpinnerSelectionTextInCardEditor(2).equals( | 399 assertTrue(getSpinnerSelectionTextInCardEditor(2).equals( |
| 415 "Jon Doe, Google, 340 Main St, Los Angeles, CA 90291, United Sta
tes")); | 400 "Jon Doe, Google, 340 Main St, Los Angeles, CA 90291, United Sta
tes")); |
| 416 } | 401 } |
| 417 } | 402 } |
| OLD | NEW |