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

Unified Diff: base/metrics/histogram_unittest.cc

Issue 1256363002: Add support to increase a UMA histogram bucket by an aribitrary integer. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: After rebase-update 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/metrics/histogram_base.h ('k') | base/metrics/sparse_histogram.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/metrics/histogram_unittest.cc
diff --git a/base/metrics/histogram_unittest.cc b/base/metrics/histogram_unittest.cc
index f189267f3587affbf6624455ca0a6426cfd21ed5..b144379050ba4b54b2e03bf8d2e4e16ca899e500 100644
--- a/base/metrics/histogram_unittest.cc
+++ b/base/metrics/histogram_unittest.cc
@@ -231,6 +231,30 @@ TEST_F(HistogramTest, CustomHistogramWithOnly2Buckets) {
EXPECT_EQ(HistogramBase::kSampleType_MAX, ranges->range(2));
}
+// Test the AddCount function.
+TEST_F(HistogramTest, AddCountTest) {
+ const size_t kBucketCount = 50;
+ Histogram* histogram = static_cast<Histogram*>(
+ Histogram::FactoryGet("AddCountHistogram", 10, 100, kBucketCount,
+ HistogramBase::kNoFlags));
+
+ histogram->AddCount(20, 15);
+ histogram->AddCount(30, 14);
+
+ scoped_ptr<SampleVector> samples = histogram->SnapshotSampleVector();
+ EXPECT_EQ(29, samples->TotalCount());
+ EXPECT_EQ(15, samples->GetCount(20));
+ EXPECT_EQ(14, samples->GetCount(30));
+
+ histogram->AddCount(20, 25);
+ histogram->AddCount(30, 24);
+
+ scoped_ptr<SampleVector> samples2 = histogram->SnapshotSampleVector();
+ EXPECT_EQ(78, samples2->TotalCount());
+ EXPECT_EQ(40, samples2->GetCount(20));
+ EXPECT_EQ(38, samples2->GetCount(30));
+}
+
// Make sure histogram handles out-of-bounds data gracefully.
TEST_F(HistogramTest, BoundsTest) {
const size_t kBucketCount = 50;
« no previous file with comments | « base/metrics/histogram_base.h ('k') | base/metrics/sparse_histogram.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698