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

Side by Side Diff: components/payments/core/journey_logger_unittest.cc

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

Powered by Google App Engine
This is Rietveld 408576698