| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/macros.h" | 11 #include "base/macros.h" |
| 12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
| 13 #include "base/run_loop.h" | 13 #include "base/run_loop.h" |
| 14 #include "base/strings/string16.h" | 14 #include "base/strings/string16.h" |
| 15 #include "base/strings/utf_string_conversions.h" | 15 #include "base/strings/utf_string_conversions.h" |
| 16 #include "base/test/histogram_tester.h" | 16 #include "base/test/histogram_tester.h" |
| 17 #include "base/time/time.h" | 17 #include "base/time/time.h" |
| 18 #include "components/autofill/core/browser/autofill_external_delegate.h" | 18 #include "components/autofill/core/browser/autofill_external_delegate.h" |
| 19 #include "components/autofill/core/browser/autofill_manager.h" | 19 #include "components/autofill/core/browser/autofill_manager.h" |
| 20 #include "components/autofill/core/browser/autofill_test_utils.h" | 20 #include "components/autofill/core/browser/autofill_test_utils.h" |
| 21 #include "components/autofill/core/browser/payments/payments_client.h" | 21 #include "components/autofill/core/browser/payments/payments_client.h" |
| 22 #include "components/autofill/core/browser/personal_data_manager.h" | 22 #include "components/autofill/core/browser/personal_data_manager.h" |
| 23 #include "components/autofill/core/browser/test_autofill_client.h" | 23 #include "components/autofill/core/browser/test_autofill_client.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/autofill_pref_names.h" | |
| 27 #include "components/autofill/core/common/form_data.h" | 26 #include "components/autofill/core/common/form_data.h" |
| 28 #include "components/autofill/core/common/form_field_data.h" | 27 #include "components/autofill/core/common/form_field_data.h" |
| 29 #include "components/prefs/pref_service.h" | 28 #include "components/prefs/pref_service.h" |
| 30 #include "components/rappor/test_rappor_service.h" | 29 #include "components/rappor/test_rappor_service.h" |
| 31 #include "components/signin/core/browser/account_tracker_service.h" | 30 #include "components/signin/core/browser/account_tracker_service.h" |
| 32 #include "components/signin/core/browser/fake_signin_manager.h" | 31 #include "components/signin/core/browser/fake_signin_manager.h" |
| 33 #include "components/signin/core/browser/test_signin_client.h" | 32 #include "components/signin/core/browser/test_signin_client.h" |
| 34 #include "components/signin/core/common/signin_pref_names.h" | 33 #include "components/signin/core/common/signin_pref_names.h" |
| 35 #include "components/webdata/common/web_data_results.h" | 34 #include "components/webdata/common/web_data_results.h" |
| 36 #include "testing/gmock/include/gmock/gmock.h" | 35 #include "testing/gmock/include/gmock/gmock.h" |
| (...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 364 autofill_driver_.reset(); | 363 autofill_driver_.reset(); |
| 365 personal_data_.reset(); | 364 personal_data_.reset(); |
| 366 signin_manager_->Shutdown(); | 365 signin_manager_->Shutdown(); |
| 367 signin_manager_.reset(); | 366 signin_manager_.reset(); |
| 368 account_tracker_->Shutdown(); | 367 account_tracker_->Shutdown(); |
| 369 account_tracker_.reset(); | 368 account_tracker_.reset(); |
| 370 signin_client_.reset(); | 369 signin_client_.reset(); |
| 371 } | 370 } |
| 372 | 371 |
| 373 void AutofillMetricsTest::EnableWalletSync() { | 372 void AutofillMetricsTest::EnableWalletSync() { |
| 374 autofill_client_.GetPrefs()->SetBoolean( | |
| 375 prefs::kAutofillWalletSyncExperimentEnabled, true); | |
| 376 signin_manager_->SetAuthenticatedAccountInfo("12345", "syncuser@example.com"); | 373 signin_manager_->SetAuthenticatedAccountInfo("12345", "syncuser@example.com"); |
| 377 } | 374 } |
| 378 | 375 |
| 379 // Test that we log quality metrics appropriately. | 376 // Test that we log quality metrics appropriately. |
| 380 TEST_F(AutofillMetricsTest, QualityMetrics) { | 377 TEST_F(AutofillMetricsTest, QualityMetrics) { |
| 381 // Set up our form data. | 378 // Set up our form data. |
| 382 FormData form; | 379 FormData form; |
| 383 form.name = ASCIIToUTF16("TestForm"); | 380 form.name = ASCIIToUTF16("TestForm"); |
| 384 form.origin = GURL("http://example.com/form.html"); | 381 form.origin = GURL("http://example.com/form.html"); |
| 385 form.action = GURL("http://example.com/submit.html"); | 382 form.action = GURL("http://example.com/submit.html"); |
| (...skipping 1260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1646 AutofillMetrics::FORM_EVENT_MASKED_SERVER_CARD_SUGGESTION_SELECTED, 2); | 1643 AutofillMetrics::FORM_EVENT_MASKED_SERVER_CARD_SUGGESTION_SELECTED, 2); |
| 1647 histogram_tester.ExpectBucketCount( | 1644 histogram_tester.ExpectBucketCount( |
| 1648 "Autofill.FormEvents.CreditCard", | 1645 "Autofill.FormEvents.CreditCard", |
| 1649 AutofillMetrics::FORM_EVENT_MASKED_SERVER_CARD_SUGGESTION_SELECTED_ONCE, | 1646 AutofillMetrics::FORM_EVENT_MASKED_SERVER_CARD_SUGGESTION_SELECTED_ONCE, |
| 1650 1); | 1647 1); |
| 1651 } | 1648 } |
| 1652 } | 1649 } |
| 1653 | 1650 |
| 1654 // Test that we log filled form events for credit cards. | 1651 // Test that we log filled form events for credit cards. |
| 1655 TEST_F(AutofillMetricsTest, CreditCardFilledFormEvents) { | 1652 TEST_F(AutofillMetricsTest, CreditCardFilledFormEvents) { |
| 1656 autofill_client_.GetPrefs()->SetBoolean( | |
| 1657 prefs::kAutofillWalletSyncExperimentEnabled, true); | |
| 1658 // Creating all kinds of cards. | 1653 // Creating all kinds of cards. |
| 1659 personal_data_->RecreateCreditCards( | 1654 personal_data_->RecreateCreditCards( |
| 1660 true /* include_local_credit_card */, | 1655 true /* include_local_credit_card */, |
| 1661 true /* include_masked_server_credit_card */, | 1656 true /* include_masked_server_credit_card */, |
| 1662 true /* include_full_server_credit_card */); | 1657 true /* include_full_server_credit_card */); |
| 1663 // Set up our form data. | 1658 // Set up our form data. |
| 1664 FormData form; | 1659 FormData form; |
| 1665 form.name = ASCIIToUTF16("TestForm"); | 1660 form.name = ASCIIToUTF16("TestForm"); |
| 1666 form.origin = GURL("http://example.com/form.html"); | 1661 form.origin = GURL("http://example.com/form.html"); |
| 1667 form.action = GURL("http://example.com/submit.html"); | 1662 form.action = GURL("http://example.com/submit.html"); |
| (...skipping 1922 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3590 EXPECT_THAT( | 3585 EXPECT_THAT( |
| 3591 histogram_tester.GetAllSamples("Autofill.ServerResponseHasDataForForm"), | 3586 histogram_tester.GetAllSamples("Autofill.ServerResponseHasDataForForm"), |
| 3592 ElementsAre(Bucket(true, 2))); | 3587 ElementsAre(Bucket(true, 2))); |
| 3593 | 3588 |
| 3594 // No RAPPOR metrics are logged in the case there is at least some server data | 3589 // No RAPPOR metrics are logged in the case there is at least some server data |
| 3595 // available for all forms. | 3590 // available for all forms. |
| 3596 EXPECT_EQ(0, rappor_service_.GetReportsCount()); | 3591 EXPECT_EQ(0, rappor_service_.GetReportsCount()); |
| 3597 } | 3592 } |
| 3598 | 3593 |
| 3599 } // namespace autofill | 3594 } // namespace autofill |
| OLD | NEW |