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 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
222 for (size_t i = 0; i < empty_form.fields.size(); ++i) { | 222 for (size_t i = 0; i < empty_form.fields.size(); ++i) { |
223 empty_form.fields[i].value = base::string16(); | 223 empty_form.fields[i].value = base::string16(); |
224 } | 224 } |
225 | 225 |
226 // |form_structure| will be owned by |form_structures()|. | 226 // |form_structure| will be owned by |form_structures()|. |
227 TestFormStructure* form_structure = new TestFormStructure(empty_form); | 227 TestFormStructure* form_structure = new TestFormStructure(empty_form); |
228 form_structure->SetFieldTypes(heuristic_types, server_types); | 228 form_structure->SetFieldTypes(heuristic_types, server_types); |
229 form_structures()->push_back(form_structure); | 229 form_structures()->push_back(form_structure); |
230 } | 230 } |
231 | 231 |
| 232 // Calls AutofillManager::OnWillSubmitForm and waits for it to complete. |
232 void WillSubmitForm(const FormData& form, const TimeTicks& timestamp) { | 233 void WillSubmitForm(const FormData& form, const TimeTicks& timestamp) { |
233 run_loop_.reset(new base::RunLoop()); | 234 run_loop_.reset(new base::RunLoop()); |
234 if (!OnWillSubmitForm(form, timestamp)) | 235 if (!OnWillSubmitForm(form, timestamp)) |
235 return; | 236 return; |
236 | 237 |
237 // Wait for the asynchronous OnWillSubmitForm() call to complete. | 238 // Wait for the asynchronous OnWillSubmitForm() call to complete. |
238 run_loop_->Run(); | 239 run_loop_->Run(); |
239 } | 240 } |
240 | 241 |
| 242 // Calls both AutofillManager::OnWillSubmitForm and |
| 243 // AutofillManager::OnFormSubmitted. |
| 244 void SubmitForm(const FormData& form, const TimeTicks& timestamp) { |
| 245 WillSubmitForm(form, timestamp); |
| 246 OnFormSubmitted(form); |
| 247 } |
| 248 |
241 void UploadFormDataAsyncCallback( | 249 void UploadFormDataAsyncCallback( |
242 const FormStructure* submitted_form, | 250 const FormStructure* submitted_form, |
243 const base::TimeTicks& load_time, | 251 const base::TimeTicks& load_time, |
244 const base::TimeTicks& interaction_time, | 252 const base::TimeTicks& interaction_time, |
245 const base::TimeTicks& submission_time) override { | 253 const base::TimeTicks& submission_time) override { |
246 run_loop_->Quit(); | 254 run_loop_->Quit(); |
247 | 255 |
248 AutofillManager::UploadFormDataAsyncCallback(submitted_form, | 256 AutofillManager::UploadFormDataAsyncCallback(submitted_form, |
249 load_time, | 257 load_time, |
250 interaction_time, | 258 interaction_time, |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
370 field.is_autofilled = true; | 378 field.is_autofilled = true; |
371 form.fields.push_back(field); | 379 form.fields.push_back(field); |
372 heuristic_types.push_back(PHONE_HOME_CITY_AND_NUMBER); | 380 heuristic_types.push_back(PHONE_HOME_CITY_AND_NUMBER); |
373 server_types.push_back(PHONE_HOME_WHOLE_NUMBER); | 381 server_types.push_back(PHONE_HOME_WHOLE_NUMBER); |
374 | 382 |
375 // Simulate having seen this form on page load. | 383 // Simulate having seen this form on page load. |
376 autofill_manager_->AddSeenForm(form, heuristic_types, server_types); | 384 autofill_manager_->AddSeenForm(form, heuristic_types, server_types); |
377 | 385 |
378 // Simulate form submission. | 386 // Simulate form submission. |
379 base::HistogramTester histogram_tester; | 387 base::HistogramTester histogram_tester; |
380 autofill_manager_->WillSubmitForm(form, TimeTicks::Now()); | 388 autofill_manager_->SubmitForm(form, TimeTicks::Now()); |
381 | 389 |
382 // Heuristic predictions. | 390 // Heuristic predictions. |
383 // Unknown: | 391 // Unknown: |
384 histogram_tester.ExpectBucketCount("Autofill.Quality.HeuristicType", | 392 histogram_tester.ExpectBucketCount("Autofill.Quality.HeuristicType", |
385 AutofillMetrics::TYPE_UNKNOWN, 1); | 393 AutofillMetrics::TYPE_UNKNOWN, 1); |
386 histogram_tester.ExpectBucketCount( | 394 histogram_tester.ExpectBucketCount( |
387 "Autofill.Quality.HeuristicType.ByFieldType", | 395 "Autofill.Quality.HeuristicType.ByFieldType", |
388 GetFieldTypeGroupMetric(ADDRESS_HOME_COUNTRY, | 396 GetFieldTypeGroupMetric(ADDRESS_HOME_COUNTRY, |
389 AutofillMetrics::TYPE_UNKNOWN), | 397 AutofillMetrics::TYPE_UNKNOWN), |
390 1); | 398 1); |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
492 test::CreateTestFormField("Phone", "phone", "2345678901", "tel", &field); | 500 test::CreateTestFormField("Phone", "phone", "2345678901", "tel", &field); |
493 field.is_autofilled = true; | 501 field.is_autofilled = true; |
494 form.fields.push_back(field); | 502 form.fields.push_back(field); |
495 heuristic_types.push_back(PHONE_HOME_CITY_AND_NUMBER); | 503 heuristic_types.push_back(PHONE_HOME_CITY_AND_NUMBER); |
496 server_types.push_back(EMAIL_ADDRESS); | 504 server_types.push_back(EMAIL_ADDRESS); |
497 | 505 |
498 // Simulate having seen this form on page load. | 506 // Simulate having seen this form on page load. |
499 autofill_manager_->AddSeenForm(form, heuristic_types, server_types); | 507 autofill_manager_->AddSeenForm(form, heuristic_types, server_types); |
500 | 508 |
501 // Simulate form submission. | 509 // Simulate form submission. |
502 autofill_manager_->WillSubmitForm(form, TimeTicks::Now()); | 510 autofill_manager_->SubmitForm(form, TimeTicks::Now()); |
503 | 511 |
504 // The number of mismatches did not trigger the RAPPOR metric logging. | 512 // The number of mismatches did not trigger the RAPPOR metric logging. |
505 EXPECT_EQ(0, autofill_client_.test_rappor_service()->GetReportsCount()); | 513 EXPECT_EQ(0, autofill_client_.test_rappor_service()->GetReportsCount()); |
506 } | 514 } |
507 | 515 |
508 // Test that we don't log RAPPOR metrics in the case heuristics and/or server | 516 // Test that we don't log RAPPOR metrics in the case heuristics and/or server |
509 // have no data. | 517 // have no data. |
510 TEST_F(AutofillMetricsTest, Rappor_NoDataServerAndHeuristic_NoMetricsReported) { | 518 TEST_F(AutofillMetricsTest, Rappor_NoDataServerAndHeuristic_NoMetricsReported) { |
511 // Set up our form data. | 519 // Set up our form data. |
512 FormData form; | 520 FormData form; |
(...skipping 22 matching lines...) Expand all Loading... |
535 test::CreateTestFormField("Phone", "phone", "2345678901", "tel", &field); | 543 test::CreateTestFormField("Phone", "phone", "2345678901", "tel", &field); |
536 field.is_autofilled = true; | 544 field.is_autofilled = true; |
537 form.fields.push_back(field); | 545 form.fields.push_back(field); |
538 heuristic_types.push_back(UNKNOWN_TYPE); | 546 heuristic_types.push_back(UNKNOWN_TYPE); |
539 server_types.push_back(NO_SERVER_DATA); | 547 server_types.push_back(NO_SERVER_DATA); |
540 | 548 |
541 // Simulate having seen this form on page load. | 549 // Simulate having seen this form on page load. |
542 autofill_manager_->AddSeenForm(form, heuristic_types, server_types); | 550 autofill_manager_->AddSeenForm(form, heuristic_types, server_types); |
543 | 551 |
544 // Simulate form submission. | 552 // Simulate form submission. |
545 autofill_manager_->WillSubmitForm(form, TimeTicks::Now()); | 553 autofill_manager_->SubmitForm(form, TimeTicks::Now()); |
546 | 554 |
547 // No RAPPOR metrics are logged in the case of multiple UNKNOWN_TYPE and | 555 // No RAPPOR metrics are logged in the case of multiple UNKNOWN_TYPE and |
548 // NO_SERVER_DATA for heuristics and server predictions, respectively. | 556 // NO_SERVER_DATA for heuristics and server predictions, respectively. |
549 EXPECT_EQ(0, autofill_client_.test_rappor_service()->GetReportsCount()); | 557 EXPECT_EQ(0, autofill_client_.test_rappor_service()->GetReportsCount()); |
550 } | 558 } |
551 | 559 |
552 // Test that we log high number of mismatches for the server prediction. | 560 // Test that we log high number of mismatches for the server prediction. |
553 TEST_F(AutofillMetricsTest, Rappor_HighServerMismatchRate_MetricsReported) { | 561 TEST_F(AutofillMetricsTest, Rappor_HighServerMismatchRate_MetricsReported) { |
554 // Set up our form data. | 562 // Set up our form data. |
555 FormData form; | 563 FormData form; |
(...skipping 22 matching lines...) Expand all Loading... |
578 test::CreateTestFormField("Phone", "phone", "2345678901", "tel", &field); | 586 test::CreateTestFormField("Phone", "phone", "2345678901", "tel", &field); |
579 field.is_autofilled = true; | 587 field.is_autofilled = true; |
580 form.fields.push_back(field); | 588 form.fields.push_back(field); |
581 heuristic_types.push_back(PHONE_HOME_CITY_AND_NUMBER); | 589 heuristic_types.push_back(PHONE_HOME_CITY_AND_NUMBER); |
582 server_types.push_back(EMAIL_ADDRESS); | 590 server_types.push_back(EMAIL_ADDRESS); |
583 | 591 |
584 // Simulate having seen this form on page load. | 592 // Simulate having seen this form on page load. |
585 autofill_manager_->AddSeenForm(form, heuristic_types, server_types); | 593 autofill_manager_->AddSeenForm(form, heuristic_types, server_types); |
586 | 594 |
587 // Simulate form submission. | 595 // Simulate form submission. |
588 autofill_manager_->WillSubmitForm(form, TimeTicks::Now()); | 596 autofill_manager_->SubmitForm(form, TimeTicks::Now()); |
589 | 597 |
590 // The number of mismatches did trigger the RAPPOR metric logging for server | 598 // The number of mismatches did trigger the RAPPOR metric logging for server |
591 // predictions. | 599 // predictions. |
592 EXPECT_EQ(1, autofill_client_.test_rappor_service()->GetReportsCount()); | 600 EXPECT_EQ(1, autofill_client_.test_rappor_service()->GetReportsCount()); |
593 std::string sample; | 601 std::string sample; |
594 rappor::RapporType type; | 602 rappor::RapporType type; |
595 EXPECT_FALSE( | 603 EXPECT_FALSE( |
596 autofill_client_.test_rappor_service()->GetRecordedSampleForMetric( | 604 autofill_client_.test_rappor_service()->GetRecordedSampleForMetric( |
597 "Autofill.HighNumberOfHeuristicMismatches", &sample, &type)); | 605 "Autofill.HighNumberOfHeuristicMismatches", &sample, &type)); |
598 EXPECT_TRUE( | 606 EXPECT_TRUE( |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
631 test::CreateTestFormField("Phone", "phone", "2345678901", "tel", &field); | 639 test::CreateTestFormField("Phone", "phone", "2345678901", "tel", &field); |
632 field.is_autofilled = true; | 640 field.is_autofilled = true; |
633 form.fields.push_back(field); | 641 form.fields.push_back(field); |
634 heuristic_types.push_back(EMAIL_ADDRESS); | 642 heuristic_types.push_back(EMAIL_ADDRESS); |
635 server_types.push_back(PHONE_HOME_WHOLE_NUMBER); | 643 server_types.push_back(PHONE_HOME_WHOLE_NUMBER); |
636 | 644 |
637 // Simulate having seen this form on page load. | 645 // Simulate having seen this form on page load. |
638 autofill_manager_->AddSeenForm(form, heuristic_types, server_types); | 646 autofill_manager_->AddSeenForm(form, heuristic_types, server_types); |
639 | 647 |
640 // Simulate form submission. | 648 // Simulate form submission. |
641 autofill_manager_->WillSubmitForm(form, TimeTicks::Now()); | 649 autofill_manager_->SubmitForm(form, TimeTicks::Now()); |
642 | 650 |
643 // The number of mismatches did trigger the RAPPOR metric logging for | 651 // The number of mismatches did trigger the RAPPOR metric logging for |
644 // heuristic predictions. | 652 // heuristic predictions. |
645 EXPECT_EQ(1, autofill_client_.test_rappor_service()->GetReportsCount()); | 653 EXPECT_EQ(1, autofill_client_.test_rappor_service()->GetReportsCount()); |
646 std::string sample; | 654 std::string sample; |
647 rappor::RapporType type; | 655 rappor::RapporType type; |
648 EXPECT_FALSE( | 656 EXPECT_FALSE( |
649 autofill_client_.test_rappor_service()->GetRecordedSampleForMetric( | 657 autofill_client_.test_rappor_service()->GetRecordedSampleForMetric( |
650 "Autofill.HighNumberOfServerMismatches", &sample, &type)); | 658 "Autofill.HighNumberOfServerMismatches", &sample, &type)); |
651 EXPECT_TRUE( | 659 EXPECT_TRUE( |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
684 std::vector<FormData> forms(1, form); | 692 std::vector<FormData> forms(1, form); |
685 | 693 |
686 { | 694 { |
687 base::HistogramTester histogram_tester; | 695 base::HistogramTester histogram_tester; |
688 autofill_manager_->OnFormsSeen(forms, TimeTicks()); | 696 autofill_manager_->OnFormsSeen(forms, TimeTicks()); |
689 // We change the value of the text fields to change the default/seen values | 697 // We change the value of the text fields to change the default/seen values |
690 // (hence the values are not cleared in UpdateFromCache). The new values | 698 // (hence the values are not cleared in UpdateFromCache). The new values |
691 // match what is in the test profile. | 699 // match what is in the test profile. |
692 form.fields[1].value = base::ASCIIToUTF16("79401"); | 700 form.fields[1].value = base::ASCIIToUTF16("79401"); |
693 form.fields[2].value = base::ASCIIToUTF16("2345678901"); | 701 form.fields[2].value = base::ASCIIToUTF16("2345678901"); |
694 autofill_manager_->WillSubmitForm(form, TimeTicks::Now()); | 702 autofill_manager_->SubmitForm(form, TimeTicks::Now()); |
695 | 703 |
696 // First verify that country was not predicted by client or server. | 704 // First verify that country was not predicted by client or server. |
697 histogram_tester.ExpectBucketCount( | 705 histogram_tester.ExpectBucketCount( |
698 "Autofill.Quality.ServerType.ByFieldType", | 706 "Autofill.Quality.ServerType.ByFieldType", |
699 GetFieldTypeGroupMetric(ADDRESS_HOME_COUNTRY, | 707 GetFieldTypeGroupMetric(ADDRESS_HOME_COUNTRY, |
700 AutofillMetrics::TYPE_UNKNOWN), | 708 AutofillMetrics::TYPE_UNKNOWN), |
701 1); | 709 1); |
702 histogram_tester.ExpectBucketCount( | 710 histogram_tester.ExpectBucketCount( |
703 "Autofill.Quality.HeuristicType.ByFieldType", | 711 "Autofill.Quality.HeuristicType.ByFieldType", |
704 GetFieldTypeGroupMetric(ADDRESS_HOME_COUNTRY, | 712 GetFieldTypeGroupMetric(ADDRESS_HOME_COUNTRY, |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
797 test::CreateTestFormField( | 805 test::CreateTestFormField( |
798 "New field", "new field", "Tennessee", "text", &field); | 806 "New field", "new field", "Tennessee", "text", &field); |
799 form.fields.push_back(field); | 807 form.fields.push_back(field); |
800 form.fields.push_back(cached_fields[2]); | 808 form.fields.push_back(cached_fields[2]); |
801 form.fields.push_back(cached_fields[1]); | 809 form.fields.push_back(cached_fields[1]); |
802 form.fields.push_back(cached_fields[3]); | 810 form.fields.push_back(cached_fields[3]); |
803 form.fields.push_back(cached_fields[0]); | 811 form.fields.push_back(cached_fields[0]); |
804 | 812 |
805 // Simulate form submission. | 813 // Simulate form submission. |
806 base::HistogramTester histogram_tester; | 814 base::HistogramTester histogram_tester; |
807 autofill_manager_->WillSubmitForm(form, TimeTicks::Now()); | 815 autofill_manager_->SubmitForm(form, TimeTicks::Now()); |
808 | 816 |
809 // Heuristic predictions. | 817 // Heuristic predictions. |
810 // Unknown: | 818 // Unknown: |
811 histogram_tester.ExpectBucketCount("Autofill.Quality.HeuristicType", | 819 histogram_tester.ExpectBucketCount("Autofill.Quality.HeuristicType", |
812 AutofillMetrics::TYPE_UNKNOWN, 1); | 820 AutofillMetrics::TYPE_UNKNOWN, 1); |
813 histogram_tester.ExpectBucketCount( | 821 histogram_tester.ExpectBucketCount( |
814 "Autofill.Quality.HeuristicType.ByFieldType", | 822 "Autofill.Quality.HeuristicType.ByFieldType", |
815 GetFieldTypeGroupMetric(ADDRESS_HOME_STATE, | 823 GetFieldTypeGroupMetric(ADDRESS_HOME_STATE, |
816 AutofillMetrics::TYPE_UNKNOWN), | 824 AutofillMetrics::TYPE_UNKNOWN), |
817 1); | 825 1); |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
907 test::CreateTestFormField("Email", "email", "", "text", &field); | 915 test::CreateTestFormField("Email", "email", "", "text", &field); |
908 form.fields.push_back(field); | 916 form.fields.push_back(field); |
909 test::CreateTestFormField("Phone", "phone", "", "text", &field); | 917 test::CreateTestFormField("Phone", "phone", "", "text", &field); |
910 form.fields.push_back(field); | 918 form.fields.push_back(field); |
911 | 919 |
912 std::vector<FormData> forms(1, form); | 920 std::vector<FormData> forms(1, form); |
913 | 921 |
914 // Simulate form submission. | 922 // Simulate form submission. |
915 base::HistogramTester histogram_tester; | 923 base::HistogramTester histogram_tester; |
916 autofill_manager_->OnFormsSeen(forms, TimeTicks()); | 924 autofill_manager_->OnFormsSeen(forms, TimeTicks()); |
917 autofill_manager_->WillSubmitForm(form, TimeTicks::Now()); | 925 autofill_manager_->SubmitForm(form, TimeTicks::Now()); |
918 | 926 |
919 // An autofillable form was submitted, and the number of stored profiles is | 927 // An autofillable form was submitted, and the number of stored profiles is |
920 // logged. | 928 // logged. |
921 histogram_tester.ExpectUniqueSample( | 929 histogram_tester.ExpectUniqueSample( |
922 "Autofill.StoredProfileCountAtAutofillableFormSubmission", 2, 1); | 930 "Autofill.StoredProfileCountAtAutofillableFormSubmission", 2, 1); |
923 } | 931 } |
924 | 932 |
925 // Verify that when submitting a non-autofillable form, the stored profile | 933 // Verify that when submitting a non-autofillable form, the stored profile |
926 // metric is not logged. | 934 // metric is not logged. |
927 TEST_F(AutofillMetricsTest, StoredProfileCountNonAutofillableFormSubmission) { | 935 TEST_F(AutofillMetricsTest, StoredProfileCountNonAutofillableFormSubmission) { |
928 // Construct a non-fillable form. | 936 // Construct a non-fillable form. |
929 FormData form; | 937 FormData form; |
930 form.name = ASCIIToUTF16("TestForm"); | 938 form.name = ASCIIToUTF16("TestForm"); |
931 form.origin = GURL("http://example.com/form.html"); | 939 form.origin = GURL("http://example.com/form.html"); |
932 form.action = GURL("http://example.com/submit.html"); | 940 form.action = GURL("http://example.com/submit.html"); |
933 form.user_submitted = true; | 941 form.user_submitted = true; |
934 | 942 |
935 // Two fields is not enough to make it an autofillable form. | 943 // Two fields is not enough to make it an autofillable form. |
936 FormFieldData field; | 944 FormFieldData field; |
937 test::CreateTestFormField("Name", "name", "", "text", &field); | 945 test::CreateTestFormField("Name", "name", "", "text", &field); |
938 form.fields.push_back(field); | 946 form.fields.push_back(field); |
939 test::CreateTestFormField("Email", "email", "", "text", &field); | 947 test::CreateTestFormField("Email", "email", "", "text", &field); |
940 form.fields.push_back(field); | 948 form.fields.push_back(field); |
941 | 949 |
942 std::vector<FormData> forms(1, form); | 950 std::vector<FormData> forms(1, form); |
943 | 951 |
944 // Simulate form submission. | 952 // Simulate form submission. |
945 base::HistogramTester histogram_tester; | 953 base::HistogramTester histogram_tester; |
946 autofill_manager_->OnFormsSeen(forms, TimeTicks()); | 954 autofill_manager_->OnFormsSeen(forms, TimeTicks()); |
947 autofill_manager_->WillSubmitForm(form, TimeTicks::Now()); | 955 autofill_manager_->SubmitForm(form, TimeTicks::Now()); |
948 | 956 |
949 // A non-autofillable form was submitted, and number of stored profiles is NOT | 957 // A non-autofillable form was submitted, and number of stored profiles is NOT |
950 // logged. | 958 // logged. |
951 histogram_tester.ExpectTotalCount( | 959 histogram_tester.ExpectTotalCount( |
952 "Autofill.StoredProfileCountAtAutofillableFormSubmission", 0); | 960 "Autofill.StoredProfileCountAtAutofillableFormSubmission", 0); |
953 } | 961 } |
954 | 962 |
955 // Verify that we correctly log metrics regarding developer engagement. | 963 // Verify that we correctly log metrics regarding developer engagement. |
956 TEST_F(AutofillMetricsTest, DeveloperEngagement) { | 964 TEST_F(AutofillMetricsTest, DeveloperEngagement) { |
957 // Start with a non-fillable form. | 965 // Start with a non-fillable form. |
(...skipping 525 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1483 | 1491 |
1484 // Simulate having seen this form on page load. | 1492 // Simulate having seen this form on page load. |
1485 // |form_structure| will be owned by |autofill_manager_|. | 1493 // |form_structure| will be owned by |autofill_manager_|. |
1486 autofill_manager_->AddSeenForm(form, field_types, field_types); | 1494 autofill_manager_->AddSeenForm(form, field_types, field_types); |
1487 | 1495 |
1488 { | 1496 { |
1489 // Simulating submission with no filled data. | 1497 // Simulating submission with no filled data. |
1490 base::HistogramTester histogram_tester; | 1498 base::HistogramTester histogram_tester; |
1491 autofill_manager_->OnQueryFormFieldAutofill(0, form, field, gfx::Rect(), | 1499 autofill_manager_->OnQueryFormFieldAutofill(0, form, field, gfx::Rect(), |
1492 false); | 1500 false); |
1493 autofill_manager_->WillSubmitForm(form, TimeTicks::Now()); | 1501 autofill_manager_->SubmitForm(form, TimeTicks::Now()); |
| 1502 histogram_tester.ExpectBucketCount( |
| 1503 "Autofill.FormEvents.CreditCard", |
| 1504 AutofillMetrics::FORM_EVENT_WILL_SUBMIT_ONCE, 1); |
1494 histogram_tester.ExpectBucketCount( | 1505 histogram_tester.ExpectBucketCount( |
1495 "Autofill.FormEvents.CreditCard", | 1506 "Autofill.FormEvents.CreditCard", |
1496 AutofillMetrics::FORM_EVENT_NO_SUGGESTION_SUBMITTED_ONCE, 1); | 1507 AutofillMetrics::FORM_EVENT_NO_SUGGESTION_SUBMITTED_ONCE, 1); |
1497 } | 1508 } |
1498 | 1509 |
1499 // Reset the autofill manager state. | 1510 // Reset the autofill manager state. |
1500 autofill_manager_->Reset(); | 1511 autofill_manager_->Reset(); |
1501 autofill_manager_->AddSeenForm(form, field_types, field_types); | 1512 autofill_manager_->AddSeenForm(form, field_types, field_types); |
1502 | 1513 |
1503 { | 1514 { |
1504 // Simulating submission with filled local data. | 1515 // Simulating submission with filled local data. |
1505 base::HistogramTester histogram_tester; | 1516 base::HistogramTester histogram_tester; |
1506 autofill_manager_->OnQueryFormFieldAutofill(0, form, field, gfx::Rect(), | 1517 autofill_manager_->OnQueryFormFieldAutofill(0, form, field, gfx::Rect(), |
1507 false); | 1518 false); |
1508 SuggestionBackendID guid( | 1519 SuggestionBackendID guid( |
1509 "10000000-0000-0000-0000-000000000001", 0); // local card | 1520 "10000000-0000-0000-0000-000000000001", 0); // local card |
1510 autofill_manager_->FillOrPreviewForm( | 1521 autofill_manager_->FillOrPreviewForm( |
1511 AutofillDriver::FORM_DATA_ACTION_FILL, | 1522 AutofillDriver::FORM_DATA_ACTION_FILL, |
1512 0, form, form.fields.front(), | 1523 0, form, form.fields.front(), |
1513 autofill_manager_->MakeFrontendID(guid, SuggestionBackendID())); | 1524 autofill_manager_->MakeFrontendID(guid, SuggestionBackendID())); |
1514 autofill_manager_->WillSubmitForm(form, TimeTicks::Now()); | 1525 autofill_manager_->SubmitForm(form, TimeTicks::Now()); |
| 1526 histogram_tester.ExpectBucketCount( |
| 1527 "Autofill.FormEvents.CreditCard", |
| 1528 AutofillMetrics::FORM_EVENT_WILL_SUBMIT_ONCE, 1); |
1515 histogram_tester.ExpectBucketCount( | 1529 histogram_tester.ExpectBucketCount( |
1516 "Autofill.FormEvents.CreditCard", | 1530 "Autofill.FormEvents.CreditCard", |
1517 AutofillMetrics::FORM_EVENT_LOCAL_SUGGESTION_SUBMITTED_ONCE, 1); | 1531 AutofillMetrics::FORM_EVENT_LOCAL_SUGGESTION_SUBMITTED_ONCE, 1); |
1518 } | 1532 } |
1519 | 1533 |
1520 // Reset the autofill manager state. | 1534 // Reset the autofill manager state. |
1521 autofill_manager_->Reset(); | 1535 autofill_manager_->Reset(); |
1522 autofill_manager_->AddSeenForm(form, field_types, field_types); | 1536 autofill_manager_->AddSeenForm(form, field_types, field_types); |
1523 | 1537 |
1524 { | 1538 { |
1525 // Simulating submission with filled server data. | 1539 // Simulating submission with filled server data. |
1526 base::HistogramTester histogram_tester; | 1540 base::HistogramTester histogram_tester; |
1527 autofill_manager_->OnQueryFormFieldAutofill(0, form, field, gfx::Rect(), | 1541 autofill_manager_->OnQueryFormFieldAutofill(0, form, field, gfx::Rect(), |
1528 false); | 1542 false); |
1529 SuggestionBackendID guid( | 1543 SuggestionBackendID guid( |
1530 "10000000-0000-0000-0000-000000000003", 0); // full server card | 1544 "10000000-0000-0000-0000-000000000003", 0); // full server card |
1531 autofill_manager_->FillOrPreviewForm( | 1545 autofill_manager_->FillOrPreviewForm( |
1532 AutofillDriver::FORM_DATA_ACTION_FILL, | 1546 AutofillDriver::FORM_DATA_ACTION_FILL, |
1533 0, form, form.fields.front(), | 1547 0, form, form.fields.front(), |
1534 autofill_manager_->MakeFrontendID(guid, SuggestionBackendID())); | 1548 autofill_manager_->MakeFrontendID(guid, SuggestionBackendID())); |
1535 autofill_manager_->WillSubmitForm(form, TimeTicks::Now()); | 1549 autofill_manager_->SubmitForm(form, TimeTicks::Now()); |
| 1550 histogram_tester.ExpectBucketCount( |
| 1551 "Autofill.FormEvents.CreditCard", |
| 1552 AutofillMetrics::FORM_EVENT_WILL_SUBMIT_ONCE, 1); |
1536 histogram_tester.ExpectBucketCount( | 1553 histogram_tester.ExpectBucketCount( |
1537 "Autofill.FormEvents.CreditCard", | 1554 "Autofill.FormEvents.CreditCard", |
1538 AutofillMetrics::FORM_EVENT_SERVER_SUGGESTION_SUBMITTED_ONCE, 1); | 1555 AutofillMetrics::FORM_EVENT_SERVER_SUGGESTION_SUBMITTED_ONCE, 1); |
1539 } | 1556 } |
1540 | 1557 |
1541 // Reset the autofill manager state. | 1558 // Reset the autofill manager state. |
1542 autofill_manager_->Reset(); | 1559 autofill_manager_->Reset(); |
1543 autofill_manager_->AddSeenForm(form, field_types, field_types); | 1560 autofill_manager_->AddSeenForm(form, field_types, field_types); |
1544 | 1561 |
1545 { | 1562 { |
(...skipping 25 matching lines...) Expand all Loading... |
1571 | 1588 |
1572 // Reset the autofill manager state. | 1589 // Reset the autofill manager state. |
1573 autofill_manager_->Reset(); | 1590 autofill_manager_->Reset(); |
1574 autofill_manager_->AddSeenForm(form, field_types, field_types); | 1591 autofill_manager_->AddSeenForm(form, field_types, field_types); |
1575 | 1592 |
1576 { | 1593 { |
1577 // Simulating multiple submissions. | 1594 // Simulating multiple submissions. |
1578 base::HistogramTester histogram_tester; | 1595 base::HistogramTester histogram_tester; |
1579 autofill_manager_->OnQueryFormFieldAutofill(0, form, field, gfx::Rect(), | 1596 autofill_manager_->OnQueryFormFieldAutofill(0, form, field, gfx::Rect(), |
1580 false); | 1597 false); |
| 1598 autofill_manager_->SubmitForm(form, TimeTicks::Now()); |
| 1599 autofill_manager_->SubmitForm(form, TimeTicks::Now()); |
| 1600 histogram_tester.ExpectBucketCount( |
| 1601 "Autofill.FormEvents.CreditCard", |
| 1602 AutofillMetrics::FORM_EVENT_WILL_SUBMIT_ONCE, 1); |
| 1603 histogram_tester.ExpectBucketCount( |
| 1604 "Autofill.FormEvents.CreditCard", |
| 1605 AutofillMetrics::FORM_EVENT_NO_SUGGESTION_SUBMITTED_ONCE, 1); |
| 1606 histogram_tester.ExpectBucketCount( |
| 1607 "Autofill.FormEvents.CreditCard", |
| 1608 AutofillMetrics::FORM_EVENT_LOCAL_SUGGESTION_SUBMITTED_ONCE, 0); |
| 1609 histogram_tester.ExpectBucketCount( |
| 1610 "Autofill.FormEvents.CreditCard", |
| 1611 AutofillMetrics::FORM_EVENT_SERVER_SUGGESTION_SUBMITTED_ONCE, 0); |
| 1612 histogram_tester.ExpectBucketCount( |
| 1613 "Autofill.FormEvents.CreditCard", |
| 1614 AutofillMetrics:: |
| 1615 FORM_EVENT_MASKED_SERVER_CARD_SUGGESTION_SUBMITTED_ONCE, |
| 1616 0); |
| 1617 } |
| 1618 |
| 1619 // Reset the autofill manager state. |
| 1620 autofill_manager_->Reset(); |
| 1621 autofill_manager_->AddSeenForm(form, field_types, field_types); |
| 1622 |
| 1623 { |
| 1624 // Simulating submission without previous interaction. |
| 1625 base::HistogramTester histogram_tester; |
| 1626 autofill_manager_->SubmitForm(form, TimeTicks::Now()); |
| 1627 histogram_tester.ExpectBucketCount( |
| 1628 "Autofill.FormEvents.CreditCard", |
| 1629 AutofillMetrics::FORM_EVENT_WILL_SUBMIT_ONCE, 0); |
| 1630 histogram_tester.ExpectBucketCount( |
| 1631 "Autofill.FormEvents.CreditCard", |
| 1632 AutofillMetrics::FORM_EVENT_NO_SUGGESTION_SUBMITTED_ONCE, 0); |
| 1633 histogram_tester.ExpectBucketCount( |
| 1634 "Autofill.FormEvents.CreditCard", |
| 1635 AutofillMetrics::FORM_EVENT_SERVER_SUGGESTION_SUBMITTED_ONCE, 0); |
| 1636 histogram_tester.ExpectBucketCount( |
| 1637 "Autofill.FormEvents.CreditCard", |
| 1638 AutofillMetrics::FORM_EVENT_SERVER_SUGGESTION_SUBMITTED_ONCE, 0); |
| 1639 } |
| 1640 } |
| 1641 |
| 1642 // Test that we log "will submit" (but not submitted) form events for credit |
| 1643 // cards. Mirrors CreditCardSubmittedFormEvents test but does not expect any |
| 1644 // "submitted" metrics. |
| 1645 TEST_F(AutofillMetricsTest, CreditCardWillSubmitFormEvents) { |
| 1646 EnableWalletSync(); |
| 1647 // Creating all kinds of cards. |
| 1648 personal_data_->RecreateCreditCards( |
| 1649 true /* include_local_credit_card */, |
| 1650 true /* include_masked_server_credit_card */, |
| 1651 true /* include_full_server_credit_card */); |
| 1652 // Set up our form data. |
| 1653 FormData form; |
| 1654 form.name = ASCIIToUTF16("TestForm"); |
| 1655 form.origin = GURL("http://example.com/form.html"); |
| 1656 form.action = GURL("http://example.com/submit.html"); |
| 1657 form.user_submitted = true; |
| 1658 |
| 1659 FormFieldData field; |
| 1660 std::vector<ServerFieldType> field_types; |
| 1661 test::CreateTestFormField("Month", "card_month", "", "text", &field); |
| 1662 form.fields.push_back(field); |
| 1663 field_types.push_back(CREDIT_CARD_EXP_MONTH); |
| 1664 test::CreateTestFormField("Year", "card_year", "", "text", &field); |
| 1665 form.fields.push_back(field); |
| 1666 field_types.push_back(CREDIT_CARD_EXP_2_DIGIT_YEAR); |
| 1667 test::CreateTestFormField("Credit card", "card", "", "text", &field); |
| 1668 form.fields.push_back(field); |
| 1669 field_types.push_back(CREDIT_CARD_NUMBER); |
| 1670 |
| 1671 // Simulate having seen this form on page load. |
| 1672 // |form_structure| will be owned by |autofill_manager_|. |
| 1673 autofill_manager_->AddSeenForm(form, field_types, field_types); |
| 1674 |
| 1675 { |
| 1676 // Simulating submission with no filled data. |
| 1677 base::HistogramTester histogram_tester; |
| 1678 autofill_manager_->OnQueryFormFieldAutofill(0, form, field, gfx::Rect(), |
| 1679 false); |
| 1680 autofill_manager_->WillSubmitForm(form, TimeTicks::Now()); |
| 1681 histogram_tester.ExpectBucketCount( |
| 1682 "Autofill.FormEvents.CreditCard", |
| 1683 AutofillMetrics::FORM_EVENT_WILL_SUBMIT_ONCE, 1); |
| 1684 histogram_tester.ExpectBucketCount( |
| 1685 "Autofill.FormEvents.CreditCard", |
| 1686 AutofillMetrics::FORM_EVENT_NO_SUGGESTION_SUBMITTED_ONCE, 0); |
| 1687 } |
| 1688 |
| 1689 // Reset the autofill manager state. |
| 1690 autofill_manager_->Reset(); |
| 1691 autofill_manager_->AddSeenForm(form, field_types, field_types); |
| 1692 |
| 1693 { |
| 1694 // Simulating submission with filled local data. |
| 1695 base::HistogramTester histogram_tester; |
| 1696 autofill_manager_->OnQueryFormFieldAutofill(0, form, field, gfx::Rect(), |
| 1697 false); |
| 1698 SuggestionBackendID guid("10000000-0000-0000-0000-000000000001", |
| 1699 0); // local card |
| 1700 autofill_manager_->FillOrPreviewForm( |
| 1701 AutofillDriver::FORM_DATA_ACTION_FILL, 0, form, form.fields.front(), |
| 1702 autofill_manager_->MakeFrontendID(guid, SuggestionBackendID())); |
| 1703 autofill_manager_->WillSubmitForm(form, TimeTicks::Now()); |
| 1704 histogram_tester.ExpectBucketCount( |
| 1705 "Autofill.FormEvents.CreditCard", |
| 1706 AutofillMetrics::FORM_EVENT_WILL_SUBMIT_ONCE, 1); |
| 1707 histogram_tester.ExpectBucketCount( |
| 1708 "Autofill.FormEvents.CreditCard", |
| 1709 AutofillMetrics::FORM_EVENT_LOCAL_SUGGESTION_SUBMITTED_ONCE, 0); |
| 1710 } |
| 1711 |
| 1712 // Reset the autofill manager state. |
| 1713 autofill_manager_->Reset(); |
| 1714 autofill_manager_->AddSeenForm(form, field_types, field_types); |
| 1715 |
| 1716 { |
| 1717 // Simulating submission with filled server data. |
| 1718 base::HistogramTester histogram_tester; |
| 1719 autofill_manager_->OnQueryFormFieldAutofill(0, form, field, gfx::Rect(), |
| 1720 false); |
| 1721 SuggestionBackendID guid("10000000-0000-0000-0000-000000000003", |
| 1722 0); // full server card |
| 1723 autofill_manager_->FillOrPreviewForm( |
| 1724 AutofillDriver::FORM_DATA_ACTION_FILL, 0, form, form.fields.front(), |
| 1725 autofill_manager_->MakeFrontendID(guid, SuggestionBackendID())); |
| 1726 autofill_manager_->WillSubmitForm(form, TimeTicks::Now()); |
| 1727 histogram_tester.ExpectBucketCount( |
| 1728 "Autofill.FormEvents.CreditCard", |
| 1729 AutofillMetrics::FORM_EVENT_WILL_SUBMIT_ONCE, 1); |
| 1730 histogram_tester.ExpectBucketCount( |
| 1731 "Autofill.FormEvents.CreditCard", |
| 1732 AutofillMetrics::FORM_EVENT_SERVER_SUGGESTION_SUBMITTED_ONCE, 0); |
| 1733 } |
| 1734 |
| 1735 // Reset the autofill manager state. |
| 1736 autofill_manager_->Reset(); |
| 1737 autofill_manager_->AddSeenForm(form, field_types, field_types); |
| 1738 |
| 1739 { |
| 1740 // Simulating submission with a masked card server suggestion. |
| 1741 base::HistogramTester histogram_tester; |
| 1742 SuggestionBackendID guid("10000000-0000-0000-0000-000000000002", |
| 1743 0); // masked server card |
| 1744 autofill_manager_->FillOrPreviewForm( |
| 1745 AutofillDriver::FORM_DATA_ACTION_FILL, 0, form, form.fields.front(), |
| 1746 autofill_manager_->MakeFrontendID(guid, SuggestionBackendID())); |
| 1747 autofill_manager_->OnDidGetRealPan(AutofillClient::SUCCESS, |
| 1748 "6011000990139424"); |
| 1749 histogram_tester.ExpectBucketCount( |
| 1750 "Autofill.FormEvents.CreditCard", |
| 1751 AutofillMetrics::FORM_EVENT_MASKED_SERVER_CARD_SUGGESTION_FILLED, 1); |
| 1752 histogram_tester.ExpectBucketCount( |
| 1753 "Autofill.FormEvents.CreditCard", |
| 1754 AutofillMetrics::FORM_EVENT_MASKED_SERVER_CARD_SUGGESTION_FILLED_ONCE, |
| 1755 1); |
| 1756 } |
| 1757 |
| 1758 // Recreating cards as the previous test should have upgraded the masked |
| 1759 // card to a full card. |
| 1760 personal_data_->RecreateCreditCards( |
| 1761 true /* include_local_credit_card */, |
| 1762 true /* include_masked_server_credit_card */, |
| 1763 true /* include_full_server_credit_card */); |
| 1764 |
| 1765 // Reset the autofill manager state. |
| 1766 autofill_manager_->Reset(); |
| 1767 autofill_manager_->AddSeenForm(form, field_types, field_types); |
| 1768 |
| 1769 { |
| 1770 // Simulating multiple submissions. |
| 1771 base::HistogramTester histogram_tester; |
| 1772 autofill_manager_->OnQueryFormFieldAutofill(0, form, field, gfx::Rect(), |
| 1773 false); |
1581 autofill_manager_->WillSubmitForm(form, TimeTicks::Now()); | 1774 autofill_manager_->WillSubmitForm(form, TimeTicks::Now()); |
1582 autofill_manager_->WillSubmitForm(form, TimeTicks::Now()); | 1775 autofill_manager_->WillSubmitForm(form, TimeTicks::Now()); |
1583 histogram_tester.ExpectBucketCount( | 1776 histogram_tester.ExpectBucketCount( |
1584 "Autofill.FormEvents.CreditCard", | 1777 "Autofill.FormEvents.CreditCard", |
1585 AutofillMetrics::FORM_EVENT_NO_SUGGESTION_SUBMITTED_ONCE, 1); | 1778 AutofillMetrics::FORM_EVENT_WILL_SUBMIT_ONCE, 1); |
| 1779 histogram_tester.ExpectBucketCount( |
| 1780 "Autofill.FormEvents.CreditCard", |
| 1781 AutofillMetrics::FORM_EVENT_NO_SUGGESTION_SUBMITTED_ONCE, 0); |
1586 histogram_tester.ExpectBucketCount( | 1782 histogram_tester.ExpectBucketCount( |
1587 "Autofill.FormEvents.CreditCard", | 1783 "Autofill.FormEvents.CreditCard", |
1588 AutofillMetrics::FORM_EVENT_LOCAL_SUGGESTION_SUBMITTED_ONCE, 0); | 1784 AutofillMetrics::FORM_EVENT_LOCAL_SUGGESTION_SUBMITTED_ONCE, 0); |
1589 histogram_tester.ExpectBucketCount( | 1785 histogram_tester.ExpectBucketCount( |
1590 "Autofill.FormEvents.CreditCard", | 1786 "Autofill.FormEvents.CreditCard", |
1591 AutofillMetrics::FORM_EVENT_SERVER_SUGGESTION_SUBMITTED_ONCE, 0); | 1787 AutofillMetrics::FORM_EVENT_SERVER_SUGGESTION_SUBMITTED_ONCE, 0); |
1592 histogram_tester.ExpectBucketCount( | 1788 histogram_tester.ExpectBucketCount( |
1593 "Autofill.FormEvents.CreditCard", | 1789 "Autofill.FormEvents.CreditCard", |
1594 AutofillMetrics | 1790 AutofillMetrics |
1595 ::FORM_EVENT_MASKED_SERVER_CARD_SUGGESTION_SUBMITTED_ONCE, | 1791 ::FORM_EVENT_MASKED_SERVER_CARD_SUGGESTION_SUBMITTED_ONCE, |
1596 0); | 1792 0); |
1597 } | 1793 } |
1598 | 1794 |
1599 // Reset the autofill manager state. | 1795 // Reset the autofill manager state. |
1600 autofill_manager_->Reset(); | 1796 autofill_manager_->Reset(); |
1601 autofill_manager_->AddSeenForm(form, field_types, field_types); | 1797 autofill_manager_->AddSeenForm(form, field_types, field_types); |
1602 | 1798 |
1603 { | 1799 { |
1604 // Simulating submission without previous interaction. | 1800 // Simulating submission without previous interaction. |
1605 base::HistogramTester histogram_tester; | 1801 base::HistogramTester histogram_tester; |
1606 autofill_manager_->WillSubmitForm(form, TimeTicks::Now()); | 1802 autofill_manager_->WillSubmitForm(form, TimeTicks::Now()); |
1607 histogram_tester.ExpectBucketCount( | 1803 histogram_tester.ExpectBucketCount( |
1608 "Autofill.FormEvents.CreditCard", | 1804 "Autofill.FormEvents.CreditCard", |
| 1805 AutofillMetrics::FORM_EVENT_WILL_SUBMIT_ONCE, 0); |
| 1806 histogram_tester.ExpectBucketCount( |
| 1807 "Autofill.FormEvents.CreditCard", |
1609 AutofillMetrics::FORM_EVENT_NO_SUGGESTION_SUBMITTED_ONCE, 0); | 1808 AutofillMetrics::FORM_EVENT_NO_SUGGESTION_SUBMITTED_ONCE, 0); |
1610 histogram_tester.ExpectBucketCount( | 1809 histogram_tester.ExpectBucketCount( |
1611 "Autofill.FormEvents.CreditCard", | 1810 "Autofill.FormEvents.CreditCard", |
1612 AutofillMetrics::FORM_EVENT_SERVER_SUGGESTION_SUBMITTED_ONCE, 0); | 1811 AutofillMetrics::FORM_EVENT_SERVER_SUGGESTION_SUBMITTED_ONCE, 0); |
1613 histogram_tester.ExpectBucketCount( | 1812 histogram_tester.ExpectBucketCount( |
1614 "Autofill.FormEvents.CreditCard", | 1813 "Autofill.FormEvents.CreditCard", |
1615 AutofillMetrics::FORM_EVENT_SERVER_SUGGESTION_SUBMITTED_ONCE, 0); | 1814 AutofillMetrics::FORM_EVENT_SERVER_SUGGESTION_SUBMITTED_ONCE, 0); |
1616 } | 1815 } |
1617 } | 1816 } |
1618 | 1817 |
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1864 | 2063 |
1865 // Simulate having seen this form on page load. | 2064 // Simulate having seen this form on page load. |
1866 // |form_structure| will be owned by |autofill_manager_|. | 2065 // |form_structure| will be owned by |autofill_manager_|. |
1867 autofill_manager_->AddSeenForm(form, field_types, field_types); | 2066 autofill_manager_->AddSeenForm(form, field_types, field_types); |
1868 | 2067 |
1869 { | 2068 { |
1870 // Simulating submission with no filled data. | 2069 // Simulating submission with no filled data. |
1871 base::HistogramTester histogram_tester; | 2070 base::HistogramTester histogram_tester; |
1872 autofill_manager_->OnQueryFormFieldAutofill(0, form, field, gfx::Rect(), | 2071 autofill_manager_->OnQueryFormFieldAutofill(0, form, field, gfx::Rect(), |
1873 false); | 2072 false); |
1874 autofill_manager_->WillSubmitForm(form, TimeTicks::Now()); | 2073 autofill_manager_->SubmitForm(form, TimeTicks::Now()); |
| 2074 histogram_tester.ExpectBucketCount( |
| 2075 "Autofill.FormEvents.Address", |
| 2076 AutofillMetrics::FORM_EVENT_WILL_SUBMIT_ONCE, 1); |
1875 histogram_tester.ExpectBucketCount( | 2077 histogram_tester.ExpectBucketCount( |
1876 "Autofill.FormEvents.Address", | 2078 "Autofill.FormEvents.Address", |
1877 AutofillMetrics::FORM_EVENT_NO_SUGGESTION_SUBMITTED_ONCE, 1); | 2079 AutofillMetrics::FORM_EVENT_NO_SUGGESTION_SUBMITTED_ONCE, 1); |
1878 } | 2080 } |
1879 | 2081 |
1880 // Reset the autofill manager state. | 2082 // Reset the autofill manager state. |
1881 autofill_manager_->Reset(); | 2083 autofill_manager_->Reset(); |
1882 autofill_manager_->AddSeenForm(form, field_types, field_types); | 2084 autofill_manager_->AddSeenForm(form, field_types, field_types); |
1883 | 2085 |
1884 { | 2086 { |
1885 // Simulating submission with filled local data. | 2087 // Simulating submission with filled local data. |
1886 base::HistogramTester histogram_tester; | 2088 base::HistogramTester histogram_tester; |
1887 autofill_manager_->OnQueryFormFieldAutofill(0, form, field, gfx::Rect(), | 2089 autofill_manager_->OnQueryFormFieldAutofill(0, form, field, gfx::Rect(), |
1888 false); | 2090 false); |
1889 SuggestionBackendID guid( | 2091 SuggestionBackendID guid( |
1890 "00000000-0000-0000-0000-000000000001", 0); // local profile | 2092 "00000000-0000-0000-0000-000000000001", 0); // local profile |
1891 autofill_manager_->FillOrPreviewForm( | 2093 autofill_manager_->FillOrPreviewForm( |
1892 AutofillDriver::FORM_DATA_ACTION_FILL, | 2094 AutofillDriver::FORM_DATA_ACTION_FILL, |
1893 0, form, form.fields.front(), | 2095 0, form, form.fields.front(), |
1894 autofill_manager_->MakeFrontendID(SuggestionBackendID(), guid)); | 2096 autofill_manager_->MakeFrontendID(SuggestionBackendID(), guid)); |
1895 autofill_manager_->WillSubmitForm(form, TimeTicks::Now()); | 2097 autofill_manager_->SubmitForm(form, TimeTicks::Now()); |
| 2098 histogram_tester.ExpectBucketCount( |
| 2099 "Autofill.FormEvents.Address", |
| 2100 AutofillMetrics::FORM_EVENT_WILL_SUBMIT_ONCE, 1); |
1896 histogram_tester.ExpectBucketCount( | 2101 histogram_tester.ExpectBucketCount( |
1897 "Autofill.FormEvents.Address", | 2102 "Autofill.FormEvents.Address", |
1898 AutofillMetrics::FORM_EVENT_LOCAL_SUGGESTION_SUBMITTED_ONCE, 1); | 2103 AutofillMetrics::FORM_EVENT_LOCAL_SUGGESTION_SUBMITTED_ONCE, 1); |
1899 } | 2104 } |
1900 | 2105 |
1901 // Reset the autofill manager state. | 2106 // Reset the autofill manager state. |
1902 autofill_manager_->Reset(); | 2107 autofill_manager_->Reset(); |
1903 autofill_manager_->AddSeenForm(form, field_types, field_types); | 2108 autofill_manager_->AddSeenForm(form, field_types, field_types); |
1904 | 2109 |
1905 { | 2110 { |
1906 // Simulating submission with filled server data. | 2111 // Simulating submission with filled server data. |
1907 base::HistogramTester histogram_tester; | 2112 base::HistogramTester histogram_tester; |
1908 autofill_manager_->OnQueryFormFieldAutofill(0, form, field, gfx::Rect(), | 2113 autofill_manager_->OnQueryFormFieldAutofill(0, form, field, gfx::Rect(), |
1909 false); | 2114 false); |
1910 SuggestionBackendID guid( | 2115 SuggestionBackendID guid( |
1911 "00000000-0000-0000-0000-000000000002", 0); // server profile | 2116 "00000000-0000-0000-0000-000000000002", 0); // server profile |
1912 autofill_manager_->FillOrPreviewForm( | 2117 autofill_manager_->FillOrPreviewForm( |
1913 AutofillDriver::FORM_DATA_ACTION_FILL, | 2118 AutofillDriver::FORM_DATA_ACTION_FILL, |
1914 0, form, form.fields.front(), | 2119 0, form, form.fields.front(), |
1915 autofill_manager_->MakeFrontendID(SuggestionBackendID(), guid)); | 2120 autofill_manager_->MakeFrontendID(SuggestionBackendID(), guid)); |
1916 autofill_manager_->WillSubmitForm(form, TimeTicks::Now()); | 2121 autofill_manager_->SubmitForm(form, TimeTicks::Now()); |
| 2122 histogram_tester.ExpectBucketCount( |
| 2123 "Autofill.FormEvents.Address", |
| 2124 AutofillMetrics::FORM_EVENT_WILL_SUBMIT_ONCE, 1); |
1917 histogram_tester.ExpectBucketCount( | 2125 histogram_tester.ExpectBucketCount( |
1918 "Autofill.FormEvents.Address", | 2126 "Autofill.FormEvents.Address", |
1919 AutofillMetrics::FORM_EVENT_SERVER_SUGGESTION_SUBMITTED_ONCE, 1); | 2127 AutofillMetrics::FORM_EVENT_SERVER_SUGGESTION_SUBMITTED_ONCE, 1); |
1920 } | 2128 } |
1921 | 2129 |
1922 // Reset the autofill manager state. | 2130 // Reset the autofill manager state. |
1923 autofill_manager_->Reset(); | 2131 autofill_manager_->Reset(); |
1924 autofill_manager_->AddSeenForm(form, field_types, field_types); | 2132 autofill_manager_->AddSeenForm(form, field_types, field_types); |
1925 | 2133 |
1926 { | 2134 { |
1927 // Simulating multiple submissions. | 2135 // Simulating multiple submissions. |
1928 base::HistogramTester histogram_tester; | 2136 base::HistogramTester histogram_tester; |
1929 autofill_manager_->OnQueryFormFieldAutofill(0, form, field, gfx::Rect(), | 2137 autofill_manager_->OnQueryFormFieldAutofill(0, form, field, gfx::Rect(), |
1930 false); | 2138 false); |
1931 autofill_manager_->WillSubmitForm(form, TimeTicks::Now()); | 2139 autofill_manager_->SubmitForm(form, TimeTicks::Now()); |
| 2140 autofill_manager_->SubmitForm(form, TimeTicks::Now()); |
| 2141 histogram_tester.ExpectBucketCount( |
| 2142 "Autofill.FormEvents.Address", |
| 2143 AutofillMetrics::FORM_EVENT_WILL_SUBMIT_ONCE, 1); |
1932 histogram_tester.ExpectBucketCount( | 2144 histogram_tester.ExpectBucketCount( |
1933 "Autofill.FormEvents.Address", | 2145 "Autofill.FormEvents.Address", |
1934 AutofillMetrics::FORM_EVENT_NO_SUGGESTION_SUBMITTED_ONCE, 1); | 2146 AutofillMetrics::FORM_EVENT_NO_SUGGESTION_SUBMITTED_ONCE, 1); |
1935 histogram_tester.ExpectBucketCount( | 2147 histogram_tester.ExpectBucketCount( |
1936 "Autofill.FormEvents.Address", | 2148 "Autofill.FormEvents.Address", |
1937 AutofillMetrics::FORM_EVENT_LOCAL_SUGGESTION_SUBMITTED_ONCE, 0); | 2149 AutofillMetrics::FORM_EVENT_LOCAL_SUGGESTION_SUBMITTED_ONCE, 0); |
1938 histogram_tester.ExpectBucketCount( | 2150 histogram_tester.ExpectBucketCount( |
1939 "Autofill.FormEvents.Address", | 2151 "Autofill.FormEvents.Address", |
1940 AutofillMetrics::FORM_EVENT_SERVER_SUGGESTION_SUBMITTED_ONCE, 0); | 2152 AutofillMetrics::FORM_EVENT_SERVER_SUGGESTION_SUBMITTED_ONCE, 0); |
1941 } | 2153 } |
1942 | 2154 |
1943 // Reset the autofill manager state. | 2155 // Reset the autofill manager state. |
1944 autofill_manager_->Reset(); | 2156 autofill_manager_->Reset(); |
1945 autofill_manager_->AddSeenForm(form, field_types, field_types); | 2157 autofill_manager_->AddSeenForm(form, field_types, field_types); |
1946 | 2158 |
1947 { | 2159 { |
1948 // Simulating submission without previous interaction. | 2160 // Simulating submission without previous interaction. |
1949 base::HistogramTester histogram_tester; | 2161 base::HistogramTester histogram_tester; |
| 2162 autofill_manager_->SubmitForm(form, TimeTicks::Now()); |
| 2163 histogram_tester.ExpectBucketCount( |
| 2164 "Autofill.FormEvents.Address", |
| 2165 AutofillMetrics::FORM_EVENT_WILL_SUBMIT_ONCE, 0); |
| 2166 histogram_tester.ExpectBucketCount( |
| 2167 "Autofill.FormEvents.Address", |
| 2168 AutofillMetrics::FORM_EVENT_NO_SUGGESTION_SUBMITTED_ONCE, 0); |
| 2169 histogram_tester.ExpectBucketCount( |
| 2170 "Autofill.FormEvents.Address", |
| 2171 AutofillMetrics::FORM_EVENT_LOCAL_SUGGESTION_SUBMITTED_ONCE, 0); |
| 2172 histogram_tester.ExpectBucketCount( |
| 2173 "Autofill.FormEvents.Address", |
| 2174 AutofillMetrics::FORM_EVENT_SERVER_SUGGESTION_SUBMITTED_ONCE, 0); |
| 2175 } |
| 2176 } |
| 2177 |
| 2178 // Test that we log "will submit" (but not submitted) form events for address. |
| 2179 // Mirrors AddressSubmittedFormEvents test but does not expect any "submitted" |
| 2180 // metrics. |
| 2181 TEST_F(AutofillMetricsTest, AddressWillSubmitFormEvents) { |
| 2182 EnableWalletSync(); |
| 2183 // Creating all kinds of profiles. |
| 2184 personal_data_->RecreateProfiles(true /* include_local_profile */, |
| 2185 true /* include_server_profile */); |
| 2186 // Set up our form data. |
| 2187 FormData form; |
| 2188 form.name = ASCIIToUTF16("TestForm"); |
| 2189 form.origin = GURL("http://example.com/form.html"); |
| 2190 form.action = GURL("http://example.com/submit.html"); |
| 2191 form.user_submitted = true; |
| 2192 |
| 2193 FormFieldData field; |
| 2194 std::vector<ServerFieldType> field_types; |
| 2195 test::CreateTestFormField("State", "state", "", "text", &field); |
| 2196 form.fields.push_back(field); |
| 2197 field_types.push_back(ADDRESS_HOME_STATE); |
| 2198 test::CreateTestFormField("City", "city", "", "text", &field); |
| 2199 form.fields.push_back(field); |
| 2200 field_types.push_back(ADDRESS_HOME_CITY); |
| 2201 test::CreateTestFormField("Street", "street", "", "text", &field); |
| 2202 form.fields.push_back(field); |
| 2203 field_types.push_back(ADDRESS_HOME_STREET_ADDRESS); |
| 2204 |
| 2205 // Simulate having seen this form on page load. |
| 2206 // |form_structure| will be owned by |autofill_manager_|. |
| 2207 autofill_manager_->AddSeenForm(form, field_types, field_types); |
| 2208 |
| 2209 { |
| 2210 // Simulating submission with no filled data. |
| 2211 base::HistogramTester histogram_tester; |
| 2212 autofill_manager_->OnQueryFormFieldAutofill(0, form, field, gfx::Rect(), |
| 2213 false); |
| 2214 autofill_manager_->WillSubmitForm(form, TimeTicks::Now()); |
| 2215 histogram_tester.ExpectBucketCount( |
| 2216 "Autofill.FormEvents.Address", |
| 2217 AutofillMetrics::FORM_EVENT_WILL_SUBMIT_ONCE, 1); |
| 2218 histogram_tester.ExpectBucketCount( |
| 2219 "Autofill.FormEvents.Address", |
| 2220 AutofillMetrics::FORM_EVENT_NO_SUGGESTION_SUBMITTED_ONCE, 0); |
| 2221 } |
| 2222 |
| 2223 // Reset the autofill manager state. |
| 2224 autofill_manager_->Reset(); |
| 2225 autofill_manager_->AddSeenForm(form, field_types, field_types); |
| 2226 |
| 2227 { |
| 2228 // Simulating submission with filled local data. |
| 2229 base::HistogramTester histogram_tester; |
| 2230 autofill_manager_->OnQueryFormFieldAutofill(0, form, field, gfx::Rect(), |
| 2231 false); |
| 2232 SuggestionBackendID guid("00000000-0000-0000-0000-000000000001", |
| 2233 0); // local profile |
| 2234 autofill_manager_->FillOrPreviewForm( |
| 2235 AutofillDriver::FORM_DATA_ACTION_FILL, 0, form, form.fields.front(), |
| 2236 autofill_manager_->MakeFrontendID(SuggestionBackendID(), guid)); |
| 2237 autofill_manager_->WillSubmitForm(form, TimeTicks::Now()); |
| 2238 histogram_tester.ExpectBucketCount( |
| 2239 "Autofill.FormEvents.Address", |
| 2240 AutofillMetrics::FORM_EVENT_WILL_SUBMIT_ONCE, 1); |
| 2241 histogram_tester.ExpectBucketCount( |
| 2242 "Autofill.FormEvents.Address", |
| 2243 AutofillMetrics::FORM_EVENT_LOCAL_SUGGESTION_SUBMITTED_ONCE, 0); |
| 2244 } |
| 2245 |
| 2246 // Reset the autofill manager state. |
| 2247 autofill_manager_->Reset(); |
| 2248 autofill_manager_->AddSeenForm(form, field_types, field_types); |
| 2249 |
| 2250 { |
| 2251 // Simulating submission with filled server data. |
| 2252 base::HistogramTester histogram_tester; |
| 2253 autofill_manager_->OnQueryFormFieldAutofill(0, form, field, gfx::Rect(), |
| 2254 false); |
| 2255 SuggestionBackendID guid("00000000-0000-0000-0000-000000000002", |
| 2256 0); // server profile |
| 2257 autofill_manager_->FillOrPreviewForm( |
| 2258 AutofillDriver::FORM_DATA_ACTION_FILL, 0, form, form.fields.front(), |
| 2259 autofill_manager_->MakeFrontendID(SuggestionBackendID(), guid)); |
| 2260 autofill_manager_->WillSubmitForm(form, TimeTicks::Now()); |
| 2261 histogram_tester.ExpectBucketCount( |
| 2262 "Autofill.FormEvents.Address", |
| 2263 AutofillMetrics::FORM_EVENT_WILL_SUBMIT_ONCE, 1); |
| 2264 histogram_tester.ExpectBucketCount( |
| 2265 "Autofill.FormEvents.Address", |
| 2266 AutofillMetrics::FORM_EVENT_SERVER_SUGGESTION_SUBMITTED_ONCE, 0); |
| 2267 } |
| 2268 |
| 2269 // Reset the autofill manager state. |
| 2270 autofill_manager_->Reset(); |
| 2271 autofill_manager_->AddSeenForm(form, field_types, field_types); |
| 2272 |
| 2273 { |
| 2274 // Simulating multiple submissions. |
| 2275 base::HistogramTester histogram_tester; |
| 2276 autofill_manager_->OnQueryFormFieldAutofill(0, form, field, gfx::Rect(), |
| 2277 false); |
| 2278 autofill_manager_->WillSubmitForm(form, TimeTicks::Now()); |
| 2279 autofill_manager_->WillSubmitForm(form, TimeTicks::Now()); |
| 2280 histogram_tester.ExpectBucketCount( |
| 2281 "Autofill.FormEvents.Address", |
| 2282 AutofillMetrics::FORM_EVENT_WILL_SUBMIT_ONCE, 1); |
| 2283 histogram_tester.ExpectBucketCount( |
| 2284 "Autofill.FormEvents.Address", |
| 2285 AutofillMetrics::FORM_EVENT_NO_SUGGESTION_SUBMITTED_ONCE, 0); |
| 2286 histogram_tester.ExpectBucketCount( |
| 2287 "Autofill.FormEvents.Address", |
| 2288 AutofillMetrics::FORM_EVENT_LOCAL_SUGGESTION_SUBMITTED_ONCE, 0); |
| 2289 histogram_tester.ExpectBucketCount( |
| 2290 "Autofill.FormEvents.Address", |
| 2291 AutofillMetrics::FORM_EVENT_SERVER_SUGGESTION_SUBMITTED_ONCE, 0); |
| 2292 } |
| 2293 |
| 2294 // Reset the autofill manager state. |
| 2295 autofill_manager_->Reset(); |
| 2296 autofill_manager_->AddSeenForm(form, field_types, field_types); |
| 2297 |
| 2298 { |
| 2299 // Simulating submission without previous interaction. |
| 2300 base::HistogramTester histogram_tester; |
1950 autofill_manager_->WillSubmitForm(form, TimeTicks::Now()); | 2301 autofill_manager_->WillSubmitForm(form, TimeTicks::Now()); |
1951 histogram_tester.ExpectBucketCount( | 2302 histogram_tester.ExpectBucketCount( |
1952 "Autofill.FormEvents.Address", | 2303 "Autofill.FormEvents.Address", |
| 2304 AutofillMetrics::FORM_EVENT_WILL_SUBMIT_ONCE, 0); |
| 2305 histogram_tester.ExpectBucketCount( |
| 2306 "Autofill.FormEvents.Address", |
1953 AutofillMetrics::FORM_EVENT_NO_SUGGESTION_SUBMITTED_ONCE, 0); | 2307 AutofillMetrics::FORM_EVENT_NO_SUGGESTION_SUBMITTED_ONCE, 0); |
1954 histogram_tester.ExpectBucketCount( | 2308 histogram_tester.ExpectBucketCount( |
1955 "Autofill.FormEvents.Address", | 2309 "Autofill.FormEvents.Address", |
1956 AutofillMetrics::FORM_EVENT_LOCAL_SUGGESTION_SUBMITTED_ONCE, 0); | 2310 AutofillMetrics::FORM_EVENT_LOCAL_SUGGESTION_SUBMITTED_ONCE, 0); |
1957 histogram_tester.ExpectBucketCount( | 2311 histogram_tester.ExpectBucketCount( |
1958 "Autofill.FormEvents.Address", | 2312 "Autofill.FormEvents.Address", |
1959 AutofillMetrics::FORM_EVENT_SERVER_SUGGESTION_SUBMITTED_ONCE, 0); | 2313 AutofillMetrics::FORM_EVENT_SERVER_SUGGESTION_SUBMITTED_ONCE, 0); |
1960 } | 2314 } |
1961 } | 2315 } |
1962 | 2316 |
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2201 { | 2555 { |
2202 base::HistogramTester histogram_tester; | 2556 base::HistogramTester histogram_tester; |
2203 autofill_manager_->OnFormsSeen(forms, TimeTicks()); | 2557 autofill_manager_->OnFormsSeen(forms, TimeTicks()); |
2204 histogram_tester.ExpectTotalCount("Autofill.UserHappiness", 0); | 2558 histogram_tester.ExpectTotalCount("Autofill.UserHappiness", 0); |
2205 } | 2559 } |
2206 | 2560 |
2207 | 2561 |
2208 // Expect no notifications when the form is submitted. | 2562 // Expect no notifications when the form is submitted. |
2209 { | 2563 { |
2210 base::HistogramTester histogram_tester; | 2564 base::HistogramTester histogram_tester; |
2211 autofill_manager_->WillSubmitForm(form, TimeTicks::Now()); | 2565 autofill_manager_->SubmitForm(form, TimeTicks::Now()); |
2212 histogram_tester.ExpectTotalCount("Autofill.UserHappiness", 0); | 2566 histogram_tester.ExpectTotalCount("Autofill.UserHappiness", 0); |
2213 } | 2567 } |
2214 | 2568 |
2215 // Add more fields to the form. | 2569 // Add more fields to the form. |
2216 test::CreateTestFormField("Phone", "phone", "", "text", &field); | 2570 test::CreateTestFormField("Phone", "phone", "", "text", &field); |
2217 form.fields.push_back(field); | 2571 form.fields.push_back(field); |
2218 test::CreateTestFormField("Unknown", "unknown", "", "text", &field); | 2572 test::CreateTestFormField("Unknown", "unknown", "", "text", &field); |
2219 form.fields.push_back(field); | 2573 form.fields.push_back(field); |
2220 forms.front() = form; | 2574 forms.front() = form; |
2221 | 2575 |
2222 // Expect a notification when the form is first seen. | 2576 // Expect a notification when the form is first seen. |
2223 { | 2577 { |
2224 base::HistogramTester histogram_tester; | 2578 base::HistogramTester histogram_tester; |
2225 autofill_manager_->OnFormsSeen(forms, TimeTicks()); | 2579 autofill_manager_->OnFormsSeen(forms, TimeTicks()); |
2226 histogram_tester.ExpectUniqueSample("Autofill.UserHappiness", | 2580 histogram_tester.ExpectUniqueSample("Autofill.UserHappiness", |
2227 AutofillMetrics::FORMS_LOADED, 1); | 2581 AutofillMetrics::FORMS_LOADED, 1); |
2228 } | 2582 } |
2229 | 2583 |
2230 // Expect a notification when the form is submitted. | 2584 // Expect a notification when the form is submitted. |
2231 { | 2585 { |
2232 base::HistogramTester histogram_tester; | 2586 base::HistogramTester histogram_tester; |
2233 autofill_manager_->WillSubmitForm(form, TimeTicks::Now()); | 2587 autofill_manager_->SubmitForm(form, TimeTicks::Now()); |
2234 histogram_tester.ExpectUniqueSample( | 2588 histogram_tester.ExpectUniqueSample( |
2235 "Autofill.UserHappiness", AutofillMetrics::SUBMITTED_NON_FILLABLE_FORM, | 2589 "Autofill.UserHappiness", AutofillMetrics::SUBMITTED_NON_FILLABLE_FORM, |
2236 1); | 2590 1); |
2237 } | 2591 } |
2238 | 2592 |
2239 // Fill in two of the fields. | 2593 // Fill in two of the fields. |
2240 form.fields[0].value = ASCIIToUTF16("Elvis Aaron Presley"); | 2594 form.fields[0].value = ASCIIToUTF16("Elvis Aaron Presley"); |
2241 form.fields[1].value = ASCIIToUTF16("theking@gmail.com"); | 2595 form.fields[1].value = ASCIIToUTF16("theking@gmail.com"); |
2242 forms.front() = form; | 2596 forms.front() = form; |
2243 | 2597 |
2244 // Expect a notification when the form is submitted. | 2598 // Expect a notification when the form is submitted. |
2245 { | 2599 { |
2246 base::HistogramTester histogram_tester; | 2600 base::HistogramTester histogram_tester; |
2247 autofill_manager_->WillSubmitForm(form, TimeTicks::Now()); | 2601 autofill_manager_->SubmitForm(form, TimeTicks::Now()); |
2248 histogram_tester.ExpectUniqueSample( | 2602 histogram_tester.ExpectUniqueSample( |
2249 "Autofill.UserHappiness", AutofillMetrics::SUBMITTED_NON_FILLABLE_FORM, | 2603 "Autofill.UserHappiness", AutofillMetrics::SUBMITTED_NON_FILLABLE_FORM, |
2250 1); | 2604 1); |
2251 } | 2605 } |
2252 | 2606 |
2253 // Fill in the third field. | 2607 // Fill in the third field. |
2254 form.fields[2].value = ASCIIToUTF16("12345678901"); | 2608 form.fields[2].value = ASCIIToUTF16("12345678901"); |
2255 forms.front() = form; | 2609 forms.front() = form; |
2256 | 2610 |
2257 // Expect notifications when the form is submitted. | 2611 // Expect notifications when the form is submitted. |
2258 { | 2612 { |
2259 base::HistogramTester histogram_tester; | 2613 base::HistogramTester histogram_tester; |
2260 autofill_manager_->WillSubmitForm(form, TimeTicks::Now()); | 2614 autofill_manager_->SubmitForm(form, TimeTicks::Now()); |
2261 histogram_tester.ExpectUniqueSample( | 2615 histogram_tester.ExpectUniqueSample( |
2262 "Autofill.UserHappiness", | 2616 "Autofill.UserHappiness", |
2263 AutofillMetrics::SUBMITTED_FILLABLE_FORM_AUTOFILLED_NONE, 1); | 2617 AutofillMetrics::SUBMITTED_FILLABLE_FORM_AUTOFILLED_NONE, 1); |
2264 } | 2618 } |
2265 | 2619 |
2266 | 2620 |
2267 // Mark one of the fields as autofilled. | 2621 // Mark one of the fields as autofilled. |
2268 form.fields[1].is_autofilled = true; | 2622 form.fields[1].is_autofilled = true; |
2269 forms.front() = form; | 2623 forms.front() = form; |
2270 | 2624 |
2271 // Expect notifications when the form is submitted. | 2625 // Expect notifications when the form is submitted. |
2272 { | 2626 { |
2273 base::HistogramTester histogram_tester; | 2627 base::HistogramTester histogram_tester; |
2274 autofill_manager_->WillSubmitForm(form, TimeTicks::Now()); | 2628 autofill_manager_->SubmitForm(form, TimeTicks::Now()); |
2275 histogram_tester.ExpectUniqueSample( | 2629 histogram_tester.ExpectUniqueSample( |
2276 "Autofill.UserHappiness", | 2630 "Autofill.UserHappiness", |
2277 AutofillMetrics::SUBMITTED_FILLABLE_FORM_AUTOFILLED_SOME, 1); | 2631 AutofillMetrics::SUBMITTED_FILLABLE_FORM_AUTOFILLED_SOME, 1); |
2278 } | 2632 } |
2279 | 2633 |
2280 // Mark all of the fillable fields as autofilled. | 2634 // Mark all of the fillable fields as autofilled. |
2281 form.fields[0].is_autofilled = true; | 2635 form.fields[0].is_autofilled = true; |
2282 form.fields[2].is_autofilled = true; | 2636 form.fields[2].is_autofilled = true; |
2283 forms.front() = form; | 2637 forms.front() = form; |
2284 | 2638 |
2285 // Expect notifications when the form is submitted. | 2639 // Expect notifications when the form is submitted. |
2286 { | 2640 { |
2287 base::HistogramTester histogram_tester; | 2641 base::HistogramTester histogram_tester; |
2288 autofill_manager_->WillSubmitForm(form, TimeTicks::Now()); | 2642 autofill_manager_->SubmitForm(form, TimeTicks::Now()); |
2289 histogram_tester.ExpectUniqueSample( | 2643 histogram_tester.ExpectUniqueSample( |
2290 "Autofill.UserHappiness", | 2644 "Autofill.UserHappiness", |
2291 AutofillMetrics::SUBMITTED_FILLABLE_FORM_AUTOFILLED_ALL, 1); | 2645 AutofillMetrics::SUBMITTED_FILLABLE_FORM_AUTOFILLED_ALL, 1); |
2292 } | 2646 } |
2293 | 2647 |
2294 // Clear out the third field's value. | 2648 // Clear out the third field's value. |
2295 form.fields[2].value = base::string16(); | 2649 form.fields[2].value = base::string16(); |
2296 forms.front() = form; | 2650 forms.front() = form; |
2297 | 2651 |
2298 // Expect notifications when the form is submitted. | 2652 // Expect notifications when the form is submitted. |
2299 { | 2653 { |
2300 base::HistogramTester histogram_tester; | 2654 base::HistogramTester histogram_tester; |
2301 autofill_manager_->WillSubmitForm(form, TimeTicks::Now()); | 2655 autofill_manager_->SubmitForm(form, TimeTicks::Now()); |
2302 histogram_tester.ExpectUniqueSample( | 2656 histogram_tester.ExpectUniqueSample( |
2303 "Autofill.UserHappiness", AutofillMetrics::SUBMITTED_NON_FILLABLE_FORM, | 2657 "Autofill.UserHappiness", AutofillMetrics::SUBMITTED_NON_FILLABLE_FORM, |
2304 1); | 2658 1); |
2305 } | 2659 } |
2306 } | 2660 } |
2307 | 2661 |
2308 // Verify that we correctly log user happiness metrics dealing with form | 2662 // Verify that we correctly log user happiness metrics dealing with form |
2309 // interaction. | 2663 // interaction. |
2310 TEST_F(AutofillMetricsTest, UserHappinessFormInteraction) { | 2664 TEST_F(AutofillMetricsTest, UserHappinessFormInteraction) { |
2311 // Load a fillable form. | 2665 // Load a fillable form. |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2447 second_form.fields[0].value = ASCIIToUTF16("Elvis Aaron Presley"); | 2801 second_form.fields[0].value = ASCIIToUTF16("Elvis Aaron Presley"); |
2448 second_form.fields[1].value = ASCIIToUTF16("theking@gmail.com"); | 2802 second_form.fields[1].value = ASCIIToUTF16("theking@gmail.com"); |
2449 second_form.fields[2].value = ASCIIToUTF16("12345678901"); | 2803 second_form.fields[2].value = ASCIIToUTF16("12345678901"); |
2450 second_form.fields[3].value = ASCIIToUTF16("51512345678"); | 2804 second_form.fields[3].value = ASCIIToUTF16("51512345678"); |
2451 | 2805 |
2452 // Expect only form load metrics to be logged if the form is submitted without | 2806 // Expect only form load metrics to be logged if the form is submitted without |
2453 // user interaction. | 2807 // user interaction. |
2454 { | 2808 { |
2455 base::HistogramTester histogram_tester; | 2809 base::HistogramTester histogram_tester; |
2456 autofill_manager_->OnFormsSeen(forms, TimeTicks::FromInternalValue(1)); | 2810 autofill_manager_->OnFormsSeen(forms, TimeTicks::FromInternalValue(1)); |
2457 autofill_manager_->WillSubmitForm(form, TimeTicks::FromInternalValue(17)); | 2811 autofill_manager_->SubmitForm(form, TimeTicks::FromInternalValue(17)); |
2458 | 2812 |
2459 histogram_tester.ExpectTotalCount( | 2813 histogram_tester.ExpectTotalCount( |
2460 "Autofill.FillDuration.FromLoad.WithAutofill", 0); | 2814 "Autofill.FillDuration.FromLoad.WithAutofill", 0); |
2461 histogram_tester.ExpectUniqueSample( | 2815 histogram_tester.ExpectUniqueSample( |
2462 "Autofill.FillDuration.FromLoad.WithoutAutofill", 16, 1); | 2816 "Autofill.FillDuration.FromLoad.WithoutAutofill", 16, 1); |
2463 histogram_tester.ExpectTotalCount( | 2817 histogram_tester.ExpectTotalCount( |
2464 "Autofill.FillDuration.FromInteraction.WithAutofill", 0); | 2818 "Autofill.FillDuration.FromInteraction.WithAutofill", 0); |
2465 histogram_tester.ExpectTotalCount( | 2819 histogram_tester.ExpectTotalCount( |
2466 "Autofill.FillDuration.FromInteraction.WithoutAutofill", 0); | 2820 "Autofill.FillDuration.FromInteraction.WithoutAutofill", 0); |
2467 | 2821 |
2468 autofill_manager_->Reset(); | 2822 autofill_manager_->Reset(); |
2469 } | 2823 } |
2470 | 2824 |
2471 // Expect metric to be logged if the user manually edited a form field. | 2825 // Expect metric to be logged if the user manually edited a form field. |
2472 { | 2826 { |
2473 base::HistogramTester histogram_tester; | 2827 base::HistogramTester histogram_tester; |
2474 autofill_manager_->OnFormsSeen(forms, TimeTicks::FromInternalValue(1)); | 2828 autofill_manager_->OnFormsSeen(forms, TimeTicks::FromInternalValue(1)); |
2475 autofill_manager_->OnTextFieldDidChange(form, form.fields.front(), | 2829 autofill_manager_->OnTextFieldDidChange(form, form.fields.front(), |
2476 TimeTicks::FromInternalValue(3)); | 2830 TimeTicks::FromInternalValue(3)); |
2477 autofill_manager_->WillSubmitForm(form, TimeTicks::FromInternalValue(17)); | 2831 autofill_manager_->SubmitForm(form, TimeTicks::FromInternalValue(17)); |
2478 | 2832 |
2479 histogram_tester.ExpectTotalCount( | 2833 histogram_tester.ExpectTotalCount( |
2480 "Autofill.FillDuration.FromLoad.WithAutofill", 0); | 2834 "Autofill.FillDuration.FromLoad.WithAutofill", 0); |
2481 histogram_tester.ExpectUniqueSample( | 2835 histogram_tester.ExpectUniqueSample( |
2482 "Autofill.FillDuration.FromLoad.WithoutAutofill", 16, 1); | 2836 "Autofill.FillDuration.FromLoad.WithoutAutofill", 16, 1); |
2483 histogram_tester.ExpectTotalCount( | 2837 histogram_tester.ExpectTotalCount( |
2484 "Autofill.FillDuration.FromInteraction.WithAutofill", 0); | 2838 "Autofill.FillDuration.FromInteraction.WithAutofill", 0); |
2485 histogram_tester.ExpectUniqueSample( | 2839 histogram_tester.ExpectUniqueSample( |
2486 "Autofill.FillDuration.FromInteraction.WithoutAutofill", 14, 1); | 2840 "Autofill.FillDuration.FromInteraction.WithoutAutofill", 14, 1); |
2487 | 2841 |
2488 autofill_manager_->Reset(); | 2842 autofill_manager_->Reset(); |
2489 } | 2843 } |
2490 | 2844 |
2491 // Expect metric to be logged if the user autofilled the form. | 2845 // Expect metric to be logged if the user autofilled the form. |
2492 form.fields[0].is_autofilled = true; | 2846 form.fields[0].is_autofilled = true; |
2493 { | 2847 { |
2494 base::HistogramTester histogram_tester; | 2848 base::HistogramTester histogram_tester; |
2495 autofill_manager_->OnFormsSeen(forms, TimeTicks::FromInternalValue(1)); | 2849 autofill_manager_->OnFormsSeen(forms, TimeTicks::FromInternalValue(1)); |
2496 autofill_manager_->OnDidFillAutofillFormData( | 2850 autofill_manager_->OnDidFillAutofillFormData( |
2497 TimeTicks::FromInternalValue(5)); | 2851 TimeTicks::FromInternalValue(5)); |
2498 autofill_manager_->WillSubmitForm(form, TimeTicks::FromInternalValue(17)); | 2852 autofill_manager_->SubmitForm(form, TimeTicks::FromInternalValue(17)); |
2499 | 2853 |
2500 histogram_tester.ExpectUniqueSample( | 2854 histogram_tester.ExpectUniqueSample( |
2501 "Autofill.FillDuration.FromLoad.WithAutofill", 16, 1); | 2855 "Autofill.FillDuration.FromLoad.WithAutofill", 16, 1); |
2502 histogram_tester.ExpectTotalCount( | 2856 histogram_tester.ExpectTotalCount( |
2503 "Autofill.FillDuration.FromLoad.WithoutAutofill", 0); | 2857 "Autofill.FillDuration.FromLoad.WithoutAutofill", 0); |
2504 histogram_tester.ExpectUniqueSample( | 2858 histogram_tester.ExpectUniqueSample( |
2505 "Autofill.FillDuration.FromInteraction.WithAutofill", 12, 1); | 2859 "Autofill.FillDuration.FromInteraction.WithAutofill", 12, 1); |
2506 histogram_tester.ExpectTotalCount( | 2860 histogram_tester.ExpectTotalCount( |
2507 "Autofill.FillDuration.FromInteraction.WithoutAutofill", 0); | 2861 "Autofill.FillDuration.FromInteraction.WithoutAutofill", 0); |
2508 | 2862 |
2509 autofill_manager_->Reset(); | 2863 autofill_manager_->Reset(); |
2510 } | 2864 } |
2511 | 2865 |
2512 // Expect metric to be logged if the user both manually filled some fields | 2866 // Expect metric to be logged if the user both manually filled some fields |
2513 // and autofilled others. Messages can arrive out of order, so make sure they | 2867 // and autofilled others. Messages can arrive out of order, so make sure they |
2514 // take precedence appropriately. | 2868 // take precedence appropriately. |
2515 { | 2869 { |
2516 base::HistogramTester histogram_tester; | 2870 base::HistogramTester histogram_tester; |
2517 | 2871 |
2518 autofill_manager_->OnFormsSeen(forms, TimeTicks::FromInternalValue(1)); | 2872 autofill_manager_->OnFormsSeen(forms, TimeTicks::FromInternalValue(1)); |
2519 autofill_manager_->OnDidFillAutofillFormData( | 2873 autofill_manager_->OnDidFillAutofillFormData( |
2520 TimeTicks::FromInternalValue(5)); | 2874 TimeTicks::FromInternalValue(5)); |
2521 autofill_manager_->OnTextFieldDidChange(form, form.fields.front(), | 2875 autofill_manager_->OnTextFieldDidChange(form, form.fields.front(), |
2522 TimeTicks::FromInternalValue(3)); | 2876 TimeTicks::FromInternalValue(3)); |
2523 autofill_manager_->WillSubmitForm(form, TimeTicks::FromInternalValue(17)); | 2877 autofill_manager_->SubmitForm(form, TimeTicks::FromInternalValue(17)); |
2524 | 2878 |
2525 histogram_tester.ExpectUniqueSample( | 2879 histogram_tester.ExpectUniqueSample( |
2526 "Autofill.FillDuration.FromLoad.WithAutofill", 16, 1); | 2880 "Autofill.FillDuration.FromLoad.WithAutofill", 16, 1); |
2527 histogram_tester.ExpectTotalCount( | 2881 histogram_tester.ExpectTotalCount( |
2528 "Autofill.FillDuration.FromLoad.WithoutAutofill", 0); | 2882 "Autofill.FillDuration.FromLoad.WithoutAutofill", 0); |
2529 histogram_tester.ExpectUniqueSample( | 2883 histogram_tester.ExpectUniqueSample( |
2530 "Autofill.FillDuration.FromInteraction.WithAutofill", 14, 1); | 2884 "Autofill.FillDuration.FromInteraction.WithAutofill", 14, 1); |
2531 histogram_tester.ExpectTotalCount( | 2885 histogram_tester.ExpectTotalCount( |
2532 "Autofill.FillDuration.FromInteraction.WithoutAutofill", 0); | 2886 "Autofill.FillDuration.FromInteraction.WithoutAutofill", 0); |
2533 | 2887 |
2534 autofill_manager_->Reset(); | 2888 autofill_manager_->Reset(); |
2535 } | 2889 } |
2536 | 2890 |
2537 // Make sure that loading another form doesn't affect metrics from the first | 2891 // Make sure that loading another form doesn't affect metrics from the first |
2538 // form. | 2892 // form. |
2539 { | 2893 { |
2540 base::HistogramTester histogram_tester; | 2894 base::HistogramTester histogram_tester; |
2541 autofill_manager_->OnFormsSeen(forms, TimeTicks::FromInternalValue(1)); | 2895 autofill_manager_->OnFormsSeen(forms, TimeTicks::FromInternalValue(1)); |
2542 autofill_manager_->OnFormsSeen(second_forms, | 2896 autofill_manager_->OnFormsSeen(second_forms, |
2543 TimeTicks::FromInternalValue(3)); | 2897 TimeTicks::FromInternalValue(3)); |
2544 autofill_manager_->OnDidFillAutofillFormData( | 2898 autofill_manager_->OnDidFillAutofillFormData( |
2545 TimeTicks::FromInternalValue(5)); | 2899 TimeTicks::FromInternalValue(5)); |
2546 autofill_manager_->OnTextFieldDidChange(form, form.fields.front(), | 2900 autofill_manager_->OnTextFieldDidChange(form, form.fields.front(), |
2547 TimeTicks::FromInternalValue(3)); | 2901 TimeTicks::FromInternalValue(3)); |
2548 autofill_manager_->WillSubmitForm(form, TimeTicks::FromInternalValue(17)); | 2902 autofill_manager_->SubmitForm(form, TimeTicks::FromInternalValue(17)); |
2549 | 2903 |
2550 histogram_tester.ExpectUniqueSample( | 2904 histogram_tester.ExpectUniqueSample( |
2551 "Autofill.FillDuration.FromLoad.WithAutofill", 16, 1); | 2905 "Autofill.FillDuration.FromLoad.WithAutofill", 16, 1); |
2552 histogram_tester.ExpectTotalCount( | 2906 histogram_tester.ExpectTotalCount( |
2553 "Autofill.FillDuration.FromLoad.WithoutAutofill", 0); | 2907 "Autofill.FillDuration.FromLoad.WithoutAutofill", 0); |
2554 histogram_tester.ExpectUniqueSample( | 2908 histogram_tester.ExpectUniqueSample( |
2555 "Autofill.FillDuration.FromInteraction.WithAutofill", 14, 1); | 2909 "Autofill.FillDuration.FromInteraction.WithAutofill", 14, 1); |
2556 histogram_tester.ExpectTotalCount( | 2910 histogram_tester.ExpectTotalCount( |
2557 "Autofill.FillDuration.FromInteraction.WithoutAutofill", 0); | 2911 "Autofill.FillDuration.FromInteraction.WithoutAutofill", 0); |
2558 | 2912 |
2559 autofill_manager_->Reset(); | 2913 autofill_manager_->Reset(); |
2560 } | 2914 } |
2561 | 2915 |
2562 // Make sure that submitting a form that was loaded later will report the | 2916 // Make sure that submitting a form that was loaded later will report the |
2563 // later loading time. | 2917 // later loading time. |
2564 { | 2918 { |
2565 base::HistogramTester histogram_tester; | 2919 base::HistogramTester histogram_tester; |
2566 autofill_manager_->OnFormsSeen(forms, TimeTicks::FromInternalValue(1)); | 2920 autofill_manager_->OnFormsSeen(forms, TimeTicks::FromInternalValue(1)); |
2567 autofill_manager_->OnFormsSeen(second_forms, | 2921 autofill_manager_->OnFormsSeen(second_forms, |
2568 TimeTicks::FromInternalValue(5)); | 2922 TimeTicks::FromInternalValue(5)); |
2569 autofill_manager_->WillSubmitForm(second_form, | 2923 autofill_manager_->SubmitForm(second_form, |
2570 TimeTicks::FromInternalValue(17)); | 2924 TimeTicks::FromInternalValue(17)); |
2571 | 2925 |
2572 histogram_tester.ExpectTotalCount( | 2926 histogram_tester.ExpectTotalCount( |
2573 "Autofill.FillDuration.FromLoad.WithAutofill", 0); | 2927 "Autofill.FillDuration.FromLoad.WithAutofill", 0); |
2574 histogram_tester.ExpectUniqueSample( | 2928 histogram_tester.ExpectUniqueSample( |
2575 "Autofill.FillDuration.FromLoad.WithoutAutofill", 12, 1); | 2929 "Autofill.FillDuration.FromLoad.WithoutAutofill", 12, 1); |
2576 histogram_tester.ExpectTotalCount( | 2930 histogram_tester.ExpectTotalCount( |
2577 "Autofill.FillDuration.FromInteraction.WithAutofill", 0); | 2931 "Autofill.FillDuration.FromInteraction.WithAutofill", 0); |
2578 histogram_tester.ExpectTotalCount( | 2932 histogram_tester.ExpectTotalCount( |
2579 "Autofill.FillDuration.FromInteraction.WithoutAutofill", 0); | 2933 "Autofill.FillDuration.FromInteraction.WithoutAutofill", 0); |
2580 | 2934 |
2581 autofill_manager_->Reset(); | 2935 autofill_manager_->Reset(); |
2582 } | 2936 } |
2583 } | 2937 } |
2584 | 2938 |
2585 } // namespace autofill | 2939 } // namespace autofill |
OLD | NEW |