it('should send an update request if there is sufficient data', function () {
var expected_msg = {_sQ: new Uint8Array(10), _sQlen: 0, flush: function() {}};
- RFB.messages.fbUpdateRequest(expected_msg, false, 0, 0, 240, 20);
+ RFB.messages.fbUpdateRequest(expected_msg, true, 0, 0, 640, 20);
client._framebufferUpdate = function () { return true; };
client._sock._websocket._receive_data(new Uint8Array([0]));
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() {}};
- RFB.messages.fbUpdateRequest(expected_msg, false, 0, 0, 240, 20);
+ RFB.messages.fbUpdateRequest(expected_msg, true, 0, 0, 640, 20);
// just enough to set FBU.rects
client._sock._websocket._receive_data(new Uint8Array([0, 0, 0, 3]));
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 only request non-incremental rects in continuous updates mode', function () {
- var expected_msg = {_sQ: new Uint8Array(10), _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, false, 120, 0, 120, 20);
-
- client._enabledContinuousUpdates = true;
- 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 not send a request in continuous updates mode when clean', function () {
- var expected_cdr = { cleanBox: { x: 0, y: 0, w: 240, h: 20 },
- dirtyBoxes: [] };
-
+ it('should not send a request in continuous updates mode', function () {
client._enabledContinuousUpdates = true;
client._framebufferUpdate = function () { return true; };
- client._display.getCleanDirtyReset = function () { return expected_cdr; };
client._sock._websocket._receive_data(new Uint8Array([0]));
expect(client._sock._websocket._get_sent_data()).to.have.length(0);
client._fb_width = 4;
client._fb_height = 4;
client._display.resize(4, 4);
- var initial_data = client._display._drawCtx.createImageData(4, 2);
- var initial_data_arr = target_data_check_arr.slice(0, 32);
- for (var i = 0; i < 32; i++) { initial_data.data[i] = initial_data_arr[i]; }
- client._display._drawCtx.putImageData(initial_data, 0, 0);
+ client._display.blitRgbxImage(0, 0, 4, 2, new Uint8Array(target_data_check_arr.slice(0, 32)), 0);
var info = [{ x: 0, y: 2, width: 2, height: 2, encoding: 0x01},
{ x: 2, y: 2, width: 2, height: 2, encoding: 0x01}];
- // data says [{ old_x: 0, old_y: 0 }, { old_x: 0, old_y: 0 }]
+ // data says [{ old_x: 2, old_y: 0 }, { old_x: 0, old_y: 0 }]
var rects = [[0, 2, 0, 0], [0, 0, 0, 0]];
send_fbu_msg([info[0]], [rects[0]], client, 2);
send_fbu_msg([info[1]], [rects[1]], client, -1);
// a really small frame
client._fb_width = 4;
client._fb_height = 4;
- client._display._fb_width = 4;
- client._display._fb_height = 4;
- client._display._viewportLoc.w = 4;
- client._display._viewportLoc.h = 4;
+ client._display.resize(4, 4);
client._fb_Bpp = 4;
});
it('should handle the COPYRECT encoding', function () {
// seed some initial data to copy
- var initial_data = client._display._drawCtx.createImageData(4, 2);
- var initial_data_arr = target_data_check_arr.slice(0, 32);
- for (var i = 0; i < 32; i++) { initial_data.data[i] = initial_data_arr[i]; }
- client._display._drawCtx.putImageData(initial_data, 0, 0);
+ client._display.blitRgbxImage(0, 0, 4, 2, new Uint8Array(target_data_check_arr.slice(0, 32)), 0);
var info = [{ x: 0, y: 2, width: 2, height: 2, encoding: 0x01},
{ x: 2, y: 2, width: 2, height: 2, encoding: 0x01}];
// a really small frame
client._fb_width = 4;
client._fb_height = 4;
- client._display._fb_width = 4;
- client._display._fb_height = 4;
- client._display._viewportLoc.w = 4;
- client._display._viewportLoc.h = 4;
+ client._display.resize(4, 4);
client._fb_Bpp = 4;
});
it('should handle a tile with only bg specified and an empty frame afterwards', function () {
// set the width so we can have two tiles
client._fb_width = 8;
- client._display._fb_width = 8;
- client._display._viewportLoc.w = 8;
+ client._display.resize(8, 4);
var info = [{ x: 0, y: 0, width: 32, height: 4, encoding: 0x05 }];
// a really small frame
client._fb_width = 4;
client._fb_height = 4;
- client._display._fb_width = 4;
- client._display._fb_height = 4;
- client._display._viewportLoc.w = 4;
- client._display._viewportLoc.h = 4;
+ client._display.resize(4, 4);
client._fb_Bpp = 4;
sinon.spy(client._display, 'resize');
client.set_onFBResize(sinon.spy());