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

Side by Side Diff: chrome/browser/ui/views/payments/payment_request_completion_status_metrics_browsertest.cc

Issue 2943433004: [Payments] Log multiple events in the journey logger. (Closed)
Patch Set: Created 3 years, 6 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
« no previous file with comments | « no previous file | chrome/browser/ui/views/payments/payment_request_journey_logger_browsertest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #include <vector> 5 #include <vector>
6 6
7 #include "base/macros.h" 7 #include "base/macros.h"
8 #include "base/strings/utf_string_conversions.h" 8 #include "base/strings/utf_string_conversions.h"
9 #include "base/test/histogram_tester.h" 9 #include "base/test/histogram_tester.h"
10 #include "chrome/browser/ui/browser_commands.h" 10 #include "chrome/browser/ui/browser_commands.h"
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 // Payment Request is shown. 44 // Payment Request is shown.
45 ResetEventObserverForSequence( 45 ResetEventObserverForSequence(
46 {DialogEvent::CAN_MAKE_PAYMENT_CALLED, DialogEvent::DIALOG_OPENED}); 46 {DialogEvent::CAN_MAKE_PAYMENT_CALLED, DialogEvent::DIALOG_OPENED});
47 ASSERT_TRUE(content::ExecuteScript(GetActiveWebContents(), "queryShow();")); 47 ASSERT_TRUE(content::ExecuteScript(GetActiveWebContents(), "queryShow();"));
48 WaitForObservedEvent(); 48 WaitForObservedEvent();
49 49
50 // Complete the Payment Request. 50 // Complete the Payment Request.
51 PayWithCreditCardAndWait(base::ASCIIToUTF16("123")); 51 PayWithCreditCardAndWait(base::ASCIIToUTF16("123"));
52 52
53 // Make sure the metrics are logged correctly. 53 // Make sure the metrics are logged correctly.
54 histogram_tester.ExpectUniqueSample("PaymentRequest.CheckoutFunnel.Initiated",
55 1, 1);
56 histogram_tester.ExpectUniqueSample("PaymentRequest.CheckoutFunnel.Shown", 1,
57 1);
58 histogram_tester.ExpectUniqueSample(
59 "PaymentRequest.CheckoutFunnel.PayClicked", 1, 1);
60 histogram_tester.ExpectUniqueSample(
61 "PaymentRequest.CheckoutFunnel.ReceivedInstrumentDetails", 1, 1);
54 histogram_tester.ExpectUniqueSample("PaymentRequest.CheckoutFunnel.Completed", 62 histogram_tester.ExpectUniqueSample("PaymentRequest.CheckoutFunnel.Completed",
55 1, 1); 63 1, 1);
56 } 64 }
57 65
58 IN_PROC_BROWSER_TEST_F(PaymentRequestCompletionStatusMetricsTest, 66 IN_PROC_BROWSER_TEST_F(PaymentRequestCompletionStatusMetricsTest,
59 MerchantAborted_Reload) { 67 MerchantAborted_Reload) {
60 base::HistogramTester histogram_tester; 68 base::HistogramTester histogram_tester;
61 69
62 // Start the Payment Request. 70 // Start the Payment Request.
63 ResetEventObserver(DialogEvent::DIALOG_OPENED); 71 ResetEventObserver(DialogEvent::DIALOG_OPENED);
64 ASSERT_TRUE(content::ExecuteScript(GetActiveWebContents(), "noQueryShow();")); 72 ASSERT_TRUE(content::ExecuteScript(GetActiveWebContents(), "noQueryShow();"));
65 WaitForObservedEvent(); 73 WaitForObservedEvent();
66 74
67 // The merchant reloads the page. 75 // The merchant reloads the page.
68 ResetEventObserver(DialogEvent::DIALOG_CLOSED); 76 ResetEventObserver(DialogEvent::DIALOG_CLOSED);
69 ASSERT_TRUE(content::ExecuteScript(GetActiveWebContents(), 77 ASSERT_TRUE(content::ExecuteScript(GetActiveWebContents(),
70 "(function() { location.reload(); })();")); 78 "(function() { location.reload(); })();"));
71 WaitForObservedEvent(); 79 WaitForObservedEvent();
72 80
73 // Make sure the metrics are logged correctly. 81 // Make sure the metrics are logged correctly.
82 histogram_tester.ExpectUniqueSample("PaymentRequest.CheckoutFunnel.Shown", 1,
sebsg 2017/06/16 18:26:48 Initiated too?
Mathieu 2017/06/16 19:03:14 Done.
83 1);
74 histogram_tester.ExpectUniqueSample( 84 histogram_tester.ExpectUniqueSample(
75 "PaymentRequest.CheckoutFunnel.Aborted", 85 "PaymentRequest.CheckoutFunnel.Aborted",
76 JourneyLogger::ABORT_REASON_MERCHANT_NAVIGATION, 1); 86 JourneyLogger::ABORT_REASON_MERCHANT_NAVIGATION, 1);
77 } 87 }
78 88
79 IN_PROC_BROWSER_TEST_F(PaymentRequestCompletionStatusMetricsTest, 89 IN_PROC_BROWSER_TEST_F(PaymentRequestCompletionStatusMetricsTest,
80 MerchantAborted_Navigation) { 90 MerchantAborted_Navigation) {
81 base::HistogramTester histogram_tester; 91 base::HistogramTester histogram_tester;
82 92
83 // Start the Payment Request. 93 // Start the Payment Request.
84 ResetEventObserver(DialogEvent::DIALOG_OPENED); 94 ResetEventObserver(DialogEvent::DIALOG_OPENED);
85 ASSERT_TRUE(content::ExecuteScript(GetActiveWebContents(), "noQueryShow();")); 95 ASSERT_TRUE(content::ExecuteScript(GetActiveWebContents(), "noQueryShow();"));
86 WaitForObservedEvent(); 96 WaitForObservedEvent();
87 97
88 // The merchant navigates away. 98 // The merchant navigates away.
89 ResetEventObserver(DialogEvent::DIALOG_CLOSED); 99 ResetEventObserver(DialogEvent::DIALOG_CLOSED);
90 ASSERT_TRUE(content::ExecuteScript(GetActiveWebContents(), 100 ASSERT_TRUE(content::ExecuteScript(GetActiveWebContents(),
91 "(function() { window.location.href = " 101 "(function() { window.location.href = "
92 "'/payment_request_email_test.html'; " 102 "'/payment_request_email_test.html'; "
93 "})();")); 103 "})();"));
94 WaitForObservedEvent(); 104 WaitForObservedEvent();
95 105
96 // Make sure the metrics are logged correctly. 106 // Make sure the metrics are logged correctly.
107 histogram_tester.ExpectUniqueSample("PaymentRequest.CheckoutFunnel.Initiated",
108 1, 1);
109 histogram_tester.ExpectUniqueSample("PaymentRequest.CheckoutFunnel.Shown", 1,
110 1);
97 histogram_tester.ExpectUniqueSample( 111 histogram_tester.ExpectUniqueSample(
98 "PaymentRequest.CheckoutFunnel.Aborted", 112 "PaymentRequest.CheckoutFunnel.Aborted",
99 JourneyLogger::ABORT_REASON_MERCHANT_NAVIGATION, 1); 113 JourneyLogger::ABORT_REASON_MERCHANT_NAVIGATION, 1);
100 } 114 }
101 115
102 IN_PROC_BROWSER_TEST_F(PaymentRequestCompletionStatusMetricsTest, 116 IN_PROC_BROWSER_TEST_F(PaymentRequestCompletionStatusMetricsTest,
103 MerchantAborted_Abort) { 117 MerchantAborted_Abort) {
104 base::HistogramTester histogram_tester; 118 base::HistogramTester histogram_tester;
105 119
106 // Start the Payment Request. 120 // Start the Payment Request.
107 ResetEventObserver(DialogEvent::DIALOG_OPENED); 121 ResetEventObserver(DialogEvent::DIALOG_OPENED);
108 ASSERT_TRUE(content::ExecuteScript(GetActiveWebContents(), "noQueryShow();")); 122 ASSERT_TRUE(content::ExecuteScript(GetActiveWebContents(), "noQueryShow();"));
109 WaitForObservedEvent(); 123 WaitForObservedEvent();
110 124
111 // The merchant aborts the Payment Request. 125 // The merchant aborts the Payment Request.
112 ResetEventObserverForSequence( 126 ResetEventObserverForSequence(
113 {DialogEvent::ABORT_CALLED, DialogEvent::DIALOG_CLOSED}); 127 {DialogEvent::ABORT_CALLED, DialogEvent::DIALOG_CLOSED});
114 const std::string click_buy_button_js = 128 const std::string click_buy_button_js =
115 "(function() { document.getElementById('abort').click(); })();"; 129 "(function() { document.getElementById('abort').click(); })();";
116 ASSERT_TRUE( 130 ASSERT_TRUE(
117 content::ExecuteScript(GetActiveWebContents(), click_buy_button_js)); 131 content::ExecuteScript(GetActiveWebContents(), click_buy_button_js));
118 WaitForObservedEvent(); 132 WaitForObservedEvent();
119 133
120 // Make sure the metrics are logged correctly. 134 // Make sure the metrics are logged correctly.
135 histogram_tester.ExpectUniqueSample("PaymentRequest.CheckoutFunnel.Initiated",
136 1, 1);
137 histogram_tester.ExpectUniqueSample("PaymentRequest.CheckoutFunnel.Shown", 1,
138 1);
121 histogram_tester.ExpectUniqueSample( 139 histogram_tester.ExpectUniqueSample(
122 "PaymentRequest.CheckoutFunnel.Aborted", 140 "PaymentRequest.CheckoutFunnel.Aborted",
123 JourneyLogger::ABORT_REASON_ABORTED_BY_MERCHANT, 1); 141 JourneyLogger::ABORT_REASON_ABORTED_BY_MERCHANT, 1);
124 } 142 }
125 143
126 IN_PROC_BROWSER_TEST_F(PaymentRequestCompletionStatusMetricsTest, 144 IN_PROC_BROWSER_TEST_F(PaymentRequestCompletionStatusMetricsTest,
127 UserAborted_Navigation) { 145 UserAborted_Navigation) {
128 base::HistogramTester histogram_tester; 146 base::HistogramTester histogram_tester;
129 147
130 // Start the Payment Request. 148 // Start the Payment Request.
131 ResetEventObserver(DialogEvent::DIALOG_OPENED); 149 ResetEventObserver(DialogEvent::DIALOG_OPENED);
132 ASSERT_TRUE(content::ExecuteScript(GetActiveWebContents(), "noQueryShow();")); 150 ASSERT_TRUE(content::ExecuteScript(GetActiveWebContents(), "noQueryShow();"));
133 WaitForObservedEvent(); 151 WaitForObservedEvent();
134 152
135 // Navigate away. 153 // Navigate away.
136 NavigateTo("/payment_request_email_test.html"); 154 NavigateTo("/payment_request_email_test.html");
137 155
138 // Make sure the metrics are logged correctly. 156 // Make sure the metrics are logged correctly.
157 histogram_tester.ExpectUniqueSample("PaymentRequest.CheckoutFunnel.Initiated",
158 1, 1);
159 histogram_tester.ExpectUniqueSample("PaymentRequest.CheckoutFunnel.Shown", 1,
160 1);
139 histogram_tester.ExpectUniqueSample( 161 histogram_tester.ExpectUniqueSample(
140 "PaymentRequest.CheckoutFunnel.Aborted", 162 "PaymentRequest.CheckoutFunnel.Aborted",
141 JourneyLogger::ABORT_REASON_USER_NAVIGATION, 1); 163 JourneyLogger::ABORT_REASON_USER_NAVIGATION, 1);
142 } 164 }
143 165
144 IN_PROC_BROWSER_TEST_F(PaymentRequestCompletionStatusMetricsTest, 166 IN_PROC_BROWSER_TEST_F(PaymentRequestCompletionStatusMetricsTest,
145 UserAborted_CancelButton) { 167 UserAborted_CancelButton) {
146 base::HistogramTester histogram_tester; 168 base::HistogramTester histogram_tester;
147 169
148 // Start the Payment Request. 170 // Start the Payment Request.
149 ResetEventObserver(DialogEvent::DIALOG_OPENED); 171 ResetEventObserver(DialogEvent::DIALOG_OPENED);
150 ASSERT_TRUE(content::ExecuteScript(GetActiveWebContents(), "noQueryShow();")); 172 ASSERT_TRUE(content::ExecuteScript(GetActiveWebContents(), "noQueryShow();"));
151 WaitForObservedEvent(); 173 WaitForObservedEvent();
152 174
153 // Click on the cancel button. 175 // Click on the cancel button.
154 ClickOnCancel(); 176 ClickOnCancel();
155 177
156 // Make sure the metrics are logged correctly. 178 // Make sure the metrics are logged correctly.
179 histogram_tester.ExpectUniqueSample("PaymentRequest.CheckoutFunnel.Initiated",
180 1, 1);
181 histogram_tester.ExpectUniqueSample("PaymentRequest.CheckoutFunnel.Shown", 1,
182 1);
157 histogram_tester.ExpectUniqueSample( 183 histogram_tester.ExpectUniqueSample(
158 "PaymentRequest.CheckoutFunnel.Aborted", 184 "PaymentRequest.CheckoutFunnel.Aborted",
159 JourneyLogger::ABORT_REASON_ABORTED_BY_USER, 1); 185 JourneyLogger::ABORT_REASON_ABORTED_BY_USER, 1);
160 } 186 }
161 187
162 IN_PROC_BROWSER_TEST_F(PaymentRequestCompletionStatusMetricsTest, 188 IN_PROC_BROWSER_TEST_F(PaymentRequestCompletionStatusMetricsTest,
163 UserAborted_TabClosed) { 189 UserAborted_TabClosed) {
164 base::HistogramTester histogram_tester; 190 base::HistogramTester histogram_tester;
165 191
166 // Start the Payment Request. 192 // Start the Payment Request.
167 ResetEventObserver(DialogEvent::DIALOG_OPENED); 193 ResetEventObserver(DialogEvent::DIALOG_OPENED);
168 ASSERT_TRUE(content::ExecuteScript(GetActiveWebContents(), "noQueryShow();")); 194 ASSERT_TRUE(content::ExecuteScript(GetActiveWebContents(), "noQueryShow();"));
169 WaitForObservedEvent(); 195 WaitForObservedEvent();
170 196
171 // Close the tab containing the Payment Request. 197 // Close the tab containing the Payment Request.
172 ResetEventObserverForSequence({DialogEvent::DIALOG_CLOSED}); 198 ResetEventObserverForSequence({DialogEvent::DIALOG_CLOSED});
173 chrome::CloseTab(browser()); 199 chrome::CloseTab(browser());
174 WaitForObservedEvent(); 200 WaitForObservedEvent();
175 201
176 // Make sure the metrics are logged correctly. 202 // Make sure the metrics are logged correctly.
203 histogram_tester.ExpectUniqueSample("PaymentRequest.CheckoutFunnel.Initiated",
204 1, 1);
205 histogram_tester.ExpectUniqueSample("PaymentRequest.CheckoutFunnel.Shown", 1,
206 1);
177 histogram_tester.ExpectUniqueSample( 207 histogram_tester.ExpectUniqueSample(
178 "PaymentRequest.CheckoutFunnel.Aborted", 208 "PaymentRequest.CheckoutFunnel.Aborted",
179 JourneyLogger::ABORT_REASON_ABORTED_BY_USER, 1); 209 JourneyLogger::ABORT_REASON_ABORTED_BY_USER, 1);
180 } 210 }
181 211
182 IN_PROC_BROWSER_TEST_F(PaymentRequestCompletionStatusMetricsTest, 212 IN_PROC_BROWSER_TEST_F(PaymentRequestCompletionStatusMetricsTest,
183 UserAborted_Reload) { 213 UserAborted_Reload) {
184 base::HistogramTester histogram_tester; 214 base::HistogramTester histogram_tester;
185 215
186 // Start the Payment Request. 216 // Start the Payment Request.
187 ResetEventObserver(DialogEvent::DIALOG_OPENED); 217 ResetEventObserver(DialogEvent::DIALOG_OPENED);
188 ASSERT_TRUE(content::ExecuteScript(GetActiveWebContents(), "noQueryShow();")); 218 ASSERT_TRUE(content::ExecuteScript(GetActiveWebContents(), "noQueryShow();"));
189 WaitForObservedEvent(); 219 WaitForObservedEvent();
190 220
191 // Reload the page containing the Payment Request. 221 // Reload the page containing the Payment Request.
192 ResetEventObserverForSequence({DialogEvent::DIALOG_CLOSED}); 222 ResetEventObserverForSequence({DialogEvent::DIALOG_CLOSED});
193 chrome::Reload(browser(), WindowOpenDisposition::CURRENT_TAB); 223 chrome::Reload(browser(), WindowOpenDisposition::CURRENT_TAB);
194 WaitForObservedEvent(); 224 WaitForObservedEvent();
195 225
196 // Make sure the metrics are logged correctly. 226 // Make sure the metrics are logged correctly.
227 histogram_tester.ExpectUniqueSample("PaymentRequest.CheckoutFunnel.Initiated",
228 1, 1);
229 histogram_tester.ExpectUniqueSample("PaymentRequest.CheckoutFunnel.Shown", 1,
230 1);
197 histogram_tester.ExpectUniqueSample( 231 histogram_tester.ExpectUniqueSample(
198 "PaymentRequest.CheckoutFunnel.Aborted", 232 "PaymentRequest.CheckoutFunnel.Aborted",
199 JourneyLogger::ABORT_REASON_USER_NAVIGATION, 1); 233 JourneyLogger::ABORT_REASON_USER_NAVIGATION, 1);
200 } 234 }
201 235
202 } // namespace payments 236 } // namespace payments
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/ui/views/payments/payment_request_journey_logger_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698