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 <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/prefs/pref_service.h" | 10 #include "base/prefs/pref_service.h" |
| (...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 355 "Autofill.Quality.PredictedType.ByFieldType", | 355 "Autofill.Quality.PredictedType.ByFieldType", |
| 356 GetFieldTypeGroupMetric(PHONE_HOME_WHOLE_NUMBER, | 356 GetFieldTypeGroupMetric(PHONE_HOME_WHOLE_NUMBER, |
| 357 AutofillMetrics::TYPE_MATCH), | 357 AutofillMetrics::TYPE_MATCH), |
| 358 1); | 358 1); |
| 359 // Mismatch: | 359 // Mismatch: |
| 360 histogram_tester.ExpectBucketCount("Autofill.Quality.PredictedType", | 360 histogram_tester.ExpectBucketCount("Autofill.Quality.PredictedType", |
| 361 AutofillMetrics::TYPE_MISMATCH, 1); | 361 AutofillMetrics::TYPE_MISMATCH, 1); |
| 362 histogram_tester.ExpectBucketCount( | 362 histogram_tester.ExpectBucketCount( |
| 363 "Autofill.Quality.PredictedType.ByFieldType", | 363 "Autofill.Quality.PredictedType.ByFieldType", |
| 364 GetFieldTypeGroupMetric(NAME_FULL, AutofillMetrics::TYPE_MISMATCH), 1); | 364 GetFieldTypeGroupMetric(NAME_FULL, AutofillMetrics::TYPE_MISMATCH), 1); |
| 365 | |
| 366 // An autofillable form was submitted, and number of stored profiles is | |
| 367 // logged. | |
| 368 histogram_tester.ExpectBucketCount( | |
| 369 "Autofill.StoredProfileCountAtAutofillableFormSubmission", 2, 1); | |
|
Ilya Sherman
2015/01/30 22:11:44
This isn't a quality metric. Please write a separ
Mathieu
2015/01/31 18:25:51
Done. Thanks, cleaner now.
| |
| 365 } | 370 } |
| 366 | 371 |
| 367 // Test that we behave sanely when the cached form differs from the submitted | 372 // Test that we behave sanely when the cached form differs from the submitted |
| 368 // one. | 373 // one. |
| 369 TEST_F(AutofillMetricsTest, SaneMetricsWithCacheMismatch) { | 374 TEST_F(AutofillMetricsTest, SaneMetricsWithCacheMismatch) { |
| 370 // Set up our form data. | 375 // Set up our form data. |
| 371 FormData form; | 376 FormData form; |
| 372 form.name = ASCIIToUTF16("TestForm"); | 377 form.name = ASCIIToUTF16("TestForm"); |
| 373 form.origin = GURL("http://example.com/form.html"); | 378 form.origin = GURL("http://example.com/form.html"); |
| 374 form.action = GURL("http://example.com/submit.html"); | 379 form.action = GURL("http://example.com/submit.html"); |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 498 "Autofill.Quality.PredictedType.ByFieldType", | 503 "Autofill.Quality.PredictedType.ByFieldType", |
| 499 GetFieldTypeGroupMetric(ADDRESS_HOME_CITY, | 504 GetFieldTypeGroupMetric(ADDRESS_HOME_CITY, |
| 500 AutofillMetrics::TYPE_MISMATCH), | 505 AutofillMetrics::TYPE_MISMATCH), |
| 501 1); | 506 1); |
| 502 histogram_tester.ExpectBucketCount( | 507 histogram_tester.ExpectBucketCount( |
| 503 "Autofill.Quality.PredictedType.ByFieldType", | 508 "Autofill.Quality.PredictedType.ByFieldType", |
| 504 GetFieldTypeGroupMetric(EMAIL_ADDRESS, AutofillMetrics::TYPE_MISMATCH), | 509 GetFieldTypeGroupMetric(EMAIL_ADDRESS, AutofillMetrics::TYPE_MISMATCH), |
| 505 1); | 510 1); |
| 506 } | 511 } |
| 507 | 512 |
| 513 // Verify that when submitting a non-autofillable form, the stored profile | |
| 514 // metric is not logged. | |
| 515 TEST_F(AutofillMetricsTest, StoredProfileCountNonAutofillableFormSubmission) { | |
| 516 // Construct a non-fillable form. | |
| 517 FormData form; | |
| 518 form.name = ASCIIToUTF16("TestForm"); | |
| 519 form.origin = GURL("http://example.com/form.html"); | |
| 520 form.action = GURL("http://example.com/submit.html"); | |
| 521 | |
| 522 // Two fields is not enough to make it an autofillable form. | |
| 523 FormFieldData field; | |
| 524 test::CreateTestFormField("Name", "name", "", "text", &field); | |
| 525 form.fields.push_back(field); | |
| 526 test::CreateTestFormField("Email", "email", "", "text", &field); | |
| 527 form.fields.push_back(field); | |
| 528 | |
| 529 // Simulate form submission. | |
| 530 base::HistogramTester histogram_tester; | |
| 531 autofill_manager_->FormSubmitted(form, TimeTicks::Now()); | |
| 532 | |
| 533 // A non-autofillable form was submitted, and number of stored profiles is NOT | |
| 534 // logged. | |
| 535 histogram_tester.ExpectTotalCount( | |
| 536 "Autofill.StoredProfileCountAtAutofillableFormSubmission", 0); | |
| 537 } | |
| 538 | |
| 508 // Verify that we correctly log metrics regarding developer engagement. | 539 // Verify that we correctly log metrics regarding developer engagement. |
| 509 TEST_F(AutofillMetricsTest, DeveloperEngagement) { | 540 TEST_F(AutofillMetricsTest, DeveloperEngagement) { |
| 510 // Start with a non-fillable form. | 541 // Start with a non-fillable form. |
| 511 FormData form; | 542 FormData form; |
| 512 form.name = ASCIIToUTF16("TestForm"); | 543 form.name = ASCIIToUTF16("TestForm"); |
| 513 form.origin = GURL("http://example.com/form.html"); | 544 form.origin = GURL("http://example.com/form.html"); |
| 514 form.action = GURL("http://example.com/submit.html"); | 545 form.action = GURL("http://example.com/submit.html"); |
| 515 | 546 |
| 516 FormFieldData field; | 547 FormFieldData field; |
| 517 test::CreateTestFormField("Name", "name", "", "text", &field); | 548 test::CreateTestFormField("Name", "name", "", "text", &field); |
| (...skipping 575 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1093 histogram_tester.ExpectTotalCount( | 1124 histogram_tester.ExpectTotalCount( |
| 1094 "Autofill.FillDuration.FromInteraction.WithAutofill", 0); | 1125 "Autofill.FillDuration.FromInteraction.WithAutofill", 0); |
| 1095 histogram_tester.ExpectTotalCount( | 1126 histogram_tester.ExpectTotalCount( |
| 1096 "Autofill.FillDuration.FromInteraction.WithoutAutofill", 0); | 1127 "Autofill.FillDuration.FromInteraction.WithoutAutofill", 0); |
| 1097 | 1128 |
| 1098 autofill_manager_->Reset(); | 1129 autofill_manager_->Reset(); |
| 1099 } | 1130 } |
| 1100 } | 1131 } |
| 1101 | 1132 |
| 1102 } // namespace autofill | 1133 } // namespace autofill |
| OLD | NEW |