| 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 <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 405 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 416 test::CreateTestFormField("Select", "select", "USA", "select-one", &field); | 416 test::CreateTestFormField("Select", "select", "USA", "select-one", &field); |
| 417 field.is_autofilled = false; | 417 field.is_autofilled = false; |
| 418 form.fields.push_back(field); | 418 form.fields.push_back(field); |
| 419 heuristic_types.push_back(UNKNOWN_TYPE); | 419 heuristic_types.push_back(UNKNOWN_TYPE); |
| 420 server_types.push_back(NO_SERVER_DATA); | 420 server_types.push_back(NO_SERVER_DATA); |
| 421 | 421 |
| 422 test::CreateTestFormField("Phone", "phone", "2345678901", "tel", &field); | 422 test::CreateTestFormField("Phone", "phone", "2345678901", "tel", &field); |
| 423 field.is_autofilled = true; | 423 field.is_autofilled = true; |
| 424 form.fields.push_back(field); | 424 form.fields.push_back(field); |
| 425 heuristic_types.push_back(PHONE_HOME_CITY_AND_NUMBER); | 425 heuristic_types.push_back(PHONE_HOME_CITY_AND_NUMBER); |
| 426 server_types.push_back(PHONE_HOME_WHOLE_NUMBER); | 426 server_types.push_back(PHONE_HOME_CITY_AND_NUMBER); |
| 427 | 427 |
| 428 // Simulate having seen this form on page load. | 428 // Simulate having seen this form on page load. |
| 429 autofill_manager_->AddSeenForm(form, heuristic_types, server_types); | 429 autofill_manager_->AddSeenForm(form, heuristic_types, server_types); |
| 430 | 430 |
| 431 // Simulate form submission. | 431 // Simulate form submission. |
| 432 base::HistogramTester histogram_tester; | 432 base::HistogramTester histogram_tester; |
| 433 autofill_manager_->SubmitForm(form, TimeTicks::Now()); | 433 autofill_manager_->SubmitForm(form, TimeTicks::Now()); |
| 434 | 434 |
| 435 // Heuristic predictions. | 435 // Heuristic predictions. |
| 436 // Unknown: | 436 // Unknown: |
| 437 histogram_tester.ExpectBucketCount("Autofill.Quality.HeuristicType", | 437 histogram_tester.ExpectBucketCount("Autofill.Quality.HeuristicType", |
| 438 AutofillMetrics::TYPE_UNKNOWN, 1); | 438 AutofillMetrics::TYPE_UNKNOWN, 1); |
| 439 histogram_tester.ExpectBucketCount( | 439 histogram_tester.ExpectBucketCount( |
| 440 "Autofill.Quality.HeuristicType.ByFieldType", | 440 "Autofill.Quality.HeuristicType.ByFieldType", |
| 441 GetFieldTypeGroupMetric(ADDRESS_HOME_COUNTRY, | 441 GetFieldTypeGroupMetric(ADDRESS_HOME_COUNTRY, |
| 442 AutofillMetrics::TYPE_UNKNOWN), | 442 AutofillMetrics::TYPE_UNKNOWN), |
| 443 1); | 443 1); |
| 444 // Match: | 444 // Match: |
| 445 histogram_tester.ExpectBucketCount("Autofill.Quality.HeuristicType", | 445 histogram_tester.ExpectBucketCount("Autofill.Quality.HeuristicType", |
| 446 AutofillMetrics::TYPE_MATCH, 2); | 446 AutofillMetrics::TYPE_MATCH, 2); |
| 447 histogram_tester.ExpectBucketCount( | 447 histogram_tester.ExpectBucketCount( |
| 448 "Autofill.Quality.HeuristicType.ByFieldType", | 448 "Autofill.Quality.HeuristicType.ByFieldType", |
| 449 GetFieldTypeGroupMetric(NAME_FULL, AutofillMetrics::TYPE_MATCH), 1); | 449 GetFieldTypeGroupMetric(NAME_FULL, AutofillMetrics::TYPE_MATCH), 1); |
| 450 histogram_tester.ExpectBucketCount( | 450 histogram_tester.ExpectBucketCount( |
| 451 "Autofill.Quality.HeuristicType.ByFieldType", | 451 "Autofill.Quality.HeuristicType.ByFieldType", |
| 452 GetFieldTypeGroupMetric(PHONE_HOME_WHOLE_NUMBER, | 452 GetFieldTypeGroupMetric(PHONE_HOME_CITY_AND_NUMBER, |
| 453 AutofillMetrics::TYPE_MATCH), | 453 AutofillMetrics::TYPE_MATCH), |
| 454 1); | 454 1); |
| 455 // Mismatch: | 455 // Mismatch: |
| 456 histogram_tester.ExpectBucketCount("Autofill.Quality.HeuristicType", | 456 histogram_tester.ExpectBucketCount("Autofill.Quality.HeuristicType", |
| 457 AutofillMetrics::TYPE_MISMATCH, 1); | 457 AutofillMetrics::TYPE_MISMATCH, 1); |
| 458 histogram_tester.ExpectBucketCount( | 458 histogram_tester.ExpectBucketCount( |
| 459 "Autofill.Quality.HeuristicType.ByFieldType", | 459 "Autofill.Quality.HeuristicType.ByFieldType", |
| 460 GetFieldTypeGroupMetric(EMAIL_ADDRESS, AutofillMetrics::TYPE_MISMATCH), | 460 GetFieldTypeGroupMetric(EMAIL_ADDRESS, AutofillMetrics::TYPE_MISMATCH), |
| 461 1); | 461 1); |
| 462 | 462 |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 556 test::CreateTestFormField("Select", "select", "USA", "select-one", &field); | 556 test::CreateTestFormField("Select", "select", "USA", "select-one", &field); |
| 557 field.is_autofilled = false; | 557 field.is_autofilled = false; |
| 558 form.fields.push_back(field); | 558 form.fields.push_back(field); |
| 559 heuristic_types.push_back(UNKNOWN_TYPE); | 559 heuristic_types.push_back(UNKNOWN_TYPE); |
| 560 server_types.push_back(NO_SERVER_DATA); | 560 server_types.push_back(NO_SERVER_DATA); |
| 561 | 561 |
| 562 test::CreateTestFormField("Phone", "phone", "2345678901", "tel", &field); | 562 test::CreateTestFormField("Phone", "phone", "2345678901", "tel", &field); |
| 563 field.is_autofilled = true; | 563 field.is_autofilled = true; |
| 564 form.fields.push_back(field); | 564 form.fields.push_back(field); |
| 565 heuristic_types.push_back(PHONE_HOME_CITY_AND_NUMBER); | 565 heuristic_types.push_back(PHONE_HOME_CITY_AND_NUMBER); |
| 566 server_types.push_back(PHONE_HOME_WHOLE_NUMBER); | 566 server_types.push_back(PHONE_HOME_CITY_AND_NUMBER); |
| 567 | 567 |
| 568 // Simulate having seen this form on page load. | 568 // Simulate having seen this form on page load. |
| 569 autofill_manager_->AddSeenForm(form, heuristic_types, server_types); | 569 autofill_manager_->AddSeenForm(form, heuristic_types, server_types); |
| 570 | 570 |
| 571 // Simulate text input on one of the fields. | 571 // Simulate text input on one of the fields. |
| 572 autofill_manager_->OnTextFieldDidChange(form, form.fields[0], TimeTicks()); | 572 autofill_manager_->OnTextFieldDidChange(form, form.fields[0], TimeTicks()); |
| 573 | 573 |
| 574 // Trigger a form upload and metrics by Resetting the manager. | 574 // Trigger a form upload and metrics by Resetting the manager. |
| 575 base::HistogramTester histogram_tester; | 575 base::HistogramTester histogram_tester; |
| 576 | 576 |
| (...skipping 2966 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3543 EXPECT_THAT( | 3543 EXPECT_THAT( |
| 3544 histogram_tester.GetAllSamples("Autofill.ServerResponseHasDataForForm"), | 3544 histogram_tester.GetAllSamples("Autofill.ServerResponseHasDataForForm"), |
| 3545 ElementsAre(Bucket(true, 2))); | 3545 ElementsAre(Bucket(true, 2))); |
| 3546 | 3546 |
| 3547 // No RAPPOR metrics are logged in the case there is at least some server data | 3547 // No RAPPOR metrics are logged in the case there is at least some server data |
| 3548 // available for all forms. | 3548 // available for all forms. |
| 3549 EXPECT_EQ(0, rappor_service_.GetReportsCount()); | 3549 EXPECT_EQ(0, rappor_service_.GetReportsCount()); |
| 3550 } | 3550 } |
| 3551 | 3551 |
| 3552 } // namespace autofill | 3552 } // namespace autofill |
| OLD | NEW |