Bug 1097762 - part 2 - add test for clearing flag histograms; r=froydnj
authorMichael Ratcliffe <mratcliffe@mozilla.com>
Thu, 13 Nov 2014 10:18:10 -0500
changeset 241945 44d6420a3cc7de60012f832534320f77a6497787
parent 241944 e0c591e12feae8328eeef98a78a172693101ceb6
child 241946 58f75321e4c18b78276b561531b65b19fb8ab579
push id660
push userraliiev@mozilla.com
push dateWed, 18 Feb 2015 20:30:48 +0000
treeherdermozilla-release@49e493494178 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfroydnj
bugs1097762
milestone36.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1097762 - part 2 - add test for clearing flag histograms; r=froydnj
toolkit/components/telemetry/tests/unit/test_TelemetryFlagClear.js
toolkit/components/telemetry/tests/unit/xpcshell.ini
new file mode 100644
--- /dev/null
+++ b/toolkit/components/telemetry/tests/unit/test_TelemetryFlagClear.js
@@ -0,0 +1,17 @@
+/* Any copyright is dedicated to the Public Domain.
+   http://creativecommons.org/publicdomain/zero/1.0/ */
+
+const Cu = Components.utils;
+const {Services} = Cu.import("resource://gre/modules/Services.jsm", {});
+
+function run_test()
+{
+  let testFlag = Services.telemetry.getHistogramById("TELEMETRY_TEST_FLAG");
+  equal(JSON.stringify(testFlag.snapshot().counts), "[1,0,0]", "Original value is correct");
+  testFlag.add(1);
+  equal(JSON.stringify(testFlag.snapshot().counts), "[0,1,0]", "Value is correct after ping.");
+  testFlag.clear();
+  equal(JSON.stringify(testFlag.snapshot().counts), "[1,0,0]", "Value is correct after calling clear()");
+  testFlag.add(1);
+  equal(JSON.stringify(testFlag.snapshot().counts), "[0,1,0]", "Value is correct after ping.");
+}
--- a/toolkit/components/telemetry/tests/unit/xpcshell.ini
+++ b/toolkit/components/telemetry/tests/unit/xpcshell.ini
@@ -1,14 +1,15 @@
 [DEFAULT]
 head = head.js
 tail = 
 skip-if = toolkit == 'gonk'
 
 [test_nsITelemetry.js]
+[test_TelemetryFlagClear.js]
 [test_TelemetryLateWrites.js]
 [test_TelemetryLockCount.js]
 [test_TelemetryLog.js]
 [test_TelemetryPing.js]
 # Bug 676989: test fails consistently on Android
 # fail-if = os == "android"
 [test_TelemetryPing_idle.js]
 [test_TelemetryStopwatch.js]