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

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

Issue 2750103005: [Payments] Move journey logger to native. (Closed)
Patch Set: Add the component_jni_registrar files Created 3 years, 8 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;
11 import org.chromium.chrome.test.util.ApplicationData; 11 import org.chromium.chrome.test.util.ApplicationData;
12 import org.chromium.components.payments.JourneyLogger;
12 import org.chromium.content.browser.test.NativeLibraryTestBase; 13 import org.chromium.content.browser.test.NativeLibraryTestBase;
13 14
14 /** 15 /**
15 * Tests for the PaymentRequestJourneyLogger class. 16 * Tests for the PaymentRequestJourneyLogger class.
16 */ 17 */
17 public class PaymentRequestJourneyLoggerUnitTest extends NativeLibraryTestBase { 18 public class PaymentRequestJourneyLoggerUnitTest extends NativeLibraryTestBase {
18 @Override 19 @Override
19 public void setUp() throws Exception { 20 public void setUp() throws Exception {
20 super.setUp(); 21 super.setUp();
21 ApplicationData.clearAppData(getInstrumentation().getTargetContext()); 22 ApplicationData.clearAppData(getInstrumentation().getTargetContext());
22 loadNativeLibraryAndInitBrowserProcess(); 23 loadNativeLibraryAndInitBrowserProcess();
23 } 24 }
24 25
25 /** 26 /**
26 * Tests the canMakePayment stats for the case where the merchant does not u se it and does not 27 * Tests the canMakePayment stats for the case where the merchant does not u se it and does not
27 * show the PaymentRequest to the user. 28 * show the PaymentRequest to the user.
28 */ 29 */
29 @SmallTest 30 @SmallTest
30 @Feature({"Payments"}) 31 @Feature({"Payments"})
31 public void testRecordJourneyStatsHistograms_CanMakePaymentNotCalled_NoShow( ) { 32 public void testRecordJourneyStatsHistograms_CanMakePaymentNotCalled_NoShow( ) {
32 PaymentRequestJourneyLogger logger = new PaymentRequestJourneyLogger(); 33 JourneyLogger logger = new JourneyLogger();
33 assertNoLogForCanMakePayment(); 34 assertNoLogForCanMakePayment();
34 35
35 logger.recordJourneyStatsHistograms(""); 36 logger.recordJourneyStatsHistograms(JourneyLogger.COMPLETION_STATUS_USER _ABORTED);
36 37
37 // CanMakePayment was not used. 38 // CanMakePayment was not used.
38 assertEquals(1, RecordHistogram.getHistogramValueCountForTesting( 39 assertEquals(1,
39 "PaymentRequest.CanMakePayment.Usage", 40 RecordHistogram.getHistogramValueCountForTesting(
40 PaymentRequestJourneyLogger.CAN_MAKE_PAYMENT_NOT _USED)); 41 "PaymentRequest.CanMakePayment.Usage",
42 JourneyLogger.CAN_MAKE_PAYMENT_NOT_USED));
41 43
42 // There should be no completion stats since PR was not shown to the use r 44 // There should be no completion stats since PR was not shown to the use r
43 assertEquals(0, RecordHistogram.getHistogramValueCountForTesting( 45 assertEquals(0,
44 "PaymentRequest.CanMakePayment.NotUsed.WithShowE ffectOnCompletion", 46 RecordHistogram.getHistogramValueCountForTesting(
45 PaymentRequestJourneyLogger.COMPLETION_STATUS_AB ORTED)); 47 "PaymentRequest.CanMakePayment.NotUsed.WithShowEffectOnC ompletion",
46 assertEquals(0, RecordHistogram.getHistogramValueCountForTesting( 48 JourneyLogger.COMPLETION_STATUS_USER_ABORTED));
47 "PaymentRequest.CanMakePayment.NotUsed.WithShowE ffectOnCompletion", 49 assertEquals(0,
48 PaymentRequestJourneyLogger.COMPLETION_STATUS_CO MPLETED)); 50 RecordHistogram.getHistogramValueCountForTesting(
51 "PaymentRequest.CanMakePayment.NotUsed.WithShowEffectOnC ompletion",
52 JourneyLogger.COMPLETION_STATUS_COMPLETED));
49 } 53 }
50 54
51 /** 55 /**
52 * Tests the canMakePayment stats for the case where the merchant does not u se it and the 56 * Tests the canMakePayment stats for the case where the merchant does not u se it and the
53 * transaction is aborted. 57 * transaction is aborted.
54 */ 58 */
55 @SmallTest 59 @SmallTest
56 @Feature({"Payments"}) 60 @Feature({"Payments"})
57 public void testRecordJourneyStatsHistograms_CanMakePaymentNotCalled_ShowAnd Abort() { 61 public void testRecordJourneyStatsHistograms_CanMakePaymentNotCalled_ShowAnd UserAbort() {
58 PaymentRequestJourneyLogger logger = new PaymentRequestJourneyLogger(); 62 JourneyLogger logger = new JourneyLogger();
59 assertNoLogForCanMakePayment(); 63 assertNoLogForCanMakePayment();
60 64
61 // The merchant does not query CanMakePayment, show the PaymentRequest a nd the user 65 // The merchant does not query CanMakePayment, show the PaymentRequest a nd the user
62 // aborts it. 66 // aborts it.
63 logger.setShowCalled(); 67 logger.setShowCalled();
64 logger.recordJourneyStatsHistograms("Aborted"); 68 logger.recordJourneyStatsHistograms(JourneyLogger.COMPLETION_STATUS_USER _ABORTED);
65 69
66 // CanMakePayment was not used. 70 // CanMakePayment was not used.
67 assertEquals(1, RecordHistogram.getHistogramValueCountForTesting( 71 assertEquals(1,
68 "PaymentRequest.CanMakePayment.Usage", 72 RecordHistogram.getHistogramValueCountForTesting(
69 PaymentRequestJourneyLogger.CAN_MAKE_PAYMENT_NOT _USED)); 73 "PaymentRequest.CanMakePayment.Usage",
74 JourneyLogger.CAN_MAKE_PAYMENT_NOT_USED));
70 75
71 // There should be a record for an abort when CanMakePayment is not used but the PR is shown 76 // There should be a record for an abort when CanMakePayment is not used but the PR is shown
72 // to the user. 77 // to the user.
73 assertEquals(1, RecordHistogram.getHistogramValueCountForTesting( 78 assertEquals(1,
74 "PaymentRequest.CanMakePayment.NotUsed.WithShowE ffectOnCompletion", 79 RecordHistogram.getHistogramValueCountForTesting(
75 PaymentRequestJourneyLogger.COMPLETION_STATUS_AB ORTED)); 80 "PaymentRequest.CanMakePayment.NotUsed.WithShowEffectOnC ompletion",
81 JourneyLogger.COMPLETION_STATUS_USER_ABORTED));
76 } 82 }
77 83
78 /** 84 /**
85 * Tests the canMakePayment stats for the case where the merchant does not u se it and the
86 * transaction is aborted.
87 */
88 @SmallTest
89 @Feature({"Payments"})
90 public void testRecordJourneyStatsHistograms_CanMakePaymentNotCalled_ShowAnd OtherAbort() {
91 JourneyLogger logger = new JourneyLogger();
92 assertNoLogForCanMakePayment();
93
94 // The merchant does not query CanMakePayment, show the PaymentRequest a nd the user
95 // aborts it.
96 logger.setShowCalled();
97 logger.recordJourneyStatsHistograms(JourneyLogger.COMPLETION_STATUS_OTHE R_ABORTED);
98
99 // CanMakePayment was not used.
100 assertEquals(1,
101 RecordHistogram.getHistogramValueCountForTesting(
102 "PaymentRequest.CanMakePayment.Usage",
103 JourneyLogger.CAN_MAKE_PAYMENT_NOT_USED));
104
105 // There should be a record for an abort when CanMakePayment is not used but the PR is shown
106 // to the user.
107 assertEquals(1,
108 RecordHistogram.getHistogramValueCountForTesting(
109 "PaymentRequest.CanMakePayment.NotUsed.WithShowEffectOnC ompletion",
110 JourneyLogger.COMPLETION_STATUS_OTHER_ABORTED));
111 }
112
113 /**
79 * Tests the canMakePayment stats for the case where the merchant does not u se it and the 114 * Tests the canMakePayment stats for the case where the merchant does not u se it and the
80 * transaction is completed. 115 * transaction is completed.
81 */ 116 */
82 @SmallTest 117 @SmallTest
83 @Feature({"Payments"}) 118 @Feature({"Payments"})
84 public void testRecordJourneyStatsHistograms_CanMakePaymentNotCalled_ShowAnd Complete() { 119 public void testRecordJourneyStatsHistograms_CanMakePaymentNotCalled_ShowAnd Complete() {
85 PaymentRequestJourneyLogger logger = new PaymentRequestJourneyLogger(); 120 JourneyLogger logger = new JourneyLogger();
86 assertNoLogForCanMakePayment(); 121 assertNoLogForCanMakePayment();
87 122
88 // The merchant does not query CanMakePayment, show the PaymentRequest a nd the user 123 // The merchant does not query CanMakePayment, show the PaymentRequest a nd the user
89 // completes it. 124 // completes it.
90 logger.setShowCalled(); 125 logger.setShowCalled();
91 logger.recordJourneyStatsHistograms("Completed"); 126 logger.recordJourneyStatsHistograms(JourneyLogger.COMPLETION_STATUS_COMP LETED);
92 127
93 // CanMakePayment was not used. 128 // CanMakePayment was not used.
94 assertEquals(1, RecordHistogram.getHistogramValueCountForTesting( 129 assertEquals(1,
95 "PaymentRequest.CanMakePayment.Usage", 130 RecordHistogram.getHistogramValueCountForTesting(
96 PaymentRequestJourneyLogger.CAN_MAKE_PAYMENT_NOT _USED)); 131 "PaymentRequest.CanMakePayment.Usage",
132 JourneyLogger.CAN_MAKE_PAYMENT_NOT_USED));
97 133
98 // There should be a record for a completion when CanMakePayment is not used but the PR is 134 // There should be a record for a completion when CanMakePayment is not used but the PR is
99 // shown to the user. 135 // shown to the user.
100 assertEquals(1, RecordHistogram.getHistogramValueCountForTesting( 136 assertEquals(1,
101 "PaymentRequest.CanMakePayment.NotUsed.WithShowE ffectOnCompletion", 137 RecordHistogram.getHistogramValueCountForTesting(
102 PaymentRequestJourneyLogger.COMPLETION_STATUS_CO MPLETED)); 138 "PaymentRequest.CanMakePayment.NotUsed.WithShowEffectOnC ompletion",
139 JourneyLogger.COMPLETION_STATUS_COMPLETED));
103 } 140 }
104 141
105 /** 142 /**
106 * Tests the canMakePayment stats for the case where the merchant uses it, r eturns false and 143 * Tests the canMakePayment stats for the case where the merchant uses it, r eturns false and
107 * show is not called. 144 * show is not called.
108 */ 145 */
109 @SmallTest 146 @SmallTest
110 @Feature({"Payments"}) 147 @Feature({"Payments"})
111 public void testRecordJourneyStatsHistograms_CanMakePaymentCalled_FalseAndNo Show() { 148 public void testRecordJourneyStatsHistograms_CanMakePaymentCalled_FalseAndNo Show() {
112 PaymentRequestJourneyLogger logger = new PaymentRequestJourneyLogger(); 149 JourneyLogger logger = new JourneyLogger();
113 assertNoLogForCanMakePayment(); 150 assertNoLogForCanMakePayment();
114 151
115 // The user cannot make payment and the PaymentRequest is not shown. 152 // The user cannot make payment and the PaymentRequest is not shown.
116 logger.setCanMakePaymentValue(false); 153 logger.setCanMakePaymentValue(false);
117 logger.recordJourneyStatsHistograms(""); 154 logger.recordJourneyStatsHistograms(JourneyLogger.COMPLETION_STATUS_OTHE R_ABORTED);
118 155
119 // CanMakePayment was used. 156 // CanMakePayment was used.
120 assertEquals(1, RecordHistogram.getHistogramValueCountForTesting( 157 assertEquals(1,
121 "PaymentRequest.CanMakePayment.Usage", 158 RecordHistogram.getHistogramValueCountForTesting(
122 PaymentRequestJourneyLogger.CAN_MAKE_PAYMENT_USE D)); 159 "PaymentRequest.CanMakePayment.Usage",
160 JourneyLogger.CAN_MAKE_PAYMENT_USED));
123 161
124 // The CanMakePayment effect on show should be recorded as being false a nd not shown. 162 // The CanMakePayment effect on show should be recorded as being false a nd not shown.
125 assertEquals(1, RecordHistogram.getHistogramValueCountForTesting( 163 assertEquals(1,
126 "PaymentRequest.CanMakePayment.Used.EffetOnShow" , 164 RecordHistogram.getHistogramValueCountForTesting(
127 PaymentRequestJourneyLogger 165 "PaymentRequest.CanMakePayment.Used.EffectOnShow",
128 .CMP_SHOW_COULD_NOT_MAKE_PAYMENT_AND_DID _NOT_SHOW)); 166 JourneyLogger.CMP_SHOW_COULD_NOT_MAKE_PAYMENT_AND_DID_NO T_SHOW));
129 167
130 // There should be no completion stats since PR was not shown to the use r. 168 // There should be no completion stats since PR was not shown to the use r.
131 assertEquals(0, RecordHistogram.getHistogramValueCountForTesting( 169 assertEquals(0,
132 "PaymentRequest.CanMakePayment.NotUsed.WithShowE ffectOnCompletion", 170 RecordHistogram.getHistogramValueCountForTesting(
133 PaymentRequestJourneyLogger.COMPLETION_STATUS_AB ORTED)); 171 "PaymentRequest.CanMakePayment.NotUsed.WithShowEffectOnC ompletion",
134 assertEquals(0, RecordHistogram.getHistogramValueCountForTesting( 172 JourneyLogger.COMPLETION_STATUS_OTHER_ABORTED));
135 "PaymentRequest.CanMakePayment.NotUsed.WithShowE ffectOnCompletion", 173 assertEquals(0,
136 PaymentRequestJourneyLogger.COMPLETION_STATUS_CO MPLETED)); 174 RecordHistogram.getHistogramValueCountForTesting(
175 "PaymentRequest.CanMakePayment.NotUsed.WithShowEffectOnC ompletion",
176 JourneyLogger.COMPLETION_STATUS_COMPLETED));
137 } 177 }
138 178
139 /** 179 /**
140 * Tests the canMakePayment stats for the case where the merchant uses it, r eturns true and 180 * Tests the canMakePayment stats for the case where the merchant uses it, r eturns true and
141 * show is not called. 181 * show is not called.
142 */ 182 */
143 @SmallTest 183 @SmallTest
144 @Feature({"Payments"}) 184 @Feature({"Payments"})
145 public void testRecordJourneyStatsHistograms_CanMakePaymentCalled_TrueAndNoS how() { 185 public void testRecordJourneyStatsHistograms_CanMakePaymentCalled_TrueAndNoS how() {
146 PaymentRequestJourneyLogger logger = new PaymentRequestJourneyLogger(); 186 JourneyLogger logger = new JourneyLogger();
147 assertNoLogForCanMakePayment(); 187 assertNoLogForCanMakePayment();
148 188
149 // The user can make a payment but the Payment Request is not shown. 189 // The user can make a payment but the Payment Request is not shown.
150 logger.setCanMakePaymentValue(true); 190 logger.setCanMakePaymentValue(true);
151 logger.recordJourneyStatsHistograms(""); 191 logger.recordJourneyStatsHistograms(JourneyLogger.COMPLETION_STATUS_OTHE R_ABORTED);
152 192
153 // CanMakePayment was used. 193 // CanMakePayment was used.
154 assertEquals(1, RecordHistogram.getHistogramValueCountForTesting( 194 assertEquals(1,
155 "PaymentRequest.CanMakePayment.Usage", 195 RecordHistogram.getHistogramValueCountForTesting(
156 PaymentRequestJourneyLogger.CAN_MAKE_PAYMENT_USE D)); 196 "PaymentRequest.CanMakePayment.Usage",
197 JourneyLogger.CAN_MAKE_PAYMENT_USED));
157 198
158 // The CanMakePayment effect on show should be recorded as being true an d not shown. 199 // The CanMakePayment effect on show should be recorded as being true an d not shown.
159 assertEquals(1, RecordHistogram.getHistogramValueCountForTesting( 200 assertEquals(1,
160 "PaymentRequest.CanMakePayment.Used.EffetOnShow" , 201 RecordHistogram.getHistogramValueCountForTesting(
161 PaymentRequestJourneyLogger.CMP_SHOW_COULD_MAKE_ PAYMENT)); 202 "PaymentRequest.CanMakePayment.Used.EffectOnShow",
203 JourneyLogger.CMP_SHOW_COULD_MAKE_PAYMENT));
162 204
163 // There should be no completion stats since PR was not shown to the use r. 205 // There should be no completion stats since PR was not shown to the use r.
164 assertEquals(0, RecordHistogram.getHistogramValueCountForTesting( 206 assertEquals(0,
165 "PaymentRequest.CanMakePayment.NotUsed.WithShowE ffectOnCompletion", 207 RecordHistogram.getHistogramValueCountForTesting(
166 PaymentRequestJourneyLogger.COMPLETION_STATUS_AB ORTED)); 208 "PaymentRequest.CanMakePayment.NotUsed.WithShowEffectOnC ompletion",
167 assertEquals(0, RecordHistogram.getHistogramValueCountForTesting( 209 JourneyLogger.COMPLETION_STATUS_OTHER_ABORTED));
168 "PaymentRequest.CanMakePayment.NotUsed.WithShowE ffectOnCompletion", 210 assertEquals(0,
169 PaymentRequestJourneyLogger.COMPLETION_STATUS_CO MPLETED)); 211 RecordHistogram.getHistogramValueCountForTesting(
212 "PaymentRequest.CanMakePayment.NotUsed.WithShowEffectOnC ompletion",
213 JourneyLogger.COMPLETION_STATUS_COMPLETED));
170 } 214 }
171 215
172 /** 216 /**
217 * Tests the canMakePayment stats for the case where the merchant uses it, r eturns false, show
218 * is called but the transaction is aborted by the user.
219 */
220 @SmallTest
221 @Feature({"Payments"})
222 public void testRecordJourneyStatsHistograms_CanMakePaymentCalled_FalseShowA ndUserAbort() {
223 JourneyLogger logger = new JourneyLogger();
224 assertNoLogForCanMakePayment();
225
226 // The user cannot make a payment. the payment request is shown but abor ted.
227 logger.setShowCalled();
228 logger.setCanMakePaymentValue(false);
229 logger.recordJourneyStatsHistograms(JourneyLogger.COMPLETION_STATUS_USER _ABORTED);
230
231 // CanMakePayment was used.
232 assertEquals(1,
233 RecordHistogram.getHistogramValueCountForTesting(
234 "PaymentRequest.CanMakePayment.Usage",
235 JourneyLogger.CAN_MAKE_PAYMENT_USED));
236
237 // The CanMakePayment effect on show should be recorded as being true an d not shown.
238 assertEquals(1,
239 RecordHistogram.getHistogramValueCountForTesting(
240 "PaymentRequest.CanMakePayment.Used.EffectOnShow",
241 JourneyLogger.CMP_SHOW_DID_SHOW));
242
243 // There should be a record for an abort when CanMakePayment is false bu t the PR is shown to
244 // the user.
245 assertEquals(1,
246 RecordHistogram.getHistogramValueCountForTesting(
247 "PaymentRequest.CanMakePayment.Used.FalseWithShowEffectO nCompletion",
248 JourneyLogger.COMPLETION_STATUS_USER_ABORTED));
249 }
250
251 /**
173 * Tests the canMakePayment stats for the case where the merchant uses it, r eturns false, show 252 * Tests the canMakePayment stats for the case where the merchant uses it, r eturns false, show
174 * is called but the transaction is aborted. 253 * is called but the transaction is aborted.
175 */ 254 */
176 @SmallTest 255 @SmallTest
177 @Feature({"Payments"}) 256 @Feature({"Payments"})
178 public void testRecordJourneyStatsHistograms_CanMakePaymentCalled_FalseShowA ndAbort() { 257 public void testRecordJourneyStatsHistograms_CanMakePaymentCalled_FalseShowA ndOtherAbort() {
179 PaymentRequestJourneyLogger logger = new PaymentRequestJourneyLogger(); 258 JourneyLogger logger = new JourneyLogger();
180 assertNoLogForCanMakePayment(); 259 assertNoLogForCanMakePayment();
181 260
182 // The user cannot make a payment. the payment request is shown but abor ted. 261 // The user cannot make a payment. the payment request is shown but abor ted.
183 logger.setShowCalled(); 262 logger.setShowCalled();
184 logger.setCanMakePaymentValue(false); 263 logger.setCanMakePaymentValue(false);
185 logger.recordJourneyStatsHistograms("Aborted"); 264 logger.recordJourneyStatsHistograms(JourneyLogger.COMPLETION_STATUS_OTHE R_ABORTED);
186 265
187 // CanMakePayment was used. 266 // CanMakePayment was used.
188 assertEquals(1, RecordHistogram.getHistogramValueCountForTesting( 267 assertEquals(1,
189 "PaymentRequest.CanMakePayment.Usage", 268 RecordHistogram.getHistogramValueCountForTesting(
190 PaymentRequestJourneyLogger.CAN_MAKE_PAYMENT_USE D)); 269 "PaymentRequest.CanMakePayment.Usage",
270 JourneyLogger.CAN_MAKE_PAYMENT_USED));
191 271
192 // The CanMakePayment effect on show should be recorded as being true an d not shown. 272 // The CanMakePayment effect on show should be recorded as being true an d not shown.
193 assertEquals(1, RecordHistogram.getHistogramValueCountForTesting( 273 assertEquals(1,
194 "PaymentRequest.CanMakePayment.Used.EffetOnShow" , 274 RecordHistogram.getHistogramValueCountForTesting(
195 PaymentRequestJourneyLogger.CMP_SHOW_DID_SHOW)); 275 "PaymentRequest.CanMakePayment.Used.EffectOnShow",
276 JourneyLogger.CMP_SHOW_DID_SHOW));
196 277
197 // There should be a record for an abort when CanMakePayment is false bu t the PR is shown to 278 // There should be a record for an abort when CanMakePayment is false bu t the PR is shown to
198 // the user. 279 // the user.
199 assertEquals( 280 assertEquals(1,
200 1, RecordHistogram.getHistogramValueCountForTesting( 281 RecordHistogram.getHistogramValueCountForTesting(
201 "PaymentRequest.CanMakePayment.Used.FalseWithShowEffe ctOnCompletion", 282 "PaymentRequest.CanMakePayment.Used.FalseWithShowEffectO nCompletion",
202 PaymentRequestJourneyLogger.COMPLETION_STATUS_ABORTED )); 283 JourneyLogger.COMPLETION_STATUS_OTHER_ABORTED));
203 } 284 }
204 285
205 /** 286 /**
206 * Tests the canMakePayment stats for the case where the merchant uses it, r eturns false, 287 * Tests the canMakePayment stats for the case where the merchant uses it, r eturns false,
207 * show is called and the transaction is completed. 288 * show is called and the transaction is completed.
208 */ 289 */
209 @SmallTest 290 @SmallTest
210 @Feature({"Payments"}) 291 @Feature({"Payments"})
211 public void testRecordJourneyStatsHistograms_CanMakePaymentCalled_FalseShowA ndComplete() { 292 public void testRecordJourneyStatsHistograms_CanMakePaymentCalled_FalseShowA ndComplete() {
212 PaymentRequestJourneyLogger logger = new PaymentRequestJourneyLogger(); 293 JourneyLogger logger = new JourneyLogger();
213 assertNoLogForCanMakePayment(); 294 assertNoLogForCanMakePayment();
214 295
215 // The user cannot make a payment. the payment request is shown and comp leted. 296 // The user cannot make a payment. the payment request is shown and comp leted.
216 logger.setShowCalled(); 297 logger.setShowCalled();
217 logger.setCanMakePaymentValue(false); 298 logger.setCanMakePaymentValue(false);
218 logger.recordJourneyStatsHistograms("Completed"); 299 logger.recordJourneyStatsHistograms(JourneyLogger.COMPLETION_STATUS_COMP LETED);
219 300
220 // CanMakePayment was used. 301 // CanMakePayment was used.
221 assertEquals(1, RecordHistogram.getHistogramValueCountForTesting( 302 assertEquals(1,
222 "PaymentRequest.CanMakePayment.Usage", 303 RecordHistogram.getHistogramValueCountForTesting(
223 PaymentRequestJourneyLogger.CAN_MAKE_PAYMENT_USE D)); 304 "PaymentRequest.CanMakePayment.Usage",
305 JourneyLogger.CAN_MAKE_PAYMENT_USED));
224 306
225 // The CanMakePayment effect on show should be recorded as being true an d not shown. 307 // The CanMakePayment effect on show should be recorded as being true an d not shown.
226 assertEquals(1, RecordHistogram.getHistogramValueCountForTesting( 308 assertEquals(1,
227 "PaymentRequest.CanMakePayment.Used.EffetOnShow" , 309 RecordHistogram.getHistogramValueCountForTesting(
228 PaymentRequestJourneyLogger.CMP_SHOW_DID_SHOW)); 310 "PaymentRequest.CanMakePayment.Used.EffectOnShow",
311 JourneyLogger.CMP_SHOW_DID_SHOW));
229 312
230 // There should be a record for a completion when CanMakePayment is fals e and the PR is 313 // There should be a record for a completion when CanMakePayment is fals e and the PR is
231 // shown to the user. 314 // shown to the user.
232 assertEquals( 315 assertEquals(1,
233 1, RecordHistogram.getHistogramValueCountForTesting( 316 RecordHistogram.getHistogramValueCountForTesting(
234 "PaymentRequest.CanMakePayment.Used.FalseWithShowEffe ctOnCompletion", 317 "PaymentRequest.CanMakePayment.Used.FalseWithShowEffectO nCompletion",
235 PaymentRequestJourneyLogger.COMPLETION_STATUS_COMPLET ED)); 318 JourneyLogger.COMPLETION_STATUS_COMPLETED));
236 } 319 }
237 320
238 /** 321 /**
322 * Tests the canMakePayment stats for the case where the merchant uses it, r eturns true, show
323 * is called but the transaction is aborted by the user.
324 */
325 @SmallTest
326 @Feature({"Payments"})
327 public void testRecordJourneyStatsHistograms_CanMakePaymentCalled_TrueShowAn dUserAbort() {
328 JourneyLogger logger = new JourneyLogger();
329 assertNoLogForCanMakePayment();
330
331 // The user cannot make a payment. the payment request is shown and comp leted.
332 logger.setShowCalled();
333 logger.setCanMakePaymentValue(true);
334 logger.recordJourneyStatsHistograms(JourneyLogger.COMPLETION_STATUS_USER _ABORTED);
335
336 // CanMakePayment was used.
337 assertEquals(1,
338 RecordHistogram.getHistogramValueCountForTesting(
339 "PaymentRequest.CanMakePayment.Usage",
340 JourneyLogger.CAN_MAKE_PAYMENT_USED));
341
342 // The CanMakePayment effect on show should be recorded as being true an d not shown.
343 assertEquals(1,
344 RecordHistogram.getHistogramValueCountForTesting(
345 "PaymentRequest.CanMakePayment.Used.EffectOnShow",
346 JourneyLogger.CMP_SHOW_DID_SHOW
347 | JourneyLogger.CMP_SHOW_COULD_MAKE_PAYMENT));
348
349 // There should be a record for an abort when CanMakePayment is true and the PR is shown to
350 // the user.
351 assertEquals(1,
352 RecordHistogram.getHistogramValueCountForTesting(
353 "PaymentRequest.CanMakePayment.Used.TrueWithShowEffectOn Completion",
354 JourneyLogger.COMPLETION_STATUS_USER_ABORTED));
355 }
356
357 /**
239 * Tests the canMakePayment stats for the case where the merchant uses it, r eturns true, show 358 * Tests the canMakePayment stats for the case where the merchant uses it, r eturns true, show
240 * is called but the transaction is aborted. 359 * is called but the transaction is aborted.
241 */ 360 */
242 @SmallTest 361 @SmallTest
243 @Feature({"Payments"}) 362 @Feature({"Payments"})
244 public void testRecordJourneyStatsHistograms_CanMakePaymentCalled_TrueShowAn dAbort() { 363 public void testRecordJourneyStatsHistograms_CanMakePaymentCalled_TrueShowAn dOtherAbort() {
245 PaymentRequestJourneyLogger logger = new PaymentRequestJourneyLogger(); 364 JourneyLogger logger = new JourneyLogger();
246 assertNoLogForCanMakePayment(); 365 assertNoLogForCanMakePayment();
247 366
248 // The user cannot make a payment. the payment request is shown and comp leted. 367 // The user cannot make a payment. the payment request is shown and comp leted.
249 logger.setShowCalled(); 368 logger.setShowCalled();
250 logger.setCanMakePaymentValue(true); 369 logger.setCanMakePaymentValue(true);
251 logger.recordJourneyStatsHistograms("Aborted"); 370 logger.recordJourneyStatsHistograms(JourneyLogger.COMPLETION_STATUS_OTHE R_ABORTED);
252 371
253 // CanMakePayment was used. 372 // CanMakePayment was used.
254 assertEquals(1, RecordHistogram.getHistogramValueCountForTesting( 373 assertEquals(1,
255 "PaymentRequest.CanMakePayment.Usage", 374 RecordHistogram.getHistogramValueCountForTesting(
256 PaymentRequestJourneyLogger.CAN_MAKE_PAYMENT_USE D)); 375 "PaymentRequest.CanMakePayment.Usage",
376 JourneyLogger.CAN_MAKE_PAYMENT_USED));
257 377
258 // The CanMakePayment effect on show should be recorded as being true an d not shown. 378 // The CanMakePayment effect on show should be recorded as being true an d not shown.
259 assertEquals(1, RecordHistogram.getHistogramValueCountForTesting( 379 assertEquals(1,
260 "PaymentRequest.CanMakePayment.Used.EffetOnShow" , 380 RecordHistogram.getHistogramValueCountForTesting(
261 PaymentRequestJourneyLogger.CMP_SHOW_DID_SHOW 381 "PaymentRequest.CanMakePayment.Used.EffectOnShow",
262 | PaymentRequestJourneyLogger.CMP_SHOW_C OULD_MAKE_PAYMENT)); 382 JourneyLogger.CMP_SHOW_DID_SHOW
383 | JourneyLogger.CMP_SHOW_COULD_MAKE_PAYMENT));
263 384
264 // There should be a record for an abort when CanMakePayment is true and the PR is shown to 385 // There should be a record for an abort when CanMakePayment is true and the PR is shown to
265 // the user. 386 // the user.
266 assertEquals(1, RecordHistogram.getHistogramValueCountForTesting( 387 assertEquals(1,
267 "PaymentRequest.CanMakePayment.Used.TrueWithShow EffectOnCompletion", 388 RecordHistogram.getHistogramValueCountForTesting(
268 PaymentRequestJourneyLogger.COMPLETION_STATUS_AB ORTED)); 389 "PaymentRequest.CanMakePayment.Used.TrueWithShowEffectOn Completion",
390 JourneyLogger.COMPLETION_STATUS_OTHER_ABORTED));
269 } 391 }
270 392
271 /** 393 /**
272 * Tests the canMakePayment stats for the case where the merchant uses it, r eturns true, show 394 * Tests the canMakePayment stats for the case where the merchant uses it, r eturns true, show
273 * is called and the transaction is completed. 395 * is called and the transaction is completed.
274 */ 396 */
275 @SmallTest 397 @SmallTest
276 @Feature({"Payments"}) 398 @Feature({"Payments"})
277 public void testRecordJourneyStatsHistograms_CanMakePaymentCalled_TrueShowAn dComplete() { 399 public void testRecordJourneyStatsHistograms_CanMakePaymentCalled_TrueShowAn dComplete() {
278 PaymentRequestJourneyLogger logger = new PaymentRequestJourneyLogger(); 400 JourneyLogger logger = new JourneyLogger();
279 assertNoLogForCanMakePayment(); 401 assertNoLogForCanMakePayment();
280 402
281 // The user cannot make a payment. the payment request is shown and comp leted. 403 // The user cannot make a payment. the payment request is shown and comp leted.
282 logger.setShowCalled(); 404 logger.setShowCalled();
283 logger.setCanMakePaymentValue(true); 405 logger.setCanMakePaymentValue(true);
284 logger.recordJourneyStatsHistograms("Completed"); 406 logger.recordJourneyStatsHistograms(JourneyLogger.COMPLETION_STATUS_COMP LETED);
285 407
286 // CanMakePayment was used. 408 // CanMakePayment was used.
287 assertEquals(1, RecordHistogram.getHistogramValueCountForTesting( 409 assertEquals(1,
288 "PaymentRequest.CanMakePayment.Usage", 410 RecordHistogram.getHistogramValueCountForTesting(
289 PaymentRequestJourneyLogger.CAN_MAKE_PAYMENT_USE D)); 411 "PaymentRequest.CanMakePayment.Usage",
412 JourneyLogger.CAN_MAKE_PAYMENT_USED));
290 413
291 // The CanMakePayment effect on show should be recorded as being true an d not shown. 414 // The CanMakePayment effect on show should be recorded as being true an d not shown.
292 assertEquals(1, RecordHistogram.getHistogramValueCountForTesting( 415 assertEquals(1,
293 "PaymentRequest.CanMakePayment.Used.EffetOnShow" , 416 RecordHistogram.getHistogramValueCountForTesting(
294 PaymentRequestJourneyLogger.CMP_SHOW_DID_SHOW 417 "PaymentRequest.CanMakePayment.Used.EffectOnShow",
295 | PaymentRequestJourneyLogger.CMP_SHOW_C OULD_MAKE_PAYMENT)); 418 JourneyLogger.CMP_SHOW_DID_SHOW
419 | JourneyLogger.CMP_SHOW_COULD_MAKE_PAYMENT));
296 420
297 // There should be a record for a completion when CanMakePayment is true and the PR is shown 421 // There should be a record for a completion when CanMakePayment is true and the PR is shown
298 // to the user. 422 // to the user.
299 assertEquals(1, RecordHistogram.getHistogramValueCountForTesting( 423 assertEquals(1,
300 "PaymentRequest.CanMakePayment.Used.TrueWithShow EffectOnCompletion", 424 RecordHistogram.getHistogramValueCountForTesting(
301 PaymentRequestJourneyLogger.COMPLETION_STATUS_CO MPLETED)); 425 "PaymentRequest.CanMakePayment.Used.TrueWithShowEffectOn Completion",
426 JourneyLogger.COMPLETION_STATUS_COMPLETED));
302 } 427 }
303 428
304 /** 429 /**
305 * Tests that the completion status metrics based on whether the user had su ggestions for all 430 * Tests that the completion status metrics based on whether the user had su ggestions for all
306 * the requested sections are logged as correctly. 431 * the requested sections are logged as correctly.
307 */ 432 */
308 @SmallTest 433 @SmallTest
309 @Feature({"Payments"}) 434 @Feature({"Payments"})
310 public void testRecordJourneyStatsHistograms_SuggestionsForEverything_Comple ted() { 435 public void testRecordJourneyStatsHistograms_SuggestionsForEverything_Comple ted() {
311 PaymentRequestJourneyLogger logger = new PaymentRequestJourneyLogger(); 436 JourneyLogger logger = new JourneyLogger();
312 437
313 // Simulate that the user had suggestions for all the requested sections . 438 // Simulate that the user had suggestions for all the requested sections .
314 logger.setNumberOfSuggestionsShown(PaymentRequestJourneyLogger.SECTION_C REDIT_CARDS, 1); 439 logger.setNumberOfSuggestionsShown(JourneyLogger.SECTION_CREDIT_CARDS, 1 );
315 440
316 // Simulate that the user completes the checkout. 441 // Simulate that the user completes the checkout.
317 logger.recordJourneyStatsHistograms("Completed"); 442 logger.recordJourneyStatsHistograms(JourneyLogger.COMPLETION_STATUS_COMP LETED);
318 443
319 // Make sure the appropriate metric was logged. 444 // Make sure the appropriate metric was logged.
320 assertEquals(1, RecordHistogram.getHistogramValueCountForTesting( 445 assertEquals(1,
321 "PaymentRequest.UserHadSuggestionsForEverything. EffectOnCompletion", 446 RecordHistogram.getHistogramValueCountForTesting(
322 PaymentRequestJourneyLogger.COMPLETION_STATUS_CO MPLETED)); 447 "PaymentRequest.UserHadSuggestionsForEverything.EffectOn Completion",
448 JourneyLogger.COMPLETION_STATUS_COMPLETED));
323 449
324 assertEquals(0, 450 assertEquals(0,
325 RecordHistogram.getHistogramValueCountForTesting( 451 RecordHistogram.getHistogramValueCountForTesting(
326 "PaymentRequest.UserDidNotHaveSuggestionsForEverything.E ffectOnCompletion", 452 "PaymentRequest.UserDidNotHaveSuggestionsForEverything.E ffectOnCompletion",
327 PaymentRequestJourneyLogger.COMPLETION_STATUS_COMPLETED) ); 453 JourneyLogger.COMPLETION_STATUS_COMPLETED));
328 } 454 }
329 455
330 /** 456 /**
331 * Tests that the completion status metrics based on whether the user had su ggestions for all 457 * Tests that the completion status metrics based on whether the user had su ggestions for all
332 * the requested sections are logged as correctly. 458 * the requested sections are logged as correctly.
333 */ 459 */
334 @SmallTest 460 @SmallTest
335 @Feature({"Payments"}) 461 @Feature({"Payments"})
336 public void testRecordJourneyStatsHistograms_SuggestionsForEverything_Aborte d() { 462 public void testRecordJourneyStatsHistograms_SuggestionsForEverything_UserAb orted() {
337 PaymentRequestJourneyLogger logger = new PaymentRequestJourneyLogger(); 463 JourneyLogger logger = new JourneyLogger();
338 464
339 // Simulate that the user had suggestions for all the requested sections . 465 // Simulate that the user had suggestions for all the requested sections .
340 logger.setNumberOfSuggestionsShown(PaymentRequestJourneyLogger.SECTION_C REDIT_CARDS, 1); 466 logger.setNumberOfSuggestionsShown(JourneyLogger.SECTION_CREDIT_CARDS, 1 );
341 467
342 // Simulate that the user aborts the checkout. 468 // Simulate that the user aborts the checkout.
343 logger.recordJourneyStatsHistograms("Aborted"); 469 logger.recordJourneyStatsHistograms(JourneyLogger.COMPLETION_STATUS_USER _ABORTED);
344 470
345 // Make sure the appropriate metric was logged. 471 // Make sure the appropriate metric was logged.
346 assertEquals(1, RecordHistogram.getHistogramValueCountForTesting( 472 assertEquals(1,
347 "PaymentRequest.UserHadSuggestionsForEverything. EffectOnCompletion", 473 RecordHistogram.getHistogramValueCountForTesting(
348 PaymentRequestJourneyLogger.COMPLETION_STATUS_AB ORTED)); 474 "PaymentRequest.UserHadSuggestionsForEverything.EffectOn Completion",
475 JourneyLogger.COMPLETION_STATUS_USER_ABORTED));
349 476
350 assertEquals(0, 477 assertEquals(0,
351 RecordHistogram.getHistogramValueCountForTesting( 478 RecordHistogram.getHistogramValueCountForTesting(
352 "PaymentRequest.UserDidNotHaveSuggestionsForEverything.E ffectOnCompletion", 479 "PaymentRequest.UserDidNotHaveSuggestionsForEverything.E ffectOnCompletion",
353 PaymentRequestJourneyLogger.COMPLETION_STATUS_ABORTED)); 480 JourneyLogger.COMPLETION_STATUS_USER_ABORTED));
354 } 481 }
355 482
356 /** 483 /**
484 * Tests that the completion status metrics based on whether the user had su ggestions for all
485 * the requested sections are logged as correctly.
486 */
487 @SmallTest
488 @Feature({"Payments"})
489 public void testRecordJourneyStatsHistograms_SuggestionsForEverything_OtherA borted() {
490 JourneyLogger logger = new JourneyLogger();
491
492 // Simulate that the user had suggestions for all the requested sections .
493 logger.setNumberOfSuggestionsShown(JourneyLogger.SECTION_CREDIT_CARDS, 1 );
494
495 // Simulate that the user aborts the checkout.
496 logger.recordJourneyStatsHistograms(JourneyLogger.COMPLETION_STATUS_OTHE R_ABORTED);
497
498 // Make sure the appropriate metric was logged.
499 assertEquals(1,
500 RecordHistogram.getHistogramValueCountForTesting(
501 "PaymentRequest.UserHadSuggestionsForEverything.EffectOn Completion",
502 JourneyLogger.COMPLETION_STATUS_OTHER_ABORTED));
503
504 assertEquals(0,
505 RecordHistogram.getHistogramValueCountForTesting(
506 "PaymentRequest.UserDidNotHaveSuggestionsForEverything.E ffectOnCompletion",
507 JourneyLogger.COMPLETION_STATUS_OTHER_ABORTED));
508 }
509
510 /**
357 * Tests that the completion status metrics based on whether the user had su ggestions for all 511 * Tests that the completion status metrics based on whether the user had su ggestions for all
358 * the requested sections are logged as correctly. 512 * the requested sections are logged as correctly.
359 */ 513 */
360 @SmallTest 514 @SmallTest
361 @Feature({"Payments"}) 515 @Feature({"Payments"})
362 public void testRecordJourneyStatsHistograms_NoSuggestionsForEverything_Comp leted() { 516 public void testRecordJourneyStatsHistograms_NoSuggestionsForEverything_Comp leted() {
363 PaymentRequestJourneyLogger logger = new PaymentRequestJourneyLogger(); 517 JourneyLogger logger = new JourneyLogger();
364 518
365 // Simulate that the user did not have suggestions for all the requested sections. 519 // Simulate that the user did not have suggestions for all the requested sections.
366 logger.setNumberOfSuggestionsShown(PaymentRequestJourneyLogger.SECTION_C REDIT_CARDS, 0); 520 logger.setNumberOfSuggestionsShown(JourneyLogger.SECTION_CREDIT_CARDS, 0 );
367 521
368 // Simulate that the user completes the checkout. 522 // Simulate that the user completes the checkout.
369 logger.recordJourneyStatsHistograms("Completed"); 523 logger.recordJourneyStatsHistograms(JourneyLogger.COMPLETION_STATUS_COMP LETED);
370 524
371 // Make sure the appropriate metric was logged. 525 // Make sure the appropriate metric was logged.
372 assertEquals(1, 526 assertEquals(1,
373 RecordHistogram.getHistogramValueCountForTesting( 527 RecordHistogram.getHistogramValueCountForTesting(
374 "PaymentRequest.UserDidNotHaveSuggestionsForEverything.E ffectOnCompletion", 528 "PaymentRequest.UserDidNotHaveSuggestionsForEverything.E ffectOnCompletion",
375 PaymentRequestJourneyLogger.COMPLETION_STATUS_COMPLETED) ); 529 JourneyLogger.COMPLETION_STATUS_COMPLETED));
376 530
377 assertEquals(0, RecordHistogram.getHistogramValueCountForTesting( 531 assertEquals(0,
378 "PaymentRequest.UserHadSuggestionsForEverything. EffectOnCompletion", 532 RecordHistogram.getHistogramValueCountForTesting(
379 PaymentRequestJourneyLogger.COMPLETION_STATUS_CO MPLETED)); 533 "PaymentRequest.UserHadSuggestionsForEverything.EffectOn Completion",
534 JourneyLogger.COMPLETION_STATUS_COMPLETED));
380 } 535 }
381 536
382 /** 537 /**
383 * Tests that the completion status metrics based on whether the user had su ggestions for all 538 * Tests that the completion status metrics based on whether the user had su ggestions for all
384 * the requested sections are logged as correctly. 539 * the requested sections are logged as correctly.
385 */ 540 */
386 @SmallTest 541 @SmallTest
387 @Feature({"Payments"}) 542 @Feature({"Payments"})
388 public void testRecordJourneyStatsHistograms_NoSuggestionsForEverything_Abor ted() { 543 public void testRecordJourneyStatsHistograms_NoSuggestionsForEverything_User Aborted() {
389 PaymentRequestJourneyLogger logger = new PaymentRequestJourneyLogger(); 544 JourneyLogger logger = new JourneyLogger();
390 545
391 // Simulate that the user had suggestions for all the requested sections . 546 // Simulate that the user did not have suggestions for all the requested sections.
392 logger.setNumberOfSuggestionsShown(PaymentRequestJourneyLogger.SECTION_C REDIT_CARDS, 0); 547 logger.setNumberOfSuggestionsShown(JourneyLogger.SECTION_CREDIT_CARDS, 0 );
393 548
394 // Simulate that the user aborts the checkout. 549 // Simulate that the user aborts the checkout.
395 logger.recordJourneyStatsHistograms("Aborted"); 550 logger.recordJourneyStatsHistograms(JourneyLogger.COMPLETION_STATUS_USER _ABORTED);
396 551
397 // Make sure the appropriate metric was logged. 552 // Make sure the appropriate metric was logged.
398 assertEquals(1, 553 assertEquals(1,
399 RecordHistogram.getHistogramValueCountForTesting( 554 RecordHistogram.getHistogramValueCountForTesting(
400 "PaymentRequest.UserDidNotHaveSuggestionsForEverything.E ffectOnCompletion", 555 "PaymentRequest.UserDidNotHaveSuggestionsForEverything.E ffectOnCompletion",
401 PaymentRequestJourneyLogger.COMPLETION_STATUS_ABORTED)); 556 JourneyLogger.COMPLETION_STATUS_USER_ABORTED));
402 557
403 assertEquals(0, RecordHistogram.getHistogramValueCountForTesting( 558 assertEquals(0,
404 "PaymentRequest.UserHadSuggestionsForEverything. EffectOnCompletion", 559 RecordHistogram.getHistogramValueCountForTesting(
405 PaymentRequestJourneyLogger.COMPLETION_STATUS_AB ORTED)); 560 "PaymentRequest.UserHadSuggestionsForEverything.EffectOn Completion",
561 JourneyLogger.COMPLETION_STATUS_USER_ABORTED));
406 } 562 }
407 563
408 /** 564 /**
565 * Tests that the completion status metrics based on whether the user had su ggestions for all
566 * the requested sections are logged as correctly.
567 */
568 @SmallTest
569 @Feature({"Payments"})
570 public void testRecordJourneyStatsHistograms_NoSuggestionsForEverything_Othe rAborted() {
571 JourneyLogger logger = new JourneyLogger();
572
573 // Simulate that the user did not have suggestions for all the requested sections.
574 logger.setNumberOfSuggestionsShown(JourneyLogger.SECTION_CREDIT_CARDS, 0 );
575
576 // Simulate that the user aborts the checkout.
577 logger.recordJourneyStatsHistograms(JourneyLogger.COMPLETION_STATUS_OTHE R_ABORTED);
578
579 // Make sure the appropriate metric was logged.
580 assertEquals(1,
581 RecordHistogram.getHistogramValueCountForTesting(
582 "PaymentRequest.UserDidNotHaveSuggestionsForEverything.E ffectOnCompletion",
583 JourneyLogger.COMPLETION_STATUS_OTHER_ABORTED));
584
585 assertEquals(0,
586 RecordHistogram.getHistogramValueCountForTesting(
587 "PaymentRequest.UserHadSuggestionsForEverything.EffectOn Completion",
588 JourneyLogger.COMPLETION_STATUS_OTHER_ABORTED));
589 }
590
591 /**
592 * Tests that the metrics are logged correctly for two simultaneous Payment Requests.
593 */
594 @SmallTest
595 @Feature({"Payments"})
596 public void testRecordJourneyStatsHistograms_TwoPaymentRequests() {
597 JourneyLogger logger1 = new JourneyLogger();
598 JourneyLogger logger2 = new JourneyLogger();
599
600 // Make the two loggers have different data.
601 logger1.setShowCalled();
602 logger2.setShowCalled();
603
604 logger1.setCanMakePaymentValue(true);
605
606 logger1.setNumberOfSuggestionsShown(JourneyLogger.SECTION_CREDIT_CARDS, 1);
607 logger2.setNumberOfSuggestionsShown(JourneyLogger.SECTION_CREDIT_CARDS, 0);
608
609 // Simulate that the user completes one checkout and aborts the other.
610 logger1.recordJourneyStatsHistograms(JourneyLogger.COMPLETION_STATUS_COM PLETED);
611 logger2.recordJourneyStatsHistograms(JourneyLogger.COMPLETION_STATUS_USE R_ABORTED);
612
613 // Make sure the appropriate metric was logged for logger1.
614 assertEquals(1,
615 RecordHistogram.getHistogramValueCountForTesting(
616 "PaymentRequest.UserHadSuggestionsForEverything.EffectOn Completion",
617 JourneyLogger.COMPLETION_STATUS_COMPLETED));
618 assertEquals(1,
619 RecordHistogram.getHistogramValueCountForTesting(
620 "PaymentRequest.CanMakePayment.Usage",
621 JourneyLogger.CAN_MAKE_PAYMENT_USED));
622 assertEquals(1,
623 RecordHistogram.getHistogramValueCountForTesting(
624 "PaymentRequest.CanMakePayment.Used.TrueWithShowEffectOn Completion",
625 JourneyLogger.COMPLETION_STATUS_COMPLETED));
626
627 // Make sure the appropriate metric was logged for logger2.
628 assertEquals(1,
629 RecordHistogram.getHistogramValueCountForTesting(
630 "PaymentRequest.UserDidNotHaveSuggestionsForEverything.E ffectOnCompletion",
631 JourneyLogger.COMPLETION_STATUS_USER_ABORTED));
632 assertEquals(1,
633 RecordHistogram.getHistogramValueCountForTesting(
634 "PaymentRequest.CanMakePayment.Usage",
635 JourneyLogger.CAN_MAKE_PAYMENT_NOT_USED));
636 assertEquals(1,
637 RecordHistogram.getHistogramValueCountForTesting(
638 "PaymentRequest.CanMakePayment.NotUsed.WithShowEffectOnC ompletion",
639 JourneyLogger.COMPLETION_STATUS_USER_ABORTED));
640 }
641
642 /**
409 * Asserts that no histogram is logged. 643 * Asserts that no histogram is logged.
410 */ 644 */
411 private void assertNoLogForCanMakePayment() { 645 private void assertNoLogForCanMakePayment() {
412 // Use stats. 646 // Use stats.
413 for (int i = 0; i < PaymentRequestJourneyLogger.CAN_MAKE_PAYMENT_USE_MAX ; ++i) { 647 for (int i = 0; i < JourneyLogger.CAN_MAKE_PAYMENT_USE_MAX; ++i) {
414 assertEquals(0, RecordHistogram.getHistogramValueCountForTesting( 648 assertEquals(0, RecordHistogram.getHistogramValueCountForTesting(
415 "PaymentRequest.CanMakePayment.Usage", i)); 649 "PaymentRequest.CanMakePayment.Usage", i));
416 } 650 }
417 651
418 // Effect on show stats. 652 // Effect on show stats.
419 for (int i = 0; i < PaymentRequestJourneyLogger.CMP_SHOW_MAX; ++i) { 653 for (int i = 0; i < JourneyLogger.CMP_SHOW_MAX; ++i) {
420 assertEquals(0, RecordHistogram.getHistogramValueCountForTesting( 654 assertEquals(0,
421 "PaymentRequest.CanMakePayment.Used.EffetOnS how", i)); 655 RecordHistogram.getHistogramValueCountForTesting(
656 "PaymentRequest.CanMakePayment.Used.EffectOnShow", i ));
422 } 657 }
423 658
424 // Effect on completion stats. 659 // Effect on completion stats.
425 for (int i = 0; i < PaymentRequestJourneyLogger.COMPLETION_STATUS_MAX; + +i) { 660 for (int i = 0; i < JourneyLogger.COMPLETION_STATUS_MAX; ++i) {
426 assertEquals(0, 661 assertEquals(0,
427 RecordHistogram.getHistogramValueCountForTesting( 662 RecordHistogram.getHistogramValueCountForTesting(
428 "PaymentRequest.CanMakePayment.NotUsed.WithShowEffec tOnCompletion", i)); 663 "PaymentRequest.CanMakePayment.NotUsed.WithShowEffec tOnCompletion", i));
429 assertEquals( 664 assertEquals(
430 0, RecordHistogram.getHistogramValueCountForTesting( 665 0, RecordHistogram.getHistogramValueCountForTesting(
431 "PaymentRequest.CanMakePayment.Used.TrueWithShowE ffectOnCompletion", 666 "PaymentRequest.CanMakePayment.Used.TrueWithShowE ffectOnCompletion",
432 i)); 667 i));
433 assertEquals( 668 assertEquals(
434 0, RecordHistogram.getHistogramValueCountForTesting( 669 0, RecordHistogram.getHistogramValueCountForTesting(
435 "PaymentRequest.CanMakePayment.Used.FalseWithShow EffectOnCompletion", 670 "PaymentRequest.CanMakePayment.Used.FalseWithShow EffectOnCompletion",
436 i)); 671 i));
437 } 672 }
438 } 673 }
439 } 674 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698