OLD | NEW |
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 "components/payments/core/journey_logger.h" | 5 #include "components/payments/core/journey_logger.h" |
6 | 6 |
7 #include "base/metrics/metrics_hashes.h" | 7 #include "base/metrics/metrics_hashes.h" |
8 #include "base/test/histogram_tester.h" | 8 #include "base/test/histogram_tester.h" |
9 #include "base/test/scoped_feature_list.h" | 9 #include "base/test/scoped_feature_list.h" |
| 10 #include "components/autofill/core/browser/autofill_experiments.h" |
10 #include "components/metrics/proto/ukm/entry.pb.h" | 11 #include "components/metrics/proto/ukm/entry.pb.h" |
11 #include "components/ukm/test_ukm_service.h" | 12 #include "components/ukm/test_ukm_service.h" |
12 #include "components/ukm/ukm_entry.h" | 13 #include "components/ukm/ukm_entry.h" |
13 #include "components/ukm/ukm_source.h" | 14 #include "components/ukm/ukm_source.h" |
14 #include "testing/gmock/include/gmock/gmock.h" | 15 #include "testing/gmock/include/gmock/gmock.h" |
15 #include "testing/gtest/include/gtest/gtest.h" | 16 #include "testing/gtest/include/gtest/gtest.h" |
16 | 17 |
17 using testing::ContainerEq; | 18 using testing::ContainerEq; |
18 | 19 |
19 namespace payments { | 20 namespace payments { |
(...skipping 675 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
695 histogram_tester.ExpectBucketCount("PaymentRequest.CanMakePayment.Usage", | 696 histogram_tester.ExpectBucketCount("PaymentRequest.CanMakePayment.Usage", |
696 JourneyLogger::CAN_MAKE_PAYMENT_NOT_USED, | 697 JourneyLogger::CAN_MAKE_PAYMENT_NOT_USED, |
697 1); | 698 1); |
698 histogram_tester.ExpectBucketCount( | 699 histogram_tester.ExpectBucketCount( |
699 "PaymentRequest.CanMakePayment.NotUsed.WithShowEffectOnCompletion", | 700 "PaymentRequest.CanMakePayment.NotUsed.WithShowEffectOnCompletion", |
700 JourneyLogger::COMPLETION_STATUS_USER_ABORTED, 1); | 701 JourneyLogger::COMPLETION_STATUS_USER_ABORTED, 1); |
701 } | 702 } |
702 | 703 |
703 // Tests that the Payment Request UKMs are logged correctly. | 704 // Tests that the Payment Request UKMs are logged correctly. |
704 TEST(JourneyLoggerTest, RecordJourneyStatsHistograms_CheckoutFunnelUkm) { | 705 TEST(JourneyLoggerTest, RecordJourneyStatsHistograms_CheckoutFunnelUkm) { |
| 706 base::test::ScopedFeatureList scoped_feature_list_; |
| 707 scoped_feature_list_.InitAndEnableFeature(autofill::kAutofillUkmLogging); |
| 708 |
705 ukm::UkmServiceTestingHarness ukm_service_test_harness; | 709 ukm::UkmServiceTestingHarness ukm_service_test_harness; |
706 ukm::TestUkmService* ukm_service = | 710 ukm::TestUkmService* ukm_service = |
707 ukm_service_test_harness.test_ukm_service(); | 711 ukm_service_test_harness.test_ukm_service(); |
708 char test_url[] = "http://www.google.com/"; | 712 char test_url[] = "http://www.google.com/"; |
709 | 713 |
710 base::HistogramTester histogram_tester; | 714 base::HistogramTester histogram_tester; |
711 JourneyLogger logger(/*is_incognito=*/true, /*url=*/GURL(test_url), | 715 JourneyLogger logger(/*is_incognito=*/true, /*url=*/GURL(test_url), |
712 /*ukm_service=*/ukm_service); | 716 /*ukm_service=*/ukm_service); |
713 | 717 |
714 // Simulate that the user aborts after being shown the Payment Request and | 718 // Simulate that the user aborts after being shown the Payment Request and |
(...skipping 25 matching lines...) Expand all Loading... |
740 status_metric->value()); | 744 status_metric->value()); |
741 | 745 |
742 const ukm::Entry_Metric* step_metric = | 746 const ukm::Entry_Metric* step_metric = |
743 FindMetric(internal::kUKMEventsMetricName, entry_proto.metrics()); | 747 FindMetric(internal::kUKMEventsMetricName, entry_proto.metrics()); |
744 ASSERT_NE(nullptr, step_metric); | 748 ASSERT_NE(nullptr, step_metric); |
745 EXPECT_EQ(JourneyLogger::EVENT_SHOWN | JourneyLogger::EVENT_PAY_CLICKED, | 749 EXPECT_EQ(JourneyLogger::EVENT_SHOWN | JourneyLogger::EVENT_PAY_CLICKED, |
746 step_metric->value()); | 750 step_metric->value()); |
747 } | 751 } |
748 | 752 |
749 } // namespace payments | 753 } // namespace payments |
OLD | NEW |