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

Side by Side Diff: chrome/browser/autofill/autofill_metrics_unittest.cc

Issue 7740070: Add metrics to measure time elapsed between form load and form submission with or without Autofill. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Once more, with feeling Created 9 years, 3 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
« no previous file with comments | « chrome/browser/autofill/autofill_metrics.cc ('k') | chrome/browser/autofill/autofill_type.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 <vector> 5 #include <vector>
6 6
7 #include "base/memory/ref_counted.h" 7 #include "base/memory/ref_counted.h"
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "base/string16.h" 9 #include "base/string16.h"
10 #include "base/time.h"
10 #include "base/utf_string_conversions.h" 11 #include "base/utf_string_conversions.h"
11 #include "chrome/browser/autofill/autofill_cc_infobar_delegate.h" 12 #include "chrome/browser/autofill/autofill_cc_infobar_delegate.h"
12 #include "chrome/browser/autofill/autofill_common_test.h" 13 #include "chrome/browser/autofill/autofill_common_test.h"
13 #include "chrome/browser/autofill/autofill_manager.h" 14 #include "chrome/browser/autofill/autofill_manager.h"
14 #include "chrome/browser/autofill/autofill_metrics.h" 15 #include "chrome/browser/autofill/autofill_metrics.h"
15 #include "chrome/browser/autofill/personal_data_manager.h" 16 #include "chrome/browser/autofill/personal_data_manager.h"
16 #include "chrome/browser/webdata/web_data_service.h" 17 #include "chrome/browser/webdata/web_data_service.h"
17 #include "chrome/browser/ui/tab_contents/test_tab_contents_wrapper.h" 18 #include "chrome/browser/ui/tab_contents/test_tab_contents_wrapper.h"
18 #include "content/browser/browser_thread.h" 19 #include "content/browser/browser_thread.h"
19 #include "content/browser/tab_contents/test_tab_contents.h" 20 #include "content/browser/tab_contents/test_tab_contents.h"
20 #include "testing/gmock/include/gmock/gmock.h" 21 #include "testing/gmock/include/gmock/gmock.h"
21 #include "testing/gtest/include/gtest/gtest.h" 22 #include "testing/gtest/include/gtest/gtest.h"
22 #include "webkit/glue/form_data.h" 23 #include "webkit/glue/form_data.h"
23 #include "webkit/glue/form_field.h" 24 #include "webkit/glue/form_field.h"
24 25
26 using ::testing::_;
27 using ::testing::AnyNumber;
28 using ::testing::Mock;
29 using base::TimeTicks;
30 using base::TimeDelta;
25 using webkit_glue::FormData; 31 using webkit_glue::FormData;
26 using webkit_glue::FormField; 32 using webkit_glue::FormField;
27 33
28 namespace { 34 namespace {
29 35
30 class MockAutofillMetrics : public AutofillMetrics { 36 class MockAutofillMetrics : public AutofillMetrics {
31 public: 37 public:
32 MockAutofillMetrics() {} 38 MockAutofillMetrics() {}
33 MOCK_CONST_METHOD1(LogCreditCardInfoBarMetric, void(InfoBarMetric metric)); 39 MOCK_CONST_METHOD1(LogCreditCardInfoBarMetric, void(InfoBarMetric metric));
34 MOCK_CONST_METHOD3(LogHeuristicTypePrediction, 40 MOCK_CONST_METHOD3(LogHeuristicTypePrediction,
35 void(FieldTypeQualityMetric metric, 41 void(FieldTypeQualityMetric metric,
36 AutofillFieldType field_type, 42 AutofillFieldType field_type,
37 const std::string& experiment_id)); 43 const std::string& experiment_id));
38 MOCK_CONST_METHOD3(LogOverallTypePrediction, 44 MOCK_CONST_METHOD3(LogOverallTypePrediction,
39 void(FieldTypeQualityMetric metric, 45 void(FieldTypeQualityMetric metric,
40 AutofillFieldType field_type, 46 AutofillFieldType field_type,
41 const std::string& experiment_id)); 47 const std::string& experiment_id));
42 MOCK_CONST_METHOD3(LogServerTypePrediction, 48 MOCK_CONST_METHOD3(LogServerTypePrediction,
43 void(FieldTypeQualityMetric metric, 49 void(FieldTypeQualityMetric metric,
44 AutofillFieldType field_type, 50 AutofillFieldType field_type,
45 const std::string& experiment_id)); 51 const std::string& experiment_id));
46 MOCK_CONST_METHOD2(LogQualityMetric, void(QualityMetric metric, 52 MOCK_CONST_METHOD2(LogQualityMetric, void(QualityMetric metric,
47 const std::string& experiment_id)); 53 const std::string& experiment_id));
48 MOCK_CONST_METHOD1(LogServerQueryMetric, void(ServerQueryMetric metric)); 54 MOCK_CONST_METHOD1(LogServerQueryMetric, void(ServerQueryMetric metric));
49 MOCK_CONST_METHOD1(LogUserHappinessMetric, void(UserHappinessMetric metric)); 55 MOCK_CONST_METHOD1(LogUserHappinessMetric, void(UserHappinessMetric metric));
56 MOCK_CONST_METHOD1(LogFormFillDurationFromLoadWithAutofill,
57 void(const TimeDelta& duration));
58 MOCK_CONST_METHOD1(LogFormFillDurationFromLoadWithoutAutofill,
59 void(const TimeDelta& duration));
60 MOCK_CONST_METHOD1(LogFormFillDurationFromInteractionWithAutofill,
61 void(const TimeDelta& duration));
62 MOCK_CONST_METHOD1(LogFormFillDurationFromInteractionWithoutAutofill,
63 void(const TimeDelta& duration));
50 MOCK_CONST_METHOD1(LogIsAutofillEnabledAtPageLoad, void(bool enabled)); 64 MOCK_CONST_METHOD1(LogIsAutofillEnabledAtPageLoad, void(bool enabled));
51 MOCK_CONST_METHOD1(LogIsAutofillEnabledAtStartup, void(bool enabled)); 65 MOCK_CONST_METHOD1(LogIsAutofillEnabledAtStartup, void(bool enabled));
52 MOCK_CONST_METHOD1(LogStoredProfileCount, void(size_t num_profiles)); 66 MOCK_CONST_METHOD1(LogStoredProfileCount, void(size_t num_profiles));
53 MOCK_CONST_METHOD1(LogAddressSuggestionsCount, void(size_t num_suggestions)); 67 MOCK_CONST_METHOD1(LogAddressSuggestionsCount, void(size_t num_suggestions));
54 MOCK_CONST_METHOD1(LogServerExperimentIdForQuery, 68 MOCK_CONST_METHOD1(LogServerExperimentIdForQuery,
55 void(const std::string& experiment_id)); 69 void(const std::string& experiment_id));
56 MOCK_CONST_METHOD1(LogServerExperimentIdForUpload, 70 MOCK_CONST_METHOD1(LogServerExperimentIdForUpload,
57 void(const std::string& experiment_id)); 71 void(const std::string& experiment_id));
58 72
59 private: 73 private:
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 set_metric_logger(new MockAutofillMetrics); 176 set_metric_logger(new MockAutofillMetrics);
163 } 177 }
164 virtual ~TestAutofillManager() {} 178 virtual ~TestAutofillManager() {}
165 179
166 virtual bool IsAutofillEnabled() const { return autofill_enabled_; } 180 virtual bool IsAutofillEnabled() const { return autofill_enabled_; }
167 181
168 void set_autofill_enabled(bool autofill_enabled) { 182 void set_autofill_enabled(bool autofill_enabled) {
169 autofill_enabled_ = autofill_enabled; 183 autofill_enabled_ = autofill_enabled;
170 } 184 }
171 185
172 const MockAutofillMetrics* metric_logger() const { 186 MockAutofillMetrics* metric_logger() {
173 return static_cast<const MockAutofillMetrics*>( 187 return static_cast<MockAutofillMetrics*>(const_cast<AutofillMetrics*>(
174 AutofillManager::metric_logger()); 188 AutofillManager::metric_logger()));
175 } 189 }
176 190
177 void AddSeenForm(const FormData& form, 191 void AddSeenForm(const FormData& form,
178 const std::vector<AutofillFieldType>& heuristic_types, 192 const std::vector<AutofillFieldType>& heuristic_types,
179 const std::vector<AutofillFieldType>& server_types, 193 const std::vector<AutofillFieldType>& server_types,
180 const std::string& experiment_id) { 194 const std::string& experiment_id) {
181 FormData empty_form = form; 195 FormData empty_form = form;
182 for (size_t i = 0; i < empty_form.fields.size(); ++i) { 196 for (size_t i = 0; i < empty_form.fields.size(); ++i) {
183 empty_form.fields[i].value = string16(); 197 empty_form.fields[i].value = string16();
184 } 198 }
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
388 LogOverallTypePrediction(AutofillMetrics::TYPE_MATCH, 402 LogOverallTypePrediction(AutofillMetrics::TYPE_MATCH,
389 PHONE_HOME_WHOLE_NUMBER, std::string())); 403 PHONE_HOME_WHOLE_NUMBER, std::string()));
390 EXPECT_CALL(*autofill_manager_->metric_logger(), 404 EXPECT_CALL(*autofill_manager_->metric_logger(),
391 LogQualityMetric(AutofillMetrics::FIELD_AUTOFILLED, 405 LogQualityMetric(AutofillMetrics::FIELD_AUTOFILLED,
392 std::string())); 406 std::string()));
393 EXPECT_CALL(*autofill_manager_->metric_logger(), 407 EXPECT_CALL(*autofill_manager_->metric_logger(),
394 LogUserHappinessMetric( 408 LogUserHappinessMetric(
395 AutofillMetrics::SUBMITTED_FILLABLE_FORM_AUTOFILLED_SOME)); 409 AutofillMetrics::SUBMITTED_FILLABLE_FORM_AUTOFILLED_SOME));
396 410
397 // Simulate form submission. 411 // Simulate form submission.
398 EXPECT_NO_FATAL_FAILURE(autofill_manager_->OnFormSubmitted(form)); 412 EXPECT_NO_FATAL_FAILURE(autofill_manager_->OnFormSubmitted(form,
413 TimeTicks::Now()));
399 } 414 }
400 415
401 // Test that we log the appropriate additional metrics when Autofill failed. 416 // Test that we log the appropriate additional metrics when Autofill failed.
402 TEST_F(AutofillMetricsTest, QualityMetricsForFailure) { 417 TEST_F(AutofillMetricsTest, QualityMetricsForFailure) {
403 // Set up our form data. 418 // Set up our form data.
404 FormData form; 419 FormData form;
405 form.name = ASCIIToUTF16("TestForm"); 420 form.name = ASCIIToUTF16("TestForm");
406 form.method = ASCIIToUTF16("POST"); 421 form.method = ASCIIToUTF16("POST");
407 form.origin = GURL("http://example.com/form.html"); 422 form.origin = GURL("http://example.com/form.html");
408 form.action = GURL("http://example.com/submit.html"); 423 form.action = GURL("http://example.com/submit.html");
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
505 std::string())); 520 std::string()));
506 EXPECT_CALL(*autofill_manager_->metric_logger(), 521 EXPECT_CALL(*autofill_manager_->metric_logger(),
507 LogQualityMetric(failure_cases[i].heuristic_metric, 522 LogQualityMetric(failure_cases[i].heuristic_metric,
508 std::string())); 523 std::string()));
509 EXPECT_CALL(*autofill_manager_->metric_logger(), 524 EXPECT_CALL(*autofill_manager_->metric_logger(),
510 LogQualityMetric(failure_cases[i].server_metric, 525 LogQualityMetric(failure_cases[i].server_metric,
511 std::string())); 526 std::string()));
512 } 527 }
513 528
514 // Simulate form submission. 529 // Simulate form submission.
515 EXPECT_NO_FATAL_FAILURE(autofill_manager_->OnFormSubmitted(form)); 530 EXPECT_NO_FATAL_FAILURE(autofill_manager_->OnFormSubmitted(form,
531 TimeTicks::Now()));
516 } 532 }
517 533
518 // Test that we behave sanely when the cached form differs from the submitted 534 // Test that we behave sanely when the cached form differs from the submitted
519 // one. 535 // one.
520 TEST_F(AutofillMetricsTest, SaneMetricsWithCacheMismatch) { 536 TEST_F(AutofillMetricsTest, SaneMetricsWithCacheMismatch) {
521 // Set up our form data. 537 // Set up our form data.
522 FormData form; 538 FormData form;
523 form.name = ASCIIToUTF16("TestForm"); 539 form.name = ASCIIToUTF16("TestForm");
524 form.method = ASCIIToUTF16("POST"); 540 form.method = ASCIIToUTF16("POST");
525 form.origin = GURL("http://example.com/form.html"); 541 form.origin = GURL("http://example.com/form.html");
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
662 LogServerTypePrediction(AutofillMetrics::TYPE_MATCH, 678 LogServerTypePrediction(AutofillMetrics::TYPE_MATCH,
663 NAME_FULL, std::string())); 679 NAME_FULL, std::string()));
664 EXPECT_CALL(*autofill_manager_->metric_logger(), 680 EXPECT_CALL(*autofill_manager_->metric_logger(),
665 LogOverallTypePrediction(AutofillMetrics::TYPE_MATCH, 681 LogOverallTypePrediction(AutofillMetrics::TYPE_MATCH,
666 NAME_FULL, std::string())); 682 NAME_FULL, std::string()));
667 EXPECT_CALL(*autofill_manager_->metric_logger(), 683 EXPECT_CALL(*autofill_manager_->metric_logger(),
668 LogQualityMetric(AutofillMetrics::FIELD_AUTOFILLED, 684 LogQualityMetric(AutofillMetrics::FIELD_AUTOFILLED,
669 std::string())); 685 std::string()));
670 686
671 // Simulate form submission. 687 // Simulate form submission.
672 EXPECT_NO_FATAL_FAILURE(autofill_manager_->OnFormSubmitted(form)); 688 EXPECT_NO_FATAL_FAILURE(autofill_manager_->OnFormSubmitted(form,
689 TimeTicks::Now()));
673 } 690 }
674 691
675 // Test that we don't log quality metrics for non-autofillable forms. 692 // Test that we don't log quality metrics for non-autofillable forms.
676 TEST_F(AutofillMetricsTest, NoQualityMetricsForNonAutofillableForms) { 693 TEST_F(AutofillMetricsTest, NoQualityMetricsForNonAutofillableForms) {
677 // Forms must include at least three fields to be auto-fillable. 694 // Forms must include at least three fields to be auto-fillable.
678 FormData form; 695 FormData form;
679 form.name = ASCIIToUTF16("TestForm"); 696 form.name = ASCIIToUTF16("TestForm");
680 form.method = ASCIIToUTF16("POST"); 697 form.method = ASCIIToUTF16("POST");
681 form.origin = GURL("http://example.com/form.html"); 698 form.origin = GURL("http://example.com/form.html");
682 form.action = GURL("http://example.com/submit.html"); 699 form.action = GURL("http://example.com/submit.html");
683 form.user_submitted = true; 700 form.user_submitted = true;
684 701
685 FormField field; 702 FormField field;
686 autofill_test::CreateTestFormField( 703 autofill_test::CreateTestFormField(
687 "Autofilled", "autofilled", "Elvis Presley", "text", &field); 704 "Autofilled", "autofilled", "Elvis Presley", "text", &field);
688 field.is_autofilled = true; 705 field.is_autofilled = true;
689 form.fields.push_back(field); 706 form.fields.push_back(field);
690 autofill_test::CreateTestFormField( 707 autofill_test::CreateTestFormField(
691 "Autofill Failed", "autofillfailed", "buddy@gmail.com", "text", &field); 708 "Autofill Failed", "autofillfailed", "buddy@gmail.com", "text", &field);
692 form.fields.push_back(field); 709 form.fields.push_back(field);
693 710
694 // Simulate form submission. 711 // Simulate form submission.
695 EXPECT_CALL(*autofill_manager_->metric_logger(), 712 EXPECT_CALL(*autofill_manager_->metric_logger(),
696 LogQualityMetric(AutofillMetrics::FIELD_SUBMITTED, 713 LogQualityMetric(AutofillMetrics::FIELD_SUBMITTED,
697 std::string())).Times(0); 714 std::string())).Times(0);
698 EXPECT_NO_FATAL_FAILURE(autofill_manager_->OnFormSubmitted(form)); 715 EXPECT_NO_FATAL_FAILURE(autofill_manager_->OnFormSubmitted(form,
716 TimeTicks::Now()));
699 717
700 // Search forms are not auto-fillable. 718 // Search forms are not auto-fillable.
701 form.action = GURL("http://example.com/search?q=Elvis%20Presley"); 719 form.action = GURL("http://example.com/search?q=Elvis%20Presley");
702 autofill_test::CreateTestFormField( 720 autofill_test::CreateTestFormField(
703 "Empty", "empty", "", "text", &field); 721 "Empty", "empty", "", "text", &field);
704 form.fields.push_back(field); 722 form.fields.push_back(field);
705 723
706 // Simulate form submission. 724 // Simulate form submission.
707 EXPECT_CALL(*autofill_manager_->metric_logger(), 725 EXPECT_CALL(*autofill_manager_->metric_logger(),
708 LogQualityMetric(AutofillMetrics::FIELD_SUBMITTED, 726 LogQualityMetric(AutofillMetrics::FIELD_SUBMITTED,
709 std::string())).Times(0); 727 std::string())).Times(0);
710 EXPECT_NO_FATAL_FAILURE(autofill_manager_->OnFormSubmitted(form)); 728 EXPECT_NO_FATAL_FAILURE(autofill_manager_->OnFormSubmitted(form,
729 TimeTicks::Now()));
711 } 730 }
712 731
713 // Test that we recored the experiment id appropriately. 732 // Test that we recored the experiment id appropriately.
714 TEST_F(AutofillMetricsTest, QualityMetricsWithExperimentId) { 733 TEST_F(AutofillMetricsTest, QualityMetricsWithExperimentId) {
715 // Set up our form data. 734 // Set up our form data.
716 FormData form; 735 FormData form;
717 form.name = ASCIIToUTF16("TestForm"); 736 form.name = ASCIIToUTF16("TestForm");
718 form.method = ASCIIToUTF16("POST"); 737 form.method = ASCIIToUTF16("POST");
719 form.origin = GURL("http://example.com/form.html"); 738 form.origin = GURL("http://example.com/form.html");
720 form.action = GURL("http://example.com/submit.html"); 739 form.action = GURL("http://example.com/submit.html");
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
825 LogHeuristicTypePrediction(AutofillMetrics::TYPE_UNKNOWN, 844 LogHeuristicTypePrediction(AutofillMetrics::TYPE_UNKNOWN,
826 ADDRESS_HOME_COUNTRY, experiment_id)); 845 ADDRESS_HOME_COUNTRY, experiment_id));
827 EXPECT_CALL(*autofill_manager_->metric_logger(), 846 EXPECT_CALL(*autofill_manager_->metric_logger(),
828 LogServerTypePrediction(AutofillMetrics::TYPE_UNKNOWN, 847 LogServerTypePrediction(AutofillMetrics::TYPE_UNKNOWN,
829 ADDRESS_HOME_COUNTRY, experiment_id)); 848 ADDRESS_HOME_COUNTRY, experiment_id));
830 EXPECT_CALL(*autofill_manager_->metric_logger(), 849 EXPECT_CALL(*autofill_manager_->metric_logger(),
831 LogOverallTypePrediction(AutofillMetrics::TYPE_UNKNOWN, 850 LogOverallTypePrediction(AutofillMetrics::TYPE_UNKNOWN,
832 ADDRESS_HOME_COUNTRY, experiment_id)); 851 ADDRESS_HOME_COUNTRY, experiment_id));
833 852
834 // Simulate form submission. 853 // Simulate form submission.
835 EXPECT_NO_FATAL_FAILURE(autofill_manager_->OnFormSubmitted(form)); 854 EXPECT_NO_FATAL_FAILURE(autofill_manager_->OnFormSubmitted(form,
855 TimeTicks::Now()));
836 } 856 }
837 857
838 // Test that the profile count is logged correctly. 858 // Test that the profile count is logged correctly.
839 TEST_F(AutofillMetricsTest, StoredProfileCount) { 859 TEST_F(AutofillMetricsTest, StoredProfileCount) {
840 // The metric should be logged when the profiles are first loaded. 860 // The metric should be logged when the profiles are first loaded.
841 EXPECT_CALL(*test_personal_data_->metric_logger(), 861 EXPECT_CALL(*test_personal_data_->metric_logger(),
842 LogStoredProfileCount(2)).Times(1); 862 LogStoredProfileCount(2)).Times(1);
843 test_personal_data_->LoadProfiles(); 863 test_personal_data_->LoadProfiles();
844 864
845 // The metric should only be logged once. 865 // The metric should only be logged once.
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
930 950
931 // Test that we log whether Autofill is enabled when filling a form. 951 // Test that we log whether Autofill is enabled when filling a form.
932 TEST_F(AutofillMetricsTest, AutofillIsEnabledAtPageLoad) { 952 TEST_F(AutofillMetricsTest, AutofillIsEnabledAtPageLoad) {
933 // Establish our expectations. 953 // Establish our expectations.
934 ::testing::FLAGS_gmock_verbose = "error"; 954 ::testing::FLAGS_gmock_verbose = "error";
935 ::testing::InSequence dummy; 955 ::testing::InSequence dummy;
936 EXPECT_CALL(*autofill_manager_->metric_logger(), 956 EXPECT_CALL(*autofill_manager_->metric_logger(),
937 LogIsAutofillEnabledAtPageLoad(true)).Times(1); 957 LogIsAutofillEnabledAtPageLoad(true)).Times(1);
938 958
939 autofill_manager_->set_autofill_enabled(true); 959 autofill_manager_->set_autofill_enabled(true);
940 autofill_manager_->OnFormsSeen(std::vector<FormData>()); 960 autofill_manager_->OnFormsSeen(std::vector<FormData>(), TimeTicks());
941 961
942 // Reset the autofill manager state. 962 // Reset the autofill manager state.
943 autofill_manager_->Reset(); 963 autofill_manager_->Reset();
944 964
945 // Establish our expectations. 965 // Establish our expectations.
946 EXPECT_CALL(*autofill_manager_->metric_logger(), 966 EXPECT_CALL(*autofill_manager_->metric_logger(),
947 LogIsAutofillEnabledAtPageLoad(false)).Times(1); 967 LogIsAutofillEnabledAtPageLoad(false)).Times(1);
948 968
949 autofill_manager_->set_autofill_enabled(false); 969 autofill_manager_->set_autofill_enabled(false);
950 autofill_manager_->OnFormsSeen(std::vector<FormData>()); 970 autofill_manager_->OnFormsSeen(std::vector<FormData>(), TimeTicks());
951 } 971 }
952 972
953 // Test that credit card infobar metrics are logged correctly. 973 // Test that credit card infobar metrics are logged correctly.
954 TEST_F(AutofillMetricsTest, CreditCardInfoBar) { 974 TEST_F(AutofillMetricsTest, CreditCardInfoBar) {
955 MockAutofillMetrics metric_logger; 975 MockAutofillMetrics metric_logger;
956 ::testing::InSequence dummy; 976 ::testing::InSequence dummy;
957 977
958 // Accept the infobar. 978 // Accept the infobar.
959 { 979 {
960 CreditCard* credit_card; 980 CreditCard* credit_card;
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
1047 form.fields.push_back(field); 1067 form.fields.push_back(field);
1048 autofill_test::CreateTestFormField("Email", "email", "", "text", &field); 1068 autofill_test::CreateTestFormField("Email", "email", "", "text", &field);
1049 form.fields.push_back(field); 1069 form.fields.push_back(field);
1050 1070
1051 std::vector<FormData> forms(1, form); 1071 std::vector<FormData> forms(1, form);
1052 1072
1053 // Expect no notifications when the form is first seen. 1073 // Expect no notifications when the form is first seen.
1054 { 1074 {
1055 EXPECT_CALL(*autofill_manager_->metric_logger(), 1075 EXPECT_CALL(*autofill_manager_->metric_logger(),
1056 LogUserHappinessMetric(AutofillMetrics::FORMS_LOADED)).Times(0); 1076 LogUserHappinessMetric(AutofillMetrics::FORMS_LOADED)).Times(0);
1057 autofill_manager_->OnFormsSeen(forms); 1077 autofill_manager_->OnFormsSeen(forms, TimeTicks());
1058 } 1078 }
1059 1079
1060 1080
1061 // Expect no notifications when the form is submitted. 1081 // Expect no notifications when the form is submitted.
1062 { 1082 {
1063 EXPECT_CALL( 1083 EXPECT_CALL(
1064 *autofill_manager_->metric_logger(), 1084 *autofill_manager_->metric_logger(),
1065 LogUserHappinessMetric( 1085 LogUserHappinessMetric(
1066 AutofillMetrics::SUBMITTED_FILLABLE_FORM_AUTOFILLED_ALL)).Times(0); 1086 AutofillMetrics::SUBMITTED_FILLABLE_FORM_AUTOFILLED_ALL)).Times(0);
1067 EXPECT_CALL( 1087 EXPECT_CALL(
1068 *autofill_manager_->metric_logger(), 1088 *autofill_manager_->metric_logger(),
1069 LogUserHappinessMetric( 1089 LogUserHappinessMetric(
1070 AutofillMetrics::SUBMITTED_FILLABLE_FORM_AUTOFILLED_SOME)).Times(0); 1090 AutofillMetrics::SUBMITTED_FILLABLE_FORM_AUTOFILLED_SOME)).Times(0);
1071 EXPECT_CALL( 1091 EXPECT_CALL(
1072 *autofill_manager_->metric_logger(), 1092 *autofill_manager_->metric_logger(),
1073 LogUserHappinessMetric( 1093 LogUserHappinessMetric(
1074 AutofillMetrics::SUBMITTED_FILLABLE_FORM_AUTOFILLED_NONE)).Times(0); 1094 AutofillMetrics::SUBMITTED_FILLABLE_FORM_AUTOFILLED_NONE)).Times(0);
1075 EXPECT_CALL( 1095 EXPECT_CALL(
1076 *autofill_manager_->metric_logger(), 1096 *autofill_manager_->metric_logger(),
1077 LogUserHappinessMetric( 1097 LogUserHappinessMetric(
1078 AutofillMetrics::SUBMITTED_NON_FILLABLE_FORM)).Times(0); 1098 AutofillMetrics::SUBMITTED_NON_FILLABLE_FORM)).Times(0);
1079 autofill_manager_->OnFormSubmitted(form); 1099 autofill_manager_->OnFormSubmitted(form, TimeTicks::Now());
1080 } 1100 }
1081 1101
1082 // Add more fields to the form. 1102 // Add more fields to the form.
1083 autofill_test::CreateTestFormField("Phone", "phone", "", "text", &field); 1103 autofill_test::CreateTestFormField("Phone", "phone", "", "text", &field);
1084 form.fields.push_back(field); 1104 form.fields.push_back(field);
1085 autofill_test::CreateTestFormField("Unknown", "unknown", "", "text", &field); 1105 autofill_test::CreateTestFormField("Unknown", "unknown", "", "text", &field);
1086 form.fields.push_back(field); 1106 form.fields.push_back(field);
1087 forms.front() = form; 1107 forms.front() = form;
1088 1108
1089 // Expect a notification when the form is first seen. 1109 // Expect a notification when the form is first seen.
1090 { 1110 {
1091 EXPECT_CALL(*autofill_manager_->metric_logger(), 1111 EXPECT_CALL(*autofill_manager_->metric_logger(),
1092 LogUserHappinessMetric(AutofillMetrics::FORMS_LOADED)); 1112 LogUserHappinessMetric(AutofillMetrics::FORMS_LOADED));
1093 autofill_manager_->OnFormsSeen(forms); 1113 autofill_manager_->OnFormsSeen(forms, TimeTicks());
1094 } 1114 }
1095 1115
1096 // Expect a notification when the form is submitted. 1116 // Expect a notification when the form is submitted.
1097 { 1117 {
1098 EXPECT_CALL(*autofill_manager_->metric_logger(), 1118 EXPECT_CALL(*autofill_manager_->metric_logger(),
1099 LogUserHappinessMetric( 1119 LogUserHappinessMetric(
1100 AutofillMetrics::SUBMITTED_NON_FILLABLE_FORM)); 1120 AutofillMetrics::SUBMITTED_NON_FILLABLE_FORM));
1101 autofill_manager_->OnFormSubmitted(form); 1121 autofill_manager_->OnFormSubmitted(form, TimeTicks::Now());
1102 } 1122 }
1103 1123
1104 // Fill in two of the fields. 1124 // Fill in two of the fields.
1105 form.fields[0].value = ASCIIToUTF16("Elvis Aaron Presley"); 1125 form.fields[0].value = ASCIIToUTF16("Elvis Aaron Presley");
1106 form.fields[1].value = ASCIIToUTF16("theking@gmail.com"); 1126 form.fields[1].value = ASCIIToUTF16("theking@gmail.com");
1107 forms.front() = form; 1127 forms.front() = form;
1108 1128
1109 // Expect a notification when the form is submitted. 1129 // Expect a notification when the form is submitted.
1110 { 1130 {
1111 EXPECT_CALL(*autofill_manager_->metric_logger(), 1131 EXPECT_CALL(*autofill_manager_->metric_logger(),
1112 LogUserHappinessMetric( 1132 LogUserHappinessMetric(
1113 AutofillMetrics::SUBMITTED_NON_FILLABLE_FORM)); 1133 AutofillMetrics::SUBMITTED_NON_FILLABLE_FORM));
1114 autofill_manager_->OnFormSubmitted(form); 1134 autofill_manager_->OnFormSubmitted(form, TimeTicks::Now());
1115 } 1135 }
1116 1136
1117 // Fill in the third field. 1137 // Fill in the third field.
1118 form.fields[2].value = ASCIIToUTF16("12345678901"); 1138 form.fields[2].value = ASCIIToUTF16("12345678901");
1119 forms.front() = form; 1139 forms.front() = form;
1120 1140
1121 // Expect notifications when the form is submitted. 1141 // Expect notifications when the form is submitted.
1122 { 1142 {
1123 EXPECT_CALL(*autofill_manager_->metric_logger(), 1143 EXPECT_CALL(*autofill_manager_->metric_logger(),
1124 LogUserHappinessMetric( 1144 LogUserHappinessMetric(
1125 AutofillMetrics::SUBMITTED_FILLABLE_FORM_AUTOFILLED_NONE)); 1145 AutofillMetrics::SUBMITTED_FILLABLE_FORM_AUTOFILLED_NONE));
1126 autofill_manager_->OnFormSubmitted(form); 1146 autofill_manager_->OnFormSubmitted(form, TimeTicks::Now());
1127 } 1147 }
1128 1148
1129 1149
1130 // Mark one of the fields as autofilled. 1150 // Mark one of the fields as autofilled.
1131 form.fields[1].is_autofilled = true; 1151 form.fields[1].is_autofilled = true;
1132 forms.front() = form; 1152 forms.front() = form;
1133 1153
1134 // Expect notifications when the form is submitted. 1154 // Expect notifications when the form is submitted.
1135 { 1155 {
1136 EXPECT_CALL(*autofill_manager_->metric_logger(), 1156 EXPECT_CALL(*autofill_manager_->metric_logger(),
1137 LogUserHappinessMetric( 1157 LogUserHappinessMetric(
1138 AutofillMetrics::SUBMITTED_FILLABLE_FORM_AUTOFILLED_SOME)); 1158 AutofillMetrics::SUBMITTED_FILLABLE_FORM_AUTOFILLED_SOME));
1139 autofill_manager_->OnFormSubmitted(form); 1159 autofill_manager_->OnFormSubmitted(form, TimeTicks::Now());
1140 } 1160 }
1141 1161
1142 // Mark all of the fillable fields as autofilled. 1162 // Mark all of the fillable fields as autofilled.
1143 form.fields[0].is_autofilled = true; 1163 form.fields[0].is_autofilled = true;
1144 form.fields[2].is_autofilled = true; 1164 form.fields[2].is_autofilled = true;
1145 forms.front() = form; 1165 forms.front() = form;
1146 1166
1147 // Expect notifications when the form is submitted. 1167 // Expect notifications when the form is submitted.
1148 { 1168 {
1149 EXPECT_CALL(*autofill_manager_->metric_logger(), 1169 EXPECT_CALL(*autofill_manager_->metric_logger(),
1150 LogUserHappinessMetric( 1170 LogUserHappinessMetric(
1151 AutofillMetrics::SUBMITTED_FILLABLE_FORM_AUTOFILLED_ALL)); 1171 AutofillMetrics::SUBMITTED_FILLABLE_FORM_AUTOFILLED_ALL));
1152 autofill_manager_->OnFormSubmitted(form); 1172 autofill_manager_->OnFormSubmitted(form, TimeTicks::Now());
1153 } 1173 }
1154 1174
1155 // Clear out the third field's value. 1175 // Clear out the third field's value.
1156 form.fields[2].value = string16(); 1176 form.fields[2].value = string16();
1157 forms.front() = form; 1177 forms.front() = form;
1158 1178
1159 // Expect notifications when the form is submitted. 1179 // Expect notifications when the form is submitted.
1160 { 1180 {
1161 EXPECT_CALL(*autofill_manager_->metric_logger(), 1181 EXPECT_CALL(*autofill_manager_->metric_logger(),
1162 LogUserHappinessMetric( 1182 LogUserHappinessMetric(
1163 AutofillMetrics::SUBMITTED_NON_FILLABLE_FORM)); 1183 AutofillMetrics::SUBMITTED_NON_FILLABLE_FORM));
1164 autofill_manager_->OnFormSubmitted(form); 1184 autofill_manager_->OnFormSubmitted(form, TimeTicks::Now());
1165 } 1185 }
1166 } 1186 }
1167 1187
1168 // Verify that we correctly log user happiness metrics dealing with form 1188 // Verify that we correctly log user happiness metrics dealing with form
1169 // interaction. 1189 // interaction.
1170 TEST_F(AutofillMetricsTest, UserHappinessFormInteraction) { 1190 TEST_F(AutofillMetricsTest, UserHappinessFormInteraction) {
1171 // Load a fillable form. 1191 // Load a fillable form.
1172 FormData form; 1192 FormData form;
1173 form.name = ASCIIToUTF16("TestForm"); 1193 form.name = ASCIIToUTF16("TestForm");
1174 form.method = ASCIIToUTF16("POST"); 1194 form.method = ASCIIToUTF16("POST");
1175 form.origin = GURL("http://example.com/form.html"); 1195 form.origin = GURL("http://example.com/form.html");
1176 form.action = GURL("http://example.com/submit.html"); 1196 form.action = GURL("http://example.com/submit.html");
1177 form.user_submitted = true; 1197 form.user_submitted = true;
1178 1198
1179 FormField field; 1199 FormField field;
1180 autofill_test::CreateTestFormField("Name", "name", "", "text", &field); 1200 autofill_test::CreateTestFormField("Name", "name", "", "text", &field);
1181 form.fields.push_back(field); 1201 form.fields.push_back(field);
1182 autofill_test::CreateTestFormField("Email", "email", "", "text", &field); 1202 autofill_test::CreateTestFormField("Email", "email", "", "text", &field);
1183 form.fields.push_back(field); 1203 form.fields.push_back(field);
1184 autofill_test::CreateTestFormField("Phone", "phone", "", "text", &field); 1204 autofill_test::CreateTestFormField("Phone", "phone", "", "text", &field);
1185 form.fields.push_back(field); 1205 form.fields.push_back(field);
1186 1206
1187 std::vector<FormData> forms(1, form); 1207 std::vector<FormData> forms(1, form);
1188 1208
1189 // Expect a notification when the form is first seen. 1209 // Expect a notification when the form is first seen.
1190 { 1210 {
1191 EXPECT_CALL(*autofill_manager_->metric_logger(), 1211 EXPECT_CALL(*autofill_manager_->metric_logger(),
1192 LogUserHappinessMetric(AutofillMetrics::FORMS_LOADED)); 1212 LogUserHappinessMetric(AutofillMetrics::FORMS_LOADED));
1193 autofill_manager_->OnFormsSeen(forms); 1213 autofill_manager_->OnFormsSeen(forms, TimeTicks());
1194 } 1214 }
1195 1215
1196 // Simulate typing. 1216 // Simulate typing.
1197 { 1217 {
1198 EXPECT_CALL(*autofill_manager_->metric_logger(), 1218 EXPECT_CALL(*autofill_manager_->metric_logger(),
1199 LogUserHappinessMetric(AutofillMetrics::USER_DID_TYPE)); 1219 LogUserHappinessMetric(AutofillMetrics::USER_DID_TYPE));
1200 autofill_manager_->OnTextFieldDidChange(form, form.fields.front()); 1220 autofill_manager_->OnTextFieldDidChange(form, form.fields.front(),
1221 TimeTicks());
1201 } 1222 }
1202 1223
1203 // Simulate suggestions shown twice for a single edit (i.e. multiple 1224 // Simulate suggestions shown twice for a single edit (i.e. multiple
1204 // keystrokes in a single field). 1225 // keystrokes in a single field).
1205 { 1226 {
1206 EXPECT_CALL(*autofill_manager_->metric_logger(), 1227 EXPECT_CALL(*autofill_manager_->metric_logger(),
1207 LogUserHappinessMetric( 1228 LogUserHappinessMetric(
1208 AutofillMetrics::SUGGESTIONS_SHOWN)).Times(1); 1229 AutofillMetrics::SUGGESTIONS_SHOWN)).Times(1);
1209 EXPECT_CALL(*autofill_manager_->metric_logger(), 1230 EXPECT_CALL(*autofill_manager_->metric_logger(),
1210 LogUserHappinessMetric( 1231 LogUserHappinessMetric(
(...skipping 12 matching lines...) Expand all
1223 autofill_manager_->OnDidShowAutofillSuggestions(true); 1244 autofill_manager_->OnDidShowAutofillSuggestions(true);
1224 } 1245 }
1225 1246
1226 // Simulate invoking autofill. 1247 // Simulate invoking autofill.
1227 { 1248 {
1228 EXPECT_CALL(*autofill_manager_->metric_logger(), 1249 EXPECT_CALL(*autofill_manager_->metric_logger(),
1229 LogUserHappinessMetric(AutofillMetrics::USER_DID_AUTOFILL)); 1250 LogUserHappinessMetric(AutofillMetrics::USER_DID_AUTOFILL));
1230 EXPECT_CALL(*autofill_manager_->metric_logger(), 1251 EXPECT_CALL(*autofill_manager_->metric_logger(),
1231 LogUserHappinessMetric( 1252 LogUserHappinessMetric(
1232 AutofillMetrics::USER_DID_AUTOFILL_ONCE)); 1253 AutofillMetrics::USER_DID_AUTOFILL_ONCE));
1233 autofill_manager_->OnDidFillAutofillFormData(); 1254 autofill_manager_->OnDidFillAutofillFormData(TimeTicks());
1234 } 1255 }
1235 1256
1236 // Simulate editing an autofilled field. 1257 // Simulate editing an autofilled field.
1237 { 1258 {
1238 EXPECT_CALL(*autofill_manager_->metric_logger(), 1259 EXPECT_CALL(*autofill_manager_->metric_logger(),
1239 LogUserHappinessMetric( 1260 LogUserHappinessMetric(
1240 AutofillMetrics::USER_DID_EDIT_AUTOFILLED_FIELD)); 1261 AutofillMetrics::USER_DID_EDIT_AUTOFILLED_FIELD));
1241 EXPECT_CALL(*autofill_manager_->metric_logger(), 1262 EXPECT_CALL(*autofill_manager_->metric_logger(),
1242 LogUserHappinessMetric( 1263 LogUserHappinessMetric(
1243 AutofillMetrics::USER_DID_EDIT_AUTOFILLED_FIELD_ONCE)); 1264 AutofillMetrics::USER_DID_EDIT_AUTOFILLED_FIELD_ONCE));
1244 AutofillManager::GUIDPair guid("00000000-0000-0000-0000-000000000001", 0); 1265 AutofillManager::GUIDPair guid("00000000-0000-0000-0000-000000000001", 0);
1245 AutofillManager::GUIDPair empty(std::string(), 0); 1266 AutofillManager::GUIDPair empty(std::string(), 0);
1246 autofill_manager_->OnFillAutofillFormData( 1267 autofill_manager_->OnFillAutofillFormData(
1247 0, form, form.fields.front(), 1268 0, form, form.fields.front(),
1248 autofill_manager_->PackGUIDs(empty, guid)); 1269 autofill_manager_->PackGUIDs(empty, guid));
1249 autofill_manager_->OnTextFieldDidChange(form, form.fields.front()); 1270 autofill_manager_->OnTextFieldDidChange(form, form.fields.front(),
1271 TimeTicks());
1250 // Simulate a second keystroke; make sure we don't log the metric twice. 1272 // Simulate a second keystroke; make sure we don't log the metric twice.
1251 autofill_manager_->OnTextFieldDidChange(form, form.fields.front()); 1273 autofill_manager_->OnTextFieldDidChange(form, form.fields.front(),
1274 TimeTicks());
1252 } 1275 }
1253 1276
1254 // Simulate invoking autofill again. 1277 // Simulate invoking autofill again.
1255 EXPECT_CALL(*autofill_manager_->metric_logger(), 1278 EXPECT_CALL(*autofill_manager_->metric_logger(),
1256 LogUserHappinessMetric(AutofillMetrics::USER_DID_AUTOFILL)); 1279 LogUserHappinessMetric(AutofillMetrics::USER_DID_AUTOFILL));
1257 EXPECT_CALL(*autofill_manager_->metric_logger(), 1280 EXPECT_CALL(*autofill_manager_->metric_logger(),
1258 LogUserHappinessMetric( 1281 LogUserHappinessMetric(
1259 AutofillMetrics::USER_DID_AUTOFILL_ONCE)).Times(0); 1282 AutofillMetrics::USER_DID_AUTOFILL_ONCE)).Times(0);
1260 autofill_manager_->OnDidFillAutofillFormData(); 1283 autofill_manager_->OnDidFillAutofillFormData(TimeTicks());
1261 1284
1262 // Simulate editing another autofilled field. 1285 // Simulate editing another autofilled field.
1263 { 1286 {
1264 EXPECT_CALL(*autofill_manager_->metric_logger(), 1287 EXPECT_CALL(*autofill_manager_->metric_logger(),
1265 LogUserHappinessMetric( 1288 LogUserHappinessMetric(
1266 AutofillMetrics::USER_DID_EDIT_AUTOFILLED_FIELD)); 1289 AutofillMetrics::USER_DID_EDIT_AUTOFILLED_FIELD));
1267 autofill_manager_->OnTextFieldDidChange(form, form.fields[1]); 1290 autofill_manager_->OnTextFieldDidChange(form, form.fields[1], TimeTicks());
1268 } 1291 }
1269 } 1292 }
1293
1294 // Verify that we correctly log metrics tracking the duration of form fill.
1295 TEST_F(AutofillMetricsTest, FormFillDuration) {
1296 // Load a fillable form.
1297 FormData form;
1298 form.name = ASCIIToUTF16("TestForm");
1299 form.method = ASCIIToUTF16("POST");
1300 form.origin = GURL("http://example.com/form.html");
1301 form.action = GURL("http://example.com/submit.html");
1302 form.user_submitted = true;
1303
1304 FormField field;
1305 autofill_test::CreateTestFormField("Name", "name", "", "text", &field);
1306 form.fields.push_back(field);
1307 autofill_test::CreateTestFormField("Email", "email", "", "text", &field);
1308 form.fields.push_back(field);
1309 autofill_test::CreateTestFormField("Phone", "phone", "", "text", &field);
1310 form.fields.push_back(field);
1311
1312 std::vector<FormData> forms(1, form);
1313
1314 // Fill the field values for form submission.
1315 form.fields[0].value = ASCIIToUTF16("Elvis Aaron Presley");
1316 form.fields[1].value = ASCIIToUTF16("theking@gmail.com");
1317 form.fields[2].value = ASCIIToUTF16("12345678901");
1318
1319 // Ignore any non-timing metrics.
1320 // CAUTION: This is a global variable. So as to not affect other tests, this
1321 // _must_ be restored to "warning" at the end of the test.
1322 ::testing::FLAGS_gmock_verbose = "error";
1323
1324 // Expect only form load metrics to be logged if the form is submitted without
1325 // user interaction.
1326 {
1327 EXPECT_CALL(*autofill_manager_->metric_logger(),
1328 LogFormFillDurationFromLoadWithAutofill(_)).Times(0);
1329 EXPECT_CALL(*autofill_manager_->metric_logger(),
1330 LogFormFillDurationFromLoadWithoutAutofill(
1331 TimeDelta::FromInternalValue(16)));
1332 EXPECT_CALL(*autofill_manager_->metric_logger(),
1333 LogFormFillDurationFromInteractionWithAutofill(_)).Times(0);
1334 EXPECT_CALL(*autofill_manager_->metric_logger(),
1335 LogFormFillDurationFromInteractionWithoutAutofill(_)).Times(0);
1336 autofill_manager_->OnFormsSeen(forms, TimeTicks::FromInternalValue(1));
1337 autofill_manager_->OnFormSubmitted(form, TimeTicks::FromInternalValue(17));
1338 autofill_manager_->Reset();
1339 Mock::VerifyAndClearExpectations(autofill_manager_->metric_logger());
1340 }
1341
1342 // Expect metric to be logged if the user manually edited a form field.
1343 {
1344 EXPECT_CALL(*autofill_manager_->metric_logger(),
1345 LogFormFillDurationFromLoadWithAutofill(_)).Times(0);
1346 EXPECT_CALL(*autofill_manager_->metric_logger(),
1347 LogFormFillDurationFromLoadWithoutAutofill(
1348 TimeDelta::FromInternalValue(16)));
1349 EXPECT_CALL(*autofill_manager_->metric_logger(),
1350 LogFormFillDurationFromInteractionWithAutofill(_)).Times(0);
1351 EXPECT_CALL(*autofill_manager_->metric_logger(),
1352 LogFormFillDurationFromInteractionWithoutAutofill(
1353 TimeDelta::FromInternalValue(14)));
1354 autofill_manager_->OnFormsSeen(forms, TimeTicks::FromInternalValue(1));
1355 autofill_manager_->OnTextFieldDidChange(form, form.fields.front(),
1356 TimeTicks::FromInternalValue(3));
1357 autofill_manager_->OnFormSubmitted(form, TimeTicks::FromInternalValue(17));
1358 autofill_manager_->Reset();
1359 Mock::VerifyAndClearExpectations(autofill_manager_->metric_logger());
1360 }
1361
1362 // Expect metric to be logged if the user autofilled the form.
1363 form.fields[0].is_autofilled = true;
1364 {
1365 EXPECT_CALL(*autofill_manager_->metric_logger(),
1366 LogFormFillDurationFromLoadWithAutofill(
1367 TimeDelta::FromInternalValue(16)));
1368 EXPECT_CALL(*autofill_manager_->metric_logger(),
1369 LogFormFillDurationFromLoadWithoutAutofill(_)).Times(0);
1370 EXPECT_CALL(*autofill_manager_->metric_logger(),
1371 LogFormFillDurationFromInteractionWithAutofill(
1372 TimeDelta::FromInternalValue(12)));
1373 EXPECT_CALL(*autofill_manager_->metric_logger(),
1374 LogFormFillDurationFromInteractionWithoutAutofill(_)).Times(0);
1375 autofill_manager_->OnFormsSeen(forms, TimeTicks::FromInternalValue(1));
1376 autofill_manager_->OnDidFillAutofillFormData(
1377 TimeTicks::FromInternalValue(5));
1378 autofill_manager_->OnFormSubmitted(form, TimeTicks::FromInternalValue(17));
1379 autofill_manager_->Reset();
1380 Mock::VerifyAndClearExpectations(autofill_manager_->metric_logger());
1381 }
1382
1383 // Expect metric to be logged if the user both manually filled some fields
1384 // and autofilled others. Messages can arrive out of order, so make sure they
1385 // take precedence appropriately.
1386 {
1387 EXPECT_CALL(*autofill_manager_->metric_logger(),
1388 LogFormFillDurationFromLoadWithAutofill(
1389 TimeDelta::FromInternalValue(16)));
1390 EXPECT_CALL(*autofill_manager_->metric_logger(),
1391 LogFormFillDurationFromLoadWithoutAutofill(_)).Times(0);
1392 EXPECT_CALL(*autofill_manager_->metric_logger(),
1393 LogFormFillDurationFromInteractionWithAutofill(
1394 TimeDelta::FromInternalValue(14)));
1395 EXPECT_CALL(*autofill_manager_->metric_logger(),
1396 LogFormFillDurationFromInteractionWithoutAutofill(_)).Times(0);
1397 autofill_manager_->OnFormsSeen(forms, TimeTicks::FromInternalValue(1));
1398 autofill_manager_->OnDidFillAutofillFormData(
1399 TimeTicks::FromInternalValue(5));
1400 autofill_manager_->OnTextFieldDidChange(form, form.fields.front(),
1401 TimeTicks::FromInternalValue(3));
1402 autofill_manager_->OnFormSubmitted(form, TimeTicks::FromInternalValue(17));
1403 autofill_manager_->Reset();
1404 Mock::VerifyAndClearExpectations(autofill_manager_->metric_logger());
1405 }
1406
1407 // Restore the global Gmock verbosity level to its default value.
1408 ::testing::FLAGS_gmock_verbose = "warning";
1409 }
OLDNEW
« no previous file with comments | « chrome/browser/autofill/autofill_metrics.cc ('k') | chrome/browser/autofill/autofill_type.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698