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

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

Issue 2685623002: [Payments] Add completion metrics based on user had suggestions for all. (Closed)
Patch Set: Created 3 years, 10 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 unified diff | Download patch
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 package org.chromium.chrome.browser.payments; 5 package org.chromium.chrome.browser.payments;
6 6
7 import android.support.test.filters.SmallTest; 7 import android.support.test.filters.SmallTest;
8 8
9 import org.chromium.base.metrics.RecordHistogram; 9 import org.chromium.base.metrics.RecordHistogram;
10 import org.chromium.base.test.util.Feature; 10 import org.chromium.base.test.util.Feature;
(...skipping 24 matching lines...) Expand all
35 logger.recordJourneyStatsHistograms(""); 35 logger.recordJourneyStatsHistograms("");
36 36
37 // CanMakePayment was not used. 37 // CanMakePayment was not used.
38 assertEquals(1, RecordHistogram.getHistogramValueCountForTesting( 38 assertEquals(1, RecordHistogram.getHistogramValueCountForTesting(
39 "PaymentRequest.CanMakePayment.Usage", 39 "PaymentRequest.CanMakePayment.Usage",
40 PaymentRequestJourneyLogger.CAN_MAKE_PAYMENT_NOT _USED)); 40 PaymentRequestJourneyLogger.CAN_MAKE_PAYMENT_NOT _USED));
41 41
42 // There should be no completion stats since PR was not shown to the use r 42 // There should be no completion stats since PR was not shown to the use r
43 assertEquals(0, RecordHistogram.getHistogramValueCountForTesting( 43 assertEquals(0, RecordHistogram.getHistogramValueCountForTesting(
44 "PaymentRequest.CanMakePayment.NotUsed.WithShowE ffectOnCompletion", 44 "PaymentRequest.CanMakePayment.NotUsed.WithShowE ffectOnCompletion",
45 PaymentRequestJourneyLogger.CMP_EFFECT_ON_COMPLE TION_ABORTED)); 45 PaymentRequestJourneyLogger.COMPLETION_STATUS_AB ORTED));
46 assertEquals(0, RecordHistogram.getHistogramValueCountForTesting( 46 assertEquals(0, RecordHistogram.getHistogramValueCountForTesting(
47 "PaymentRequest.CanMakePayment.NotUsed.WithShowE ffectOnCompletion", 47 "PaymentRequest.CanMakePayment.NotUsed.WithShowE ffectOnCompletion",
48 PaymentRequestJourneyLogger.CMP_EFFECT_ON_COMPLE TION_COMPLETED)); 48 PaymentRequestJourneyLogger.COMPLETION_STATUS_CO MPLETED));
49 } 49 }
50 50
51 /** 51 /**
52 * Tests the canMakePayment stats for the case where the merchant does not u se it and the 52 * Tests the canMakePayment stats for the case where the merchant does not u se it and the
53 * transaction is aborted. 53 * transaction is aborted.
54 */ 54 */
55 @SmallTest 55 @SmallTest
56 @Feature({"Payments"}) 56 @Feature({"Payments"})
57 public void testRecordJourneyStatsHistograms_CanMakePaymentNotCalled_ShowAnd Abort() { 57 public void testRecordJourneyStatsHistograms_CanMakePaymentNotCalled_ShowAnd Abort() {
58 PaymentRequestJourneyLogger logger = new PaymentRequestJourneyLogger(); 58 PaymentRequestJourneyLogger logger = new PaymentRequestJourneyLogger();
59 assertNoLogForCanMakePayment(); 59 assertNoLogForCanMakePayment();
60 60
61 // The merchant does not query CanMakePayment, show the PaymentRequest a nd the user 61 // The merchant does not query CanMakePayment, show the PaymentRequest a nd the user
62 // aborts it. 62 // aborts it.
63 logger.setShowCalled(); 63 logger.setShowCalled();
64 logger.recordJourneyStatsHistograms("Aborted"); 64 logger.recordJourneyStatsHistograms("Aborted");
65 65
66 // CanMakePayment was not used. 66 // CanMakePayment was not used.
67 assertEquals(1, RecordHistogram.getHistogramValueCountForTesting( 67 assertEquals(1, RecordHistogram.getHistogramValueCountForTesting(
68 "PaymentRequest.CanMakePayment.Usage", 68 "PaymentRequest.CanMakePayment.Usage",
69 PaymentRequestJourneyLogger.CAN_MAKE_PAYMENT_NOT _USED)); 69 PaymentRequestJourneyLogger.CAN_MAKE_PAYMENT_NOT _USED));
70 70
71 // There should be a record for an abort when CanMakePayment is not used but the PR is shown 71 // There should be a record for an abort when CanMakePayment is not used but the PR is shown
72 // to the user. 72 // to the user.
73 assertEquals(1, RecordHistogram.getHistogramValueCountForTesting( 73 assertEquals(1, RecordHistogram.getHistogramValueCountForTesting(
74 "PaymentRequest.CanMakePayment.NotUsed.WithShowE ffectOnCompletion", 74 "PaymentRequest.CanMakePayment.NotUsed.WithShowE ffectOnCompletion",
75 PaymentRequestJourneyLogger.CMP_EFFECT_ON_COMPLE TION_ABORTED)); 75 PaymentRequestJourneyLogger.COMPLETION_STATUS_AB ORTED));
76 } 76 }
77 77
78 /** 78 /**
79 * Tests the canMakePayment stats for the case where the merchant does not u se it and the 79 * Tests the canMakePayment stats for the case where the merchant does not u se it and the
80 * transaction is completed. 80 * transaction is completed.
81 */ 81 */
82 @SmallTest 82 @SmallTest
83 @Feature({"Payments"}) 83 @Feature({"Payments"})
84 public void testRecordJourneyStatsHistograms_CanMakePaymentNotCalled_ShowAnd Complete() { 84 public void testRecordJourneyStatsHistograms_CanMakePaymentNotCalled_ShowAnd Complete() {
85 PaymentRequestJourneyLogger logger = new PaymentRequestJourneyLogger(); 85 PaymentRequestJourneyLogger logger = new PaymentRequestJourneyLogger();
86 assertNoLogForCanMakePayment(); 86 assertNoLogForCanMakePayment();
87 87
88 // The merchant does not query CanMakePayment, show the PaymentRequest a nd the user 88 // The merchant does not query CanMakePayment, show the PaymentRequest a nd the user
89 // completes it. 89 // completes it.
90 logger.setShowCalled(); 90 logger.setShowCalled();
91 logger.recordJourneyStatsHistograms("Completed"); 91 logger.recordJourneyStatsHistograms("Completed");
92 92
93 // CanMakePayment was not used. 93 // CanMakePayment was not used.
94 assertEquals(1, RecordHistogram.getHistogramValueCountForTesting( 94 assertEquals(1, RecordHistogram.getHistogramValueCountForTesting(
95 "PaymentRequest.CanMakePayment.Usage", 95 "PaymentRequest.CanMakePayment.Usage",
96 PaymentRequestJourneyLogger.CAN_MAKE_PAYMENT_NOT _USED)); 96 PaymentRequestJourneyLogger.CAN_MAKE_PAYMENT_NOT _USED));
97 97
98 // There should be a record for a completion when CanMakePayment is not used but the PR is 98 // There should be a record for a completion when CanMakePayment is not used but the PR is
99 // shown to the user. 99 // shown to the user.
100 assertEquals(1, RecordHistogram.getHistogramValueCountForTesting( 100 assertEquals(1, RecordHistogram.getHistogramValueCountForTesting(
101 "PaymentRequest.CanMakePayment.NotUsed.WithShowE ffectOnCompletion", 101 "PaymentRequest.CanMakePayment.NotUsed.WithShowE ffectOnCompletion",
102 PaymentRequestJourneyLogger.CMP_EFFECT_ON_COMPLE TION_COMPLETED)); 102 PaymentRequestJourneyLogger.COMPLETION_STATUS_CO MPLETED));
103 } 103 }
104 104
105 /** 105 /**
106 * Tests the canMakePayment stats for the case where the merchant uses it, r eturns false and 106 * Tests the canMakePayment stats for the case where the merchant uses it, r eturns false and
107 * show is not called. 107 * show is not called.
108 */ 108 */
109 @SmallTest 109 @SmallTest
110 @Feature({"Payments"}) 110 @Feature({"Payments"})
111 public void testRecordJourneyStatsHistograms_CanMakePaymentCalled_FalseAndNo Show() { 111 public void testRecordJourneyStatsHistograms_CanMakePaymentCalled_FalseAndNo Show() {
112 PaymentRequestJourneyLogger logger = new PaymentRequestJourneyLogger(); 112 PaymentRequestJourneyLogger logger = new PaymentRequestJourneyLogger();
(...skipping 10 matching lines...) Expand all
123 123
124 // The CanMakePayment effect on show should be recorded as being false a nd not shown. 124 // The CanMakePayment effect on show should be recorded as being false a nd not shown.
125 assertEquals(1, RecordHistogram.getHistogramValueCountForTesting( 125 assertEquals(1, RecordHistogram.getHistogramValueCountForTesting(
126 "PaymentRequest.CanMakePayment.Used.EffetOnShow" , 126 "PaymentRequest.CanMakePayment.Used.EffetOnShow" ,
127 PaymentRequestJourneyLogger 127 PaymentRequestJourneyLogger
128 .CMP_SHOW_COULD_NOT_MAKE_PAYMENT_AND_DID _NOT_SHOW)); 128 .CMP_SHOW_COULD_NOT_MAKE_PAYMENT_AND_DID _NOT_SHOW));
129 129
130 // There should be no completion stats since PR was not shown to the use r. 130 // There should be no completion stats since PR was not shown to the use r.
131 assertEquals(0, RecordHistogram.getHistogramValueCountForTesting( 131 assertEquals(0, RecordHistogram.getHistogramValueCountForTesting(
132 "PaymentRequest.CanMakePayment.NotUsed.WithShowE ffectOnCompletion", 132 "PaymentRequest.CanMakePayment.NotUsed.WithShowE ffectOnCompletion",
133 PaymentRequestJourneyLogger.CMP_EFFECT_ON_COMPLE TION_ABORTED)); 133 PaymentRequestJourneyLogger.COMPLETION_STATUS_AB ORTED));
134 assertEquals(0, RecordHistogram.getHistogramValueCountForTesting( 134 assertEquals(0, RecordHistogram.getHistogramValueCountForTesting(
135 "PaymentRequest.CanMakePayment.NotUsed.WithShowE ffectOnCompletion", 135 "PaymentRequest.CanMakePayment.NotUsed.WithShowE ffectOnCompletion",
136 PaymentRequestJourneyLogger.CMP_EFFECT_ON_COMPLE TION_COMPLETED)); 136 PaymentRequestJourneyLogger.COMPLETION_STATUS_CO MPLETED));
137 } 137 }
138 138
139 /** 139 /**
140 * Tests the canMakePayment stats for the case where the merchant uses it, r eturns true and 140 * Tests the canMakePayment stats for the case where the merchant uses it, r eturns true and
141 * show is not called. 141 * show is not called.
142 */ 142 */
143 @SmallTest 143 @SmallTest
144 @Feature({"Payments"}) 144 @Feature({"Payments"})
145 public void testRecordJourneyStatsHistograms_CanMakePaymentCalled_TrueAndNoS how() { 145 public void testRecordJourneyStatsHistograms_CanMakePaymentCalled_TrueAndNoS how() {
146 PaymentRequestJourneyLogger logger = new PaymentRequestJourneyLogger(); 146 PaymentRequestJourneyLogger logger = new PaymentRequestJourneyLogger();
147 assertNoLogForCanMakePayment(); 147 assertNoLogForCanMakePayment();
148 148
149 // The user can make a payment but the Payment Request is not shown. 149 // The user can make a payment but the Payment Request is not shown.
150 logger.setCanMakePaymentValue(true); 150 logger.setCanMakePaymentValue(true);
151 logger.recordJourneyStatsHistograms(""); 151 logger.recordJourneyStatsHistograms("");
152 152
153 // CanMakePayment was used. 153 // CanMakePayment was used.
154 assertEquals(1, RecordHistogram.getHistogramValueCountForTesting( 154 assertEquals(1, RecordHistogram.getHistogramValueCountForTesting(
155 "PaymentRequest.CanMakePayment.Usage", 155 "PaymentRequest.CanMakePayment.Usage",
156 PaymentRequestJourneyLogger.CAN_MAKE_PAYMENT_USE D)); 156 PaymentRequestJourneyLogger.CAN_MAKE_PAYMENT_USE D));
157 157
158 // The CanMakePayment effect on show should be recorded as being true an d not shown. 158 // The CanMakePayment effect on show should be recorded as being true an d not shown.
159 assertEquals(1, RecordHistogram.getHistogramValueCountForTesting( 159 assertEquals(1, RecordHistogram.getHistogramValueCountForTesting(
160 "PaymentRequest.CanMakePayment.Used.EffetOnShow" , 160 "PaymentRequest.CanMakePayment.Used.EffetOnShow" ,
161 PaymentRequestJourneyLogger.CMP_SHOW_COULD_MAKE_ PAYMENT)); 161 PaymentRequestJourneyLogger.CMP_SHOW_COULD_MAKE_ PAYMENT));
162 162
163 // There should be no completion stats since PR was not shown to the use r. 163 // There should be no completion stats since PR was not shown to the use r.
164 assertEquals(0, RecordHistogram.getHistogramValueCountForTesting( 164 assertEquals(0, RecordHistogram.getHistogramValueCountForTesting(
165 "PaymentRequest.CanMakePayment.NotUsed.WithShowE ffectOnCompletion", 165 "PaymentRequest.CanMakePayment.NotUsed.WithShowE ffectOnCompletion",
166 PaymentRequestJourneyLogger.CMP_EFFECT_ON_COMPLE TION_ABORTED)); 166 PaymentRequestJourneyLogger.COMPLETION_STATUS_AB ORTED));
167 assertEquals(0, RecordHistogram.getHistogramValueCountForTesting( 167 assertEquals(0, RecordHistogram.getHistogramValueCountForTesting(
168 "PaymentRequest.CanMakePayment.NotUsed.WithShowE ffectOnCompletion", 168 "PaymentRequest.CanMakePayment.NotUsed.WithShowE ffectOnCompletion",
169 PaymentRequestJourneyLogger.CMP_EFFECT_ON_COMPLE TION_COMPLETED)); 169 PaymentRequestJourneyLogger.COMPLETION_STATUS_CO MPLETED));
170 } 170 }
171 171
172 /** 172 /**
173 * Tests the canMakePayment stats for the case where the merchant uses it, r eturns false, show 173 * Tests the canMakePayment stats for the case where the merchant uses it, r eturns false, show
174 * is called but the transaction is aborted. 174 * is called but the transaction is aborted.
175 */ 175 */
176 @SmallTest 176 @SmallTest
177 @Feature({"Payments"}) 177 @Feature({"Payments"})
178 public void testRecordJourneyStatsHistograms_CanMakePaymentCalled_FalseShowA ndAbort() { 178 public void testRecordJourneyStatsHistograms_CanMakePaymentCalled_FalseShowA ndAbort() {
179 PaymentRequestJourneyLogger logger = new PaymentRequestJourneyLogger(); 179 PaymentRequestJourneyLogger logger = new PaymentRequestJourneyLogger();
(...skipping 12 matching lines...) Expand all
192 // The CanMakePayment effect on show should be recorded as being true an d not shown. 192 // The CanMakePayment effect on show should be recorded as being true an d not shown.
193 assertEquals(1, RecordHistogram.getHistogramValueCountForTesting( 193 assertEquals(1, RecordHistogram.getHistogramValueCountForTesting(
194 "PaymentRequest.CanMakePayment.Used.EffetOnShow" , 194 "PaymentRequest.CanMakePayment.Used.EffetOnShow" ,
195 PaymentRequestJourneyLogger.CMP_SHOW_DID_SHOW)); 195 PaymentRequestJourneyLogger.CMP_SHOW_DID_SHOW));
196 196
197 // There should be a record for an abort when CanMakePayment is false bu t the PR is shown to 197 // There should be a record for an abort when CanMakePayment is false bu t the PR is shown to
198 // the user. 198 // the user.
199 assertEquals( 199 assertEquals(
200 1, RecordHistogram.getHistogramValueCountForTesting( 200 1, RecordHistogram.getHistogramValueCountForTesting(
201 "PaymentRequest.CanMakePayment.Used.FalseWithShowEffe ctOnCompletion", 201 "PaymentRequest.CanMakePayment.Used.FalseWithShowEffe ctOnCompletion",
202 PaymentRequestJourneyLogger.CMP_EFFECT_ON_COMPLETION_ ABORTED)); 202 PaymentRequestJourneyLogger.COMPLETION_STATUS_ABORTED ));
203 } 203 }
204 204
205 /** 205 /**
206 * Tests the canMakePayment stats for the case where the merchant uses it, r eturns false, 206 * Tests the canMakePayment stats for the case where the merchant uses it, r eturns false,
207 * show is called and the transaction is completed. 207 * show is called and the transaction is completed.
208 */ 208 */
209 @SmallTest 209 @SmallTest
210 @Feature({"Payments"}) 210 @Feature({"Payments"})
211 public void testRecordJourneyStatsHistograms_CanMakePaymentCalled_FalseShowA ndComplete() { 211 public void testRecordJourneyStatsHistograms_CanMakePaymentCalled_FalseShowA ndComplete() {
212 PaymentRequestJourneyLogger logger = new PaymentRequestJourneyLogger(); 212 PaymentRequestJourneyLogger logger = new PaymentRequestJourneyLogger();
(...skipping 12 matching lines...) Expand all
225 // The CanMakePayment effect on show should be recorded as being true an d not shown. 225 // The CanMakePayment effect on show should be recorded as being true an d not shown.
226 assertEquals(1, RecordHistogram.getHistogramValueCountForTesting( 226 assertEquals(1, RecordHistogram.getHistogramValueCountForTesting(
227 "PaymentRequest.CanMakePayment.Used.EffetOnShow" , 227 "PaymentRequest.CanMakePayment.Used.EffetOnShow" ,
228 PaymentRequestJourneyLogger.CMP_SHOW_DID_SHOW)); 228 PaymentRequestJourneyLogger.CMP_SHOW_DID_SHOW));
229 229
230 // There should be a record for a completion when CanMakePayment is fals e and the PR is 230 // There should be a record for a completion when CanMakePayment is fals e and the PR is
231 // shown to the user. 231 // shown to the user.
232 assertEquals( 232 assertEquals(
233 1, RecordHistogram.getHistogramValueCountForTesting( 233 1, RecordHistogram.getHistogramValueCountForTesting(
234 "PaymentRequest.CanMakePayment.Used.FalseWithShowEffe ctOnCompletion", 234 "PaymentRequest.CanMakePayment.Used.FalseWithShowEffe ctOnCompletion",
235 PaymentRequestJourneyLogger.CMP_EFFECT_ON_COMPLETION_ COMPLETED)); 235 PaymentRequestJourneyLogger.COMPLETION_STATUS_COMPLET ED));
236 } 236 }
237 237
238 /** 238 /**
239 * Tests the canMakePayment stats for the case where the merchant uses it, r eturns true, show 239 * Tests the canMakePayment stats for the case where the merchant uses it, r eturns true, show
240 * is called but the transaction is aborted. 240 * is called but the transaction is aborted.
241 */ 241 */
242 @SmallTest 242 @SmallTest
243 @Feature({"Payments"}) 243 @Feature({"Payments"})
244 public void testRecordJourneyStatsHistograms_CanMakePaymentCalled_TrueShowAn dAbort() { 244 public void testRecordJourneyStatsHistograms_CanMakePaymentCalled_TrueShowAn dAbort() {
245 PaymentRequestJourneyLogger logger = new PaymentRequestJourneyLogger(); 245 PaymentRequestJourneyLogger logger = new PaymentRequestJourneyLogger();
(...skipping 12 matching lines...) Expand all
258 // The CanMakePayment effect on show should be recorded as being true an d not shown. 258 // The CanMakePayment effect on show should be recorded as being true an d not shown.
259 assertEquals(1, RecordHistogram.getHistogramValueCountForTesting( 259 assertEquals(1, RecordHistogram.getHistogramValueCountForTesting(
260 "PaymentRequest.CanMakePayment.Used.EffetOnShow" , 260 "PaymentRequest.CanMakePayment.Used.EffetOnShow" ,
261 PaymentRequestJourneyLogger.CMP_SHOW_DID_SHOW 261 PaymentRequestJourneyLogger.CMP_SHOW_DID_SHOW
262 | PaymentRequestJourneyLogger.CMP_SHOW_C OULD_MAKE_PAYMENT)); 262 | PaymentRequestJourneyLogger.CMP_SHOW_C OULD_MAKE_PAYMENT));
263 263
264 // There should be a record for an abort when CanMakePayment is true and the PR is shown to 264 // There should be a record for an abort when CanMakePayment is true and the PR is shown to
265 // the user. 265 // the user.
266 assertEquals(1, RecordHistogram.getHistogramValueCountForTesting( 266 assertEquals(1, RecordHistogram.getHistogramValueCountForTesting(
267 "PaymentRequest.CanMakePayment.Used.TrueWithShow EffectOnCompletion", 267 "PaymentRequest.CanMakePayment.Used.TrueWithShow EffectOnCompletion",
268 PaymentRequestJourneyLogger.CMP_EFFECT_ON_COMPLE TION_ABORTED)); 268 PaymentRequestJourneyLogger.COMPLETION_STATUS_AB ORTED));
269 } 269 }
270 270
271 /** 271 /**
272 * Tests the canMakePayment stats for the case where the merchant uses it, r eturns true, show 272 * Tests the canMakePayment stats for the case where the merchant uses it, r eturns true, show
273 * is called and the transaction is completed. 273 * is called and the transaction is completed.
274 */ 274 */
275 @SmallTest 275 @SmallTest
276 @Feature({"Payments"}) 276 @Feature({"Payments"})
277 public void testRecordJourneyStatsHistograms_CanMakePaymentCalled_TrueShowAn dComplete() { 277 public void testRecordJourneyStatsHistograms_CanMakePaymentCalled_TrueShowAn dComplete() {
278 PaymentRequestJourneyLogger logger = new PaymentRequestJourneyLogger(); 278 PaymentRequestJourneyLogger logger = new PaymentRequestJourneyLogger();
(...skipping 12 matching lines...) Expand all
291 // The CanMakePayment effect on show should be recorded as being true an d not shown. 291 // The CanMakePayment effect on show should be recorded as being true an d not shown.
292 assertEquals(1, RecordHistogram.getHistogramValueCountForTesting( 292 assertEquals(1, RecordHistogram.getHistogramValueCountForTesting(
293 "PaymentRequest.CanMakePayment.Used.EffetOnShow" , 293 "PaymentRequest.CanMakePayment.Used.EffetOnShow" ,
294 PaymentRequestJourneyLogger.CMP_SHOW_DID_SHOW 294 PaymentRequestJourneyLogger.CMP_SHOW_DID_SHOW
295 | PaymentRequestJourneyLogger.CMP_SHOW_C OULD_MAKE_PAYMENT)); 295 | PaymentRequestJourneyLogger.CMP_SHOW_C OULD_MAKE_PAYMENT));
296 296
297 // There should be a record for a completion when CanMakePayment is true and the PR is shown 297 // There should be a record for a completion when CanMakePayment is true and the PR is shown
298 // to the user. 298 // to the user.
299 assertEquals(1, RecordHistogram.getHistogramValueCountForTesting( 299 assertEquals(1, RecordHistogram.getHistogramValueCountForTesting(
300 "PaymentRequest.CanMakePayment.Used.TrueWithShow EffectOnCompletion", 300 "PaymentRequest.CanMakePayment.Used.TrueWithShow EffectOnCompletion",
301 PaymentRequestJourneyLogger.CMP_EFFECT_ON_COMPLE TION_COMPLETED)); 301 PaymentRequestJourneyLogger.COMPLETION_STATUS_CO MPLETED));
302 } 302 }
303 303
304 /** 304 /**
305 * Tests that the completion status metrics based on whether the user had su ggestions for all
306 * the requested sections are logged as correctly.
307 */
308 @SmallTest
309 @Feature({"Payments"})
310 public void testRecordJourneyStatsHistograms_SuggestionsForEverything_Comple ted() {
311 PaymentRequestJourneyLogger logger = new PaymentRequestJourneyLogger();
312
313 // Simulate that the user had suggestions for all the requested sections .
314 logger.setNumberOfSuggestionsShown(PaymentRequestJourneyLogger.SECTION_C REDIT_CARDS, 1);
315
316 // Simulate that the user completes the checkout.
317 logger.recordJourneyStatsHistograms("Completed");
318
319 // Make sure the appropriate metric was logged.
320 assertEquals(1, RecordHistogram.getHistogramValueCountForTesting(
321 "PaymentRequest.UserHadSuggestionsForEverything. EffectOnCompletion",
322 PaymentRequestJourneyLogger.COMPLETION_STATUS_CO MPLETED));
323
324 assertEquals(0,
325 RecordHistogram.getHistogramValueCountForTesting(
326 "PaymentRequest.UserDidNotHaveSuggestionsForEverything.E ffectOnCompletion",
327 PaymentRequestJourneyLogger.COMPLETION_STATUS_COMPLETED) );
328 }
329
330 /**
331 * Tests that the completion status metrics based on whether the user had su ggestions for all
332 * the requested sections are logged as correctly.
333 */
334 @SmallTest
335 @Feature({"Payments"})
336 public void testRecordJourneyStatsHistograms_SuggestionsForEverything_Aborte d() {
337 PaymentRequestJourneyLogger logger = new PaymentRequestJourneyLogger();
338
339 // Simulate that the user had suggestions for all the requested sections .
340 logger.setNumberOfSuggestionsShown(PaymentRequestJourneyLogger.SECTION_C REDIT_CARDS, 1);
341
342 // Simulate that the user aborts the checkout.
343 logger.recordJourneyStatsHistograms("Aborted");
344
345 // Make sure the appropriate metric was logged.
346 assertEquals(1, RecordHistogram.getHistogramValueCountForTesting(
347 "PaymentRequest.UserHadSuggestionsForEverything. EffectOnCompletion",
348 PaymentRequestJourneyLogger.COMPLETION_STATUS_AB ORTED));
349
350 assertEquals(0,
351 RecordHistogram.getHistogramValueCountForTesting(
352 "PaymentRequest.UserDidNotHaveSuggestionsForEverything.E ffectOnCompletion",
353 PaymentRequestJourneyLogger.COMPLETION_STATUS_ABORTED));
354 }
355
356 /**
357 * Tests that the completion status metrics based on whether the user had su ggestions for all
358 * the requested sections are logged as correctly.
359 */
360 @SmallTest
361 @Feature({"Payments"})
362 public void testRecordJourneyStatsHistograms_NoSuggestionsForEverything_Comp leted() {
363 PaymentRequestJourneyLogger logger = new PaymentRequestJourneyLogger();
364
365 // Simulate that the user did not have suggestions for all the requested sections.
366 logger.setNumberOfSuggestionsShown(PaymentRequestJourneyLogger.SECTION_C REDIT_CARDS, 0);
367
368 // Simulate that the user completes the checkout.
369 logger.recordJourneyStatsHistograms("Completed");
370
371 // Make sure the appropriate metric was logged.
372 assertEquals(1,
373 RecordHistogram.getHistogramValueCountForTesting(
374 "PaymentRequest.UserDidNotHaveSuggestionsForEverything.E ffectOnCompletion",
375 PaymentRequestJourneyLogger.COMPLETION_STATUS_COMPLETED) );
376
377 assertEquals(0, RecordHistogram.getHistogramValueCountForTesting(
378 "PaymentRequest.UserHadSuggestionsForEverything. EffectOnCompletion",
379 PaymentRequestJourneyLogger.COMPLETION_STATUS_CO MPLETED));
380 }
381
382 /**
383 * Tests that the completion status metrics based on whether the user had su ggestions for all
384 * the requested sections are logged as correctly.
385 */
386 @SmallTest
387 @Feature({"Payments"})
388 public void testRecordJourneyStatsHistograms_NoSuggestionsForEverything_Abor ted() {
389 PaymentRequestJourneyLogger logger = new PaymentRequestJourneyLogger();
390
391 // Simulate that the user had suggestions for all the requested sections .
392 logger.setNumberOfSuggestionsShown(PaymentRequestJourneyLogger.SECTION_C REDIT_CARDS, 0);
393
394 // Simulate that the user aborts the checkout.
395 logger.recordJourneyStatsHistograms("Aborted");
396
397 // Make sure the appropriate metric was logged.
398 assertEquals(1,
399 RecordHistogram.getHistogramValueCountForTesting(
400 "PaymentRequest.UserDidNotHaveSuggestionsForEverything.E ffectOnCompletion",
401 PaymentRequestJourneyLogger.COMPLETION_STATUS_ABORTED));
402
403 assertEquals(0, RecordHistogram.getHistogramValueCountForTesting(
404 "PaymentRequest.UserHadSuggestionsForEverything. EffectOnCompletion",
405 PaymentRequestJourneyLogger.COMPLETION_STATUS_AB ORTED));
406 }
407
408 /**
305 * Asserts that no histogram is logged. 409 * Asserts that no histogram is logged.
306 */ 410 */
307 private void assertNoLogForCanMakePayment() { 411 private void assertNoLogForCanMakePayment() {
308 // Use stats. 412 // Use stats.
309 for (int i = 0; i < PaymentRequestJourneyLogger.CAN_MAKE_PAYMENT_USE_MAX ; ++i) { 413 for (int i = 0; i < PaymentRequestJourneyLogger.CAN_MAKE_PAYMENT_USE_MAX ; ++i) {
310 assertEquals(0, RecordHistogram.getHistogramValueCountForTesting( 414 assertEquals(0, RecordHistogram.getHistogramValueCountForTesting(
311 "PaymentRequest.CanMakePayment.Usage", i)); 415 "PaymentRequest.CanMakePayment.Usage", i));
312 } 416 }
313 417
314 // Effect on show stats. 418 // Effect on show stats.
315 for (int i = 0; i < PaymentRequestJourneyLogger.CMP_SHOW_MAX; ++i) { 419 for (int i = 0; i < PaymentRequestJourneyLogger.CMP_SHOW_MAX; ++i) {
316 assertEquals(0, RecordHistogram.getHistogramValueCountForTesting( 420 assertEquals(0, RecordHistogram.getHistogramValueCountForTesting(
317 "PaymentRequest.CanMakePayment.Used.EffetOnS how", i)); 421 "PaymentRequest.CanMakePayment.Used.EffetOnS how", i));
318 } 422 }
319 423
320 // Effect on completion stats. 424 // Effect on completion stats.
321 for (int i = 0; i < PaymentRequestJourneyLogger.CMP_EFFECT_ON_COMPLETION _MAX; ++i) { 425 for (int i = 0; i < PaymentRequestJourneyLogger.COMPLETION_STATUS_MAX; + +i) {
322 assertEquals(0, 426 assertEquals(0,
323 RecordHistogram.getHistogramValueCountForTesting( 427 RecordHistogram.getHistogramValueCountForTesting(
324 "PaymentRequest.CanMakePayment.NotUsed.WithShowEffec tOnCompletion", i)); 428 "PaymentRequest.CanMakePayment.NotUsed.WithShowEffec tOnCompletion", i));
325 assertEquals( 429 assertEquals(
326 0, RecordHistogram.getHistogramValueCountForTesting( 430 0, RecordHistogram.getHistogramValueCountForTesting(
327 "PaymentRequest.CanMakePayment.Used.TrueWithShowE ffectOnCompletion", 431 "PaymentRequest.CanMakePayment.Used.TrueWithShowE ffectOnCompletion",
328 i)); 432 i));
329 assertEquals( 433 assertEquals(
330 0, RecordHistogram.getHistogramValueCountForTesting( 434 0, RecordHistogram.getHistogramValueCountForTesting(
331 "PaymentRequest.CanMakePayment.Used.FalseWithShow EffectOnCompletion", 435 "PaymentRequest.CanMakePayment.Used.FalseWithShow EffectOnCompletion",
332 i)); 436 i));
333 } 437 }
334 } 438 }
335 } 439 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698