Index: base/android/javatests/src/org/chromium/base/metrics/RecordHistogramTest.java |
diff --git a/base/android/javatests/src/org/chromium/base/metrics/RecordHistogramTest.java b/base/android/javatests/src/org/chromium/base/metrics/RecordHistogramTest.java |
index 1bf9c216145da7020f72c5699c153564c1b7d0ce..6b1888ce59ca62cc586dfd6260b7731761a9e431 100644 |
--- a/base/android/javatests/src/org/chromium/base/metrics/RecordHistogramTest.java |
+++ b/base/android/javatests/src/org/chromium/base/metrics/RecordHistogramTest.java |
@@ -157,4 +157,37 @@ public class RecordHistogramTest extends InstrumentationTestCase { |
assertEquals(1, oneCount.getDelta()); |
assertEquals(1, twoCount.getDelta()); |
} |
+ |
+ /** |
+ * Tests recording of linear count histograms. |
+ */ |
+ @SmallTest |
+ public void testRecordLinearCountHistogram() { |
+ String histogram = "HelloWorld.LinearCountMetric"; |
+ HistogramDelta zeroCount = new HistogramDelta(histogram, 0); |
+ HistogramDelta oneCount = new HistogramDelta(histogram, 1); |
+ HistogramDelta twoCount = new HistogramDelta(histogram, 2); |
+ final int min = 1; |
+ final int max = 3; |
+ final int numBuckets = 4; |
+ |
+ assertEquals(0, zeroCount.getDelta()); |
+ assertEquals(0, oneCount.getDelta()); |
+ assertEquals(0, twoCount.getDelta()); |
+ |
+ RecordHistogram.recordLinearCountHistogram(histogram, 0, min, max, numBuckets); |
+ assertEquals(1, zeroCount.getDelta()); |
+ assertEquals(0, oneCount.getDelta()); |
+ assertEquals(0, twoCount.getDelta()); |
+ |
+ RecordHistogram.recordLinearCountHistogram(histogram, 0, min, max, numBuckets); |
+ assertEquals(2, zeroCount.getDelta()); |
+ assertEquals(0, oneCount.getDelta()); |
+ assertEquals(0, twoCount.getDelta()); |
+ |
+ RecordHistogram.recordLinearCountHistogram(histogram, 2, min, max, numBuckets); |
+ assertEquals(2, zeroCount.getDelta()); |
+ assertEquals(0, oneCount.getDelta()); |
+ assertEquals(1, twoCount.getDelta()); |
+ } |
} |