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

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

Issue 2220713002: [Payments] Add Payment Request metrics for selected payment method. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed comments Created 4 years, 4 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 242b7b4daf6cb449a0a26a38ad2ed3e55bfcbd2a..b87683364b18581ae9b96cc35f48f5a87f5fb44e 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
@@ -119,6 +119,12 @@ abstract class PaymentRequestTestBase extends ChromeActivityTestCaseBase<ChromeT
triggerUIAndWait("buy", helper);
}
+ protected void triggerUIAndWait(String nodeId, PaymentsCallbackHelper<PaymentRequestUI> helper)
+ throws InterruptedException, ExecutionException, TimeoutException {
+ triggerUIAndWait(nodeId, (CallbackHelper) helper);
+ mUI = helper.getTarget();
+ }
+
protected void triggerUIAndWait(String nodeId, CallbackHelper helper)
throws InterruptedException, ExecutionException, TimeoutException {
startMainActivityWithURL(mTestFilePath);
@@ -610,10 +616,25 @@ abstract class PaymentRequestTestBase extends ChromeActivityTestCaseBase<ChromeT
* or HAVE_INSTRUMENTS.
* @param responseSpeed How quickly the app will respond to "get instruments" query. Either
* IMMEDIATE_RESPONSE, DELAYED_RESPONSE, or NO_RESPONSE.
- * @return The install payment app.
+ * @return The installed payment app.
+ */
+ protected TestPay installPaymentApp(final int instrumentPresence, final int responseSpeed) {
+ return installPaymentApp("https://bobpay.com", 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, DELAYED_RESPONSE, or NO_RESPONSE.
+ * @return The installed payment app.
*/
- protected BobPay installPaymentApp(final int instrumentPresence, final int responseSpeed) {
- final BobPay app = new BobPay(instrumentPresence, responseSpeed);
+ protected TestPay installPaymentApp(final String methodName, final int instrumentPresence,
+ final int responseSpeed) {
+ final TestPay app = new TestPay(methodName, instrumentPresence, responseSpeed);
PaymentAppFactory.setAdditionalFactory(new PaymentAppFactoryAddition() {
@Override
public List<PaymentApp> create(WebContents webContents) {
@@ -626,12 +647,14 @@ abstract class PaymentRequestTestBase extends ChromeActivityTestCaseBase<ChromeT
}
/** A payment app implementation for test. */
- protected static class BobPay implements PaymentApp {
+ protected static class TestPay implements PaymentApp {
+ private final String mMethodName;
private final int mInstrumentPresence;
private final int mResponseSpeed;
private InstrumentsCallback mCallback;
- BobPay(int instrumentPresence, int responseSpeed) {
+ TestPay(String methodName, int instrumentPresence, int responseSpeed) {
+ mMethodName = methodName;
mInstrumentPresence = instrumentPresence;
mResponseSpeed = responseSpeed;
}
@@ -645,12 +668,14 @@ abstract class PaymentRequestTestBase extends ChromeActivityTestCaseBase<ChromeT
void respond() {
final List<PaymentInstrument> instruments = new ArrayList<>();
- if (mInstrumentPresence == HAVE_INSTRUMENTS) instruments.add(new BobPayInstrument());
+ if (mInstrumentPresence == HAVE_INSTRUMENTS) {
+ instruments.add(new TestPayInstrument(mMethodName));
+ }
Runnable instrumentsReady = new Runnable() {
@Override
public void run() {
ThreadUtils.assertOnUiThread();
- mCallback.onInstrumentsReady(BobPay.this, instruments);
+ mCallback.onInstrumentsReady(TestPay.this, instruments);
}
};
if (mResponseSpeed == IMMEDIATE_RESPONSE) {
@@ -663,32 +688,35 @@ abstract class PaymentRequestTestBase extends ChromeActivityTestCaseBase<ChromeT
@Override
public Set<String> getSupportedMethodNames() {
Set<String> methodNames = new HashSet<>();
- methodNames.add("https://bobpay.com");
+ methodNames.add(mMethodName);
return methodNames;
}
@Override
public String getIdentifier() {
- return "https://bobpay.com";
+ return mMethodName;
}
}
/** A payment instrument implementation for test. */
- private static class BobPayInstrument extends PaymentInstrument {
- BobPayInstrument() {
- super("https://bobpay.com", "Bob Pay", null, NO_ICON);
+ private static class TestPayInstrument extends PaymentInstrument {
+ private final String mMethodName;
+
+ TestPayInstrument(String methodName) {
+ super(methodName, "Test Pay", null, NO_ICON);
+ mMethodName = methodName;
}
@Override
public String getMethodName() {
- return "https://bobpay.com";
+ return mMethodName;
}
@Override
public void getDetails(String merchantName, String origin, PaymentItem total,
List<PaymentItem> cart, JSONObject details, DetailsCallback detailsCallback) {
detailsCallback.onInstrumentDetailsReady(
- "https://bobpay.com", "{\"transaction\": 1337}");
+ mMethodName, "{\"transaction\": 1337}");
}
@Override

Powered by Google App Engine
This is Rietveld 408576698