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

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

Issue 2003563003: [Autofill] Quality metric based on autocomplete attributes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: histograms.xml Created 4 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
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 472746f32563893f1f42ada15b8ed472eb190e7b..6f37dbd693c76ad064f1b1e57b57cc0b5959cfa6 100644
--- a/components/autofill/core/browser/autofill_metrics_unittest.cc
+++ b/components/autofill/core/browser/autofill_metrics_unittest.cc
@@ -705,6 +705,120 @@ TEST_F(AutofillMetricsTest, QualityMetrics_NoSubmission) {
GetFieldTypeGroupMetric(NAME_FULL, AutofillMetrics::TYPE_MISMATCH), 1);
}
+// Test that we log quality metrics for heuristics and server predictions based
+// on autocomplete attributes present on the fields.
+TEST_F(AutofillMetricsTest, QualityMetrics_BasedOnAutocomplete) {
+ FormData form;
+ form.name = ASCIIToUTF16("MyForm");
+ form.origin = GURL("http://myform.com/form.html");
+ form.action = GURL("http://myform.com/submit.html");
+
+ FormFieldData field;
+ // Heuristic value will match with Autocomplete attribute.
+ test::CreateTestFormField("Last Name", "lastname", "", "text", &field);
+ field.autocomplete_attribute = "family-name";
+ form.fields.push_back(field);
+
+ // Heuristic value will NOT match with Autocomplete attribute.
+ test::CreateTestFormField("First Name", "firstname", "", "text", &field);
+ field.autocomplete_attribute = "additional-name";
+ form.fields.push_back(field);
+
+ // Heuristic value will be unknown.
+ test::CreateTestFormField("Garbage label", "garbage", "", "text", &field);
+ field.autocomplete_attribute = "postal-code";
+ form.fields.push_back(field);
+
+ // No autocomplete attribute. No metric logged.
+ test::CreateTestFormField("Address", "address", "", "text", &field);
+ field.autocomplete_attribute = "";
+ form.fields.push_back(field);
+
+ TestFormStructure* form_structure = new TestFormStructure(form);
+ form_structure->DetermineHeuristicTypes();
+ autofill_manager_->form_structures()->push_back(form_structure);
+
+ AutofillQueryResponseContents response;
+ // Server response will match with autocomplete.
+ response.add_field()->set_autofill_type(NAME_LAST);
+ // Server response will NOT match with autocomplete.
+ response.add_field()->set_autofill_type(NAME_FIRST);
+ // Server response will have no data.
+ response.add_field()->set_autofill_type(NO_SERVER_DATA);
+ // Not logged.
+ response.add_field()->set_autofill_type(NAME_MIDDLE);
+
+ std::string response_string;
+ ASSERT_TRUE(response.SerializeToString(&response_string));
+
+ std::vector<std::string> signatures;
+ signatures.push_back(form_structure->FormSignature());
+
+ base::HistogramTester histogram_tester;
+ autofill_manager_->OnLoadedServerPredictions(response_string, signatures);
+
+ // Verify that FormStructure::ParseQueryResponse was called (here and below).
+ histogram_tester.ExpectBucketCount("Autofill.ServerQueryResponse",
+ AutofillMetrics::QUERY_RESPONSE_RECEIVED,
+ 1);
+ histogram_tester.ExpectBucketCount("Autofill.ServerQueryResponse",
+ AutofillMetrics::QUERY_RESPONSE_PARSED, 1);
+
+ // Autocomplete-derived types are eventually what's inferred.
+ EXPECT_EQ(NAME_LAST, form_structure->field(0)->Type().GetStorableType());
+ EXPECT_EQ(NAME_MIDDLE, form_structure->field(1)->Type().GetStorableType());
+ EXPECT_EQ(ADDRESS_HOME_ZIP,
+ form_structure->field(2)->Type().GetStorableType());
+
+ // Heuristic predictions.
+ // Unknown:
+ histogram_tester.ExpectBucketCount(
+ "Autofill.Quality.HeuristicType.BasedOnAutocomplete",
+ AutofillMetrics::TYPE_UNKNOWN, 1);
+ histogram_tester.ExpectBucketCount(
+ "Autofill.Quality.HeuristicType.ByFieldType.BasedOnAutocomplete",
+ GetFieldTypeGroupMetric(ADDRESS_HOME_ZIP, AutofillMetrics::TYPE_UNKNOWN),
+ 1);
+ // Match:
+ histogram_tester.ExpectBucketCount(
+ "Autofill.Quality.HeuristicType.BasedOnAutocomplete",
+ AutofillMetrics::TYPE_MATCH, 1);
+ histogram_tester.ExpectBucketCount(
+ "Autofill.Quality.HeuristicType.ByFieldType.BasedOnAutocomplete",
+ GetFieldTypeGroupMetric(NAME_LAST, AutofillMetrics::TYPE_MATCH), 1);
+ // Mismatch:
+ histogram_tester.ExpectBucketCount(
+ "Autofill.Quality.HeuristicType.BasedOnAutocomplete",
+ AutofillMetrics::TYPE_MISMATCH, 1);
+ histogram_tester.ExpectBucketCount(
+ "Autofill.Quality.HeuristicType.ByFieldType.BasedOnAutocomplete",
+ GetFieldTypeGroupMetric(NAME_MIDDLE, AutofillMetrics::TYPE_MISMATCH), 1);
+
+ // Server predictions.
+ // Unknown:
+ histogram_tester.ExpectBucketCount(
+ "Autofill.Quality.ServerType.BasedOnAutocomplete",
+ AutofillMetrics::TYPE_UNKNOWN, 1);
+ histogram_tester.ExpectBucketCount(
+ "Autofill.Quality.ServerType.ByFieldType.BasedOnAutocomplete",
+ GetFieldTypeGroupMetric(ADDRESS_HOME_ZIP, AutofillMetrics::TYPE_UNKNOWN),
+ 1);
+ // Match:
+ histogram_tester.ExpectBucketCount(
+ "Autofill.Quality.ServerType.BasedOnAutocomplete",
+ AutofillMetrics::TYPE_MATCH, 1);
+ histogram_tester.ExpectBucketCount(
+ "Autofill.Quality.ServerType.ByFieldType.BasedOnAutocomplete",
+ GetFieldTypeGroupMetric(NAME_LAST, AutofillMetrics::TYPE_MATCH), 1);
+ // Mismatch:
+ histogram_tester.ExpectBucketCount(
+ "Autofill.Quality.ServerType.BasedOnAutocomplete",
+ AutofillMetrics::TYPE_MISMATCH, 1);
+ histogram_tester.ExpectBucketCount(
+ "Autofill.Quality.ServerType.ByFieldType.BasedOnAutocomplete",
+ GetFieldTypeGroupMetric(NAME_MIDDLE, AutofillMetrics::TYPE_MISMATCH), 1);
+}
+
// Test that we do not log RAPPOR metrics when the number of mismatches is not
// high enough.
TEST_F(AutofillMetricsTest, Rappor_LowMismatchRate_NoMetricsReported) {
« no previous file with comments | « components/autofill/core/browser/autofill_metrics.cc ('k') | components/autofill/core/browser/form_structure.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698