Wed, 31 Dec 2014 06:09:35 +0100
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 {utils: Cu} = Components; |
michael@0 | 7 | |
michael@0 | 8 | Cu.import("resource://gre/modules/Metrics.jsm"); |
michael@0 | 9 | Cu.import("resource://gre/modules/services/healthreport/providers.jsm"); |
michael@0 | 10 | |
michael@0 | 11 | |
michael@0 | 12 | function run_test() { |
michael@0 | 13 | run_next_test(); |
michael@0 | 14 | } |
michael@0 | 15 | |
michael@0 | 16 | add_test(function test_constructor() { |
michael@0 | 17 | let provider = new PlacesProvider(); |
michael@0 | 18 | |
michael@0 | 19 | run_next_test(); |
michael@0 | 20 | }); |
michael@0 | 21 | |
michael@0 | 22 | add_task(function test_collect_smoketest() { |
michael@0 | 23 | let storage = yield Metrics.Storage("collect_smoketest"); |
michael@0 | 24 | let provider = new PlacesProvider(); |
michael@0 | 25 | |
michael@0 | 26 | yield provider.init(storage); |
michael@0 | 27 | |
michael@0 | 28 | let now = new Date(); |
michael@0 | 29 | yield provider.collectDailyData(); |
michael@0 | 30 | |
michael@0 | 31 | let m = provider.getMeasurement("places", 1); |
michael@0 | 32 | let data = yield storage.getMeasurementValues(m.id); |
michael@0 | 33 | do_check_eq(data.days.size, 1); |
michael@0 | 34 | do_check_true(data.days.hasDay(now)); |
michael@0 | 35 | |
michael@0 | 36 | let serializer = m.serializer(m.SERIALIZE_JSON); |
michael@0 | 37 | let day = serializer.daily(data.days.getDay(now)); |
michael@0 | 38 | |
michael@0 | 39 | do_check_eq(day._v, 1); |
michael@0 | 40 | do_check_eq(Object.keys(day).length, 3); |
michael@0 | 41 | do_check_eq(day.pages, 0); |
michael@0 | 42 | do_check_eq(day.bookmarks, 0); |
michael@0 | 43 | |
michael@0 | 44 | yield storage.close(); |
michael@0 | 45 | }); |
michael@0 | 46 |