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" |
(...skipping 12 matching lines...) Expand all Loading... |
23 #include "components/autofill/core/browser/personal_data_manager.h" | 23 #include "components/autofill/core/browser/personal_data_manager.h" |
24 #include "components/autofill/core/browser/test_autofill_driver.h" | 24 #include "components/autofill/core/browser/test_autofill_driver.h" |
25 #include "components/autofill/core/browser/webdata/autofill_webdata_service.h" | 25 #include "components/autofill/core/browser/webdata/autofill_webdata_service.h" |
26 #include "components/autofill/core/common/form_data.h" | 26 #include "components/autofill/core/common/form_data.h" |
27 #include "components/autofill/core/common/form_field_data.h" | 27 #include "components/autofill/core/common/form_field_data.h" |
28 #include "components/autofill/core/common/forms_seen_state.h" | 28 #include "components/autofill/core/common/forms_seen_state.h" |
29 #include "components/webdata/common/web_data_results.h" | 29 #include "components/webdata/common/web_data_results.h" |
30 #include "content/public/test/test_utils.h" | 30 #include "content/public/test/test_utils.h" |
31 #include "testing/gmock/include/gmock/gmock.h" | 31 #include "testing/gmock/include/gmock/gmock.h" |
32 #include "testing/gtest/include/gtest/gtest.h" | 32 #include "testing/gtest/include/gtest/gtest.h" |
| 33 #include "third_party/WebKit/public/web/WebFormElement.h" |
33 #include "ui/gfx/rect.h" | 34 #include "ui/gfx/rect.h" |
34 #include "url/gurl.h" | 35 #include "url/gurl.h" |
35 | 36 |
36 using base::TimeDelta; | 37 using base::TimeDelta; |
37 using base::TimeTicks; | 38 using base::TimeTicks; |
38 using testing::_; | 39 using testing::_; |
39 using testing::AnyNumber; | 40 using testing::AnyNumber; |
40 using testing::Mock; | 41 using testing::Mock; |
41 | 42 |
42 namespace autofill { | 43 namespace autofill { |
(...skipping 1005 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1048 // Simulate having seen this form on page load. | 1049 // Simulate having seen this form on page load. |
1049 // |form_structure| will be owned by |autofill_manager_|. | 1050 // |form_structure| will be owned by |autofill_manager_|. |
1050 autofill_manager_->AddSeenForm(form, field_types, field_types, | 1051 autofill_manager_->AddSeenForm(form, field_types, field_types, |
1051 std::string()); | 1052 std::string()); |
1052 | 1053 |
1053 // Establish our expectations. | 1054 // Establish our expectations. |
1054 ::testing::InSequence dummy; | 1055 ::testing::InSequence dummy; |
1055 EXPECT_CALL(*autofill_manager_->metric_logger(), | 1056 EXPECT_CALL(*autofill_manager_->metric_logger(), |
1056 LogAddressSuggestionsCount(2)).Times(1); | 1057 LogAddressSuggestionsCount(2)).Times(1); |
1057 | 1058 |
| 1059 blink::WebFormElement webformelement; |
1058 // Simulate activating the autofill popup for the phone field. | 1060 // Simulate activating the autofill popup for the phone field. |
1059 autofill_manager_->OnQueryFormFieldAutofill( | 1061 autofill_manager_->OnQueryFormFieldAutofill( |
1060 0, form, field, gfx::Rect(), false); | 1062 0, form, field, webformelement, gfx::Rect(), false); |
1061 | 1063 |
1062 // Simulate activating the autofill popup for the email field after typing. | 1064 // Simulate activating the autofill popup for the email field after typing. |
1063 // No new metric should be logged, since we're still on the same page. | 1065 // No new metric should be logged, since we're still on the same page. |
1064 test::CreateTestFormField("Email", "email", "b", "email", &field); | 1066 test::CreateTestFormField("Email", "email", "b", "email", &field); |
1065 autofill_manager_->OnQueryFormFieldAutofill( | 1067 autofill_manager_->OnQueryFormFieldAutofill( |
1066 0, form, field, gfx::Rect(), false); | 1068 0, form, field, webformelement, gfx::Rect(), false); |
1067 | 1069 |
1068 // Reset the autofill manager state. | 1070 // Reset the autofill manager state. |
1069 autofill_manager_->Reset(); | 1071 autofill_manager_->Reset(); |
1070 autofill_manager_->AddSeenForm(form, field_types, field_types, | 1072 autofill_manager_->AddSeenForm(form, field_types, field_types, |
1071 std::string()); | 1073 std::string()); |
1072 | 1074 |
1073 // Establish our expectations. | 1075 // Establish our expectations. |
1074 EXPECT_CALL(*autofill_manager_->metric_logger(), | 1076 EXPECT_CALL(*autofill_manager_->metric_logger(), |
1075 LogAddressSuggestionsCount(1)).Times(1); | 1077 LogAddressSuggestionsCount(1)).Times(1); |
1076 | 1078 |
1077 // Simulate activating the autofill popup for the email field after typing. | 1079 // Simulate activating the autofill popup for the email field after typing. |
1078 autofill_manager_->OnQueryFormFieldAutofill( | 1080 autofill_manager_->OnQueryFormFieldAutofill( |
1079 0, form, field, gfx::Rect(), false); | 1081 0, form, field, webformelement, gfx::Rect(), false); |
1080 | 1082 |
1081 // Reset the autofill manager state again. | 1083 // Reset the autofill manager state again. |
1082 autofill_manager_->Reset(); | 1084 autofill_manager_->Reset(); |
1083 autofill_manager_->AddSeenForm(form, field_types, field_types, | 1085 autofill_manager_->AddSeenForm(form, field_types, field_types, |
1084 std::string()); | 1086 std::string()); |
1085 | 1087 |
1086 // Establish our expectations. | 1088 // Establish our expectations. |
1087 EXPECT_CALL(*autofill_manager_->metric_logger(), | 1089 EXPECT_CALL(*autofill_manager_->metric_logger(), |
1088 LogAddressSuggestionsCount(::testing::_)).Times(0); | 1090 LogAddressSuggestionsCount(::testing::_)).Times(0); |
1089 | 1091 |
1090 // Simulate activating the autofill popup for the email field after typing. | 1092 // Simulate activating the autofill popup for the email field after typing. |
1091 form.fields[0].is_autofilled = true; | 1093 form.fields[0].is_autofilled = true; |
1092 autofill_manager_->OnQueryFormFieldAutofill( | 1094 autofill_manager_->OnQueryFormFieldAutofill( |
1093 0, form, field, gfx::Rect(), false); | 1095 0, form, webformelement, field, webformelement, gfx::Rect(), false); |
1094 } | 1096 } |
1095 | 1097 |
1096 // Test that we log whether Autofill is enabled when filling a form. | 1098 // Test that we log whether Autofill is enabled when filling a form. |
1097 TEST_F(AutofillMetricsTest, AutofillIsEnabledAtPageLoad) { | 1099 TEST_F(AutofillMetricsTest, AutofillIsEnabledAtPageLoad) { |
1098 // Establish our expectations. | 1100 // Establish our expectations. |
1099 ::testing::InSequence dummy; | 1101 ::testing::InSequence dummy; |
1100 EXPECT_CALL(*autofill_manager_->metric_logger(), | 1102 EXPECT_CALL(*autofill_manager_->metric_logger(), |
1101 LogIsAutofillEnabledAtPageLoad(true)).Times(1); | 1103 LogIsAutofillEnabledAtPageLoad(true)).Times(1); |
1102 | 1104 |
1103 autofill_manager_->set_autofill_enabled(true); | 1105 autofill_manager_->set_autofill_enabled(true); |
(...skipping 451 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1555 TimeTicks::FromInternalValue(5)); | 1557 TimeTicks::FromInternalValue(5)); |
1556 autofill_manager_->OnTextFieldDidChange(form, form.fields.front(), | 1558 autofill_manager_->OnTextFieldDidChange(form, form.fields.front(), |
1557 TimeTicks::FromInternalValue(3)); | 1559 TimeTicks::FromInternalValue(3)); |
1558 autofill_manager_->FormSubmitted(form, TimeTicks::FromInternalValue(17)); | 1560 autofill_manager_->FormSubmitted(form, TimeTicks::FromInternalValue(17)); |
1559 autofill_manager_->Reset(); | 1561 autofill_manager_->Reset(); |
1560 Mock::VerifyAndClearExpectations(autofill_manager_->metric_logger()); | 1562 Mock::VerifyAndClearExpectations(autofill_manager_->metric_logger()); |
1561 } | 1563 } |
1562 } | 1564 } |
1563 | 1565 |
1564 } // namespace autofill | 1566 } // namespace autofill |
OLD | NEW |