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

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

Issue 2750103005: [Payments] Move journey logger to native. (Closed)
Patch Set: Addressed comments Created 3 years, 9 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/PaymentRequestJourneyLoggerUnitTest.java
diff --git a/chrome/android/javatests/src/org/chromium/chrome/browser/payments/PaymentRequestJourneyLoggerUnitTest.java b/chrome/android/javatests/src/org/chromium/chrome/browser/payments/PaymentRequestJourneyLoggerUnitTest.java
index b0291172a26da1b9fc5fce53ae2575b0350170f5..eab31205a2179c27a9f42835c086fd8492a6fe92 100644
--- a/chrome/android/javatests/src/org/chromium/chrome/browser/payments/PaymentRequestJourneyLoggerUnitTest.java
+++ b/chrome/android/javatests/src/org/chromium/chrome/browser/payments/PaymentRequestJourneyLoggerUnitTest.java
@@ -9,6 +9,7 @@ import android.support.test.filters.SmallTest;
import org.chromium.base.metrics.RecordHistogram;
import org.chromium.base.test.util.Feature;
import org.chromium.chrome.test.util.ApplicationData;
+import org.chromium.components.payments.JourneyLogger;
import org.chromium.content.browser.test.NativeLibraryTestBase;
/**
@@ -29,23 +30,26 @@ public class PaymentRequestJourneyLoggerUnitTest extends NativeLibraryTestBase {
@SmallTest
@Feature({"Payments"})
public void testRecordJourneyStatsHistograms_CanMakePaymentNotCalled_NoShow() {
- PaymentRequestJourneyLogger logger = new PaymentRequestJourneyLogger();
+ JourneyLogger logger = new JourneyLogger();
assertNoLogForCanMakePayment();
logger.recordJourneyStatsHistograms("");
// CanMakePayment was not used.
- assertEquals(1, RecordHistogram.getHistogramValueCountForTesting(
- "PaymentRequest.CanMakePayment.Usage",
- PaymentRequestJourneyLogger.CAN_MAKE_PAYMENT_NOT_USED));
+ assertEquals(1,
+ RecordHistogram.getHistogramValueCountForTesting(
+ "PaymentRequest.CanMakePayment.Usage",
+ JourneyLogger.CAN_MAKE_PAYMENT_NOT_USED));
// There should be no completion stats since PR was not shown to the user
- assertEquals(0, RecordHistogram.getHistogramValueCountForTesting(
- "PaymentRequest.CanMakePayment.NotUsed.WithShowEffectOnCompletion",
- PaymentRequestJourneyLogger.COMPLETION_STATUS_ABORTED));
- assertEquals(0, RecordHistogram.getHistogramValueCountForTesting(
- "PaymentRequest.CanMakePayment.NotUsed.WithShowEffectOnCompletion",
- PaymentRequestJourneyLogger.COMPLETION_STATUS_COMPLETED));
+ assertEquals(0,
+ RecordHistogram.getHistogramValueCountForTesting(
+ "PaymentRequest.CanMakePayment.NotUsed.WithShowEffectOnCompletion",
+ JourneyLogger.COMPLETION_STATUS_ABORTED));
+ assertEquals(0,
+ RecordHistogram.getHistogramValueCountForTesting(
+ "PaymentRequest.CanMakePayment.NotUsed.WithShowEffectOnCompletion",
+ JourneyLogger.COMPLETION_STATUS_COMPLETED));
}
/**
@@ -55,7 +59,7 @@ public class PaymentRequestJourneyLoggerUnitTest extends NativeLibraryTestBase {
@SmallTest
@Feature({"Payments"})
public void testRecordJourneyStatsHistograms_CanMakePaymentNotCalled_ShowAndAbort() {
- PaymentRequestJourneyLogger logger = new PaymentRequestJourneyLogger();
+ JourneyLogger logger = new JourneyLogger();
assertNoLogForCanMakePayment();
// The merchant does not query CanMakePayment, show the PaymentRequest and the user
@@ -64,15 +68,17 @@ public class PaymentRequestJourneyLoggerUnitTest extends NativeLibraryTestBase {
logger.recordJourneyStatsHistograms("Aborted");
// CanMakePayment was not used.
- assertEquals(1, RecordHistogram.getHistogramValueCountForTesting(
- "PaymentRequest.CanMakePayment.Usage",
- PaymentRequestJourneyLogger.CAN_MAKE_PAYMENT_NOT_USED));
+ assertEquals(1,
+ RecordHistogram.getHistogramValueCountForTesting(
+ "PaymentRequest.CanMakePayment.Usage",
+ JourneyLogger.CAN_MAKE_PAYMENT_NOT_USED));
// There should be a record for an abort when CanMakePayment is not used but the PR is shown
// to the user.
- assertEquals(1, RecordHistogram.getHistogramValueCountForTesting(
- "PaymentRequest.CanMakePayment.NotUsed.WithShowEffectOnCompletion",
- PaymentRequestJourneyLogger.COMPLETION_STATUS_ABORTED));
+ assertEquals(1,
+ RecordHistogram.getHistogramValueCountForTesting(
+ "PaymentRequest.CanMakePayment.NotUsed.WithShowEffectOnCompletion",
+ JourneyLogger.COMPLETION_STATUS_ABORTED));
}
/**
@@ -82,7 +88,7 @@ public class PaymentRequestJourneyLoggerUnitTest extends NativeLibraryTestBase {
@SmallTest
@Feature({"Payments"})
public void testRecordJourneyStatsHistograms_CanMakePaymentNotCalled_ShowAndComplete() {
- PaymentRequestJourneyLogger logger = new PaymentRequestJourneyLogger();
+ JourneyLogger logger = new JourneyLogger();
assertNoLogForCanMakePayment();
// The merchant does not query CanMakePayment, show the PaymentRequest and the user
@@ -91,15 +97,17 @@ public class PaymentRequestJourneyLoggerUnitTest extends NativeLibraryTestBase {
logger.recordJourneyStatsHistograms("Completed");
// CanMakePayment was not used.
- assertEquals(1, RecordHistogram.getHistogramValueCountForTesting(
- "PaymentRequest.CanMakePayment.Usage",
- PaymentRequestJourneyLogger.CAN_MAKE_PAYMENT_NOT_USED));
+ assertEquals(1,
+ RecordHistogram.getHistogramValueCountForTesting(
+ "PaymentRequest.CanMakePayment.Usage",
+ JourneyLogger.CAN_MAKE_PAYMENT_NOT_USED));
// There should be a record for a completion when CanMakePayment is not used but the PR is
// shown to the user.
- assertEquals(1, RecordHistogram.getHistogramValueCountForTesting(
- "PaymentRequest.CanMakePayment.NotUsed.WithShowEffectOnCompletion",
- PaymentRequestJourneyLogger.COMPLETION_STATUS_COMPLETED));
+ assertEquals(1,
+ RecordHistogram.getHistogramValueCountForTesting(
+ "PaymentRequest.CanMakePayment.NotUsed.WithShowEffectOnCompletion",
+ JourneyLogger.COMPLETION_STATUS_COMPLETED));
}
/**
@@ -109,7 +117,7 @@ public class PaymentRequestJourneyLoggerUnitTest extends NativeLibraryTestBase {
@SmallTest
@Feature({"Payments"})
public void testRecordJourneyStatsHistograms_CanMakePaymentCalled_FalseAndNoShow() {
- PaymentRequestJourneyLogger logger = new PaymentRequestJourneyLogger();
+ JourneyLogger logger = new JourneyLogger();
assertNoLogForCanMakePayment();
// The user cannot make payment and the PaymentRequest is not shown.
@@ -117,23 +125,26 @@ public class PaymentRequestJourneyLoggerUnitTest extends NativeLibraryTestBase {
logger.recordJourneyStatsHistograms("");
// CanMakePayment was used.
- assertEquals(1, RecordHistogram.getHistogramValueCountForTesting(
- "PaymentRequest.CanMakePayment.Usage",
- PaymentRequestJourneyLogger.CAN_MAKE_PAYMENT_USED));
+ assertEquals(1,
+ RecordHistogram.getHistogramValueCountForTesting(
+ "PaymentRequest.CanMakePayment.Usage",
+ JourneyLogger.CAN_MAKE_PAYMENT_USED));
// The CanMakePayment effect on show should be recorded as being false and not shown.
- assertEquals(1, RecordHistogram.getHistogramValueCountForTesting(
- "PaymentRequest.CanMakePayment.Used.EffetOnShow",
- PaymentRequestJourneyLogger
- .CMP_SHOW_COULD_NOT_MAKE_PAYMENT_AND_DID_NOT_SHOW));
+ assertEquals(1,
+ RecordHistogram.getHistogramValueCountForTesting(
+ "PaymentRequest.CanMakePayment.Used.EffectOnShow",
+ JourneyLogger.CMP_SHOW_COULD_NOT_MAKE_PAYMENT_AND_DID_NOT_SHOW));
// There should be no completion stats since PR was not shown to the user.
- assertEquals(0, RecordHistogram.getHistogramValueCountForTesting(
- "PaymentRequest.CanMakePayment.NotUsed.WithShowEffectOnCompletion",
- PaymentRequestJourneyLogger.COMPLETION_STATUS_ABORTED));
- assertEquals(0, RecordHistogram.getHistogramValueCountForTesting(
- "PaymentRequest.CanMakePayment.NotUsed.WithShowEffectOnCompletion",
- PaymentRequestJourneyLogger.COMPLETION_STATUS_COMPLETED));
+ assertEquals(0,
+ RecordHistogram.getHistogramValueCountForTesting(
+ "PaymentRequest.CanMakePayment.NotUsed.WithShowEffectOnCompletion",
+ JourneyLogger.COMPLETION_STATUS_ABORTED));
+ assertEquals(0,
+ RecordHistogram.getHistogramValueCountForTesting(
+ "PaymentRequest.CanMakePayment.NotUsed.WithShowEffectOnCompletion",
+ JourneyLogger.COMPLETION_STATUS_COMPLETED));
}
/**
@@ -143,7 +154,7 @@ public class PaymentRequestJourneyLoggerUnitTest extends NativeLibraryTestBase {
@SmallTest
@Feature({"Payments"})
public void testRecordJourneyStatsHistograms_CanMakePaymentCalled_TrueAndNoShow() {
- PaymentRequestJourneyLogger logger = new PaymentRequestJourneyLogger();
+ JourneyLogger logger = new JourneyLogger();
assertNoLogForCanMakePayment();
// The user can make a payment but the Payment Request is not shown.
@@ -151,22 +162,26 @@ public class PaymentRequestJourneyLoggerUnitTest extends NativeLibraryTestBase {
logger.recordJourneyStatsHistograms("");
// CanMakePayment was used.
- assertEquals(1, RecordHistogram.getHistogramValueCountForTesting(
- "PaymentRequest.CanMakePayment.Usage",
- PaymentRequestJourneyLogger.CAN_MAKE_PAYMENT_USED));
+ assertEquals(1,
+ RecordHistogram.getHistogramValueCountForTesting(
+ "PaymentRequest.CanMakePayment.Usage",
+ JourneyLogger.CAN_MAKE_PAYMENT_USED));
// The CanMakePayment effect on show should be recorded as being true and not shown.
- assertEquals(1, RecordHistogram.getHistogramValueCountForTesting(
- "PaymentRequest.CanMakePayment.Used.EffetOnShow",
- PaymentRequestJourneyLogger.CMP_SHOW_COULD_MAKE_PAYMENT));
+ assertEquals(1,
+ RecordHistogram.getHistogramValueCountForTesting(
+ "PaymentRequest.CanMakePayment.Used.EffectOnShow",
+ JourneyLogger.CMP_SHOW_COULD_MAKE_PAYMENT));
// There should be no completion stats since PR was not shown to the user.
- assertEquals(0, RecordHistogram.getHistogramValueCountForTesting(
- "PaymentRequest.CanMakePayment.NotUsed.WithShowEffectOnCompletion",
- PaymentRequestJourneyLogger.COMPLETION_STATUS_ABORTED));
- assertEquals(0, RecordHistogram.getHistogramValueCountForTesting(
- "PaymentRequest.CanMakePayment.NotUsed.WithShowEffectOnCompletion",
- PaymentRequestJourneyLogger.COMPLETION_STATUS_COMPLETED));
+ assertEquals(0,
+ RecordHistogram.getHistogramValueCountForTesting(
+ "PaymentRequest.CanMakePayment.NotUsed.WithShowEffectOnCompletion",
+ JourneyLogger.COMPLETION_STATUS_ABORTED));
+ assertEquals(0,
+ RecordHistogram.getHistogramValueCountForTesting(
+ "PaymentRequest.CanMakePayment.NotUsed.WithShowEffectOnCompletion",
+ JourneyLogger.COMPLETION_STATUS_COMPLETED));
}
/**
@@ -176,7 +191,7 @@ public class PaymentRequestJourneyLoggerUnitTest extends NativeLibraryTestBase {
@SmallTest
@Feature({"Payments"})
public void testRecordJourneyStatsHistograms_CanMakePaymentCalled_FalseShowAndAbort() {
- PaymentRequestJourneyLogger logger = new PaymentRequestJourneyLogger();
+ JourneyLogger logger = new JourneyLogger();
assertNoLogForCanMakePayment();
// The user cannot make a payment. the payment request is shown but aborted.
@@ -185,21 +200,23 @@ public class PaymentRequestJourneyLoggerUnitTest extends NativeLibraryTestBase {
logger.recordJourneyStatsHistograms("Aborted");
// CanMakePayment was used.
- assertEquals(1, RecordHistogram.getHistogramValueCountForTesting(
- "PaymentRequest.CanMakePayment.Usage",
- PaymentRequestJourneyLogger.CAN_MAKE_PAYMENT_USED));
+ assertEquals(1,
+ RecordHistogram.getHistogramValueCountForTesting(
+ "PaymentRequest.CanMakePayment.Usage",
+ JourneyLogger.CAN_MAKE_PAYMENT_USED));
// The CanMakePayment effect on show should be recorded as being true and not shown.
- assertEquals(1, RecordHistogram.getHistogramValueCountForTesting(
- "PaymentRequest.CanMakePayment.Used.EffetOnShow",
- PaymentRequestJourneyLogger.CMP_SHOW_DID_SHOW));
+ assertEquals(1,
+ RecordHistogram.getHistogramValueCountForTesting(
+ "PaymentRequest.CanMakePayment.Used.EffectOnShow",
+ JourneyLogger.CMP_SHOW_DID_SHOW));
// There should be a record for an abort when CanMakePayment is false but the PR is shown to
// the user.
- assertEquals(
- 1, RecordHistogram.getHistogramValueCountForTesting(
- "PaymentRequest.CanMakePayment.Used.FalseWithShowEffectOnCompletion",
- PaymentRequestJourneyLogger.COMPLETION_STATUS_ABORTED));
+ assertEquals(1,
+ RecordHistogram.getHistogramValueCountForTesting(
+ "PaymentRequest.CanMakePayment.Used.FalseWithShowEffectOnCompletion",
+ JourneyLogger.COMPLETION_STATUS_ABORTED));
}
/**
@@ -209,7 +226,7 @@ public class PaymentRequestJourneyLoggerUnitTest extends NativeLibraryTestBase {
@SmallTest
@Feature({"Payments"})
public void testRecordJourneyStatsHistograms_CanMakePaymentCalled_FalseShowAndComplete() {
- PaymentRequestJourneyLogger logger = new PaymentRequestJourneyLogger();
+ JourneyLogger logger = new JourneyLogger();
assertNoLogForCanMakePayment();
// The user cannot make a payment. the payment request is shown and completed.
@@ -218,21 +235,23 @@ public class PaymentRequestJourneyLoggerUnitTest extends NativeLibraryTestBase {
logger.recordJourneyStatsHistograms("Completed");
// CanMakePayment was used.
- assertEquals(1, RecordHistogram.getHistogramValueCountForTesting(
- "PaymentRequest.CanMakePayment.Usage",
- PaymentRequestJourneyLogger.CAN_MAKE_PAYMENT_USED));
+ assertEquals(1,
+ RecordHistogram.getHistogramValueCountForTesting(
+ "PaymentRequest.CanMakePayment.Usage",
+ JourneyLogger.CAN_MAKE_PAYMENT_USED));
// The CanMakePayment effect on show should be recorded as being true and not shown.
- assertEquals(1, RecordHistogram.getHistogramValueCountForTesting(
- "PaymentRequest.CanMakePayment.Used.EffetOnShow",
- PaymentRequestJourneyLogger.CMP_SHOW_DID_SHOW));
+ assertEquals(1,
+ RecordHistogram.getHistogramValueCountForTesting(
+ "PaymentRequest.CanMakePayment.Used.EffectOnShow",
+ JourneyLogger.CMP_SHOW_DID_SHOW));
// There should be a record for a completion when CanMakePayment is false and the PR is
// shown to the user.
- assertEquals(
- 1, RecordHistogram.getHistogramValueCountForTesting(
- "PaymentRequest.CanMakePayment.Used.FalseWithShowEffectOnCompletion",
- PaymentRequestJourneyLogger.COMPLETION_STATUS_COMPLETED));
+ assertEquals(1,
+ RecordHistogram.getHistogramValueCountForTesting(
+ "PaymentRequest.CanMakePayment.Used.FalseWithShowEffectOnCompletion",
+ JourneyLogger.COMPLETION_STATUS_COMPLETED));
}
/**
@@ -242,7 +261,7 @@ public class PaymentRequestJourneyLoggerUnitTest extends NativeLibraryTestBase {
@SmallTest
@Feature({"Payments"})
public void testRecordJourneyStatsHistograms_CanMakePaymentCalled_TrueShowAndAbort() {
- PaymentRequestJourneyLogger logger = new PaymentRequestJourneyLogger();
+ JourneyLogger logger = new JourneyLogger();
assertNoLogForCanMakePayment();
// The user cannot make a payment. the payment request is shown and completed.
@@ -251,21 +270,24 @@ public class PaymentRequestJourneyLoggerUnitTest extends NativeLibraryTestBase {
logger.recordJourneyStatsHistograms("Aborted");
// CanMakePayment was used.
- assertEquals(1, RecordHistogram.getHistogramValueCountForTesting(
- "PaymentRequest.CanMakePayment.Usage",
- PaymentRequestJourneyLogger.CAN_MAKE_PAYMENT_USED));
+ assertEquals(1,
+ RecordHistogram.getHistogramValueCountForTesting(
+ "PaymentRequest.CanMakePayment.Usage",
+ JourneyLogger.CAN_MAKE_PAYMENT_USED));
// The CanMakePayment effect on show should be recorded as being true and not shown.
- assertEquals(1, RecordHistogram.getHistogramValueCountForTesting(
- "PaymentRequest.CanMakePayment.Used.EffetOnShow",
- PaymentRequestJourneyLogger.CMP_SHOW_DID_SHOW
- | PaymentRequestJourneyLogger.CMP_SHOW_COULD_MAKE_PAYMENT));
+ assertEquals(1,
+ RecordHistogram.getHistogramValueCountForTesting(
+ "PaymentRequest.CanMakePayment.Used.EffectOnShow",
+ JourneyLogger.CMP_SHOW_DID_SHOW
+ | JourneyLogger.CMP_SHOW_COULD_MAKE_PAYMENT));
// There should be a record for an abort when CanMakePayment is true and the PR is shown to
// the user.
- assertEquals(1, RecordHistogram.getHistogramValueCountForTesting(
- "PaymentRequest.CanMakePayment.Used.TrueWithShowEffectOnCompletion",
- PaymentRequestJourneyLogger.COMPLETION_STATUS_ABORTED));
+ assertEquals(1,
+ RecordHistogram.getHistogramValueCountForTesting(
+ "PaymentRequest.CanMakePayment.Used.TrueWithShowEffectOnCompletion",
+ JourneyLogger.COMPLETION_STATUS_ABORTED));
}
/**
@@ -275,7 +297,7 @@ public class PaymentRequestJourneyLoggerUnitTest extends NativeLibraryTestBase {
@SmallTest
@Feature({"Payments"})
public void testRecordJourneyStatsHistograms_CanMakePaymentCalled_TrueShowAndComplete() {
- PaymentRequestJourneyLogger logger = new PaymentRequestJourneyLogger();
+ JourneyLogger logger = new JourneyLogger();
assertNoLogForCanMakePayment();
// The user cannot make a payment. the payment request is shown and completed.
@@ -284,21 +306,24 @@ public class PaymentRequestJourneyLoggerUnitTest extends NativeLibraryTestBase {
logger.recordJourneyStatsHistograms("Completed");
// CanMakePayment was used.
- assertEquals(1, RecordHistogram.getHistogramValueCountForTesting(
- "PaymentRequest.CanMakePayment.Usage",
- PaymentRequestJourneyLogger.CAN_MAKE_PAYMENT_USED));
+ assertEquals(1,
+ RecordHistogram.getHistogramValueCountForTesting(
+ "PaymentRequest.CanMakePayment.Usage",
+ JourneyLogger.CAN_MAKE_PAYMENT_USED));
// The CanMakePayment effect on show should be recorded as being true and not shown.
- assertEquals(1, RecordHistogram.getHistogramValueCountForTesting(
- "PaymentRequest.CanMakePayment.Used.EffetOnShow",
- PaymentRequestJourneyLogger.CMP_SHOW_DID_SHOW
- | PaymentRequestJourneyLogger.CMP_SHOW_COULD_MAKE_PAYMENT));
+ assertEquals(1,
+ RecordHistogram.getHistogramValueCountForTesting(
+ "PaymentRequest.CanMakePayment.Used.EffectOnShow",
+ JourneyLogger.CMP_SHOW_DID_SHOW
+ | JourneyLogger.CMP_SHOW_COULD_MAKE_PAYMENT));
// There should be a record for a completion when CanMakePayment is true and the PR is shown
// to the user.
- assertEquals(1, RecordHistogram.getHistogramValueCountForTesting(
- "PaymentRequest.CanMakePayment.Used.TrueWithShowEffectOnCompletion",
- PaymentRequestJourneyLogger.COMPLETION_STATUS_COMPLETED));
+ assertEquals(1,
+ RecordHistogram.getHistogramValueCountForTesting(
+ "PaymentRequest.CanMakePayment.Used.TrueWithShowEffectOnCompletion",
+ JourneyLogger.COMPLETION_STATUS_COMPLETED));
}
/**
@@ -308,23 +333,24 @@ public class PaymentRequestJourneyLoggerUnitTest extends NativeLibraryTestBase {
@SmallTest
@Feature({"Payments"})
public void testRecordJourneyStatsHistograms_SuggestionsForEverything_Completed() {
- PaymentRequestJourneyLogger logger = new PaymentRequestJourneyLogger();
+ JourneyLogger logger = new JourneyLogger();
// Simulate that the user had suggestions for all the requested sections.
- logger.setNumberOfSuggestionsShown(PaymentRequestJourneyLogger.SECTION_CREDIT_CARDS, 1);
+ logger.setNumberOfSuggestionsShown(JourneyLogger.SECTION_CREDIT_CARDS, 1);
// Simulate that the user completes the checkout.
logger.recordJourneyStatsHistograms("Completed");
// Make sure the appropriate metric was logged.
- assertEquals(1, RecordHistogram.getHistogramValueCountForTesting(
- "PaymentRequest.UserHadSuggestionsForEverything.EffectOnCompletion",
- PaymentRequestJourneyLogger.COMPLETION_STATUS_COMPLETED));
+ assertEquals(1,
+ RecordHistogram.getHistogramValueCountForTesting(
+ "PaymentRequest.UserHadSuggestionsForEverything.EffectOnCompletion",
+ JourneyLogger.COMPLETION_STATUS_COMPLETED));
assertEquals(0,
RecordHistogram.getHistogramValueCountForTesting(
"PaymentRequest.UserDidNotHaveSuggestionsForEverything.EffectOnCompletion",
- PaymentRequestJourneyLogger.COMPLETION_STATUS_COMPLETED));
+ JourneyLogger.COMPLETION_STATUS_COMPLETED));
}
/**
@@ -334,23 +360,24 @@ public class PaymentRequestJourneyLoggerUnitTest extends NativeLibraryTestBase {
@SmallTest
@Feature({"Payments"})
public void testRecordJourneyStatsHistograms_SuggestionsForEverything_Aborted() {
- PaymentRequestJourneyLogger logger = new PaymentRequestJourneyLogger();
+ JourneyLogger logger = new JourneyLogger();
// Simulate that the user had suggestions for all the requested sections.
- logger.setNumberOfSuggestionsShown(PaymentRequestJourneyLogger.SECTION_CREDIT_CARDS, 1);
+ logger.setNumberOfSuggestionsShown(JourneyLogger.SECTION_CREDIT_CARDS, 1);
// Simulate that the user aborts the checkout.
logger.recordJourneyStatsHistograms("Aborted");
// Make sure the appropriate metric was logged.
- assertEquals(1, RecordHistogram.getHistogramValueCountForTesting(
- "PaymentRequest.UserHadSuggestionsForEverything.EffectOnCompletion",
- PaymentRequestJourneyLogger.COMPLETION_STATUS_ABORTED));
+ assertEquals(1,
+ RecordHistogram.getHistogramValueCountForTesting(
+ "PaymentRequest.UserHadSuggestionsForEverything.EffectOnCompletion",
+ JourneyLogger.COMPLETION_STATUS_ABORTED));
assertEquals(0,
RecordHistogram.getHistogramValueCountForTesting(
"PaymentRequest.UserDidNotHaveSuggestionsForEverything.EffectOnCompletion",
- PaymentRequestJourneyLogger.COMPLETION_STATUS_ABORTED));
+ JourneyLogger.COMPLETION_STATUS_ABORTED));
}
/**
@@ -360,10 +387,10 @@ public class PaymentRequestJourneyLoggerUnitTest extends NativeLibraryTestBase {
@SmallTest
@Feature({"Payments"})
public void testRecordJourneyStatsHistograms_NoSuggestionsForEverything_Completed() {
- PaymentRequestJourneyLogger logger = new PaymentRequestJourneyLogger();
+ JourneyLogger logger = new JourneyLogger();
// Simulate that the user did not have suggestions for all the requested sections.
- logger.setNumberOfSuggestionsShown(PaymentRequestJourneyLogger.SECTION_CREDIT_CARDS, 0);
+ logger.setNumberOfSuggestionsShown(JourneyLogger.SECTION_CREDIT_CARDS, 0);
// Simulate that the user completes the checkout.
logger.recordJourneyStatsHistograms("Completed");
@@ -372,11 +399,12 @@ public class PaymentRequestJourneyLoggerUnitTest extends NativeLibraryTestBase {
assertEquals(1,
RecordHistogram.getHistogramValueCountForTesting(
"PaymentRequest.UserDidNotHaveSuggestionsForEverything.EffectOnCompletion",
- PaymentRequestJourneyLogger.COMPLETION_STATUS_COMPLETED));
+ JourneyLogger.COMPLETION_STATUS_COMPLETED));
- assertEquals(0, RecordHistogram.getHistogramValueCountForTesting(
- "PaymentRequest.UserHadSuggestionsForEverything.EffectOnCompletion",
- PaymentRequestJourneyLogger.COMPLETION_STATUS_COMPLETED));
+ assertEquals(0,
+ RecordHistogram.getHistogramValueCountForTesting(
+ "PaymentRequest.UserHadSuggestionsForEverything.EffectOnCompletion",
+ JourneyLogger.COMPLETION_STATUS_COMPLETED));
}
/**
@@ -386,10 +414,10 @@ public class PaymentRequestJourneyLoggerUnitTest extends NativeLibraryTestBase {
@SmallTest
@Feature({"Payments"})
public void testRecordJourneyStatsHistograms_NoSuggestionsForEverything_Aborted() {
- PaymentRequestJourneyLogger logger = new PaymentRequestJourneyLogger();
+ JourneyLogger logger = new JourneyLogger();
- // Simulate that the user had suggestions for all the requested sections.
- logger.setNumberOfSuggestionsShown(PaymentRequestJourneyLogger.SECTION_CREDIT_CARDS, 0);
+ // Simulate that the user did not have suggestions for all the requested sections.
+ logger.setNumberOfSuggestionsShown(JourneyLogger.SECTION_CREDIT_CARDS, 0);
// Simulate that the user aborts the checkout.
logger.recordJourneyStatsHistograms("Aborted");
@@ -398,11 +426,63 @@ public class PaymentRequestJourneyLoggerUnitTest extends NativeLibraryTestBase {
assertEquals(1,
RecordHistogram.getHistogramValueCountForTesting(
"PaymentRequest.UserDidNotHaveSuggestionsForEverything.EffectOnCompletion",
- PaymentRequestJourneyLogger.COMPLETION_STATUS_ABORTED));
+ JourneyLogger.COMPLETION_STATUS_ABORTED));
+
+ assertEquals(0,
+ RecordHistogram.getHistogramValueCountForTesting(
+ "PaymentRequest.UserHadSuggestionsForEverything.EffectOnCompletion",
+ JourneyLogger.COMPLETION_STATUS_ABORTED));
+ }
+
+ /**
+ * Tests that the metrics are logged correctly for two simultaneous Payment Requests.
+ */
+ @SmallTest
+ @Feature({"Payments"})
+ public void testRecordJourneyStatsHistograms_TwoPaymentRequests() {
+ JourneyLogger logger1 = new JourneyLogger();
+ JourneyLogger logger2 = new JourneyLogger();
+
+ // Make the two loggers have different data.
+ logger1.setShowCalled();
+ logger2.setShowCalled();
+
+ logger1.setCanMakePaymentValue(true);
+
+ logger1.setNumberOfSuggestionsShown(JourneyLogger.SECTION_CREDIT_CARDS, 1);
+ logger2.setNumberOfSuggestionsShown(JourneyLogger.SECTION_CREDIT_CARDS, 0);
+
+ // Simulate that the user completes one checkout and aborts the other.
+ logger1.recordJourneyStatsHistograms("Completed");
+ logger2.recordJourneyStatsHistograms("Aborted");
- assertEquals(0, RecordHistogram.getHistogramValueCountForTesting(
- "PaymentRequest.UserHadSuggestionsForEverything.EffectOnCompletion",
- PaymentRequestJourneyLogger.COMPLETION_STATUS_ABORTED));
+ // Make sure the appropriate metric was logged for logger1.
+ assertEquals(1,
+ RecordHistogram.getHistogramValueCountForTesting(
+ "PaymentRequest.UserHadSuggestionsForEverything.EffectOnCompletion",
+ JourneyLogger.COMPLETION_STATUS_COMPLETED));
+ assertEquals(1,
+ RecordHistogram.getHistogramValueCountForTesting(
+ "PaymentRequest.CanMakePayment.Usage",
+ JourneyLogger.CAN_MAKE_PAYMENT_USED));
+ assertEquals(1,
+ RecordHistogram.getHistogramValueCountForTesting(
+ "PaymentRequest.CanMakePayment.Used.TrueWithShowEffectOnCompletion",
+ JourneyLogger.COMPLETION_STATUS_COMPLETED));
+
+ // Make sure the appropriate metric was logged for logger2.
+ assertEquals(1,
+ RecordHistogram.getHistogramValueCountForTesting(
+ "PaymentRequest.UserDidNotHaveSuggestionsForEverything.EffectOnCompletion",
+ JourneyLogger.COMPLETION_STATUS_ABORTED));
+ assertEquals(1,
+ RecordHistogram.getHistogramValueCountForTesting(
+ "PaymentRequest.CanMakePayment.Usage",
+ JourneyLogger.CAN_MAKE_PAYMENT_NOT_USED));
+ assertEquals(1,
+ RecordHistogram.getHistogramValueCountForTesting(
+ "PaymentRequest.CanMakePayment.NotUsed.WithShowEffectOnCompletion",
+ JourneyLogger.COMPLETION_STATUS_ABORTED));
}
/**
@@ -410,19 +490,20 @@ public class PaymentRequestJourneyLoggerUnitTest extends NativeLibraryTestBase {
*/
private void assertNoLogForCanMakePayment() {
// Use stats.
- for (int i = 0; i < PaymentRequestJourneyLogger.CAN_MAKE_PAYMENT_USE_MAX; ++i) {
+ for (int i = 0; i < JourneyLogger.CAN_MAKE_PAYMENT_USE_MAX; ++i) {
assertEquals(0, RecordHistogram.getHistogramValueCountForTesting(
"PaymentRequest.CanMakePayment.Usage", i));
}
// Effect on show stats.
- for (int i = 0; i < PaymentRequestJourneyLogger.CMP_SHOW_MAX; ++i) {
- assertEquals(0, RecordHistogram.getHistogramValueCountForTesting(
- "PaymentRequest.CanMakePayment.Used.EffetOnShow", i));
+ for (int i = 0; i < JourneyLogger.CMP_SHOW_MAX; ++i) {
+ assertEquals(0,
+ RecordHistogram.getHistogramValueCountForTesting(
+ "PaymentRequest.CanMakePayment.Used.EffectOnShow", i));
}
// Effect on completion stats.
- for (int i = 0; i < PaymentRequestJourneyLogger.COMPLETION_STATUS_MAX; ++i) {
+ for (int i = 0; i < JourneyLogger.COMPLETION_STATUS_MAX; ++i) {
assertEquals(0,
RecordHistogram.getHistogramValueCountForTesting(
"PaymentRequest.CanMakePayment.NotUsed.WithShowEffectOnCompletion", i));

Powered by Google App Engine
This is Rietveld 408576698