Skip to content

Commit

Permalink
Remove ledstatus event, and update test to check internal state instead
Browse files Browse the repository at this point in the history
  • Loading branch information
otthou committed Aug 30, 2023
1 parent 934f78e commit df8df55
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 17 deletions.
6 changes: 1 addition & 5 deletions core/rfb.js
Original file line number Diff line number Diff line change
Expand Up @@ -2756,16 +2756,12 @@ export default class RFB extends EventTargetMixin {
}

let data = this._sock.rQshift8();
let scrollLock = data & 1 ? true : false;
// ScrollLock state can be retrieved with data & 1. This is currently not needed.
let numLock = data & 2 ? true : false;
let capsLock = data & 4 ? true : false;
this._remoteCapsLock = capsLock;
this._remoteNumLock = numLock;

this.dispatchEvent(new CustomEvent(
"ledstatus",
{ detail: { scrollLock: scrollLock, numLock: numLock, capsLock: capsLock } }));

return true;
}

Expand Down
20 changes: 8 additions & 12 deletions tests/test.rfb.js
Original file line number Diff line number Diff line change
Expand Up @@ -3125,28 +3125,24 @@ describe('Remote Frame Buffer Protocol Client', function () {

sendFbuMsg([{ x: 0, y: 0, width: 0, height: 0, encoding: -261 }], [data], client);

expect(client._remoteCapsLock).to.equal(true);
expect(client._remoteNumLock).to.equal(true);

data = [];
push8(data, 0b011);

sendFbuMsg([{ x: 0, y: 0, width: 0, height: 0, encoding: -261 }], [data], client);

expect(client._remoteCapsLock).to.equal(false);
expect(client._remoteNumLock).to.equal(true);

data = [];
push8(data, 0b000);

sendFbuMsg([{ x: 0, y: 0, width: 0, height: 0, encoding: -261 }], [data], client);

expect(spy).to.have.been.calledThrice;
expect(spy.args[0][0].detail.capsLock).to.equal(true);
expect(spy.args[0][0].detail.numLock).to.equal(true);
expect(spy.args[0][0].detail.scrollLock).to.equal(false);

expect(spy.args[1][0].detail.capsLock).to.equal(false);
expect(spy.args[1][0].detail.numLock).to.equal(true);
expect(spy.args[1][0].detail.scrollLock).to.equal(true);

expect(spy.args[2][0].detail.capsLock).to.equal(false);
expect(spy.args[2][0].detail.numLock).to.equal(false);
expect(spy.args[2][0].detail.scrollLock).to.equal(false);
expect(client._remoteCapsLock).to.equal(false);
expect(client._remoteNumLock).to.equal(false);
});
});
});
Expand Down

0 comments on commit df8df55

Please sign in to comment.