summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsamhed <samuel@cendio.se>2016-06-03 15:22:19 +0200
committersamhed <samuel@cendio.se>2016-06-03 16:35:59 +0200
commit37195e4b5e776d1ce19a65ba72009536de7dcd67 (patch)
tree6cfc41a3393010abe1dcb86a15ab62923a5fa1af
parent89d2837fa8e3f0498bbac7b7194f453d88bcbc1f (diff)
downloadnovnc-37195e4b5e776d1ce19a65ba72009536de7dcd67.tar.gz
Lower level check for framebuffer update requests
Try to avoid using helper functions with complex logic when verifying results as those helper functions are also something we want to verify. Also add a test for a mix of clean and dirty areas specifically to make sure that helper function behaves properly.
-rw-r--r--tests/test.rfb.js27
1 files changed, 18 insertions, 9 deletions
diff --git a/tests/test.rfb.js b/tests/test.rfb.js
index aed339c..a0fdf8f 100644
--- a/tests/test.rfb.js
+++ b/tests/test.rfb.js
@@ -1068,9 +1068,7 @@ describe('Remote Frame Buffer Protocol Client', function() {
flush: function () {}};
RFB.messages.pixelFormat(expected, 4, 3, true);
RFB.messages.clientEncodings(expected, client._encodings, false, true);
- var expected_cdr = { cleanBox: { x: 0, y: 0, w: 0, h: 0 },
- dirtyBoxes: [ { x: 0, y: 0, w: 27, h: 32 } ] };
- RFB.messages.fbUpdateRequests(expected, expected_cdr, 27, 32);
+ RFB.messages.fbUpdateRequest(expected, false, 0, 0, 27, 32);
send_server_init({ width: 27, height: 32 }, client);
expect(client._sock).to.have.sent(expected._sQ);
@@ -1157,9 +1155,7 @@ describe('Remote Frame Buffer Protocol Client', function() {
it('should send an update request if there is sufficient data', function () {
var expected_msg = {_sQ: new Uint8Array(10), _sQlen: 0, flush: function() {}};
- var expected_cdr = { cleanBox: { x: 0, y: 0, w: 0, h: 0 },
- dirtyBoxes: [ { x: 0, y: 0, w: 240, h: 20 } ] };
- RFB.messages.fbUpdateRequests(expected_msg, expected_cdr, 240, 20);
+ RFB.messages.fbUpdateRequest(expected_msg, false, 0, 0, 240, 20);
client._framebufferUpdate = function () { return true; };
client._sock._websocket._receive_data(new Uint8Array([0]));
@@ -1174,9 +1170,7 @@ describe('Remote Frame Buffer Protocol Client', function() {
it('should resume receiving an update if we previously did not have enough data', function () {
var expected_msg = {_sQ: new Uint8Array(10), _sQlen: 0, flush: function() {}};
- var expected_cdr = { cleanBox: { x: 0, y: 0, w: 0, h: 0 },
- dirtyBoxes: [ { x: 0, y: 0, w: 240, h: 20 } ] };
- RFB.messages.fbUpdateRequests(expected_msg, expected_cdr, 240, 20);
+ RFB.messages.fbUpdateRequest(expected_msg, false, 0, 0, 240, 20);
// just enough to set FBU.rects
client._sock._websocket._receive_data(new Uint8Array([0, 0, 0, 3]));
@@ -1188,6 +1182,21 @@ describe('Remote Frame Buffer Protocol Client', function() {
expect(client._sock).to.have.sent(expected_msg._sQ);
});
+ it('should send a request for both clean and dirty areas', function () {
+ var expected_msg = {_sQ: new Uint8Array(20), _sQlen: 0, flush: function() {}};
+ var expected_cdr = { cleanBox: { x: 0, y: 0, w: 120, h: 20 },
+ dirtyBoxes: [ { x: 120, y: 0, w: 120, h: 20 } ] };
+
+ RFB.messages.fbUpdateRequest(expected_msg, true, 0, 0, 120, 20);
+ RFB.messages.fbUpdateRequest(expected_msg, false, 120, 0, 120, 20);
+
+ client._framebufferUpdate = function () { return true; };
+ client._display.getCleanDirtyReset = function () { return expected_cdr; };
+ client._sock._websocket._receive_data(new Uint8Array([0]));
+
+ expect(client._sock).to.have.sent(expected_msg._sQ);
+ });
+
it('should parse out information from a header before any actual data comes in', function () {
client.set_onFBUReceive(sinon.spy());
var rect_info = { x: 8, y: 11, width: 27, height: 32, encoding: 0x02, encodingName: 'RRE' };