| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/time.h" |
| 11 #include "base/utf_string_conversions.h" | 11 #include "base/utf_string_conversions.h" |
| 12 #include "chrome/browser/autofill/autofill_cc_infobar_delegate.h" | 12 #include "chrome/browser/autofill/autofill_cc_infobar_delegate.h" |
| 13 #include "chrome/browser/autofill/personal_data_manager_factory.h" | 13 #include "chrome/browser/autofill/personal_data_manager_factory.h" |
| 14 #include "chrome/browser/ui/autofill/tab_autofill_manager_delegate.h" | 14 #include "chrome/browser/ui/autofill/tab_autofill_manager_delegate.h" |
| 15 #include "chrome/browser/webdata/web_data_service_factory.h" |
| 15 #include "chrome/test/base/chrome_render_view_host_test_harness.h" | 16 #include "chrome/test/base/chrome_render_view_host_test_harness.h" |
| 16 #include "chrome/test/base/testing_profile.h" | 17 #include "chrome/test/base/testing_profile.h" |
| 17 #include "components/autofill/browser/autocheckout_page_meta_data.h" | 18 #include "components/autofill/browser/autocheckout_page_meta_data.h" |
| 18 #include "components/autofill/browser/autofill_common_test.h" | 19 #include "components/autofill/browser/autofill_common_test.h" |
| 19 #include "components/autofill/browser/autofill_manager.h" | 20 #include "components/autofill/browser/autofill_manager.h" |
| 20 #include "components/autofill/browser/autofill_manager_delegate.h" | 21 #include "components/autofill/browser/autofill_manager_delegate.h" |
| 21 #include "components/autofill/browser/autofill_metrics.h" | 22 #include "components/autofill/browser/autofill_metrics.h" |
| 22 #include "components/autofill/browser/personal_data_manager.h" | 23 #include "components/autofill/browser/personal_data_manager.h" |
| 24 #include "components/autofill/browser/webdata/autofill_webdata_service.h" |
| 23 #include "components/autofill/common/form_data.h" | 25 #include "components/autofill/common/form_data.h" |
| 24 #include "components/autofill/common/form_field_data.h" | 26 #include "components/autofill/common/form_field_data.h" |
| 25 #include "components/webdata/common/web_data_results.h" | 27 #include "components/webdata/common/web_data_results.h" |
| 26 #include "content/public/test/test_browser_thread.h" | 28 #include "content/public/test/test_browser_thread.h" |
| 27 #include "content/public/test/test_utils.h" | 29 #include "content/public/test/test_utils.h" |
| 28 #include "googleurl/src/gurl.h" | 30 #include "googleurl/src/gurl.h" |
| 29 #include "testing/gmock/include/gmock/gmock.h" | 31 #include "testing/gmock/include/gmock/gmock.h" |
| 30 #include "testing/gtest/include/gtest/gtest.h" | 32 #include "testing/gtest/include/gtest/gtest.h" |
| 31 #include "ui/gfx/rect.h" | 33 #include "ui/gfx/rect.h" |
| 32 | 34 |
| (...skipping 974 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1007 EXPECT_CALL(*personal_data_->metric_logger(), | 1009 EXPECT_CALL(*personal_data_->metric_logger(), |
| 1008 LogStoredProfileCount(::testing::_)).Times(0); | 1010 LogStoredProfileCount(::testing::_)).Times(0); |
| 1009 personal_data_->LoadProfiles(); | 1011 personal_data_->LoadProfiles(); |
| 1010 } | 1012 } |
| 1011 | 1013 |
| 1012 // Test that we correctly log when Autofill is enabled. | 1014 // Test that we correctly log when Autofill is enabled. |
| 1013 TEST_F(AutofillMetricsTest, AutofillIsEnabledAtStartup) { | 1015 TEST_F(AutofillMetricsTest, AutofillIsEnabledAtStartup) { |
| 1014 personal_data_->set_autofill_enabled(true); | 1016 personal_data_->set_autofill_enabled(true); |
| 1015 EXPECT_CALL(*personal_data_->metric_logger(), | 1017 EXPECT_CALL(*personal_data_->metric_logger(), |
| 1016 LogIsAutofillEnabledAtStartup(true)).Times(1); | 1018 LogIsAutofillEnabledAtStartup(true)).Times(1); |
| 1017 personal_data_->Init(profile()); | 1019 personal_data_->Init( |
| 1020 profile(), |
| 1021 WebDataServiceFactory::GetAutofillWebDataServiceForProfile(profile())); |
| 1018 } | 1022 } |
| 1019 | 1023 |
| 1020 // Test that we correctly log when Autofill is disabled. | 1024 // Test that we correctly log when Autofill is disabled. |
| 1021 TEST_F(AutofillMetricsTest, AutofillIsDisabledAtStartup) { | 1025 TEST_F(AutofillMetricsTest, AutofillIsDisabledAtStartup) { |
| 1022 personal_data_->set_autofill_enabled(false); | 1026 personal_data_->set_autofill_enabled(false); |
| 1023 EXPECT_CALL(*personal_data_->metric_logger(), | 1027 EXPECT_CALL(*personal_data_->metric_logger(), |
| 1024 LogIsAutofillEnabledAtStartup(false)).Times(1); | 1028 LogIsAutofillEnabledAtStartup(false)).Times(1); |
| 1025 personal_data_->Init(profile()); | 1029 personal_data_->Init( |
| 1030 profile(), |
| 1031 WebDataServiceFactory::GetAutofillWebDataServiceForProfile(profile())); |
| 1026 } | 1032 } |
| 1027 | 1033 |
| 1028 // Test that we log the number of Autofill suggestions when filling a form. | 1034 // Test that we log the number of Autofill suggestions when filling a form. |
| 1029 TEST_F(AutofillMetricsTest, AddressSuggestionsCount) { | 1035 TEST_F(AutofillMetricsTest, AddressSuggestionsCount) { |
| 1030 // Set up our form data. | 1036 // Set up our form data. |
| 1031 FormData form; | 1037 FormData form; |
| 1032 form.name = ASCIIToUTF16("TestForm"); | 1038 form.name = ASCIIToUTF16("TestForm"); |
| 1033 form.method = ASCIIToUTF16("POST"); | 1039 form.method = ASCIIToUTF16("POST"); |
| 1034 form.origin = GURL("http://example.com/form.html"); | 1040 form.origin = GURL("http://example.com/form.html"); |
| 1035 form.action = GURL("http://example.com/submit.html"); | 1041 form.action = GURL("http://example.com/submit.html"); |
| (...skipping 515 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1551 TimeTicks::FromInternalValue(5)); | 1557 TimeTicks::FromInternalValue(5)); |
| 1552 autofill_manager_->OnTextFieldDidChange(form, form.fields.front(), | 1558 autofill_manager_->OnTextFieldDidChange(form, form.fields.front(), |
| 1553 TimeTicks::FromInternalValue(3)); | 1559 TimeTicks::FromInternalValue(3)); |
| 1554 autofill_manager_->FormSubmitted(form, TimeTicks::FromInternalValue(17)); | 1560 autofill_manager_->FormSubmitted(form, TimeTicks::FromInternalValue(17)); |
| 1555 autofill_manager_->Reset(); | 1561 autofill_manager_->Reset(); |
| 1556 Mock::VerifyAndClearExpectations(autofill_manager_->metric_logger()); | 1562 Mock::VerifyAndClearExpectations(autofill_manager_->metric_logger()); |
| 1557 } | 1563 } |
| 1558 } | 1564 } |
| 1559 | 1565 |
| 1560 } // namespace autofill | 1566 } // namespace autofill |
| OLD | NEW |