| 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 |
| (...skipping 1356 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1367 } | 1367 } |
| 1368 | 1368 |
| 1369 // The metric should only be logged once. | 1369 // The metric should only be logged once. |
| 1370 { | 1370 { |
| 1371 base::HistogramTester histogram_tester; | 1371 base::HistogramTester histogram_tester; |
| 1372 personal_data_->LoadProfiles(); | 1372 personal_data_->LoadProfiles(); |
| 1373 histogram_tester.ExpectTotalCount("Autofill.StoredProfileCount", 0); | 1373 histogram_tester.ExpectTotalCount("Autofill.StoredProfileCount", 0); |
| 1374 } | 1374 } |
| 1375 } | 1375 } |
| 1376 | 1376 |
| 1377 // Test that the local credit card count is logged correctly. |
| 1378 TEST_F(AutofillMetricsTest, StoredLocalCreditCardCount) { |
| 1379 // The metric should be logged when the credit cards are first loaded. |
| 1380 { |
| 1381 base::HistogramTester histogram_tester; |
| 1382 personal_data_->RecreateCreditCards( |
| 1383 true /* include_local_credit_card */, |
| 1384 false /* include_masked_server_credit_card */, |
| 1385 false /* include_full_server_credit_card */); |
| 1386 histogram_tester.ExpectUniqueSample("Autofill.StoredLocalCreditCardCount", |
| 1387 1, 1); |
| 1388 } |
| 1389 |
| 1390 // The metric should only be logged once. |
| 1391 { |
| 1392 base::HistogramTester histogram_tester; |
| 1393 personal_data_->RecreateCreditCards( |
| 1394 true /* include_local_credit_card */, |
| 1395 false /* include_masked_server_credit_card */, |
| 1396 false /* include_full_server_credit_card */); |
| 1397 histogram_tester.ExpectTotalCount("Autofill.StoredLocalCreditCardCount", 0); |
| 1398 } |
| 1399 } |
| 1400 |
| 1377 // Test that we correctly log when Autofill is enabled. | 1401 // Test that we correctly log when Autofill is enabled. |
| 1378 TEST_F(AutofillMetricsTest, AutofillIsEnabledAtStartup) { | 1402 TEST_F(AutofillMetricsTest, AutofillIsEnabledAtStartup) { |
| 1379 base::HistogramTester histogram_tester; | 1403 base::HistogramTester histogram_tester; |
| 1380 personal_data_->set_autofill_enabled(true); | 1404 personal_data_->set_autofill_enabled(true); |
| 1381 personal_data_->Init( | 1405 personal_data_->Init( |
| 1382 autofill_client_.GetDatabase(), autofill_client_.GetPrefs(), | 1406 autofill_client_.GetDatabase(), autofill_client_.GetPrefs(), |
| 1383 account_tracker_.get(), signin_manager_.get(), false); | 1407 account_tracker_.get(), signin_manager_.get(), false); |
| 1384 histogram_tester.ExpectUniqueSample("Autofill.IsEnabled.Startup", true, 1); | 1408 histogram_tester.ExpectUniqueSample("Autofill.IsEnabled.Startup", true, 1); |
| 1385 } | 1409 } |
| 1386 | 1410 |
| (...skipping 2203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3590 EXPECT_THAT( | 3614 EXPECT_THAT( |
| 3591 histogram_tester.GetAllSamples("Autofill.ServerResponseHasDataForForm"), | 3615 histogram_tester.GetAllSamples("Autofill.ServerResponseHasDataForForm"), |
| 3592 ElementsAre(Bucket(true, 2))); | 3616 ElementsAre(Bucket(true, 2))); |
| 3593 | 3617 |
| 3594 // No RAPPOR metrics are logged in the case there is at least some server data | 3618 // No RAPPOR metrics are logged in the case there is at least some server data |
| 3595 // available for all forms. | 3619 // available for all forms. |
| 3596 EXPECT_EQ(0, rappor_service_.GetReportsCount()); | 3620 EXPECT_EQ(0, rappor_service_.GetReportsCount()); |
| 3597 } | 3621 } |
| 3598 | 3622 |
| 3599 } // namespace autofill | 3623 } // namespace autofill |
| OLD | NEW |