@@ -228,12 +228,59 @@ describe('Tight Decoder', function () {
228
228
expect ( display ) . to . have . displayed ( targetData ) ;
229
229
} ) ;
230
230
231
- it . skip ( 'should handle uncompressed gradient rects' , function ( ) {
232
- // Not implemented yet
231
+ it ( 'should handle uncompressed gradient rects' , function ( ) {
232
+ let done ;
233
+ let blueData = [ 0x40 , 0x02 , 0x00 , 0x00 , 0xff , 0x00 , 0x00 , 0x00 ] ;
234
+ let greenData = [ 0x40 , 0x02 , 0x00 , 0xff , 0x00 , 0x00 , 0x00 , 0x00 ] ;
235
+
236
+ done = testDecodeRect ( decoder , 0 , 0 , 2 , 1 , blueData , display , 24 ) ;
237
+ expect ( done ) . to . be . true ;
238
+ done = testDecodeRect ( decoder , 0 , 1 , 2 , 1 , blueData , display , 24 ) ;
239
+ expect ( done ) . to . be . true ;
240
+ done = testDecodeRect ( decoder , 2 , 0 , 2 , 1 , greenData , display , 24 ) ;
241
+ expect ( done ) . to . be . true ;
242
+ done = testDecodeRect ( decoder , 2 , 1 , 2 , 1 , greenData , display , 24 ) ;
243
+ expect ( done ) . to . be . true ;
244
+ done = testDecodeRect ( decoder , 0 , 2 , 2 , 1 , greenData , display , 24 ) ;
245
+ expect ( done ) . to . be . true ;
246
+ done = testDecodeRect ( decoder , 0 , 3 , 2 , 1 , greenData , display , 24 ) ;
247
+ expect ( done ) . to . be . true ;
248
+ done = testDecodeRect ( decoder , 2 , 2 , 2 , 1 , blueData , display , 24 ) ;
249
+ expect ( done ) . to . be . true ;
250
+ done = testDecodeRect ( decoder , 2 , 3 , 2 , 1 , blueData , display , 24 ) ;
251
+ expect ( done ) . to . be . true ;
252
+
253
+ let targetData = new Uint8Array ( [
254
+ 0x00 , 0x00 , 0xff , 255 , 0x00 , 0x00 , 0xff , 255 , 0x00 , 0xff , 0x00 , 255 , 0x00 , 0xff , 0x00 , 255 ,
255
+ 0x00 , 0x00 , 0xff , 255 , 0x00 , 0x00 , 0xff , 255 , 0x00 , 0xff , 0x00 , 255 , 0x00 , 0xff , 0x00 , 255 ,
256
+ 0x00 , 0xff , 0x00 , 255 , 0x00 , 0xff , 0x00 , 255 , 0x00 , 0x00 , 0xff , 255 , 0x00 , 0x00 , 0xff , 255 ,
257
+ 0x00 , 0xff , 0x00 , 255 , 0x00 , 0xff , 0x00 , 255 , 0x00 , 0x00 , 0xff , 255 , 0x00 , 0x00 , 0xff , 255
258
+ ] ) ;
259
+
260
+ expect ( display ) . to . have . displayed ( targetData ) ;
233
261
} ) ;
234
262
235
- it . skip ( 'should handle compressed gradient rects' , function ( ) {
236
- // Not implemented yet
263
+ it ( 'should handle compressed gradient rects' , function ( ) {
264
+ let data = [
265
+ // Control byte
266
+ 0x40 , 0x02 ,
267
+ // Pixels (compressed)
268
+ 0x18 ,
269
+ 0x78 , 0x9c , 0x62 , 0x60 , 0xf8 , 0xcf , 0x00 , 0x04 ,
270
+ 0xff , 0x19 , 0x19 , 0xd0 , 0x00 , 0x44 , 0x84 , 0xf1 ,
271
+ 0x3f , 0x9a , 0x30 , 0x00 , 0x00 , 0x00 , 0xff , 0xff ] ;
272
+
273
+ let done = testDecodeRect ( decoder , 0 , 0 , 4 , 4 , data , display , 24 ) ;
274
+
275
+ let targetData = new Uint8Array ( [
276
+ 0x00 , 0x00 , 0xff , 255 , 0x00 , 0x00 , 0xff , 255 , 0x00 , 0xff , 0x00 , 255 , 0x00 , 0xff , 0x00 , 255 ,
277
+ 0x00 , 0x00 , 0xff , 255 , 0x00 , 0x00 , 0xff , 255 , 0x00 , 0xff , 0x00 , 255 , 0x00 , 0xff , 0x00 , 255 ,
278
+ 0x00 , 0xff , 0x00 , 255 , 0x00 , 0xff , 0x00 , 255 , 0x00 , 0x00 , 0xff , 255 , 0x00 , 0x00 , 0xff , 255 ,
279
+ 0x00 , 0xff , 0x00 , 255 , 0x00 , 0xff , 0x00 , 255 , 0x00 , 0x00 , 0xff , 255 , 0x00 , 0x00 , 0xff , 255
280
+ ] ) ;
281
+
282
+ expect ( done ) . to . be . true ;
283
+ expect ( display ) . to . have . displayed ( targetData ) ;
237
284
} ) ;
238
285
239
286
it ( 'should handle empty copy rects' , function ( ) {
@@ -275,6 +322,25 @@ describe('Tight Decoder', function () {
275
322
expect ( display ) . to . have . displayed ( targetData ) ;
276
323
} ) ;
277
324
325
+ it ( 'should handle empty gradient rects' , function ( ) {
326
+ display . fillRect ( 0 , 0 , 4 , 4 , [ 0x00 , 0x00 , 0xff ] ) ;
327
+ display . fillRect ( 2 , 0 , 2 , 2 , [ 0x00 , 0xff , 0x00 ] ) ;
328
+ display . fillRect ( 0 , 2 , 2 , 2 , [ 0x00 , 0xff , 0x00 ] ) ;
329
+
330
+ let done = testDecodeRect ( decoder , 1 , 2 , 0 , 0 ,
331
+ [ 0x40 , 0x02 ] , display , 24 ) ;
332
+
333
+ let targetData = new Uint8Array ( [
334
+ 0x00 , 0x00 , 0xff , 255 , 0x00 , 0x00 , 0xff , 255 , 0x00 , 0xff , 0x00 , 255 , 0x00 , 0xff , 0x00 , 255 ,
335
+ 0x00 , 0x00 , 0xff , 255 , 0x00 , 0x00 , 0xff , 255 , 0x00 , 0xff , 0x00 , 255 , 0x00 , 0xff , 0x00 , 255 ,
336
+ 0x00 , 0xff , 0x00 , 255 , 0x00 , 0xff , 0x00 , 255 , 0x00 , 0x00 , 0xff , 255 , 0x00 , 0x00 , 0xff , 255 ,
337
+ 0x00 , 0xff , 0x00 , 255 , 0x00 , 0xff , 0x00 , 255 , 0x00 , 0x00 , 0xff , 255 , 0x00 , 0x00 , 0xff , 255
338
+ ] ) ;
339
+
340
+ expect ( done ) . to . be . true ;
341
+ expect ( display ) . to . have . displayed ( targetData ) ;
342
+ } ) ;
343
+
278
344
it ( 'should handle empty fill rects' , function ( ) {
279
345
display . fillRect ( 0 , 0 , 4 , 4 , [ 0x00 , 0x00 , 0xff ] ) ;
280
346
display . fillRect ( 2 , 0 , 2 , 2 , [ 0x00 , 0xff , 0x00 ] ) ;
0 commit comments