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

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

Issue 2943433004: [Payments] Log multiple events in the journey logger. (Closed)
Patch Set: addressed comment 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
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 "base/macros.h" 5 #include "base/macros.h"
6 #include "base/strings/utf_string_conversions.h" 6 #include "base/strings/utf_string_conversions.h"
7 #include "base/test/histogram_tester.h" 7 #include "base/test/histogram_tester.h"
8 #include "chrome/browser/ui/views/payments/payment_request_browsertest_base.h" 8 #include "chrome/browser/ui/views/payments/payment_request_browsertest_base.h"
9 #include "components/autofill/core/browser/autofill_profile.h" 9 #include "components/autofill/core/browser/autofill_profile.h"
10 #include "components/autofill/core/browser/autofill_test_utils.h" 10 #include "components/autofill/core/browser/autofill_test_utils.h"
(...skipping 26 matching lines...) Expand all
37 AddAutofillProfile(billing_address); 37 AddAutofillProfile(billing_address);
38 autofill::CreditCard card = autofill::test::GetCreditCard(); 38 autofill::CreditCard card = autofill::test::GetCreditCard();
39 card.set_billing_address_id(billing_address.guid()); 39 card.set_billing_address_id(billing_address.guid());
40 AddCreditCard(card); // Visa. 40 AddCreditCard(card); // Visa.
41 41
42 // Complete the Payment Request. 42 // Complete the Payment Request.
43 InvokePaymentRequestUI(); 43 InvokePaymentRequestUI();
44 ResetEventObserver(DialogEvent::DIALOG_CLOSED); 44 ResetEventObserver(DialogEvent::DIALOG_CLOSED);
45 PayWithCreditCardAndWait(base::ASCIIToUTF16("123")); 45 PayWithCreditCardAndWait(base::ASCIIToUTF16("123"));
46 46
47 histogram_tester.ExpectUniqueSample("PaymentRequest.CheckoutFunnel.Initiated",
48 1, 1);
49 histogram_tester.ExpectUniqueSample("PaymentRequest.CheckoutFunnel.Shown", 1,
50 1);
51 histogram_tester.ExpectUniqueSample(
52 "PaymentRequest.CheckoutFunnel.PayClicked", 1, 1);
53 histogram_tester.ExpectUniqueSample(
54 "PaymentRequest.CheckoutFunnel.ReceivedInstrumentDetails", 1, 1);
47 // Expect a credit card as the selected payment instrument in the metrics. 55 // Expect a credit card as the selected payment instrument in the metrics.
48 histogram_tester.ExpectBucketCount( 56 histogram_tester.ExpectBucketCount(
49 "PaymentRequest.SelectedPaymentMethod", 57 "PaymentRequest.SelectedPaymentMethod",
50 JourneyLogger::SELECTED_PAYMENT_METHOD_CREDIT_CARD, 1); 58 JourneyLogger::SELECTED_PAYMENT_METHOD_CREDIT_CARD, 1);
51 } 59 }
52 60
53 class PaymentRequestJourneyLoggerNoSupportedPaymentMethodTest 61 class PaymentRequestJourneyLoggerNoSupportedPaymentMethodTest
54 : public PaymentRequestBrowserTestBase { 62 : public PaymentRequestBrowserTestBase {
55 protected: 63 protected:
56 PaymentRequestJourneyLoggerNoSupportedPaymentMethodTest() 64 PaymentRequestJourneyLoggerNoSupportedPaymentMethodTest()
57 : PaymentRequestBrowserTestBase("/payment_request_bobpay_test.html") {} 65 : PaymentRequestBrowserTestBase("/payment_request_bobpay_test.html") {}
58 66
59 private: 67 private:
60 DISALLOW_COPY_AND_ASSIGN( 68 DISALLOW_COPY_AND_ASSIGN(
61 PaymentRequestJourneyLoggerNoSupportedPaymentMethodTest); 69 PaymentRequestJourneyLoggerNoSupportedPaymentMethodTest);
62 }; 70 };
63 71
64 IN_PROC_BROWSER_TEST_F(PaymentRequestJourneyLoggerNoSupportedPaymentMethodTest, 72 IN_PROC_BROWSER_TEST_F(PaymentRequestJourneyLoggerNoSupportedPaymentMethodTest,
65 OnlyBobpaySupported) { 73 OnlyBobpaySupported) {
66 base::HistogramTester histogram_tester; 74 base::HistogramTester histogram_tester;
67 75
68 ResetEventObserver(DialogEvent::NOT_SUPPORTED_ERROR); 76 ResetEventObserver(DialogEvent::NOT_SUPPORTED_ERROR);
69 content::WebContents* web_contents = GetActiveWebContents(); 77 content::WebContents* web_contents = GetActiveWebContents();
70 const std::string click_buy_button_js = 78 const std::string click_buy_button_js =
71 "(function() { document.getElementById('buy').click(); })();"; 79 "(function() { document.getElementById('buy').click(); })();";
72 ASSERT_TRUE(content::ExecuteScript(web_contents, click_buy_button_js)); 80 ASSERT_TRUE(content::ExecuteScript(web_contents, click_buy_button_js));
73 WaitForObservedEvent(); 81 WaitForObservedEvent();
74 82
83 histogram_tester.ExpectUniqueSample("PaymentRequest.CheckoutFunnel.Initiated",
84 1, 1);
75 histogram_tester.ExpectBucketCount( 85 histogram_tester.ExpectBucketCount(
76 "PaymentRequest.CheckoutFunnel.NoShow", 86 "PaymentRequest.CheckoutFunnel.NoShow",
77 JourneyLogger::NOT_SHOWN_REASON_NO_SUPPORTED_PAYMENT_METHOD, 1); 87 JourneyLogger::NOT_SHOWN_REASON_NO_SUPPORTED_PAYMENT_METHOD, 1);
78 } 88 }
79 89
80 class PaymentRequestJourneyLoggerMultipleShowTest 90 class PaymentRequestJourneyLoggerMultipleShowTest
81 : public PaymentRequestBrowserTestBase { 91 : public PaymentRequestBrowserTestBase {
82 protected: 92 protected:
83 PaymentRequestJourneyLoggerMultipleShowTest() 93 PaymentRequestJourneyLoggerMultipleShowTest()
84 : PaymentRequestBrowserTestBase( 94 : PaymentRequestBrowserTestBase(
(...skipping 25 matching lines...) Expand all
110 120
111 // Complete the original Payment Request. 121 // Complete the original Payment Request.
112 PayWithCreditCardAndWait(base::ASCIIToUTF16("123")); 122 PayWithCreditCardAndWait(base::ASCIIToUTF16("123"));
113 123
114 // Trying to show the same request twice is not considered a concurrent 124 // Trying to show the same request twice is not considered a concurrent
115 // request. 125 // request.
116 EXPECT_TRUE( 126 EXPECT_TRUE(
117 histogram_tester.GetAllSamples("PaymentRequest.CheckoutFunnel.NoShow") 127 histogram_tester.GetAllSamples("PaymentRequest.CheckoutFunnel.NoShow")
118 .empty()); 128 .empty());
119 129
120 // Expect that the completion was logged correctly. 130 // Expect that other metrics were logged correctly.
131 histogram_tester.ExpectUniqueSample("PaymentRequest.CheckoutFunnel.Initiated",
132 1, 1);
133 histogram_tester.ExpectUniqueSample("PaymentRequest.CheckoutFunnel.Shown", 1,
134 1);
135 histogram_tester.ExpectUniqueSample(
136 "PaymentRequest.CheckoutFunnel.PayClicked", 1, 1);
137 histogram_tester.ExpectUniqueSample(
138 "PaymentRequest.CheckoutFunnel.ReceivedInstrumentDetails", 1, 1);
121 histogram_tester.ExpectUniqueSample("PaymentRequest.CheckoutFunnel.Completed", 139 histogram_tester.ExpectUniqueSample("PaymentRequest.CheckoutFunnel.Completed",
122 1, 1); 140 1, 1);
123 } 141 }
124 142
125 IN_PROC_BROWSER_TEST_F(PaymentRequestJourneyLoggerMultipleShowTest, 143 IN_PROC_BROWSER_TEST_F(PaymentRequestJourneyLoggerMultipleShowTest,
126 StartNewRequest) { 144 StartNewRequest) {
127 base::HistogramTester histogram_tester; 145 base::HistogramTester histogram_tester;
128 146
129 // Setup a credit card with an associated billing address. 147 // Setup a credit card with an associated billing address.
130 autofill::AutofillProfile billing_address = autofill::test::GetFullProfile(); 148 autofill::AutofillProfile billing_address = autofill::test::GetFullProfile();
(...skipping 14 matching lines...) Expand all
145 content::WebContents* web_contents = GetActiveWebContents(); 163 content::WebContents* web_contents = GetActiveWebContents();
146 const std::string click_buy_button_js = 164 const std::string click_buy_button_js =
147 "(function() { document.getElementById('showSecondRequest').click(); " 165 "(function() { document.getElementById('showSecondRequest').click(); "
148 "})();"; 166 "})();";
149 ASSERT_TRUE(content::ExecuteScript(web_contents, click_buy_button_js)); 167 ASSERT_TRUE(content::ExecuteScript(web_contents, click_buy_button_js));
150 WaitForObservedEvent(); 168 WaitForObservedEvent();
151 169
152 // Complete the original Payment Request. 170 // Complete the original Payment Request.
153 PayWithCreditCardAndWait(base::ASCIIToUTF16("123"), first_dialog_view); 171 PayWithCreditCardAndWait(base::ASCIIToUTF16("123"), first_dialog_view);
154 172
173 histogram_tester.ExpectUniqueSample("PaymentRequest.CheckoutFunnel.Initiated",
174 1, 2);
175 histogram_tester.ExpectUniqueSample("PaymentRequest.CheckoutFunnel.Shown", 1,
176 1);
177 histogram_tester.ExpectUniqueSample(
178 "PaymentRequest.CheckoutFunnel.PayClicked", 1, 1);
179 histogram_tester.ExpectUniqueSample(
180 "PaymentRequest.CheckoutFunnel.ReceivedInstrumentDetails", 1, 1);
181
155 // The metrics should show that the original Payment Request should be 182 // The metrics should show that the original Payment Request should be
156 // completed and the second one should not have been shown. 183 // completed and the second one should not have been shown.
157 histogram_tester.ExpectUniqueSample("PaymentRequest.CheckoutFunnel.Completed", 184 histogram_tester.ExpectUniqueSample("PaymentRequest.CheckoutFunnel.Completed",
158 1, 1); 185 1, 1);
159 histogram_tester.ExpectBucketCount( 186 histogram_tester.ExpectBucketCount(
160 "PaymentRequest.CheckoutFunnel.NoShow", 187 "PaymentRequest.CheckoutFunnel.NoShow",
161 JourneyLogger::NOT_SHOWN_REASON_CONCURRENT_REQUESTS, 1); 188 JourneyLogger::NOT_SHOWN_REASON_CONCURRENT_REQUESTS, 1);
162 } 189 }
163 190
164 } // namespace payments 191 } // namespace payments
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698