diff options
author | Samuel Mannehed <samuel@cendio.se> | 2017-02-16 13:32:11 +0100 |
---|---|---|
committer | Samuel Mannehed <samuel@cendio.se> | 2017-02-16 14:00:39 +0100 |
commit | 280676c7e9df28f703003f68340989d30b2c0f48 (patch) | |
tree | fd48110bc120064b2da424f78fad3c77d0d87293 /tests/test.display.js | |
parent | 8cbf1dd9d220950ea5163a3c2da2ebca0c7bc450 (diff) | |
download | novnc-280676c7e9df28f703003f68340989d30b2c0f48.tar.gz |
Properly encapsulate the scale in Display
Other parts of the code shouldn't have to care about this. Let Display
convert between canvas coordinates and framebuffer coordinates.
Diffstat (limited to 'tests/test.display.js')
-rw-r--r-- | tests/test.display.js | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/tests/test.display.js b/tests/test.display.js index 5f4eed1..e4e3348 100644 --- a/tests/test.display.js +++ b/tests/test.display.js @@ -274,13 +274,17 @@ describe('Display/Canvas Helper', function () { }); it('should use width to determine scale when the current aspect ratio is wider than the target', function () { - expect(display.autoscale(9, 16)).to.equal(9 / 4); + display.autoscale(9, 16); + expect(display.absX(9)).to.equal(4); + expect(display.absY(18)).to.equal(8); expect(canvas.clientWidth).to.equal(9); expect(canvas.clientHeight).to.equal(7); // round 9 / (4 / 3) }); it('should use height to determine scale when the current aspect ratio is taller than the target', function () { - expect(display.autoscale(16, 9)).to.equal(3); // 9 / 3 + display.autoscale(16, 9); + expect(display.absX(9)).to.equal(3); + expect(display.absY(18)).to.equal(6); expect(canvas.clientWidth).to.equal(12); // 16 * (4 / 3) expect(canvas.clientHeight).to.equal(9); @@ -293,11 +297,15 @@ describe('Display/Canvas Helper', function () { }); it('should not upscale when downscaleOnly is true', function () { - expect(display.autoscale(2, 2, true)).to.equal(0.5); + display.autoscale(2, 2, true); + expect(display.absX(9)).to.equal(18); + expect(display.absY(18)).to.equal(36); expect(canvas.clientWidth).to.equal(2); expect(canvas.clientHeight).to.equal(2); - expect(display.autoscale(16, 9, true)).to.equal(1.0); + display.autoscale(16, 9, true); + expect(display.absX(9)).to.equal(9); + expect(display.absY(18)).to.equal(18); expect(canvas.clientWidth).to.equal(4); expect(canvas.clientHeight).to.equal(3); }); |