services/healthreport/tests/xpcshell/test_provider_sysinfo.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 /* Any copyright is dedicated to the Public Domain.
michael@0 2 * http://creativecommons.org/publicdomain/zero/1.0/ */
michael@0 3
michael@0 4 "use strict";
michael@0 5
michael@0 6 const {interfaces: Ci, results: Cr, utils: Cu} = Components;
michael@0 7
michael@0 8 Cu.import("resource://gre/modules/Metrics.jsm");
michael@0 9 Cu.import("resource://gre/modules/XPCOMUtils.jsm");
michael@0 10 Cu.import("resource://gre/modules/services/healthreport/providers.jsm");
michael@0 11
michael@0 12
michael@0 13 function run_test() {
michael@0 14 run_next_test();
michael@0 15 }
michael@0 16
michael@0 17 add_test(function test_constructor() {
michael@0 18 let provider = new SysInfoProvider();
michael@0 19
michael@0 20 run_next_test();
michael@0 21 });
michael@0 22
michael@0 23 add_task(function test_collect_smoketest() {
michael@0 24 let storage = yield Metrics.Storage("collect_smoketest");
michael@0 25 let provider = new SysInfoProvider();
michael@0 26 yield provider.init(storage);
michael@0 27
michael@0 28 yield provider.collectConstantData();
michael@0 29
michael@0 30 let m = provider.getMeasurement("sysinfo", 2);
michael@0 31 let data = yield storage.getMeasurementValues(m.id);
michael@0 32 let serializer = m.serializer(m.SERIALIZE_JSON);
michael@0 33 let d = serializer.singular(data.singular);
michael@0 34
michael@0 35 do_check_eq(d._v, 2);
michael@0 36 do_check_true(d.cpuCount > 0);
michael@0 37 do_check_neq(d.name, null);
michael@0 38
michael@0 39 yield storage.close();
michael@0 40 });
michael@0 41

mercurial