Commit dc54ae55 authored by Yoland Yan's avatar Yoland Yan Committed by Commit Bot

Convert the rest of Payment tests to JUnit4

For more on JUnit4 migration, please check
src/testing/android/docs/junit4.md

Bug: 640116
Change-Id: I0270db03b98377e50bcbd45ccbc972fe28e4c918
Reviewed-on: https://chromium-review.googlesource.com/699794
Commit-Queue: Yoland Yan <yolandyan@chromium.org>
Reviewed-by: default avatarRouslan Solomakhin <rouslan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#506812}
parent da4ce848
...@@ -1650,7 +1650,6 @@ chrome_test_java_sources = [ ...@@ -1650,7 +1650,6 @@ chrome_test_java_sources = [
"javatests/src/org/chromium/chrome/browser/payments/PaymentRequestShippingAddressChangeTest.java", "javatests/src/org/chromium/chrome/browser/payments/PaymentRequestShippingAddressChangeTest.java",
"javatests/src/org/chromium/chrome/browser/payments/PaymentRequestShowTwiceTest.java", "javatests/src/org/chromium/chrome/browser/payments/PaymentRequestShowTwiceTest.java",
"javatests/src/org/chromium/chrome/browser/payments/PaymentRequestTabTest.java", "javatests/src/org/chromium/chrome/browser/payments/PaymentRequestTabTest.java",
"javatests/src/org/chromium/chrome/browser/payments/PaymentRequestTestBase.java",
"javatests/src/org/chromium/chrome/browser/payments/PaymentRequestTestCommon.java", "javatests/src/org/chromium/chrome/browser/payments/PaymentRequestTestCommon.java",
"javatests/src/org/chromium/chrome/browser/payments/PaymentRequestTestRule.java", "javatests/src/org/chromium/chrome/browser/payments/PaymentRequestTestRule.java",
"javatests/src/org/chromium/chrome/browser/payments/PaymentRequestUseStatsTest.java", "javatests/src/org/chromium/chrome/browser/payments/PaymentRequestUseStatsTest.java",
......
...@@ -6,11 +6,21 @@ package org.chromium.chrome.browser.payments; ...@@ -6,11 +6,21 @@ package org.chromium.chrome.browser.payments;
import android.support.test.filters.MediumTest; import android.support.test.filters.MediumTest;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.chromium.base.test.util.CommandLineFlags;
import org.chromium.base.test.util.Feature; import org.chromium.base.test.util.Feature;
import org.chromium.chrome.R; import org.chromium.chrome.R;
import org.chromium.chrome.browser.ChromeSwitches;
import org.chromium.chrome.browser.autofill.AutofillTestHelper; import org.chromium.chrome.browser.autofill.AutofillTestHelper;
import org.chromium.chrome.browser.autofill.CardType; import org.chromium.chrome.browser.autofill.CardType;
import org.chromium.chrome.browser.autofill.PersonalDataManager.CreditCard; import org.chromium.chrome.browser.autofill.PersonalDataManager.CreditCard;
import org.chromium.chrome.browser.payments.PaymentRequestTestRule.MainActivityStartCallback;
import org.chromium.chrome.test.ChromeActivityTestRule;
import org.chromium.chrome.test.ChromeJUnit4ClassRunner;
import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeoutException; import java.util.concurrent.TimeoutException;
...@@ -19,9 +29,18 @@ import java.util.concurrent.TimeoutException; ...@@ -19,9 +29,18 @@ import java.util.concurrent.TimeoutException;
* A payment integration test for checking whether user can make a payment via a credit card. This * A payment integration test for checking whether user can make a payment via a credit card. This
* user has a valid credit card without a billing address on file. * user has a valid credit card without a billing address on file.
*/ */
public class PaymentRequestCcCanMakePaymentQueryTest extends PaymentRequestTestBase { @RunWith(ChromeJUnit4ClassRunner.class)
public PaymentRequestCcCanMakePaymentQueryTest() { @CommandLineFlags.Add({
super("payment_request_can_make_payment_query_cc_test.html"); ChromeSwitches.DISABLE_FIRST_RUN_EXPERIENCE,
ChromeActivityTestRule.DISABLE_NETWORK_PREDICTION_FLAG,
})
public class PaymentRequestCcCanMakePaymentQueryTest implements MainActivityStartCallback {
@Rule
public PaymentRequestTestRule mPaymentRequestTestRule =
new PaymentRequestTestRule("payment_request_can_make_payment_query_cc_test.html", this);
@Before
public void setUp() {
PaymentRequestImpl.setIsLocalCanMakePaymentQueryQuotaEnforcedForTest(); PaymentRequestImpl.setIsLocalCanMakePaymentQueryQuotaEnforcedForTest();
} }
...@@ -35,26 +54,33 @@ public class PaymentRequestCcCanMakePaymentQueryTest extends PaymentRequestTestB ...@@ -35,26 +54,33 @@ public class PaymentRequestCcCanMakePaymentQueryTest extends PaymentRequestTestB
CardType.UNKNOWN, "" /* billingAddressId */, "" /* serverId */)); CardType.UNKNOWN, "" /* billingAddressId */, "" /* serverId */));
} }
@Test
@MediumTest @MediumTest
@Feature({"Payments"}) @Feature({"Payments"})
public void testCanMakePayment() throws InterruptedException, ExecutionException, public void testCanMakePayment()
TimeoutException { throws InterruptedException, ExecutionException, TimeoutException {
openPageAndClickBuyAndWait(getCanMakePaymentQueryResponded()); mPaymentRequestTestRule.openPageAndClickBuyAndWait(
expectResultContains(new String[]{"true"}); mPaymentRequestTestRule.getCanMakePaymentQueryResponded());
mPaymentRequestTestRule.expectResultContains(new String[] {"true"});
// Repeating a query does not count against the quota. // Repeating a query does not count against the quota.
clickNodeAndWait("buy", getCanMakePaymentQueryResponded()); mPaymentRequestTestRule.clickNodeAndWait(
expectResultContains(new String[]{"true"}); "buy", mPaymentRequestTestRule.getCanMakePaymentQueryResponded());
mPaymentRequestTestRule.expectResultContains(new String[] {"true"});
clickNodeAndWait("buy", getCanMakePaymentQueryResponded()); mPaymentRequestTestRule.clickNodeAndWait(
expectResultContains(new String[]{"true"}); "buy", mPaymentRequestTestRule.getCanMakePaymentQueryResponded());
mPaymentRequestTestRule.expectResultContains(new String[] {"true"});
// Different queries are throttled for a period of time. // Different queries are throttled for a period of time.
clickNodeAndWait("other-buy", getCanMakePaymentQueryResponded()); mPaymentRequestTestRule.clickNodeAndWait(
expectResultContains(new String[] {"Not allowed to check whether can make payment"}); "other-buy", mPaymentRequestTestRule.getCanMakePaymentQueryResponded());
mPaymentRequestTestRule.expectResultContains(
new String[] {"Not allowed to check whether can make payment"});
// Repeating the same query again does not count against the quota. // Repeating the same query again does not count against the quota.
clickNodeAndWait("buy", getCanMakePaymentQueryResponded()); mPaymentRequestTestRule.clickNodeAndWait(
expectResultContains(new String[]{"true"}); "buy", mPaymentRequestTestRule.getCanMakePaymentQueryResponded());
mPaymentRequestTestRule.expectResultContains(new String[] {"true"});
} }
} }
...@@ -6,15 +6,30 @@ package org.chromium.chrome.browser.payments; ...@@ -6,15 +6,30 @@ package org.chromium.chrome.browser.payments;
import android.support.test.filters.MediumTest; import android.support.test.filters.MediumTest;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.chromium.base.test.util.CommandLineFlags;
import org.chromium.base.test.util.Feature; import org.chromium.base.test.util.Feature;
import org.chromium.chrome.browser.ChromeSwitches;
import org.chromium.chrome.browser.payments.PaymentRequestTestRule.MainActivityStartCallback;
import org.chromium.chrome.test.ChromeActivityTestRule;
import org.chromium.chrome.test.ChromeJUnit4ClassRunner;
import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeoutException; import java.util.concurrent.TimeoutException;
/** Web payments test for data URL. */ /** Web payments test for data URL. */
public class PaymentRequestDataUrlTest extends PaymentRequestTestBase { @RunWith(ChromeJUnit4ClassRunner.class)
public PaymentRequestDataUrlTest() { @CommandLineFlags.Add({
super("data:text/html,<html><head>" ChromeSwitches.DISABLE_FIRST_RUN_EXPERIENCE,
ChromeActivityTestRule.DISABLE_NETWORK_PREDICTION_FLAG,
})
public class PaymentRequestDataUrlTest implements MainActivityStartCallback {
@Rule
public PaymentRequestTestRule mPaymentRequestTestRule = new PaymentRequestTestRule(
"data:text/html,<html><head>"
+ "<meta name=\"viewport\" content=\"width=device-width, initial-scale=1, " + "<meta name=\"viewport\" content=\"width=device-width, initial-scale=1, "
+ "maximum-scale=1\"></head><body><button id=\"buy\" onclick=\"try { " + "maximum-scale=1\"></head><body><button id=\"buy\" onclick=\"try { "
+ "(new PaymentRequest([{supportedMethods: ['basic-card']}], " + "(new PaymentRequest([{supportedMethods: ['basic-card']}], "
...@@ -22,18 +37,20 @@ public class PaymentRequestDataUrlTest extends PaymentRequestTestBase { ...@@ -22,18 +37,20 @@ public class PaymentRequestDataUrlTest extends PaymentRequestTestBase {
+ " amount: {currency: 'USD', value: '1.00'}}})).show(); " + " amount: {currency: 'USD', value: '1.00'}}})).show(); "
+ "} catch(e) { " + "} catch(e) { "
+ "document.getElementById('result').innerHTML = e; " + "document.getElementById('result').innerHTML = e; "
+ "}\">Data URL Test</button><div id='result'></div></body></html>"); + "}\">Data URL Test</button><div id='result'></div></body></html>",
} this);
@Override @Override
public void onMainActivityStarted() public void onMainActivityStarted()
throws InterruptedException, ExecutionException, TimeoutException {} throws InterruptedException, ExecutionException, TimeoutException {}
@Test
@MediumTest @MediumTest
@Feature({"Payments"}) @Feature({"Payments"})
public void test() throws InterruptedException, ExecutionException, TimeoutException { public void test() throws InterruptedException, ExecutionException, TimeoutException {
openPageAndClickNode("buy"); mPaymentRequestTestRule.openPageAndClickNode("buy");
expectResultContains(new String[] {"SecurityError: Failed to construct 'PaymentRequest': " mPaymentRequestTestRule.expectResultContains(
new String[] {"SecurityError: Failed to construct 'PaymentRequest': "
+ "Must be in a secure context"}); + "Must be in a secure context"});
} }
} }
...@@ -4,9 +4,24 @@ ...@@ -4,9 +4,24 @@
package org.chromium.chrome.browser.payments; package org.chromium.chrome.browser.payments;
import static org.chromium.chrome.browser.payments.PaymentRequestTestRule.DELAYED_RESPONSE;
import static org.chromium.chrome.browser.payments.PaymentRequestTestRule.HAVE_INSTRUMENTS;
import static org.chromium.chrome.browser.payments.PaymentRequestTestRule.IMMEDIATE_RESPONSE;
import static org.chromium.chrome.browser.payments.PaymentRequestTestRule.NO_INSTRUMENTS;
import android.support.test.filters.MediumTest; import android.support.test.filters.MediumTest;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.chromium.base.test.util.CommandLineFlags;
import org.chromium.base.test.util.Feature; import org.chromium.base.test.util.Feature;
import org.chromium.chrome.browser.ChromeSwitches;
import org.chromium.chrome.browser.payments.PaymentRequestTestRule.MainActivityStartCallback;
import org.chromium.chrome.test.ChromeActivityTestRule;
import org.chromium.chrome.test.ChromeJUnit4ClassRunner;
import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeoutException; import java.util.concurrent.TimeoutException;
...@@ -14,85 +29,114 @@ import java.util.concurrent.TimeoutException; ...@@ -14,85 +29,114 @@ import java.util.concurrent.TimeoutException;
/** /**
* A payment integration test for checking whether user can make a payment using a payment app. * A payment integration test for checking whether user can make a payment using a payment app.
*/ */
public class PaymentRequestPaymentAppCanMakePaymentQueryTest extends PaymentRequestTestBase { @RunWith(ChromeJUnit4ClassRunner.class)
public PaymentRequestPaymentAppCanMakePaymentQueryTest() { @CommandLineFlags.Add({
super("payment_request_can_make_payment_query_bobpay_test.html"); ChromeSwitches.DISABLE_FIRST_RUN_EXPERIENCE,
PaymentRequestImpl.setIsLocalCanMakePaymentQueryQuotaEnforcedForTest(); ChromeActivityTestRule.DISABLE_NETWORK_PREDICTION_FLAG,
} })
public class PaymentRequestPaymentAppCanMakePaymentQueryTest implements MainActivityStartCallback {
@Rule
public PaymentRequestTestRule mPaymentRequestTestRule = new PaymentRequestTestRule(
"payment_request_can_make_payment_query_bobpay_test.html", this);
@Override @Override
public void onMainActivityStarted() throws InterruptedException, ExecutionException, public void onMainActivityStarted() throws InterruptedException, ExecutionException,
TimeoutException {} TimeoutException {}
@Before
public void setUp() {
PaymentRequestImpl.setIsLocalCanMakePaymentQueryQuotaEnforcedForTest();
}
@Test
@MediumTest @MediumTest
@Feature({"Payments"}) @Feature({"Payments"})
public void testNoBobPayInstalled() throws InterruptedException, ExecutionException, public void testNoBobPayInstalled()
TimeoutException { throws InterruptedException, ExecutionException, TimeoutException {
openPageAndClickBuyAndWait(getCanMakePaymentQueryResponded()); mPaymentRequestTestRule.openPageAndClickBuyAndWait(
expectResultContains(new String[] {"false, false"}); mPaymentRequestTestRule.getCanMakePaymentQueryResponded());
mPaymentRequestTestRule.expectResultContains(new String[] {"false, false"});
clickNodeAndWait("otherBuy", getCanMakePaymentQueryResponded()); mPaymentRequestTestRule.clickNodeAndWait(
expectResultContains(new String[] {"false, NotAllowedError"}); "otherBuy", mPaymentRequestTestRule.getCanMakePaymentQueryResponded());
mPaymentRequestTestRule.expectResultContains(new String[] {"false, NotAllowedError"});
} }
@Test
@MediumTest @MediumTest
@Feature({"Payments"}) @Feature({"Payments"})
public void testBobPayInstalledLater() public void testBobPayInstalledLater()
throws InterruptedException, ExecutionException, TimeoutException { throws InterruptedException, ExecutionException, TimeoutException {
openPageAndClickBuyAndWait(getCanMakePaymentQueryResponded()); mPaymentRequestTestRule.openPageAndClickBuyAndWait(
expectResultContains(new String[] {"false, false"}); mPaymentRequestTestRule.getCanMakePaymentQueryResponded());
mPaymentRequestTestRule.expectResultContains(new String[] {"false, false"});
installPaymentApp(HAVE_INSTRUMENTS, IMMEDIATE_RESPONSE); mPaymentRequestTestRule.installPaymentApp(HAVE_INSTRUMENTS, IMMEDIATE_RESPONSE);
clickNodeAndWait("otherBuy", getCanMakePaymentQueryResponded()); Thread.sleep(10000);
expectResultContains(new String[] {"true, NotAllowedError"}); mPaymentRequestTestRule.clickNodeAndWait(
"otherBuy", mPaymentRequestTestRule.getCanMakePaymentQueryResponded());
Thread.sleep(10000);
mPaymentRequestTestRule.expectResultContains(new String[] {"true, NotAllowedError"});
} }
@Test
@MediumTest @MediumTest
@Feature({"Payments"}) @Feature({"Payments"})
public void testNoInstrumentsInFastBobPay() throws InterruptedException, ExecutionException, public void testNoInstrumentsInFastBobPay()
TimeoutException { throws InterruptedException, ExecutionException, TimeoutException {
installPaymentApp(NO_INSTRUMENTS, IMMEDIATE_RESPONSE); mPaymentRequestTestRule.installPaymentApp(NO_INSTRUMENTS, IMMEDIATE_RESPONSE);
openPageAndClickBuyAndWait(getCanMakePaymentQueryResponded()); mPaymentRequestTestRule.openPageAndClickBuyAndWait(
expectResultContains(new String[] {"false, false"}); mPaymentRequestTestRule.getCanMakePaymentQueryResponded());
mPaymentRequestTestRule.expectResultContains(new String[] {"false, false"});
clickNodeAndWait("otherBuy", getCanMakePaymentQueryResponded());
expectResultContains(new String[] {"false, NotAllowedError"}); mPaymentRequestTestRule.clickNodeAndWait(
"otherBuy", mPaymentRequestTestRule.getCanMakePaymentQueryResponded());
mPaymentRequestTestRule.expectResultContains(new String[] {"false, NotAllowedError"});
} }
@Test
@MediumTest @MediumTest
@Feature({"Payments"}) @Feature({"Payments"})
public void testNoInstrumentsInSlowBobPay() throws InterruptedException, ExecutionException, public void testNoInstrumentsInSlowBobPay()
TimeoutException { throws InterruptedException, ExecutionException, TimeoutException {
installPaymentApp(NO_INSTRUMENTS, DELAYED_RESPONSE); mPaymentRequestTestRule.installPaymentApp(NO_INSTRUMENTS, DELAYED_RESPONSE);
openPageAndClickBuyAndWait(getCanMakePaymentQueryResponded()); mPaymentRequestTestRule.openPageAndClickBuyAndWait(
expectResultContains(new String[] {"false, false"}); mPaymentRequestTestRule.getCanMakePaymentQueryResponded());
mPaymentRequestTestRule.expectResultContains(new String[] {"false, false"});
clickNodeAndWait("otherBuy", getCanMakePaymentQueryResponded());
expectResultContains(new String[] {"false, NotAllowedError"}); mPaymentRequestTestRule.clickNodeAndWait(
"otherBuy", mPaymentRequestTestRule.getCanMakePaymentQueryResponded());
mPaymentRequestTestRule.expectResultContains(new String[] {"false, NotAllowedError"});
} }
@Test
@MediumTest @MediumTest
@Feature({"Payments"}) @Feature({"Payments"})
public void testPayViaFastBobPay() throws InterruptedException, ExecutionException, public void testPayViaFastBobPay()
TimeoutException { throws InterruptedException, ExecutionException, TimeoutException {
installPaymentApp(HAVE_INSTRUMENTS, IMMEDIATE_RESPONSE); mPaymentRequestTestRule.installPaymentApp(HAVE_INSTRUMENTS, IMMEDIATE_RESPONSE);
openPageAndClickBuyAndWait(getCanMakePaymentQueryResponded()); mPaymentRequestTestRule.openPageAndClickBuyAndWait(
expectResultContains(new String[] {"true, true"}); mPaymentRequestTestRule.getCanMakePaymentQueryResponded());
mPaymentRequestTestRule.expectResultContains(new String[] {"true, true"});
clickNodeAndWait("otherBuy", getCanMakePaymentQueryResponded());
expectResultContains(new String[] {"true, NotAllowedError"}); mPaymentRequestTestRule.clickNodeAndWait(
"otherBuy", mPaymentRequestTestRule.getCanMakePaymentQueryResponded());
mPaymentRequestTestRule.expectResultContains(new String[] {"true, NotAllowedError"});
} }
@Test
@MediumTest @MediumTest
@Feature({"Payments"}) @Feature({"Payments"})
public void testPayViaSlowBobPay() throws InterruptedException, ExecutionException, public void testPayViaSlowBobPay()
TimeoutException { throws InterruptedException, ExecutionException, TimeoutException {
installPaymentApp(HAVE_INSTRUMENTS, DELAYED_RESPONSE); mPaymentRequestTestRule.installPaymentApp(HAVE_INSTRUMENTS, DELAYED_RESPONSE);
openPageAndClickBuyAndWait(getCanMakePaymentQueryResponded()); mPaymentRequestTestRule.openPageAndClickBuyAndWait(
expectResultContains(new String[] {"true, true"}); mPaymentRequestTestRule.getCanMakePaymentQueryResponded());
mPaymentRequestTestRule.expectResultContains(new String[] {"true, true"});
clickNodeAndWait("otherBuy", getCanMakePaymentQueryResponded());
expectResultContains(new String[] {"true, NotAllowedError"}); mPaymentRequestTestRule.clickNodeAndWait(
"otherBuy", mPaymentRequestTestRule.getCanMakePaymentQueryResponded());
mPaymentRequestTestRule.expectResultContains(new String[] {"true, NotAllowedError"});
} }
} }
...@@ -4,15 +4,29 @@ ...@@ -4,15 +4,29 @@
package org.chromium.chrome.browser.payments; package org.chromium.chrome.browser.payments;
import static org.chromium.chrome.browser.payments.PaymentRequestTestRule.DECEMBER;
import static org.chromium.chrome.browser.payments.PaymentRequestTestRule.FIRST_BILLING_ADDRESS;
import static org.chromium.chrome.browser.payments.PaymentRequestTestRule.NEXT_YEAR;
import android.content.DialogInterface; import android.content.DialogInterface;
import android.support.test.filters.MediumTest; import android.support.test.filters.MediumTest;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.chromium.base.test.util.CommandLineFlags;
import org.chromium.base.test.util.Feature; import org.chromium.base.test.util.Feature;
import org.chromium.chrome.R; import org.chromium.chrome.R;
import org.chromium.chrome.browser.ChromeSwitches;
import org.chromium.chrome.browser.autofill.AutofillTestHelper; import org.chromium.chrome.browser.autofill.AutofillTestHelper;
import org.chromium.chrome.browser.autofill.CardType; import org.chromium.chrome.browser.autofill.CardType;
import org.chromium.chrome.browser.autofill.PersonalDataManager.AutofillProfile; import org.chromium.chrome.browser.autofill.PersonalDataManager.AutofillProfile;
import org.chromium.chrome.browser.autofill.PersonalDataManager.CreditCard; import org.chromium.chrome.browser.autofill.PersonalDataManager.CreditCard;
import org.chromium.chrome.browser.payments.PaymentRequestTestRule.MainActivityStartCallback;
import org.chromium.chrome.test.ChromeActivityTestRule;
import org.chromium.chrome.test.ChromeJUnit4ClassRunner;
import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeoutException; import java.util.concurrent.TimeoutException;
...@@ -20,9 +34,18 @@ import java.util.concurrent.TimeoutException; ...@@ -20,9 +34,18 @@ import java.util.concurrent.TimeoutException;
/** /**
* A payment integration test for supported payment methods. * A payment integration test for supported payment methods.
*/ */
public class PaymentRequestPaymentMethodIdentifierTest extends PaymentRequestTestBase { @RunWith(ChromeJUnit4ClassRunner.class)
public PaymentRequestPaymentMethodIdentifierTest() { @CommandLineFlags.Add({
super("payment_request_payment_method_identifier_test.html"); ChromeSwitches.DISABLE_FIRST_RUN_EXPERIENCE,
ChromeActivityTestRule.DISABLE_NETWORK_PREDICTION_FLAG,
})
public class PaymentRequestPaymentMethodIdentifierTest implements MainActivityStartCallback {
@Rule
public PaymentRequestTestRule mPaymentRequestTestRule =
new PaymentRequestTestRule("payment_request_payment_method_identifier_test.html", this);
@Before
public void setUp() {
PaymentRequestImpl.setIsLocalCanMakePaymentQueryQuotaEnforcedForTest(); PaymentRequestImpl.setIsLocalCanMakePaymentQueryQuotaEnforcedForTest();
} }
...@@ -39,62 +62,81 @@ public class PaymentRequestPaymentMethodIdentifierTest extends PaymentRequestTes ...@@ -39,62 +62,81 @@ public class PaymentRequestPaymentMethodIdentifierTest extends PaymentRequestTes
CardType.UNKNOWN, billingAddressId, "" /* serverId */)); CardType.UNKNOWN, billingAddressId, "" /* serverId */));
} }
@Test
@MediumTest @MediumTest
@Feature({"Payments"}) @Feature({"Payments"})
public void testCanPayWithBasicCard() throws InterruptedException, public void testCanPayWithBasicCard()
ExecutionException, TimeoutException { throws InterruptedException, ExecutionException, TimeoutException {
openPageAndClickNodeAndWait("checkBasicCard", getCanMakePaymentQueryResponded()); mPaymentRequestTestRule.openPageAndClickNodeAndWait(
expectResultContains(new String[] {"true"}); "checkBasicCard", mPaymentRequestTestRule.getCanMakePaymentQueryResponded());
mPaymentRequestTestRule.expectResultContains(new String[] {"true"});
clickNodeAndWait("buyBasicCard", getReadyForInput()); mPaymentRequestTestRule.clickNodeAndWait(
"buyBasicCard", mPaymentRequestTestRule.getReadyForInput());
} }
@Test
@MediumTest @MediumTest
@Feature({"Payments"}) @Feature({"Payments"})
public void testIgnoreCardType() throws InterruptedException, public void testIgnoreCardType()
ExecutionException, TimeoutException { throws InterruptedException, ExecutionException, TimeoutException {
openPageAndClickNodeAndWait("checkBasicDebit", getCanMakePaymentQueryResponded()); mPaymentRequestTestRule.openPageAndClickNodeAndWait(
expectResultContains(new String[] {"true"}); "checkBasicDebit", mPaymentRequestTestRule.getCanMakePaymentQueryResponded());
mPaymentRequestTestRule.expectResultContains(new String[] {"true"});
clickNodeAndWait("buyBasicDebit", getReadyForInput()); mPaymentRequestTestRule.clickNodeAndWait(
"buyBasicDebit", mPaymentRequestTestRule.getReadyForInput());
} }
@Test
@MediumTest @MediumTest
@Feature({"Payments"}) @Feature({"Payments"})
public void testCannotMakeActivePaymentWithBasicMasterCard() throws InterruptedException, public void testCannotMakeActivePaymentWithBasicMasterCard()
ExecutionException, TimeoutException { throws InterruptedException, ExecutionException, TimeoutException {
openPageAndClickNodeAndWait("checkBasicMasterCard", getCanMakePaymentQueryResponded()); mPaymentRequestTestRule.openPageAndClickNodeAndWait(
expectResultContains(new String[] {"false"}); "checkBasicMasterCard", mPaymentRequestTestRule.getCanMakePaymentQueryResponded());
mPaymentRequestTestRule.expectResultContains(new String[] {"false"});
reTriggerUIAndWait("buyBasicMasterCard", getReadyForInput()); mPaymentRequestTestRule.reTriggerUIAndWait(
"buyBasicMasterCard", mPaymentRequestTestRule.getReadyForInput());
} }
@Test
@MediumTest @MediumTest
@Feature({"Payments"}) @Feature({"Payments"})
public void testSupportedNetworksMustMatchForCanMakePayment() public void testSupportedNetworksMustMatchForCanMakePayment()
throws InterruptedException, ExecutionException, TimeoutException { throws InterruptedException, ExecutionException, TimeoutException {
openPageAndClickNodeAndWait("checkBasicVisa", getCanMakePaymentQueryResponded()); mPaymentRequestTestRule.openPageAndClickNodeAndWait(
expectResultContains(new String[] {"true"}); "checkBasicVisa", mPaymentRequestTestRule.getCanMakePaymentQueryResponded());
mPaymentRequestTestRule.expectResultContains(new String[] {"true"});
clickNodeAndWait("checkBasicMasterCard", getCanMakePaymentQueryResponded());
expectResultContains(new String[] {"Not allowed to check whether can make payment"}); mPaymentRequestTestRule.clickNodeAndWait(
"checkBasicMasterCard", mPaymentRequestTestRule.getCanMakePaymentQueryResponded());
clickNodeAndWait("checkBasicVisa", getCanMakePaymentQueryResponded()); mPaymentRequestTestRule.expectResultContains(
expectResultContains(new String[] {"true"}); new String[] {"Not allowed to check whether can make payment"});
mPaymentRequestTestRule.clickNodeAndWait(
"checkBasicVisa", mPaymentRequestTestRule.getCanMakePaymentQueryResponded());
mPaymentRequestTestRule.expectResultContains(new String[] {"true"});
} }
@Test
@MediumTest @MediumTest
@Feature({"Payments"}) @Feature({"Payments"})
public void testSupportedTypesMustMatchForCanMakePayment() public void testSupportedTypesMustMatchForCanMakePayment()
throws InterruptedException, ExecutionException, TimeoutException { throws InterruptedException, ExecutionException, TimeoutException {
openPageAndClickNodeAndWait("checkBasicVisa", getCanMakePaymentQueryResponded()); mPaymentRequestTestRule.openPageAndClickNodeAndWait(
expectResultContains(new String[] {"true"}); "checkBasicVisa", mPaymentRequestTestRule.getCanMakePaymentQueryResponded());
mPaymentRequestTestRule.expectResultContains(new String[] {"true"});
clickNodeAndWait("checkBasicDebit", getCanMakePaymentQueryResponded());
expectResultContains(new String[] {"Not allowed to check whether can make payment"}); mPaymentRequestTestRule.clickNodeAndWait(
"checkBasicDebit", mPaymentRequestTestRule.getCanMakePaymentQueryResponded());
clickNodeAndWait("checkBasicVisa", getCanMakePaymentQueryResponded()); mPaymentRequestTestRule.expectResultContains(
expectResultContains(new String[] {"true"}); new String[] {"Not allowed to check whether can make payment"});
mPaymentRequestTestRule.clickNodeAndWait(
"checkBasicVisa", mPaymentRequestTestRule.getCanMakePaymentQueryResponded());
mPaymentRequestTestRule.expectResultContains(new String[] {"true"});
} }
/** /**
...@@ -102,19 +144,24 @@ public class PaymentRequestPaymentMethodIdentifierTest extends PaymentRequestTes ...@@ -102,19 +144,24 @@ public class PaymentRequestPaymentMethodIdentifierTest extends PaymentRequestTes
* network support, then the user should be able to pay via their "visa" card. The merchant will * network support, then the user should be able to pay via their "visa" card. The merchant will
* receive the "basic-card" method name. * receive the "basic-card" method name.
*/ */
@Test
@MediumTest @MediumTest
@Feature({"Payments"}) @Feature({"Payments"})
public void testPayWithBasicCard() throws InterruptedException, ExecutionException, public void testPayWithBasicCard()
TimeoutException { throws InterruptedException, ExecutionException, TimeoutException {
openPageAndClickNodeAndWait("checkBasicVisa", getCanMakePaymentQueryResponded()); mPaymentRequestTestRule.openPageAndClickNodeAndWait(
expectResultContains(new String[] {"true"}); "checkBasicVisa", mPaymentRequestTestRule.getCanMakePaymentQueryResponded());
mPaymentRequestTestRule.expectResultContains(new String[] {"true"});
reTriggerUIAndWait("buy", getReadyToPay());
clickAndWait(R.id.button_primary, getReadyForUnmaskInput()); mPaymentRequestTestRule.reTriggerUIAndWait("buy", mPaymentRequestTestRule.getReadyToPay());
setTextInCardUnmaskDialogAndWait(R.id.card_unmask_input, "123", getReadyToUnmask()); mPaymentRequestTestRule.clickAndWait(
clickCardUnmaskButtonAndWait(DialogInterface.BUTTON_POSITIVE, getDismissed()); R.id.button_primary, mPaymentRequestTestRule.getReadyForUnmaskInput());
expectResultContains(new String[] {"Jon Doe", "4111111111111111", "12", "2050", mPaymentRequestTestRule.setTextInCardUnmaskDialogAndWait(
"basic-card", "123"}); R.id.card_unmask_input, "123", mPaymentRequestTestRule.getReadyToUnmask());
mPaymentRequestTestRule.clickCardUnmaskButtonAndWait(
DialogInterface.BUTTON_POSITIVE, mPaymentRequestTestRule.getDismissed());
mPaymentRequestTestRule.expectResultContains(
new String[] {"Jon Doe", "4111111111111111", "12", "2050", "basic-card", "123"});
} }
/** /**
...@@ -122,23 +169,31 @@ public class PaymentRequestPaymentMethodIdentifierTest extends PaymentRequestTes ...@@ -122,23 +169,31 @@ public class PaymentRequestPaymentMethodIdentifierTest extends PaymentRequestTes
* network support, then the user should be able to add a "mastercard" card and pay with it. The * network support, then the user should be able to add a "mastercard" card and pay with it. The
* merchant will receive the "mastercard" method name. * merchant will receive the "mastercard" method name.
*/ */
@Test
@MediumTest @MediumTest
@Feature({"Payments"}) @Feature({"Payments"})
public void testAddMasterCard() throws InterruptedException, ExecutionException, public void testAddMasterCard()
TimeoutException { throws InterruptedException, ExecutionException, TimeoutException {
triggerUIAndWait(getReadyToPay()); mPaymentRequestTestRule.triggerUIAndWait(mPaymentRequestTestRule.getReadyToPay());
clickInPaymentMethodAndWait(R.id.payments_section, getReadyForInput()); mPaymentRequestTestRule.clickInPaymentMethodAndWait(
clickInPaymentMethodAndWait(R.id.payments_add_option_button, getReadyToEdit()); R.id.payments_section, mPaymentRequestTestRule.getReadyForInput());
setTextInCardEditorAndWait( mPaymentRequestTestRule.clickInPaymentMethodAndWait(
new String[] {"5555-5555-5555-4444", "Jane Jones"}, getEditorTextUpdate()); R.id.payments_add_option_button, mPaymentRequestTestRule.getReadyToEdit());
setSpinnerSelectionsInCardEditorAndWait( mPaymentRequestTestRule.setTextInCardEditorAndWait(
new String[] {"5555-5555-5555-4444", "Jane Jones"},
mPaymentRequestTestRule.getEditorTextUpdate());
mPaymentRequestTestRule.setSpinnerSelectionsInCardEditorAndWait(
new int[] {DECEMBER, NEXT_YEAR, FIRST_BILLING_ADDRESS}, new int[] {DECEMBER, NEXT_YEAR, FIRST_BILLING_ADDRESS},
getBillingAddressChangeProcessed()); mPaymentRequestTestRule.getBillingAddressChangeProcessed());
clickInCardEditorAndWait(R.id.payments_edit_done_button, getReadyToPay()); mPaymentRequestTestRule.clickInCardEditorAndWait(
clickAndWait(R.id.button_primary, getReadyForUnmaskInput()); R.id.payments_edit_done_button, mPaymentRequestTestRule.getReadyToPay());
setTextInCardUnmaskDialogAndWait(R.id.card_unmask_input, "123", getReadyToUnmask()); mPaymentRequestTestRule.clickAndWait(
clickCardUnmaskButtonAndWait(DialogInterface.BUTTON_POSITIVE, getDismissed()); R.id.button_primary, mPaymentRequestTestRule.getReadyForUnmaskInput());
expectResultContains( mPaymentRequestTestRule.setTextInCardUnmaskDialogAndWait(
R.id.card_unmask_input, "123", mPaymentRequestTestRule.getReadyToUnmask());
mPaymentRequestTestRule.clickCardUnmaskButtonAndWait(
DialogInterface.BUTTON_POSITIVE, mPaymentRequestTestRule.getDismissed());
mPaymentRequestTestRule.expectResultContains(
new String[] {"5555555555554444", "12", "Jane Jones", "123", "mastercard"}); new String[] {"5555555555554444", "12", "Jane Jones", "123", "mastercard"});
} }
...@@ -147,23 +202,31 @@ public class PaymentRequestPaymentMethodIdentifierTest extends PaymentRequestTes ...@@ -147,23 +202,31 @@ public class PaymentRequestPaymentMethodIdentifierTest extends PaymentRequestTes
* network support, then the user should be able to add a new "visa" card and pay with it. The * network support, then the user should be able to add a new "visa" card and pay with it. The
* merchant will receive the "basic-card" method name. * merchant will receive the "basic-card" method name.
*/ */
@Test
@MediumTest @MediumTest
@Feature({"Payments"}) @Feature({"Payments"})
public void testAddBasicCard() throws InterruptedException, ExecutionException, public void testAddBasicCard()
TimeoutException { throws InterruptedException, ExecutionException, TimeoutException {
triggerUIAndWait(getReadyToPay()); mPaymentRequestTestRule.triggerUIAndWait(mPaymentRequestTestRule.getReadyToPay());
clickInPaymentMethodAndWait(R.id.payments_section, getReadyForInput()); mPaymentRequestTestRule.clickInPaymentMethodAndWait(
clickInPaymentMethodAndWait(R.id.payments_add_option_button, getReadyToEdit()); R.id.payments_section, mPaymentRequestTestRule.getReadyForInput());
setTextInCardEditorAndWait( mPaymentRequestTestRule.clickInPaymentMethodAndWait(
new String[] {"4242-4242-4242-4242", "Jane Jones"}, getEditorTextUpdate()); R.id.payments_add_option_button, mPaymentRequestTestRule.getReadyToEdit());
setSpinnerSelectionsInCardEditorAndWait( mPaymentRequestTestRule.setTextInCardEditorAndWait(
new String[] {"4242-4242-4242-4242", "Jane Jones"},
mPaymentRequestTestRule.getEditorTextUpdate());
mPaymentRequestTestRule.setSpinnerSelectionsInCardEditorAndWait(
new int[] {DECEMBER, NEXT_YEAR, FIRST_BILLING_ADDRESS}, new int[] {DECEMBER, NEXT_YEAR, FIRST_BILLING_ADDRESS},
getBillingAddressChangeProcessed()); mPaymentRequestTestRule.getBillingAddressChangeProcessed());
clickInCardEditorAndWait(R.id.payments_edit_done_button, getReadyToPay()); mPaymentRequestTestRule.clickInCardEditorAndWait(
clickAndWait(R.id.button_primary, getReadyForUnmaskInput()); R.id.payments_edit_done_button, mPaymentRequestTestRule.getReadyToPay());
setTextInCardUnmaskDialogAndWait(R.id.card_unmask_input, "123", getReadyToUnmask()); mPaymentRequestTestRule.clickAndWait(
clickCardUnmaskButtonAndWait(DialogInterface.BUTTON_POSITIVE, getDismissed()); R.id.button_primary, mPaymentRequestTestRule.getReadyForUnmaskInput());
expectResultContains( mPaymentRequestTestRule.setTextInCardUnmaskDialogAndWait(
R.id.card_unmask_input, "123", mPaymentRequestTestRule.getReadyToUnmask());
mPaymentRequestTestRule.clickCardUnmaskButtonAndWait(
DialogInterface.BUTTON_POSITIVE, mPaymentRequestTestRule.getDismissed());
mPaymentRequestTestRule.expectResultContains(
new String[] {"4242424242424242", "12", "Jane Jones", "123", "basic-card"}); new String[] {"4242424242424242", "12", "Jane Jones", "123", "basic-card"});
} }
} }
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
package org.chromium.chrome.browser.payments;
import android.view.View;
import org.chromium.base.test.util.CallbackHelper;
import org.chromium.base.test.util.RetryOnFailure;
import org.chromium.chrome.browser.ChromeTabbedActivity;
import org.chromium.chrome.browser.autofill.CardUnmaskPrompt;
import org.chromium.chrome.browser.payments.PaymentRequestTestCommon.PaymentsCallbackHelper;
import org.chromium.chrome.browser.payments.ui.PaymentRequestSection.OptionSection.OptionRow;
import org.chromium.chrome.browser.payments.ui.PaymentRequestUI;
import org.chromium.chrome.test.ChromeActivityTestCaseBase;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeoutException;
/**
* A base integration test for payments.
*/
@RetryOnFailure
abstract class PaymentRequestTestBase extends ChromeActivityTestCaseBase<ChromeTabbedActivity>
implements PaymentRequestTestCommon.PaymentRequestTestCommonCallback {
/** Flag for installing a payment app without instruments. */
protected static final int NO_INSTRUMENTS = PaymentRequestTestCommon.NO_INSTRUMENTS;
/** Flag for installing a payment app with instruments. */
protected static final int HAVE_INSTRUMENTS = PaymentRequestTestCommon.HAVE_INSTRUMENTS;
/** Flag for installing a fast payment app. */
protected static final int IMMEDIATE_RESPONSE = PaymentRequestTestCommon.IMMEDIATE_RESPONSE;
/** Flag for installing a slow payment app. */
protected static final int DELAYED_RESPONSE = PaymentRequestTestCommon.DELAYED_RESPONSE;
/** Flag for immediately installing a payment app. */
protected static final int IMMEDIATE_CREATION = PaymentRequestTestCommon.IMMEDIATE_CREATION;
/** Flag for installing a payment app with a delay. */
protected static final int DELAYED_CREATION = PaymentRequestTestCommon.DELAYED_CREATION;
/** The expiration month dropdown index for December. */
protected static final int DECEMBER = PaymentRequestTestCommon.DECEMBER;
/** The expiration year dropdown index for the next year. */
protected static final int NEXT_YEAR = PaymentRequestTestCommon.NEXT_YEAR;
/** The billing address dropdown index for the first billing address. */
protected static final int FIRST_BILLING_ADDRESS =
PaymentRequestTestCommon.FIRST_BILLING_ADDRESS;
private final PaymentRequestTestCommon mTestCommon;
protected PaymentRequestTestBase(String testFileName) {
super(ChromeTabbedActivity.class);
mTestCommon = new PaymentRequestTestCommon(this, testFileName);
}
public PaymentsCallbackHelper<PaymentRequestUI> getReadyForInput() {
return mTestCommon.mReadyForInput;
}
public PaymentsCallbackHelper<PaymentRequestUI> getReadyToPay() {
return mTestCommon.mReadyToPay;
}
public PaymentsCallbackHelper<PaymentRequestUI> getSelectionChecked() {
return mTestCommon.mSelectionChecked;
}
public PaymentsCallbackHelper<PaymentRequestUI> getResultReady() {
return mTestCommon.mResultReady;
}
public PaymentsCallbackHelper<CardUnmaskPrompt> getReadyForUnmaskInput() {
return mTestCommon.mReadyForUnmaskInput;
}
public PaymentsCallbackHelper<CardUnmaskPrompt> getReadyToUnmask() {
return mTestCommon.mReadyToUnmask;
}
public PaymentsCallbackHelper<CardUnmaskPrompt> getUnmaskValidationDone() {
return mTestCommon.mUnmaskValidationDone;
}
public CallbackHelper getReadyToEdit() {
return mTestCommon.mReadyToEdit;
}
public CallbackHelper getEditorValidationError() {
return mTestCommon.mEditorValidationError;
}
public CallbackHelper getEditorTextUpdate() {
return mTestCommon.mEditorTextUpdate;
}
public CallbackHelper getDismissed() {
return mTestCommon.mDismissed;
}
public CallbackHelper getUnableToAbort() {
return mTestCommon.mUnableToAbort;
}
public CallbackHelper getBillingAddressChangeProcessed() {
return mTestCommon.mBillingAddressChangeProcessed;
}
public CallbackHelper getShowFailed() {
return mTestCommon.mShowFailed;
}
public CallbackHelper getCanMakePaymentQueryResponded() {
return mTestCommon.mCanMakePaymentQueryResponded;
}
public CallbackHelper getExpirationMonthChange() {
return mTestCommon.mExpirationMonthChange;
}
public PaymentRequestUI getPaymentRequestUI() {
return mTestCommon.mUI;
}
@Override
public void startMainActivity() throws InterruptedException {
mTestCommon.startMainActivity();
}
@Override
public abstract void onMainActivityStarted()
throws InterruptedException, ExecutionException, TimeoutException;
protected void triggerUIAndWait(PaymentsCallbackHelper<PaymentRequestUI> helper)
throws InterruptedException, ExecutionException, TimeoutException {
mTestCommon.triggerUIAndWait(helper);
}
protected void openPageAndClickBuyAndWait(CallbackHelper helper)
throws InterruptedException, ExecutionException, TimeoutException {
mTestCommon.openPageAndClickBuyAndWait(helper);
}
protected void triggerUIAndWait(String nodeId, PaymentsCallbackHelper<PaymentRequestUI> helper)
throws InterruptedException, ExecutionException, TimeoutException {
mTestCommon.triggerUIAndWait(nodeId, helper);
}
protected void openPageAndClickNodeAndWait(String nodeId, CallbackHelper helper)
throws InterruptedException, ExecutionException, TimeoutException {
mTestCommon.openPageAndClickNodeAndWait(nodeId, helper);
}
protected void openPageAndClickNode(String nodeId)
throws InterruptedException, ExecutionException, TimeoutException {
mTestCommon.openPageAndClickNode(nodeId);
}
protected void reTriggerUIAndWait(
String nodeId, PaymentsCallbackHelper<PaymentRequestUI> helper)
throws InterruptedException, TimeoutException {
mTestCommon.reTriggerUIAndWait(nodeId, helper);
}
/** Clicks on an HTML node. */
protected void clickNodeAndWait(String nodeId, CallbackHelper helper)
throws InterruptedException, TimeoutException {
mTestCommon.clickNodeAndWait(nodeId, helper);
}
/** Clicks on an element in the payments UI. */
protected void clickAndWait(final int resourceId, CallbackHelper helper)
throws InterruptedException, TimeoutException {
mTestCommon.clickAndWait(resourceId, helper);
}
/** Clicks on an element in the "Shipping address" section of the payments UI. */
protected void clickInShippingAddressAndWait(final int resourceId, CallbackHelper helper)
throws InterruptedException, TimeoutException {
mTestCommon.clickInShippingAddressAndWait(resourceId, helper);
}
/** Clicks on an element in the "Payment" section of the payments UI. */
protected void clickInPaymentMethodAndWait(final int resourceId, CallbackHelper helper)
throws InterruptedException, TimeoutException {
mTestCommon.clickInPaymentMethodAndWait(resourceId, helper);
}
/** Clicks on an element in the "Contact Info" section of the payments UI. */
protected void clickInContactInfoAndWait(final int resourceId, CallbackHelper helper)
throws InterruptedException, TimeoutException {
mTestCommon.clickInContactInfoAndWait(resourceId, helper);
}
/** Clicks on an element in the editor UI for credit cards. */
protected void clickInCardEditorAndWait(final int resourceId, CallbackHelper helper)
throws InterruptedException, TimeoutException {
mTestCommon.clickInCardEditorAndWait(resourceId, helper);
}
/** Clicks on an element in the editor UI. */
protected void clickInEditorAndWait(final int resourceId, CallbackHelper helper)
throws InterruptedException, TimeoutException {
mTestCommon.clickInEditorAndWait(resourceId, helper);
}
protected void clickAndroidBackButtonInEditorAndWait(CallbackHelper helper)
throws InterruptedException, TimeoutException {
mTestCommon.clickAndroidBackButtonInEditorAndWait(helper);
}
/** Clicks on a button in the card unmask UI. */
protected void clickCardUnmaskButtonAndWait(final int dialogButtonId, CallbackHelper helper)
throws InterruptedException, TimeoutException {
mTestCommon.clickCardUnmaskButtonAndWait(dialogButtonId, helper);
}
/** Gets the button state for the shipping summary section. */
protected int getSummarySectionButtonState() throws ExecutionException {
return mTestCommon.getShippingAddressSectionButtonState();
}
/** Gets the button state for the contact details section. */
protected int getContactDetailsButtonState() throws ExecutionException {
return mTestCommon.getContactDetailsButtonState();
}
/** Returns the label corresponding to the payment instrument at the specified |index|. */
protected String getPaymentInstrumentLabel(final int index) throws ExecutionException {
return mTestCommon.getPaymentInstrumentLabel(index);
}
/**
* Returns the label corresponding to the contact detail suggestion at the specified
* |suggestionIndex|.
*/
protected String getContactDetailsSuggestionLabel(final int suggestionIndex)
throws ExecutionException {
return mTestCommon.getContactDetailsSuggestionLabel(suggestionIndex);
}
/** Returns the number of payment instruments. */
protected int getNumberOfPaymentInstruments() throws ExecutionException {
return mTestCommon.getNumberOfPaymentInstruments();
}
/** Returns the number of contact detail suggestions. */
protected int getNumberOfContactDetailSuggestions() throws ExecutionException {
return mTestCommon.getNumberOfContactDetailSuggestions();
}
/**
* Returns the label corresponding to the shipping address suggestion at the specified
* |suggestionIndex|.
*/
protected String getShippingAddressSuggestionLabel(final int suggestionIndex)
throws ExecutionException {
return mTestCommon.getShippingAddressSuggestionLabel(suggestionIndex);
}
/** Returns the focused view in the card editor view. */
protected View getCardEditorFocusedView() {
return mTestCommon.getCardEditorFocusedView();
}
/**
* Clicks on the label corresponding to the shipping address suggestion at the specified
* |suggestionIndex|.
* @throws InterruptedException
*/
protected void clickOnShippingAddressSuggestionOptionAndWait(
final int suggestionIndex, CallbackHelper helper)
throws ExecutionException, TimeoutException, InterruptedException {
mTestCommon.clickOnShippingAddressSuggestionOptionAndWait(suggestionIndex, helper);
}
/**
* Clicks on the label corresponding to the payment method suggestion at the specified
* |suggestionIndex|.
* @throws InterruptedException
*/
protected void clickOnPaymentMethodSuggestionOptionAndWait(
final int suggestionIndex, CallbackHelper helper)
throws ExecutionException, TimeoutException, InterruptedException {
mTestCommon.clickOnPaymentMethodSuggestionOptionAndWait(suggestionIndex, helper);
}
/**
* Clicks on the edit icon corresponding to the payment method suggestion at the specified
* |suggestionIndex|.
*/
protected void clickOnPaymentMethodSuggestionEditIconAndWait(
final int suggestionIndex, CallbackHelper helper)
throws ExecutionException, TimeoutException, InterruptedException {
mTestCommon.clickOnPaymentMethodSuggestionEditIconAndWait(suggestionIndex, helper);
}
/**
* Returns the the number of shipping address suggestions.
*/
protected int getNumberOfShippingAddressSuggestions() throws ExecutionException {
return mTestCommon.getNumberOfShippingAddressSuggestions();
}
/** Returns the {@link OptionRow} at the given index for the shipping address section. */
protected OptionRow getShippingAddressOptionRowAtIndex(final int index)
throws ExecutionException {
return mTestCommon.getShippingAddressOptionRowAtIndex(index);
}
/** Returns the selected spinner value in the editor UI for credit cards. */
protected String getSpinnerSelectionTextInCardEditor(final int dropdownIndex)
throws ExecutionException {
return mTestCommon.getSpinnerSelectionTextInCardEditor(dropdownIndex);
}
/** Returns the spinner value at the specified position in the editor UI for credit cards. */
protected String getSpinnerTextAtPositionInCardEditor(
final int dropdownIndex, final int itemPosition) throws ExecutionException {
return mTestCommon.getSpinnerTextAtPositionInCardEditor(dropdownIndex, itemPosition);
}
/** Returns the number of items offered by the spinner in the editor UI for credit cards. */
protected int getSpinnerItemCountInCardEditor(final int dropdownIndex)
throws ExecutionException {
return mTestCommon.getSpinnerItemCountInCardEditor(dropdownIndex);
}
/** Returns the error message visible to the user in the credit card unmask prompt. */
protected String getUnmaskPromptErrorMessage() {
return mTestCommon.getUnmaskPromptErrorMessage();
}
/** Selects the spinner value in the editor UI for credit cards. */
protected void setSpinnerSelectionsInCardEditorAndWait(final int[] selections,
CallbackHelper helper) throws InterruptedException, TimeoutException {
mTestCommon.setSpinnerSelectionsInCardEditorAndWait(selections, helper);
}
/** Selects the spinner value in the editor UI. */
protected void setSpinnerSelectionInEditorAndWait(final int selection, CallbackHelper helper)
throws InterruptedException, TimeoutException {
mTestCommon.setSpinnerSelectionInEditorAndWait(selection, helper);
}
/** Directly sets the text in the editor UI for credit cards. */
protected void setTextInCardEditorAndWait(final String[] values, CallbackHelper helper)
throws InterruptedException, TimeoutException {
mTestCommon.setTextInCardEditorAndWait(values, helper);
}
/** Directly sets the text in the editor UI. */
protected void setTextInEditorAndWait(final String[] values, CallbackHelper helper)
throws InterruptedException, TimeoutException {
mTestCommon.setTextInEditorAndWait(values, helper);
}
/** 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 {
mTestCommon.selectCheckboxAndWait(resourceId, isChecked, helper);
}
/** Directly sets the text in the card unmask UI. */
protected void setTextInCardUnmaskDialogAndWait(final int resourceId, final String input,
CallbackHelper helper) throws InterruptedException, TimeoutException {
mTestCommon.setTextInCardUnmaskDialogAndWait(resourceId, input, helper);
}
/** Directly sets the text in the expired card unmask UI. */
protected void setTextInExpiredCardUnmaskDialogAndWait(
final int[] resourceIds, final String[] values, CallbackHelper helper)
throws InterruptedException, TimeoutException {
mTestCommon.setTextInExpiredCardUnmaskDialogAndWait(resourceIds, values, helper);
}
/** Verifies the contents of the test webpage. */
protected void expectResultContains(final String[] contents) {
mTestCommon.expectResultContains(contents);
}
/** Will fail if the OptionRow at |index| is not selected in Contact Details.*/
protected void expectContactDetailsRowIsSelected(final int index) {
mTestCommon.expectContactDetailsRowIsSelected(index);
}
/** Will fail if the OptionRow at |index| is not selected in Shipping Address section.*/
protected void expectShippingAddressRowIsSelected(final int index) {
mTestCommon.expectShippingAddressRowIsSelected(index);
}
/** Will fail if the OptionRow at |index| is not selected in PaymentMethod section.*/
protected void expectPaymentMethodRowIsSelected(final int index) {
mTestCommon.expectPaymentMethodRowIsSelected(index);
}
/**
* Asserts that only the specified reason for abort is logged.
*
* @param abortReason The only bucket in the abort histogram that should have a record.
*/
protected void assertOnlySpecificAbortMetricLogged(int abortReason) {
mTestCommon.assertOnlySpecificAbortMetricLogged(abortReason);
}
public void onPaymentRequestReadyForInput(PaymentRequestUI ui) {
mTestCommon.onPaymentRequestReadyForInput(ui);
}
public void onPaymentRequestReadyToEdit() {
mTestCommon.onPaymentRequestReadyToEdit();
}
public void onPaymentRequestEditorValidationError() {
mTestCommon.onPaymentRequestEditorValidationError();
}
public void onPaymentRequestEditorTextUpdate() {
mTestCommon.onPaymentRequestEditorTextUpdate();
}
public void onPaymentRequestReadyToPay(PaymentRequestUI ui) {
mTestCommon.onPaymentRequestReadyToPay(ui);
}
public void onPaymentRequestSelectionChecked(PaymentRequestUI ui) {
mTestCommon.onPaymentRequestSelectionChecked(ui);
}
public void onPaymentRequestResultReady(PaymentRequestUI ui) {
mTestCommon.onPaymentRequestResultReady(ui);
}
public void onPaymentRequestDismiss() {
mTestCommon.onPaymentRequestDismiss();
}
public void onPaymentRequestServiceUnableToAbort() {
mTestCommon.onPaymentRequestServiceUnableToAbort();
}
public void onPaymentRequestServiceBillingAddressChangeProcessed() {
mTestCommon.onPaymentRequestServiceBillingAddressChangeProcessed();
}
public void onPaymentRequestServiceExpirationMonthChange() {
mTestCommon.onPaymentRequestServiceExpirationMonthChange();
}
public void onPaymentRequestServiceShowFailed() {
mTestCommon.onPaymentRequestServiceShowFailed();
}
public void onPaymentRequestServiceCanMakePaymentQueryResponded() {
mTestCommon.onPaymentRequestServiceCanMakePaymentQueryResponded();
}
public void onCardUnmaskPromptReadyForInput(CardUnmaskPrompt prompt) {
mTestCommon.onCardUnmaskPromptReadyForInput(prompt);
}
public void onCardUnmaskPromptReadyToUnmask(CardUnmaskPrompt prompt) {
mTestCommon.onCardUnmaskPromptReadyToUnmask(prompt);
}
public void onCardUnmaskPromptValidationDone(CardUnmaskPrompt prompt) {
mTestCommon.onCardUnmaskPromptValidationDone(prompt);
}
/**
* Installs a payment app for testing.
*
* @param instrumentPresence Whether the app has any payment instruments. Either NO_INSTRUMENTS
* or HAVE_INSTRUMENTS.
* @param responseSpeed How quickly the app will respond to "get instruments" query. Either
* IMMEDIATE_RESPONSE or DELAYED_RESPONSE.
*/
protected void installPaymentApp(int instrumentPresence, int responseSpeed) {
mTestCommon.installPaymentApp(instrumentPresence, responseSpeed);
}
/**
* Installs a payment app for testing.
*
* @param methodName The name of the payment method used in the payment app.
* @param instrumentPresence Whether the app has any payment instruments. Either NO_INSTRUMENTS
* or HAVE_INSTRUMENTS.
* @param responseSpeed How quickly the app will respond to "get instruments" query. Either
* IMMEDIATE_RESPONSE or DELAYED_RESPONSE.
*/
protected void installPaymentApp(String methodName, int instrumentPresence, int responseSpeed) {
mTestCommon.installPaymentApp(methodName, instrumentPresence, responseSpeed);
}
/**
* Installs a payment app for testing.
*
* @param methodName The name of the payment method used in the payment app.
* @param instrumentPresence Whether the app has any payment instruments. Either NO_INSTRUMENTS
* or HAVE_INSTRUMENTS.
* @param responseSpeed How quickly the app will respond to "get instruments" query. Either
* IMMEDIATE_RESPONSE or DELAYED_RESPONSE.
* @param creationSpeed How quickly the app factory will create this app. Either
* IMMEDIATE_CREATION or DELAYED_CREATION.
*/
protected void installPaymentApp(
String methodName, int instrumentPresence, int responseSpeed, int creationSpeed) {
mTestCommon.installPaymentApp(methodName, instrumentPresence, responseSpeed, creationSpeed);
}
@Override
public void startMainActivityWithURL(String url) throws InterruptedException {
super.startMainActivityWithURL(url);
}
@Override
public void assertWaitForPageScaleFactorMatch(float expectedScale) {
super.assertWaitForPageScaleFactorMatch(expectedScale);
}
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment