]>
git.proxmox.com Git - mirror_novnc.git/blob - tests/test.tight.js
1 const expect
= chai
.expect
;
3 import Websock
from '../core/websock.js';
4 import Display
from '../core/display.js';
6 import TightDecoder
from '../core/decoders/tight.js';
8 import FakeWebSocket
from './fake.websocket.js';
10 function testDecodeRect(decoder
, x
, y
, width
, height
, data
, display
, depth
) {
14 sock
.open("ws://example.com");
16 sock
.on('message', () => {
17 decoder
.decodeRect(x
, y
, width
, height
, sock
, display
, depth
);
20 // Empty messages are filtered at multiple layers, so we need to
22 if (data
.length
=== 0) {
23 decoder
.decodeRect(x
, y
, width
, height
, sock
, display
, depth
);
25 sock
._websocket
._receiveData(new Uint8Array(data
));
31 describe('Tight Decoder', function () {
35 before(FakeWebSocket
.replace
);
36 after(FakeWebSocket
.restore
);
38 beforeEach(function () {
39 decoder
= new TightDecoder();
40 display
= new Display(document
.createElement('canvas'));
44 it('should handle fill rects', function () {
45 testDecodeRect(decoder
, 0, 0, 4, 4,
46 [0x80, 0xff, 0x88, 0x44],
49 let targetData
= new Uint8Array([
50 0xff, 0x88, 0x44, 255, 0xff, 0x88, 0x44, 255, 0xff, 0x88, 0x44, 255, 0xff, 0x88, 0x44, 255,
51 0xff, 0x88, 0x44, 255, 0xff, 0x88, 0x44, 255, 0xff, 0x88, 0x44, 255, 0xff, 0x88, 0x44, 255,
52 0xff, 0x88, 0x44, 255, 0xff, 0x88, 0x44, 255, 0xff, 0x88, 0x44, 255, 0xff, 0x88, 0x44, 255,
53 0xff, 0x88, 0x44, 255, 0xff, 0x88, 0x44, 255, 0xff, 0x88, 0x44, 255, 0xff, 0x88, 0x44, 255,
56 expect(display
).to
.have
.displayed(targetData
);
59 it('should handle uncompressed copy rects', function () {
60 let blueData
= [ 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0xff ];
61 let greenData
= [ 0x00, 0x00, 0xff, 0x00, 0x00, 0xff, 0x00 ];
63 testDecodeRect(decoder
, 0, 0, 2, 1, blueData
, display
, 24);
64 testDecodeRect(decoder
, 0, 1, 2, 1, blueData
, display
, 24);
65 testDecodeRect(decoder
, 2, 0, 2, 1, greenData
, display
, 24);
66 testDecodeRect(decoder
, 2, 1, 2, 1, greenData
, display
, 24);
67 testDecodeRect(decoder
, 0, 2, 2, 1, greenData
, display
, 24);
68 testDecodeRect(decoder
, 0, 3, 2, 1, greenData
, display
, 24);
69 testDecodeRect(decoder
, 2, 2, 2, 1, blueData
, display
, 24);
70 testDecodeRect(decoder
, 2, 3, 2, 1, blueData
, display
, 24);
72 let targetData
= new Uint8Array([
73 0x00, 0x00, 0xff, 255, 0x00, 0x00, 0xff, 255, 0x00, 0xff, 0x00, 255, 0x00, 0xff, 0x00, 255,
74 0x00, 0x00, 0xff, 255, 0x00, 0x00, 0xff, 255, 0x00, 0xff, 0x00, 255, 0x00, 0xff, 0x00, 255,
75 0x00, 0xff, 0x00, 255, 0x00, 0xff, 0x00, 255, 0x00, 0x00, 0xff, 255, 0x00, 0x00, 0xff, 255,
76 0x00, 0xff, 0x00, 255, 0x00, 0xff, 0x00, 255, 0x00, 0x00, 0xff, 255, 0x00, 0x00, 0xff, 255
79 expect(display
).to
.have
.displayed(targetData
);
82 it('should handle compressed copy rects', function () {
86 // Pixels (compressed)
88 0x78, 0x9c, 0x63, 0x60, 0xf8, 0xcf, 0x00, 0x44,
89 0x60, 0x82, 0x01, 0x99, 0x8d, 0x29, 0x02, 0xa6,
90 0x00, 0x7e, 0xbf, 0x0f, 0xf1 ];
92 testDecodeRect(decoder
, 0, 0, 4, 4, data
, display
, 24);
94 let targetData
= new Uint8Array([
95 0x00, 0x00, 0xff, 255, 0x00, 0x00, 0xff, 255, 0x00, 0xff, 0x00, 255, 0x00, 0xff, 0x00, 255,
96 0x00, 0x00, 0xff, 255, 0x00, 0x00, 0xff, 255, 0x00, 0xff, 0x00, 255, 0x00, 0xff, 0x00, 255,
97 0x00, 0xff, 0x00, 255, 0x00, 0xff, 0x00, 255, 0x00, 0x00, 0xff, 255, 0x00, 0x00, 0xff, 255,
98 0x00, 0xff, 0x00, 255, 0x00, 0xff, 0x00, 255, 0x00, 0x00, 0xff, 255, 0x00, 0x00, 0xff, 255
101 expect(display
).to
.have
.displayed(targetData
);
104 it('should handle uncompressed mono rects', function () {
109 0x01, 0x00, 0x00, 0xff, 0x00, 0xff, 0x00,
111 0x30, 0x30, 0xc0, 0xc0 ];
113 testDecodeRect(decoder
, 0, 0, 4, 4, data
, display
, 24);
115 let targetData
= new Uint8Array([
116 0x00, 0x00, 0xff, 255, 0x00, 0x00, 0xff, 255, 0x00, 0xff, 0x00, 255, 0x00, 0xff, 0x00, 255,
117 0x00, 0x00, 0xff, 255, 0x00, 0x00, 0xff, 255, 0x00, 0xff, 0x00, 255, 0x00, 0xff, 0x00, 255,
118 0x00, 0xff, 0x00, 255, 0x00, 0xff, 0x00, 255, 0x00, 0x00, 0xff, 255, 0x00, 0x00, 0xff, 255,
119 0x00, 0xff, 0x00, 255, 0x00, 0xff, 0x00, 255, 0x00, 0x00, 0xff, 255, 0x00, 0x00, 0xff, 255
122 expect(display
).to
.have
.displayed(targetData
);
125 it('should handle compressed mono rects', function () {
126 display
.resize(4, 12);
132 0x01, 0x00, 0x00, 0xff, 0x00, 0xff, 0x00,
133 // Pixels (compressed)
135 0x78, 0x9c, 0x33, 0x30, 0x38, 0x70, 0xc0, 0x00,
136 0x8a, 0x01, 0x21, 0x3c, 0x05, 0xa1 ];
138 testDecodeRect(decoder
, 0, 0, 4, 12, data
, display
, 24);
140 let targetData
= new Uint8Array([
141 0x00, 0x00, 0xff, 255, 0x00, 0x00, 0xff, 255, 0x00, 0xff, 0x00, 255, 0x00, 0xff, 0x00, 255,
142 0x00, 0x00, 0xff, 255, 0x00, 0x00, 0xff, 255, 0x00, 0xff, 0x00, 255, 0x00, 0xff, 0x00, 255,
143 0x00, 0xff, 0x00, 255, 0x00, 0xff, 0x00, 255, 0x00, 0x00, 0xff, 255, 0x00, 0x00, 0xff, 255,
144 0x00, 0xff, 0x00, 255, 0x00, 0xff, 0x00, 255, 0x00, 0x00, 0xff, 255, 0x00, 0x00, 0xff, 255,
145 0x00, 0x00, 0xff, 255, 0x00, 0x00, 0xff, 255, 0x00, 0xff, 0x00, 255, 0x00, 0xff, 0x00, 255,
146 0x00, 0x00, 0xff, 255, 0x00, 0x00, 0xff, 255, 0x00, 0xff, 0x00, 255, 0x00, 0xff, 0x00, 255,
147 0x00, 0xff, 0x00, 255, 0x00, 0xff, 0x00, 255, 0x00, 0x00, 0xff, 255, 0x00, 0x00, 0xff, 255,
148 0x00, 0xff, 0x00, 255, 0x00, 0xff, 0x00, 255, 0x00, 0x00, 0xff, 255, 0x00, 0x00, 0xff, 255,
149 0x00, 0x00, 0xff, 255, 0x00, 0x00, 0xff, 255, 0x00, 0xff, 0x00, 255, 0x00, 0xff, 0x00, 255,
150 0x00, 0x00, 0xff, 255, 0x00, 0x00, 0xff, 255, 0x00, 0xff, 0x00, 255, 0x00, 0xff, 0x00, 255,
151 0x00, 0xff, 0x00, 255, 0x00, 0xff, 0x00, 255, 0x00, 0x00, 0xff, 255, 0x00, 0x00, 0xff, 255,
152 0x00, 0xff, 0x00, 255, 0x00, 0xff, 0x00, 255, 0x00, 0x00, 0xff, 255, 0x00, 0x00, 0xff, 255
155 expect(display
).to
.have
.displayed(targetData
);
158 it('should handle uncompressed palette rects', function () {
163 0x02, 0x00, 0x00, 0xff, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00,
165 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01 ];
170 0x02, 0x00, 0x00, 0xff, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00,
172 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00 ];
174 testDecodeRect(decoder
, 0, 0, 4, 2, data1
, display
, 24);
175 testDecodeRect(decoder
, 0, 2, 4, 2, data2
, display
, 24);
177 let targetData
= new Uint8Array([
178 0x00, 0x00, 0xff, 255, 0x00, 0x00, 0xff, 255, 0x00, 0xff, 0x00, 255, 0x00, 0xff, 0x00, 255,
179 0x00, 0x00, 0xff, 255, 0x00, 0x00, 0xff, 255, 0x00, 0xff, 0x00, 255, 0x00, 0xff, 0x00, 255,
180 0x00, 0xff, 0x00, 255, 0x00, 0xff, 0x00, 255, 0x00, 0x00, 0xff, 255, 0x00, 0x00, 0xff, 255,
181 0x00, 0xff, 0x00, 255, 0x00, 0xff, 0x00, 255, 0x00, 0x00, 0xff, 255, 0x00, 0x00, 0xff, 255
184 expect(display
).to
.have
.displayed(targetData
);
187 it('should handle compressed palette rects', function () {
192 0x02, 0x00, 0x00, 0xff, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00,
193 // Pixels (compressed)
195 0x78, 0x9c, 0x63, 0x60, 0x60, 0x64, 0x64, 0x00,
196 0x62, 0x08, 0xc9, 0xc0, 0x00, 0x00, 0x00, 0x54,
199 testDecodeRect(decoder
, 0, 0, 4, 4, data
, display
, 24);
201 let targetData
= new Uint8Array([
202 0x00, 0x00, 0xff, 255, 0x00, 0x00, 0xff, 255, 0x00, 0xff, 0x00, 255, 0x00, 0xff, 0x00, 255,
203 0x00, 0x00, 0xff, 255, 0x00, 0x00, 0xff, 255, 0x00, 0xff, 0x00, 255, 0x00, 0xff, 0x00, 255,
204 0x00, 0xff, 0x00, 255, 0x00, 0xff, 0x00, 255, 0x00, 0x00, 0xff, 255, 0x00, 0x00, 0xff, 255,
205 0x00, 0xff, 0x00, 255, 0x00, 0xff, 0x00, 255, 0x00, 0x00, 0xff, 255, 0x00, 0x00, 0xff, 255
208 expect(display
).to
.have
.displayed(targetData
);
211 it
.skip('should handle uncompressed gradient rects', function () {
212 // Not implemented yet
215 it
.skip('should handle compressed gradient rects', function () {
216 // Not implemented yet
219 it('should handle empty copy rects', function () {
220 display
.fillRect(0, 0, 4, 4, [ 0x00, 0x00, 0xff ]);
221 display
.fillRect(2, 0, 2, 2, [ 0x00, 0xff, 0x00 ]);
222 display
.fillRect(0, 2, 2, 2, [ 0x00, 0xff, 0x00 ]);
224 testDecodeRect(decoder
, 1, 2, 0, 0, [ 0x00 ], display
, 24);
226 let targetData
= new Uint8Array([
227 0x00, 0x00, 0xff, 255, 0x00, 0x00, 0xff, 255, 0x00, 0xff, 0x00, 255, 0x00, 0xff, 0x00, 255,
228 0x00, 0x00, 0xff, 255, 0x00, 0x00, 0xff, 255, 0x00, 0xff, 0x00, 255, 0x00, 0xff, 0x00, 255,
229 0x00, 0xff, 0x00, 255, 0x00, 0xff, 0x00, 255, 0x00, 0x00, 0xff, 255, 0x00, 0x00, 0xff, 255,
230 0x00, 0xff, 0x00, 255, 0x00, 0xff, 0x00, 255, 0x00, 0x00, 0xff, 255, 0x00, 0x00, 0xff, 255
233 expect(display
).to
.have
.displayed(targetData
);
236 it('should handle empty palette rects', function () {
237 display
.fillRect(0, 0, 4, 4, [ 0x00, 0x00, 0xff ]);
238 display
.fillRect(2, 0, 2, 2, [ 0x00, 0xff, 0x00 ]);
239 display
.fillRect(0, 2, 2, 2, [ 0x00, 0xff, 0x00 ]);
241 testDecodeRect(decoder
, 1, 2, 0, 0,
244 0xff, 0xff, 0xff ], display
, 24);
246 let targetData
= new Uint8Array([
247 0x00, 0x00, 0xff, 255, 0x00, 0x00, 0xff, 255, 0x00, 0xff, 0x00, 255, 0x00, 0xff, 0x00, 255,
248 0x00, 0x00, 0xff, 255, 0x00, 0x00, 0xff, 255, 0x00, 0xff, 0x00, 255, 0x00, 0xff, 0x00, 255,
249 0x00, 0xff, 0x00, 255, 0x00, 0xff, 0x00, 255, 0x00, 0x00, 0xff, 255, 0x00, 0x00, 0xff, 255,
250 0x00, 0xff, 0x00, 255, 0x00, 0xff, 0x00, 255, 0x00, 0x00, 0xff, 255, 0x00, 0x00, 0xff, 255
253 expect(display
).to
.have
.displayed(targetData
);
256 it('should handle empty fill rects', function () {
257 display
.fillRect(0, 0, 4, 4, [ 0x00, 0x00, 0xff ]);
258 display
.fillRect(2, 0, 2, 2, [ 0x00, 0xff, 0x00 ]);
259 display
.fillRect(0, 2, 2, 2, [ 0x00, 0xff, 0x00 ]);
261 testDecodeRect(decoder
, 1, 2, 0, 0,
262 [ 0x80, 0xff, 0xff, 0xff ], display
, 24);
264 let targetData
= new Uint8Array([
265 0x00, 0x00, 0xff, 255, 0x00, 0x00, 0xff, 255, 0x00, 0xff, 0x00, 255, 0x00, 0xff, 0x00, 255,
266 0x00, 0x00, 0xff, 255, 0x00, 0x00, 0xff, 255, 0x00, 0xff, 0x00, 255, 0x00, 0xff, 0x00, 255,
267 0x00, 0xff, 0x00, 255, 0x00, 0xff, 0x00, 255, 0x00, 0x00, 0xff, 255, 0x00, 0x00, 0xff, 255,
268 0x00, 0xff, 0x00, 255, 0x00, 0xff, 0x00, 255, 0x00, 0x00, 0xff, 255, 0x00, 0x00, 0xff, 255
271 expect(display
).to
.have
.displayed(targetData
);
274 it('should handle JPEG rects', function (done
) {
279 0xff, 0xd8, 0xff, 0xe0, 0x00, 0x10, 0x4a, 0x46,
280 0x49, 0x46, 0x00, 0x01, 0x01, 0x01, 0x00, 0x48,
281 0x00, 0x48, 0x00, 0x00, 0xff, 0xfe, 0x00, 0x13,
282 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x20,
283 0x77, 0x69, 0x74, 0x68, 0x20, 0x47, 0x49, 0x4d,
284 0x50, 0xff, 0xdb, 0x00, 0x43, 0x00, 0x01, 0x01,
285 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
286 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
287 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
288 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
289 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
290 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
291 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
292 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0xff, 0xdb,
293 0x00, 0x43, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
294 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
295 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
296 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
297 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
298 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
299 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
300 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
301 0x01, 0x01, 0x01, 0xff, 0xc2, 0x00, 0x11, 0x08,
302 0x00, 0x04, 0x00, 0x04, 0x03, 0x01, 0x11, 0x00,
303 0x02, 0x11, 0x01, 0x03, 0x11, 0x01, 0xff, 0xc4,
304 0x00, 0x14, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
305 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
306 0x00, 0x00, 0x00, 0x07, 0xff, 0xc4, 0x00, 0x14,
307 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
308 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
309 0x00, 0x08, 0xff, 0xda, 0x00, 0x0c, 0x03, 0x01,
310 0x00, 0x02, 0x10, 0x03, 0x10, 0x00, 0x00, 0x01,
311 0x1e, 0x0a, 0xa7, 0x7f, 0xff, 0xc4, 0x00, 0x14,
312 0x10, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
313 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
314 0x00, 0x05, 0xff, 0xda, 0x00, 0x08, 0x01, 0x01,
315 0x00, 0x01, 0x05, 0x02, 0x5d, 0x74, 0x41, 0x47,
316 0xff, 0xc4, 0x00, 0x1f, 0x11, 0x00, 0x01, 0x04,
317 0x02, 0x02, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00,
318 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x04, 0x05,
319 0x07, 0x08, 0x14, 0x16, 0x03, 0x15, 0x17, 0x25,
320 0x26, 0xff, 0xda, 0x00, 0x08, 0x01, 0x03, 0x01,
321 0x01, 0x3f, 0x01, 0xad, 0x35, 0xa6, 0x13, 0xb8,
322 0x10, 0x98, 0x5d, 0x8a, 0xb1, 0x41, 0x7e, 0x43,
323 0x99, 0x24, 0x3d, 0x8f, 0x70, 0x30, 0xd8, 0xcb,
324 0x44, 0xbb, 0x7d, 0x48, 0xb5, 0xf8, 0x18, 0x7f,
325 0xe7, 0xc1, 0x9f, 0x86, 0x45, 0x9b, 0xfa, 0xf1,
326 0x61, 0x96, 0x46, 0xbf, 0x56, 0xc8, 0x8b, 0x2b,
327 0x0b, 0x35, 0x6e, 0x4b, 0x8a, 0x95, 0x6a, 0xf9,
328 0xff, 0x00, 0xff, 0xc4, 0x00, 0x1f, 0x11, 0x00,
329 0x01, 0x04, 0x02, 0x02, 0x03, 0x00, 0x00, 0x00,
330 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03,
331 0x02, 0x04, 0x05, 0x12, 0x13, 0x14, 0x01, 0x06,
332 0x11, 0x22, 0x23, 0xff, 0xda, 0x00, 0x08, 0x01,
333 0x02, 0x01, 0x01, 0x3f, 0x01, 0x85, 0x85, 0x8c,
334 0xec, 0x31, 0x8d, 0xa6, 0x26, 0x1b, 0x6e, 0x48,
335 0xbc, 0xcd, 0xb0, 0xe3, 0x33, 0x86, 0xf9, 0x35,
336 0xdc, 0x15, 0xa8, 0xbe, 0x4d, 0x4a, 0x10, 0x22,
337 0x80, 0x00, 0x91, 0xe8, 0x24, 0xda, 0xb6, 0x57,
338 0x95, 0xf2, 0xa5, 0x73, 0xff, 0xc4, 0x00, 0x1e,
339 0x10, 0x00, 0x01, 0x04, 0x03, 0x00, 0x03, 0x00,
340 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
341 0x00, 0x03, 0x01, 0x02, 0x04, 0x12, 0x05, 0x11,
342 0x13, 0x14, 0x22, 0x23, 0xff, 0xda, 0x00, 0x08,
343 0x01, 0x01, 0x00, 0x06, 0x3f, 0x02, 0x91, 0x89,
344 0xc4, 0xc8, 0xf1, 0x60, 0x45, 0xe5, 0xc0, 0x1c,
345 0x80, 0x7a, 0x77, 0x00, 0xe4, 0x97, 0xeb, 0x24,
346 0x66, 0x33, 0xac, 0x63, 0x11, 0xfe, 0xe4, 0x76,
347 0xad, 0x56, 0xe9, 0xa8, 0x88, 0x9f, 0xff, 0xc4,
348 0x00, 0x14, 0x10, 0x01, 0x00, 0x00, 0x00, 0x00,
349 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
350 0x00, 0x00, 0x00, 0x00, 0xff, 0xda, 0x00, 0x08,
351 0x01, 0x01, 0x00, 0x01, 0x3f, 0x21, 0x68, 0x3f,
352 0x92, 0x17, 0x81, 0x1f, 0x7f, 0xff, 0xda, 0x00,
353 0x0c, 0x03, 0x01, 0x00, 0x02, 0x00, 0x03, 0x00,
354 0x00, 0x00, 0x10, 0x5f, 0xff, 0xc4, 0x00, 0x14,
355 0x11, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
356 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
357 0x00, 0x00, 0xff, 0xda, 0x00, 0x08, 0x01, 0x03,
358 0x01, 0x01, 0x3f, 0x10, 0x03, 0xeb, 0x11, 0xe4,
359 0xa7, 0xe3, 0xff, 0x00, 0xff, 0xc4, 0x00, 0x14,
360 0x11, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
361 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
362 0x00, 0x00, 0xff, 0xda, 0x00, 0x08, 0x01, 0x02,
363 0x01, 0x01, 0x3f, 0x10, 0x6b, 0xd3, 0x02, 0xdc,
364 0x9a, 0xf4, 0xff, 0x00, 0xff, 0xc4, 0x00, 0x14,
365 0x10, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
366 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
367 0x00, 0x00, 0xff, 0xda, 0x00, 0x08, 0x01, 0x01,
368 0x00, 0x01, 0x3f, 0x10, 0x62, 0x7b, 0x3a, 0xd0,
369 0x3f, 0xeb, 0xff, 0x00, 0xff, 0xd9,
372 testDecodeRect(decoder
, 0, 0, 4, 4, data
, display
, 24);
374 let targetData
= new Uint8Array([
375 0xff, 0x00, 0x00, 255, 0xff, 0x00, 0x00, 255, 0x00, 0xff, 0x00, 255, 0x00, 0xff, 0x00, 255,
376 0xff, 0x00, 0x00, 255, 0xff, 0x00, 0x00, 255, 0x00, 0xff, 0x00, 255, 0x00, 0xff, 0x00, 255,
377 0x00, 0xff, 0x00, 255, 0x00, 0xff, 0x00, 255, 0xff, 0x00, 0x00, 255, 0xff, 0x00, 0x00, 255,
378 0x00, 0xff, 0x00, 255, 0x00, 0xff, 0x00, 255, 0xff, 0x00, 0x00, 255, 0xff, 0x00, 0x00, 255
381 // Browsers have rounding errors, so we need an approximate
382 // comparing function
383 function almost(a
, b
) {
384 let diff
= Math
.abs(a
- b
);
388 display
.onflush
= () => {
389 expect(display
).to
.have
.displayed(targetData
, almost
);