Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/autofill/core/browser/autofill_metrics.h" | 5 #include "components/autofill/core/browser/autofill_metrics.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <map> | 9 #include <map> |
| 10 #include <memory> | 10 #include <memory> |
| (...skipping 1415 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1426 autofill_manager_->Reset(); | 1426 autofill_manager_->Reset(); |
| 1427 autofill_manager_->RunRunLoop(); | 1427 autofill_manager_->RunRunLoop(); |
| 1428 | 1428 |
| 1429 // An autofillable form was uploaded, and the number of edited autofilled | 1429 // An autofillable form was uploaded, and the number of edited autofilled |
| 1430 // fields is logged. | 1430 // fields is logged. |
| 1431 histogram_tester.ExpectUniqueSample( | 1431 histogram_tester.ExpectUniqueSample( |
| 1432 "Autofill.NumberOfEditedAutofilledFieldsAtSubmission.NoSubmission", 1, 1); | 1432 "Autofill.NumberOfEditedAutofilledFieldsAtSubmission.NoSubmission", 1, 1); |
| 1433 } | 1433 } |
| 1434 | 1434 |
| 1435 // Verify that we correctly log metrics regarding developer engagement. | 1435 // Verify that we correctly log metrics regarding developer engagement. |
| 1436 TEST_F(AutofillMetricsTest, DeveloperEngagement) { | 1436 TEST_F(AutofillMetricsTest, DeveloperEngagement) { |
|
Mathieu
2017/03/23 11:26:22
Please mirror your test on this one.
Roger McFarlane (Chromium)
2017/03/28 19:08:23
Done.
| |
| 1437 // Start with a non-fillable form. | 1437 // Start with a non-fillable form. |
| 1438 FormData form; | 1438 FormData form; |
| 1439 form.name = ASCIIToUTF16("TestForm"); | 1439 form.name = ASCIIToUTF16("TestForm"); |
| 1440 form.origin = GURL("http://example.com/form.html"); | 1440 form.origin = GURL("http://example.com/form.html"); |
| 1441 form.action = GURL("http://example.com/submit.html"); | 1441 form.action = GURL("http://example.com/submit.html"); |
| 1442 | 1442 |
| 1443 FormFieldData field; | 1443 FormFieldData field; |
| 1444 test::CreateTestFormField("Name", "name", "", "text", &field); | 1444 test::CreateTestFormField("Name", "name", "", "text", &field); |
| 1445 form.fields.push_back(field); | 1445 form.fields.push_back(field); |
| 1446 test::CreateTestFormField("Email", "email", "", "text", &field); | 1446 test::CreateTestFormField("Email", "email", "", "text", &field); |
| (...skipping 2912 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4359 "Autofill.FormEvents.CreditCard", | 4359 "Autofill.FormEvents.CreditCard", |
| 4360 AutofillMetrics::FORM_EVENT_NO_SUGGESTION_SUBMITTED_ONCE, 1); | 4360 AutofillMetrics::FORM_EVENT_NO_SUGGESTION_SUBMITTED_ONCE, 1); |
| 4361 // Check that the nonsecure histogram was not recorded. ExpectBucketCount() | 4361 // Check that the nonsecure histogram was not recorded. ExpectBucketCount() |
| 4362 // can't be used here because it expects the histogram to exist. | 4362 // can't be used here because it expects the histogram to exist. |
| 4363 EXPECT_EQ( | 4363 EXPECT_EQ( |
| 4364 0, histograms.GetTotalCountsForPrefix("Autofill.FormEvents.CreditCard") | 4364 0, histograms.GetTotalCountsForPrefix("Autofill.FormEvents.CreditCard") |
| 4365 ["Autofill.FormEvents.CreditCard.OnNonsecurePage"]); | 4365 ["Autofill.FormEvents.CreditCard.OnNonsecurePage"]); |
| 4366 } | 4366 } |
| 4367 } | 4367 } |
| 4368 | 4368 |
| 4369 // Tests that logging an explicit UPI-VPA hint works as expected. | |
| 4370 TEST_F(AutofillMetricsTest, LogExplicitUpiVpaHint) { | |
| 4371 constexpr int kNumHints = 5; | |
| 4372 base::HistogramTester histograms; | |
| 4373 for (int i = 0; i < kNumHints; ++i) | |
| 4374 AutofillMetrics::LogExplicitUpiVpaHint(); | |
| 4375 histograms.ExpectBucketCount("Autofill.ExplicitUpiVpaHint", | |
| 4376 static_cast<int>(false), 0); | |
| 4377 histograms.ExpectBucketCount("Autofill.ExplicitUpiVpaHint", | |
| 4378 static_cast<int>(true), kNumHints); | |
| 4379 } | |
| 4380 | |
| 4369 // Tests that logging a UKM works as expected. | 4381 // Tests that logging a UKM works as expected. |
| 4370 TEST_F(AutofillMetricsTest, RecordCardUploadDecisionMetric) { | 4382 TEST_F(AutofillMetricsTest, RecordCardUploadDecisionMetric) { |
| 4371 EnableUkmLogging(); | 4383 EnableUkmLogging(); |
| 4372 ukm::UkmServiceTestingHarness ukm_service_test_harness; | 4384 ukm::UkmServiceTestingHarness ukm_service_test_harness; |
| 4373 GURL url("https://www.google.com"); | 4385 GURL url("https://www.google.com"); |
| 4374 int upload_decision = 1; | 4386 int upload_decision = 1; |
| 4375 std::map<std::string, int> metrics; | 4387 std::map<std::string, int> metrics; |
| 4376 metrics.insert(std::make_pair(internal::kUKMCardUploadDecisionMetricName, | 4388 metrics.insert(std::make_pair(internal::kUKMCardUploadDecisionMetricName, |
| 4377 upload_decision)); | 4389 upload_decision)); |
| 4378 | 4390 |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4451 GURL url("https://www.google.com"); | 4463 GURL url("https://www.google.com"); |
| 4452 std::map<std::string, int> metrics; | 4464 std::map<std::string, int> metrics; |
| 4453 metrics.insert(std::make_pair("metric", 1)); | 4465 metrics.insert(std::make_pair("metric", 1)); |
| 4454 | 4466 |
| 4455 EXPECT_FALSE(AutofillMetrics::LogUkm( | 4467 EXPECT_FALSE(AutofillMetrics::LogUkm( |
| 4456 ukm_service_test_harness.test_ukm_service(), url, "test_ukm", metrics)); | 4468 ukm_service_test_harness.test_ukm_service(), url, "test_ukm", metrics)); |
| 4457 EXPECT_EQ(0U, ukm_service_test_harness.test_ukm_service()->sources_count()); | 4469 EXPECT_EQ(0U, ukm_service_test_harness.test_ukm_service()->sources_count()); |
| 4458 } | 4470 } |
| 4459 | 4471 |
| 4460 } // namespace autofill | 4472 } // namespace autofill |
| OLD | NEW |