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

Unified Diff: chrome/browser/ui/cocoa/browser/password_generation_bubble_controller_unittest.mm

Issue 379283002: Rework UMAHistogramHelper and StatisticsDeltaReader into [Chrome]HistogramTester. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 6 years, 4 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/cocoa/browser/password_generation_bubble_controller_unittest.mm
diff --git a/chrome/browser/ui/cocoa/browser/password_generation_bubble_controller_unittest.mm b/chrome/browser/ui/cocoa/browser/password_generation_bubble_controller_unittest.mm
index 0637f244b7d77e9894afb270af5aa65780444a43..0c8884239be3635c6792e87882100f635d26fd5d 100644
--- a/chrome/browser/ui/cocoa/browser/password_generation_bubble_controller_unittest.mm
+++ b/chrome/browser/ui/cocoa/browser/password_generation_bubble_controller_unittest.mm
@@ -8,7 +8,7 @@
#include "base/metrics/histogram_samples.h"
#include "base/metrics/statistics_recorder.h"
#include "base/strings/sys_string_conversions.h"
-#include "base/test/statistics_delta_reader.h"
+#include "base/test/histogram_tester.h"
#include "chrome/browser/ui/cocoa/cocoa_profile_test.h"
#include "components/autofill/core/browser/password_generator.h"
#include "components/autofill/core/common/password_form.h"
@@ -81,24 +81,14 @@ TEST_F(PasswordGenerationBubbleControllerTest, Regenerate) {
}
TEST_F(PasswordGenerationBubbleControllerTest, UMALogging) {
- base::StatisticsDeltaReader statistics_delta_reader;
+ base::HistogramTester histogram_tester;
[controller() showWindow:nil];
// Do nothing.
CloseController();
- scoped_ptr<base::HistogramSamples> samples(
- statistics_delta_reader.GetHistogramSamplesSinceCreation(kHistogramName));
- EXPECT_EQ(
- 1,
- samples->GetCount(autofill::password_generation::IGNORE_FEATURE));
- EXPECT_EQ(
- 0,
- samples->GetCount(autofill::password_generation::ACCEPT_AFTER_EDITING));
- EXPECT_EQ(
- 0,
- samples->GetCount(
- autofill::password_generation::ACCEPT_ORIGINAL_PASSWORD));
+ histogram_tester.ExpectUniqueSample(
+ kHistogramName, autofill::password_generation::IGNORE_FEATURE, 1);
SetUpController();
@@ -107,18 +97,11 @@ TEST_F(PasswordGenerationBubbleControllerTest, UMALogging) {
[controller() fillPassword:nil];
CloseController();
- samples =
- statistics_delta_reader.GetHistogramSamplesSinceCreation(kHistogramName);
- EXPECT_EQ(
- 1,
- samples->GetCount(autofill::password_generation::IGNORE_FEATURE));
- EXPECT_EQ(
- 1,
- samples->GetCount(autofill::password_generation::ACCEPT_AFTER_EDITING));
- EXPECT_EQ(
- 0,
- samples->GetCount(
- autofill::password_generation::ACCEPT_ORIGINAL_PASSWORD));
+ histogram_tester.ExpectBucketCount(
+ kHistogramName, autofill::password_generation::IGNORE_FEATURE, 1);
+ histogram_tester.ExpectBucketCount(
+ kHistogramName, autofill::password_generation::ACCEPT_AFTER_EDITING, 1);
+ histogram_tester.ExpectTotalCount(kHistogramName, 2);
SetUpController();
@@ -126,16 +109,13 @@ TEST_F(PasswordGenerationBubbleControllerTest, UMALogging) {
[controller() fillPassword:nil];
CloseController();
- samples =
- statistics_delta_reader.GetHistogramSamplesSinceCreation(kHistogramName);
- EXPECT_EQ(
- 1,
- samples->GetCount(autofill::password_generation::IGNORE_FEATURE));
- EXPECT_EQ(
- 1,
- samples->GetCount(autofill::password_generation::ACCEPT_AFTER_EDITING));
- EXPECT_EQ(
- 1,
- samples->GetCount(
- autofill::password_generation::ACCEPT_ORIGINAL_PASSWORD));
+ histogram_tester.ExpectBucketCount(
+ kHistogramName, autofill::password_generation::IGNORE_FEATURE, 1);
+ histogram_tester.ExpectBucketCount(
+ kHistogramName, autofill::password_generation::ACCEPT_AFTER_EDITING, 1);
+ histogram_tester.ExpectBucketCount(
+ kHistogramName,
+ autofill::password_generation::ACCEPT_ORIGINAL_PASSWORD,
+ 1);
+ histogram_tester.ExpectTotalCount(kHistogramName, 3);
}

Powered by Google App Engine
This is Rietveld 408576698