mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2026-03-13 03:35:46 +01:00
Bang on tests a bit more.
This commit is contained in:
@@ -1001,9 +1001,9 @@ var Timer = Class("Timer", {
|
|||||||
this.latest = 0;
|
this.latest = 0;
|
||||||
},
|
},
|
||||||
|
|
||||||
notify: function (timer) {
|
notify: function (timer, force) {
|
||||||
try {
|
try {
|
||||||
if (util.rehashing || typeof util === "undefined")
|
if (util.rehashing || typeof util === "undefined" || !force && this.doneAt == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
this._timer.cancel();
|
this._timer.cancel();
|
||||||
@@ -1051,7 +1051,7 @@ var Timer = Class("Timer", {
|
|||||||
|
|
||||||
flush: function (force) {
|
flush: function (force) {
|
||||||
if (this.doneAt == -1 || force)
|
if (this.doneAt == -1 || force)
|
||||||
this.notify();
|
this.notify(null, true);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ function Controller(controller) {
|
|||||||
* @property {object} The dactyl modules namespace, to be used
|
* @property {object} The dactyl modules namespace, to be used
|
||||||
* sparingly in tests.
|
* sparingly in tests.
|
||||||
*/
|
*/
|
||||||
this.dactyl = controller.window.dactyl.modules;
|
this.modules = controller.window.dactyl.modules;
|
||||||
|
|
||||||
this.errorCount = 0;
|
this.errorCount = 0;
|
||||||
|
|
||||||
@@ -53,9 +53,9 @@ function Controller(controller) {
|
|||||||
if (/\bErrorMsg\b/.test(highlight))
|
if (/\bErrorMsg\b/.test(highlight))
|
||||||
self.errors.push(String(message));
|
self.errors.push(String(message));
|
||||||
}
|
}
|
||||||
this.dactyl.dactyl.registerObserver("beep", this._countBeep);
|
this.modules.dactyl.registerObserver("beep", this._countBeep);
|
||||||
this.dactyl.dactyl.registerObserver("echoLine", this._countError);
|
this.modules.dactyl.registerObserver("echoLine", this._countError);
|
||||||
this.dactyl.dactyl.registerObserver("echoMultiline", this._countError);
|
this.modules.dactyl.registerObserver("echoMultiline", this._countError);
|
||||||
|
|
||||||
this.resetErrorCount();
|
this.resetErrorCount();
|
||||||
}
|
}
|
||||||
@@ -63,9 +63,9 @@ function Controller(controller) {
|
|||||||
Controller.prototype = {
|
Controller.prototype = {
|
||||||
|
|
||||||
teardown: function () {
|
teardown: function () {
|
||||||
this.dactyl.dactyl.unregisterObserver("beep", this._countBeep);
|
this.modules.dactyl.unregisterObserver("beep", this._countBeep);
|
||||||
this.dactyl.dactyl.unregisterObserver("echoLine", this._countError);
|
this.modules.dactyl.unregisterObserver("echoLine", this._countError);
|
||||||
this.dactyl.dactyl.unregisterObserver("echoMultiline", this._countError);
|
this.modules.dactyl.unregisterObserver("echoMultiline", this._countError);
|
||||||
},
|
},
|
||||||
|
|
||||||
beepCount: 0,
|
beepCount: 0,
|
||||||
@@ -172,29 +172,29 @@ Controller.prototype = {
|
|||||||
let beepCount = this.beepCount;
|
let beepCount = this.beepCount;
|
||||||
let errorCount = this.errorCount;
|
let errorCount = this.errorCount;
|
||||||
if (func) {
|
if (func) {
|
||||||
errorCount = this.dactyl.util.errorCount;
|
errorCount = this.modules.util.errorCount;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
func.apply(self || this, args || []);
|
func.apply(self || this, args || []);
|
||||||
}
|
}
|
||||||
catch (e) {
|
catch (e) {
|
||||||
this.dactyl.util.reportError(e);
|
this.modules.util.reportError(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.beepCount > beepCount)
|
if (this.beepCount > beepCount)
|
||||||
this.frame.log({
|
frame.log({
|
||||||
function: "dactyl.beepMonitor",
|
function: "dactyl.beepMonitor",
|
||||||
want: beepCount, got: this.beepCount,
|
want: beepCount, got: this.beepCount,
|
||||||
comment: "Got " + (this.beepCount - beepCount) + " beeps during execution" + msg
|
comment: "Got " + (this.beepCount - beepCount) + " beeps during execution" + msg
|
||||||
});
|
});
|
||||||
|
|
||||||
if (errorCount != this.dactyl.util.errorCount)
|
if (errorCount != this.modules.util.errorCount)
|
||||||
var errors = this.dactyl.util.errors.slice(errorCount - this.dactyl.util.errorCount)
|
var errors = this.modules.util.errors.slice(errorCount - this.modules.util.errorCount)
|
||||||
.join("\n");
|
.join("\n");
|
||||||
|
|
||||||
return utils.assertEqual('dactyl.assertNoErrors',
|
return utils.assertEqual('dactyl.assertNoErrors',
|
||||||
errorCount, this.dactyl.util.errorCount,
|
errorCount, this.modules.util.errorCount,
|
||||||
"Errors were reported during the execution of this test" + msg + "\n" + errors);
|
"Errors were reported during the execution of this test" + msg + "\n" + errors);
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -219,7 +219,7 @@ Controller.prototype = {
|
|||||||
func.apply(self || this, args || []);
|
func.apply(self || this, args || []);
|
||||||
}
|
}
|
||||||
catch (e) {
|
catch (e) {
|
||||||
this.dactyl.util.reportError(e);
|
this.modules.util.reportError(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
return utils.assertEqual('dactyl.assertNoErrorMessages', count, this.errors.length,
|
return utils.assertEqual('dactyl.assertNoErrorMessages', count, this.errors.length,
|
||||||
@@ -232,7 +232,7 @@ Controller.prototype = {
|
|||||||
* reported during the execution of a test.
|
* reported during the execution of a test.
|
||||||
*/
|
*/
|
||||||
resetErrorCount: function () {
|
resetErrorCount: function () {
|
||||||
this.errorCount = this.dactyl.util.errorCount;
|
this.errorCount = this.modules.util.errorCount;
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -263,7 +263,7 @@ Controller.prototype = {
|
|||||||
* @property {string} The name of dactyl's current key handling
|
* @property {string} The name of dactyl's current key handling
|
||||||
* mode.
|
* mode.
|
||||||
*/
|
*/
|
||||||
get currentMode() this.dactyl.modes.main.name,
|
get currentMode() this.modules.modes.main.name,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @property {object} A map of dactyl widgets to be used sparingly
|
* @property {object} A map of dactyl widgets to be used sparingly
|
||||||
@@ -273,7 +273,7 @@ Controller.prototype = {
|
|||||||
/**
|
/**
|
||||||
* @property {HTMLInputElement} The command line's command input box
|
* @property {HTMLInputElement} The command line's command input box
|
||||||
*/
|
*/
|
||||||
get commandInput() self.dactyl.commandline.widgets.active.command.inputField,
|
get commandInput() self.modules.commandline.widgets.active.command.inputField,
|
||||||
/**
|
/**
|
||||||
* @property {Node|null} The currently focused node.
|
* @property {Node|null} The currently focused node.
|
||||||
*/
|
*/
|
||||||
@@ -281,15 +281,15 @@ Controller.prototype = {
|
|||||||
/**
|
/**
|
||||||
* @property {HTMLInputElement} The message bar's command input box
|
* @property {HTMLInputElement} The message bar's command input box
|
||||||
*/
|
*/
|
||||||
get message() self.dactyl.commandline.widgets.active.message,
|
get message() self.modules.commandline.widgets.active.message,
|
||||||
/**
|
/**
|
||||||
* @property {Node} The multi-line output window.
|
* @property {Node} The multi-line output window.
|
||||||
*/
|
*/
|
||||||
get multiline() self.dactyl.commandline.widgets.multilineOutput,
|
get multiline() self.modules.commandline.widgets.multilineOutput,
|
||||||
/**
|
/**
|
||||||
* @property {Node} The multi-line output container.
|
* @property {Node} The multi-line output container.
|
||||||
*/
|
*/
|
||||||
get multilineContainer() self.dactyl.commandline.widgets.mowContainer,
|
get multilineContainer() self.modules.commandline.widgets.mowContainer,
|
||||||
}),
|
}),
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -297,12 +297,12 @@ Controller.prototype = {
|
|||||||
*/
|
*/
|
||||||
setNormalMode: wrapAssertNoErrors(function () {
|
setNormalMode: wrapAssertNoErrors(function () {
|
||||||
// XXX: Normal mode test
|
// XXX: Normal mode test
|
||||||
for (let i = 0; i < 15 && this.dactyl.modes.stack.length > 1; i++)
|
for (let i = 0; i < 15 && this.modules.modes.stack.length > 1; i++)
|
||||||
this.controller.keypress(null, "VK_ESCAPE", {});
|
this.controller.keypress(null, "VK_ESCAPE", {});
|
||||||
|
|
||||||
this.controller.keypress(null, "l", { ctrlKey: true });
|
this.controller.keypress(null, "l", { ctrlKey: true });
|
||||||
|
|
||||||
utils.assert("dactyl.setNormalMode", this.dactyl.modes.stack.length == 1,
|
utils.assert("dactyl.setNormalMode", this.modules.modes.stack.length == 1,
|
||||||
"Failed to return to Normal mode");
|
"Failed to return to Normal mode");
|
||||||
|
|
||||||
this.assertMessageWindowOpen(false, "Returning to normal mode: Multi-line output not closed");
|
this.assertMessageWindowOpen(false, "Returning to normal mode: Multi-line output not closed");
|
||||||
@@ -352,11 +352,11 @@ Controller.prototype = {
|
|||||||
try {
|
try {
|
||||||
// Force async commands to wait for their output to be ready
|
// Force async commands to wait for their output to be ready
|
||||||
// before returning.
|
// before returning.
|
||||||
this.dactyl.commandline.savingOutput = true;
|
this.modules.commandline.savingOutput = true;
|
||||||
if (args)
|
if (args)
|
||||||
this.dactyl.ex[cmd](args);
|
this.modules.ex[cmd](args);
|
||||||
else if (true)
|
else if (true)
|
||||||
this.dactyl.commands.execute(cmd, null, false, null,
|
this.modules.commands.execute(cmd, null, false, null,
|
||||||
{ file: "[Command Line]", line: 1 });
|
{ file: "[Command Line]", line: 1 });
|
||||||
else {
|
else {
|
||||||
var doc = this.controller.window.document;
|
var doc = this.controller.window.document;
|
||||||
@@ -367,7 +367,7 @@ Controller.prototype = {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
this.dactyl.commandline.savingOutput = false;
|
this.modules.commandline.savingOutput = false;
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
|
|
||||||
@@ -406,10 +406,10 @@ Controller.prototype = {
|
|||||||
this.controller.keypress(null, "VK_TAB", {});
|
this.controller.keypress(null, "VK_TAB", {});
|
||||||
|
|
||||||
// XXX
|
// XXX
|
||||||
if (this.dactyl.commandline._tabTimer)
|
if (this.modules.commandline._tabTimer)
|
||||||
this.dactyl.commandline._tabTimer.flush();
|
this.modules.commandline._tabTimer.flush();
|
||||||
else if (this.dactyl.commandline.commandSession && this.dactyl.commandline.commandSession.completions)
|
else if (this.modules.commandline.commandSession && this.modules.commandline.commandSession.completions)
|
||||||
this.dactyl.commandline.commandSession.completions.tabTimer.flush();
|
this.modules.commandline.commandSession.completions.tabTimer.flush();
|
||||||
}),
|
}),
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -436,7 +436,7 @@ Controller.prototype = {
|
|||||||
* Opens the output message window by echoing a single newline character.
|
* Opens the output message window by echoing a single newline character.
|
||||||
*/
|
*/
|
||||||
openMessageWindow: wrapAssertNoErrors(function () {
|
openMessageWindow: wrapAssertNoErrors(function () {
|
||||||
this.dactyl.dactyl.echo("\n");
|
this.modules.dactyl.echo("\n");
|
||||||
}, "Opening message window"),
|
}, "Opening message window"),
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -458,7 +458,7 @@ Controller.prototype = {
|
|||||||
/**
|
/**
|
||||||
* @property {string} The specific Dactyl application. Eg. Pentadactyl
|
* @property {string} The specific Dactyl application. Eg. Pentadactyl
|
||||||
*/
|
*/
|
||||||
get applicationName() this.dactyl.config.appName // XXX
|
get applicationName() this.modules.config.appName // XXX
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.Controller = Controller;
|
exports.Controller = Controller;
|
||||||
|
|||||||
@@ -1,15 +1,19 @@
|
|||||||
// Runs a slew of generic command tests
|
// Runs a slew of generic command tests
|
||||||
|
|
||||||
var dactyllib = require("dactyl");
|
var dactyllib = require("dactyl");
|
||||||
|
var utils = require("utils");
|
||||||
|
|
||||||
|
const { module } = utils;
|
||||||
|
var jumlib = module("resource://mozmill/modules/jum.js");
|
||||||
|
|
||||||
var setupModule = function (module) {
|
var setupModule = function (module) {
|
||||||
controller = mozmill.getBrowserController();
|
controller = mozmill.getBrowserController();
|
||||||
dactyl = new dactyllib.Controller(controller);
|
dactyl = new dactyllib.Controller(controller);
|
||||||
|
|
||||||
dactyl.dactyl.options["autocomplete"] = [];
|
dactyl.modules.options["autocomplete"] = [];
|
||||||
dactyl.dactyl.options["wildmode"] = ["list"];
|
dactyl.modules.options["wildmode"] = ["list"];
|
||||||
|
|
||||||
dactyl.dactyl.prefs.set("browser.tabs.closeWindowWithLastTab", false);
|
dactyl.modules.prefs.set("browser.tabs.closeWindowWithLastTab", false);
|
||||||
};
|
};
|
||||||
var teardownModule = function (module) {
|
var teardownModule = function (module) {
|
||||||
dactyl.teardown();
|
dactyl.teardown();
|
||||||
@@ -118,8 +122,13 @@ var tests = {
|
|||||||
multiOutput: ["", "dactyl", "dactyl"]
|
multiOutput: ["", "dactyl", "dactyl"]
|
||||||
},
|
},
|
||||||
echo: {
|
echo: {
|
||||||
singleOutput: ["' - '"],
|
singleOutput: [
|
||||||
multiOutput: ["'\\n'", "window"],
|
["' - '", " - "]
|
||||||
|
],
|
||||||
|
multiOutput: [
|
||||||
|
["'\\n'", /\n/],
|
||||||
|
["window", /\[object\sChromeWindow\]/]
|
||||||
|
],
|
||||||
completions: [
|
completions: [
|
||||||
"",
|
"",
|
||||||
"window",
|
"window",
|
||||||
@@ -145,16 +154,22 @@ var tests = {
|
|||||||
noOutput: ["", "'js " + "".quote() + "'"],
|
noOutput: ["", "'js " + "".quote() + "'"],
|
||||||
someOutput: ["'ls'"]
|
someOutput: ["'ls'"]
|
||||||
},
|
},
|
||||||
extadd: { error: [""] },
|
extadd: {
|
||||||
extdelete: { error: [""] },
|
completions: [""],
|
||||||
extdisable: { error: [""] },
|
error: [""]
|
||||||
extenable: { error: [""] },
|
},
|
||||||
extoptions: { error: [""] },
|
extdelete: {
|
||||||
extrehash: { error: [""] },
|
completions: [""],
|
||||||
exttoggle: { error: [""] },
|
error: [""]
|
||||||
extupdate: { error: [""] },
|
},
|
||||||
|
get extdisable() this.extdelete,
|
||||||
|
get extenable() this.extdelete,
|
||||||
|
get extoptions() this.extdelete,
|
||||||
|
get extrehash() this.extdelete,
|
||||||
|
get exttoggle() this.extdelete,
|
||||||
|
get extupdate() this.extdelete,
|
||||||
feedkeys: {
|
feedkeys: {
|
||||||
noOutput: ["<Exc>"],
|
noOutput: ["<Esc>"],
|
||||||
error: [""]
|
error: [""]
|
||||||
},
|
},
|
||||||
finish: { noOutput: [""] },
|
finish: { noOutput: [""] },
|
||||||
@@ -223,7 +238,7 @@ var tests = {
|
|||||||
loadplugins: {},
|
loadplugins: {},
|
||||||
macros: {
|
macros: {
|
||||||
multiOutput: [""],
|
multiOutput: [""],
|
||||||
complete: [""]
|
completeions: [""]
|
||||||
},
|
},
|
||||||
map: {
|
map: {
|
||||||
multiOutput: ["", "i"],
|
multiOutput: ["", "i"],
|
||||||
@@ -240,7 +255,7 @@ var tests = {
|
|||||||
"-mode=some-nonexistent-mode <C-a> <C-a>",
|
"-mode=some-nonexistent-mode <C-a> <C-a>",
|
||||||
"-gtroup=some-nonexistent-group <C-a> <C-a>"
|
"-gtroup=some-nonexistent-group <C-a> <C-a>"
|
||||||
],
|
],
|
||||||
complete: [
|
completeions: [
|
||||||
"",
|
"",
|
||||||
"-",
|
"-",
|
||||||
"-mode=ex ",
|
"-mode=ex ",
|
||||||
@@ -253,7 +268,7 @@ var tests = {
|
|||||||
},
|
},
|
||||||
mapclear: {
|
mapclear: {
|
||||||
noOutput: [""],
|
noOutput: [""],
|
||||||
complete: [""]
|
completeions: [""]
|
||||||
},
|
},
|
||||||
mapgroup: {
|
mapgroup: {
|
||||||
multiOutput: [""],
|
multiOutput: [""],
|
||||||
@@ -267,7 +282,7 @@ var tests = {
|
|||||||
"some-nonexistent-group",
|
"some-nonexistent-group",
|
||||||
"foo -d='foo group' -nopersist 'bar.com,http://bar/*,http://bar,^http:'"
|
"foo -d='foo group' -nopersist 'bar.com,http://bar/*,http://bar,^http:'"
|
||||||
],
|
],
|
||||||
complete: [
|
completeions: [
|
||||||
"",
|
"",
|
||||||
"foo "
|
"foo "
|
||||||
],
|
],
|
||||||
@@ -276,13 +291,13 @@ var tests = {
|
|||||||
mark: {
|
mark: {
|
||||||
error: ["", "#", "xy"],
|
error: ["", "#", "xy"],
|
||||||
noOutput: ["y"],
|
noOutput: ["y"],
|
||||||
complete: [""]
|
completeions: [""]
|
||||||
},
|
},
|
||||||
marks: {
|
marks: {
|
||||||
init: ["delmarks q"],
|
init: ["delmarks q"],
|
||||||
multiOutput: ["", "y"],
|
multiOutput: ["", "y"],
|
||||||
error: ["q", "#"],
|
error: ["q", "#"],
|
||||||
complete: [""]
|
completeions: [""]
|
||||||
},
|
},
|
||||||
messages: {
|
messages: {
|
||||||
anyOutput: ["messages"]
|
anyOutput: ["messages"]
|
||||||
@@ -297,7 +312,7 @@ var tests = {
|
|||||||
"! some-nonexistent-rc.penta"
|
"! some-nonexistent-rc.penta"
|
||||||
],
|
],
|
||||||
error: ["some-nonexistent-rc.penta"],
|
error: ["some-nonexistent-rc.penta"],
|
||||||
complete: [""],
|
completeions: [""],
|
||||||
cleanup: ["silent !rm some-nonexistent-rc.penta"]
|
cleanup: ["silent !rm some-nonexistent-rc.penta"]
|
||||||
},
|
},
|
||||||
mksyntax: {
|
mksyntax: {
|
||||||
@@ -311,7 +326,7 @@ var tests = {
|
|||||||
"some-nonexistent-pentadactyl-dir/",
|
"some-nonexistent-pentadactyl-dir/",
|
||||||
"some-nonexistent-pentadactyl-dir/foo.vim"
|
"some-nonexistent-pentadactyl-dir/foo.vim"
|
||||||
],
|
],
|
||||||
complete: [""],
|
completeions: [""],
|
||||||
cleanup: ["silent !rm -r some-nonexistent-pentadactyl-dir/"]
|
cleanup: ["silent !rm -r some-nonexistent-pentadactyl-dir/"]
|
||||||
},
|
},
|
||||||
normal: {
|
normal: {
|
||||||
@@ -321,7 +336,7 @@ var tests = {
|
|||||||
},
|
},
|
||||||
open: {
|
open: {
|
||||||
noOutput: ["about:blank | about:home"],
|
noOutput: ["about:blank | about:home"],
|
||||||
complete: [
|
completions: [
|
||||||
"",
|
"",
|
||||||
"./",
|
"./",
|
||||||
"./ | ",
|
"./ | ",
|
||||||
@@ -335,11 +350,11 @@ var tests = {
|
|||||||
},
|
},
|
||||||
pageinfo: {
|
pageinfo: {
|
||||||
multiOutput: ["", "fgm"],
|
multiOutput: ["", "fgm"],
|
||||||
complete: [""],
|
completions: [""],
|
||||||
error: ["abcdefghijklmnopqrstuvwxyz", "f g m"]
|
error: ["abcdefghijklmnopqrstuvwxyz", "f g m"]
|
||||||
},
|
},
|
||||||
pagestyle: {
|
pagestyle: {
|
||||||
complete: [""]
|
completions: [""]
|
||||||
},
|
},
|
||||||
preferences: {}, // Skip for now
|
preferences: {}, // Skip for now
|
||||||
pwd: {
|
pwd: {
|
||||||
@@ -351,15 +366,19 @@ var tests = {
|
|||||||
"m foo bar"
|
"m foo bar"
|
||||||
],
|
],
|
||||||
error: ["", "#"],
|
error: ["", "#"],
|
||||||
complete: ["", "m "]
|
completions: ["", "m "]
|
||||||
},
|
|
||||||
qmarks: {
|
|
||||||
// init: ["delqmarks a-zA-Z0-9"],
|
|
||||||
// error: ["", "x"],
|
|
||||||
init: ["qmark x"],
|
|
||||||
multiOutput: ["", "m", "x"],
|
|
||||||
complete: [""]
|
|
||||||
},
|
},
|
||||||
|
qmarks: [
|
||||||
|
{
|
||||||
|
init: ["delqmarks a-zA-Z0-9"],
|
||||||
|
error: ["", "x"],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
init: ["qmark x"],
|
||||||
|
multiOutput: ["", "m", "x"],
|
||||||
|
completions: [""]
|
||||||
|
}
|
||||||
|
],
|
||||||
quit: {}, // Skip for now
|
quit: {}, // Skip for now
|
||||||
quitall: {}, // Skip for now
|
quitall: {}, // Skip for now
|
||||||
redraw: {
|
redraw: {
|
||||||
@@ -392,13 +411,21 @@ var tests = {
|
|||||||
"some-nonexistent/bad.penta"
|
"some-nonexistent/bad.penta"
|
||||||
],
|
],
|
||||||
singleOutput: ["some-nonexistent-file.js"],
|
singleOutput: ["some-nonexistent-file.js"],
|
||||||
complete: [
|
completions: [
|
||||||
"",
|
"",
|
||||||
"plugins/",
|
"plugins/",
|
||||||
"info/"
|
"info/"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
sanitize: {},
|
sanitize: {
|
||||||
|
// Skip details for now.
|
||||||
|
completions: [
|
||||||
|
"",
|
||||||
|
"-",
|
||||||
|
"-host=",
|
||||||
|
"-timespan="
|
||||||
|
]
|
||||||
|
},
|
||||||
saveas: {},
|
saveas: {},
|
||||||
sbclose: {
|
sbclose: {
|
||||||
noOutput: [""]
|
noOutput: [""]
|
||||||
@@ -478,8 +505,10 @@ function addTest(cmdName, testName, func) {
|
|||||||
|
|
||||||
function runCommands(cmdName, testName, commands, test, forbidErrors) {
|
function runCommands(cmdName, testName, commands, test, forbidErrors) {
|
||||||
addTest(cmdName, testName, function () {
|
addTest(cmdName, testName, function () {
|
||||||
commands.forEach(function (cmd) {
|
commands.forEach(function (val) {
|
||||||
// dump("CMD: " + cmdName + " " + cmd + "\n");
|
var [cmd, testVal] = Array.concat(val);
|
||||||
|
|
||||||
|
// dump("CMD: " + testName + " " + cmdName + " " + cmd + "\n");
|
||||||
dactyl.clearMessage();
|
dactyl.clearMessage();
|
||||||
dactyl.closeMessageWindow();
|
dactyl.closeMessageWindow();
|
||||||
|
|
||||||
@@ -491,74 +520,104 @@ function runCommands(cmdName, testName, commands, test, forbidErrors) {
|
|||||||
dactyl.runExCommand(cmd);
|
dactyl.runExCommand(cmd);
|
||||||
controller.waitForPageLoad(controller.tabs.activeTab);
|
controller.waitForPageLoad(controller.tabs.activeTab);
|
||||||
|
|
||||||
test(cmd);
|
test(cmd, testVal);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
function _runCommands(cmdName, testName, commands) {
|
function _runCommands(cmdName, testName, commands) {
|
||||||
addTest(cmdName, testName, function () {
|
addTest(cmdName, testName, function () {
|
||||||
commands.forEach(function (cmd) {
|
commands.forEach(function (value) {
|
||||||
dactyl.runExCommand(cmd);
|
var [cmd, test] = Array.concat(value);
|
||||||
|
|
||||||
|
// dump("CMD: " + testName + " " + cmdName + " " + cmd + "\n");
|
||||||
|
var res = dactyl.runExCommand(cmd);
|
||||||
controller.waitForPageLoad(controller.tabs.activeTab);
|
controller.waitForPageLoad(controller.tabs.activeTab);
|
||||||
|
if (test)
|
||||||
|
jumlib.assert(test(), "Initializing for " + cmdName + " tests failed: " + cmd.quote() + " " + test);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
for (var val in Iterator(tests)) (function ([command, params]) {
|
for (var val in Iterator(tests)) (function ([command, paramsList]) {
|
||||||
if (params.init)
|
Array.concat(paramsList).forEach(function (params, i) {
|
||||||
_runCommands(command, "init", params.init, function () {});
|
if (params.init)
|
||||||
|
_runCommands(command, "init" + (i || ""), params.init);
|
||||||
|
|
||||||
// Goddamn stupid fucking MozMill and its stupid fucking sandboxes with their ancient fucking JS versions.
|
// Goddamn stupid fucking MozMill and its stupid fucking sandboxes with their ancient fucking JS versions.
|
||||||
for (var val in Iterator(params)) (function ([testName, commands]) {
|
for (var val in Iterator(params)) (function ([test, commands]) {
|
||||||
switch (testName) {
|
var testName = test + (i || "");
|
||||||
case "noOutput":
|
|
||||||
runCommands(command, testName, commands, function (cmd) {
|
switch (test) {
|
||||||
dactyl.assertMessage(function (msg) !msg, "Unexpected command output: " + cmd);
|
case "noOutput":
|
||||||
});
|
runCommands(command, testName, commands, function (cmd, test) {
|
||||||
break;
|
var res = dactyl.assertMessage(function (msg) !msg, "Unexpected command output: " + cmd);
|
||||||
case "anyOutput":
|
if (res && test)
|
||||||
runCommands(command, testName, commands, function (cmd) {});
|
jumlib.assert(test(), "Initializing for " + cmdName + " tests failed: " + cmd.quote() + " " + test);
|
||||||
break;
|
|
||||||
case "someOutput":
|
|
||||||
runCommands(command, testName, commands, function (cmd) {
|
|
||||||
dactyl.assertMessage(/./, "Expected command output: " + cmd);
|
|
||||||
});
|
|
||||||
break;
|
|
||||||
case "singleOutput":
|
|
||||||
runCommands(command, testName, commands, function (cmd) {
|
|
||||||
dactyl.assertMessageLine(/./, "Expected command output: " + cmd);
|
|
||||||
}, true && !params.errorsOk);
|
|
||||||
break;
|
|
||||||
case "multiOutput":
|
|
||||||
runCommands(command, testName, commands, function (cmd) {
|
|
||||||
dactyl.assertMessageWindowOpen(true, "Expected command output: " + cmd);
|
|
||||||
}, true && !params.errorsOk);
|
|
||||||
break;
|
|
||||||
case "error":
|
|
||||||
addTest(command, testName, function () {
|
|
||||||
commands.forEach(function (cmd) {
|
|
||||||
cmd = command + cmd.replace(/^(!?) ?/, "$1 ");
|
|
||||||
dactyl.assertMessageError(function () {
|
|
||||||
dactyl.runExCommand(cmd);
|
|
||||||
controller.waitForPageLoad(controller.tabs.activeTab);
|
|
||||||
}, null, [], cmd);
|
|
||||||
});
|
});
|
||||||
});
|
break;
|
||||||
break;
|
case "anyOutput":
|
||||||
case "completions":
|
runCommands(command, testName, commands, function (cmd, test) {
|
||||||
addTest(command, testName, function () {
|
if (test)
|
||||||
commands.forEach(function (cmd) {
|
jumlib.assert(test(), "Initializing for " + cmdName + " tests failed: " + cmd.quote() + " " + test);
|
||||||
dactyl.assertNoErrorMessages(function () {
|
});
|
||||||
dactyl.runExCompletion(command + cmd.replace(/^(!?) ?/, "$1 "));
|
break;
|
||||||
|
case "someOutput":
|
||||||
|
runCommands(command, testName, commands, function (cmd, test) {
|
||||||
|
var res = dactyl.assertMessage(/./, "Expected command output: " + cmd);
|
||||||
|
if (res && res && test != null)
|
||||||
|
dactyl.assertMessage(test, "Running " + testName + " tests failed: " + cmd.quote() + " " + test.toSource());
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case "singleOutput":
|
||||||
|
runCommands(command, testName, commands, function (cmd, test) {
|
||||||
|
var res = dactyl.assertMessageLine(/./, "Expected command output: " + cmd);
|
||||||
|
if (res && test != null)
|
||||||
|
dactyl.assertMessageLine(test, "Running " + testName + " tests failed: " + cmd.quote() + " " + test.toSource());
|
||||||
|
}, true && !params.errorsOk);
|
||||||
|
break;
|
||||||
|
case "multiOutput":
|
||||||
|
runCommands(command, testName, commands, function (cmd, test) {
|
||||||
|
var res = dactyl.assertMessageWindowOpen(true, "Expected command output: " + cmd);
|
||||||
|
if (res && test != null)
|
||||||
|
dactyl.assertMessageWindow(test, "Running " + testName + " tests failed: " + cmd.quote() + " " + test.toSource());
|
||||||
|
}, true && !params.errorsOk);
|
||||||
|
break;
|
||||||
|
case "error":
|
||||||
|
addTest(command, testName, function () {
|
||||||
|
commands.forEach(function (val) {
|
||||||
|
var [cmd, test] = Array.concat(val);
|
||||||
|
cmd = command + cmd.replace(/^(!?) ?/, "$1 ");
|
||||||
|
|
||||||
|
var res = dactyl.assertMessageError(function () {
|
||||||
|
dactyl.runExCommand(cmd);
|
||||||
|
controller.waitForPageLoad(controller.tabs.activeTab);
|
||||||
|
}, null, [], cmd);
|
||||||
|
|
||||||
|
if (res && test != null)
|
||||||
|
dactyl.runExCommand(test, "Running " + testName + " tests failed: " + cmd.quote() + " " + test.toSource());
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
break;
|
||||||
break;
|
case "completions":
|
||||||
}
|
addTest(command, testName, function () {
|
||||||
})(val);
|
commands.forEach(function (val) {
|
||||||
|
var [cmd, test] = Array.concat(val);
|
||||||
|
|
||||||
if (params.cleanup)
|
dactyl.assertNoErrorMessages(function () {
|
||||||
_runCommands(command, "cleanup", params.cleanup, function () {});
|
dactyl.runExCompletion(command + cmd.replace(/^(!?) ?/, "$1 "));
|
||||||
|
if (test)
|
||||||
|
jumlib.assert(test(dactyl.modules.commandline.commandSession.completions.context),
|
||||||
|
"Initializing for " + cmdName + " tests failed: " + cmd.quote() + " " + test);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
})(val);
|
||||||
|
|
||||||
|
if (params.cleanup)
|
||||||
|
_runCommands(command, "cleanup" + (i || ""), params.cleanup);
|
||||||
|
});
|
||||||
})(val);
|
})(val);
|
||||||
|
|
||||||
// vim: sw=4 ts=8 et:
|
// vim: sw=4 ts=8 et:
|
||||||
|
|||||||
@@ -11,8 +11,9 @@ var jumlib = module("resource://mozmill/modules/jum.js");
|
|||||||
function toJSON(val) {
|
function toJSON(val) {
|
||||||
if (typeof val == "function")
|
if (typeof val == "function")
|
||||||
return val.toSource();
|
return val.toSource();
|
||||||
else
|
if (val instanceof Ci.nsIDOMNode || val instanceof Ci.nsIDOMWindow)
|
||||||
return val;
|
return { DOMNode: String(val) };
|
||||||
|
return val;
|
||||||
}
|
}
|
||||||
|
|
||||||
function test(val, params) {
|
function test(val, params) {
|
||||||
|
|||||||
Reference in New Issue
Block a user