]> git.proxmox.com Git - mirror_novnc.git/blob - tests/test.tight.js
feat: add French localization strings
[mirror_novnc.git] / tests / test.tight.js
1 const expect = chai.expect;
2
3 import Websock from '../core/websock.js';
4 import Display from '../core/display.js';
5
6 import TightDecoder from '../core/decoders/tight.js';
7
8 import FakeWebSocket from './fake.websocket.js';
9
10 function testDecodeRect(decoder, x, y, width, height, data, display, depth) {
11 let sock;
12
13 sock = new Websock;
14 sock.open("ws://example.com");
15
16 sock.on('message', () => {
17 decoder.decodeRect(x, y, width, height, sock, display, depth);
18 });
19
20 // Empty messages are filtered at multiple layers, so we need to
21 // do a direct call
22 if (data.length === 0) {
23 decoder.decodeRect(x, y, width, height, sock, display, depth);
24 } else {
25 sock._websocket._receiveData(new Uint8Array(data));
26 }
27
28 display.flip();
29 }
30
31 describe('Tight Decoder', function () {
32 let decoder;
33 let display;
34
35 before(FakeWebSocket.replace);
36 after(FakeWebSocket.restore);
37
38 beforeEach(function () {
39 decoder = new TightDecoder();
40 display = new Display(document.createElement('canvas'));
41 display.resize(4, 4);
42 });
43
44 it('should handle fill rects', function () {
45 testDecodeRect(decoder, 0, 0, 4, 4,
46 [0x80, 0xff, 0x88, 0x44],
47 display, 24);
48
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,
54 ]);
55
56 expect(display).to.have.displayed(targetData);
57 });
58
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 ];
62
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);
71
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
77 ]);
78
79 expect(display).to.have.displayed(targetData);
80 });
81
82 it('should handle compressed copy rects', function () {
83 let data = [
84 // Control byte
85 0x00,
86 // Pixels (compressed)
87 0x15,
88 0x78, 0x9c, 0x63, 0x60, 0xf8, 0xcf, 0x00, 0x44,
89 0x60, 0x82, 0x01, 0x99, 0x8d, 0x29, 0x02, 0xa6,
90 0x00, 0x7e, 0xbf, 0x0f, 0xf1 ];
91
92 testDecodeRect(decoder, 0, 0, 4, 4, data, display, 24);
93
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
99 ]);
100
101 expect(display).to.have.displayed(targetData);
102 });
103
104 it('should handle uncompressed mono rects', function () {
105 let data = [
106 // Control bytes
107 0x40, 0x01,
108 // Palette
109 0x01, 0x00, 0x00, 0xff, 0x00, 0xff, 0x00,
110 // Pixels
111 0x30, 0x30, 0xc0, 0xc0 ];
112
113 testDecodeRect(decoder, 0, 0, 4, 4, data, display, 24);
114
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
120 ]);
121
122 expect(display).to.have.displayed(targetData);
123 });
124
125 it('should handle compressed mono rects', function () {
126 display.resize(4, 12);
127
128 let data = [
129 // Control bytes
130 0x40, 0x01,
131 // Palette
132 0x01, 0x00, 0x00, 0xff, 0x00, 0xff, 0x00,
133 // Pixels (compressed)
134 0x0e,
135 0x78, 0x9c, 0x33, 0x30, 0x38, 0x70, 0xc0, 0x00,
136 0x8a, 0x01, 0x21, 0x3c, 0x05, 0xa1 ];
137
138 testDecodeRect(decoder, 0, 0, 4, 12, data, display, 24);
139
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
153 ]);
154
155 expect(display).to.have.displayed(targetData);
156 });
157
158 it('should handle uncompressed palette rects', function () {
159 let data1 = [
160 // Control bytes
161 0x40, 0x01,
162 // Palette
163 0x02, 0x00, 0x00, 0xff, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00,
164 // Pixels
165 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01 ];
166 let data2 = [
167 // Control bytes
168 0x40, 0x01,
169 // Palette
170 0x02, 0x00, 0x00, 0xff, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00,
171 // Pixels
172 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00 ];
173
174 testDecodeRect(decoder, 0, 0, 4, 2, data1, display, 24);
175 testDecodeRect(decoder, 0, 2, 4, 2, data2, display, 24);
176
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
182 ]);
183
184 expect(display).to.have.displayed(targetData);
185 });
186
187 it('should handle compressed palette rects', function () {
188 let data = [
189 // Control bytes
190 0x40, 0x01,
191 // Palette
192 0x02, 0x00, 0x00, 0xff, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00,
193 // Pixels (compressed)
194 0x12,
195 0x78, 0x9c, 0x63, 0x60, 0x60, 0x64, 0x64, 0x00,
196 0x62, 0x08, 0xc9, 0xc0, 0x00, 0x00, 0x00, 0x54,
197 0x00, 0x09 ];
198
199 testDecodeRect(decoder, 0, 0, 4, 4, data, display, 24);
200
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
206 ]);
207
208 expect(display).to.have.displayed(targetData);
209 });
210
211 it.skip('should handle uncompressed gradient rects', function () {
212 // Not implemented yet
213 });
214
215 it.skip('should handle compressed gradient rects', function () {
216 // Not implemented yet
217 });
218
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 ]);
223
224 testDecodeRect(decoder, 1, 2, 0, 0, [ 0x00 ], display, 24);
225
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
231 ]);
232
233 expect(display).to.have.displayed(targetData);
234 });
235
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 ]);
240
241 testDecodeRect(decoder, 1, 2, 0, 0,
242 [ 0x40, 0x01, 0x01,
243 0xff, 0xff, 0xff,
244 0xff, 0xff, 0xff ], display, 24);
245
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
251 ]);
252
253 expect(display).to.have.displayed(targetData);
254 });
255
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 ]);
260
261 testDecodeRect(decoder, 1, 2, 0, 0,
262 [ 0x80, 0xff, 0xff, 0xff ], display, 24);
263
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
269 ]);
270
271 expect(display).to.have.displayed(targetData);
272 });
273
274 it('should handle JPEG rects', function (done) {
275 let data = [
276 // Control bytes
277 0x90, 0xd6, 0x05,
278 // JPEG data
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,
370 ];
371
372 testDecodeRect(decoder, 0, 0, 4, 4, data, display, 24);
373
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
379 ]);
380
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);
385 return diff < 5;
386 }
387
388 display.onflush = () => {
389 expect(display).to.have.displayed(targetData, almost);
390 done();
391 };
392 display.flush();
393 });
394 });