diff options
author | Matt A. Tobin <email@mattatobin.com> | 2020-02-25 15:07:00 -0500 |
---|---|---|
committer | wolfbeast <mcwerewolf@wolfbeast.com> | 2020-04-14 12:55:19 +0200 |
commit | eb70e6e3d0bff11c25f14b1196025791bf2308fb (patch) | |
tree | 5ef4ce17db83c74d7b05ec12c8f59e095a6dd5bd /toolkit/components/telemetry/tests/unit/TelemetryArchiveTesting.jsm | |
parent | 32ead795290b3399d56b4708fc75b77d296f6a1a (diff) | |
download | UXP-eb70e6e3d0bff11c25f14b1196025791bf2308fb.tar UXP-eb70e6e3d0bff11c25f14b1196025791bf2308fb.tar.gz UXP-eb70e6e3d0bff11c25f14b1196025791bf2308fb.tar.lz UXP-eb70e6e3d0bff11c25f14b1196025791bf2308fb.tar.xz UXP-eb70e6e3d0bff11c25f14b1196025791bf2308fb.zip |
Issue #439 - Remove tests from toolkit/
Diffstat (limited to 'toolkit/components/telemetry/tests/unit/TelemetryArchiveTesting.jsm')
-rw-r--r-- | toolkit/components/telemetry/tests/unit/TelemetryArchiveTesting.jsm | 86 |
1 files changed, 0 insertions, 86 deletions
diff --git a/toolkit/components/telemetry/tests/unit/TelemetryArchiveTesting.jsm b/toolkit/components/telemetry/tests/unit/TelemetryArchiveTesting.jsm deleted file mode 100644 index 9be82c883..000000000 --- a/toolkit/components/telemetry/tests/unit/TelemetryArchiveTesting.jsm +++ /dev/null @@ -1,86 +0,0 @@ -const {utils: Cu} = Components; -Cu.import("resource://gre/modules/TelemetryArchive.jsm"); -Cu.import("resource://testing-common/Assert.jsm"); -Cu.import("resource://gre/modules/Task.jsm"); -Cu.import("resource://gre/modules/Services.jsm"); -Cu.import("resource://gre/modules/TelemetryController.jsm"); - -this.EXPORTED_SYMBOLS = [ - "TelemetryArchiveTesting", -]; - -function checkForProperties(ping, expected) { - for (let [props, val] of expected) { - let test = ping; - for (let prop of props) { - test = test[prop]; - if (test === undefined) { - return false; - } - } - if (test !== val) { - return false; - } - } - return true; -} - -/** - * A helper object that allows test code to check whether a telemetry ping - * was properly saved. To use, first initialize to collect the starting pings - * and then check for new ping data. - */ -function Checker() { -} -Checker.prototype = { - promiseInit: function() { - this._pingMap = new Map(); - return TelemetryArchive.promiseArchivedPingList().then((plist) => { - for (let ping of plist) { - this._pingMap.set(ping.id, ping); - } - }); - }, - - /** - * Find and return a new ping with certain properties. - * - * @param expected: an array of [['prop'...], 'value'] to check - * For example: - * [ - * [['environment', 'build', 'applicationId'], '20150101010101'], - * [['version'], 1], - * [['metadata', 'OOMAllocationSize'], 123456789], - * ] - * @returns a matching ping if found, or null - */ - promiseFindPing: Task.async(function*(type, expected) { - let candidates = []; - let plist = yield TelemetryArchive.promiseArchivedPingList(); - for (let ping of plist) { - if (this._pingMap.has(ping.id)) { - continue; - } - if (ping.type == type) { - candidates.push(ping); - } - } - - for (let candidate of candidates) { - let ping = yield TelemetryArchive.promiseArchivedPingById(candidate.id); - if (checkForProperties(ping, expected)) { - return ping; - } - } - return null; - }), -}; - -const TelemetryArchiveTesting = { - setup: function() { - Services.prefs.setCharPref("toolkit.telemetry.log.level", "Trace"); - Services.prefs.setBoolPref("toolkit.telemetry.archive.enabled", true); - }, - - Checker: Checker, -}; |