testing/xpcshell/example/unit/test_get_idle.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/testing/xpcshell/example/unit/test_get_idle.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,23 @@
     1.4 +/* Any copyright is dedicated to the Public Domain.
     1.5 + * http://creativecommons.org/publicdomain/zero/1.0/
     1.6 + */
     1.7 +
     1.8 +function run_test() {
     1.9 +  print("Init the fake idle service and check its identity.");
    1.10 +  let fakeIdleService = Components.classes["@mozilla.org/widget/idleservice;1"].
    1.11 +                        getService(Components.interfaces.nsIIdleService);
    1.12 +  try {
    1.13 +    fakeIdleService.QueryInterface(Components.interfaces.nsIFactory);
    1.14 +  } catch (ex) {
    1.15 +    do_throw("The fake idle service implements nsIFactory.");
    1.16 +  }
    1.17 +  // We need at least one PASS, thus sanity check the idle time.
    1.18 +  do_check_eq(fakeIdleService.idleTime, 0);
    1.19 +
    1.20 +  print("Init the real idle service and check its identity.");
    1.21 +  let realIdleService = do_get_idle();
    1.22 +  try {
    1.23 +    realIdleService.QueryInterface(Components.interfaces.nsIFactory);
    1.24 +    do_throw("The real idle service does not implement nsIFactory.");
    1.25 +  } catch (ex) {}
    1.26 +}

mercurial