From 0035b3f36ff9a526a4d17298f45a224fd5f421c3 Mon Sep 17 00:00:00 2001 From: Victor Rodriguez Gil Date: Mon, 13 Jun 2016 23:04:55 +0000 Subject: [PATCH] Test that shows the bug #890, fails --- test/modules/viewport.js | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/test/modules/viewport.js b/test/modules/viewport.js index f39473cf..fb94d11d 100644 --- a/test/modules/viewport.js +++ b/test/modules/viewport.js @@ -437,8 +437,8 @@ viewport.applyConstraints(true); var bounds = viewport.getBounds(); Util.assertRectangleEquals( - bounds, new OpenSeadragon.Rect(0.7, 0.7, 1, 1), + bounds, EPSILON, "Viewport.applyConstraints should move viewport."); start(); @@ -447,6 +447,27 @@ viewer.open(DZI_PATH); }); + asyncTest('applyConstraints with visibilityRatio = 1 shouldn\'t bounce around', function() { + var openHandler = function() { + viewer.removeHandler('open', openHandler); + var viewport = viewer.viewport; + + viewport.visibilityRatio = 1; + viewport.zoomTo(0.5, undefined, true); + viewport.panBy(new OpenSeadragon.Point(0.75, 0), true); + viewport.applyConstraints(true); + var bounds = viewport.getBounds(); + Util.assertRectangleEquals( + new OpenSeadragon.Rect(-0.5, 1, 2, 2), + bounds, + EPSILON, + "Viewport.applyConstraints should move viewport to the center, not to a side."); + start(); + }; + viewer.addHandler('open', openHandler); + viewer.open(TALL_PATH); + }); + asyncTest('applyConstraints with rotation', function() { var openHandler = function() { viewer.removeHandler('open', openHandler);