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 1480 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1491 { | 1491 { |
1492 base::HistogramTester histogram_tester; | 1492 base::HistogramTester histogram_tester; |
1493 autofill_manager_->OnFormsSeen(forms, TimeTicks()); | 1493 autofill_manager_->OnFormsSeen(forms, TimeTicks()); |
1494 autofill_manager_->Reset(); | 1494 autofill_manager_->Reset(); |
1495 histogram_tester.ExpectBucketCount("Autofill.DeveloperEngagement", | 1495 histogram_tester.ExpectBucketCount("Autofill.DeveloperEngagement", |
1496 AutofillMetrics::FILLABLE_FORM_PARSED, | 1496 AutofillMetrics::FILLABLE_FORM_PARSED, |
1497 1); | 1497 1); |
1498 histogram_tester.ExpectBucketCount( | 1498 histogram_tester.ExpectBucketCount( |
1499 "Autofill.DeveloperEngagement", | 1499 "Autofill.DeveloperEngagement", |
1500 AutofillMetrics::FILLABLE_FORM_CONTAINS_TYPE_HINTS, 1); | 1500 AutofillMetrics::FILLABLE_FORM_CONTAINS_TYPE_HINTS, 1); |
| 1501 histogram_tester.ExpectBucketCount( |
| 1502 "Autofill.DeveloperEngagement", |
| 1503 AutofillMetrics::FORM_CONTAINS_UPI_VPA_HINT, 0); |
| 1504 } |
| 1505 |
| 1506 // Add a field with an author-specified UPI-VPA field type in the form. |
| 1507 test::CreateTestFormField("", "", "", "text", &field); |
| 1508 field.autocomplete_attribute = "upi-vpa"; |
| 1509 forms.back().fields.push_back(field); |
| 1510 |
| 1511 // Expect the "form parsed" metric, the "author-specified field type |
| 1512 // hints" metric, and the "author-specified upi-vpa type" metric to be logged. |
| 1513 { |
| 1514 base::HistogramTester histogram_tester; |
| 1515 autofill_manager_->OnFormsSeen(forms, TimeTicks()); |
| 1516 autofill_manager_->Reset(); |
| 1517 histogram_tester.ExpectBucketCount("Autofill.DeveloperEngagement", |
| 1518 AutofillMetrics::FILLABLE_FORM_PARSED, |
| 1519 1); |
| 1520 histogram_tester.ExpectBucketCount( |
| 1521 "Autofill.DeveloperEngagement", |
| 1522 AutofillMetrics::FILLABLE_FORM_CONTAINS_TYPE_HINTS, 1); |
| 1523 histogram_tester.ExpectBucketCount( |
| 1524 "Autofill.DeveloperEngagement", |
| 1525 AutofillMetrics::FORM_CONTAINS_UPI_VPA_HINT, 1); |
1501 } | 1526 } |
1502 } | 1527 } |
1503 | 1528 |
1504 // Test that the profile count is logged correctly. | 1529 // Test that the profile count is logged correctly. |
1505 TEST_F(AutofillMetricsTest, StoredProfileCount) { | 1530 TEST_F(AutofillMetricsTest, StoredProfileCount) { |
1506 // The metric should be logged when the profiles are first loaded. | 1531 // The metric should be logged when the profiles are first loaded. |
1507 { | 1532 { |
1508 base::HistogramTester histogram_tester; | 1533 base::HistogramTester histogram_tester; |
1509 personal_data_->LoadProfiles(); | 1534 personal_data_->LoadProfiles(); |
1510 histogram_tester.ExpectUniqueSample("Autofill.StoredProfileCount", 2, 1); | 1535 histogram_tester.ExpectUniqueSample("Autofill.StoredProfileCount", 2, 1); |
(...skipping 2940 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4451 GURL url("https://www.google.com"); | 4476 GURL url("https://www.google.com"); |
4452 std::map<std::string, int> metrics; | 4477 std::map<std::string, int> metrics; |
4453 metrics.insert(std::make_pair("metric", 1)); | 4478 metrics.insert(std::make_pair("metric", 1)); |
4454 | 4479 |
4455 EXPECT_FALSE(AutofillMetrics::LogUkm( | 4480 EXPECT_FALSE(AutofillMetrics::LogUkm( |
4456 ukm_service_test_harness.test_ukm_service(), url, "test_ukm", metrics)); | 4481 ukm_service_test_harness.test_ukm_service(), url, "test_ukm", metrics)); |
4457 EXPECT_EQ(0U, ukm_service_test_harness.test_ukm_service()->sources_count()); | 4482 EXPECT_EQ(0U, ukm_service_test_harness.test_ukm_service()->sources_count()); |
4458 } | 4483 } |
4459 | 4484 |
4460 } // namespace autofill | 4485 } // namespace autofill |
OLD | NEW |