| 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.support.test.filters.MediumTest; | 8 import android.support.test.filters.MediumTest; |
| 9 | 9 |
| 10 import org.chromium.base.ThreadUtils; | 10 import org.chromium.base.ThreadUtils; |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 super("payment_request_free_shipping_test.html"); | 28 super("payment_request_free_shipping_test.html"); |
| 29 } | 29 } |
| 30 | 30 |
| 31 @Override | 31 @Override |
| 32 public void onMainActivityStarted() | 32 public void onMainActivityStarted() |
| 33 throws InterruptedException, ExecutionException, TimeoutException { | 33 throws InterruptedException, ExecutionException, TimeoutException { |
| 34 AutofillTestHelper helper = new AutofillTestHelper(); | 34 AutofillTestHelper helper = new AutofillTestHelper(); |
| 35 // The user has a shipping address on disk. | 35 // The user has a shipping address on disk. |
| 36 String billingAddressId = helper.setProfile(new AutofillProfile("", "htt
ps://example.com", | 36 String billingAddressId = helper.setProfile(new AutofillProfile("", "htt
ps://example.com", |
| 37 true, "Jon Doe", "Google", "340 Main St", "CA", "Los Angeles", "
", "90291", "", | 37 true, "Jon Doe", "Google", "340 Main St", "CA", "Los Angeles", "
", "90291", "", |
| 38 "US", "555-555-5555", "", "en-US")); | 38 "US", "650-253-0000", "", "en-US")); |
| 39 helper.setCreditCard(new CreditCard("", "https://example.com", true, tru
e, "Jon Doe", | 39 helper.setCreditCard(new CreditCard("", "https://example.com", true, tru
e, "Jon Doe", |
| 40 "4111111111111111", "1111", "12", "2050", "visa", R.drawable.pr_
visa, | 40 "4111111111111111", "1111", "12", "2050", "visa", R.drawable.pr_
visa, |
| 41 billingAddressId, "" /* serverId */)); | 41 billingAddressId, "" /* serverId */)); |
| 42 } | 42 } |
| 43 | 43 |
| 44 /** Submit the shipping address to the merchant when the user clicks "Pay."
*/ | 44 /** Submit the shipping address to the merchant when the user clicks "Pay."
*/ |
| 45 @MediumTest | 45 @MediumTest |
| 46 @Feature({"Payments"}) | 46 @Feature({"Payments"}) |
| 47 public void testPay() throws InterruptedException, ExecutionException, Timeo
utException { | 47 public void testPay() throws InterruptedException, ExecutionException, Timeo
utException { |
| 48 triggerUIAndWait(mReadyToPay); | 48 triggerUIAndWait(mReadyToPay); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 71 | 71 |
| 72 /** Add a valid address and complete the transaction. */ | 72 /** Add a valid address and complete the transaction. */ |
| 73 @MediumTest | 73 @MediumTest |
| 74 @Feature({"Payments"}) | 74 @Feature({"Payments"}) |
| 75 public void testAddAddressAndPay() | 75 public void testAddAddressAndPay() |
| 76 throws InterruptedException, ExecutionException, TimeoutException { | 76 throws InterruptedException, ExecutionException, TimeoutException { |
| 77 triggerUIAndWait(mReadyToPay); | 77 triggerUIAndWait(mReadyToPay); |
| 78 clickInShippingSummaryAndWait(R.id.payments_section, mReadyForInput); | 78 clickInShippingSummaryAndWait(R.id.payments_section, mReadyForInput); |
| 79 clickInShippingAddressAndWait(R.id.payments_add_option_button, mReadyToE
dit); | 79 clickInShippingAddressAndWait(R.id.payments_add_option_button, mReadyToE
dit); |
| 80 setTextInEditorAndWait(new String[] {"Bob", "Google", "1600 Amphitheatre
Pkwy", | 80 setTextInEditorAndWait(new String[] {"Bob", "Google", "1600 Amphitheatre
Pkwy", |
| 81 "Mountain View", "CA", "94043", "999-999-9999"}, mEditorTextUpda
te); | 81 "Mountain View", "CA", "94043", "650-253-0000"}, mEditorTextUpda
te); |
| 82 clickInEditorAndWait(R.id.payments_edit_done_button, mReadyToPay); | 82 clickInEditorAndWait(R.id.payments_edit_done_button, mReadyToPay); |
| 83 clickAndWait(R.id.button_primary, mReadyForUnmaskInput); | 83 clickAndWait(R.id.button_primary, mReadyForUnmaskInput); |
| 84 setTextInCardUnmaskDialogAndWait(R.id.card_unmask_input, "123", mReadyTo
Unmask); | 84 setTextInCardUnmaskDialogAndWait(R.id.card_unmask_input, "123", mReadyTo
Unmask); |
| 85 clickCardUnmaskButtonAndWait(DialogInterface.BUTTON_POSITIVE, mDismissed
); | 85 clickCardUnmaskButtonAndWait(DialogInterface.BUTTON_POSITIVE, mDismissed
); |
| 86 expectResultContains(new String[] {"Bob", "Google", "1600 Amphitheatre P
kwy", | 86 expectResultContains(new String[] {"Bob", "Google", "1600 Amphitheatre P
kwy", |
| 87 "Mountain View", "CA", "94043", "999-999-9999"}); | 87 "Mountain View", "CA", "94043", "+1 650-253-0000"}); |
| 88 } | 88 } |
| 89 | 89 |
| 90 /** Change the country in the spinner, add a valid address, and complete the
transaction. */ | 90 /** Change the country in the spinner, add a valid address, and complete the
transaction. */ |
| 91 @MediumTest | 91 @MediumTest |
| 92 @Feature({"Payments"}) | 92 @Feature({"Payments"}) |
| 93 public void testChangeCountryAddAddressAndPay() | 93 public void testChangeCountryAddAddressAndPay() |
| 94 throws InterruptedException, ExecutionException, TimeoutException { | 94 throws InterruptedException, ExecutionException, TimeoutException { |
| 95 triggerUIAndWait(mReadyToPay); | 95 triggerUIAndWait(mReadyToPay); |
| 96 clickInShippingSummaryAndWait(R.id.payments_section, mReadyForInput); | 96 clickInShippingSummaryAndWait(R.id.payments_section, mReadyForInput); |
| 97 clickInShippingAddressAndWait(R.id.payments_add_option_button, mReadyToE
dit); | 97 clickInShippingAddressAndWait(R.id.payments_add_option_button, mReadyToE
dit); |
| 98 setSpinnerSelectionInEditorAndWait(0 /* Afghanistan */, mReadyToEdit); | 98 setSpinnerSelectionInEditorAndWait(0 /* Afghanistan */, mReadyToEdit); |
| 99 setTextInEditorAndWait(new String[] {"Alice", "Supreme Court", "Airport
Road", "Kabul", | 99 setTextInEditorAndWait(new String[] {"Alice", "Supreme Court", "Airport
Road", "Kabul", |
| 100 "1043", "999-999-9999"}, mEditorTextUpdate); | 100 "1043", "650-253-0000"}, mEditorTextUpdate); |
| 101 clickInEditorAndWait(R.id.payments_edit_done_button, mReadyToPay); | 101 clickInEditorAndWait(R.id.payments_edit_done_button, mReadyToPay); |
| 102 clickAndWait(R.id.button_primary, mReadyForUnmaskInput); | 102 clickAndWait(R.id.button_primary, mReadyForUnmaskInput); |
| 103 setTextInCardUnmaskDialogAndWait(R.id.card_unmask_input, "123", mReadyTo
Unmask); | 103 setTextInCardUnmaskDialogAndWait(R.id.card_unmask_input, "123", mReadyTo
Unmask); |
| 104 clickCardUnmaskButtonAndWait(DialogInterface.BUTTON_POSITIVE, mDismissed
); | 104 clickCardUnmaskButtonAndWait(DialogInterface.BUTTON_POSITIVE, mDismissed
); |
| 105 expectResultContains(new String[] {"Alice", "Supreme Court", "Airport Ro
ad", "Kabul", | 105 expectResultContains(new String[] { |
| 106 "1043", "999-999-9999"}); | 106 "Alice", "Supreme Court", "Airport Road", "Kabul", "1043", "+1 6
50-253-0000"}); |
| 107 } | 107 } |
| 108 | 108 |
| 109 /** Quickly pressing on "add address" and then [X] should not crash. */ | 109 /** Quickly pressing on "add address" and then [X] should not crash. */ |
| 110 @MediumTest | 110 @MediumTest |
| 111 @Feature({"Payments"}) | 111 @Feature({"Payments"}) |
| 112 public void testQuickAddAddressAndCloseShouldNotCrash() | 112 public void testQuickAddAddressAndCloseShouldNotCrash() |
| 113 throws InterruptedException, ExecutionException, TimeoutException { | 113 throws InterruptedException, ExecutionException, TimeoutException { |
| 114 triggerUIAndWait(mReadyToPay); | 114 triggerUIAndWait(mReadyToPay); |
| 115 clickInShippingSummaryAndWait(R.id.payments_section, mReadyForInput); | 115 clickInShippingSummaryAndWait(R.id.payments_section, mReadyForInput); |
| 116 | 116 |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 215 triggerUIAndWait(mReadyToPay); | 215 triggerUIAndWait(mReadyToPay); |
| 216 | 216 |
| 217 // Make sure that only the appropriate enum value was logged. | 217 // Make sure that only the appropriate enum value was logged. |
| 218 for (int i = 0; i < PaymentRequestMetrics.REQUESTED_INFORMATION_MAX; ++i
) { | 218 for (int i = 0; i < PaymentRequestMetrics.REQUESTED_INFORMATION_MAX; ++i
) { |
| 219 assertEquals((i == PaymentRequestMetrics.REQUESTED_INFORMATION_SHIPP
ING ? 1 : 0), | 219 assertEquals((i == PaymentRequestMetrics.REQUESTED_INFORMATION_SHIPP
ING ? 1 : 0), |
| 220 RecordHistogram.getHistogramValueCountForTesting( | 220 RecordHistogram.getHistogramValueCountForTesting( |
| 221 "PaymentRequest.RequestedInformation", i)); | 221 "PaymentRequest.RequestedInformation", i)); |
| 222 } | 222 } |
| 223 } | 223 } |
| 224 } | 224 } |
| OLD | NEW |