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

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

Issue 120753002: Add a StatisticsDeltaReader class and use cases (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address isherman's feedback (and bump copyright year). Created 6 years, 11 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 c32117141ef7715f2ad3a381da5674a374a6ac4c..0637f244b7d77e9894afb270af5aa65780444a43 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
@@ -5,19 +5,15 @@
#import "chrome/browser/ui/cocoa/browser/password_generation_bubble_controller.h"
#include "base/logging.h"
-#include "base/metrics/histogram.h"
#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 "chrome/browser/ui/cocoa/cocoa_profile_test.h"
#include "components/autofill/core/browser/password_generator.h"
#include "components/autofill/core/common/password_form.h"
#include "testing/gtest_mac.h"
-using base::HistogramBase;
-using base::HistogramSamples;
-using base::StatisticsRecorder;
-
const char kHistogramName[] = "PasswordGeneration.UserActions";
class PasswordGenerationBubbleControllerTest : public CocoaProfileTest {
@@ -26,7 +22,7 @@ class PasswordGenerationBubbleControllerTest : public CocoaProfileTest {
: controller_(nil) {}
static void SetUpTestCase() {
- StatisticsRecorder::Initialize();
+ base::StatisticsRecorder::Initialize();
}
virtual void SetUp() {
@@ -34,11 +30,6 @@ class PasswordGenerationBubbleControllerTest : public CocoaProfileTest {
generator_.reset(new autofill::PasswordGenerator(20));
- HistogramBase* histogram =
- StatisticsRecorder::FindHistogram(kHistogramName);
- if (histogram)
- original_ = histogram->SnapshotSamples();
-
SetUpController();
}
@@ -65,27 +56,10 @@ class PasswordGenerationBubbleControllerTest : public CocoaProfileTest {
controller_ = nil;
}
- HistogramSamples* GetHistogramSamples() {
- HistogramBase* histogram =
- StatisticsRecorder::FindHistogram(kHistogramName);
- if (histogram) {
- current_ = histogram->SnapshotSamples();
- if (original_.get())
- current_->Subtract(*original_.get());
- }
- return current_.get();
- }
-
protected:
// Weak.
PasswordGenerationBubbleController* controller_;
- // Used to determine the histogram changes made just for this specific
- // test run.
- scoped_ptr<HistogramSamples> original_;
-
- scoped_ptr<HistogramSamples> current_;
-
scoped_ptr<autofill::PasswordGenerator> generator_;
};
@@ -107,12 +81,14 @@ TEST_F(PasswordGenerationBubbleControllerTest, Regenerate) {
}
TEST_F(PasswordGenerationBubbleControllerTest, UMALogging) {
+ base::StatisticsDeltaReader statistics_delta_reader;
[controller() showWindow:nil];
// Do nothing.
CloseController();
- HistogramSamples* samples = GetHistogramSamples();
+ scoped_ptr<base::HistogramSamples> samples(
+ statistics_delta_reader.GetHistogramSamplesSinceCreation(kHistogramName));
EXPECT_EQ(
1,
samples->GetCount(autofill::password_generation::IGNORE_FEATURE));
@@ -131,7 +107,8 @@ TEST_F(PasswordGenerationBubbleControllerTest, UMALogging) {
[controller() fillPassword:nil];
CloseController();
- samples = GetHistogramSamples();
+ samples =
+ statistics_delta_reader.GetHistogramSamplesSinceCreation(kHistogramName);
EXPECT_EQ(
1,
samples->GetCount(autofill::password_generation::IGNORE_FEATURE));
@@ -149,7 +126,8 @@ TEST_F(PasswordGenerationBubbleControllerTest, UMALogging) {
[controller() fillPassword:nil];
CloseController();
- samples = GetHistogramSamples();
+ samples =
+ statistics_delta_reader.GetHistogramSamplesSinceCreation(kHistogramName);
EXPECT_EQ(
1,
samples->GetCount(autofill::password_generation::IGNORE_FEATURE));
@@ -160,5 +138,4 @@ TEST_F(PasswordGenerationBubbleControllerTest, UMALogging) {
1,
samples->GetCount(
autofill::password_generation::ACCEPT_ORIGINAL_PASSWORD));
-
}
« no previous file with comments | « chrome/browser/spellchecker/spellcheck_host_metrics_unittest.cc ('k') | net/url_request/url_request_throttler_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698