| OLD | NEW |
| 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/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
| 8 #include "base/string16.h" | 8 #include "base/string16.h" |
| 9 #include "base/time.h" | 9 #include "base/time.h" |
| 10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
| (...skipping 958 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 969 autofill_manager_->AddSeenForm(form, field_types, field_types, | 969 autofill_manager_->AddSeenForm(form, field_types, field_types, |
| 970 std::string()); | 970 std::string()); |
| 971 | 971 |
| 972 // Establish our expectations. | 972 // Establish our expectations. |
| 973 ::testing::FLAGS_gmock_verbose = "error"; | 973 ::testing::FLAGS_gmock_verbose = "error"; |
| 974 ::testing::InSequence dummy; | 974 ::testing::InSequence dummy; |
| 975 EXPECT_CALL(*autofill_manager_->metric_logger(), | 975 EXPECT_CALL(*autofill_manager_->metric_logger(), |
| 976 LogAddressSuggestionsCount(2)).Times(1); | 976 LogAddressSuggestionsCount(2)).Times(1); |
| 977 | 977 |
| 978 // Simulate activating the autofill popup for the phone field. | 978 // Simulate activating the autofill popup for the phone field. |
| 979 autofill_manager_->OnQueryFormFieldAutofill(0, form, field); | 979 autofill_manager_->OnQueryFormFieldAutofill(0, form, field, false); |
| 980 | 980 |
| 981 // Simulate activating the autofill popup for the email field after typing. | 981 // Simulate activating the autofill popup for the email field after typing. |
| 982 // No new metric should be logged, since we're still on the same page. | 982 // No new metric should be logged, since we're still on the same page. |
| 983 autofill_test::CreateTestFormField("Email", "email", "b", "email", &field); | 983 autofill_test::CreateTestFormField("Email", "email", "b", "email", &field); |
| 984 autofill_manager_->OnQueryFormFieldAutofill(0, form, field); | 984 autofill_manager_->OnQueryFormFieldAutofill(0, form, field, false); |
| 985 | 985 |
| 986 // Reset the autofill manager state. | 986 // Reset the autofill manager state. |
| 987 autofill_manager_->Reset(); | 987 autofill_manager_->Reset(); |
| 988 autofill_manager_->AddSeenForm(form, field_types, field_types, | 988 autofill_manager_->AddSeenForm(form, field_types, field_types, |
| 989 std::string()); | 989 std::string()); |
| 990 | 990 |
| 991 // Establish our expectations. | 991 // Establish our expectations. |
| 992 EXPECT_CALL(*autofill_manager_->metric_logger(), | 992 EXPECT_CALL(*autofill_manager_->metric_logger(), |
| 993 LogAddressSuggestionsCount(1)).Times(1); | 993 LogAddressSuggestionsCount(1)).Times(1); |
| 994 | 994 |
| 995 // Simulate activating the autofill popup for the email field after typing. | 995 // Simulate activating the autofill popup for the email field after typing. |
| 996 autofill_manager_->OnQueryFormFieldAutofill(0, form, field); | 996 autofill_manager_->OnQueryFormFieldAutofill(0, form, field, false); |
| 997 | 997 |
| 998 // Reset the autofill manager state again. | 998 // Reset the autofill manager state again. |
| 999 autofill_manager_->Reset(); | 999 autofill_manager_->Reset(); |
| 1000 autofill_manager_->AddSeenForm(form, field_types, field_types, | 1000 autofill_manager_->AddSeenForm(form, field_types, field_types, |
| 1001 std::string()); | 1001 std::string()); |
| 1002 | 1002 |
| 1003 // Establish our expectations. | 1003 // Establish our expectations. |
| 1004 EXPECT_CALL(*autofill_manager_->metric_logger(), | 1004 EXPECT_CALL(*autofill_manager_->metric_logger(), |
| 1005 LogAddressSuggestionsCount(::testing::_)).Times(0); | 1005 LogAddressSuggestionsCount(::testing::_)).Times(0); |
| 1006 | 1006 |
| 1007 // Simulate activating the autofill popup for the email field after typing. | 1007 // Simulate activating the autofill popup for the email field after typing. |
| 1008 form.fields[0].is_autofilled = true; | 1008 form.fields[0].is_autofilled = true; |
| 1009 autofill_manager_->OnQueryFormFieldAutofill(0, form, field); | 1009 autofill_manager_->OnQueryFormFieldAutofill(0, form, field, false); |
| 1010 } | 1010 } |
| 1011 | 1011 |
| 1012 // Test that we log whether Autofill is enabled when filling a form. | 1012 // Test that we log whether Autofill is enabled when filling a form. |
| 1013 TEST_F(AutofillMetricsTest, AutofillIsEnabledAtPageLoad) { | 1013 TEST_F(AutofillMetricsTest, AutofillIsEnabledAtPageLoad) { |
| 1014 // Establish our expectations. | 1014 // Establish our expectations. |
| 1015 ::testing::FLAGS_gmock_verbose = "error"; | 1015 ::testing::FLAGS_gmock_verbose = "error"; |
| 1016 ::testing::InSequence dummy; | 1016 ::testing::InSequence dummy; |
| 1017 EXPECT_CALL(*autofill_manager_->metric_logger(), | 1017 EXPECT_CALL(*autofill_manager_->metric_logger(), |
| 1018 LogIsAutofillEnabledAtPageLoad(true)).Times(1); | 1018 LogIsAutofillEnabledAtPageLoad(true)).Times(1); |
| 1019 | 1019 |
| (...skipping 440 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1460 autofill_manager_->OnTextFieldDidChange(form, form.fields.front(), | 1460 autofill_manager_->OnTextFieldDidChange(form, form.fields.front(), |
| 1461 TimeTicks::FromInternalValue(3)); | 1461 TimeTicks::FromInternalValue(3)); |
| 1462 autofill_manager_->FormSubmitted(form, TimeTicks::FromInternalValue(17)); | 1462 autofill_manager_->FormSubmitted(form, TimeTicks::FromInternalValue(17)); |
| 1463 autofill_manager_->Reset(); | 1463 autofill_manager_->Reset(); |
| 1464 Mock::VerifyAndClearExpectations(autofill_manager_->metric_logger()); | 1464 Mock::VerifyAndClearExpectations(autofill_manager_->metric_logger()); |
| 1465 } | 1465 } |
| 1466 | 1466 |
| 1467 // Restore the global Gmock verbosity level to its default value. | 1467 // Restore the global Gmock verbosity level to its default value. |
| 1468 ::testing::FLAGS_gmock_verbose = "warning"; | 1468 ::testing::FLAGS_gmock_verbose = "warning"; |
| 1469 } | 1469 } |
| OLD | NEW |