Commit 84825b08 authored by sebsg's avatar sebsg Committed by Commit Bot

[Payments] Add java tests for the new events metric in PR.

Change-Id: Ibc7e908d7d0ae3805d5b3edeb59d9933fe5b6620
Reviewed-on: https://chromium-review.googlesource.com/581739Reviewed-by: default avatarGanggui Tang <gogerald@chromium.org>
Commit-Queue: Sebastien Seguin-Gagnon <sebsg@chromium.org>
Cr-Commit-Position: refs/heads/master@{#488723}
parent c45d868e
......@@ -585,6 +585,13 @@ public class PaymentRequestJourneyLoggerTest implements MainActivityStartCallbac
RecordHistogram.getHistogramTotalCountForTesting(
"PaymentRequest.UserDidNotHaveCompleteSuggestionsForEverything."
+ "EffectOnCompletion"));
// Make sure the events were logged correctly.
int expectedSample = Event.SHOWN | Event.USER_ABORTED | Event.HAD_INITIAL_FORM_OF_PAYMENT
| Event.HAD_NECESSARY_COMPLETE_SUGGESTIONS;
Assert.assertEquals(1,
RecordHistogram.getHistogramValueCountForTesting(
"PaymentRequest.Events", expectedSample));
}
/**
......@@ -624,6 +631,12 @@ public class PaymentRequestJourneyLoggerTest implements MainActivityStartCallbac
RecordHistogram.getHistogramTotalCountForTesting(
"PaymentRequest.UserHadCompleteSuggestionsForEverything."
+ "EffectOnCompletion"));
// Make sure the events were logged correctly.
int expectedSample = Event.SHOWN | Event.USER_ABORTED | Event.HAD_INITIAL_FORM_OF_PAYMENT;
Assert.assertEquals(1,
RecordHistogram.getHistogramValueCountForTesting(
"PaymentRequest.Events", expectedSample));
}
/**
......@@ -640,9 +653,9 @@ public class PaymentRequestJourneyLoggerTest implements MainActivityStartCallbac
String mBillingAddressId = mHelper.setProfile(new AutofillProfile("", "https://example.com",
true, "Jon Doe", "Google", "340 Main St", "CA", "Los Angeles", "", "90291", "",
"US", "650-253-0000", "", "en-US"));
mHelper.setCreditCard(new CreditCard("", "https://example.com", true, true, "Jon Doe",
/*number=*/"", "1111", "10", "2021", "visa", R.drawable.visa_card, CardType.UNKNOWN,
mBillingAddressId, "" /* serverId */));
mHelper.setCreditCard(new CreditCard("", "https://example.com", true, true,
/*cardholderName=*/"", "4111111111111111", "1111", "10", "2021", "visa",
R.drawable.visa_card, CardType.UNKNOWN, mBillingAddressId, "" /* serverId */));
// Cancel the payment request.
mPaymentRequestTestRule.triggerUIAndWait(
......@@ -663,6 +676,12 @@ public class PaymentRequestJourneyLoggerTest implements MainActivityStartCallbac
RecordHistogram.getHistogramTotalCountForTesting(
"PaymentRequest.UserHadCompleteSuggestionsForEverything."
+ "EffectOnCompletion"));
// Make sure the events were logged correctly.
int expectedSample = Event.SHOWN | Event.USER_ABORTED | Event.HAD_INITIAL_FORM_OF_PAYMENT;
Assert.assertEquals(1,
RecordHistogram.getHistogramValueCountForTesting(
"PaymentRequest.Events", expectedSample));
}
/**
......@@ -702,6 +721,12 @@ public class PaymentRequestJourneyLoggerTest implements MainActivityStartCallbac
RecordHistogram.getHistogramTotalCountForTesting(
"PaymentRequest.UserHadCompleteSuggestionsForEverything."
+ "EffectOnCompletion"));
// Make sure the events were logged correctly.
int expectedSample = Event.SHOWN | Event.USER_ABORTED;
Assert.assertEquals(1,
RecordHistogram.getHistogramValueCountForTesting(
"PaymentRequest.Events", expectedSample));
}
/**
......@@ -739,6 +764,12 @@ public class PaymentRequestJourneyLoggerTest implements MainActivityStartCallbac
RecordHistogram.getHistogramTotalCountForTesting(
"PaymentRequest.UserHadCompleteSuggestionsForEverything."
+ "EffectOnCompletion"));
// Make sure the events were logged correctly.
int expectedSample = Event.SHOWN | Event.USER_ABORTED;
Assert.assertEquals(1,
RecordHistogram.getHistogramValueCountForTesting(
"PaymentRequest.Events", expectedSample));
}
/**
......@@ -776,6 +807,12 @@ public class PaymentRequestJourneyLoggerTest implements MainActivityStartCallbac
RecordHistogram.getHistogramTotalCountForTesting(
"PaymentRequest.UserHadCompleteSuggestionsForEverything."
+ "EffectOnCompletion"));
// Make sure the events were logged correctly.
int expectedSample = Event.SHOWN | Event.USER_ABORTED;
Assert.assertEquals(1,
RecordHistogram.getHistogramValueCountForTesting(
"PaymentRequest.Events", expectedSample));
}
/**
......@@ -812,6 +849,13 @@ public class PaymentRequestJourneyLoggerTest implements MainActivityStartCallbac
RecordHistogram.getHistogramTotalCountForTesting(
"PaymentRequest.UserDidNotHaveCompleteSuggestionsForEverything."
+ "EffectOnCompletion"));
// Make sure the events were logged correctly.
int expectedSample = Event.SHOWN | Event.USER_ABORTED | Event.HAD_INITIAL_FORM_OF_PAYMENT
| Event.HAD_NECESSARY_COMPLETE_SUGGESTIONS;
Assert.assertEquals(1,
RecordHistogram.getHistogramValueCountForTesting(
"PaymentRequest.Events", expectedSample));
}
/**
......@@ -851,6 +895,12 @@ public class PaymentRequestJourneyLoggerTest implements MainActivityStartCallbac
RecordHistogram.getHistogramTotalCountForTesting(
"PaymentRequest.UserHadCompleteSuggestionsForEverything."
+ "EffectOnCompletion"));
// Make sure the events were logged correctly.
int expectedSample = Event.SHOWN | Event.USER_ABORTED | Event.HAD_INITIAL_FORM_OF_PAYMENT;
Assert.assertEquals(1,
RecordHistogram.getHistogramValueCountForTesting(
"PaymentRequest.Events", expectedSample));
}
/**
......@@ -890,6 +940,13 @@ public class PaymentRequestJourneyLoggerTest implements MainActivityStartCallbac
RecordHistogram.getHistogramTotalCountForTesting(
"PaymentRequest.UserDidNotHaveCompleteSuggestionsForEverything."
+ "EffectOnCompletion"));
// Make sure the events were logged correctly.
int expectedSample = Event.SHOWN | Event.USER_ABORTED | Event.HAD_INITIAL_FORM_OF_PAYMENT
| Event.HAD_NECESSARY_COMPLETE_SUGGESTIONS;
Assert.assertEquals(1,
RecordHistogram.getHistogramValueCountForTesting(
"PaymentRequest.Events", expectedSample));
}
/**
......@@ -927,6 +984,13 @@ public class PaymentRequestJourneyLoggerTest implements MainActivityStartCallbac
RecordHistogram.getHistogramTotalCountForTesting(
"PaymentRequest.UserDidNotHaveCompleteSuggestionsForEverything."
+ "EffectOnCompletion"));
// Make sure the events were logged correctly.
int expectedSample = Event.SHOWN | Event.USER_ABORTED | Event.HAD_INITIAL_FORM_OF_PAYMENT
| Event.HAD_NECESSARY_COMPLETE_SUGGESTIONS;
Assert.assertEquals(1,
RecordHistogram.getHistogramValueCountForTesting(
"PaymentRequest.Events", expectedSample));
}
/**
......@@ -967,6 +1031,13 @@ public class PaymentRequestJourneyLoggerTest implements MainActivityStartCallbac
RecordHistogram.getHistogramTotalCountForTesting(
"PaymentRequest.UserDidNotHaveCompleteSuggestionsForEverything."
+ "EffectOnCompletion"));
// Make sure the events were logged correctly.
int expectedSample = Event.SHOWN | Event.USER_ABORTED | Event.HAD_INITIAL_FORM_OF_PAYMENT
| Event.HAD_NECESSARY_COMPLETE_SUGGESTIONS;
Assert.assertEquals(1,
RecordHistogram.getHistogramValueCountForTesting(
"PaymentRequest.Events", expectedSample));
}
/**
......@@ -1002,6 +1073,12 @@ public class PaymentRequestJourneyLoggerTest implements MainActivityStartCallbac
Assert.assertEquals(0,
RecordHistogram.getHistogramTotalCountForTesting(
"PaymentRequest.UserHadCompleteSuggestions.EffectOnCompletion"));
// Make sure the events were logged correctly.
int expectedSample = Event.SHOWN | Event.USER_ABORTED;
Assert.assertEquals(1,
RecordHistogram.getHistogramValueCountForTesting(
"PaymentRequest.Events", expectedSample));
}
/**
......
......@@ -103,6 +103,14 @@ public class PaymentRequestMetricsTest implements MainActivityStartCallback {
Assert.assertEquals(1,
RecordHistogram.getHistogramValueCountForTesting(
"PaymentRequest.CheckoutFunnel.Completed", 1));
// Make sure the events were logged correctly.
int expectedSample = Event.SHOWN | Event.PAY_CLICKED | Event.RECEIVED_INSTRUMENT_DETAILS
| Event.COMPLETED | Event.HAD_INITIAL_FORM_OF_PAYMENT
| Event.HAD_NECESSARY_COMPLETE_SUGGESTIONS;
Assert.assertEquals(1,
RecordHistogram.getHistogramValueCountForTesting(
"PaymentRequest.Events", expectedSample));
}
/**
......@@ -134,6 +142,13 @@ public class PaymentRequestMetricsTest implements MainActivityStartCallback {
mPaymentRequestTestRule.expectResultContains(new String[] {"Request cancelled"});
mPaymentRequestTestRule.assertOnlySpecificAbortMetricLogged(AbortReason.ABORTED_BY_USER);
// Make sure the events were logged correctly.
int expectedSample = Event.SHOWN | Event.USER_ABORTED | Event.HAD_INITIAL_FORM_OF_PAYMENT
| Event.HAD_NECESSARY_COMPLETE_SUGGESTIONS;
Assert.assertEquals(1,
RecordHistogram.getHistogramValueCountForTesting(
"PaymentRequest.Events", expectedSample));
}
/**
......@@ -156,6 +171,13 @@ public class PaymentRequestMetricsTest implements MainActivityStartCallback {
mPaymentRequestTestRule.expectResultContains(new String[] {"Request cancelled"});
mPaymentRequestTestRule.assertOnlySpecificAbortMetricLogged(AbortReason.ABORTED_BY_USER);
// Make sure the events were logged correctly.
int expectedSample = Event.SHOWN | Event.USER_ABORTED | Event.HAD_INITIAL_FORM_OF_PAYMENT
| Event.HAD_NECESSARY_COMPLETE_SUGGESTIONS;
Assert.assertEquals(1,
RecordHistogram.getHistogramValueCountForTesting(
"PaymentRequest.Events", expectedSample));
}
/**
......@@ -184,6 +206,13 @@ public class PaymentRequestMetricsTest implements MainActivityStartCallback {
mPaymentRequestTestRule.expectResultContains(new String[] {"Request cancelled"});
mPaymentRequestTestRule.assertOnlySpecificAbortMetricLogged(AbortReason.ABORTED_BY_USER);
// Make sure the events were logged correctly.
int expectedSample = Event.SHOWN | Event.USER_ABORTED | Event.HAD_INITIAL_FORM_OF_PAYMENT
| Event.HAD_NECESSARY_COMPLETE_SUGGESTIONS;
Assert.assertEquals(1,
RecordHistogram.getHistogramValueCountForTesting(
"PaymentRequest.Events", expectedSample));
}
/**
......@@ -194,7 +223,7 @@ public class PaymentRequestMetricsTest implements MainActivityStartCallback {
@MediumTest
@Feature({"Payments"})
@RetryOnFailure
public void testAbortMetrics_AbortedByUser_TabClosed()
public void testAbortMetrics_OtherAborted_TabClosed()
throws InterruptedException, ExecutionException, TimeoutException {
mPaymentRequestTestRule.triggerUIAndWait("ccBuy", mPaymentRequestTestRule.getReadyToPay());
mPaymentRequestTestRule.clickInShippingAddressAndWait(
......@@ -206,6 +235,13 @@ public class PaymentRequestMetricsTest implements MainActivityStartCallback {
mPaymentRequestTestRule.assertOnlySpecificAbortMetricLogged(
AbortReason.MOJO_RENDERER_CLOSING);
// Make sure the events were logged correctly.
int expectedSample = Event.SHOWN | Event.OTHER_ABORTED | Event.HAD_INITIAL_FORM_OF_PAYMENT
| Event.HAD_NECESSARY_COMPLETE_SUGGESTIONS;
Assert.assertEquals(1,
RecordHistogram.getHistogramValueCountForTesting(
"PaymentRequest.Events", expectedSample));
}
/**
......@@ -226,6 +262,13 @@ public class PaymentRequestMetricsTest implements MainActivityStartCallback {
mPaymentRequestTestRule.assertOnlySpecificAbortMetricLogged(
AbortReason.ABORTED_BY_MERCHANT);
// Make sure the events were logged correctly.
int expectedSample = Event.SHOWN | Event.OTHER_ABORTED | Event.HAD_INITIAL_FORM_OF_PAYMENT
| Event.HAD_NECESSARY_COMPLETE_SUGGESTIONS;
Assert.assertEquals(1,
RecordHistogram.getHistogramValueCountForTesting(
"PaymentRequest.Events", expectedSample));
}
/**
......@@ -256,6 +299,10 @@ public class PaymentRequestMetricsTest implements MainActivityStartCallback {
RecordHistogram.getHistogramValueCountForTesting(
"PaymentRequest.CheckoutFunnel.NoShow",
NotShownReason.NO_MATCHING_PAYMENT_METHOD));
// Make sure no events were logged.
Assert.assertEquals(
0, RecordHistogram.getHistogramTotalCountForTesting("PaymentRequest.Events"));
}
/**
......@@ -282,6 +329,10 @@ public class PaymentRequestMetricsTest implements MainActivityStartCallback {
RecordHistogram.getHistogramValueCountForTesting(
"PaymentRequest.CheckoutFunnel.NoShow",
NotShownReason.NO_SUPPORTED_PAYMENT_METHOD));
// Make sure no events were logged.
Assert.assertEquals(
0, RecordHistogram.getHistogramTotalCountForTesting("PaymentRequest.Events"));
}
/**
......@@ -352,6 +403,14 @@ public class PaymentRequestMetricsTest implements MainActivityStartCallback {
"PaymentRequest.CheckoutFunnel.Shown", 1));
assertOnlySpecificSelectedPaymentMethodMetricLogged(SelectedPaymentMethod.ANDROID_PAY);
// Make sure the events were logged correctly.
int expectedSample = Event.SKIPPED_SHOW | Event.PAY_CLICKED
| Event.RECEIVED_INSTRUMENT_DETAILS | Event.COMPLETED
| Event.HAD_INITIAL_FORM_OF_PAYMENT | Event.HAD_NECESSARY_COMPLETE_SUGGESTIONS;
Assert.assertEquals(1,
RecordHistogram.getHistogramValueCountForTesting(
"PaymentRequest.Events", expectedSample));
}
/**
......@@ -383,6 +442,13 @@ public class PaymentRequestMetricsTest implements MainActivityStartCallback {
Assert.assertEquals(0,
RecordHistogram.getHistogramValueCountForTesting(
"PaymentRequest.CheckoutFunnel.SkippedShow", 1));
// Make sure the events were logged correctly.
int expectedSample = Event.SHOWN | Event.USER_ABORTED | Event.HAD_INITIAL_FORM_OF_PAYMENT
| Event.HAD_NECESSARY_COMPLETE_SUGGESTIONS;
Assert.assertEquals(1,
RecordHistogram.getHistogramValueCountForTesting(
"PaymentRequest.Events", expectedSample));
}
/**
......@@ -418,6 +484,10 @@ public class PaymentRequestMetricsTest implements MainActivityStartCallback {
Assert.assertEquals(1,
RecordHistogram.getHistogramValueCountForTesting(
"PaymentRequest.CheckoutFunnel.Shown", 1));
// Make sure only one set of events was logged.
Assert.assertEquals(
1, RecordHistogram.getHistogramTotalCountForTesting("PaymentRequest.Events"));
}
/**
......
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