Add unit tests for Tight gradient filter
This commit is contained in:
parent
c187b2e5e0
commit
d80e3bfa2f
|
@ -228,12 +228,59 @@ describe('Tight Decoder', function () {
|
|||
expect(display).to.have.displayed(targetData);
|
||||
});
|
||||
|
||||
it.skip('should handle uncompressed gradient rects', function () {
|
||||
// Not implemented yet
|
||||
it('should handle uncompressed gradient rects', function () {
|
||||
let done;
|
||||
let blueData = [ 0x40, 0x02, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00 ];
|
||||
let greenData = [ 0x40, 0x02, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00 ];
|
||||
|
||||
done = testDecodeRect(decoder, 0, 0, 2, 1, blueData, display, 24);
|
||||
expect(done).to.be.true;
|
||||
done = testDecodeRect(decoder, 0, 1, 2, 1, blueData, display, 24);
|
||||
expect(done).to.be.true;
|
||||
done = testDecodeRect(decoder, 2, 0, 2, 1, greenData, display, 24);
|
||||
expect(done).to.be.true;
|
||||
done = testDecodeRect(decoder, 2, 1, 2, 1, greenData, display, 24);
|
||||
expect(done).to.be.true;
|
||||
done = testDecodeRect(decoder, 0, 2, 2, 1, greenData, display, 24);
|
||||
expect(done).to.be.true;
|
||||
done = testDecodeRect(decoder, 0, 3, 2, 1, greenData, display, 24);
|
||||
expect(done).to.be.true;
|
||||
done = testDecodeRect(decoder, 2, 2, 2, 1, blueData, display, 24);
|
||||
expect(done).to.be.true;
|
||||
done = testDecodeRect(decoder, 2, 3, 2, 1, blueData, display, 24);
|
||||
expect(done).to.be.true;
|
||||
|
||||
let targetData = new Uint8Array([
|
||||
0x00, 0x00, 0xff, 255, 0x00, 0x00, 0xff, 255, 0x00, 0xff, 0x00, 255, 0x00, 0xff, 0x00, 255,
|
||||
0x00, 0x00, 0xff, 255, 0x00, 0x00, 0xff, 255, 0x00, 0xff, 0x00, 255, 0x00, 0xff, 0x00, 255,
|
||||
0x00, 0xff, 0x00, 255, 0x00, 0xff, 0x00, 255, 0x00, 0x00, 0xff, 255, 0x00, 0x00, 0xff, 255,
|
||||
0x00, 0xff, 0x00, 255, 0x00, 0xff, 0x00, 255, 0x00, 0x00, 0xff, 255, 0x00, 0x00, 0xff, 255
|
||||
]);
|
||||
|
||||
expect(display).to.have.displayed(targetData);
|
||||
});
|
||||
|
||||
it.skip('should handle compressed gradient rects', function () {
|
||||
// Not implemented yet
|
||||
it('should handle compressed gradient rects', function () {
|
||||
let data = [
|
||||
// Control byte
|
||||
0x40, 0x02,
|
||||
// Pixels (compressed)
|
||||
0x18,
|
||||
0x78, 0x9c, 0x62, 0x60, 0xf8, 0xcf, 0x00, 0x04,
|
||||
0xff, 0x19, 0x19, 0xd0, 0x00, 0x44, 0x84, 0xf1,
|
||||
0x3f, 0x9a, 0x30, 0x00, 0x00, 0x00, 0xff, 0xff ];
|
||||
|
||||
let done = testDecodeRect(decoder, 0, 0, 4, 4, data, display, 24);
|
||||
|
||||
let targetData = new Uint8Array([
|
||||
0x00, 0x00, 0xff, 255, 0x00, 0x00, 0xff, 255, 0x00, 0xff, 0x00, 255, 0x00, 0xff, 0x00, 255,
|
||||
0x00, 0x00, 0xff, 255, 0x00, 0x00, 0xff, 255, 0x00, 0xff, 0x00, 255, 0x00, 0xff, 0x00, 255,
|
||||
0x00, 0xff, 0x00, 255, 0x00, 0xff, 0x00, 255, 0x00, 0x00, 0xff, 255, 0x00, 0x00, 0xff, 255,
|
||||
0x00, 0xff, 0x00, 255, 0x00, 0xff, 0x00, 255, 0x00, 0x00, 0xff, 255, 0x00, 0x00, 0xff, 255
|
||||
]);
|
||||
|
||||
expect(done).to.be.true;
|
||||
expect(display).to.have.displayed(targetData);
|
||||
});
|
||||
|
||||
it('should handle empty copy rects', function () {
|
||||
|
@ -275,6 +322,25 @@ describe('Tight Decoder', function () {
|
|||
expect(display).to.have.displayed(targetData);
|
||||
});
|
||||
|
||||
it('should handle empty gradient rects', function () {
|
||||
display.fillRect(0, 0, 4, 4, [ 0x00, 0x00, 0xff ]);
|
||||
display.fillRect(2, 0, 2, 2, [ 0x00, 0xff, 0x00 ]);
|
||||
display.fillRect(0, 2, 2, 2, [ 0x00, 0xff, 0x00 ]);
|
||||
|
||||
let done = testDecodeRect(decoder, 1, 2, 0, 0,
|
||||
[ 0x40, 0x02 ], display, 24);
|
||||
|
||||
let targetData = new Uint8Array([
|
||||
0x00, 0x00, 0xff, 255, 0x00, 0x00, 0xff, 255, 0x00, 0xff, 0x00, 255, 0x00, 0xff, 0x00, 255,
|
||||
0x00, 0x00, 0xff, 255, 0x00, 0x00, 0xff, 255, 0x00, 0xff, 0x00, 255, 0x00, 0xff, 0x00, 255,
|
||||
0x00, 0xff, 0x00, 255, 0x00, 0xff, 0x00, 255, 0x00, 0x00, 0xff, 255, 0x00, 0x00, 0xff, 255,
|
||||
0x00, 0xff, 0x00, 255, 0x00, 0xff, 0x00, 255, 0x00, 0x00, 0xff, 255, 0x00, 0x00, 0xff, 255
|
||||
]);
|
||||
|
||||
expect(done).to.be.true;
|
||||
expect(display).to.have.displayed(targetData);
|
||||
});
|
||||
|
||||
it('should handle empty fill rects', function () {
|
||||
display.fillRect(0, 0, 4, 4, [ 0x00, 0x00, 0xff ]);
|
||||
display.fillRect(2, 0, 2, 2, [ 0x00, 0xff, 0x00 ]);
|
||||
|
|
Loading…
Reference in New Issue