Harmonise extended clipboard tests
Let them all follow the same pattern to make things more clear.
This commit is contained in:
parent
91307951d3
commit
0dd9678e64
|
@ -2528,17 +2528,14 @@ describe('Remote Frame Buffer Protocol Client', function () {
|
||||||
let data = [3, 0, 0, 0];
|
let data = [3, 0, 0, 0];
|
||||||
const flags = [0x10, 0x00, 0x00, 0x01];
|
const flags = [0x10, 0x00, 0x00, 0x01];
|
||||||
|
|
||||||
/* The size 10 (utf8 encoded string size) and the
|
let text = encodeUTF8("Aå漢字!");
|
||||||
string "Aå漢字!" utf8 encoded and deflated. */
|
let deflatedText = deflateWithSize(text);
|
||||||
let deflatedData = [120, 94, 99, 96, 96, 224, 114, 60,
|
|
||||||
188, 244, 217, 158, 69, 79, 215,
|
|
||||||
78, 87, 4, 0, 35, 207, 6, 66];
|
|
||||||
|
|
||||||
// How much data we are sending.
|
// How much data we are sending.
|
||||||
push32(data, toUnsigned32bit(-(4 + deflatedData.length)));
|
push32(data, toUnsigned32bit(-(4 + deflatedText.length)));
|
||||||
|
|
||||||
data = data.concat(flags);
|
data = data.concat(flags);
|
||||||
data = data.concat(deflatedData);
|
data = data.concat(Array.from(deflatedText));
|
||||||
|
|
||||||
const spy = sinon.spy();
|
const spy = sinon.spy();
|
||||||
client.addEventListener("clipboard", spy);
|
client.addEventListener("clipboard", spy);
|
||||||
|
@ -2562,15 +2559,12 @@ describe('Remote Frame Buffer Protocol Client', function () {
|
||||||
push32(data, toUnsigned32bit(-(4 + deflatedText.length)));
|
push32(data, toUnsigned32bit(-(4 + deflatedText.length)));
|
||||||
|
|
||||||
data = data.concat(flags);
|
data = data.concat(flags);
|
||||||
|
data = data.concat(Array.from(deflatedText));
|
||||||
let sendData = new Uint8Array(data.length + deflatedText.length);
|
|
||||||
sendData.set(data);
|
|
||||||
sendData.set(deflatedText, data.length);
|
|
||||||
|
|
||||||
const spy = sinon.spy();
|
const spy = sinon.spy();
|
||||||
client.addEventListener("clipboard", spy);
|
client.addEventListener("clipboard", spy);
|
||||||
|
|
||||||
client._sock._websocket._receiveData(sendData);
|
client._sock._websocket._receiveData(new Uint8Array(data));
|
||||||
expect(spy).to.have.been.calledOnce;
|
expect(spy).to.have.been.calledOnce;
|
||||||
expect(spy.args[0][0].detail.text).to.equal(expectedData);
|
expect(spy.args[0][0].detail.text).to.equal(expectedData);
|
||||||
client.removeEventListener("clipboard", spy);
|
client.removeEventListener("clipboard", spy);
|
||||||
|
@ -2589,15 +2583,12 @@ describe('Remote Frame Buffer Protocol Client', function () {
|
||||||
push32(data, toUnsigned32bit(-(4 + deflatedText.length)));
|
push32(data, toUnsigned32bit(-(4 + deflatedText.length)));
|
||||||
|
|
||||||
data = data.concat(flags);
|
data = data.concat(flags);
|
||||||
|
data = data.concat(Array.from(deflatedText));
|
||||||
let sendData = new Uint8Array(data.length + deflatedText.length);
|
|
||||||
sendData.set(data);
|
|
||||||
sendData.set(deflatedText, data.length);
|
|
||||||
|
|
||||||
const spy = sinon.spy();
|
const spy = sinon.spy();
|
||||||
client.addEventListener("clipboard", spy);
|
client.addEventListener("clipboard", spy);
|
||||||
|
|
||||||
client._sock._websocket._receiveData(sendData);
|
client._sock._websocket._receiveData(new Uint8Array(data));
|
||||||
expect(spy).to.have.been.calledOnce;
|
expect(spy).to.have.been.calledOnce;
|
||||||
expect(spy.args[0][0].detail.text).to.equal(expectedData);
|
expect(spy.args[0][0].detail.text).to.equal(expectedData);
|
||||||
client.removeEventListener("clipboard", spy);
|
client.removeEventListener("clipboard", spy);
|
||||||
|
|
Loading…
Reference in New Issue