OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 package org.chromium.base.metrics; | 5 package org.chromium.base.metrics; |
6 | 6 |
7 import android.test.InstrumentationTestCase; | 7 import android.test.InstrumentationTestCase; |
8 import android.test.suitebuilder.annotation.SmallTest; | 8 import android.test.suitebuilder.annotation.SmallTest; |
9 | 9 |
10 import org.chromium.base.library_loader.LibraryLoader; | 10 import org.chromium.base.library_loader.LibraryLoader; |
11 import org.chromium.base.library_loader.LibraryProcessType; | 11 import org.chromium.base.library_loader.LibraryProcessType; |
12 import org.chromium.base.test.util.MetricsUtils.HistogramDelta; | 12 import org.chromium.base.test.util.MetricsUtils.HistogramDelta; |
13 | 13 |
14 import java.util.concurrent.TimeUnit; | 14 import java.util.concurrent.TimeUnit; |
15 | 15 |
16 /** | 16 /** |
17 * Tests for the Java API for recording UMA histograms. | 17 * Tests for the Java API for recording UMA histograms. |
18 */ | 18 */ |
19 public class RecordHistogramTest extends InstrumentationTestCase { | 19 public class RecordHistogramTest extends InstrumentationTestCase { |
20 @Override | 20 @Override |
21 protected void setUp() throws Exception { | 21 protected void setUp() throws Exception { |
22 super.setUp(); | 22 super.setUp(); |
23 LibraryLoader.get(LibraryProcessType.PROCESS_BROWSER) | 23 LibraryLoader.get(LibraryProcessType.PROCESS_BROWSER).ensureInitialized(
); |
24 .ensureInitialized(getInstrumentation().getTargetContext()); | |
25 RecordHistogram.initialize(); | 24 RecordHistogram.initialize(); |
26 } | 25 } |
27 | 26 |
28 /** | 27 /** |
29 * Tests recording of boolean histograms. | 28 * Tests recording of boolean histograms. |
30 */ | 29 */ |
31 @SmallTest | 30 @SmallTest |
32 public void testRecordBooleanHistogram() { | 31 public void testRecordBooleanHistogram() { |
33 String histogram = "HelloWorld.BooleanMetric"; | 32 String histogram = "HelloWorld.BooleanMetric"; |
34 HistogramDelta falseCount = new HistogramDelta(histogram, 0); | 33 HistogramDelta falseCount = new HistogramDelta(histogram, 0); |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
184 assertEquals(2, zeroCount.getDelta()); | 183 assertEquals(2, zeroCount.getDelta()); |
185 assertEquals(0, oneCount.getDelta()); | 184 assertEquals(0, oneCount.getDelta()); |
186 assertEquals(0, twoCount.getDelta()); | 185 assertEquals(0, twoCount.getDelta()); |
187 | 186 |
188 RecordHistogram.recordLinearCountHistogram(histogram, 2, min, max, numBu
ckets); | 187 RecordHistogram.recordLinearCountHistogram(histogram, 2, min, max, numBu
ckets); |
189 assertEquals(2, zeroCount.getDelta()); | 188 assertEquals(2, zeroCount.getDelta()); |
190 assertEquals(0, oneCount.getDelta()); | 189 assertEquals(0, oneCount.getDelta()); |
191 assertEquals(1, twoCount.getDelta()); | 190 assertEquals(1, twoCount.getDelta()); |
192 } | 191 } |
193 } | 192 } |
OLD | NEW |