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

Side by Side Diff: components/autofill/core/browser/autofill_metrics_unittest.cc

Issue 242613006: [Autofill] Enable Autofill for dynamically created forms. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Tests and comments Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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"
26 #include "components/webdata/common/web_data_results.h" 25 #include "components/webdata/common/web_data_results.h"
27 #include "testing/gmock/include/gmock/gmock.h" 26 #include "testing/gmock/include/gmock/gmock.h"
28 #include "testing/gtest/include/gtest/gtest.h" 27 #include "testing/gtest/include/gtest/gtest.h"
29 #include "ui/gfx/rect.h" 28 #include "ui/gfx/rect.h"
30 #include "url/gurl.h" 29 #include "url/gurl.h"
31 30
32 using base::ASCIIToUTF16; 31 using base::ASCIIToUTF16;
33 using base::TimeDelta; 32 using base::TimeDelta;
34 using base::TimeTicks; 33 using base::TimeTicks;
35 using testing::_; 34 using testing::_;
(...skipping 467 matching lines...) Expand 10 before | Expand all | Expand 10 after
503 form.fields.push_back(field); 502 form.fields.push_back(field);
504 test::CreateTestFormField("Email", "email", "", "text", &field); 503 test::CreateTestFormField("Email", "email", "", "text", &field);
505 form.fields.push_back(field); 504 form.fields.push_back(field);
506 505
507 std::vector<FormData> forms(1, form); 506 std::vector<FormData> forms(1, form);
508 507
509 // Ensure no metrics are logged when loading a non-fillable form. 508 // Ensure no metrics are logged when loading a non-fillable form.
510 { 509 {
511 EXPECT_CALL(*autofill_manager_->metric_logger(), 510 EXPECT_CALL(*autofill_manager_->metric_logger(),
512 LogDeveloperEngagementMetric(_)).Times(0); 511 LogDeveloperEngagementMetric(_)).Times(0);
513 autofill_manager_->OnFormsSeen(forms, TimeTicks(), 512 autofill_manager_->OnFormsSeen(forms, TimeTicks());
514 autofill::NO_SPECIAL_FORMS_SEEN);
515 autofill_manager_->Reset(); 513 autofill_manager_->Reset();
516 Mock::VerifyAndClearExpectations(autofill_manager_->metric_logger()); 514 Mock::VerifyAndClearExpectations(autofill_manager_->metric_logger());
517 } 515 }
518 516
519 // Add another field to the form, so that it becomes fillable. 517 // Add another field to the form, so that it becomes fillable.
520 test::CreateTestFormField("Phone", "phone", "", "text", &field); 518 test::CreateTestFormField("Phone", "phone", "", "text", &field);
521 forms.back().fields.push_back(field); 519 forms.back().fields.push_back(field);
522 520
523 // Expect only the "form parsed" metric to be logged; no metrics about 521 // Expect only the "form parsed" metric to be logged; no metrics about
524 // author-specified field type hints. 522 // author-specified field type hints.
525 { 523 {
526 EXPECT_CALL( 524 EXPECT_CALL(
527 *autofill_manager_->metric_logger(), 525 *autofill_manager_->metric_logger(),
528 LogDeveloperEngagementMetric( 526 LogDeveloperEngagementMetric(
529 AutofillMetrics::FILLABLE_FORM_PARSED)).Times(1); 527 AutofillMetrics::FILLABLE_FORM_PARSED)).Times(1);
530 EXPECT_CALL( 528 EXPECT_CALL(
531 *autofill_manager_->metric_logger(), 529 *autofill_manager_->metric_logger(),
532 LogDeveloperEngagementMetric( 530 LogDeveloperEngagementMetric(
533 AutofillMetrics::FILLABLE_FORM_CONTAINS_TYPE_HINTS)).Times(0); 531 AutofillMetrics::FILLABLE_FORM_CONTAINS_TYPE_HINTS)).Times(0);
534 autofill_manager_->OnFormsSeen(forms, TimeTicks(), 532 autofill_manager_->OnFormsSeen(forms, TimeTicks());
535 autofill::NO_SPECIAL_FORMS_SEEN);
536 autofill_manager_->Reset(); 533 autofill_manager_->Reset();
537 Mock::VerifyAndClearExpectations(autofill_manager_->metric_logger()); 534 Mock::VerifyAndClearExpectations(autofill_manager_->metric_logger());
538 } 535 }
539 536
540 // Add some fields with an author-specified field type to the form. 537 // Add some fields with an author-specified field type to the form.
541 // We need to add at least three fields, because a form must have at least 538 // We need to add at least three fields, because a form must have at least
542 // three fillable fields to be considered to be autofillable; and if at least 539 // three fillable fields to be considered to be autofillable; and if at least
543 // one field specifies an explicit type hint, we don't apply any of our usual 540 // one field specifies an explicit type hint, we don't apply any of our usual
544 // local heuristics to detect field types in the rest of the form. 541 // local heuristics to detect field types in the rest of the form.
545 test::CreateTestFormField("", "", "", "text", &field); 542 test::CreateTestFormField("", "", "", "text", &field);
(...skipping 10 matching lines...) Expand all
556 // hints metric to be logged. 553 // hints metric to be logged.
557 { 554 {
558 EXPECT_CALL( 555 EXPECT_CALL(
559 *autofill_manager_->metric_logger(), 556 *autofill_manager_->metric_logger(),
560 LogDeveloperEngagementMetric( 557 LogDeveloperEngagementMetric(
561 AutofillMetrics::FILLABLE_FORM_PARSED)).Times(1); 558 AutofillMetrics::FILLABLE_FORM_PARSED)).Times(1);
562 EXPECT_CALL( 559 EXPECT_CALL(
563 *autofill_manager_->metric_logger(), 560 *autofill_manager_->metric_logger(),
564 LogDeveloperEngagementMetric( 561 LogDeveloperEngagementMetric(
565 AutofillMetrics::FILLABLE_FORM_CONTAINS_TYPE_HINTS)).Times(1); 562 AutofillMetrics::FILLABLE_FORM_CONTAINS_TYPE_HINTS)).Times(1);
566 autofill_manager_->OnFormsSeen(forms, TimeTicks(), 563 autofill_manager_->OnFormsSeen(forms, TimeTicks());
567 autofill::NO_SPECIAL_FORMS_SEEN);
568 autofill_manager_->Reset(); 564 autofill_manager_->Reset();
569 Mock::VerifyAndClearExpectations(autofill_manager_->metric_logger()); 565 Mock::VerifyAndClearExpectations(autofill_manager_->metric_logger());
570 } 566 }
571 } 567 }
572 568
573 // Test that the profile count is logged correctly. 569 // Test that the profile count is logged correctly.
574 TEST_F(AutofillMetricsTest, StoredProfileCount) { 570 TEST_F(AutofillMetricsTest, StoredProfileCount) {
575 // The metric should be logged when the profiles are first loaded. 571 // The metric should be logged when the profiles are first loaded.
576 EXPECT_CALL(*personal_data_->metric_logger(), 572 EXPECT_CALL(*personal_data_->metric_logger(),
577 LogStoredProfileCount(2)).Times(1); 573 LogStoredProfileCount(2)).Times(1);
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
669 } 665 }
670 666
671 // Test that we log whether Autofill is enabled when filling a form. 667 // Test that we log whether Autofill is enabled when filling a form.
672 TEST_F(AutofillMetricsTest, AutofillIsEnabledAtPageLoad) { 668 TEST_F(AutofillMetricsTest, AutofillIsEnabledAtPageLoad) {
673 // Establish our expectations. 669 // Establish our expectations.
674 ::testing::InSequence dummy; 670 ::testing::InSequence dummy;
675 EXPECT_CALL(*autofill_manager_->metric_logger(), 671 EXPECT_CALL(*autofill_manager_->metric_logger(),
676 LogIsAutofillEnabledAtPageLoad(true)).Times(1); 672 LogIsAutofillEnabledAtPageLoad(true)).Times(1);
677 673
678 autofill_manager_->set_autofill_enabled(true); 674 autofill_manager_->set_autofill_enabled(true);
679 autofill_manager_->OnFormsSeen(std::vector<FormData>(), TimeTicks(), 675 autofill_manager_->OnFormsSeen(std::vector<FormData>(), TimeTicks());
680 autofill::NO_SPECIAL_FORMS_SEEN);
681 676
682 // Reset the autofill manager state. 677 // Reset the autofill manager state.
683 autofill_manager_->Reset(); 678 autofill_manager_->Reset();
684 679
685 // Establish our expectations. 680 // Establish our expectations.
686 EXPECT_CALL(*autofill_manager_->metric_logger(), 681 EXPECT_CALL(*autofill_manager_->metric_logger(),
687 LogIsAutofillEnabledAtPageLoad(false)).Times(1); 682 LogIsAutofillEnabledAtPageLoad(false)).Times(1);
688 683
689 autofill_manager_->set_autofill_enabled(false); 684 autofill_manager_->set_autofill_enabled(false);
690 autofill_manager_->OnFormsSeen(std::vector<FormData>(), TimeTicks(), 685 autofill_manager_->OnFormsSeen(std::vector<FormData>(), TimeTicks());
691 autofill::NO_SPECIAL_FORMS_SEEN);
692 } 686 }
693 687
694 // Verify that we correctly log user happiness metrics dealing with form loading 688 // Verify that we correctly log user happiness metrics dealing with form loading
695 // and form submission. 689 // and form submission.
696 TEST_F(AutofillMetricsTest, UserHappinessFormLoadAndSubmission) { 690 TEST_F(AutofillMetricsTest, UserHappinessFormLoadAndSubmission) {
697 // Start with a form with insufficiently many fields. 691 // Start with a form with insufficiently many fields.
698 FormData form; 692 FormData form;
699 form.name = ASCIIToUTF16("TestForm"); 693 form.name = ASCIIToUTF16("TestForm");
700 form.method = ASCIIToUTF16("POST"); 694 form.method = ASCIIToUTF16("POST");
701 form.origin = GURL("http://example.com/form.html"); 695 form.origin = GURL("http://example.com/form.html");
702 form.action = GURL("http://example.com/submit.html"); 696 form.action = GURL("http://example.com/submit.html");
703 form.user_submitted = true; 697 form.user_submitted = true;
704 698
705 FormFieldData field; 699 FormFieldData field;
706 test::CreateTestFormField("Name", "name", "", "text", &field); 700 test::CreateTestFormField("Name", "name", "", "text", &field);
707 form.fields.push_back(field); 701 form.fields.push_back(field);
708 test::CreateTestFormField("Email", "email", "", "text", &field); 702 test::CreateTestFormField("Email", "email", "", "text", &field);
709 form.fields.push_back(field); 703 form.fields.push_back(field);
710 704
711 std::vector<FormData> forms(1, form); 705 std::vector<FormData> forms(1, form);
712 706
713 // Expect no notifications when the form is first seen. 707 // Expect no notifications when the form is first seen.
714 { 708 {
715 EXPECT_CALL(*autofill_manager_->metric_logger(), 709 EXPECT_CALL(*autofill_manager_->metric_logger(),
716 LogUserHappinessMetric(AutofillMetrics::FORMS_LOADED)).Times(0); 710 LogUserHappinessMetric(AutofillMetrics::FORMS_LOADED)).Times(0);
717 autofill_manager_->OnFormsSeen(forms, TimeTicks(), 711 autofill_manager_->OnFormsSeen(forms, TimeTicks());
718 autofill::NO_SPECIAL_FORMS_SEEN);
719 } 712 }
720 713
721 714
722 // Expect no notifications when the form is submitted. 715 // Expect no notifications when the form is submitted.
723 { 716 {
724 EXPECT_CALL( 717 EXPECT_CALL(
725 *autofill_manager_->metric_logger(), 718 *autofill_manager_->metric_logger(),
726 LogUserHappinessMetric( 719 LogUserHappinessMetric(
727 AutofillMetrics::SUBMITTED_FILLABLE_FORM_AUTOFILLED_ALL)).Times(0); 720 AutofillMetrics::SUBMITTED_FILLABLE_FORM_AUTOFILLED_ALL)).Times(0);
728 EXPECT_CALL( 721 EXPECT_CALL(
(...skipping 15 matching lines...) Expand all
744 test::CreateTestFormField("Phone", "phone", "", "text", &field); 737 test::CreateTestFormField("Phone", "phone", "", "text", &field);
745 form.fields.push_back(field); 738 form.fields.push_back(field);
746 test::CreateTestFormField("Unknown", "unknown", "", "text", &field); 739 test::CreateTestFormField("Unknown", "unknown", "", "text", &field);
747 form.fields.push_back(field); 740 form.fields.push_back(field);
748 forms.front() = form; 741 forms.front() = form;
749 742
750 // Expect a notification when the form is first seen. 743 // Expect a notification when the form is first seen.
751 { 744 {
752 EXPECT_CALL(*autofill_manager_->metric_logger(), 745 EXPECT_CALL(*autofill_manager_->metric_logger(),
753 LogUserHappinessMetric(AutofillMetrics::FORMS_LOADED)); 746 LogUserHappinessMetric(AutofillMetrics::FORMS_LOADED));
754 autofill_manager_->OnFormsSeen(forms, TimeTicks(), 747 autofill_manager_->OnFormsSeen(forms, TimeTicks());
755 autofill::NO_SPECIAL_FORMS_SEEN);
756 } 748 }
757 749
758 // Expect a notification when the form is submitted. 750 // Expect a notification when the form is submitted.
759 { 751 {
760 EXPECT_CALL(*autofill_manager_->metric_logger(), 752 EXPECT_CALL(*autofill_manager_->metric_logger(),
761 LogUserHappinessMetric( 753 LogUserHappinessMetric(
762 AutofillMetrics::SUBMITTED_NON_FILLABLE_FORM)); 754 AutofillMetrics::SUBMITTED_NON_FILLABLE_FORM));
763 autofill_manager_->FormSubmitted(form, TimeTicks::Now()); 755 autofill_manager_->FormSubmitted(form, TimeTicks::Now());
764 } 756 }
765 757
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
845 form.fields.push_back(field); 837 form.fields.push_back(field);
846 test::CreateTestFormField("Phone", "phone", "", "text", &field); 838 test::CreateTestFormField("Phone", "phone", "", "text", &field);
847 form.fields.push_back(field); 839 form.fields.push_back(field);
848 840
849 std::vector<FormData> forms(1, form); 841 std::vector<FormData> forms(1, form);
850 842
851 // Expect a notification when the form is first seen. 843 // Expect a notification when the form is first seen.
852 { 844 {
853 EXPECT_CALL(*autofill_manager_->metric_logger(), 845 EXPECT_CALL(*autofill_manager_->metric_logger(),
854 LogUserHappinessMetric(AutofillMetrics::FORMS_LOADED)); 846 LogUserHappinessMetric(AutofillMetrics::FORMS_LOADED));
855 autofill_manager_->OnFormsSeen(forms, TimeTicks(), 847 autofill_manager_->OnFormsSeen(forms, TimeTicks());
856 autofill::NO_SPECIAL_FORMS_SEEN);
857 } 848 }
858 849
859 // Simulate typing. 850 // Simulate typing.
860 { 851 {
861 EXPECT_CALL(*autofill_manager_->metric_logger(), 852 EXPECT_CALL(*autofill_manager_->metric_logger(),
862 LogUserHappinessMetric(AutofillMetrics::USER_DID_TYPE)); 853 LogUserHappinessMetric(AutofillMetrics::USER_DID_TYPE));
863 autofill_manager_->OnTextFieldDidChange(form, form.fields.front(), 854 autofill_manager_->OnTextFieldDidChange(form, form.fields.front(),
864 TimeTicks()); 855 TimeTicks());
865 } 856 }
866 857
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
949 FormFieldData field; 940 FormFieldData field;
950 test::CreateTestFormField("Name", "name", "", "text", &field); 941 test::CreateTestFormField("Name", "name", "", "text", &field);
951 form.fields.push_back(field); 942 form.fields.push_back(field);
952 test::CreateTestFormField("Email", "email", "", "text", &field); 943 test::CreateTestFormField("Email", "email", "", "text", &field);
953 form.fields.push_back(field); 944 form.fields.push_back(field);
954 test::CreateTestFormField("Phone", "phone", "", "text", &field); 945 test::CreateTestFormField("Phone", "phone", "", "text", &field);
955 form.fields.push_back(field); 946 form.fields.push_back(field);
956 947
957 std::vector<FormData> forms(1, form); 948 std::vector<FormData> forms(1, form);
958 949
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
959 // Fill the field values for form submission. 957 // Fill the field values for form submission.
960 form.fields[0].value = ASCIIToUTF16("Elvis Aaron Presley"); 958 form.fields[0].value = ASCIIToUTF16("Elvis Aaron Presley");
961 form.fields[1].value = ASCIIToUTF16("theking@gmail.com"); 959 form.fields[1].value = ASCIIToUTF16("theking@gmail.com");
962 form.fields[2].value = ASCIIToUTF16("12345678901"); 960 form.fields[2].value = ASCIIToUTF16("12345678901");
963 961
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
964 // Expect only form load metrics to be logged if the form is submitted without 968 // Expect only form load metrics to be logged if the form is submitted without
965 // user interaction. 969 // user interaction.
966 { 970 {
967 EXPECT_CALL(*autofill_manager_->metric_logger(), 971 EXPECT_CALL(*autofill_manager_->metric_logger(),
968 LogFormFillDurationFromLoadWithAutofill(_)).Times(0); 972 LogFormFillDurationFromLoadWithAutofill(_)).Times(0);
969 EXPECT_CALL(*autofill_manager_->metric_logger(), 973 EXPECT_CALL(*autofill_manager_->metric_logger(),
970 LogFormFillDurationFromLoadWithoutAutofill( 974 LogFormFillDurationFromLoadWithoutAutofill(
971 TimeDelta::FromInternalValue(16))); 975 TimeDelta::FromInternalValue(16)));
972 EXPECT_CALL(*autofill_manager_->metric_logger(), 976 EXPECT_CALL(*autofill_manager_->metric_logger(),
973 LogFormFillDurationFromInteractionWithAutofill(_)).Times(0); 977 LogFormFillDurationFromInteractionWithAutofill(_)).Times(0);
974 EXPECT_CALL(*autofill_manager_->metric_logger(), 978 EXPECT_CALL(*autofill_manager_->metric_logger(),
975 LogFormFillDurationFromInteractionWithoutAutofill(_)).Times(0); 979 LogFormFillDurationFromInteractionWithoutAutofill(_)).Times(0);
976 autofill_manager_->OnFormsSeen( 980 autofill_manager_->OnFormsSeen(forms, TimeTicks::FromInternalValue(1));
977 forms, TimeTicks::FromInternalValue(1),
978 autofill::NO_SPECIAL_FORMS_SEEN);
979 autofill_manager_->FormSubmitted(form, TimeTicks::FromInternalValue(17)); 981 autofill_manager_->FormSubmitted(form, TimeTicks::FromInternalValue(17));
980 autofill_manager_->Reset(); 982 autofill_manager_->Reset();
981 Mock::VerifyAndClearExpectations(autofill_manager_->metric_logger()); 983 Mock::VerifyAndClearExpectations(autofill_manager_->metric_logger());
982 } 984 }
983 985
984 // Expect metric to be logged if the user manually edited a form field. 986 // Expect metric to be logged if the user manually edited a form field.
985 { 987 {
986 EXPECT_CALL(*autofill_manager_->metric_logger(), 988 EXPECT_CALL(*autofill_manager_->metric_logger(),
987 LogFormFillDurationFromLoadWithAutofill(_)).Times(0); 989 LogFormFillDurationFromLoadWithAutofill(_)).Times(0);
988 EXPECT_CALL(*autofill_manager_->metric_logger(), 990 EXPECT_CALL(*autofill_manager_->metric_logger(),
989 LogFormFillDurationFromLoadWithoutAutofill( 991 LogFormFillDurationFromLoadWithoutAutofill(
990 TimeDelta::FromInternalValue(16))); 992 TimeDelta::FromInternalValue(16)));
991 EXPECT_CALL(*autofill_manager_->metric_logger(), 993 EXPECT_CALL(*autofill_manager_->metric_logger(),
992 LogFormFillDurationFromInteractionWithAutofill(_)).Times(0); 994 LogFormFillDurationFromInteractionWithAutofill(_)).Times(0);
993 EXPECT_CALL(*autofill_manager_->metric_logger(), 995 EXPECT_CALL(*autofill_manager_->metric_logger(),
994 LogFormFillDurationFromInteractionWithoutAutofill( 996 LogFormFillDurationFromInteractionWithoutAutofill(
995 TimeDelta::FromInternalValue(14))); 997 TimeDelta::FromInternalValue(14)));
996 autofill_manager_->OnFormsSeen( 998 autofill_manager_->OnFormsSeen(forms, TimeTicks::FromInternalValue(1));
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( 1019 autofill_manager_->OnFormsSeen(forms, TimeTicks::FromInternalValue(1));
1020 forms, TimeTicks::FromInternalValue(1),
1021 autofill::NO_SPECIAL_FORMS_SEEN);
1022 autofill_manager_->OnDidFillAutofillFormData( 1020 autofill_manager_->OnDidFillAutofillFormData(
1023 TimeTicks::FromInternalValue(5)); 1021 TimeTicks::FromInternalValue(5));
1024 autofill_manager_->FormSubmitted(form, TimeTicks::FromInternalValue(17)); 1022 autofill_manager_->FormSubmitted(form, TimeTicks::FromInternalValue(17));
1025 autofill_manager_->Reset(); 1023 autofill_manager_->Reset();
1026 Mock::VerifyAndClearExpectations(autofill_manager_->metric_logger()); 1024 Mock::VerifyAndClearExpectations(autofill_manager_->metric_logger());
1027 } 1025 }
1028 1026
1029 // Expect metric to be logged if the user both manually filled some fields 1027 // Expect metric to be logged if the user both manually filled some fields
1030 // and autofilled others. Messages can arrive out of order, so make sure they 1028 // and autofilled others. Messages can arrive out of order, so make sure they
1031 // take precedence appropriately. 1029 // take precedence appropriately.
1032 { 1030 {
1033 EXPECT_CALL(*autofill_manager_->metric_logger(), 1031 EXPECT_CALL(*autofill_manager_->metric_logger(),
1034 LogFormFillDurationFromLoadWithAutofill( 1032 LogFormFillDurationFromLoadWithAutofill(
1035 TimeDelta::FromInternalValue(16))); 1033 TimeDelta::FromInternalValue(16)));
1036 EXPECT_CALL(*autofill_manager_->metric_logger(), 1034 EXPECT_CALL(*autofill_manager_->metric_logger(),
1037 LogFormFillDurationFromLoadWithoutAutofill(_)).Times(0); 1035 LogFormFillDurationFromLoadWithoutAutofill(_)).Times(0);
1038 EXPECT_CALL(*autofill_manager_->metric_logger(), 1036 EXPECT_CALL(*autofill_manager_->metric_logger(),
1039 LogFormFillDurationFromInteractionWithAutofill( 1037 LogFormFillDurationFromInteractionWithAutofill(
1040 TimeDelta::FromInternalValue(14))); 1038 TimeDelta::FromInternalValue(14)));
1041 EXPECT_CALL(*autofill_manager_->metric_logger(), 1039 EXPECT_CALL(*autofill_manager_->metric_logger(),
1042 LogFormFillDurationFromInteractionWithoutAutofill(_)).Times(0); 1040 LogFormFillDurationFromInteractionWithoutAutofill(_)).Times(0);
1043 autofill_manager_->OnFormsSeen( 1041 autofill_manager_->OnFormsSeen(forms, TimeTicks::FromInternalValue(1));
1044 forms, TimeTicks::FromInternalValue(1),
1045 autofill::NO_SPECIAL_FORMS_SEEN);
1046 autofill_manager_->OnDidFillAutofillFormData( 1042 autofill_manager_->OnDidFillAutofillFormData(
1047 TimeTicks::FromInternalValue(5)); 1043 TimeTicks::FromInternalValue(5));
1048 autofill_manager_->OnTextFieldDidChange(form, form.fields.front(), 1044 autofill_manager_->OnTextFieldDidChange(form, form.fields.front(),
1045 TimeTicks::FromInternalValue(3));
1046 autofill_manager_->FormSubmitted(form, TimeTicks::FromInternalValue(17));
1047 autofill_manager_->Reset();
1048 Mock::VerifyAndClearExpectations(autofill_manager_->metric_logger());
1049 }
1050
1051 // Make sure that loading another form doesn't effect metrics from the first
Ilya Sherman 2014/05/01 01:08:23 nit: "effect" -> "affect"
Garrett Casto 2014/05/01 20:28:30 Done. I never get that right.
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(),
1049 TimeTicks::FromInternalValue(3)); 1070 TimeTicks::FromInternalValue(3));
1050 autofill_manager_->FormSubmitted(form, TimeTicks::FromInternalValue(17)); 1071 autofill_manager_->FormSubmitted(form, TimeTicks::FromInternalValue(17));
1051 autofill_manager_->Reset(); 1072 autofill_manager_->Reset();
1052 Mock::VerifyAndClearExpectations(autofill_manager_->metric_logger()); 1073 Mock::VerifyAndClearExpectations(autofill_manager_->metric_logger());
1053 } 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 }
1054 } 1096 }
1055 1097
1056 } // namespace autofill 1098 } // namespace autofill
OLDNEW
« no previous file with comments | « components/autofill/core/browser/autofill_manager_unittest.cc ('k') | components/autofill/core/common/form_data.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698