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/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
11 #include "base/prefs/pref_service.h" | 11 #include "base/prefs/pref_service.h" |
12 #include "base/run_loop.h" | 12 #include "base/run_loop.h" |
13 #include "base/strings/string16.h" | 13 #include "base/strings/string16.h" |
14 #include "base/strings/utf_string_conversions.h" | 14 #include "base/strings/utf_string_conversions.h" |
15 #include "base/time/time.h" | 15 #include "base/time/time.h" |
16 #include "components/autofill/core/browser/autofill_external_delegate.h" | 16 #include "components/autofill/core/browser/autofill_external_delegate.h" |
17 #include "components/autofill/core/browser/autofill_manager.h" | 17 #include "components/autofill/core/browser/autofill_manager.h" |
18 #include "components/autofill/core/browser/autofill_test_utils.h" | 18 #include "components/autofill/core/browser/autofill_test_utils.h" |
19 #include "components/autofill/core/browser/personal_data_manager.h" | 19 #include "components/autofill/core/browser/personal_data_manager.h" |
20 #include "components/autofill/core/browser/test_autofill_driver.h" | 20 #include "components/autofill/core/browser/test_autofill_driver.h" |
21 #include "components/autofill/core/browser/test_autofill_manager_delegate.h" | 21 #include "components/autofill/core/browser/test_autofill_manager_delegate.h" |
22 #include "components/autofill/core/browser/webdata/autofill_webdata_service.h" | 22 #include "components/autofill/core/browser/webdata/autofill_webdata_service.h" |
23 #include "components/autofill/core/common/form_data.h" | 23 #include "components/autofill/core/common/form_data.h" |
24 #include "components/autofill/core/common/form_field_data.h" | 24 #include "components/autofill/core/common/form_field_data.h" |
| 25 #include "components/autofill/core/common/forms_seen_state.h" |
25 #include "components/webdata/common/web_data_results.h" | 26 #include "components/webdata/common/web_data_results.h" |
26 #include "testing/gmock/include/gmock/gmock.h" | 27 #include "testing/gmock/include/gmock/gmock.h" |
27 #include "testing/gtest/include/gtest/gtest.h" | 28 #include "testing/gtest/include/gtest/gtest.h" |
28 #include "ui/gfx/rect.h" | 29 #include "ui/gfx/rect.h" |
29 #include "url/gurl.h" | 30 #include "url/gurl.h" |
30 | 31 |
31 using base::ASCIIToUTF16; | 32 using base::ASCIIToUTF16; |
32 using base::TimeDelta; | 33 using base::TimeDelta; |
33 using base::TimeTicks; | 34 using base::TimeTicks; |
34 using testing::_; | 35 using testing::_; |
(...skipping 467 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
502 form.fields.push_back(field); | 503 form.fields.push_back(field); |
503 test::CreateTestFormField("Email", "email", "", "text", &field); | 504 test::CreateTestFormField("Email", "email", "", "text", &field); |
504 form.fields.push_back(field); | 505 form.fields.push_back(field); |
505 | 506 |
506 std::vector<FormData> forms(1, form); | 507 std::vector<FormData> forms(1, form); |
507 | 508 |
508 // Ensure no metrics are logged when loading a non-fillable form. | 509 // Ensure no metrics are logged when loading a non-fillable form. |
509 { | 510 { |
510 EXPECT_CALL(*autofill_manager_->metric_logger(), | 511 EXPECT_CALL(*autofill_manager_->metric_logger(), |
511 LogDeveloperEngagementMetric(_)).Times(0); | 512 LogDeveloperEngagementMetric(_)).Times(0); |
512 autofill_manager_->OnFormsSeen(forms, TimeTicks()); | 513 autofill_manager_->OnFormsSeen(forms, TimeTicks(), |
| 514 autofill::NO_SPECIAL_FORMS_SEEN); |
513 autofill_manager_->Reset(); | 515 autofill_manager_->Reset(); |
514 Mock::VerifyAndClearExpectations(autofill_manager_->metric_logger()); | 516 Mock::VerifyAndClearExpectations(autofill_manager_->metric_logger()); |
515 } | 517 } |
516 | 518 |
517 // Add another field to the form, so that it becomes fillable. | 519 // Add another field to the form, so that it becomes fillable. |
518 test::CreateTestFormField("Phone", "phone", "", "text", &field); | 520 test::CreateTestFormField("Phone", "phone", "", "text", &field); |
519 forms.back().fields.push_back(field); | 521 forms.back().fields.push_back(field); |
520 | 522 |
521 // Expect only the "form parsed" metric to be logged; no metrics about | 523 // Expect only the "form parsed" metric to be logged; no metrics about |
522 // author-specified field type hints. | 524 // author-specified field type hints. |
523 { | 525 { |
524 EXPECT_CALL( | 526 EXPECT_CALL( |
525 *autofill_manager_->metric_logger(), | 527 *autofill_manager_->metric_logger(), |
526 LogDeveloperEngagementMetric( | 528 LogDeveloperEngagementMetric( |
527 AutofillMetrics::FILLABLE_FORM_PARSED)).Times(1); | 529 AutofillMetrics::FILLABLE_FORM_PARSED)).Times(1); |
528 EXPECT_CALL( | 530 EXPECT_CALL( |
529 *autofill_manager_->metric_logger(), | 531 *autofill_manager_->metric_logger(), |
530 LogDeveloperEngagementMetric( | 532 LogDeveloperEngagementMetric( |
531 AutofillMetrics::FILLABLE_FORM_CONTAINS_TYPE_HINTS)).Times(0); | 533 AutofillMetrics::FILLABLE_FORM_CONTAINS_TYPE_HINTS)).Times(0); |
532 autofill_manager_->OnFormsSeen(forms, TimeTicks()); | 534 autofill_manager_->OnFormsSeen(forms, TimeTicks(), |
| 535 autofill::NO_SPECIAL_FORMS_SEEN); |
533 autofill_manager_->Reset(); | 536 autofill_manager_->Reset(); |
534 Mock::VerifyAndClearExpectations(autofill_manager_->metric_logger()); | 537 Mock::VerifyAndClearExpectations(autofill_manager_->metric_logger()); |
535 } | 538 } |
536 | 539 |
537 // Add some fields with an author-specified field type to the form. | 540 // Add some fields with an author-specified field type to the form. |
538 // We need to add at least three fields, because a form must have at least | 541 // We need to add at least three fields, because a form must have at least |
539 // three fillable fields to be considered to be autofillable; and if at least | 542 // three fillable fields to be considered to be autofillable; and if at least |
540 // one field specifies an explicit type hint, we don't apply any of our usual | 543 // one field specifies an explicit type hint, we don't apply any of our usual |
541 // local heuristics to detect field types in the rest of the form. | 544 // local heuristics to detect field types in the rest of the form. |
542 test::CreateTestFormField("", "", "", "text", &field); | 545 test::CreateTestFormField("", "", "", "text", &field); |
(...skipping 10 matching lines...) Expand all Loading... |
553 // hints metric to be logged. | 556 // hints metric to be logged. |
554 { | 557 { |
555 EXPECT_CALL( | 558 EXPECT_CALL( |
556 *autofill_manager_->metric_logger(), | 559 *autofill_manager_->metric_logger(), |
557 LogDeveloperEngagementMetric( | 560 LogDeveloperEngagementMetric( |
558 AutofillMetrics::FILLABLE_FORM_PARSED)).Times(1); | 561 AutofillMetrics::FILLABLE_FORM_PARSED)).Times(1); |
559 EXPECT_CALL( | 562 EXPECT_CALL( |
560 *autofill_manager_->metric_logger(), | 563 *autofill_manager_->metric_logger(), |
561 LogDeveloperEngagementMetric( | 564 LogDeveloperEngagementMetric( |
562 AutofillMetrics::FILLABLE_FORM_CONTAINS_TYPE_HINTS)).Times(1); | 565 AutofillMetrics::FILLABLE_FORM_CONTAINS_TYPE_HINTS)).Times(1); |
563 autofill_manager_->OnFormsSeen(forms, TimeTicks()); | 566 autofill_manager_->OnFormsSeen(forms, TimeTicks(), |
| 567 autofill::NO_SPECIAL_FORMS_SEEN); |
564 autofill_manager_->Reset(); | 568 autofill_manager_->Reset(); |
565 Mock::VerifyAndClearExpectations(autofill_manager_->metric_logger()); | 569 Mock::VerifyAndClearExpectations(autofill_manager_->metric_logger()); |
566 } | 570 } |
567 } | 571 } |
568 | 572 |
569 // Test that the profile count is logged correctly. | 573 // Test that the profile count is logged correctly. |
570 TEST_F(AutofillMetricsTest, StoredProfileCount) { | 574 TEST_F(AutofillMetricsTest, StoredProfileCount) { |
571 // The metric should be logged when the profiles are first loaded. | 575 // The metric should be logged when the profiles are first loaded. |
572 EXPECT_CALL(*personal_data_->metric_logger(), | 576 EXPECT_CALL(*personal_data_->metric_logger(), |
573 LogStoredProfileCount(2)).Times(1); | 577 LogStoredProfileCount(2)).Times(1); |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
665 } | 669 } |
666 | 670 |
667 // Test that we log whether Autofill is enabled when filling a form. | 671 // Test that we log whether Autofill is enabled when filling a form. |
668 TEST_F(AutofillMetricsTest, AutofillIsEnabledAtPageLoad) { | 672 TEST_F(AutofillMetricsTest, AutofillIsEnabledAtPageLoad) { |
669 // Establish our expectations. | 673 // Establish our expectations. |
670 ::testing::InSequence dummy; | 674 ::testing::InSequence dummy; |
671 EXPECT_CALL(*autofill_manager_->metric_logger(), | 675 EXPECT_CALL(*autofill_manager_->metric_logger(), |
672 LogIsAutofillEnabledAtPageLoad(true)).Times(1); | 676 LogIsAutofillEnabledAtPageLoad(true)).Times(1); |
673 | 677 |
674 autofill_manager_->set_autofill_enabled(true); | 678 autofill_manager_->set_autofill_enabled(true); |
675 autofill_manager_->OnFormsSeen(std::vector<FormData>(), TimeTicks()); | 679 autofill_manager_->OnFormsSeen(std::vector<FormData>(), TimeTicks(), |
| 680 autofill::NO_SPECIAL_FORMS_SEEN); |
676 | 681 |
677 // Reset the autofill manager state. | 682 // Reset the autofill manager state. |
678 autofill_manager_->Reset(); | 683 autofill_manager_->Reset(); |
679 | 684 |
680 // Establish our expectations. | 685 // Establish our expectations. |
681 EXPECT_CALL(*autofill_manager_->metric_logger(), | 686 EXPECT_CALL(*autofill_manager_->metric_logger(), |
682 LogIsAutofillEnabledAtPageLoad(false)).Times(1); | 687 LogIsAutofillEnabledAtPageLoad(false)).Times(1); |
683 | 688 |
684 autofill_manager_->set_autofill_enabled(false); | 689 autofill_manager_->set_autofill_enabled(false); |
685 autofill_manager_->OnFormsSeen(std::vector<FormData>(), TimeTicks()); | 690 autofill_manager_->OnFormsSeen(std::vector<FormData>(), TimeTicks(), |
| 691 autofill::NO_SPECIAL_FORMS_SEEN); |
686 } | 692 } |
687 | 693 |
688 // Verify that we correctly log user happiness metrics dealing with form loading | 694 // Verify that we correctly log user happiness metrics dealing with form loading |
689 // and form submission. | 695 // and form submission. |
690 TEST_F(AutofillMetricsTest, UserHappinessFormLoadAndSubmission) { | 696 TEST_F(AutofillMetricsTest, UserHappinessFormLoadAndSubmission) { |
691 // Start with a form with insufficiently many fields. | 697 // Start with a form with insufficiently many fields. |
692 FormData form; | 698 FormData form; |
693 form.name = ASCIIToUTF16("TestForm"); | 699 form.name = ASCIIToUTF16("TestForm"); |
694 form.method = ASCIIToUTF16("POST"); | 700 form.method = ASCIIToUTF16("POST"); |
695 form.origin = GURL("http://example.com/form.html"); | 701 form.origin = GURL("http://example.com/form.html"); |
696 form.action = GURL("http://example.com/submit.html"); | 702 form.action = GURL("http://example.com/submit.html"); |
697 form.user_submitted = true; | 703 form.user_submitted = true; |
698 | 704 |
699 FormFieldData field; | 705 FormFieldData field; |
700 test::CreateTestFormField("Name", "name", "", "text", &field); | 706 test::CreateTestFormField("Name", "name", "", "text", &field); |
701 form.fields.push_back(field); | 707 form.fields.push_back(field); |
702 test::CreateTestFormField("Email", "email", "", "text", &field); | 708 test::CreateTestFormField("Email", "email", "", "text", &field); |
703 form.fields.push_back(field); | 709 form.fields.push_back(field); |
704 | 710 |
705 std::vector<FormData> forms(1, form); | 711 std::vector<FormData> forms(1, form); |
706 | 712 |
707 // Expect no notifications when the form is first seen. | 713 // Expect no notifications when the form is first seen. |
708 { | 714 { |
709 EXPECT_CALL(*autofill_manager_->metric_logger(), | 715 EXPECT_CALL(*autofill_manager_->metric_logger(), |
710 LogUserHappinessMetric(AutofillMetrics::FORMS_LOADED)).Times(0); | 716 LogUserHappinessMetric(AutofillMetrics::FORMS_LOADED)).Times(0); |
711 autofill_manager_->OnFormsSeen(forms, TimeTicks()); | 717 autofill_manager_->OnFormsSeen(forms, TimeTicks(), |
| 718 autofill::NO_SPECIAL_FORMS_SEEN); |
712 } | 719 } |
713 | 720 |
714 | 721 |
715 // Expect no notifications when the form is submitted. | 722 // Expect no notifications when the form is submitted. |
716 { | 723 { |
717 EXPECT_CALL( | 724 EXPECT_CALL( |
718 *autofill_manager_->metric_logger(), | 725 *autofill_manager_->metric_logger(), |
719 LogUserHappinessMetric( | 726 LogUserHappinessMetric( |
720 AutofillMetrics::SUBMITTED_FILLABLE_FORM_AUTOFILLED_ALL)).Times(0); | 727 AutofillMetrics::SUBMITTED_FILLABLE_FORM_AUTOFILLED_ALL)).Times(0); |
721 EXPECT_CALL( | 728 EXPECT_CALL( |
(...skipping 15 matching lines...) Expand all Loading... |
737 test::CreateTestFormField("Phone", "phone", "", "text", &field); | 744 test::CreateTestFormField("Phone", "phone", "", "text", &field); |
738 form.fields.push_back(field); | 745 form.fields.push_back(field); |
739 test::CreateTestFormField("Unknown", "unknown", "", "text", &field); | 746 test::CreateTestFormField("Unknown", "unknown", "", "text", &field); |
740 form.fields.push_back(field); | 747 form.fields.push_back(field); |
741 forms.front() = form; | 748 forms.front() = form; |
742 | 749 |
743 // Expect a notification when the form is first seen. | 750 // Expect a notification when the form is first seen. |
744 { | 751 { |
745 EXPECT_CALL(*autofill_manager_->metric_logger(), | 752 EXPECT_CALL(*autofill_manager_->metric_logger(), |
746 LogUserHappinessMetric(AutofillMetrics::FORMS_LOADED)); | 753 LogUserHappinessMetric(AutofillMetrics::FORMS_LOADED)); |
747 autofill_manager_->OnFormsSeen(forms, TimeTicks()); | 754 autofill_manager_->OnFormsSeen(forms, TimeTicks(), |
| 755 autofill::NO_SPECIAL_FORMS_SEEN); |
748 } | 756 } |
749 | 757 |
750 // Expect a notification when the form is submitted. | 758 // Expect a notification when the form is submitted. |
751 { | 759 { |
752 EXPECT_CALL(*autofill_manager_->metric_logger(), | 760 EXPECT_CALL(*autofill_manager_->metric_logger(), |
753 LogUserHappinessMetric( | 761 LogUserHappinessMetric( |
754 AutofillMetrics::SUBMITTED_NON_FILLABLE_FORM)); | 762 AutofillMetrics::SUBMITTED_NON_FILLABLE_FORM)); |
755 autofill_manager_->FormSubmitted(form, TimeTicks::Now()); | 763 autofill_manager_->FormSubmitted(form, TimeTicks::Now()); |
756 } | 764 } |
757 | 765 |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
837 form.fields.push_back(field); | 845 form.fields.push_back(field); |
838 test::CreateTestFormField("Phone", "phone", "", "text", &field); | 846 test::CreateTestFormField("Phone", "phone", "", "text", &field); |
839 form.fields.push_back(field); | 847 form.fields.push_back(field); |
840 | 848 |
841 std::vector<FormData> forms(1, form); | 849 std::vector<FormData> forms(1, form); |
842 | 850 |
843 // Expect a notification when the form is first seen. | 851 // Expect a notification when the form is first seen. |
844 { | 852 { |
845 EXPECT_CALL(*autofill_manager_->metric_logger(), | 853 EXPECT_CALL(*autofill_manager_->metric_logger(), |
846 LogUserHappinessMetric(AutofillMetrics::FORMS_LOADED)); | 854 LogUserHappinessMetric(AutofillMetrics::FORMS_LOADED)); |
847 autofill_manager_->OnFormsSeen(forms, TimeTicks()); | 855 autofill_manager_->OnFormsSeen(forms, TimeTicks(), |
| 856 autofill::NO_SPECIAL_FORMS_SEEN); |
848 } | 857 } |
849 | 858 |
850 // Simulate typing. | 859 // Simulate typing. |
851 { | 860 { |
852 EXPECT_CALL(*autofill_manager_->metric_logger(), | 861 EXPECT_CALL(*autofill_manager_->metric_logger(), |
853 LogUserHappinessMetric(AutofillMetrics::USER_DID_TYPE)); | 862 LogUserHappinessMetric(AutofillMetrics::USER_DID_TYPE)); |
854 autofill_manager_->OnTextFieldDidChange(form, form.fields.front(), | 863 autofill_manager_->OnTextFieldDidChange(form, form.fields.front(), |
855 TimeTicks()); | 864 TimeTicks()); |
856 } | 865 } |
857 | 866 |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
940 FormFieldData field; | 949 FormFieldData field; |
941 test::CreateTestFormField("Name", "name", "", "text", &field); | 950 test::CreateTestFormField("Name", "name", "", "text", &field); |
942 form.fields.push_back(field); | 951 form.fields.push_back(field); |
943 test::CreateTestFormField("Email", "email", "", "text", &field); | 952 test::CreateTestFormField("Email", "email", "", "text", &field); |
944 form.fields.push_back(field); | 953 form.fields.push_back(field); |
945 test::CreateTestFormField("Phone", "phone", "", "text", &field); | 954 test::CreateTestFormField("Phone", "phone", "", "text", &field); |
946 form.fields.push_back(field); | 955 form.fields.push_back(field); |
947 | 956 |
948 std::vector<FormData> forms(1, form); | 957 std::vector<FormData> forms(1, form); |
949 | 958 |
950 // Fill additional form. | |
951 FormData second_form = form; | |
952 test::CreateTestFormField("Second Phone", "second_phone", "", "text", &field); | |
953 second_form.fields.push_back(field); | |
954 | |
955 std::vector<FormData> second_forms(1, second_form); | |
956 | |
957 // Fill the field values for form submission. | 959 // Fill the field values for form submission. |
958 form.fields[0].value = ASCIIToUTF16("Elvis Aaron Presley"); | 960 form.fields[0].value = ASCIIToUTF16("Elvis Aaron Presley"); |
959 form.fields[1].value = ASCIIToUTF16("theking@gmail.com"); | 961 form.fields[1].value = ASCIIToUTF16("theking@gmail.com"); |
960 form.fields[2].value = ASCIIToUTF16("12345678901"); | 962 form.fields[2].value = ASCIIToUTF16("12345678901"); |
961 | 963 |
962 // Fill the field values for form submission. | |
963 second_form.fields[0].value = ASCIIToUTF16("Elvis Aaron Presley"); | |
964 second_form.fields[1].value = ASCIIToUTF16("theking@gmail.com"); | |
965 second_form.fields[2].value = ASCIIToUTF16("12345678901"); | |
966 second_form.fields[3].value = ASCIIToUTF16("51512345678"); | |
967 | |
968 // Expect only form load metrics to be logged if the form is submitted without | 964 // Expect only form load metrics to be logged if the form is submitted without |
969 // user interaction. | 965 // user interaction. |
970 { | 966 { |
971 EXPECT_CALL(*autofill_manager_->metric_logger(), | 967 EXPECT_CALL(*autofill_manager_->metric_logger(), |
972 LogFormFillDurationFromLoadWithAutofill(_)).Times(0); | 968 LogFormFillDurationFromLoadWithAutofill(_)).Times(0); |
973 EXPECT_CALL(*autofill_manager_->metric_logger(), | 969 EXPECT_CALL(*autofill_manager_->metric_logger(), |
974 LogFormFillDurationFromLoadWithoutAutofill( | 970 LogFormFillDurationFromLoadWithoutAutofill( |
975 TimeDelta::FromInternalValue(16))); | 971 TimeDelta::FromInternalValue(16))); |
976 EXPECT_CALL(*autofill_manager_->metric_logger(), | 972 EXPECT_CALL(*autofill_manager_->metric_logger(), |
977 LogFormFillDurationFromInteractionWithAutofill(_)).Times(0); | 973 LogFormFillDurationFromInteractionWithAutofill(_)).Times(0); |
978 EXPECT_CALL(*autofill_manager_->metric_logger(), | 974 EXPECT_CALL(*autofill_manager_->metric_logger(), |
979 LogFormFillDurationFromInteractionWithoutAutofill(_)).Times(0); | 975 LogFormFillDurationFromInteractionWithoutAutofill(_)).Times(0); |
980 autofill_manager_->OnFormsSeen(forms, TimeTicks::FromInternalValue(1)); | 976 autofill_manager_->OnFormsSeen( |
| 977 forms, TimeTicks::FromInternalValue(1), |
| 978 autofill::NO_SPECIAL_FORMS_SEEN); |
981 autofill_manager_->FormSubmitted(form, TimeTicks::FromInternalValue(17)); | 979 autofill_manager_->FormSubmitted(form, TimeTicks::FromInternalValue(17)); |
982 autofill_manager_->Reset(); | 980 autofill_manager_->Reset(); |
983 Mock::VerifyAndClearExpectations(autofill_manager_->metric_logger()); | 981 Mock::VerifyAndClearExpectations(autofill_manager_->metric_logger()); |
984 } | 982 } |
985 | 983 |
986 // Expect metric to be logged if the user manually edited a form field. | 984 // Expect metric to be logged if the user manually edited a form field. |
987 { | 985 { |
988 EXPECT_CALL(*autofill_manager_->metric_logger(), | 986 EXPECT_CALL(*autofill_manager_->metric_logger(), |
989 LogFormFillDurationFromLoadWithAutofill(_)).Times(0); | 987 LogFormFillDurationFromLoadWithAutofill(_)).Times(0); |
990 EXPECT_CALL(*autofill_manager_->metric_logger(), | 988 EXPECT_CALL(*autofill_manager_->metric_logger(), |
991 LogFormFillDurationFromLoadWithoutAutofill( | 989 LogFormFillDurationFromLoadWithoutAutofill( |
992 TimeDelta::FromInternalValue(16))); | 990 TimeDelta::FromInternalValue(16))); |
993 EXPECT_CALL(*autofill_manager_->metric_logger(), | 991 EXPECT_CALL(*autofill_manager_->metric_logger(), |
994 LogFormFillDurationFromInteractionWithAutofill(_)).Times(0); | 992 LogFormFillDurationFromInteractionWithAutofill(_)).Times(0); |
995 EXPECT_CALL(*autofill_manager_->metric_logger(), | 993 EXPECT_CALL(*autofill_manager_->metric_logger(), |
996 LogFormFillDurationFromInteractionWithoutAutofill( | 994 LogFormFillDurationFromInteractionWithoutAutofill( |
997 TimeDelta::FromInternalValue(14))); | 995 TimeDelta::FromInternalValue(14))); |
998 autofill_manager_->OnFormsSeen(forms, TimeTicks::FromInternalValue(1)); | 996 autofill_manager_->OnFormsSeen( |
| 997 forms, TimeTicks::FromInternalValue(1), |
| 998 autofill::NO_SPECIAL_FORMS_SEEN); |
999 autofill_manager_->OnTextFieldDidChange(form, form.fields.front(), | 999 autofill_manager_->OnTextFieldDidChange(form, form.fields.front(), |
1000 TimeTicks::FromInternalValue(3)); | 1000 TimeTicks::FromInternalValue(3)); |
1001 autofill_manager_->FormSubmitted(form, TimeTicks::FromInternalValue(17)); | 1001 autofill_manager_->FormSubmitted(form, TimeTicks::FromInternalValue(17)); |
1002 autofill_manager_->Reset(); | 1002 autofill_manager_->Reset(); |
1003 Mock::VerifyAndClearExpectations(autofill_manager_->metric_logger()); | 1003 Mock::VerifyAndClearExpectations(autofill_manager_->metric_logger()); |
1004 } | 1004 } |
1005 | 1005 |
1006 // Expect metric to be logged if the user autofilled the form. | 1006 // Expect metric to be logged if the user autofilled the form. |
1007 form.fields[0].is_autofilled = true; | 1007 form.fields[0].is_autofilled = true; |
1008 { | 1008 { |
1009 EXPECT_CALL(*autofill_manager_->metric_logger(), | 1009 EXPECT_CALL(*autofill_manager_->metric_logger(), |
1010 LogFormFillDurationFromLoadWithAutofill( | 1010 LogFormFillDurationFromLoadWithAutofill( |
1011 TimeDelta::FromInternalValue(16))); | 1011 TimeDelta::FromInternalValue(16))); |
1012 EXPECT_CALL(*autofill_manager_->metric_logger(), | 1012 EXPECT_CALL(*autofill_manager_->metric_logger(), |
1013 LogFormFillDurationFromLoadWithoutAutofill(_)).Times(0); | 1013 LogFormFillDurationFromLoadWithoutAutofill(_)).Times(0); |
1014 EXPECT_CALL(*autofill_manager_->metric_logger(), | 1014 EXPECT_CALL(*autofill_manager_->metric_logger(), |
1015 LogFormFillDurationFromInteractionWithAutofill( | 1015 LogFormFillDurationFromInteractionWithAutofill( |
1016 TimeDelta::FromInternalValue(12))); | 1016 TimeDelta::FromInternalValue(12))); |
1017 EXPECT_CALL(*autofill_manager_->metric_logger(), | 1017 EXPECT_CALL(*autofill_manager_->metric_logger(), |
1018 LogFormFillDurationFromInteractionWithoutAutofill(_)).Times(0); | 1018 LogFormFillDurationFromInteractionWithoutAutofill(_)).Times(0); |
1019 autofill_manager_->OnFormsSeen(forms, TimeTicks::FromInternalValue(1)); | 1019 autofill_manager_->OnFormsSeen( |
| 1020 forms, TimeTicks::FromInternalValue(1), |
| 1021 autofill::NO_SPECIAL_FORMS_SEEN); |
1020 autofill_manager_->OnDidFillAutofillFormData( | 1022 autofill_manager_->OnDidFillAutofillFormData( |
1021 TimeTicks::FromInternalValue(5)); | 1023 TimeTicks::FromInternalValue(5)); |
1022 autofill_manager_->FormSubmitted(form, TimeTicks::FromInternalValue(17)); | 1024 autofill_manager_->FormSubmitted(form, TimeTicks::FromInternalValue(17)); |
1023 autofill_manager_->Reset(); | 1025 autofill_manager_->Reset(); |
1024 Mock::VerifyAndClearExpectations(autofill_manager_->metric_logger()); | 1026 Mock::VerifyAndClearExpectations(autofill_manager_->metric_logger()); |
1025 } | 1027 } |
1026 | 1028 |
1027 // Expect metric to be logged if the user both manually filled some fields | 1029 // Expect metric to be logged if the user both manually filled some fields |
1028 // and autofilled others. Messages can arrive out of order, so make sure they | 1030 // and autofilled others. Messages can arrive out of order, so make sure they |
1029 // take precedence appropriately. | 1031 // take precedence appropriately. |
1030 { | 1032 { |
1031 EXPECT_CALL(*autofill_manager_->metric_logger(), | 1033 EXPECT_CALL(*autofill_manager_->metric_logger(), |
1032 LogFormFillDurationFromLoadWithAutofill( | 1034 LogFormFillDurationFromLoadWithAutofill( |
1033 TimeDelta::FromInternalValue(16))); | 1035 TimeDelta::FromInternalValue(16))); |
1034 EXPECT_CALL(*autofill_manager_->metric_logger(), | 1036 EXPECT_CALL(*autofill_manager_->metric_logger(), |
1035 LogFormFillDurationFromLoadWithoutAutofill(_)).Times(0); | 1037 LogFormFillDurationFromLoadWithoutAutofill(_)).Times(0); |
1036 EXPECT_CALL(*autofill_manager_->metric_logger(), | 1038 EXPECT_CALL(*autofill_manager_->metric_logger(), |
1037 LogFormFillDurationFromInteractionWithAutofill( | 1039 LogFormFillDurationFromInteractionWithAutofill( |
1038 TimeDelta::FromInternalValue(14))); | 1040 TimeDelta::FromInternalValue(14))); |
1039 EXPECT_CALL(*autofill_manager_->metric_logger(), | 1041 EXPECT_CALL(*autofill_manager_->metric_logger(), |
1040 LogFormFillDurationFromInteractionWithoutAutofill(_)).Times(0); | 1042 LogFormFillDurationFromInteractionWithoutAutofill(_)).Times(0); |
1041 autofill_manager_->OnFormsSeen(forms, TimeTicks::FromInternalValue(1)); | 1043 autofill_manager_->OnFormsSeen( |
| 1044 forms, TimeTicks::FromInternalValue(1), |
| 1045 autofill::NO_SPECIAL_FORMS_SEEN); |
1042 autofill_manager_->OnDidFillAutofillFormData( | 1046 autofill_manager_->OnDidFillAutofillFormData( |
1043 TimeTicks::FromInternalValue(5)); | 1047 TimeTicks::FromInternalValue(5)); |
1044 autofill_manager_->OnTextFieldDidChange(form, form.fields.front(), | 1048 autofill_manager_->OnTextFieldDidChange(form, form.fields.front(), |
1045 TimeTicks::FromInternalValue(3)); | 1049 TimeTicks::FromInternalValue(3)); |
1046 autofill_manager_->FormSubmitted(form, TimeTicks::FromInternalValue(17)); | 1050 autofill_manager_->FormSubmitted(form, TimeTicks::FromInternalValue(17)); |
1047 autofill_manager_->Reset(); | 1051 autofill_manager_->Reset(); |
1048 Mock::VerifyAndClearExpectations(autofill_manager_->metric_logger()); | 1052 Mock::VerifyAndClearExpectations(autofill_manager_->metric_logger()); |
1049 } | 1053 } |
1050 | |
1051 // Make sure that loading another form doesn't affect metrics from the first | |
1052 // form. | |
1053 { | |
1054 EXPECT_CALL(*autofill_manager_->metric_logger(), | |
1055 LogFormFillDurationFromLoadWithAutofill( | |
1056 TimeDelta::FromInternalValue(16))); | |
1057 EXPECT_CALL(*autofill_manager_->metric_logger(), | |
1058 LogFormFillDurationFromLoadWithoutAutofill(_)).Times(0); | |
1059 EXPECT_CALL(*autofill_manager_->metric_logger(), | |
1060 LogFormFillDurationFromInteractionWithAutofill( | |
1061 TimeDelta::FromInternalValue(14))); | |
1062 EXPECT_CALL(*autofill_manager_->metric_logger(), | |
1063 LogFormFillDurationFromInteractionWithoutAutofill(_)).Times(0); | |
1064 autofill_manager_->OnFormsSeen(forms, TimeTicks::FromInternalValue(1)); | |
1065 autofill_manager_->OnFormsSeen(second_forms, | |
1066 TimeTicks::FromInternalValue(3)); | |
1067 autofill_manager_->OnDidFillAutofillFormData( | |
1068 TimeTicks::FromInternalValue(5)); | |
1069 autofill_manager_->OnTextFieldDidChange(form, form.fields.front(), | |
1070 TimeTicks::FromInternalValue(3)); | |
1071 autofill_manager_->FormSubmitted(form, TimeTicks::FromInternalValue(17)); | |
1072 autofill_manager_->Reset(); | |
1073 Mock::VerifyAndClearExpectations(autofill_manager_->metric_logger()); | |
1074 } | |
1075 | |
1076 // Make sure that submitting a form that was loaded later will report the | |
1077 // later loading time. | |
1078 { | |
1079 EXPECT_CALL(*autofill_manager_->metric_logger(), | |
1080 LogFormFillDurationFromLoadWithoutAutofill( | |
1081 TimeDelta::FromInternalValue(12))); | |
1082 EXPECT_CALL(*autofill_manager_->metric_logger(), | |
1083 LogFormFillDurationFromLoadWithAutofill(_)).Times(0); | |
1084 EXPECT_CALL(*autofill_manager_->metric_logger(), | |
1085 LogFormFillDurationFromInteractionWithAutofill(_)).Times(0); | |
1086 EXPECT_CALL(*autofill_manager_->metric_logger(), | |
1087 LogFormFillDurationFromInteractionWithoutAutofill(_)).Times(0); | |
1088 autofill_manager_->OnFormsSeen(forms, TimeTicks::FromInternalValue(1)); | |
1089 autofill_manager_->OnFormsSeen(second_forms, | |
1090 TimeTicks::FromInternalValue(5)); | |
1091 autofill_manager_->FormSubmitted(second_form, | |
1092 TimeTicks::FromInternalValue(17)); | |
1093 autofill_manager_->Reset(); | |
1094 Mock::VerifyAndClearExpectations(autofill_manager_->metric_logger()); | |
1095 } | |
1096 } | 1054 } |
1097 | 1055 |
1098 } // namespace autofill | 1056 } // namespace autofill |
OLD | NEW |