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

Unified Diff: components/autofill/core/browser/autofill_metrics_unittest.cc

Issue 2888633002: Revert of [Autofill] Enable Autofill UKM by default. (Closed)
Patch Set: 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « components/autofill/core/browser/autofill_metrics.cc ('k') | components/payments/core/journey_logger.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/autofill/core/browser/autofill_metrics_unittest.cc
diff --git a/components/autofill/core/browser/autofill_metrics_unittest.cc b/components/autofill/core/browser/autofill_metrics_unittest.cc
index 375b4fb2eba304a544c9182a436f54b1993afd53..b9a4e6db8b37d32e293f4c1232540ad3beee3049 100644
--- a/components/autofill/core/browser/autofill_metrics_unittest.cc
+++ b/components/autofill/core/browser/autofill_metrics_unittest.cc
@@ -415,6 +415,7 @@
protected:
void EnableWalletSync();
+ void EnableUkmLogging();
base::test::ScopedTaskEnvironment scoped_task_environment_;
TestAutofillClient autofill_client_;
@@ -481,6 +482,10 @@
void AutofillMetricsTest::EnableWalletSync() {
signin_manager_->SetAuthenticatedAccountInfo("12345", "syncuser@example.com");
+}
+
+void AutofillMetricsTest::EnableUkmLogging() {
+ scoped_feature_list_.InitAndEnableFeature(kAutofillUkmLogging);
}
// Test that we log quality metrics appropriately.
@@ -1624,6 +1629,11 @@
// fields is logged.
histogram_tester.ExpectUniqueSample(
"Autofill.NumberOfEditedAutofilledFieldsAtSubmission", 2, 1);
+
+ // UKM must not be logged unless enabled.
+ ukm::TestUkmService* ukm_service = autofill_client_.GetTestUkmService();
+ EXPECT_EQ(0U, ukm_service->sources_count());
+ EXPECT_EQ(0U, ukm_service->entries_count());
}
// Verify that when resetting the autofill manager (such as during a
@@ -1678,6 +1688,8 @@
// Verify that we correctly log metrics regarding developer engagement.
TEST_F(AutofillMetricsTest, DeveloperEngagement) {
+ ukm::TestUkmService* ukm_service = autofill_client_.GetTestUkmService();
+
// Start with a non-fillable form.
FormData form;
form.name = ASCIIToUTF16("TestForm");
@@ -1698,6 +1710,10 @@
autofill_manager_->OnFormsSeen(forms, TimeTicks());
autofill_manager_->Reset();
histogram_tester.ExpectTotalCount("Autofill.DeveloperEngagement", 0);
+
+ // UKM must not be logged unless enabled.
+ EXPECT_EQ(0U, ukm_service->sources_count());
+ EXPECT_EQ(0U, ukm_service->entries_count());
}
// Add another field to the form, so that it becomes fillable.
@@ -1712,6 +1728,10 @@
histogram_tester.ExpectUniqueSample(
"Autofill.DeveloperEngagement",
AutofillMetrics::FILLABLE_FORM_PARSED_WITHOUT_TYPE_HINTS, 1);
+
+ // UKM must not be logged unless enabled.
+ EXPECT_EQ(0U, ukm_service->sources_count());
+ EXPECT_EQ(0U, ukm_service->entries_count());
}
// Add some fields with an author-specified field type to the form.
@@ -1738,6 +1758,10 @@
"Autofill.DeveloperEngagement",
AutofillMetrics::FILLABLE_FORM_PARSED_WITH_TYPE_HINTS, 1);
+ // UKM must not be logged unless enabled.
+ EXPECT_EQ(0U, ukm_service->sources_count());
+ EXPECT_EQ(0U, ukm_service->entries_count());
+
histogram_tester.ExpectBucketCount(
"Autofill.DeveloperEngagement",
AutofillMetrics::FORM_CONTAINS_UPI_VPA_HINT, 0);
@@ -1767,6 +1791,7 @@
// developer engagement.
TEST_F(AutofillMetricsTest,
UkmDeveloperEngagement_LogFillableFormParsedWithoutTypeHints) {
+ EnableUkmLogging();
ukm::TestUkmService* ukm_service = autofill_client_.GetTestUkmService();
// Start with a non-fillable form.
@@ -1814,6 +1839,7 @@
// developer engagement.
TEST_F(AutofillMetricsTest,
UkmDeveloperEngagement_LogFillableFormParsedWithTypeHints) {
+ EnableUkmLogging();
ukm::TestUkmService* ukm_service = autofill_client_.GetTestUkmService();
FormData form;
@@ -1865,6 +1891,7 @@
// Verify that we correctly log UKM for form parsed with type hints regarding
// developer engagement.
TEST_F(AutofillMetricsTest, UkmDeveloperEngagement_LogUpiVpaTypeHint) {
+ EnableUkmLogging();
ukm::TestUkmService* ukm_service = autofill_client_.GetTestUkmService();
FormData form;
@@ -2091,6 +2118,7 @@
// Test that the credit card checkout flow user actions are correctly logged.
TEST_F(AutofillMetricsTest, CreditCardCheckoutFlowUserActions) {
+ EnableUkmLogging();
ukm::TestUkmService* ukm_service = autofill_client_.GetTestUkmService();
personal_data_->RecreateCreditCards(
@@ -2189,6 +2217,7 @@
// Test that the profile checkout flow user actions are correctly logged.
TEST_F(AutofillMetricsTest, ProfileCheckoutFlowUserActions) {
+ EnableUkmLogging();
ukm::TestUkmService* ukm_service = autofill_client_.GetTestUkmService();
// Create a profile.
@@ -2570,6 +2599,11 @@
"Autofill.FormEvents.CreditCard",
AutofillMetrics::FORM_EVENT_SUGGESTIONS_SHOWN_ONCE, 0);
}
+
+ // UKM must not be logged unless enabled.
+ ukm::TestUkmService* ukm_service = autofill_client_.GetTestUkmService();
+ EXPECT_EQ(0U, ukm_service->sources_count());
+ EXPECT_EQ(0U, ukm_service->entries_count());
}
// Test that we log selected form event for credit cards.
@@ -2836,6 +2870,7 @@
// Test that we log submitted form events for credit cards.
TEST_F(AutofillMetricsTest, CreditCardSubmittedFormEvents) {
+ EnableUkmLogging();
ukm::TestUkmService* ukm_service = autofill_client_.GetTestUkmService();
EnableWalletSync();
@@ -3552,6 +3587,7 @@
// Test that we log submitted form events for address.
TEST_F(AutofillMetricsTest, AddressSubmittedFormEvents) {
+ EnableUkmLogging();
ukm::TestUkmService* ukm_service = autofill_client_.GetTestUkmService();
EnableWalletSync();
@@ -4092,6 +4128,7 @@
// Verify that we correctly log the submitted form's state.
TEST_F(AutofillMetricsTest, AutofillFormSubmittedState) {
+ EnableUkmLogging();
ukm::TestUkmService* ukm_service = autofill_client_.GetTestUkmService();
// Start with a form with insufficiently many fields.
@@ -4298,6 +4335,7 @@
// Verify that we correctly log user happiness metrics dealing with form
// interaction.
TEST_F(AutofillMetricsTest, UserHappinessFormInteraction) {
+ EnableUkmLogging();
ukm::TestUkmService* ukm_service = autofill_client_.GetTestUkmService();
// Load a fillable form.
@@ -5016,6 +5054,7 @@
// Tests that logging CardUploadDecision UKM works as expected.
TEST_F(AutofillMetricsTest, RecordCardUploadDecisionMetric) {
+ EnableUkmLogging();
ukm::UkmServiceTestingHarness ukm_service_test_harness;
GURL url("https://www.google.com");
int upload_decision = 1;
@@ -5056,6 +5095,7 @@
// Tests that logging DeveloperEngagement UKM works as expected.
TEST_F(AutofillMetricsTest, RecordDeveloperEngagementMetric) {
+ EnableUkmLogging();
ukm::UkmServiceTestingHarness ukm_service_test_harness;
GURL url("https://www.google.com");
int form_structure_metric = 1;
@@ -5096,6 +5136,7 @@
// Tests that no UKM is logged when the URL is not valid.
TEST_F(AutofillMetricsTest, RecordCardUploadDecisionMetric_InvalidUrl) {
+ EnableUkmLogging();
ukm::UkmServiceTestingHarness ukm_service_test_harness;
GURL url("");
std::vector<std::pair<const char*, int>> metrics = {{"metric", 1}};
@@ -5107,6 +5148,7 @@
// Tests that no UKM is logged when the metrics map is empty.
TEST_F(AutofillMetricsTest, RecordCardUploadDecisionMetric_NoMetrics) {
+ EnableUkmLogging();
ukm::UkmServiceTestingHarness ukm_service_test_harness;
GURL url("https://www.google.com");
std::vector<std::pair<const char*, int>> metrics;
@@ -5118,6 +5160,7 @@
// Tests that no UKM is logged when the ukm service is null.
TEST_F(AutofillMetricsTest, RecordCardUploadDecisionMetric_NoUkmService) {
+ EnableUkmLogging();
ukm::UkmServiceTestingHarness ukm_service_test_harness;
GURL url("https://www.google.com");
std::vector<std::pair<const char*, int>> metrics = {{"metric", 1}};
@@ -5126,4 +5169,15 @@
ASSERT_EQ(0U, ukm_service_test_harness.test_ukm_service()->sources_count());
}
+// Tests that no UKM is logged when the ukm logging feature is disabled.
+TEST_F(AutofillMetricsTest, RecordCardUploadDecisionMetric_FeatureDisabled) {
+ ukm::UkmServiceTestingHarness ukm_service_test_harness;
+ GURL url("https://www.google.com");
+ std::vector<std::pair<const char*, int>> metrics = {{"metric", 1}};
+
+ EXPECT_FALSE(AutofillMetrics::LogUkm(
+ ukm_service_test_harness.test_ukm_service(), url, "test_ukm", metrics));
+ EXPECT_EQ(0U, ukm_service_test_harness.test_ukm_service()->sources_count());
+}
+
} // namespace autofill
« no previous file with comments | « components/autofill/core/browser/autofill_metrics.cc ('k') | components/payments/core/journey_logger.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698