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

Side by Side Diff: components/autofill/core/browser/autofill_metrics_unittest.cc

Issue 2870163003: Log Autofill.Quality.*.ByFieldType by predicted type for unknown data. (Closed)
Patch Set: fix comments Created 3 years, 6 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
OLDNEW
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 <memory> 9 #include <memory>
10 #include <utility> 10 #include <utility>
(...skipping 505 matching lines...) Expand 10 before | Expand all | Expand 10 after
516 // Simulate having seen this form on page load. 516 // Simulate having seen this form on page load.
517 autofill_manager_->AddSeenForm(form, heuristic_types, server_types); 517 autofill_manager_->AddSeenForm(form, heuristic_types, server_types);
518 518
519 // Simulate form submission. 519 // Simulate form submission.
520 base::HistogramTester histogram_tester; 520 base::HistogramTester histogram_tester;
521 autofill_manager_->SubmitForm(form, TimeTicks::Now()); 521 autofill_manager_->SubmitForm(form, TimeTicks::Now());
522 522
523 // Heuristic predictions. 523 // Heuristic predictions.
524 // Unknown: 524 // Unknown:
525 histogram_tester.ExpectBucketCount("Autofill.Quality.HeuristicType", 525 histogram_tester.ExpectBucketCount("Autofill.Quality.HeuristicType",
526 AutofillMetrics::TYPE_UNKNOWN, 1); 526 AutofillMetrics::FALSE_NEGATIVE_UNKNOWN,
527 1);
527 histogram_tester.ExpectBucketCount( 528 histogram_tester.ExpectBucketCount(
528 "Autofill.Quality.HeuristicType.ByFieldType", 529 "Autofill.Quality.HeuristicType.ByFieldType",
529 GetFieldTypeGroupMetric(ADDRESS_HOME_COUNTRY, 530 GetFieldTypeGroupMetric(ADDRESS_HOME_COUNTRY,
530 AutofillMetrics::TYPE_UNKNOWN), 531 AutofillMetrics::FALSE_NEGATIVE_UNKNOWN),
531 1); 532 1);
532 // Match: 533 // Match:
533 histogram_tester.ExpectBucketCount("Autofill.Quality.HeuristicType", 534 histogram_tester.ExpectBucketCount("Autofill.Quality.HeuristicType",
534 AutofillMetrics::TYPE_MATCH, 2); 535 AutofillMetrics::TRUE_POSITIVE, 2);
535 histogram_tester.ExpectBucketCount( 536 histogram_tester.ExpectBucketCount(
536 "Autofill.Quality.HeuristicType.ByFieldType", 537 "Autofill.Quality.HeuristicType.ByFieldType",
537 GetFieldTypeGroupMetric(NAME_FULL, AutofillMetrics::TYPE_MATCH), 1); 538 GetFieldTypeGroupMetric(NAME_FULL, AutofillMetrics::TRUE_POSITIVE), 1);
538 histogram_tester.ExpectBucketCount( 539 histogram_tester.ExpectBucketCount(
539 "Autofill.Quality.HeuristicType.ByFieldType", 540 "Autofill.Quality.HeuristicType.ByFieldType",
540 GetFieldTypeGroupMetric(PHONE_HOME_CITY_AND_NUMBER, 541 GetFieldTypeGroupMetric(PHONE_HOME_CITY_AND_NUMBER,
541 AutofillMetrics::TYPE_MATCH), 542 AutofillMetrics::TRUE_POSITIVE),
542 1); 543 1);
543 // Mismatch: 544 // Mismatch:
544 histogram_tester.ExpectBucketCount("Autofill.Quality.HeuristicType", 545 histogram_tester.ExpectBucketCount("Autofill.Quality.HeuristicType",
545 AutofillMetrics::TYPE_MISMATCH, 1); 546 AutofillMetrics::FALSE_NEGATIVE_MISMATCH,
546 histogram_tester.ExpectBucketCount( 547 1);
547 "Autofill.Quality.HeuristicType.ByFieldType", 548 histogram_tester.ExpectBucketCount(
548 GetFieldTypeGroupMetric(EMAIL_ADDRESS, AutofillMetrics::TYPE_MISMATCH), 549 "Autofill.Quality.HeuristicType.ByFieldType",
550 GetFieldTypeGroupMetric(EMAIL_ADDRESS,
551 AutofillMetrics::FALSE_NEGATIVE_MISMATCH),
549 1); 552 1);
550 553
551 // Server predictions: 554 // Server predictions:
552 // Unknown: 555 // Unknown:
553 histogram_tester.ExpectBucketCount("Autofill.Quality.ServerType", 556 histogram_tester.ExpectBucketCount("Autofill.Quality.ServerType",
554 AutofillMetrics::TYPE_UNKNOWN, 1); 557 AutofillMetrics::FALSE_NEGATIVE_UNKNOWN,
558 1);
555 histogram_tester.ExpectBucketCount( 559 histogram_tester.ExpectBucketCount(
556 "Autofill.Quality.ServerType.ByFieldType", 560 "Autofill.Quality.ServerType.ByFieldType",
557 GetFieldTypeGroupMetric(ADDRESS_HOME_COUNTRY, 561 GetFieldTypeGroupMetric(ADDRESS_HOME_COUNTRY,
558 AutofillMetrics::TYPE_UNKNOWN), 562 AutofillMetrics::FALSE_NEGATIVE_UNKNOWN),
559 1); 563 1);
560 // Match: 564 // Match:
561 histogram_tester.ExpectBucketCount("Autofill.Quality.ServerType", 565 histogram_tester.ExpectBucketCount("Autofill.Quality.ServerType",
562 AutofillMetrics::TYPE_MATCH, 2); 566 AutofillMetrics::TRUE_POSITIVE, 2);
563 histogram_tester.ExpectBucketCount( 567 histogram_tester.ExpectBucketCount(
564 "Autofill.Quality.ServerType.ByFieldType", 568 "Autofill.Quality.ServerType.ByFieldType",
565 GetFieldTypeGroupMetric(EMAIL_ADDRESS, AutofillMetrics::TYPE_MATCH), 1); 569 GetFieldTypeGroupMetric(EMAIL_ADDRESS, AutofillMetrics::TRUE_POSITIVE),
570 1);
566 histogram_tester.ExpectBucketCount( 571 histogram_tester.ExpectBucketCount(
567 "Autofill.Quality.ServerType.ByFieldType", 572 "Autofill.Quality.ServerType.ByFieldType",
568 GetFieldTypeGroupMetric(PHONE_HOME_WHOLE_NUMBER, 573 GetFieldTypeGroupMetric(PHONE_HOME_WHOLE_NUMBER,
569 AutofillMetrics::TYPE_MATCH), 574 AutofillMetrics::TRUE_POSITIVE),
570 1); 575 1);
571 // Mismatch: 576 // Mismatch:
572 histogram_tester.ExpectBucketCount("Autofill.Quality.ServerType", 577 histogram_tester.ExpectBucketCount("Autofill.Quality.ServerType",
573 AutofillMetrics::TYPE_MISMATCH, 1); 578 AutofillMetrics::FALSE_NEGATIVE_MISMATCH,
574 histogram_tester.ExpectBucketCount( 579 1);
575 "Autofill.Quality.ServerType.ByFieldType", 580 histogram_tester.ExpectBucketCount(
576 GetFieldTypeGroupMetric(NAME_FULL, AutofillMetrics::TYPE_MISMATCH), 1); 581 "Autofill.Quality.ServerType.ByFieldType",
582 GetFieldTypeGroupMetric(NAME_FULL,
583 AutofillMetrics::FALSE_NEGATIVE_MISMATCH),
584 1);
577 585
578 // Overall predictions: 586 // Overall predictions:
579 // Unknown: 587 // Unknown:
580 histogram_tester.ExpectBucketCount("Autofill.Quality.PredictedType", 588 histogram_tester.ExpectBucketCount("Autofill.Quality.PredictedType",
581 AutofillMetrics::TYPE_UNKNOWN, 1); 589 AutofillMetrics::FALSE_NEGATIVE_UNKNOWN,
590 1);
582 histogram_tester.ExpectBucketCount( 591 histogram_tester.ExpectBucketCount(
583 "Autofill.Quality.PredictedType.ByFieldType", 592 "Autofill.Quality.PredictedType.ByFieldType",
584 GetFieldTypeGroupMetric(ADDRESS_HOME_COUNTRY, 593 GetFieldTypeGroupMetric(ADDRESS_HOME_COUNTRY,
585 AutofillMetrics::TYPE_UNKNOWN), 594 AutofillMetrics::FALSE_NEGATIVE_UNKNOWN),
586 1); 595 1);
587 // Match: 596 // Match:
588 histogram_tester.ExpectBucketCount("Autofill.Quality.PredictedType", 597 histogram_tester.ExpectBucketCount("Autofill.Quality.PredictedType",
589 AutofillMetrics::TYPE_MATCH, 2); 598 AutofillMetrics::TRUE_POSITIVE, 2);
590 histogram_tester.ExpectBucketCount( 599 histogram_tester.ExpectBucketCount(
591 "Autofill.Quality.PredictedType.ByFieldType", 600 "Autofill.Quality.PredictedType.ByFieldType",
592 GetFieldTypeGroupMetric(EMAIL_ADDRESS, AutofillMetrics::TYPE_MATCH), 1); 601 GetFieldTypeGroupMetric(EMAIL_ADDRESS, AutofillMetrics::TRUE_POSITIVE),
602 1);
593 histogram_tester.ExpectBucketCount( 603 histogram_tester.ExpectBucketCount(
594 "Autofill.Quality.PredictedType.ByFieldType", 604 "Autofill.Quality.PredictedType.ByFieldType",
595 GetFieldTypeGroupMetric(PHONE_HOME_WHOLE_NUMBER, 605 GetFieldTypeGroupMetric(PHONE_HOME_WHOLE_NUMBER,
596 AutofillMetrics::TYPE_MATCH), 606 AutofillMetrics::TRUE_POSITIVE),
597 1); 607 1);
598 // Mismatch: 608 // Mismatch:
599 histogram_tester.ExpectBucketCount("Autofill.Quality.PredictedType", 609 histogram_tester.ExpectBucketCount("Autofill.Quality.PredictedType",
600 AutofillMetrics::TYPE_MISMATCH, 1); 610 AutofillMetrics::FALSE_NEGATIVE_MISMATCH,
601 histogram_tester.ExpectBucketCount( 611 1);
602 "Autofill.Quality.PredictedType.ByFieldType", 612 histogram_tester.ExpectBucketCount(
603 GetFieldTypeGroupMetric(NAME_FULL, AutofillMetrics::TYPE_MISMATCH), 1); 613 "Autofill.Quality.PredictedType.ByFieldType",
614 GetFieldTypeGroupMetric(NAME_FULL,
615 AutofillMetrics::FALSE_NEGATIVE_MISMATCH),
616 1);
604 } 617 }
605 618
606 // Tests the true negatives (empty + no prediction and unknown + no prediction) 619 // Tests the true negatives (empty + no prediction and unknown + no prediction)
607 // and false positives (empty + bad prediction and unknown + bad prediction) 620 // and false positives (empty + bad prediction and unknown + bad prediction)
608 // are counted correctly. 621 // are counted correctly.
609 622
610 struct UnrecognizedOrEmptyFieldsCase { 623 struct QualityMetricsTestCase {
624 const ServerFieldType predicted_field_type;
611 const ServerFieldType actual_field_type; 625 const ServerFieldType actual_field_type;
612 const bool make_prediction;
613 const AutofillMetrics::FieldTypeQualityMetric metric_to_test;
614 }; 626 };
615 627
616 class UnrecognizedOrEmptyFieldsTest 628 class QualityMetricsTest
617 : public AutofillMetricsTest, 629 : public AutofillMetricsTest,
618 public testing::WithParamInterface<UnrecognizedOrEmptyFieldsCase> {}; 630 public testing::WithParamInterface<QualityMetricsTestCase> {
619 631 public:
620 TEST_P(UnrecognizedOrEmptyFieldsTest, QualityMetrics) { 632 const char* ValueForType(ServerFieldType type) {
633 switch (type) {
634 case EMPTY_TYPE:
635 return "";
636 case UNKNOWN_TYPE:
637 return "unknown";
638 case COMPANY_NAME:
639 return "Decca";
640 case NAME_FIRST:
641 return "Elvis";
642 case NAME_MIDDLE:
643 return "Aaron";
644 case NAME_LAST:
645 return "Presley";
646 case NAME_FULL:
647 return "Elvis Aaron Presley";
648 case EMAIL_ADDRESS:
649 return "buddy@gmail.com";
650 case PHONE_HOME_NUMBER:
651 case PHONE_HOME_WHOLE_NUMBER:
652 case PHONE_HOME_CITY_AND_NUMBER:
653 return "2345678901";
654 case ADDRESS_HOME_STREET_ADDRESS:
655 return "123 Apple St.\nunit 6";
656 case ADDRESS_HOME_LINE1:
657 return "123 Apple St.";
658 case ADDRESS_HOME_LINE2:
659 return "unit 6";
660 case ADDRESS_HOME_CITY:
661 return "Lubbock";
662 case ADDRESS_HOME_STATE:
663 return "Texas";
664 case ADDRESS_HOME_ZIP:
665 return "79401";
666 case ADDRESS_HOME_COUNTRY:
667 return "US";
668 default:
669 NOTREACHED(); // Fall through
670 return "unexpected!";
671 }
672 }
673
674 bool IsExampleOf(AutofillMetrics::FieldTypeQualityMetric metric,
675 ServerFieldType predicted_type,
676 ServerFieldType actual_type) {
677 switch (metric) {
678 case AutofillMetrics::TRUE_POSITIVE:
679 return actual_type != UNKNOWN_TYPE && actual_type != EMPTY_TYPE &&
680 predicted_type == actual_type;
681
682 case AutofillMetrics::TRUE_NEGATIVE_UNKNOWN:
683 return actual_type == UNKNOWN_TYPE && predicted_type == UNKNOWN_TYPE;
684
685 case AutofillMetrics::TRUE_NEGATIVE_EMPTY:
686 return actual_type == EMPTY_TYPE && predicted_type == UNKNOWN_TYPE;
687
688 // False negative mismatch and false positive mismatch trigger on the same
689 // conditions:
690 // - False positive prediction of predicted type
691 // - False negative prediction of actual type
692 case AutofillMetrics::FALSE_POSITIVE_MISMATCH:
693 case AutofillMetrics::FALSE_NEGATIVE_MISMATCH:
694 return actual_type != UNKNOWN_TYPE && actual_type != EMPTY_TYPE &&
695 actual_type != predicted_type && predicted_type != UNKNOWN_TYPE;
696
697 case AutofillMetrics::FALSE_POSITIVE_UNKNOWN:
698 return actual_type == UNKNOWN_TYPE && predicted_type != UNKNOWN_TYPE;
699
700 case AutofillMetrics::FALSE_POSITIVE_EMPTY:
701 return actual_type == EMPTY_TYPE && predicted_type != UNKNOWN_TYPE;
702
703 case AutofillMetrics::FALSE_NEGATIVE_UNKNOWN:
704 return actual_type != EMPTY_TYPE && actual_type != UNKNOWN_TYPE &&
705 actual_type != predicted_type && predicted_type == UNKNOWN_TYPE;
706 default:
707 NOTREACHED();
708 }
709 return false;
710 }
711 };
712
713 TEST_P(QualityMetricsTest, Classification) {
621 // Setup the test parameters. 714 // Setup the test parameters.
622 const ServerFieldType actual_field_type = GetParam().actual_field_type; 715 const ServerFieldType actual_field_type = GetParam().actual_field_type;
623 const ServerFieldType heuristic_type = 716 const ServerFieldType predicted_type = GetParam().predicted_field_type;
624 GetParam().make_prediction ? EMAIL_ADDRESS : UNKNOWN_TYPE; 717
625 const ServerFieldType server_type = 718 VLOG(2) << "Test Case = Predicted: "
626 GetParam().make_prediction ? EMAIL_ADDRESS : NO_SERVER_DATA; 719 << AutofillType(predicted_type).ToString() << "; "
627 const AutofillMetrics::FieldTypeQualityMetric metric_to_test = 720 << "Actual: " << AutofillType(actual_field_type).ToString();
628 GetParam().metric_to_test;
629 721
630 // Set up our form data. 722 // Set up our form data.
631 FormData form; 723 FormData form;
632 form.name = ASCIIToUTF16("TestForm"); 724 form.name = ASCIIToUTF16("TestForm");
633 form.origin = GURL("http://example.com/form.html"); 725 form.origin = GURL("http://example.com/form.html");
634 form.action = GURL("http://example.com/submit.html"); 726 form.action = GURL("http://example.com/submit.html");
635 727
636 std::vector<ServerFieldType> heuristic_types, server_types; 728 std::vector<ServerFieldType> heuristic_types, server_types;
637 AutofillField field; 729 AutofillField field;
638 730
639 // Add a first name field, that is predicted correctly. 731 // Add a first name field, that is predicted correctly.
640 test::CreateTestFormField("first", "first", "Elvis", "text", &field); 732 test::CreateTestFormField("first", "first", ValueForType(NAME_FIRST), "text",
641 field.set_possible_types({NAME_FIRST}); 733 &field);
642 form.fields.push_back(field); 734 form.fields.push_back(field);
643 heuristic_types.push_back(NAME_FIRST); 735 heuristic_types.push_back(NAME_FIRST);
644 server_types.push_back(NAME_FIRST); 736 server_types.push_back(NAME_FIRST);
645 737
646 // Add a last name field, that is predicted correctly. 738 // Add a last name field, that is predicted correctly.
647 test::CreateTestFormField("last", "last", "Presley", "test", &field); 739 test::CreateTestFormField("last", "last", ValueForType(NAME_LAST), "test",
648 field.set_possible_types({NAME_LAST}); 740 &field);
649 form.fields.push_back(field); 741 form.fields.push_back(field);
650 heuristic_types.push_back(NAME_LAST); 742 heuristic_types.push_back(NAME_LAST);
651 server_types.push_back(NAME_LAST); 743 server_types.push_back(NAME_LAST);
652 744
653 // Add an empty or unknown field, that is predicted as per the test params. 745 // Add an empty or unknown field, that is predicted as per the test params.
654 test::CreateTestFormField("Unknown", "Unknown", 746 test::CreateTestFormField("Unknown", "Unknown",
655 (actual_field_type == EMPTY_TYPE ? "" : "unknown"), 747 ValueForType(actual_field_type), "text", &field);
656 "text", &field);
657 field.set_possible_types({actual_field_type});
658 form.fields.push_back(field); 748 form.fields.push_back(field);
659 heuristic_types.push_back(heuristic_type); 749 heuristic_types.push_back(predicted_type);
660 server_types.push_back(server_type); 750 server_types.push_back(predicted_type == UNKNOWN_TYPE ? NO_SERVER_DATA
751 : predicted_type);
661 752
662 // Simulate having seen this form on page load. 753 // Simulate having seen this form on page load.
663 autofill_manager_->AddSeenForm(form, heuristic_types, server_types); 754 autofill_manager_->AddSeenForm(form, heuristic_types, server_types);
664 755
665 // Run the form submission code while tracking the histograms. 756 // Run the form submission code while tracking the histograms.
666 base::HistogramTester histogram_tester; 757 base::HistogramTester histogram_tester;
667 autofill_manager_->SubmitForm(form, TimeTicks::Now()); 758 autofill_manager_->SubmitForm(form, TimeTicks::Now());
668 759
669 // Validate the histogram counter values. 760 // Validate the histogram counter values.
670 for (int i = 0; i < AutofillMetrics::NUM_FIELD_TYPE_QUALITY_METRICS; ++i) { 761 for (int i = 0; i < AutofillMetrics::NUM_FIELD_TYPE_QUALITY_METRICS; ++i) {
671 // The metric enum value we're currently examining. 762 // The metric enum value we're currently examining.
672 auto metric = static_cast<AutofillMetrics::FieldTypeQualityMetric>(i); 763 auto metric = static_cast<AutofillMetrics::FieldTypeQualityMetric>(i);
673 764
674 // For the overall metric counts... 765 // The type specific expected count is 1 if (predicted, actual) is an
675 // If the current metric is the metric we're testing, then we expect its 766 // example
676 // count to be 1. Otherwise, the metric's count should be zero (0) except 767 int basic_expected_count =
677 // for the TYPE_MATCH metric which should be 2 (because of the matching 768 IsExampleOf(metric, predicted_type, actual_field_type) ? 1 : 0;
678 // first and last name fields) 769
679 int overall_expected_count = 770 // We don't capture aggregate FALSE_POSITIVE_MISMATCH.
680 (metric == metric_to_test) 771 int aggregate_expected_count =
681 ? 1 772 (metric == AutofillMetrics::TRUE_POSITIVE ? 2 : 0) +
682 : ((metric == AutofillMetrics::TYPE_MATCH) ? 2 : 0); 773 (metric == AutofillMetrics::FALSE_POSITIVE_MISMATCH
774 ? 0
775 : basic_expected_count);
683 776
684 histogram_tester.ExpectBucketCount("Autofill.Quality.HeuristicType", metric, 777 histogram_tester.ExpectBucketCount("Autofill.Quality.HeuristicType", metric,
685 overall_expected_count); 778 aggregate_expected_count);
686 histogram_tester.ExpectBucketCount("Autofill.Quality.ServerType", metric, 779 histogram_tester.ExpectBucketCount("Autofill.Quality.ServerType", metric,
687 overall_expected_count); 780 aggregate_expected_count);
688 histogram_tester.ExpectBucketCount("Autofill.Quality.PredictedType", metric, 781 histogram_tester.ExpectBucketCount("Autofill.Quality.PredictedType", metric,
689 overall_expected_count); 782 aggregate_expected_count);
690 783
691 // For the ByFieldType metric counts... 784 int expected_count_for_actual_type =
692 // We only examine the counter for the field_type being tested. If the 785 (actual_field_type != UNKNOWN_TYPE && actual_field_type != EMPTY_TYPE &&
693 // current metric is the metric we're testing, then we expect its 786 metric != AutofillMetrics::FALSE_POSITIVE_MISMATCH)
694 // count to be 1 otherwise it should be 0. 787 ? basic_expected_count
695 int field_type_expected_count = (metric == metric_to_test) ? 1 : 0; 788 : 0;
789
790 // For the ByFieldType metric counts for actual_field_type...
791 histogram_tester.ExpectBucketCount(
792 "Autofill.Quality.HeuristicType.ByFieldType",
793 GetFieldTypeGroupMetric(actual_field_type, metric),
794 expected_count_for_actual_type);
795 histogram_tester.ExpectBucketCount(
796 "Autofill.Quality.ServerType.ByFieldType",
797 GetFieldTypeGroupMetric(actual_field_type, metric),
798 expected_count_for_actual_type);
799 histogram_tester.ExpectBucketCount(
800 "Autofill.Quality.PredictedType.ByFieldType",
801 GetFieldTypeGroupMetric(actual_field_type, metric),
802 expected_count_for_actual_type);
803
804 int expected_count_for_predicted_type =
805 (predicted_type != UNKNOWN_TYPE &&
806 metric != AutofillMetrics::FALSE_NEGATIVE_MISMATCH)
807 ? basic_expected_count
808 : 0;
696 809
697 histogram_tester.ExpectBucketCount( 810 histogram_tester.ExpectBucketCount(
698 "Autofill.Quality.HeuristicType.ByFieldType", 811 "Autofill.Quality.HeuristicType.ByFieldType",
699 GetFieldTypeGroupMetric(actual_field_type, metric), 812 GetFieldTypeGroupMetric(predicted_type, metric),
700 field_type_expected_count); 813 expected_count_for_predicted_type);
701 histogram_tester.ExpectBucketCount( 814 histogram_tester.ExpectBucketCount(
702 "Autofill.Quality.ServerType.ByFieldType", 815 "Autofill.Quality.ServerType.ByFieldType",
703 GetFieldTypeGroupMetric(actual_field_type, metric), 816 GetFieldTypeGroupMetric(predicted_type, metric),
704 field_type_expected_count); 817 expected_count_for_predicted_type);
705 histogram_tester.ExpectBucketCount( 818 histogram_tester.ExpectBucketCount(
706 "Autofill.Quality.PredictedType.ByFieldType", 819 "Autofill.Quality.PredictedType.ByFieldType",
707 GetFieldTypeGroupMetric(actual_field_type, metric), 820 GetFieldTypeGroupMetric(predicted_type, metric),
708 field_type_expected_count); 821 expected_count_for_predicted_type);
709 } 822 }
710 } 823 }
711 824
712 INSTANTIATE_TEST_CASE_P( 825 INSTANTIATE_TEST_CASE_P(
713 AutofillMetricsTest, 826 AutofillMetricsTest,
714 UnrecognizedOrEmptyFieldsTest, 827 QualityMetricsTest,
715 testing::Values( 828 testing::Values(QualityMetricsTestCase{UNKNOWN_TYPE, EMPTY_TYPE},
716 UnrecognizedOrEmptyFieldsCase{EMPTY_TYPE, 829 QualityMetricsTestCase{UNKNOWN_TYPE, UNKNOWN_TYPE},
717 /* make_prediction = */ false, 830 QualityMetricsTestCase{UNKNOWN_TYPE, EMAIL_ADDRESS},
718 AutofillMetrics::TYPE_MATCH_EMPTY}, 831 QualityMetricsTestCase{EMAIL_ADDRESS, EMPTY_TYPE},
719 UnrecognizedOrEmptyFieldsCase{UNKNOWN_TYPE, 832 QualityMetricsTestCase{EMAIL_ADDRESS, UNKNOWN_TYPE},
720 /* make_prediction = */ false, 833 QualityMetricsTestCase{EMAIL_ADDRESS, EMAIL_ADDRESS},
721 AutofillMetrics::TYPE_MATCH_UNKNOWN}, 834 QualityMetricsTestCase{EMAIL_ADDRESS, COMPANY_NAME},
722 UnrecognizedOrEmptyFieldsCase{EMPTY_TYPE, 835 QualityMetricsTestCase{COMPANY_NAME, EMAIL_ADDRESS}));
723 /* make_prediction = */ true,
724 AutofillMetrics::TYPE_MISMATCH_EMPTY},
725 UnrecognizedOrEmptyFieldsCase{UNKNOWN_TYPE,
726 /* make_prediction = */ true,
727 AutofillMetrics::TYPE_MISMATCH_UNKNOWN}));
728 836
729 // Ensures that metrics that measure timing some important Autofill functions 837 // Ensures that metrics that measure timing some important Autofill functions
730 // actually are recorded and retrieved. 838 // actually are recorded and retrieved.
731 TEST_F(AutofillMetricsTest, TimingMetrics) { 839 TEST_F(AutofillMetricsTest, TimingMetrics) {
732 base::HistogramTester histogram_tester; 840 base::HistogramTester histogram_tester;
733 841
734 FormData form; 842 FormData form;
735 form.name = ASCIIToUTF16("TestForm"); 843 form.name = ASCIIToUTF16("TestForm");
736 form.origin = GURL("http://example.com/form.html"); 844 form.origin = GURL("http://example.com/form.html");
737 form.action = GURL("http://example.com/submit.html"); 845 form.action = GURL("http://example.com/submit.html");
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
826 base::HistogramTester histogram_tester; 934 base::HistogramTester histogram_tester;
827 935
828 autofill_manager_->ResetRunLoop(); 936 autofill_manager_->ResetRunLoop();
829 autofill_manager_->Reset(); 937 autofill_manager_->Reset();
830 autofill_manager_->RunRunLoop(); 938 autofill_manager_->RunRunLoop();
831 939
832 // Heuristic predictions. 940 // Heuristic predictions.
833 // Unknown: 941 // Unknown:
834 histogram_tester.ExpectBucketCount( 942 histogram_tester.ExpectBucketCount(
835 "Autofill.Quality.HeuristicType.NoSubmission", 943 "Autofill.Quality.HeuristicType.NoSubmission",
836 AutofillMetrics::TYPE_UNKNOWN, 1); 944 AutofillMetrics::FALSE_NEGATIVE_UNKNOWN, 1);
837 histogram_tester.ExpectBucketCount( 945 histogram_tester.ExpectBucketCount(
838 "Autofill.Quality.HeuristicType.ByFieldType.NoSubmission", 946 "Autofill.Quality.HeuristicType.ByFieldType.NoSubmission",
839 GetFieldTypeGroupMetric(ADDRESS_HOME_COUNTRY, 947 GetFieldTypeGroupMetric(ADDRESS_HOME_COUNTRY,
840 AutofillMetrics::TYPE_UNKNOWN), 948 AutofillMetrics::FALSE_NEGATIVE_UNKNOWN),
841 1); 949 1);
842 // Match: 950 // Match:
843 histogram_tester.ExpectBucketCount( 951 histogram_tester.ExpectBucketCount(
844 "Autofill.Quality.HeuristicType.NoSubmission", 952 "Autofill.Quality.HeuristicType.NoSubmission",
845 AutofillMetrics::TYPE_MATCH, 2); 953 AutofillMetrics::TRUE_POSITIVE, 2);
846 histogram_tester.ExpectBucketCount( 954 histogram_tester.ExpectBucketCount(
847 "Autofill.Quality.HeuristicType.ByFieldType.NoSubmission", 955 "Autofill.Quality.HeuristicType.ByFieldType.NoSubmission",
848 GetFieldTypeGroupMetric(NAME_FULL, AutofillMetrics::TYPE_MATCH), 1); 956 GetFieldTypeGroupMetric(NAME_FULL, AutofillMetrics::TRUE_POSITIVE), 1);
849 histogram_tester.ExpectBucketCount( 957 histogram_tester.ExpectBucketCount(
850 "Autofill.Quality.HeuristicType.ByFieldType.NoSubmission", 958 "Autofill.Quality.HeuristicType.ByFieldType.NoSubmission",
851 GetFieldTypeGroupMetric(PHONE_HOME_WHOLE_NUMBER, 959 GetFieldTypeGroupMetric(PHONE_HOME_WHOLE_NUMBER,
852 AutofillMetrics::TYPE_MATCH), 960 AutofillMetrics::TRUE_POSITIVE),
853 1); 961 1);
854 // Mismatch: 962 // Mismatch:
855 histogram_tester.ExpectBucketCount( 963 histogram_tester.ExpectBucketCount(
856 "Autofill.Quality.HeuristicType.NoSubmission", 964 "Autofill.Quality.HeuristicType.NoSubmission",
857 AutofillMetrics::TYPE_MISMATCH, 1); 965 AutofillMetrics::FALSE_NEGATIVE_MISMATCH, 1);
858 histogram_tester.ExpectBucketCount( 966 histogram_tester.ExpectBucketCount(
859 "Autofill.Quality.HeuristicType.ByFieldType.NoSubmission", 967 "Autofill.Quality.HeuristicType.ByFieldType.NoSubmission",
860 GetFieldTypeGroupMetric(EMAIL_ADDRESS, AutofillMetrics::TYPE_MISMATCH), 968 GetFieldTypeGroupMetric(EMAIL_ADDRESS,
969 AutofillMetrics::FALSE_NEGATIVE_MISMATCH),
861 1); 970 1);
862 971
863 // Server predictions: 972 // Server predictions:
864 // Unknown: 973 // Unknown:
865 histogram_tester.ExpectBucketCount("Autofill.Quality.ServerType.NoSubmission", 974 histogram_tester.ExpectBucketCount("Autofill.Quality.ServerType.NoSubmission",
866 AutofillMetrics::TYPE_UNKNOWN, 1); 975 AutofillMetrics::FALSE_NEGATIVE_UNKNOWN,
976 1);
867 histogram_tester.ExpectBucketCount( 977 histogram_tester.ExpectBucketCount(
868 "Autofill.Quality.ServerType.ByFieldType.NoSubmission", 978 "Autofill.Quality.ServerType.ByFieldType.NoSubmission",
869 GetFieldTypeGroupMetric(ADDRESS_HOME_COUNTRY, 979 GetFieldTypeGroupMetric(ADDRESS_HOME_COUNTRY,
870 AutofillMetrics::TYPE_UNKNOWN), 980 AutofillMetrics::FALSE_NEGATIVE_UNKNOWN),
871 1); 981 1);
872 // Match: 982 // Match:
873 histogram_tester.ExpectBucketCount("Autofill.Quality.ServerType.NoSubmission", 983 histogram_tester.ExpectBucketCount("Autofill.Quality.ServerType.NoSubmission",
874 AutofillMetrics::TYPE_MATCH, 2); 984 AutofillMetrics::TRUE_POSITIVE, 2);
875 histogram_tester.ExpectBucketCount( 985 histogram_tester.ExpectBucketCount(
876 "Autofill.Quality.ServerType.ByFieldType.NoSubmission", 986 "Autofill.Quality.ServerType.ByFieldType.NoSubmission",
877 GetFieldTypeGroupMetric(EMAIL_ADDRESS, AutofillMetrics::TYPE_MATCH), 1); 987 GetFieldTypeGroupMetric(EMAIL_ADDRESS, AutofillMetrics::TRUE_POSITIVE),
988 1);
878 histogram_tester.ExpectBucketCount( 989 histogram_tester.ExpectBucketCount(
879 "Autofill.Quality.ServerType.ByFieldType.NoSubmission", 990 "Autofill.Quality.ServerType.ByFieldType.NoSubmission",
880 GetFieldTypeGroupMetric(PHONE_HOME_WHOLE_NUMBER, 991 GetFieldTypeGroupMetric(PHONE_HOME_WHOLE_NUMBER,
881 AutofillMetrics::TYPE_MATCH), 992 AutofillMetrics::TRUE_POSITIVE),
882 1); 993 1);
883 // Mismatch: 994 // Mismatch:
884 histogram_tester.ExpectBucketCount("Autofill.Quality.ServerType.NoSubmission", 995 histogram_tester.ExpectBucketCount("Autofill.Quality.ServerType.NoSubmission",
885 AutofillMetrics::TYPE_MISMATCH, 1); 996 AutofillMetrics::FALSE_NEGATIVE_MISMATCH,
997 1);
886 histogram_tester.ExpectBucketCount( 998 histogram_tester.ExpectBucketCount(
887 "Autofill.Quality.ServerType.ByFieldType.NoSubmission", 999 "Autofill.Quality.ServerType.ByFieldType.NoSubmission",
888 GetFieldTypeGroupMetric(NAME_FULL, AutofillMetrics::TYPE_MISMATCH), 1); 1000 GetFieldTypeGroupMetric(NAME_FULL,
1001 AutofillMetrics::FALSE_NEGATIVE_MISMATCH),
1002 1);
889 1003
890 // Overall predictions: 1004 // Overall predictions:
891 // Unknown: 1005 // Unknown:
892 histogram_tester.ExpectBucketCount( 1006 histogram_tester.ExpectBucketCount(
893 "Autofill.Quality.PredictedType.NoSubmission", 1007 "Autofill.Quality.PredictedType.NoSubmission",
894 AutofillMetrics::TYPE_UNKNOWN, 1); 1008 AutofillMetrics::FALSE_NEGATIVE_UNKNOWN, 1);
895 histogram_tester.ExpectBucketCount( 1009 histogram_tester.ExpectBucketCount(
896 "Autofill.Quality.PredictedType.ByFieldType.NoSubmission", 1010 "Autofill.Quality.PredictedType.ByFieldType.NoSubmission",
897 GetFieldTypeGroupMetric(ADDRESS_HOME_COUNTRY, 1011 GetFieldTypeGroupMetric(ADDRESS_HOME_COUNTRY,
898 AutofillMetrics::TYPE_UNKNOWN), 1012 AutofillMetrics::FALSE_NEGATIVE_UNKNOWN),
899 1); 1013 1);
900 // Match: 1014 // Match:
901 histogram_tester.ExpectBucketCount( 1015 histogram_tester.ExpectBucketCount(
902 "Autofill.Quality.PredictedType.NoSubmission", 1016 "Autofill.Quality.PredictedType.NoSubmission",
903 AutofillMetrics::TYPE_MATCH, 2); 1017 AutofillMetrics::TRUE_POSITIVE, 2);
904 histogram_tester.ExpectBucketCount( 1018 histogram_tester.ExpectBucketCount(
905 "Autofill.Quality.PredictedType.ByFieldType.NoSubmission", 1019 "Autofill.Quality.PredictedType.ByFieldType.NoSubmission",
906 GetFieldTypeGroupMetric(EMAIL_ADDRESS, AutofillMetrics::TYPE_MATCH), 1); 1020 GetFieldTypeGroupMetric(EMAIL_ADDRESS, AutofillMetrics::TRUE_POSITIVE),
1021 1);
907 histogram_tester.ExpectBucketCount( 1022 histogram_tester.ExpectBucketCount(
908 "Autofill.Quality.PredictedType.ByFieldType.NoSubmission", 1023 "Autofill.Quality.PredictedType.ByFieldType.NoSubmission",
909 GetFieldTypeGroupMetric(PHONE_HOME_WHOLE_NUMBER, 1024 GetFieldTypeGroupMetric(PHONE_HOME_WHOLE_NUMBER,
910 AutofillMetrics::TYPE_MATCH), 1025 AutofillMetrics::TRUE_POSITIVE),
911 1); 1026 1);
912 // Mismatch: 1027 // Mismatch:
913 histogram_tester.ExpectBucketCount( 1028 histogram_tester.ExpectBucketCount(
914 "Autofill.Quality.PredictedType.NoSubmission", 1029 "Autofill.Quality.PredictedType.NoSubmission",
915 AutofillMetrics::TYPE_MISMATCH, 1); 1030 AutofillMetrics::FALSE_NEGATIVE_MISMATCH, 1);
916 histogram_tester.ExpectBucketCount( 1031 histogram_tester.ExpectBucketCount(
917 "Autofill.Quality.PredictedType.ByFieldType.NoSubmission", 1032 "Autofill.Quality.PredictedType.ByFieldType.NoSubmission",
918 GetFieldTypeGroupMetric(NAME_FULL, AutofillMetrics::TYPE_MISMATCH), 1); 1033 GetFieldTypeGroupMetric(NAME_FULL,
1034 AutofillMetrics::FALSE_NEGATIVE_MISMATCH),
1035 1);
919 } 1036 }
920 1037
921 // Test that we log quality metrics for heuristics and server predictions based 1038 // Test that we log quality metrics for heuristics and server predictions based
922 // on autocomplete attributes present on the fields. 1039 // on autocomplete attributes present on the fields.
923 TEST_F(AutofillMetricsTest, QualityMetrics_BasedOnAutocomplete) { 1040 TEST_F(AutofillMetricsTest, QualityMetrics_BasedOnAutocomplete) {
924 FormData form; 1041 FormData form;
925 form.name = ASCIIToUTF16("MyForm"); 1042 form.name = ASCIIToUTF16("MyForm");
926 form.origin = GURL("http://myform.com/form.html"); 1043 form.origin = GURL("http://myform.com/form.html");
927 form.action = GURL("http://myform.com/submit.html"); 1044 form.action = GURL("http://myform.com/submit.html");
928 1045
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
983 EXPECT_EQ(NAME_LAST, form_structure_ptr->field(0)->Type().GetStorableType()); 1100 EXPECT_EQ(NAME_LAST, form_structure_ptr->field(0)->Type().GetStorableType());
984 EXPECT_EQ(NAME_MIDDLE, 1101 EXPECT_EQ(NAME_MIDDLE,
985 form_structure_ptr->field(1)->Type().GetStorableType()); 1102 form_structure_ptr->field(1)->Type().GetStorableType());
986 EXPECT_EQ(ADDRESS_HOME_ZIP, 1103 EXPECT_EQ(ADDRESS_HOME_ZIP,
987 form_structure_ptr->field(2)->Type().GetStorableType()); 1104 form_structure_ptr->field(2)->Type().GetStorableType());
988 1105
989 // Heuristic predictions. 1106 // Heuristic predictions.
990 // Unknown: 1107 // Unknown:
991 histogram_tester.ExpectBucketCount( 1108 histogram_tester.ExpectBucketCount(
992 "Autofill.Quality.HeuristicType.BasedOnAutocomplete", 1109 "Autofill.Quality.HeuristicType.BasedOnAutocomplete",
993 AutofillMetrics::TYPE_UNKNOWN, 1); 1110 AutofillMetrics::FALSE_NEGATIVE_UNKNOWN, 1);
994 histogram_tester.ExpectBucketCount( 1111 histogram_tester.ExpectBucketCount(
995 "Autofill.Quality.HeuristicType.ByFieldType.BasedOnAutocomplete", 1112 "Autofill.Quality.HeuristicType.ByFieldType.BasedOnAutocomplete",
996 GetFieldTypeGroupMetric(ADDRESS_HOME_ZIP, AutofillMetrics::TYPE_UNKNOWN), 1113 GetFieldTypeGroupMetric(ADDRESS_HOME_ZIP,
1114 AutofillMetrics::FALSE_NEGATIVE_UNKNOWN),
997 1); 1115 1);
998 // Match: 1116 // Match:
999 histogram_tester.ExpectBucketCount( 1117 histogram_tester.ExpectBucketCount(
1000 "Autofill.Quality.HeuristicType.BasedOnAutocomplete", 1118 "Autofill.Quality.HeuristicType.BasedOnAutocomplete",
1001 AutofillMetrics::TYPE_MATCH, 1); 1119 AutofillMetrics::TRUE_POSITIVE, 1);
1002 histogram_tester.ExpectBucketCount( 1120 histogram_tester.ExpectBucketCount(
1003 "Autofill.Quality.HeuristicType.ByFieldType.BasedOnAutocomplete", 1121 "Autofill.Quality.HeuristicType.ByFieldType.BasedOnAutocomplete",
1004 GetFieldTypeGroupMetric(NAME_LAST, AutofillMetrics::TYPE_MATCH), 1); 1122 GetFieldTypeGroupMetric(NAME_LAST, AutofillMetrics::TRUE_POSITIVE), 1);
1005 // Mismatch: 1123 // Mismatch:
1006 histogram_tester.ExpectBucketCount( 1124 histogram_tester.ExpectBucketCount(
1007 "Autofill.Quality.HeuristicType.BasedOnAutocomplete", 1125 "Autofill.Quality.HeuristicType.BasedOnAutocomplete",
1008 AutofillMetrics::TYPE_MISMATCH, 1); 1126 AutofillMetrics::FALSE_NEGATIVE_MISMATCH, 1);
1009 histogram_tester.ExpectBucketCount( 1127 histogram_tester.ExpectBucketCount(
1010 "Autofill.Quality.HeuristicType.ByFieldType.BasedOnAutocomplete", 1128 "Autofill.Quality.HeuristicType.ByFieldType.BasedOnAutocomplete",
1011 GetFieldTypeGroupMetric(NAME_MIDDLE, AutofillMetrics::TYPE_MISMATCH), 1); 1129 GetFieldTypeGroupMetric(NAME_MIDDLE,
1130 AutofillMetrics::FALSE_NEGATIVE_MISMATCH),
1131 1);
1012 1132
1013 // Server predictions. 1133 // Server predictions.
1014 // Unknown: 1134 // Unknown:
1015 histogram_tester.ExpectBucketCount( 1135 histogram_tester.ExpectBucketCount(
1016 "Autofill.Quality.ServerType.BasedOnAutocomplete", 1136 "Autofill.Quality.ServerType.BasedOnAutocomplete",
1017 AutofillMetrics::TYPE_UNKNOWN, 1); 1137 AutofillMetrics::FALSE_NEGATIVE_UNKNOWN, 1);
1018 histogram_tester.ExpectBucketCount( 1138 histogram_tester.ExpectBucketCount(
1019 "Autofill.Quality.ServerType.ByFieldType.BasedOnAutocomplete", 1139 "Autofill.Quality.ServerType.ByFieldType.BasedOnAutocomplete",
1020 GetFieldTypeGroupMetric(ADDRESS_HOME_ZIP, AutofillMetrics::TYPE_UNKNOWN), 1140 GetFieldTypeGroupMetric(ADDRESS_HOME_ZIP,
1141 AutofillMetrics::FALSE_NEGATIVE_UNKNOWN),
1021 1); 1142 1);
1022 // Match: 1143 // Match:
1023 histogram_tester.ExpectBucketCount( 1144 histogram_tester.ExpectBucketCount(
1024 "Autofill.Quality.ServerType.BasedOnAutocomplete", 1145 "Autofill.Quality.ServerType.BasedOnAutocomplete",
1025 AutofillMetrics::TYPE_MATCH, 1); 1146 AutofillMetrics::TRUE_POSITIVE, 1);
1026 histogram_tester.ExpectBucketCount( 1147 histogram_tester.ExpectBucketCount(
1027 "Autofill.Quality.ServerType.ByFieldType.BasedOnAutocomplete", 1148 "Autofill.Quality.ServerType.ByFieldType.BasedOnAutocomplete",
1028 GetFieldTypeGroupMetric(NAME_LAST, AutofillMetrics::TYPE_MATCH), 1); 1149 GetFieldTypeGroupMetric(NAME_LAST, AutofillMetrics::TRUE_POSITIVE), 1);
1029 // Mismatch: 1150 // Mismatch:
1030 histogram_tester.ExpectBucketCount( 1151 histogram_tester.ExpectBucketCount(
1031 "Autofill.Quality.ServerType.BasedOnAutocomplete", 1152 "Autofill.Quality.ServerType.BasedOnAutocomplete",
1032 AutofillMetrics::TYPE_MISMATCH, 1); 1153 AutofillMetrics::FALSE_NEGATIVE_MISMATCH, 1);
1033 histogram_tester.ExpectBucketCount( 1154 histogram_tester.ExpectBucketCount(
1034 "Autofill.Quality.ServerType.ByFieldType.BasedOnAutocomplete", 1155 "Autofill.Quality.ServerType.ByFieldType.BasedOnAutocomplete",
1035 GetFieldTypeGroupMetric(NAME_MIDDLE, AutofillMetrics::TYPE_MISMATCH), 1); 1156 GetFieldTypeGroupMetric(NAME_MIDDLE,
1157 AutofillMetrics::FALSE_NEGATIVE_MISMATCH),
1158 1);
1036 } 1159 }
1037 1160
1038 // Test that we log UPI Virtual Payment Address. 1161 // Test that we log UPI Virtual Payment Address.
1039 TEST_F(AutofillMetricsTest, UpiVirtualPaymentAddress) { 1162 TEST_F(AutofillMetricsTest, UpiVirtualPaymentAddress) {
1040 // Set up our form data. 1163 // Set up our form data.
1041 FormData form; 1164 FormData form;
1042 form.name = ASCIIToUTF16("TestForm"); 1165 form.name = ASCIIToUTF16("TestForm");
1043 form.origin = GURL("http://example.com/form.html"); 1166 form.origin = GURL("http://example.com/form.html");
1044 form.action = GURL("http://example.com/submit.html"); 1167 form.action = GURL("http://example.com/submit.html");
1045 1168
(...skipping 23 matching lines...) Expand all
1069 autofill_manager_->AddSeenForm(form, heuristic_types, server_types); 1192 autofill_manager_->AddSeenForm(form, heuristic_types, server_types);
1070 1193
1071 // Simulate form submission. 1194 // Simulate form submission.
1072 base::HistogramTester histogram_tester; 1195 base::HistogramTester histogram_tester;
1073 autofill_manager_->SubmitForm(form, TimeTicks::Now()); 1196 autofill_manager_->SubmitForm(form, TimeTicks::Now());
1074 1197
1075 histogram_tester.ExpectBucketCount( 1198 histogram_tester.ExpectBucketCount(
1076 "Autofill.UserHappiness", AutofillMetrics::USER_DID_ENTER_UPI_VPA, 1); 1199 "Autofill.UserHappiness", AutofillMetrics::USER_DID_ENTER_UPI_VPA, 1);
1077 } 1200 }
1078 1201
1079 // Test that we do not log RAPPOR metrics when the number of mismatches is not
1080 // high enough.
1081 TEST_F(AutofillMetricsTest, Rappor_LowMismatchRate_NoMetricsReported) {
1082 // Set up our form data.
1083 FormData form;
1084 form.name = ASCIIToUTF16("TestForm");
1085 form.origin = GURL("http://example.com/form.html");
1086 form.action = GURL("http://example.com/submit.html");
1087
1088 std::vector<ServerFieldType> heuristic_types, server_types;
1089 FormFieldData field;
1090
1091 test::CreateTestFormField("Autofilled", "autofilled", "Elvis Aaron Presley",
1092 "text", &field);
1093 field.is_autofilled = true;
1094 form.fields.push_back(field);
1095 heuristic_types.push_back(NAME_FULL);
1096 server_types.push_back(NAME_FULL);
1097
1098 test::CreateTestFormField("Autofill Failed", "autofillfailed",
1099 "buddy@gmail.com", "text", &field);
1100 field.is_autofilled = false;
1101 form.fields.push_back(field);
1102 heuristic_types.push_back(EMAIL_ADDRESS);
1103 server_types.push_back(NAME_LAST);
1104
1105 test::CreateTestFormField("Phone", "phone", "2345678901", "tel", &field);
1106 field.is_autofilled = true;
1107 form.fields.push_back(field);
1108 heuristic_types.push_back(PHONE_HOME_CITY_AND_NUMBER);
1109 server_types.push_back(EMAIL_ADDRESS);
1110
1111 // Simulate having seen this form on page load.
1112 autofill_manager_->AddSeenForm(form, heuristic_types, server_types);
1113
1114 // Simulate form submission.
1115 autofill_manager_->SubmitForm(form, TimeTicks::Now());
1116
1117 // The number of mismatches did not trigger the RAPPOR metric logging.
1118 EXPECT_EQ(0, autofill_client_.test_rappor_service()->GetReportsCount());
1119 }
1120
1121 // Test that we don't log RAPPOR metrics in the case heuristics and/or server
1122 // have no data.
1123 TEST_F(AutofillMetricsTest, Rappor_NoDataServerAndHeuristic_NoMetricsReported) {
1124 // Set up our form data.
1125 FormData form;
1126 form.name = ASCIIToUTF16("TestForm");
1127 form.origin = GURL("http://example.com/form.html");
1128 form.action = GURL("http://example.com/submit.html");
1129
1130 std::vector<ServerFieldType> heuristic_types, server_types;
1131 FormFieldData field;
1132
1133 test::CreateTestFormField("Autofilled", "autofilled", "Elvis Aaron Presley",
1134 "text", &field);
1135 field.is_autofilled = true;
1136 form.fields.push_back(field);
1137 heuristic_types.push_back(UNKNOWN_TYPE);
1138 server_types.push_back(NO_SERVER_DATA);
1139
1140 test::CreateTestFormField("Autofill Failed", "autofillfailed",
1141 "buddy@gmail.com", "text", &field);
1142 field.is_autofilled = false;
1143 form.fields.push_back(field);
1144 heuristic_types.push_back(UNKNOWN_TYPE);
1145 server_types.push_back(NO_SERVER_DATA);
1146
1147 test::CreateTestFormField("Phone", "phone", "2345678901", "tel", &field);
1148 field.is_autofilled = true;
1149 form.fields.push_back(field);
1150 heuristic_types.push_back(UNKNOWN_TYPE);
1151 server_types.push_back(NO_SERVER_DATA);
1152
1153 // Simulate having seen this form on page load.
1154 autofill_manager_->AddSeenForm(form, heuristic_types, server_types);
1155
1156 // Simulate form submission.
1157 autofill_manager_->SubmitForm(form, TimeTicks::Now());
1158
1159 // No RAPPOR metrics are logged in the case of multiple UNKNOWN_TYPE and
1160 // NO_SERVER_DATA for heuristics and server predictions, respectively.
1161 EXPECT_EQ(0, autofill_client_.test_rappor_service()->GetReportsCount());
1162 }
1163
1164 // Test that we log high number of mismatches for the server prediction.
1165 TEST_F(AutofillMetricsTest, Rappor_HighServerMismatchRate_MetricsReported) {
1166 // Set up our form data.
1167 FormData form;
1168 form.name = ASCIIToUTF16("TestForm");
1169 form.origin = GURL("http://example.com/form.html");
1170 form.action = GURL("http://example.com/submit.html");
1171
1172 std::vector<ServerFieldType> heuristic_types, server_types;
1173 FormFieldData field;
1174
1175 test::CreateTestFormField("Autofilled", "autofilled", "Elvis Aaron Presley",
1176 "text", &field);
1177 field.is_autofilled = true;
1178 form.fields.push_back(field);
1179 heuristic_types.push_back(NAME_FULL);
1180 server_types.push_back(NAME_FIRST);
1181
1182 test::CreateTestFormField("Autofill Failed", "autofillfailed",
1183 "buddy@gmail.com", "text", &field);
1184 field.is_autofilled = false;
1185 form.fields.push_back(field);
1186 heuristic_types.push_back(PHONE_HOME_NUMBER);
1187 server_types.push_back(NAME_LAST);
1188
1189 test::CreateTestFormField("Phone", "phone", "2345678901", "tel", &field);
1190 field.is_autofilled = true;
1191 form.fields.push_back(field);
1192 heuristic_types.push_back(PHONE_HOME_CITY_AND_NUMBER);
1193 server_types.push_back(EMAIL_ADDRESS);
1194
1195 // Simulate having seen this form on page load.
1196 autofill_manager_->AddSeenForm(form, heuristic_types, server_types);
1197
1198 // Simulate form submission.
1199 autofill_manager_->SubmitForm(form, TimeTicks::Now());
1200
1201 // The number of mismatches did trigger the RAPPOR metric logging for server
1202 // predictions.
1203 EXPECT_EQ(1, autofill_client_.test_rappor_service()->GetReportsCount());
1204 std::string sample;
1205 rappor::RapporType type;
1206 EXPECT_FALSE(
1207 autofill_client_.test_rappor_service()->GetRecordedSampleForMetric(
1208 "Autofill.HighNumberOfHeuristicMismatches", &sample, &type));
1209 EXPECT_TRUE(
1210 autofill_client_.test_rappor_service()->GetRecordedSampleForMetric(
1211 "Autofill.HighNumberOfServerMismatches", &sample, &type));
1212 EXPECT_EQ("example.com", sample);
1213 EXPECT_EQ(rappor::ETLD_PLUS_ONE_RAPPOR_TYPE, type);
1214 }
1215
1216 // Test that we log high number of mismatches for the heuristic predictions.
1217 TEST_F(AutofillMetricsTest, Rappor_HighHeuristicMismatchRate_MetricsReported) {
1218 // Set up our form data.
1219 FormData form;
1220 form.name = ASCIIToUTF16("TestForm");
1221 form.origin = GURL("http://example.com/form.html");
1222 form.action = GURL("http://example.com/submit.html");
1223
1224 std::vector<ServerFieldType> heuristic_types, server_types;
1225 FormFieldData field;
1226
1227 test::CreateTestFormField("Autofilled", "autofilled", "Elvis Aaron Presley",
1228 "text", &field);
1229 field.is_autofilled = true;
1230 form.fields.push_back(field);
1231 heuristic_types.push_back(NAME_FIRST);
1232 server_types.push_back(NAME_FULL);
1233
1234 test::CreateTestFormField("Autofill Failed", "autofillfailed",
1235 "buddy@gmail.com", "text", &field);
1236 field.is_autofilled = false;
1237 form.fields.push_back(field);
1238 heuristic_types.push_back(PHONE_HOME_NUMBER);
1239 server_types.push_back(NAME_LAST);
1240
1241 test::CreateTestFormField("Phone", "phone", "2345678901", "tel", &field);
1242 field.is_autofilled = true;
1243 form.fields.push_back(field);
1244 heuristic_types.push_back(EMAIL_ADDRESS);
1245 server_types.push_back(PHONE_HOME_WHOLE_NUMBER);
1246
1247 // Simulate having seen this form on page load.
1248 autofill_manager_->AddSeenForm(form, heuristic_types, server_types);
1249
1250 // Simulate form submission.
1251 autofill_manager_->SubmitForm(form, TimeTicks::Now());
1252
1253 // The number of mismatches did trigger the RAPPOR metric logging for
1254 // heuristic predictions.
1255 EXPECT_EQ(1, autofill_client_.test_rappor_service()->GetReportsCount());
1256 std::string sample;
1257 rappor::RapporType type;
1258 EXPECT_FALSE(
1259 autofill_client_.test_rappor_service()->GetRecordedSampleForMetric(
1260 "Autofill.HighNumberOfServerMismatches", &sample, &type));
1261 EXPECT_TRUE(
1262 autofill_client_.test_rappor_service()->GetRecordedSampleForMetric(
1263 "Autofill.HighNumberOfHeuristicMismatches", &sample, &type));
1264 EXPECT_EQ("example.com", sample);
1265 EXPECT_EQ(rappor::ETLD_PLUS_ONE_RAPPOR_TYPE, type);
1266 }
1267
1268 // Verify that when a field is annotated with the autocomplete attribute, its 1202 // Verify that when a field is annotated with the autocomplete attribute, its
1269 // predicted type is remembered when quality metrics are logged. 1203 // predicted type is remembered when quality metrics are logged.
1270 TEST_F(AutofillMetricsTest, PredictedMetricsWithAutocomplete) { 1204 TEST_F(AutofillMetricsTest, PredictedMetricsWithAutocomplete) {
1271 // Set up our form data. 1205 // Set up our form data.
1272 FormData form; 1206 FormData form;
1273 form.name = ASCIIToUTF16("TestForm"); 1207 form.name = ASCIIToUTF16("TestForm");
1274 form.origin = GURL("http://example.com/form.html"); 1208 form.origin = GURL("http://example.com/form.html");
1275 form.action = GURL("http://example.com/submit.html"); 1209 form.action = GURL("http://example.com/submit.html");
1276 1210
1277 FormFieldData field1; 1211 FormFieldData field1;
(...skipping 21 matching lines...) Expand all
1299 // (hence the values are not cleared in UpdateFromCache). The new values 1233 // (hence the values are not cleared in UpdateFromCache). The new values
1300 // match what is in the test profile. 1234 // match what is in the test profile.
1301 form.fields[1].value = base::ASCIIToUTF16("79401"); 1235 form.fields[1].value = base::ASCIIToUTF16("79401");
1302 form.fields[2].value = base::ASCIIToUTF16("2345678901"); 1236 form.fields[2].value = base::ASCIIToUTF16("2345678901");
1303 autofill_manager_->SubmitForm(form, TimeTicks::Now()); 1237 autofill_manager_->SubmitForm(form, TimeTicks::Now());
1304 1238
1305 // First verify that country was not predicted by client or server. 1239 // First verify that country was not predicted by client or server.
1306 histogram_tester.ExpectBucketCount( 1240 histogram_tester.ExpectBucketCount(
1307 "Autofill.Quality.ServerType.ByFieldType", 1241 "Autofill.Quality.ServerType.ByFieldType",
1308 GetFieldTypeGroupMetric(ADDRESS_HOME_COUNTRY, 1242 GetFieldTypeGroupMetric(ADDRESS_HOME_COUNTRY,
1309 AutofillMetrics::TYPE_UNKNOWN), 1243 AutofillMetrics::FALSE_NEGATIVE_UNKNOWN),
1310 1); 1244 1);
1311 histogram_tester.ExpectBucketCount( 1245 histogram_tester.ExpectBucketCount(
1312 "Autofill.Quality.HeuristicType.ByFieldType", 1246 "Autofill.Quality.HeuristicType.ByFieldType",
1313 GetFieldTypeGroupMetric(ADDRESS_HOME_COUNTRY, 1247 GetFieldTypeGroupMetric(ADDRESS_HOME_COUNTRY,
1314 AutofillMetrics::TYPE_UNKNOWN), 1248 AutofillMetrics::FALSE_NEGATIVE_UNKNOWN),
1315 1); 1249 1);
1316 // We expect a match for country because it had |autocomplete_attribute|. 1250 // We expect a match for country because it had |autocomplete_attribute|.
1317 histogram_tester.ExpectBucketCount( 1251 histogram_tester.ExpectBucketCount(
1318 "Autofill.Quality.PredictedType.ByFieldType", 1252 "Autofill.Quality.PredictedType.ByFieldType",
1319 GetFieldTypeGroupMetric(ADDRESS_HOME_COUNTRY, 1253 GetFieldTypeGroupMetric(ADDRESS_HOME_COUNTRY,
1320 AutofillMetrics::TYPE_MATCH), 1254 AutofillMetrics::TRUE_POSITIVE),
1321 1); 1255 1);
1322 1256
1323 // We did not predict zip code or phone number, because they did not have 1257 // We did not predict zip code or phone number, because they did not have
1324 // |autocomplete_attribute|, nor client or server predictions. 1258 // |autocomplete_attribute|, nor client or server predictions.
1325 histogram_tester.ExpectBucketCount( 1259 histogram_tester.ExpectBucketCount(
1326 "Autofill.Quality.ServerType.ByFieldType", 1260 "Autofill.Quality.ServerType.ByFieldType",
1327 GetFieldTypeGroupMetric(ADDRESS_HOME_ZIP, 1261 GetFieldTypeGroupMetric(ADDRESS_HOME_ZIP,
1328 AutofillMetrics::TYPE_UNKNOWN), 1262 AutofillMetrics::FALSE_NEGATIVE_UNKNOWN),
1329 1); 1263 1);
1330 histogram_tester.ExpectBucketCount( 1264 histogram_tester.ExpectBucketCount(
1331 "Autofill.Quality.HeuristicType.ByFieldType", 1265 "Autofill.Quality.HeuristicType.ByFieldType",
1332 GetFieldTypeGroupMetric(ADDRESS_HOME_ZIP, 1266 GetFieldTypeGroupMetric(ADDRESS_HOME_ZIP,
1333 AutofillMetrics::TYPE_UNKNOWN), 1267 AutofillMetrics::FALSE_NEGATIVE_UNKNOWN),
1334 1); 1268 1);
1335 histogram_tester.ExpectBucketCount( 1269 histogram_tester.ExpectBucketCount(
1336 "Autofill.Quality.PredictedType.ByFieldType", 1270 "Autofill.Quality.PredictedType.ByFieldType",
1337 GetFieldTypeGroupMetric(ADDRESS_HOME_ZIP, 1271 GetFieldTypeGroupMetric(ADDRESS_HOME_ZIP,
1338 AutofillMetrics::TYPE_UNKNOWN), 1272 AutofillMetrics::FALSE_NEGATIVE_UNKNOWN),
1339 1); 1273 1);
1340 histogram_tester.ExpectBucketCount( 1274 histogram_tester.ExpectBucketCount(
1341 "Autofill.Quality.ServerType.ByFieldType", 1275 "Autofill.Quality.ServerType.ByFieldType",
1342 GetFieldTypeGroupMetric(PHONE_HOME_WHOLE_NUMBER, 1276 GetFieldTypeGroupMetric(PHONE_HOME_WHOLE_NUMBER,
1343 AutofillMetrics::TYPE_UNKNOWN), 1277 AutofillMetrics::FALSE_NEGATIVE_UNKNOWN),
1344 1); 1278 1);
1345 histogram_tester.ExpectBucketCount( 1279 histogram_tester.ExpectBucketCount(
1346 "Autofill.Quality.HeuristicType.ByFieldType", 1280 "Autofill.Quality.HeuristicType.ByFieldType",
1347 GetFieldTypeGroupMetric(PHONE_HOME_WHOLE_NUMBER, 1281 GetFieldTypeGroupMetric(PHONE_HOME_WHOLE_NUMBER,
1348 AutofillMetrics::TYPE_UNKNOWN), 1282 AutofillMetrics::FALSE_NEGATIVE_UNKNOWN),
1349 1); 1283 1);
1350 histogram_tester.ExpectBucketCount( 1284 histogram_tester.ExpectBucketCount(
1351 "Autofill.Quality.PredictedType.ByFieldType", 1285 "Autofill.Quality.PredictedType.ByFieldType",
1352 GetFieldTypeGroupMetric(PHONE_HOME_WHOLE_NUMBER, 1286 GetFieldTypeGroupMetric(PHONE_HOME_WHOLE_NUMBER,
1353 AutofillMetrics::TYPE_UNKNOWN), 1287 AutofillMetrics::FALSE_NEGATIVE_UNKNOWN),
1354 1); 1288 1);
1355 1289
1356 // Sanity check. 1290 // Sanity check.
1357 histogram_tester.ExpectTotalCount("Autofill.Quality.PredictedType", 3); 1291 histogram_tester.ExpectTotalCount("Autofill.Quality.PredictedType", 3);
1358 } 1292 }
1359 } 1293 }
1360 1294
1361 // Test that we behave sanely when the cached form differs from the submitted 1295 // Test that we behave sanely when the cached form differs from the submitted
1362 // one. 1296 // one.
1363 TEST_F(AutofillMetricsTest, SaneMetricsWithCacheMismatch) { 1297 TEST_F(AutofillMetricsTest, SaneMetricsWithCacheMismatch) {
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
1410 form.fields.push_back(cached_fields[3]); 1344 form.fields.push_back(cached_fields[3]);
1411 form.fields.push_back(cached_fields[0]); 1345 form.fields.push_back(cached_fields[0]);
1412 1346
1413 // Simulate form submission. 1347 // Simulate form submission.
1414 base::HistogramTester histogram_tester; 1348 base::HistogramTester histogram_tester;
1415 autofill_manager_->SubmitForm(form, TimeTicks::Now()); 1349 autofill_manager_->SubmitForm(form, TimeTicks::Now());
1416 1350
1417 // Heuristic predictions. 1351 // Heuristic predictions.
1418 // Unknown: 1352 // Unknown:
1419 histogram_tester.ExpectBucketCount("Autofill.Quality.HeuristicType", 1353 histogram_tester.ExpectBucketCount("Autofill.Quality.HeuristicType",
1420 AutofillMetrics::TYPE_UNKNOWN, 1); 1354 AutofillMetrics::FALSE_NEGATIVE_UNKNOWN,
1355 1);
1421 histogram_tester.ExpectBucketCount( 1356 histogram_tester.ExpectBucketCount(
1422 "Autofill.Quality.HeuristicType.ByFieldType", 1357 "Autofill.Quality.HeuristicType.ByFieldType",
1423 GetFieldTypeGroupMetric(ADDRESS_HOME_STATE, 1358 GetFieldTypeGroupMetric(ADDRESS_HOME_STATE,
1424 AutofillMetrics::TYPE_UNKNOWN), 1359 AutofillMetrics::FALSE_NEGATIVE_UNKNOWN),
1425 1); 1360 1);
1426 // Match: 1361 // Match:
1427 histogram_tester.ExpectBucketCount("Autofill.Quality.HeuristicType", 1362 histogram_tester.ExpectBucketCount("Autofill.Quality.HeuristicType",
1428 AutofillMetrics::TYPE_MATCH, 2); 1363 AutofillMetrics::TRUE_POSITIVE, 2);
1429 histogram_tester.ExpectBucketCount( 1364 histogram_tester.ExpectBucketCount(
1430 "Autofill.Quality.HeuristicType.ByFieldType", 1365 "Autofill.Quality.HeuristicType.ByFieldType",
1431 GetFieldTypeGroupMetric(ADDRESS_HOME_CITY, AutofillMetrics::TYPE_MATCH), 1366 GetFieldTypeGroupMetric(ADDRESS_HOME_CITY,
1367 AutofillMetrics::TRUE_POSITIVE),
1432 1); 1368 1);
1433 histogram_tester.ExpectBucketCount( 1369 histogram_tester.ExpectBucketCount(
1434 "Autofill.Quality.HeuristicType.ByFieldType", 1370 "Autofill.Quality.HeuristicType.ByFieldType",
1435 GetFieldTypeGroupMetric(NAME_FULL, AutofillMetrics::TYPE_MATCH), 1); 1371 GetFieldTypeGroupMetric(NAME_FULL, AutofillMetrics::TRUE_POSITIVE), 1);
1436 // Mismatch: 1372 // Mismatch:
1437 histogram_tester.ExpectBucketCount("Autofill.Quality.HeuristicType", 1373 histogram_tester.ExpectBucketCount("Autofill.Quality.HeuristicType",
1438 AutofillMetrics::TYPE_MISMATCH, 1); 1374 AutofillMetrics::FALSE_NEGATIVE_MISMATCH,
1375 1);
1439 histogram_tester.ExpectBucketCount( 1376 histogram_tester.ExpectBucketCount(
1440 "Autofill.Quality.HeuristicType.ByFieldType", 1377 "Autofill.Quality.HeuristicType.ByFieldType",
1441 GetFieldTypeGroupMetric(EMAIL_ADDRESS, AutofillMetrics::TYPE_MISMATCH), 1378 GetFieldTypeGroupMetric(EMAIL_ADDRESS,
1379 AutofillMetrics::FALSE_NEGATIVE_MISMATCH),
1442 1); 1380 1);
1443 1381
1444 // Server predictions: 1382 // Server predictions:
1445 // Unknown: 1383 // Unknown:
1446 histogram_tester.ExpectBucketCount("Autofill.Quality.ServerType", 1384 histogram_tester.ExpectBucketCount("Autofill.Quality.ServerType",
1447 AutofillMetrics::TYPE_UNKNOWN, 1); 1385 AutofillMetrics::FALSE_NEGATIVE_UNKNOWN,
1386 1);
1448 histogram_tester.ExpectBucketCount( 1387 histogram_tester.ExpectBucketCount(
1449 "Autofill.Quality.ServerType.ByFieldType", 1388 "Autofill.Quality.ServerType.ByFieldType",
1450 GetFieldTypeGroupMetric(ADDRESS_HOME_STATE, 1389 GetFieldTypeGroupMetric(ADDRESS_HOME_STATE,
1451 AutofillMetrics::TYPE_UNKNOWN), 1390 AutofillMetrics::FALSE_NEGATIVE_UNKNOWN),
1452 1); 1391 1);
1453 // Match: 1392 // Match:
1454 histogram_tester.ExpectBucketCount("Autofill.Quality.ServerType", 1393 histogram_tester.ExpectBucketCount("Autofill.Quality.ServerType",
1455 AutofillMetrics::TYPE_MATCH, 1); 1394 AutofillMetrics::TRUE_POSITIVE, 1);
1456 histogram_tester.ExpectBucketCount( 1395 histogram_tester.ExpectBucketCount(
1457 "Autofill.Quality.ServerType.ByFieldType", 1396 "Autofill.Quality.ServerType.ByFieldType",
1458 GetFieldTypeGroupMetric(NAME_FULL, AutofillMetrics::TYPE_MATCH), 1); 1397 GetFieldTypeGroupMetric(NAME_FULL, AutofillMetrics::TRUE_POSITIVE), 1);
1459 // Mismatch: 1398 // Mismatch:
1460 histogram_tester.ExpectBucketCount("Autofill.Quality.ServerType", 1399 histogram_tester.ExpectBucketCount("Autofill.Quality.ServerType",
1461 AutofillMetrics::TYPE_MISMATCH, 2); 1400 AutofillMetrics::FALSE_NEGATIVE_MISMATCH,
1401 2);
1462 histogram_tester.ExpectBucketCount( 1402 histogram_tester.ExpectBucketCount(
1463 "Autofill.Quality.ServerType.ByFieldType", 1403 "Autofill.Quality.ServerType.ByFieldType",
1464 GetFieldTypeGroupMetric(ADDRESS_HOME_CITY, 1404 GetFieldTypeGroupMetric(ADDRESS_HOME_CITY,
1465 AutofillMetrics::TYPE_MISMATCH), 1405 AutofillMetrics::FALSE_NEGATIVE_MISMATCH),
1466 1); 1406 1);
1467 histogram_tester.ExpectBucketCount( 1407 histogram_tester.ExpectBucketCount(
1468 "Autofill.Quality.ServerType.ByFieldType", 1408 "Autofill.Quality.ServerType.ByFieldType",
1469 GetFieldTypeGroupMetric(EMAIL_ADDRESS, AutofillMetrics::TYPE_MISMATCH), 1409 GetFieldTypeGroupMetric(EMAIL_ADDRESS,
1410 AutofillMetrics::FALSE_NEGATIVE_MISMATCH),
1470 1); 1411 1);
1471 1412
1472 // Overall predictions: 1413 // Overall predictions:
1473 // Unknown: 1414 // Unknown:
1474 histogram_tester.ExpectBucketCount("Autofill.Quality.PredictedType", 1415 histogram_tester.ExpectBucketCount("Autofill.Quality.PredictedType",
1475 AutofillMetrics::TYPE_UNKNOWN, 1); 1416 AutofillMetrics::FALSE_NEGATIVE_UNKNOWN,
1417 1);
1476 histogram_tester.ExpectBucketCount( 1418 histogram_tester.ExpectBucketCount(
1477 "Autofill.Quality.PredictedType.ByFieldType", 1419 "Autofill.Quality.PredictedType.ByFieldType",
1478 GetFieldTypeGroupMetric(ADDRESS_HOME_STATE, 1420 GetFieldTypeGroupMetric(ADDRESS_HOME_STATE,
1479 AutofillMetrics::TYPE_UNKNOWN), 1421 AutofillMetrics::FALSE_NEGATIVE_UNKNOWN),
1480 1); 1422 1);
1481 // Match: 1423 // Match:
1482 histogram_tester.ExpectBucketCount("Autofill.Quality.PredictedType", 1424 histogram_tester.ExpectBucketCount("Autofill.Quality.PredictedType",
1483 AutofillMetrics::TYPE_MATCH, 1); 1425 AutofillMetrics::TRUE_POSITIVE, 1);
1484 histogram_tester.ExpectBucketCount( 1426 histogram_tester.ExpectBucketCount(
1485 "Autofill.Quality.PredictedType.ByFieldType", 1427 "Autofill.Quality.PredictedType.ByFieldType",
1486 GetFieldTypeGroupMetric(NAME_FULL, AutofillMetrics::TYPE_MATCH), 1); 1428 GetFieldTypeGroupMetric(NAME_FULL, AutofillMetrics::TRUE_POSITIVE), 1);
1487 // Mismatch: 1429 // Mismatch:
1488 histogram_tester.ExpectBucketCount("Autofill.Quality.PredictedType", 1430 histogram_tester.ExpectBucketCount("Autofill.Quality.PredictedType",
1489 AutofillMetrics::TYPE_MISMATCH, 2); 1431 AutofillMetrics::FALSE_NEGATIVE_MISMATCH,
1432 2);
1490 histogram_tester.ExpectBucketCount( 1433 histogram_tester.ExpectBucketCount(
1491 "Autofill.Quality.PredictedType.ByFieldType", 1434 "Autofill.Quality.PredictedType.ByFieldType",
1492 GetFieldTypeGroupMetric(ADDRESS_HOME_CITY, 1435 GetFieldTypeGroupMetric(ADDRESS_HOME_CITY,
1493 AutofillMetrics::TYPE_MISMATCH), 1436 AutofillMetrics::FALSE_NEGATIVE_MISMATCH),
1494 1); 1437 1);
1495 histogram_tester.ExpectBucketCount( 1438 histogram_tester.ExpectBucketCount(
1496 "Autofill.Quality.PredictedType.ByFieldType", 1439 "Autofill.Quality.PredictedType.ByFieldType",
1497 GetFieldTypeGroupMetric(EMAIL_ADDRESS, AutofillMetrics::TYPE_MISMATCH), 1440 GetFieldTypeGroupMetric(EMAIL_ADDRESS,
1441 AutofillMetrics::FALSE_NEGATIVE_MISMATCH),
1498 1); 1442 1);
1499 } 1443 }
1500 1444
1501 // Verify that when submitting an autofillable form, the stored profile metric 1445 // Verify that when submitting an autofillable form, the stored profile metric
1502 // is logged. 1446 // is logged.
1503 TEST_F(AutofillMetricsTest, StoredProfileCountAutofillableFormSubmission) { 1447 TEST_F(AutofillMetricsTest, StoredProfileCountAutofillableFormSubmission) {
1504 // Construct a fillable form. 1448 // Construct a fillable form.
1505 FormData form; 1449 FormData form;
1506 form.name = ASCIIToUTF16("TestForm"); 1450 form.name = ASCIIToUTF16("TestForm");
1507 form.origin = GURL("http://example.com/form.html"); 1451 form.origin = GURL("http://example.com/form.html");
(...skipping 3585 matching lines...) Expand 10 before | Expand all | Expand 10 after
5093 TEST_F(AutofillMetricsTest, RecordCardUploadDecisionMetric_NoUkmService) { 5037 TEST_F(AutofillMetricsTest, RecordCardUploadDecisionMetric_NoUkmService) {
5094 ukm::TestUkmRecorder test_ukm_recorder; 5038 ukm::TestUkmRecorder test_ukm_recorder;
5095 GURL url("https://www.google.com"); 5039 GURL url("https://www.google.com");
5096 std::vector<std::pair<const char*, int>> metrics = {{"metric", 1}}; 5040 std::vector<std::pair<const char*, int>> metrics = {{"metric", 1}};
5097 5041
5098 EXPECT_FALSE(AutofillMetrics::LogUkm(nullptr, url, "test_ukm", metrics)); 5042 EXPECT_FALSE(AutofillMetrics::LogUkm(nullptr, url, "test_ukm", metrics));
5099 ASSERT_EQ(0U, test_ukm_recorder.sources_count()); 5043 ASSERT_EQ(0U, test_ukm_recorder.sources_count());
5100 } 5044 }
5101 5045
5102 } // namespace autofill 5046 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698