mirror of
https://github.com/sorenisanerd/gotty.git
synced 2024-11-10 07:44:25 +00:00
c66ae7b2e4
Launch an Xspice and run: echo -ne "\033]844;127.0.0.1;9876\007" This will launch a SPiCE client connecting to 127.0.0.1:9876. Still need to add all the security stuff and generally be more defensive in the implementation.
65 lines
2.0 KiB
JavaScript
65 lines
2.0 KiB
JavaScript
suite('GraphicTest', function() {
|
|
var clientGui, displayPreProcess;
|
|
|
|
this.timeout(2000);
|
|
|
|
setup(function() {
|
|
wdi.Debug.debug = false;
|
|
clientGui = new wdi.ClientGui();
|
|
displayPreProcess = new wdi.DisplayPreProcess({
|
|
clientGui: clientGui
|
|
});
|
|
});
|
|
|
|
wdi.graphicTestUris.forEach(function (item) {
|
|
test(item.split('/').pop(), function(done) {
|
|
$.get(item).done(function(data) {
|
|
data = JSON.parse(data);
|
|
var testFunction = function() {
|
|
clientGui.getCanvas = function() {
|
|
return ctxOrigin.canvas;
|
|
};
|
|
clientGui.getContext = function() {
|
|
return ctxOrigin;
|
|
};
|
|
displayPreProcess.displayProcess.postProcess = function() {
|
|
assert.equal(ctxOrigin.canvas.toDataURL('image/png'), ctxExpected.canvas.toDataURL('image/png'), 'The image is not the same as expected');
|
|
done();
|
|
};
|
|
var rawSpiceMessage = JSON.parse(data.object);
|
|
// Depending on the browser version JSON.stringify stores typed arrays attributes or not
|
|
// We are interested on length, so if it is not there we create it.
|
|
if (typeof rawSpiceMessage.body.q.length === "undefined") {
|
|
rawSpiceMessage.body.q.length = Object.keys(rawSpiceMessage.body.q).length;
|
|
}
|
|
var queue = new wdi.ViewQueue();
|
|
queue.setData(rawSpiceMessage.body.q);
|
|
rawSpiceMessage.body = queue;
|
|
displayPreProcess.process(wdi.PacketFactory.extract(rawSpiceMessage));
|
|
};
|
|
var aux = false;
|
|
var ctxOrigin = $('<canvas/>')[0].getContext('2d');
|
|
var imgOrigin = new Image();
|
|
imgOrigin.onload = function() {
|
|
ctxOrigin.drawImage(imgOrigin, 0, 0);
|
|
if (aux)
|
|
testFunction();
|
|
else
|
|
aux = true;
|
|
};
|
|
imgOrigin.src = data.origin.replace(/\s/g, '+');
|
|
var ctxExpected = $('<canvas/>')[0].getContext('2d');
|
|
var imgExpected = new Image();
|
|
imgExpected.onload = function() {
|
|
ctxExpected.drawImage(imgExpected, 0, 0);
|
|
if (aux)
|
|
testFunction();
|
|
else
|
|
aux = true;
|
|
};
|
|
imgExpected.src = data.expected.replace(/\s/g, '+');
|
|
});
|
|
});
|
|
});
|
|
});
|