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