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

Unified Diff: chrome/android/javatests/src/org/chromium/chrome/browser/payments/PaymentRequestTestBase.java

Issue 2163693002: [Merge M-53] Credit card editor for PaymentRequest UI. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2785
Patch Set: Created 4 years, 5 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 side-by-side diff with in-line comments
Download patch
Index: chrome/android/javatests/src/org/chromium/chrome/browser/payments/PaymentRequestTestBase.java
diff --git a/chrome/android/javatests/src/org/chromium/chrome/browser/payments/PaymentRequestTestBase.java b/chrome/android/javatests/src/org/chromium/chrome/browser/payments/PaymentRequestTestBase.java
index 2444005c8c58698092987572a9b3c28ccaeb72b5..af9daa4d794beae660557c2512dfa9b34cff5f6f 100644
--- a/chrome/android/javatests/src/org/chromium/chrome/browser/payments/PaymentRequestTestBase.java
+++ b/chrome/android/javatests/src/org/chromium/chrome/browser/payments/PaymentRequestTestBase.java
@@ -4,6 +4,9 @@
package org.chromium.chrome.browser.payments;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.Spinner;
import android.widget.TextView;
@@ -54,6 +57,7 @@ abstract class PaymentRequestTestBase extends ChromeActivityTestCaseBase<ChromeA
protected final CallbackHelper mEditorDismissed;
protected final CallbackHelper mDismissed;
protected final CallbackHelper mUnableToAbort;
+ protected final CallbackHelper mBillingAddressChangeProcessed;
private final AtomicReference<ContentViewCore> mViewCoreRef;
private final AtomicReference<WebContents> mWebContentsRef;
private final String mTestFilePath;
@@ -74,6 +78,7 @@ abstract class PaymentRequestTestBase extends ChromeActivityTestCaseBase<ChromeA
mEditorDismissed = new CallbackHelper();
mDismissed = new CallbackHelper();
mUnableToAbort = new CallbackHelper();
+ mBillingAddressChangeProcessed = new CallbackHelper();
mViewCoreRef = new AtomicReference<>();
mWebContentsRef = new AtomicReference<>();
mTestFilePath = UrlUtils.getIsolatedTestFilePath(
@@ -156,6 +161,19 @@ abstract class PaymentRequestTestBase extends ChromeActivityTestCaseBase<ChromeA
helper.waitForCallback(callCount);
}
+ /** Clicks on an element in the "Payment" section of the payments UI. */
+ protected void clickInPaymentMethodAndWait(final int resourceId, CallbackHelper helper)
+ throws InterruptedException, TimeoutException {
+ int callCount = helper.getCallCount();
+ ThreadUtils.runOnUiThreadBlocking(new Runnable() {
+ @Override
+ public void run() {
+ mUI.getPaymentMethodSectionForTest().findViewById(resourceId).performClick();
+ }
+ });
+ helper.waitForCallback(callCount);
+ }
+
/** Clicks on an element in the "Contact Info" section of the payments UI. */
protected void clickInContactInfoAndWait(final int resourceId, CallbackHelper helper)
throws InterruptedException, TimeoutException {
@@ -169,6 +187,19 @@ abstract class PaymentRequestTestBase extends ChromeActivityTestCaseBase<ChromeA
helper.waitForCallback(callCount);
}
+ /** Clicks on an element in the editor UI for credit cards. */
+ protected void clickInCardEditorAndWait(final int resourceId, CallbackHelper helper)
+ throws InterruptedException, TimeoutException {
+ int callCount = helper.getCallCount();
+ ThreadUtils.runOnUiThreadBlocking(new Runnable() {
+ @Override
+ public void run() {
+ mUI.getCardEditorView().findViewById(resourceId).performClick();
+ }
+ });
+ helper.waitForCallback(callCount);
+ }
+
/** Clicks on an element in the editor UI. */
protected void clickInEditorAndWait(final int resourceId, CallbackHelper helper)
throws InterruptedException, TimeoutException {
@@ -266,8 +297,24 @@ abstract class PaymentRequestTestBase extends ChromeActivityTestCaseBase<ChromeA
});
}
+ /** Selects the spinner value in the editor UI for credit cards. */
+ protected void setSpinnerSelectionsInCardEditorAndWait(final int[] selections,
+ CallbackHelper helper) throws InterruptedException, TimeoutException {
+ int callCount = helper.getCallCount();
+ ThreadUtils.runOnUiThreadBlocking(new Runnable() {
+ @Override
+ public void run() {
+ List<Spinner> fields = mUI.getCardEditorView().getDropdownFieldsForTest();
+ for (int i = 0; i < selections.length && i < fields.size(); i++) {
+ fields.get(i).setSelection(selections[i]);
+ }
+ }
+ });
+ helper.waitForCallback(callCount);
+ }
+
/** Selects the spinner value in the editor UI. */
- protected void setSpinnerSelectionInEditor(final int selection, CallbackHelper helper)
+ protected void setSpinnerSelectionInEditorAndWait(final int selection, CallbackHelper helper)
throws InterruptedException, TimeoutException {
int callCount = helper.getCallCount();
ThreadUtils.runOnUiThreadBlocking(new Runnable() {
@@ -279,6 +326,27 @@ abstract class PaymentRequestTestBase extends ChromeActivityTestCaseBase<ChromeA
helper.waitForCallback(callCount);
}
+ /** Directly sets the text in the editor UI for credit cards. */
+ protected void setTextInCardEditorAndWait(final String[] values, CallbackHelper helper)
+ throws InterruptedException, TimeoutException {
+ int callCount = helper.getCallCount();
+ ThreadUtils.runOnUiThreadBlocking(new Runnable() {
+ @Override
+ public void run() {
+ ViewGroup contents = (ViewGroup)
+ mUI.getCardEditorView().findViewById(R.id.contents);
+ assertNotNull(contents);
+ for (int i = 0, j = 0; i < contents.getChildCount() && j < values.length; i++) {
+ View view = contents.getChildAt(i);
+ if (view instanceof EditorTextField) {
+ ((EditorTextField) view).getEditText().setText(values[j++]);
+ }
+ }
+ }
+ });
+ helper.waitForCallback(callCount);
+ }
+
/** Directly sets the text in the editor UI. */
protected void setTextInEditorAndWait(final String[] values, CallbackHelper helper)
throws InterruptedException, TimeoutException {
@@ -286,15 +354,28 @@ abstract class PaymentRequestTestBase extends ChromeActivityTestCaseBase<ChromeA
ThreadUtils.runOnUiThreadBlocking(new Runnable() {
@Override
public void run() {
- List<EditorTextField> fields = mUI.getEditorView().getEditorTextFields();
+ List<EditText> fields = mUI.getEditorView().getEditableTextFieldsForTest();
for (int i = 0; i < values.length; i++) {
- fields.get(i).getEditText().setText(values[i]);
+ fields.get(i).setText(values[i]);
}
}
});
helper.waitForCallback(callCount);
}
+ /** Directly sets the checkbox selection in the editor UI for credit cards. */
+ protected void selectCheckboxAndWait(final int resourceId, final boolean isChecked,
+ CallbackHelper helper) throws InterruptedException, TimeoutException {
+ int callCount = helper.getCallCount();
+ ThreadUtils.runOnUiThreadBlocking(new Runnable() {
+ @Override
+ public void run() {
+ ((CheckBox) mUI.getCardEditorView().findViewById(resourceId)).setChecked(isChecked);
+ }
+ });
+ helper.waitForCallback(callCount);
+ }
+
/** Directly sets the text in the card unmask UI. */
protected void setTextInCardUnmaskDialogAndWait(final int resourceId, final String input,
CallbackHelper helper) throws InterruptedException, TimeoutException {
@@ -400,6 +481,12 @@ abstract class PaymentRequestTestBase extends ChromeActivityTestCaseBase<ChromeA
}
@Override
+ public void onPaymentRequestServiceBillingAddressChangeProcessed() {
+ ThreadUtils.assertOnUiThread();
+ mBillingAddressChangeProcessed.notifyCalled();
+ }
+
+ @Override
public void onCardUnmaskPromptReadyForInput(CardUnmaskPrompt prompt) {
ThreadUtils.assertOnUiThread();
mReadyForUnmaskInput.notifyCalled(prompt);

Powered by Google App Engine
This is Rietveld 408576698