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

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: 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 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("");
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_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 Abort() {
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("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_ABORTED));
76 } 82 }
77 83
78 /** 84 /**
79 * Tests the canMakePayment stats for the case where the merchant does not u se it and the 85 * Tests the canMakePayment stats for the case where the merchant does not u se it and the
80 * transaction is completed. 86 * transaction is completed.
81 */ 87 */
82 @SmallTest 88 @SmallTest
83 @Feature({"Payments"}) 89 @Feature({"Payments"})
84 public void testRecordJourneyStatsHistograms_CanMakePaymentNotCalled_ShowAnd Complete() { 90 public void testRecordJourneyStatsHistograms_CanMakePaymentNotCalled_ShowAnd Complete() {
85 PaymentRequestJourneyLogger logger = new PaymentRequestJourneyLogger(); 91 JourneyLogger logger = new JourneyLogger();
86 assertNoLogForCanMakePayment(); 92 assertNoLogForCanMakePayment();
87 93
88 // The merchant does not query CanMakePayment, show the PaymentRequest a nd the user 94 // The merchant does not query CanMakePayment, show the PaymentRequest a nd the user
89 // completes it. 95 // completes it.
90 logger.setShowCalled(); 96 logger.setShowCalled();
91 logger.recordJourneyStatsHistograms("Completed"); 97 logger.recordJourneyStatsHistograms("Completed");
92 98
93 // CanMakePayment was not used. 99 // CanMakePayment was not used.
94 assertEquals(1, RecordHistogram.getHistogramValueCountForTesting( 100 assertEquals(1,
95 "PaymentRequest.CanMakePayment.Usage", 101 RecordHistogram.getHistogramValueCountForTesting(
96 PaymentRequestJourneyLogger.CAN_MAKE_PAYMENT_NOT _USED)); 102 "PaymentRequest.CanMakePayment.Usage",
103 JourneyLogger.CAN_MAKE_PAYMENT_NOT_USED));
97 104
98 // There should be a record for a completion when CanMakePayment is not used but the PR is 105 // There should be a record for a completion when CanMakePayment is not used but the PR is
99 // shown to the user. 106 // shown to the user.
100 assertEquals(1, RecordHistogram.getHistogramValueCountForTesting( 107 assertEquals(1,
101 "PaymentRequest.CanMakePayment.NotUsed.WithShowE ffectOnCompletion", 108 RecordHistogram.getHistogramValueCountForTesting(
102 PaymentRequestJourneyLogger.COMPLETION_STATUS_CO MPLETED)); 109 "PaymentRequest.CanMakePayment.NotUsed.WithShowEffectOnC ompletion",
110 JourneyLogger.COMPLETION_STATUS_COMPLETED));
103 } 111 }
104 112
105 /** 113 /**
106 * Tests the canMakePayment stats for the case where the merchant uses it, r eturns false and 114 * Tests the canMakePayment stats for the case where the merchant uses it, r eturns false and
107 * show is not called. 115 * show is not called.
108 */ 116 */
109 @SmallTest 117 @SmallTest
110 @Feature({"Payments"}) 118 @Feature({"Payments"})
111 public void testRecordJourneyStatsHistograms_CanMakePaymentCalled_FalseAndNo Show() { 119 public void testRecordJourneyStatsHistograms_CanMakePaymentCalled_FalseAndNo Show() {
112 PaymentRequestJourneyLogger logger = new PaymentRequestJourneyLogger(); 120 JourneyLogger logger = new JourneyLogger();
113 assertNoLogForCanMakePayment(); 121 assertNoLogForCanMakePayment();
114 122
115 // The user cannot make payment and the PaymentRequest is not shown. 123 // The user cannot make payment and the PaymentRequest is not shown.
116 logger.setCanMakePaymentValue(false); 124 logger.setCanMakePaymentValue(false);
117 logger.recordJourneyStatsHistograms(""); 125 logger.recordJourneyStatsHistograms("");
118 126
119 // CanMakePayment was used. 127 // CanMakePayment was used.
120 assertEquals(1, RecordHistogram.getHistogramValueCountForTesting( 128 assertEquals(1,
121 "PaymentRequest.CanMakePayment.Usage", 129 RecordHistogram.getHistogramValueCountForTesting(
122 PaymentRequestJourneyLogger.CAN_MAKE_PAYMENT_USE D)); 130 "PaymentRequest.CanMakePayment.Usage",
131 JourneyLogger.CAN_MAKE_PAYMENT_USED));
123 132
124 // The CanMakePayment effect on show should be recorded as being false a nd not shown. 133 // The CanMakePayment effect on show should be recorded as being false a nd not shown.
125 assertEquals(1, RecordHistogram.getHistogramValueCountForTesting( 134 assertEquals(1,
126 "PaymentRequest.CanMakePayment.Used.EffetOnShow" , 135 RecordHistogram.getHistogramValueCountForTesting(
127 PaymentRequestJourneyLogger 136 "PaymentRequest.CanMakePayment.Used.EffetOnShow",
128 .CMP_SHOW_COULD_NOT_MAKE_PAYMENT_AND_DID _NOT_SHOW)); 137 JourneyLogger.CMP_SHOW_COULD_NOT_MAKE_PAYMENT_AND_DID_NO T_SHOW));
129 138
130 // There should be no completion stats since PR was not shown to the use r. 139 // There should be no completion stats since PR was not shown to the use r.
131 assertEquals(0, RecordHistogram.getHistogramValueCountForTesting( 140 assertEquals(0,
132 "PaymentRequest.CanMakePayment.NotUsed.WithShowE ffectOnCompletion", 141 RecordHistogram.getHistogramValueCountForTesting(
133 PaymentRequestJourneyLogger.COMPLETION_STATUS_AB ORTED)); 142 "PaymentRequest.CanMakePayment.NotUsed.WithShowEffectOnC ompletion",
134 assertEquals(0, RecordHistogram.getHistogramValueCountForTesting( 143 JourneyLogger.COMPLETION_STATUS_ABORTED));
135 "PaymentRequest.CanMakePayment.NotUsed.WithShowE ffectOnCompletion", 144 assertEquals(0,
136 PaymentRequestJourneyLogger.COMPLETION_STATUS_CO MPLETED)); 145 RecordHistogram.getHistogramValueCountForTesting(
146 "PaymentRequest.CanMakePayment.NotUsed.WithShowEffectOnC ompletion",
147 JourneyLogger.COMPLETION_STATUS_COMPLETED));
137 } 148 }
138 149
139 /** 150 /**
140 * Tests the canMakePayment stats for the case where the merchant uses it, r eturns true and 151 * Tests the canMakePayment stats for the case where the merchant uses it, r eturns true and
141 * show is not called. 152 * show is not called.
142 */ 153 */
143 @SmallTest 154 @SmallTest
144 @Feature({"Payments"}) 155 @Feature({"Payments"})
145 public void testRecordJourneyStatsHistograms_CanMakePaymentCalled_TrueAndNoS how() { 156 public void testRecordJourneyStatsHistograms_CanMakePaymentCalled_TrueAndNoS how() {
146 PaymentRequestJourneyLogger logger = new PaymentRequestJourneyLogger(); 157 JourneyLogger logger = new JourneyLogger();
147 assertNoLogForCanMakePayment(); 158 assertNoLogForCanMakePayment();
148 159
149 // The user can make a payment but the Payment Request is not shown. 160 // The user can make a payment but the Payment Request is not shown.
150 logger.setCanMakePaymentValue(true); 161 logger.setCanMakePaymentValue(true);
151 logger.recordJourneyStatsHistograms(""); 162 logger.recordJourneyStatsHistograms("");
152 163
153 // CanMakePayment was used. 164 // CanMakePayment was used.
154 assertEquals(1, RecordHistogram.getHistogramValueCountForTesting( 165 assertEquals(1,
155 "PaymentRequest.CanMakePayment.Usage", 166 RecordHistogram.getHistogramValueCountForTesting(
156 PaymentRequestJourneyLogger.CAN_MAKE_PAYMENT_USE D)); 167 "PaymentRequest.CanMakePayment.Usage",
168 JourneyLogger.CAN_MAKE_PAYMENT_USED));
157 169
158 // The CanMakePayment effect on show should be recorded as being true an d not shown. 170 // The CanMakePayment effect on show should be recorded as being true an d not shown.
159 assertEquals(1, RecordHistogram.getHistogramValueCountForTesting( 171 assertEquals(1,
160 "PaymentRequest.CanMakePayment.Used.EffetOnShow" , 172 RecordHistogram.getHistogramValueCountForTesting(
161 PaymentRequestJourneyLogger.CMP_SHOW_COULD_MAKE_ PAYMENT)); 173 "PaymentRequest.CanMakePayment.Used.EffetOnShow",
174 JourneyLogger.CMP_SHOW_COULD_MAKE_PAYMENT));
162 175
163 // There should be no completion stats since PR was not shown to the use r. 176 // There should be no completion stats since PR was not shown to the use r.
164 assertEquals(0, RecordHistogram.getHistogramValueCountForTesting( 177 assertEquals(0,
165 "PaymentRequest.CanMakePayment.NotUsed.WithShowE ffectOnCompletion", 178 RecordHistogram.getHistogramValueCountForTesting(
166 PaymentRequestJourneyLogger.COMPLETION_STATUS_AB ORTED)); 179 "PaymentRequest.CanMakePayment.NotUsed.WithShowEffectOnC ompletion",
167 assertEquals(0, RecordHistogram.getHistogramValueCountForTesting( 180 JourneyLogger.COMPLETION_STATUS_ABORTED));
168 "PaymentRequest.CanMakePayment.NotUsed.WithShowE ffectOnCompletion", 181 assertEquals(0,
169 PaymentRequestJourneyLogger.COMPLETION_STATUS_CO MPLETED)); 182 RecordHistogram.getHistogramValueCountForTesting(
183 "PaymentRequest.CanMakePayment.NotUsed.WithShowEffectOnC ompletion",
184 JourneyLogger.COMPLETION_STATUS_COMPLETED));
170 } 185 }
171 186
172 /** 187 /**
173 * Tests the canMakePayment stats for the case where the merchant uses it, r eturns false, show 188 * Tests the canMakePayment stats for the case where the merchant uses it, r eturns false, show
174 * is called but the transaction is aborted. 189 * is called but the transaction is aborted.
175 */ 190 */
176 @SmallTest 191 @SmallTest
177 @Feature({"Payments"}) 192 @Feature({"Payments"})
178 public void testRecordJourneyStatsHistograms_CanMakePaymentCalled_FalseShowA ndAbort() { 193 public void testRecordJourneyStatsHistograms_CanMakePaymentCalled_FalseShowA ndAbort() {
179 PaymentRequestJourneyLogger logger = new PaymentRequestJourneyLogger(); 194 JourneyLogger logger = new JourneyLogger();
180 assertNoLogForCanMakePayment(); 195 assertNoLogForCanMakePayment();
181 196
182 // The user cannot make a payment. the payment request is shown but abor ted. 197 // The user cannot make a payment. the payment request is shown but abor ted.
183 logger.setShowCalled(); 198 logger.setShowCalled();
184 logger.setCanMakePaymentValue(false); 199 logger.setCanMakePaymentValue(false);
185 logger.recordJourneyStatsHistograms("Aborted"); 200 logger.recordJourneyStatsHistograms("Aborted");
186 201
187 // CanMakePayment was used. 202 // CanMakePayment was used.
188 assertEquals(1, RecordHistogram.getHistogramValueCountForTesting( 203 assertEquals(1,
189 "PaymentRequest.CanMakePayment.Usage", 204 RecordHistogram.getHistogramValueCountForTesting(
190 PaymentRequestJourneyLogger.CAN_MAKE_PAYMENT_USE D)); 205 "PaymentRequest.CanMakePayment.Usage",
206 JourneyLogger.CAN_MAKE_PAYMENT_USED));
191 207
192 // The CanMakePayment effect on show should be recorded as being true an d not shown. 208 // The CanMakePayment effect on show should be recorded as being true an d not shown.
193 assertEquals(1, RecordHistogram.getHistogramValueCountForTesting( 209 assertEquals(1,
194 "PaymentRequest.CanMakePayment.Used.EffetOnShow" , 210 RecordHistogram.getHistogramValueCountForTesting(
195 PaymentRequestJourneyLogger.CMP_SHOW_DID_SHOW)); 211 "PaymentRequest.CanMakePayment.Used.EffetOnShow",
212 JourneyLogger.CMP_SHOW_DID_SHOW));
196 213
197 // There should be a record for an abort when CanMakePayment is false bu t the PR is shown to 214 // There should be a record for an abort when CanMakePayment is false bu t the PR is shown to
198 // the user. 215 // the user.
199 assertEquals( 216 assertEquals(1,
200 1, RecordHistogram.getHistogramValueCountForTesting( 217 RecordHistogram.getHistogramValueCountForTesting(
201 "PaymentRequest.CanMakePayment.Used.FalseWithShowEffe ctOnCompletion", 218 "PaymentRequest.CanMakePayment.Used.FalseWithShowEffectO nCompletion",
202 PaymentRequestJourneyLogger.COMPLETION_STATUS_ABORTED )); 219 JourneyLogger.COMPLETION_STATUS_ABORTED));
203 } 220 }
204 221
205 /** 222 /**
206 * Tests the canMakePayment stats for the case where the merchant uses it, r eturns false, 223 * Tests the canMakePayment stats for the case where the merchant uses it, r eturns false,
207 * show is called and the transaction is completed. 224 * show is called and the transaction is completed.
208 */ 225 */
209 @SmallTest 226 @SmallTest
210 @Feature({"Payments"}) 227 @Feature({"Payments"})
211 public void testRecordJourneyStatsHistograms_CanMakePaymentCalled_FalseShowA ndComplete() { 228 public void testRecordJourneyStatsHistograms_CanMakePaymentCalled_FalseShowA ndComplete() {
212 PaymentRequestJourneyLogger logger = new PaymentRequestJourneyLogger(); 229 JourneyLogger logger = new JourneyLogger();
213 assertNoLogForCanMakePayment(); 230 assertNoLogForCanMakePayment();
214 231
215 // The user cannot make a payment. the payment request is shown and comp leted. 232 // The user cannot make a payment. the payment request is shown and comp leted.
216 logger.setShowCalled(); 233 logger.setShowCalled();
217 logger.setCanMakePaymentValue(false); 234 logger.setCanMakePaymentValue(false);
218 logger.recordJourneyStatsHistograms("Completed"); 235 logger.recordJourneyStatsHistograms("Completed");
219 236
220 // CanMakePayment was used. 237 // CanMakePayment was used.
221 assertEquals(1, RecordHistogram.getHistogramValueCountForTesting( 238 assertEquals(1,
222 "PaymentRequest.CanMakePayment.Usage", 239 RecordHistogram.getHistogramValueCountForTesting(
223 PaymentRequestJourneyLogger.CAN_MAKE_PAYMENT_USE D)); 240 "PaymentRequest.CanMakePayment.Usage",
241 JourneyLogger.CAN_MAKE_PAYMENT_USED));
224 242
225 // The CanMakePayment effect on show should be recorded as being true an d not shown. 243 // The CanMakePayment effect on show should be recorded as being true an d not shown.
226 assertEquals(1, RecordHistogram.getHistogramValueCountForTesting( 244 assertEquals(1,
227 "PaymentRequest.CanMakePayment.Used.EffetOnShow" , 245 RecordHistogram.getHistogramValueCountForTesting(
228 PaymentRequestJourneyLogger.CMP_SHOW_DID_SHOW)); 246 "PaymentRequest.CanMakePayment.Used.EffetOnShow",
247 JourneyLogger.CMP_SHOW_DID_SHOW));
229 248
230 // There should be a record for a completion when CanMakePayment is fals e and the PR is 249 // There should be a record for a completion when CanMakePayment is fals e and the PR is
231 // shown to the user. 250 // shown to the user.
232 assertEquals( 251 assertEquals(1,
233 1, RecordHistogram.getHistogramValueCountForTesting( 252 RecordHistogram.getHistogramValueCountForTesting(
234 "PaymentRequest.CanMakePayment.Used.FalseWithShowEffe ctOnCompletion", 253 "PaymentRequest.CanMakePayment.Used.FalseWithShowEffectO nCompletion",
235 PaymentRequestJourneyLogger.COMPLETION_STATUS_COMPLET ED)); 254 JourneyLogger.COMPLETION_STATUS_COMPLETED));
236 } 255 }
237 256
238 /** 257 /**
239 * Tests the canMakePayment stats for the case where the merchant uses it, r eturns true, show 258 * Tests the canMakePayment stats for the case where the merchant uses it, r eturns true, show
240 * is called but the transaction is aborted. 259 * is called but the transaction is aborted.
241 */ 260 */
242 @SmallTest 261 @SmallTest
243 @Feature({"Payments"}) 262 @Feature({"Payments"})
244 public void testRecordJourneyStatsHistograms_CanMakePaymentCalled_TrueShowAn dAbort() { 263 public void testRecordJourneyStatsHistograms_CanMakePaymentCalled_TrueShowAn dAbort() {
245 PaymentRequestJourneyLogger logger = new PaymentRequestJourneyLogger(); 264 JourneyLogger logger = new JourneyLogger();
246 assertNoLogForCanMakePayment(); 265 assertNoLogForCanMakePayment();
247 266
248 // The user cannot make a payment. the payment request is shown and comp leted. 267 // The user cannot make a payment. the payment request is shown and comp leted.
249 logger.setShowCalled(); 268 logger.setShowCalled();
250 logger.setCanMakePaymentValue(true); 269 logger.setCanMakePaymentValue(true);
251 logger.recordJourneyStatsHistograms("Aborted"); 270 logger.recordJourneyStatsHistograms("Aborted");
252 271
253 // CanMakePayment was used. 272 // CanMakePayment was used.
254 assertEquals(1, RecordHistogram.getHistogramValueCountForTesting( 273 assertEquals(1,
255 "PaymentRequest.CanMakePayment.Usage", 274 RecordHistogram.getHistogramValueCountForTesting(
256 PaymentRequestJourneyLogger.CAN_MAKE_PAYMENT_USE D)); 275 "PaymentRequest.CanMakePayment.Usage",
276 JourneyLogger.CAN_MAKE_PAYMENT_USED));
257 277
258 // The CanMakePayment effect on show should be recorded as being true an d not shown. 278 // The CanMakePayment effect on show should be recorded as being true an d not shown.
259 assertEquals(1, RecordHistogram.getHistogramValueCountForTesting( 279 assertEquals(1,
260 "PaymentRequest.CanMakePayment.Used.EffetOnShow" , 280 RecordHistogram.getHistogramValueCountForTesting(
261 PaymentRequestJourneyLogger.CMP_SHOW_DID_SHOW 281 "PaymentRequest.CanMakePayment.Used.EffetOnShow",
262 | PaymentRequestJourneyLogger.CMP_SHOW_C OULD_MAKE_PAYMENT)); 282 JourneyLogger.CMP_SHOW_DID_SHOW
283 | JourneyLogger.CMP_SHOW_COULD_MAKE_PAYMENT));
263 284
264 // There should be a record for an abort when CanMakePayment is true and the PR is shown to 285 // There should be a record for an abort when CanMakePayment is true and the PR is shown to
265 // the user. 286 // the user.
266 assertEquals(1, RecordHistogram.getHistogramValueCountForTesting( 287 assertEquals(1,
267 "PaymentRequest.CanMakePayment.Used.TrueWithShow EffectOnCompletion", 288 RecordHistogram.getHistogramValueCountForTesting(
268 PaymentRequestJourneyLogger.COMPLETION_STATUS_AB ORTED)); 289 "PaymentRequest.CanMakePayment.Used.TrueWithShowEffectOn Completion",
290 JourneyLogger.COMPLETION_STATUS_ABORTED));
269 } 291 }
270 292
271 /** 293 /**
272 * Tests the canMakePayment stats for the case where the merchant uses it, r eturns true, show 294 * Tests the canMakePayment stats for the case where the merchant uses it, r eturns true, show
273 * is called and the transaction is completed. 295 * is called and the transaction is completed.
274 */ 296 */
275 @SmallTest 297 @SmallTest
276 @Feature({"Payments"}) 298 @Feature({"Payments"})
277 public void testRecordJourneyStatsHistograms_CanMakePaymentCalled_TrueShowAn dComplete() { 299 public void testRecordJourneyStatsHistograms_CanMakePaymentCalled_TrueShowAn dComplete() {
278 PaymentRequestJourneyLogger logger = new PaymentRequestJourneyLogger(); 300 JourneyLogger logger = new JourneyLogger();
279 assertNoLogForCanMakePayment(); 301 assertNoLogForCanMakePayment();
280 302
281 // The user cannot make a payment. the payment request is shown and comp leted. 303 // The user cannot make a payment. the payment request is shown and comp leted.
282 logger.setShowCalled(); 304 logger.setShowCalled();
283 logger.setCanMakePaymentValue(true); 305 logger.setCanMakePaymentValue(true);
284 logger.recordJourneyStatsHistograms("Completed"); 306 logger.recordJourneyStatsHistograms("Completed");
285 307
286 // CanMakePayment was used. 308 // CanMakePayment was used.
287 assertEquals(1, RecordHistogram.getHistogramValueCountForTesting( 309 assertEquals(1,
288 "PaymentRequest.CanMakePayment.Usage", 310 RecordHistogram.getHistogramValueCountForTesting(
289 PaymentRequestJourneyLogger.CAN_MAKE_PAYMENT_USE D)); 311 "PaymentRequest.CanMakePayment.Usage",
312 JourneyLogger.CAN_MAKE_PAYMENT_USED));
290 313
291 // The CanMakePayment effect on show should be recorded as being true an d not shown. 314 // The CanMakePayment effect on show should be recorded as being true an d not shown.
292 assertEquals(1, RecordHistogram.getHistogramValueCountForTesting( 315 assertEquals(1,
293 "PaymentRequest.CanMakePayment.Used.EffetOnShow" , 316 RecordHistogram.getHistogramValueCountForTesting(
294 PaymentRequestJourneyLogger.CMP_SHOW_DID_SHOW 317 "PaymentRequest.CanMakePayment.Used.EffetOnShow",
295 | PaymentRequestJourneyLogger.CMP_SHOW_C OULD_MAKE_PAYMENT)); 318 JourneyLogger.CMP_SHOW_DID_SHOW
319 | JourneyLogger.CMP_SHOW_COULD_MAKE_PAYMENT));
296 320
297 // There should be a record for a completion when CanMakePayment is true and the PR is shown 321 // There should be a record for a completion when CanMakePayment is true and the PR is shown
298 // to the user. 322 // to the user.
299 assertEquals(1, RecordHistogram.getHistogramValueCountForTesting( 323 assertEquals(1,
300 "PaymentRequest.CanMakePayment.Used.TrueWithShow EffectOnCompletion", 324 RecordHistogram.getHistogramValueCountForTesting(
301 PaymentRequestJourneyLogger.COMPLETION_STATUS_CO MPLETED)); 325 "PaymentRequest.CanMakePayment.Used.TrueWithShowEffectOn Completion",
326 JourneyLogger.COMPLETION_STATUS_COMPLETED));
302 } 327 }
303 328
304 /** 329 /**
305 * Tests that the completion status metrics based on whether the user had su ggestions for all 330 * Tests that the completion status metrics based on whether the user had su ggestions for all
306 * the requested sections are logged as correctly. 331 * the requested sections are logged as correctly.
307 */ 332 */
308 @SmallTest 333 @SmallTest
309 @Feature({"Payments"}) 334 @Feature({"Payments"})
310 public void testRecordJourneyStatsHistograms_SuggestionsForEverything_Comple ted() { 335 public void testRecordJourneyStatsHistograms_SuggestionsForEverything_Comple ted() {
311 PaymentRequestJourneyLogger logger = new PaymentRequestJourneyLogger(); 336 JourneyLogger logger = new JourneyLogger();
312 337
313 // Simulate that the user had suggestions for all the requested sections . 338 // Simulate that the user had suggestions for all the requested sections .
314 logger.setNumberOfSuggestionsShown(PaymentRequestJourneyLogger.SECTION_C REDIT_CARDS, 1); 339 logger.setNumberOfSuggestionsShown(JourneyLogger.SECTION_CREDIT_CARDS, 1 );
315 340
316 // Simulate that the user completes the checkout. 341 // Simulate that the user completes the checkout.
317 logger.recordJourneyStatsHistograms("Completed"); 342 logger.recordJourneyStatsHistograms("Completed");
318 343
319 // Make sure the appropriate metric was logged. 344 // Make sure the appropriate metric was logged.
320 assertEquals(1, RecordHistogram.getHistogramValueCountForTesting( 345 assertEquals(1,
321 "PaymentRequest.UserHadSuggestionsForEverything. EffectOnCompletion", 346 RecordHistogram.getHistogramValueCountForTesting(
322 PaymentRequestJourneyLogger.COMPLETION_STATUS_CO MPLETED)); 347 "PaymentRequest.UserHadSuggestionsForEverything.EffectOn Completion",
348 JourneyLogger.COMPLETION_STATUS_COMPLETED));
323 349
324 assertEquals(0, 350 assertEquals(0,
325 RecordHistogram.getHistogramValueCountForTesting( 351 RecordHistogram.getHistogramValueCountForTesting(
326 "PaymentRequest.UserDidNotHaveSuggestionsForEverything.E ffectOnCompletion", 352 "PaymentRequest.UserDidNotHaveSuggestionsForEverything.E ffectOnCompletion",
327 PaymentRequestJourneyLogger.COMPLETION_STATUS_COMPLETED) ); 353 JourneyLogger.COMPLETION_STATUS_COMPLETED));
328 } 354 }
329 355
330 /** 356 /**
331 * Tests that the completion status metrics based on whether the user had su ggestions for all 357 * Tests that the completion status metrics based on whether the user had su ggestions for all
332 * the requested sections are logged as correctly. 358 * the requested sections are logged as correctly.
333 */ 359 */
334 @SmallTest 360 @SmallTest
335 @Feature({"Payments"}) 361 @Feature({"Payments"})
336 public void testRecordJourneyStatsHistograms_SuggestionsForEverything_Aborte d() { 362 public void testRecordJourneyStatsHistograms_SuggestionsForEverything_Aborte d() {
337 PaymentRequestJourneyLogger logger = new PaymentRequestJourneyLogger(); 363 JourneyLogger logger = new JourneyLogger();
338 364
339 // Simulate that the user had suggestions for all the requested sections . 365 // Simulate that the user had suggestions for all the requested sections .
340 logger.setNumberOfSuggestionsShown(PaymentRequestJourneyLogger.SECTION_C REDIT_CARDS, 1); 366 logger.setNumberOfSuggestionsShown(JourneyLogger.SECTION_CREDIT_CARDS, 1 );
341 367
342 // Simulate that the user aborts the checkout. 368 // Simulate that the user aborts the checkout.
343 logger.recordJourneyStatsHistograms("Aborted"); 369 logger.recordJourneyStatsHistograms("Aborted");
344 370
345 // Make sure the appropriate metric was logged. 371 // Make sure the appropriate metric was logged.
346 assertEquals(1, RecordHistogram.getHistogramValueCountForTesting( 372 assertEquals(1,
347 "PaymentRequest.UserHadSuggestionsForEverything. EffectOnCompletion", 373 RecordHistogram.getHistogramValueCountForTesting(
348 PaymentRequestJourneyLogger.COMPLETION_STATUS_AB ORTED)); 374 "PaymentRequest.UserHadSuggestionsForEverything.EffectOn Completion",
375 JourneyLogger.COMPLETION_STATUS_ABORTED));
349 376
350 assertEquals(0, 377 assertEquals(0,
351 RecordHistogram.getHistogramValueCountForTesting( 378 RecordHistogram.getHistogramValueCountForTesting(
352 "PaymentRequest.UserDidNotHaveSuggestionsForEverything.E ffectOnCompletion", 379 "PaymentRequest.UserDidNotHaveSuggestionsForEverything.E ffectOnCompletion",
353 PaymentRequestJourneyLogger.COMPLETION_STATUS_ABORTED)); 380 JourneyLogger.COMPLETION_STATUS_ABORTED));
354 } 381 }
355 382
356 /** 383 /**
357 * Tests that the completion status metrics based on whether the user had su ggestions for all 384 * Tests that the completion status metrics based on whether the user had su ggestions for all
358 * the requested sections are logged as correctly. 385 * the requested sections are logged as correctly.
359 */ 386 */
360 @SmallTest 387 @SmallTest
361 @Feature({"Payments"}) 388 @Feature({"Payments"})
362 public void testRecordJourneyStatsHistograms_NoSuggestionsForEverything_Comp leted() { 389 public void testRecordJourneyStatsHistograms_NoSuggestionsForEverything_Comp leted() {
363 PaymentRequestJourneyLogger logger = new PaymentRequestJourneyLogger(); 390 JourneyLogger logger = new JourneyLogger();
364 391
365 // Simulate that the user did not have suggestions for all the requested sections. 392 // Simulate that the user did not have suggestions for all the requested sections.
366 logger.setNumberOfSuggestionsShown(PaymentRequestJourneyLogger.SECTION_C REDIT_CARDS, 0); 393 logger.setNumberOfSuggestionsShown(JourneyLogger.SECTION_CREDIT_CARDS, 0 );
367 394
368 // Simulate that the user completes the checkout. 395 // Simulate that the user completes the checkout.
369 logger.recordJourneyStatsHistograms("Completed"); 396 logger.recordJourneyStatsHistograms("Completed");
370 397
371 // Make sure the appropriate metric was logged. 398 // Make sure the appropriate metric was logged.
372 assertEquals(1, 399 assertEquals(1,
373 RecordHistogram.getHistogramValueCountForTesting( 400 RecordHistogram.getHistogramValueCountForTesting(
374 "PaymentRequest.UserDidNotHaveSuggestionsForEverything.E ffectOnCompletion", 401 "PaymentRequest.UserDidNotHaveSuggestionsForEverything.E ffectOnCompletion",
375 PaymentRequestJourneyLogger.COMPLETION_STATUS_COMPLETED) ); 402 JourneyLogger.COMPLETION_STATUS_COMPLETED));
376 403
377 assertEquals(0, RecordHistogram.getHistogramValueCountForTesting( 404 assertEquals(0,
378 "PaymentRequest.UserHadSuggestionsForEverything. EffectOnCompletion", 405 RecordHistogram.getHistogramValueCountForTesting(
379 PaymentRequestJourneyLogger.COMPLETION_STATUS_CO MPLETED)); 406 "PaymentRequest.UserHadSuggestionsForEverything.EffectOn Completion",
407 JourneyLogger.COMPLETION_STATUS_COMPLETED));
380 } 408 }
381 409
382 /** 410 /**
383 * Tests that the completion status metrics based on whether the user had su ggestions for all 411 * Tests that the completion status metrics based on whether the user had su ggestions for all
384 * the requested sections are logged as correctly. 412 * the requested sections are logged as correctly.
385 */ 413 */
386 @SmallTest 414 @SmallTest
387 @Feature({"Payments"}) 415 @Feature({"Payments"})
388 public void testRecordJourneyStatsHistograms_NoSuggestionsForEverything_Abor ted() { 416 public void testRecordJourneyStatsHistograms_NoSuggestionsForEverything_Abor ted() {
389 PaymentRequestJourneyLogger logger = new PaymentRequestJourneyLogger(); 417 JourneyLogger logger = new JourneyLogger();
390 418
391 // Simulate that the user had suggestions for all the requested sections . 419 // Simulate that the user had suggestions for all the requested sections .
392 logger.setNumberOfSuggestionsShown(PaymentRequestJourneyLogger.SECTION_C REDIT_CARDS, 0); 420 logger.setNumberOfSuggestionsShown(JourneyLogger.SECTION_CREDIT_CARDS, 0 );
393 421
394 // Simulate that the user aborts the checkout. 422 // Simulate that the user aborts the checkout.
395 logger.recordJourneyStatsHistograms("Aborted"); 423 logger.recordJourneyStatsHistograms("Aborted");
396 424
397 // Make sure the appropriate metric was logged. 425 // Make sure the appropriate metric was logged.
398 assertEquals(1, 426 assertEquals(1,
399 RecordHistogram.getHistogramValueCountForTesting( 427 RecordHistogram.getHistogramValueCountForTesting(
400 "PaymentRequest.UserDidNotHaveSuggestionsForEverything.E ffectOnCompletion", 428 "PaymentRequest.UserDidNotHaveSuggestionsForEverything.E ffectOnCompletion",
401 PaymentRequestJourneyLogger.COMPLETION_STATUS_ABORTED)); 429 JourneyLogger.COMPLETION_STATUS_ABORTED));
402 430
403 assertEquals(0, RecordHistogram.getHistogramValueCountForTesting( 431 assertEquals(0,
404 "PaymentRequest.UserHadSuggestionsForEverything. EffectOnCompletion", 432 RecordHistogram.getHistogramValueCountForTesting(
405 PaymentRequestJourneyLogger.COMPLETION_STATUS_AB ORTED)); 433 "PaymentRequest.UserHadSuggestionsForEverything.EffectOn Completion",
434 JourneyLogger.COMPLETION_STATUS_ABORTED));
406 } 435 }
407 436
408 /** 437 /**
409 * Asserts that no histogram is logged. 438 * Asserts that no histogram is logged.
410 */ 439 */
411 private void assertNoLogForCanMakePayment() { 440 private void assertNoLogForCanMakePayment() {
412 // Use stats. 441 // Use stats.
413 for (int i = 0; i < PaymentRequestJourneyLogger.CAN_MAKE_PAYMENT_USE_MAX ; ++i) { 442 for (int i = 0; i < JourneyLogger.CAN_MAKE_PAYMENT_USE_MAX; ++i) {
414 assertEquals(0, RecordHistogram.getHistogramValueCountForTesting( 443 assertEquals(0, RecordHistogram.getHistogramValueCountForTesting(
415 "PaymentRequest.CanMakePayment.Usage", i)); 444 "PaymentRequest.CanMakePayment.Usage", i));
416 } 445 }
417 446
418 // Effect on show stats. 447 // Effect on show stats.
419 for (int i = 0; i < PaymentRequestJourneyLogger.CMP_SHOW_MAX; ++i) { 448 for (int i = 0; i < JourneyLogger.CMP_SHOW_MAX; ++i) {
420 assertEquals(0, RecordHistogram.getHistogramValueCountForTesting( 449 assertEquals(0, RecordHistogram.getHistogramValueCountForTesting(
421 "PaymentRequest.CanMakePayment.Used.EffetOnS how", i)); 450 "PaymentRequest.CanMakePayment.Used.EffetOnS how", i));
422 } 451 }
423 452
424 // Effect on completion stats. 453 // Effect on completion stats.
425 for (int i = 0; i < PaymentRequestJourneyLogger.COMPLETION_STATUS_MAX; + +i) { 454 for (int i = 0; i < JourneyLogger.COMPLETION_STATUS_MAX; ++i) {
426 assertEquals(0, 455 assertEquals(0,
427 RecordHistogram.getHistogramValueCountForTesting( 456 RecordHistogram.getHistogramValueCountForTesting(
428 "PaymentRequest.CanMakePayment.NotUsed.WithShowEffec tOnCompletion", i)); 457 "PaymentRequest.CanMakePayment.NotUsed.WithShowEffec tOnCompletion", i));
429 assertEquals( 458 assertEquals(
430 0, RecordHistogram.getHistogramValueCountForTesting( 459 0, RecordHistogram.getHistogramValueCountForTesting(
431 "PaymentRequest.CanMakePayment.Used.TrueWithShowE ffectOnCompletion", 460 "PaymentRequest.CanMakePayment.Used.TrueWithShowE ffectOnCompletion",
432 i)); 461 i));
433 assertEquals( 462 assertEquals(
434 0, RecordHistogram.getHistogramValueCountForTesting( 463 0, RecordHistogram.getHistogramValueCountForTesting(
435 "PaymentRequest.CanMakePayment.Used.FalseWithShow EffectOnCompletion", 464 "PaymentRequest.CanMakePayment.Used.FalseWithShow EffectOnCompletion",
436 i)); 465 i));
437 } 466 }
438 } 467 }
439 } 468 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698