Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(176)

Side by Side Diff: components/autofill/core/browser/autofill_metrics_unittest.cc

Issue 2395243002: [Autofill] Log count histogram for the number of server cards (Closed)
Patch Set: addressed nits Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 <memory> 9 #include <memory>
10 #include <vector> 10 #include <vector>
(...skipping 1495 matching lines...) Expand 10 before | Expand all | Expand 10 after
1506 { 1506 {
1507 base::HistogramTester histogram_tester; 1507 base::HistogramTester histogram_tester;
1508 personal_data_->RecreateCreditCards( 1508 personal_data_->RecreateCreditCards(
1509 true /* include_local_credit_card */, 1509 true /* include_local_credit_card */,
1510 false /* include_masked_server_credit_card */, 1510 false /* include_masked_server_credit_card */,
1511 false /* include_full_server_credit_card */); 1511 false /* include_full_server_credit_card */);
1512 histogram_tester.ExpectTotalCount("Autofill.StoredLocalCreditCardCount", 0); 1512 histogram_tester.ExpectTotalCount("Autofill.StoredLocalCreditCardCount", 0);
1513 } 1513 }
1514 } 1514 }
1515 1515
1516 // Test that the masked server credit card counts are logged correctly.
1517 TEST_F(AutofillMetricsTest, StoredServerCreditCardCounts_Masked) {
1518 // The metrics should be logged when the credit cards are first loaded.
1519 {
1520 base::HistogramTester histogram_tester;
1521 personal_data_->RecreateCreditCards(
1522 false /* include_local_credit_card */,
1523 true /* include_masked_server_credit_card */,
1524 false /* include_full_server_credit_card */);
1525 histogram_tester.ExpectUniqueSample(
1526 "Autofill.StoredServerCreditCardCount.Masked", 1, 1);
1527 }
1528
1529 // The metrics should only be logged once.
1530 {
1531 base::HistogramTester histogram_tester;
1532 personal_data_->RecreateCreditCards(
1533 false /* include_local_credit_card */,
1534 true /* include_masked_server_credit_card */,
1535 true /* include_full_server_credit_card */);
1536 histogram_tester.ExpectTotalCount(
1537 "Autofill.StoredServerCreditCardCount.Masked", 0);
1538 }
1539 }
1540
1541 // Test that the unmasked (full) server credit card counts are logged correctly.
1542 TEST_F(AutofillMetricsTest, StoredServerCreditCardCounts_Unmasked) {
1543 // The metrics should be logged when the credit cards are first loaded.
1544 {
1545 base::HistogramTester histogram_tester;
1546 personal_data_->RecreateCreditCards(
1547 false /* include_local_credit_card */,
1548 false /* include_masked_server_credit_card */,
1549 true /* include_full_server_credit_card */);
1550 histogram_tester.ExpectUniqueSample(
1551 "Autofill.StoredServerCreditCardCount.Unmasked", 1, 1);
1552 }
1553
1554 // The metrics should only be logged once.
1555 {
1556 base::HistogramTester histogram_tester;
1557 personal_data_->RecreateCreditCards(
1558 false /* include_local_credit_card */,
1559 false /* include_masked_server_credit_card */,
1560 true /* include_full_server_credit_card */);
1561 histogram_tester.ExpectTotalCount(
1562 "Autofill.StoredServerCreditCardCount.Unmasked", 0);
1563 }
1564 }
1565
1516 // Test that we correctly log when Autofill is enabled. 1566 // Test that we correctly log when Autofill is enabled.
1517 TEST_F(AutofillMetricsTest, AutofillIsEnabledAtStartup) { 1567 TEST_F(AutofillMetricsTest, AutofillIsEnabledAtStartup) {
1518 base::HistogramTester histogram_tester; 1568 base::HistogramTester histogram_tester;
1519 personal_data_->set_autofill_enabled(true); 1569 personal_data_->set_autofill_enabled(true);
1520 personal_data_->Init( 1570 personal_data_->Init(
1521 autofill_client_.GetDatabase(), autofill_client_.GetPrefs(), 1571 autofill_client_.GetDatabase(), autofill_client_.GetPrefs(),
1522 account_tracker_.get(), signin_manager_.get(), false); 1572 account_tracker_.get(), signin_manager_.get(), false);
1523 histogram_tester.ExpectUniqueSample("Autofill.IsEnabled.Startup", true, 1); 1573 histogram_tester.ExpectUniqueSample("Autofill.IsEnabled.Startup", true, 1);
1524 } 1574 }
1525 1575
(...skipping 2543 matching lines...) Expand 10 before | Expand all | Expand 10 after
4069 EXPECT_THAT( 4119 EXPECT_THAT(
4070 histogram_tester.GetAllSamples("Autofill.ServerResponseHasDataForForm"), 4120 histogram_tester.GetAllSamples("Autofill.ServerResponseHasDataForForm"),
4071 ElementsAre(Bucket(true, 2))); 4121 ElementsAre(Bucket(true, 2)));
4072 4122
4073 // No RAPPOR metrics are logged in the case there is at least some server data 4123 // No RAPPOR metrics are logged in the case there is at least some server data
4074 // available for all forms. 4124 // available for all forms.
4075 EXPECT_EQ(0, rappor_service_.GetReportsCount()); 4125 EXPECT_EQ(0, rappor_service_.GetReportsCount());
4076 } 4126 }
4077 4127
4078 } // namespace autofill 4128 } // namespace autofill
OLDNEW
« no previous file with comments | « components/autofill/core/browser/autofill_metrics.cc ('k') | components/autofill/core/browser/personal_data_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698