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

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: No static initializers Created 5 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
« 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..8452013f036c7b125deb9076d0864ca111c0409b 100644
--- a/base/test/histogram_tester_unittest.cc
+++ b/base/test/histogram_tester_unittest.cc
@@ -14,11 +14,11 @@ namespace base {
using ::testing::ElementsAre;
-const std::string kHistogram1 = "Test1";
-const std::string kHistogram2 = "Test2";
-const std::string kHistogram3 = "Test3";
-const std::string kHistogram4 = "Test4";
-const std::string kHistogram5 = "Test5";
+static const char kHistogram1[] = "Test1";
vabr (Chromium) 2015/08/03 07:33:37 @thestig -- Here I followed you request literally,
Lei Zhang 2015/08/03 18:00:30 An anonymous namespace would have been fine. I sho
+static const char kHistogram2[] = "Test2";
+static const char kHistogram3[] = "Test3";
+static const char kHistogram4[] = "Test4";
+static const char kHistogram5[] = "Test5";
typedef testing::Test HistogramTesterTest;
@@ -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.
+ static const char kHistogram[] =
+ "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