browser/devtools/commandline/test/browser_cmd_calllog.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/browser/devtools/commandline/test/browser_cmd_calllog.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,119 @@
     1.4 +/* Any copyright is dedicated to the Public Domain.
     1.5 +* http://creativecommons.org/publicdomain/zero/1.0/ */
     1.6 +
     1.7 +// Tests that the calllog commands works as they should
     1.8 +
     1.9 +const TEST_URI = "data:text/html;charset=utf-8,gcli-calllog";
    1.10 +
    1.11 +let tests = {};
    1.12 +
    1.13 +function test() {
    1.14 +  return Task.spawn(function() {
    1.15 +    let options = yield helpers.openTab(TEST_URI);
    1.16 +    yield helpers.openToolbar(options);
    1.17 +
    1.18 +    yield helpers.runTests(options, tests);
    1.19 +
    1.20 +    yield helpers.closeToolbar(options);
    1.21 +    yield helpers.closeTab(options);
    1.22 +  }).then(finish, helpers.handleError);
    1.23 +}
    1.24 +
    1.25 +tests.testCallLogStatus = function(options) {
    1.26 +  return helpers.audit(options, [
    1.27 +    {
    1.28 +      setup: "calllog",
    1.29 +      check: {
    1.30 +        input:  'calllog',
    1.31 +        hints:         '',
    1.32 +        markup: 'IIIIIII',
    1.33 +        status: 'ERROR'
    1.34 +      }
    1.35 +    },
    1.36 +    {
    1.37 +      setup: "calllog start",
    1.38 +      check: {
    1.39 +        input:  'calllog start',
    1.40 +        hints:               '',
    1.41 +        markup: 'VVVVVVVVVVVVV',
    1.42 +        status: 'VALID'
    1.43 +      }
    1.44 +    },
    1.45 +    {
    1.46 +      setup: "calllog stop",
    1.47 +      check: {
    1.48 +        input:  'calllog stop',
    1.49 +        hints:              '',
    1.50 +        markup: 'VVVVVVVVVVVV',
    1.51 +        status: 'VALID'
    1.52 +      }
    1.53 +    },
    1.54 +  ]);
    1.55 +};
    1.56 +
    1.57 +tests.testCallLogExec = function(options) {
    1.58 +  var deferred = promise.defer();
    1.59 +
    1.60 +  var onWebConsoleOpen = function(subject) {
    1.61 +    Services.obs.removeObserver(onWebConsoleOpen, "web-console-created");
    1.62 +
    1.63 +    subject.QueryInterface(Ci.nsISupportsString);
    1.64 +    let hud = HUDService.getHudReferenceById(subject.data);
    1.65 +    ok(hud, "console open");
    1.66 +
    1.67 +    helpers.audit(options, [
    1.68 +      {
    1.69 +        setup: "calllog stop",
    1.70 +        exec: {
    1.71 +          output: /Stopped call logging/,
    1.72 +        }
    1.73 +      },
    1.74 +      {
    1.75 +        setup: "console clear",
    1.76 +        exec: {
    1.77 +          output: "",
    1.78 +        },
    1.79 +        post: function() {
    1.80 +          let labels = hud.outputNode.querySelectorAll(".webconsole-msg-output");
    1.81 +          is(labels.length, 0, "no output in console");
    1.82 +        }
    1.83 +      },
    1.84 +      {
    1.85 +        setup: "console close",
    1.86 +        exec: {
    1.87 +          output: "",
    1.88 +        }
    1.89 +      },
    1.90 +    ]).then(function() {
    1.91 +      deferred.resolve();
    1.92 +    });
    1.93 +  };
    1.94 +  Services.obs.addObserver(onWebConsoleOpen, "web-console-created", false);
    1.95 +
    1.96 +  helpers.audit(options, [
    1.97 +    {
    1.98 +      setup: "calllog stop",
    1.99 +      exec: {
   1.100 +        output: /No call logging/,
   1.101 +      }
   1.102 +    },
   1.103 +    {
   1.104 +      name: "calllog start",
   1.105 +      setup: function() {
   1.106 +        // This test wants to be in a different event
   1.107 +        var deferred = promise.defer();
   1.108 +        executeSoon(function() {
   1.109 +          helpers.setInput(options, "calllog start").then(() => {
   1.110 +            deferred.resolve();
   1.111 +          });
   1.112 +        });
   1.113 +        return deferred.promise;
   1.114 +      },
   1.115 +      exec: {
   1.116 +        output: /Call logging started/,
   1.117 +      },
   1.118 +    },
   1.119 +  ]);
   1.120 +
   1.121 +  return deferred.promise;
   1.122 +};

mercurial