mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-01-08 12:22:34 +00:00
Bug 1609128 - Move all protocol.js tests next to its implementation. r=jdescottes
Differential Revision: https://phabricator.services.mozilla.com/D59866 --HG-- rename : devtools/server/tests/unit/test_protocol_abort.js => devtools/shared/protocol/tests/xpcshell/test_protocol_abort.js rename : devtools/server/tests/unit/test_protocol_async.js => devtools/shared/protocol/tests/xpcshell/test_protocol_async.js rename : devtools/server/tests/unit/test_protocol_children.js => devtools/shared/protocol/tests/xpcshell/test_protocol_children.js rename : devtools/shared/tests/unit/test_protocol_index.js => devtools/shared/protocol/tests/xpcshell/test_protocol_index.js rename : devtools/server/tests/unit/test_protocol_longstring.js => devtools/shared/protocol/tests/xpcshell/test_protocol_longstring.js rename : devtools/server/tests/unit/test_protocol_simple.js => devtools/shared/protocol/tests/xpcshell/test_protocol_simple.js rename : devtools/server/tests/unit/test_protocol_stack.js => devtools/shared/protocol/tests/xpcshell/test_protocol_stack.js rename : devtools/server/tests/unit/test_protocol_unregister.js => devtools/shared/protocol/tests/xpcshell/test_protocol_unregister.js rename : devtools/server/tests/unit/test_protocol_watchFronts.js => devtools/shared/protocol/tests/xpcshell/test_protocol_watchFronts.js extra : moz-landing-system : lando
This commit is contained in:
parent
9bd96c3a3f
commit
2d3e4c8ba0
@ -511,81 +511,6 @@ function writeFile(fileName, content) {
|
||||
}
|
||||
}
|
||||
|
||||
function connectPipeTracing() {
|
||||
return new TracingTransport(DebuggerServer.connectPipe());
|
||||
}
|
||||
|
||||
function TracingTransport(childTransport) {
|
||||
this.hooks = null;
|
||||
this.child = childTransport;
|
||||
this.child.hooks = this;
|
||||
|
||||
this.expectations = [];
|
||||
this.packets = [];
|
||||
this.checkIndex = 0;
|
||||
}
|
||||
|
||||
TracingTransport.prototype = {
|
||||
// Remove actor names
|
||||
normalize: function(packet) {
|
||||
return JSON.parse(
|
||||
JSON.stringify(packet, (key, value) => {
|
||||
if (key === "to" || key === "from" || key === "actor") {
|
||||
return "<actorid>";
|
||||
}
|
||||
return value;
|
||||
})
|
||||
);
|
||||
},
|
||||
send: function(packet) {
|
||||
this.packets.push({
|
||||
type: "sent",
|
||||
packet: this.normalize(packet),
|
||||
});
|
||||
return this.child.send(packet);
|
||||
},
|
||||
close: function() {
|
||||
return this.child.close();
|
||||
},
|
||||
ready: function() {
|
||||
return this.child.ready();
|
||||
},
|
||||
onPacket: function(packet) {
|
||||
this.packets.push({
|
||||
type: "received",
|
||||
packet: this.normalize(packet),
|
||||
});
|
||||
this.hooks.onPacket(packet);
|
||||
},
|
||||
onClosed: function() {
|
||||
this.hooks.onClosed();
|
||||
},
|
||||
|
||||
expectSend: function(expected) {
|
||||
const packet = this.packets[this.checkIndex++];
|
||||
Assert.equal(packet.type, "sent");
|
||||
deepEqual(packet.packet, this.normalize(expected));
|
||||
},
|
||||
|
||||
expectReceive: function(expected) {
|
||||
const packet = this.packets[this.checkIndex++];
|
||||
Assert.equal(packet.type, "received");
|
||||
deepEqual(packet.packet, this.normalize(expected));
|
||||
},
|
||||
|
||||
// Write your tests, call dumpLog at the end, inspect the output,
|
||||
// then sprinkle the calls through the right places in your test.
|
||||
dumpLog: function() {
|
||||
for (const entry of this.packets) {
|
||||
if (entry.type === "sent") {
|
||||
dumpn("trace.expectSend(" + entry.packet + ");");
|
||||
} else {
|
||||
dumpn("trace.expectReceive(" + entry.packet + ");");
|
||||
}
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
function StubTransport() {}
|
||||
StubTransport.prototype.ready = function() {};
|
||||
StubTransport.prototype.send = function() {};
|
||||
|
@ -81,14 +81,6 @@ support-files =
|
||||
[test_nativewrappers.js]
|
||||
[test_nodelistactor.js]
|
||||
[test_format_command.js]
|
||||
[test_protocol_abort.js]
|
||||
[test_protocol_async.js]
|
||||
[test_protocol_children.js]
|
||||
[test_protocol_longstring.js]
|
||||
[test_protocol_simple.js]
|
||||
[test_protocol_stack.js]
|
||||
[test_protocol_unregister.js]
|
||||
[test_protocol_watchFronts.js]
|
||||
[test_breakpoint-01.js]
|
||||
[test_register_actor.js]
|
||||
[test_breakpoint-02.js]
|
||||
|
@ -18,3 +18,5 @@ DevToolsModules(
|
||||
'types.js',
|
||||
'utils.js',
|
||||
)
|
||||
|
||||
XPCSHELL_TESTS_MANIFESTS += ['tests/xpcshell/xpcshell.ini']
|
||||
|
6
devtools/shared/protocol/tests/xpcshell/.eslintrc.js
Normal file
6
devtools/shared/protocol/tests/xpcshell/.eslintrc.js
Normal file
@ -0,0 +1,6 @@
|
||||
"use strict";
|
||||
|
||||
module.exports = {
|
||||
// Extend from the common devtools xpcshell eslintrc config.
|
||||
"extends": "../../../../.eslintrc.xpcshell.js"
|
||||
};
|
94
devtools/shared/protocol/tests/xpcshell/head.js
Normal file
94
devtools/shared/protocol/tests/xpcshell/head.js
Normal file
@ -0,0 +1,94 @@
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
"use strict";
|
||||
|
||||
const { require } = ChromeUtils.import("resource://devtools/shared/Loader.jsm");
|
||||
const Services = require("Services");
|
||||
const { DebuggerServer } = require("devtools/server/debugger-server");
|
||||
const { DebuggerClient } = require("devtools/shared/client/debugger-client");
|
||||
|
||||
const defer = require("devtools/shared/defer");
|
||||
|
||||
function dumpn(msg) {
|
||||
dump("DBG-TEST: " + msg + "\n");
|
||||
}
|
||||
|
||||
function connectPipeTracing() {
|
||||
return new TracingTransport(DebuggerServer.connectPipe());
|
||||
}
|
||||
|
||||
/**
|
||||
* Mock the `Transport` class in order to intercept all the packet
|
||||
* getting in and out and then being able to assert them and dump them.
|
||||
*/
|
||||
function TracingTransport(childTransport) {
|
||||
this.hooks = null;
|
||||
this.child = childTransport;
|
||||
this.child.hooks = this;
|
||||
|
||||
this.expectations = [];
|
||||
this.packets = [];
|
||||
this.checkIndex = 0;
|
||||
}
|
||||
|
||||
TracingTransport.prototype = {
|
||||
// Remove actor names
|
||||
normalize: function(packet) {
|
||||
return JSON.parse(
|
||||
JSON.stringify(packet, (key, value) => {
|
||||
if (key === "to" || key === "from" || key === "actor") {
|
||||
return "<actorid>";
|
||||
}
|
||||
return value;
|
||||
})
|
||||
);
|
||||
},
|
||||
send: function(packet) {
|
||||
this.packets.push({
|
||||
type: "sent",
|
||||
packet: this.normalize(packet),
|
||||
});
|
||||
return this.child.send(packet);
|
||||
},
|
||||
close: function() {
|
||||
return this.child.close();
|
||||
},
|
||||
ready: function() {
|
||||
return this.child.ready();
|
||||
},
|
||||
onPacket: function(packet) {
|
||||
this.packets.push({
|
||||
type: "received",
|
||||
packet: this.normalize(packet),
|
||||
});
|
||||
this.hooks.onPacket(packet);
|
||||
},
|
||||
onClosed: function() {
|
||||
this.hooks.onClosed();
|
||||
},
|
||||
|
||||
expectSend: function(expected) {
|
||||
const packet = this.packets[this.checkIndex++];
|
||||
Assert.equal(packet.type, "sent");
|
||||
deepEqual(packet.packet, this.normalize(expected));
|
||||
},
|
||||
|
||||
expectReceive: function(expected) {
|
||||
const packet = this.packets[this.checkIndex++];
|
||||
Assert.equal(packet.type, "received");
|
||||
deepEqual(packet.packet, this.normalize(expected));
|
||||
},
|
||||
|
||||
// Write your tests, call dumpLog at the end, inspect the output,
|
||||
// then sprinkle the calls through the right places in your test.
|
||||
dumpLog: function() {
|
||||
for (const entry of this.packets) {
|
||||
if (entry.type === "sent") {
|
||||
dumpn("trace.expectSend(" + entry.packet + ");");
|
||||
} else {
|
||||
dumpn("trace.expectReceive(" + entry.packet + ");");
|
||||
}
|
||||
}
|
||||
},
|
||||
};
|
16
devtools/shared/protocol/tests/xpcshell/xpcshell.ini
Normal file
16
devtools/shared/protocol/tests/xpcshell/xpcshell.ini
Normal file
@ -0,0 +1,16 @@
|
||||
[DEFAULT]
|
||||
tags = devtools
|
||||
head = head.js
|
||||
firefox-appdir = browser
|
||||
skip-if = toolkit == 'android'
|
||||
support-files =
|
||||
|
||||
[test_protocol_abort.js]
|
||||
[test_protocol_async.js]
|
||||
[test_protocol_children.js]
|
||||
[test_protocol_index.js]
|
||||
[test_protocol_longstring.js]
|
||||
[test_protocol_simple.js]
|
||||
[test_protocol_stack.js]
|
||||
[test_protocol_unregister.js]
|
||||
[test_protocol_watchFronts.js]
|
@ -42,4 +42,3 @@ run-if = nightly_build
|
||||
[test_stack.js]
|
||||
[test_defer.js]
|
||||
[test_executeSoon.js]
|
||||
[test_protocol_index.js]
|
||||
|
Loading…
Reference in New Issue
Block a user