From fb8bafc6a04eabb7096e4cf7db98864847154ad6 Mon Sep 17 00:00:00 2001 From: jonasengelmann <40031476+jonasengelmann@users.noreply.github.com> Date: Wed, 30 Mar 2022 23:05:14 +0200 Subject: [PATCH] updated tests --- test/modules/controls.js | 6 +++--- test/modules/drawer.js | 2 +- test/modules/units.js | 4 ++-- test/modules/viewport.js | 30 +++++++++++++++++++++--------- 4 files changed, 27 insertions(+), 15 deletions(-) diff --git a/test/modules/controls.js b/test/modules/controls.js index 0e6bdf7c..7e774d9b 100644 --- a/test/modules/controls.js +++ b/test/modules/controls.js @@ -230,11 +230,11 @@ // Now simulate the left/right button clicks. // TODO: re-factor simulateViewerClickWithDrag so it'll accept any element, and use that. - assert.equal(viewer.viewport.degrees, 0, "Image should start at 0 degrees rotation"); + assert.equal(viewer.viewport.getRotation(), 0, "Image should start at 0 degrees rotation"); viewer.rotateLeftButton.onRelease(); - assert.equal(viewer.viewport.degrees, 270, "Image should be 270 degrees rotation (left)"); + assert.equal(viewer.viewport.getRotation(), -90, "Image should be -90 degrees rotation (left)"); viewer.rotateRightButton.onRelease(); - assert.equal(viewer.viewport.degrees, 0, "Image should be 270 degrees rotation (right)"); + assert.equal(viewer.viewport.getRotation(), 0, "Image should be 0 degrees rotation (right)"); viewer.close(); done(); diff --git a/test/modules/drawer.js b/test/modules/drawer.js index ba53ba2d..4fd1a29f 100644 --- a/test/modules/drawer.js +++ b/test/modules/drawer.js @@ -45,7 +45,7 @@ }); viewer.addHandler('open', function handler(event) { - viewer.viewport.setRotation(30); + viewer.viewport.setRotation(30, true); Util.spyOnce(viewer.drawer.context, 'rotate', function() { assert.ok(true, 'drawing with new rotation'); done(); diff --git a/test/modules/units.js b/test/modules/units.js index 6d0bc74d..46e27ec2 100644 --- a/test/modules/units.js +++ b/test/modules/units.js @@ -210,13 +210,13 @@ checkPoint(assert, ' after zoom and pan'); //Restore rotation - viewer.viewport.setRotation(0); + viewer.viewport.setRotation(0, true); done(); }); viewer.viewport.zoomTo(0.8).panTo(new OpenSeadragon.Point(0.1, 0.2)); }); - viewer.viewport.setRotation(45); + viewer.viewport.setRotation(45, true); viewer.open([{ tileSource: "/test/data/testpattern.dzi" }, { diff --git a/test/modules/viewport.js b/test/modules/viewport.js index d820d5d6..59597060 100644 --- a/test/modules/viewport.js +++ b/test/modules/viewport.js @@ -245,7 +245,7 @@ function openHandler() { viewer.removeHandler('open', openHandler); var viewport = viewer.viewport; - viewport.setRotation(-675); + viewport.setRotation(-675, true); Util.assertRectangleEquals( assert, viewport.getHomeBoundsNoRotate(), @@ -267,7 +267,7 @@ function openHandler() { viewer.removeHandler('open', openHandler); var viewport = viewer.viewport; - viewport.setRotation(-675); + viewport.setRotation(-675, true); Util.assertRectangleEquals( assert, viewport.getHomeBounds(), @@ -531,7 +531,7 @@ var openHandler = function() { viewer.removeHandler('open', openHandler); var viewport = viewer.viewport; - viewport.setRotation(45); + viewport.setRotation(45, true); viewport.fitBounds(new OpenSeadragon.Rect(1, 1, 1, 1), true); viewport.applyConstraints(true); var bounds = viewport.getBounds(); @@ -555,7 +555,7 @@ var viewport = viewer.viewport; viewport.setFlip(true); - viewport.setRotation(45); + viewport.setRotation(45, true); viewport.fitBounds(new OpenSeadragon.Rect(1, 1, 1, 1), true); viewport.applyConstraints(true); @@ -657,7 +657,7 @@ var openHandler = function(event) { viewer.removeHandler('open', openHandler); var viewport = viewer.viewport; - viewport.setRotation(45); + viewport.setRotation(45, true); for(var i = 0; i < testRectsFitBounds.length; i++){ var rect = testRectsFitBounds[i]; @@ -1064,11 +1064,23 @@ var viewport = viewer.viewport; assert.propEqual(viewport.getRotation, 0, "Original rotation should be 0 degrees"); - viewport.setRotation(90); + viewport.setRotation(90, true); assert.propEqual(viewport.getRotation, 90, "Rotation should be 90 degrees"); - viewport.setRotation(-75); + viewport.setRotation(-75, true); assert.propEqual(viewport.getRotation, -75, "Rotation should be -75 degrees"); + viewport.setRotation(0, true); + assert.strictEqual(viewport.getRotation(true), 0, 'viewport has default current rotation'); + assert.strictEqual(viewport.getRotation(false), 0, 'viewport has default target rotation'); + + viewport.setRotation(400); + assert.strictEqual(viewport.getRotation(true), 0, 'current rotation is not changed'); + assert.strictEqual(viewport.getRotation(false), 400, 'target rotation is set correctly'); + + viewport.setRotation(200, true); + assert.strictEqual(viewport.getRotation(true), 200, 'current rotation is set correctly'); + assert.strictEqual(viewport.getRotation(false), 200, 'target rotation is set correctly'); + done(); }; @@ -1085,9 +1097,9 @@ viewport.setFlip(true); assert.propEqual(viewport.getRotation, 0, "Original flipped rotation should be 0 degrees"); - viewport.setRotation(90); + viewport.setRotation(90, true); assert.propEqual(viewport.getRotation, 90, "Flipped rotation should be 90 degrees"); - viewport.setRotation(-75); + viewport.setRotation(-75, true); assert.propEqual(viewport.getRotation, -75, "Flipped rotation should be -75 degrees"); done();