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

Unified Diff: base/test/histogram_tester_unittest.cc

Issue 1264123002: HistogramTester::GetHistogramSamplesSinceCreation never returns null (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: sql tests simplified Created 5 years, 5 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
« no previous file with comments | « base/test/histogram_tester.cc ('k') | sql/connection_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/test/histogram_tester_unittest.cc
diff --git a/base/test/histogram_tester_unittest.cc b/base/test/histogram_tester_unittest.cc
index f8755279c5ac749612d95b0dacdd89bd66deeb04..153fe56312cf3a44a3d10da5964ef1498b3f5165 100644
--- a/base/test/histogram_tester_unittest.cc
+++ b/base/test/histogram_tester_unittest.cc
@@ -29,19 +29,32 @@ TEST_F(HistogramTesterTest, Scope) {
HistogramTester tester;
// Verify that no histogram is recorded.
- scoped_ptr<HistogramSamples> samples(
- tester.GetHistogramSamplesSinceCreation(kHistogram1));
- EXPECT_FALSE(samples);
+ tester.ExpectTotalCount(kHistogram1, 0);
// Record a histogram after the creation of the recorder.
UMA_HISTOGRAM_BOOLEAN(kHistogram1, true);
// Verify that one histogram is recorded.
- samples = tester.GetHistogramSamplesSinceCreation(kHistogram1);
+ scoped_ptr<HistogramSamples> samples(
+ tester.GetHistogramSamplesSinceCreation(kHistogram1));
EXPECT_TRUE(samples);
EXPECT_EQ(1, samples->TotalCount());
}
+TEST_F(HistogramTesterTest, GetHistogramSamplesSinceCreationNotNull) {
+ // Chose the histogram name uniquely, to ensure nothing was recorded for it so
+ // far.
+ const std::string kHistogram =
Lei Zhang 2015/07/31 21:48:20 Can this be static const char kHistogram[] ? Ditto
vabr (Chromium) 2015/08/03 07:33:37 Sure.
+ "GetHistogramSamplesSinceCreationNotNullHistogram";
+ HistogramTester tester;
+
+ // Verify that the returned samples are empty but not null.
+ scoped_ptr<HistogramSamples> samples(
+ tester.GetHistogramSamplesSinceCreation(kHistogram1));
+ EXPECT_TRUE(samples);
+ tester.ExpectTotalCount(kHistogram, 0);
+}
+
TEST_F(HistogramTesterTest, TestUniqueSample) {
HistogramTester tester;
« no previous file with comments | « base/test/histogram_tester.cc ('k') | sql/connection_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698