mirror of
https://github.com/openseadragon/openseadragon.git
synced 2024-11-25 06:36:11 +03:00
Fixing test failures
This commit is contained in:
parent
9c42062efb
commit
77030096e4
@ -21,6 +21,7 @@
|
|||||||
// ----------
|
// ----------
|
||||||
var createViewer = function(options) {
|
var createViewer = function(options) {
|
||||||
options = options || {};
|
options = options || {};
|
||||||
|
// eslint-disable-next-line new-cap
|
||||||
viewer = OpenSeadragon(OpenSeadragon.extend({
|
viewer = OpenSeadragon(OpenSeadragon.extend({
|
||||||
id: 'example',
|
id: 'example',
|
||||||
prefixUrl: '/build/openseadragon/images/',
|
prefixUrl: '/build/openseadragon/images/',
|
||||||
@ -45,7 +46,7 @@
|
|||||||
});
|
});
|
||||||
|
|
||||||
viewer.addHandler('open', function handler(event) {
|
viewer.addHandler('open', function handler(event) {
|
||||||
viewer.viewport.setRotation(30, true);
|
viewer.viewport.setRotation(30, null, true);
|
||||||
Util.spyOnce(viewer.drawer.context, 'rotate', function() {
|
Util.spyOnce(viewer.drawer.context, 'rotate', function() {
|
||||||
assert.ok(true, 'drawing with new rotation');
|
assert.ok(true, 'drawing with new rotation');
|
||||||
done();
|
done();
|
||||||
|
@ -9,6 +9,7 @@
|
|||||||
|
|
||||||
testLog.reset();
|
testLog.reset();
|
||||||
|
|
||||||
|
// eslint-disable-next-line new-cap
|
||||||
viewer = OpenSeadragon( {
|
viewer = OpenSeadragon( {
|
||||||
id: 'eventsexample',
|
id: 'eventsexample',
|
||||||
prefixUrl: '/build/openseadragon/images/',
|
prefixUrl: '/build/openseadragon/images/',
|
||||||
@ -194,13 +195,13 @@
|
|||||||
|
|
||||||
var simulateEnter = function (x, y) {
|
var simulateEnter = function (x, y) {
|
||||||
simEvent.clientX = offset.left + x;
|
simEvent.clientX = offset.left + x;
|
||||||
simEvent.clientY = offset.top + y;
|
simEvent.clientY = offset.top + y;
|
||||||
$canvas.simulate( 'mouseenter', simEvent );
|
$canvas.simulate( 'mouseenter', simEvent );
|
||||||
};
|
};
|
||||||
|
|
||||||
var simulateLeave = function (x, y) {
|
var simulateLeave = function (x, y) {
|
||||||
simEvent.clientX = offset.left + x;
|
simEvent.clientX = offset.left + x;
|
||||||
simEvent.clientY = offset.top + y;
|
simEvent.clientY = offset.top + y;
|
||||||
simEvent.relatedTarget = document.body;
|
simEvent.relatedTarget = document.body;
|
||||||
$canvas.simulate( 'mouseleave', simEvent );
|
$canvas.simulate( 'mouseleave', simEvent );
|
||||||
};
|
};
|
||||||
@ -215,28 +216,28 @@
|
|||||||
var simulateDown = function (x, y) {
|
var simulateDown = function (x, y) {
|
||||||
simEvent.button = 0;
|
simEvent.button = 0;
|
||||||
simEvent.clientX = offset.left + x;
|
simEvent.clientX = offset.left + x;
|
||||||
simEvent.clientY = offset.top + y;
|
simEvent.clientY = offset.top + y;
|
||||||
$canvas.simulate( 'mousedown', simEvent );
|
$canvas.simulate( 'mousedown', simEvent );
|
||||||
};
|
};
|
||||||
|
|
||||||
var simulateUp = function (x, y) {
|
var simulateUp = function (x, y) {
|
||||||
simEvent.button = 0;
|
simEvent.button = 0;
|
||||||
simEvent.clientX = offset.left + x;
|
simEvent.clientX = offset.left + x;
|
||||||
simEvent.clientY = offset.top + y;
|
simEvent.clientY = offset.top + y;
|
||||||
$canvas.simulate( 'mouseup', simEvent );
|
$canvas.simulate( 'mouseup', simEvent );
|
||||||
};
|
};
|
||||||
|
|
||||||
var simulateNonPrimaryDown = function (x, y, button) {
|
var simulateNonPrimaryDown = function (x, y, button) {
|
||||||
simEvent.button = button;
|
simEvent.button = button;
|
||||||
simEvent.clientX = offset.left + x;
|
simEvent.clientX = offset.left + x;
|
||||||
simEvent.clientY = offset.top + y;
|
simEvent.clientY = offset.top + y;
|
||||||
$canvas.simulate( 'mousedown', simEvent );
|
$canvas.simulate( 'mousedown', simEvent );
|
||||||
};
|
};
|
||||||
|
|
||||||
var simulateNonPrimaryUp = function (x, y, button) {
|
var simulateNonPrimaryUp = function (x, y, button) {
|
||||||
simEvent.button = button;
|
simEvent.button = button;
|
||||||
simEvent.clientX = offset.left + x;
|
simEvent.clientX = offset.left + x;
|
||||||
simEvent.clientY = offset.top + y;
|
simEvent.clientY = offset.top + y;
|
||||||
$canvas.simulate( 'mouseup', simEvent );
|
$canvas.simulate( 'mouseup', simEvent );
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -680,7 +681,7 @@
|
|||||||
|
|
||||||
// start-end-end (multi-touch start event)
|
// start-end-end (multi-touch start event)
|
||||||
reset();
|
reset();
|
||||||
touches = TouchUtil.start( [0,0], [20,20] );
|
touches = TouchUtil.start( [0, 0], [20, 20] );
|
||||||
assessTouchExpectations({
|
assessTouchExpectations({
|
||||||
description: 'start-end-end (multi-touch start event) [capture]: ',
|
description: 'start-end-end (multi-touch start event) [capture]: ',
|
||||||
captureCount: 2,
|
captureCount: 2,
|
||||||
@ -790,7 +791,7 @@
|
|||||||
"Zoom should not be prevented");
|
"Zoom should not be prevented");
|
||||||
Util.assertRectangleEquals(
|
Util.assertRectangleEquals(
|
||||||
assert,
|
assert,
|
||||||
new OpenSeadragon.Rect(-249.5, -0.25, 500, 0.5),
|
new OpenSeadragon.Rect(-384.5, -0.25, 500, 0.5),
|
||||||
bounds,
|
bounds,
|
||||||
epsilon,
|
epsilon,
|
||||||
'Pan should not be prevented');
|
'Pan should not be prevented');
|
||||||
@ -813,13 +814,13 @@
|
|||||||
|
|
||||||
var simulateEnter = function (x, y) {
|
var simulateEnter = function (x, y) {
|
||||||
simEvent.clientX = offset.left + x;
|
simEvent.clientX = offset.left + x;
|
||||||
simEvent.clientY = offset.top + y;
|
simEvent.clientY = offset.top + y;
|
||||||
$canvas.simulate( 'mouseenter', simEvent );
|
$canvas.simulate( 'mouseenter', simEvent );
|
||||||
};
|
};
|
||||||
|
|
||||||
var simulateLeave = function (x, y) {
|
var simulateLeave = function (x, y) {
|
||||||
simEvent.clientX = offset.left + x;
|
simEvent.clientX = offset.left + x;
|
||||||
simEvent.clientY = offset.top + y;
|
simEvent.clientY = offset.top + y;
|
||||||
simEvent.relatedTarget = document.body;
|
simEvent.relatedTarget = document.body;
|
||||||
$canvas.simulate( 'mouseleave', simEvent );
|
$canvas.simulate( 'mouseleave', simEvent );
|
||||||
};
|
};
|
||||||
@ -827,14 +828,14 @@
|
|||||||
var simulateDown = function (x, y) {
|
var simulateDown = function (x, y) {
|
||||||
simEvent.button = 0;
|
simEvent.button = 0;
|
||||||
simEvent.clientX = offset.left + x;
|
simEvent.clientX = offset.left + x;
|
||||||
simEvent.clientY = offset.top + y;
|
simEvent.clientY = offset.top + y;
|
||||||
$canvas.simulate( 'mousedown', simEvent );
|
$canvas.simulate( 'mousedown', simEvent );
|
||||||
};
|
};
|
||||||
|
|
||||||
var simulateUp = function (x, y) {
|
var simulateUp = function (x, y) {
|
||||||
simEvent.button = 0;
|
simEvent.button = 0;
|
||||||
simEvent.clientX = offset.left + x;
|
simEvent.clientX = offset.left + x;
|
||||||
simEvent.clientY = offset.top + y;
|
simEvent.clientY = offset.top + y;
|
||||||
$canvas.simulate( 'mouseup', simEvent );
|
$canvas.simulate( 'mouseup', simEvent );
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -912,50 +913,6 @@
|
|||||||
dragEndsExpected = 1,
|
dragEndsExpected = 1,
|
||||||
releasesExpected = 1;
|
releasesExpected = 1;
|
||||||
|
|
||||||
var onOpen = function ( ) {
|
|
||||||
viewer.removeHandler( 'open', onOpen );
|
|
||||||
|
|
||||||
viewer.addHandler( 'canvas-drag', onEventSourceDrag );
|
|
||||||
viewer.addHandler( 'canvas-drag-end', onEventSourceDragEnd );
|
|
||||||
viewer.addHandler( 'canvas-release', onEventSourceRelease );
|
|
||||||
viewer.addHandler( 'canvas-click', onEventSourceClick );
|
|
||||||
|
|
||||||
mouseTracker = new OpenSeadragon.MouseTracker( {
|
|
||||||
element: $canvas[0],
|
|
||||||
userData: userData,
|
|
||||||
clickTimeThreshold: OpenSeadragon.DEFAULT_SETTINGS.clickTimeThreshold,
|
|
||||||
clickDistThreshold: OpenSeadragon.DEFAULT_SETTINGS.clickDistThreshold,
|
|
||||||
dblClickTimeThreshold: OpenSeadragon.DEFAULT_SETTINGS.dblClickTimeThreshold,
|
|
||||||
dblClickDistThreshold: OpenSeadragon.DEFAULT_SETTINGS.dblClickDistThreshold,
|
|
||||||
focusHandler: onMouseTrackerFocus,
|
|
||||||
blurHandler: onMouseTrackerBlur,
|
|
||||||
enterHandler: onMouseTrackerEnter,
|
|
||||||
pressHandler: onMouseTrackerPress,
|
|
||||||
moveHandler: onMouseTrackerMove,
|
|
||||||
dragHandler: onMouseTrackerDrag,
|
|
||||||
dragEndHandler: onMouseTrackerDragEnd,
|
|
||||||
releaseHandler: onMouseTrackerRelease,
|
|
||||||
clickHandler: onMouseTrackerClick,
|
|
||||||
leaveHandler: onMouseTrackerLeave
|
|
||||||
} );
|
|
||||||
|
|
||||||
var event = {
|
|
||||||
clientX:1,
|
|
||||||
clientY:1
|
|
||||||
};
|
|
||||||
|
|
||||||
$canvas.simulate( 'focus', event );
|
|
||||||
Util.simulateViewerClickWithDrag( {
|
|
||||||
viewer: viewer,
|
|
||||||
widthFactor: 0.25,
|
|
||||||
heightFactor: 0.25,
|
|
||||||
dragCount: dragCount,
|
|
||||||
dragDx: 1,
|
|
||||||
dragDy: 1
|
|
||||||
} );
|
|
||||||
$canvas.simulate( 'blur', event );
|
|
||||||
};
|
|
||||||
|
|
||||||
var checkOriginalEventReceivedViewer = function ( event ) {
|
var checkOriginalEventReceivedViewer = function ( event ) {
|
||||||
eventsHandledViewer++;
|
eventsHandledViewer++;
|
||||||
//TODO Provide a better check for the original event...simulate doesn't currently extend the object
|
//TODO Provide a better check for the original event...simulate doesn't currently extend the object
|
||||||
@ -1055,6 +1012,50 @@
|
|||||||
done();
|
done();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
var onOpen = function ( ) {
|
||||||
|
viewer.removeHandler( 'open', onOpen );
|
||||||
|
|
||||||
|
viewer.addHandler( 'canvas-drag', onEventSourceDrag );
|
||||||
|
viewer.addHandler( 'canvas-drag-end', onEventSourceDragEnd );
|
||||||
|
viewer.addHandler( 'canvas-release', onEventSourceRelease );
|
||||||
|
viewer.addHandler( 'canvas-click', onEventSourceClick );
|
||||||
|
|
||||||
|
mouseTracker = new OpenSeadragon.MouseTracker( {
|
||||||
|
element: $canvas[0],
|
||||||
|
userData: userData,
|
||||||
|
clickTimeThreshold: OpenSeadragon.DEFAULT_SETTINGS.clickTimeThreshold,
|
||||||
|
clickDistThreshold: OpenSeadragon.DEFAULT_SETTINGS.clickDistThreshold,
|
||||||
|
dblClickTimeThreshold: OpenSeadragon.DEFAULT_SETTINGS.dblClickTimeThreshold,
|
||||||
|
dblClickDistThreshold: OpenSeadragon.DEFAULT_SETTINGS.dblClickDistThreshold,
|
||||||
|
focusHandler: onMouseTrackerFocus,
|
||||||
|
blurHandler: onMouseTrackerBlur,
|
||||||
|
enterHandler: onMouseTrackerEnter,
|
||||||
|
pressHandler: onMouseTrackerPress,
|
||||||
|
moveHandler: onMouseTrackerMove,
|
||||||
|
dragHandler: onMouseTrackerDrag,
|
||||||
|
dragEndHandler: onMouseTrackerDragEnd,
|
||||||
|
releaseHandler: onMouseTrackerRelease,
|
||||||
|
clickHandler: onMouseTrackerClick,
|
||||||
|
leaveHandler: onMouseTrackerLeave
|
||||||
|
} );
|
||||||
|
|
||||||
|
var event = {
|
||||||
|
clientX: 1,
|
||||||
|
clientY: 1
|
||||||
|
};
|
||||||
|
|
||||||
|
$canvas.simulate( 'focus', event );
|
||||||
|
Util.simulateViewerClickWithDrag( {
|
||||||
|
viewer: viewer,
|
||||||
|
widthFactor: 0.25,
|
||||||
|
heightFactor: 0.25,
|
||||||
|
dragCount: dragCount,
|
||||||
|
dragDx: 1,
|
||||||
|
dragDy: 1
|
||||||
|
} );
|
||||||
|
$canvas.simulate( 'blur', event );
|
||||||
|
};
|
||||||
|
|
||||||
viewer.addHandler( 'open', onOpen );
|
viewer.addHandler( 'open', onOpen );
|
||||||
viewer.open( '/test/data/testpattern.dzi' );
|
viewer.open( '/test/data/testpattern.dzi' );
|
||||||
} );
|
} );
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
/* eslint-disable camelcase */
|
||||||
/* global QUnit, $, Util, testLog */
|
/* global QUnit, $, Util, testLog */
|
||||||
|
|
||||||
(function () {
|
(function () {
|
||||||
@ -10,6 +11,7 @@
|
|||||||
|
|
||||||
testLog.reset();
|
testLog.reset();
|
||||||
|
|
||||||
|
// eslint-disable-next-line new-cap
|
||||||
viewer = OpenSeadragon({
|
viewer = OpenSeadragon({
|
||||||
id: 'unitsexample',
|
id: 'unitsexample',
|
||||||
prefixUrl: '/build/openseadragon/images/',
|
prefixUrl: '/build/openseadragon/images/',
|
||||||
@ -210,13 +212,13 @@
|
|||||||
checkPoint(assert, ' after zoom and pan');
|
checkPoint(assert, ' after zoom and pan');
|
||||||
|
|
||||||
//Restore rotation
|
//Restore rotation
|
||||||
viewer.viewport.setRotation(0, true);
|
viewer.viewport.setRotation(0, null, true);
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
viewer.viewport.zoomTo(0.8).panTo(new OpenSeadragon.Point(0.1, 0.2));
|
viewer.viewport.zoomTo(0.8).panTo(new OpenSeadragon.Point(0.1, 0.2));
|
||||||
});
|
});
|
||||||
|
|
||||||
viewer.viewport.setRotation(45, true);
|
viewer.viewport.setRotation(45, null, true);
|
||||||
viewer.open([{
|
viewer.open([{
|
||||||
tileSource: "/test/data/testpattern.dzi"
|
tileSource: "/test/data/testpattern.dzi"
|
||||||
}, {
|
}, {
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
/* global QUnit, $, Util, testLog, console */
|
/* eslint-disable new-cap */
|
||||||
|
/* global QUnit, $, Util, testLog */
|
||||||
|
|
||||||
(function () {
|
(function () {
|
||||||
var viewer;
|
var viewer;
|
||||||
@ -58,7 +59,8 @@
|
|||||||
// values for zoom levels, and reopen the viewer for each iteration.
|
// values for zoom levels, and reopen the viewer for each iteration.
|
||||||
var reopenViewerHelper = function(assert, config) {
|
var reopenViewerHelper = function(assert, config) {
|
||||||
var done = assert.async();
|
var done = assert.async();
|
||||||
var expected, level, actual, i = 0;
|
var expected, level, actual;
|
||||||
|
var i = 0;
|
||||||
var openHandler = function(event) {
|
var openHandler = function(event) {
|
||||||
var viewport = viewer.viewport;
|
var viewport = viewer.viewport;
|
||||||
expected = config.processExpected(level, expected);
|
expected = config.processExpected(level, expected);
|
||||||
@ -245,7 +247,7 @@
|
|||||||
function openHandler() {
|
function openHandler() {
|
||||||
viewer.removeHandler('open', openHandler);
|
viewer.removeHandler('open', openHandler);
|
||||||
var viewport = viewer.viewport;
|
var viewport = viewer.viewport;
|
||||||
viewport.setRotation(-675, true);
|
viewport.setRotation(-675, null, true);
|
||||||
Util.assertRectangleEquals(
|
Util.assertRectangleEquals(
|
||||||
assert,
|
assert,
|
||||||
viewport.getHomeBoundsNoRotate(),
|
viewport.getHomeBoundsNoRotate(),
|
||||||
@ -267,7 +269,7 @@
|
|||||||
function openHandler() {
|
function openHandler() {
|
||||||
viewer.removeHandler('open', openHandler);
|
viewer.removeHandler('open', openHandler);
|
||||||
var viewport = viewer.viewport;
|
var viewport = viewer.viewport;
|
||||||
viewport.setRotation(-675, true);
|
viewport.setRotation(-675, null, true);
|
||||||
Util.assertRectangleEquals(
|
Util.assertRectangleEquals(
|
||||||
assert,
|
assert,
|
||||||
viewport.getHomeBounds(),
|
viewport.getHomeBounds(),
|
||||||
@ -516,7 +518,7 @@
|
|||||||
var bounds = viewport.getBounds();
|
var bounds = viewport.getBounds();
|
||||||
Util.assertRectangleEquals(
|
Util.assertRectangleEquals(
|
||||||
assert,
|
assert,
|
||||||
new OpenSeadragon.Rect(-0.5, 1, 2, 2),
|
new OpenSeadragon.Rect(0, 1, 2, 2),
|
||||||
bounds,
|
bounds,
|
||||||
EPSILON,
|
EPSILON,
|
||||||
"Viewport.applyConstraints should move viewport to the center, not to a side.");
|
"Viewport.applyConstraints should move viewport to the center, not to a side.");
|
||||||
@ -531,14 +533,14 @@
|
|||||||
var openHandler = function() {
|
var openHandler = function() {
|
||||||
viewer.removeHandler('open', openHandler);
|
viewer.removeHandler('open', openHandler);
|
||||||
var viewport = viewer.viewport;
|
var viewport = viewer.viewport;
|
||||||
viewport.setRotation(45, true);
|
viewport.setRotation(45, null, true);
|
||||||
viewport.fitBounds(new OpenSeadragon.Rect(1, 1, 1, 1), true);
|
viewport.fitBounds(new OpenSeadragon.Rect(1, 1, 1, 1), true);
|
||||||
viewport.applyConstraints(true);
|
viewport.applyConstraints(true);
|
||||||
var bounds = viewport.getBounds();
|
var bounds = viewport.getBounds();
|
||||||
Util.assertRectangleEquals(
|
Util.assertRectangleEquals(
|
||||||
assert,
|
assert,
|
||||||
|
new OpenSeadragon.Rect(1.2071067811865466, 0.20710678118654746, Math.sqrt(2), Math.sqrt(2), 45),
|
||||||
bounds,
|
bounds,
|
||||||
new OpenSeadragon.Rect(1, 0, Math.sqrt(2), Math.sqrt(2), 45),
|
|
||||||
EPSILON,
|
EPSILON,
|
||||||
"Viewport.applyConstraints with rotation should move viewport.");
|
"Viewport.applyConstraints with rotation should move viewport.");
|
||||||
|
|
||||||
@ -555,15 +557,15 @@
|
|||||||
var viewport = viewer.viewport;
|
var viewport = viewer.viewport;
|
||||||
|
|
||||||
viewport.setFlip(true);
|
viewport.setFlip(true);
|
||||||
viewport.setRotation(45, true);
|
viewport.setRotation(45, null, true);
|
||||||
|
|
||||||
viewport.fitBounds(new OpenSeadragon.Rect(1, 1, 1, 1), true);
|
viewport.fitBounds(new OpenSeadragon.Rect(1, 1, 1, 1), true);
|
||||||
viewport.applyConstraints(true);
|
viewport.applyConstraints(true);
|
||||||
var bounds = viewport.getBounds();
|
var bounds = viewport.getBounds();
|
||||||
Util.assertRectangleEquals(
|
Util.assertRectangleEquals(
|
||||||
assert,
|
assert,
|
||||||
|
new OpenSeadragon.Rect(1.2071067811865466, 0.20710678118654746, Math.sqrt(2), Math.sqrt(2), 45),
|
||||||
bounds,
|
bounds,
|
||||||
new OpenSeadragon.Rect(1, 0, Math.sqrt(2), Math.sqrt(2), 45),
|
|
||||||
EPSILON,
|
EPSILON,
|
||||||
"Viewport.applyConstraints flipped and with rotation should move viewport.");
|
"Viewport.applyConstraints flipped and with rotation should move viewport.");
|
||||||
|
|
||||||
@ -657,7 +659,7 @@
|
|||||||
var openHandler = function(event) {
|
var openHandler = function(event) {
|
||||||
viewer.removeHandler('open', openHandler);
|
viewer.removeHandler('open', openHandler);
|
||||||
var viewport = viewer.viewport;
|
var viewport = viewer.viewport;
|
||||||
viewport.setRotation(45, true);
|
viewport.setRotation(45, null, true);
|
||||||
|
|
||||||
for(var i = 0; i < testRectsFitBounds.length; i++){
|
for(var i = 0; i < testRectsFitBounds.length; i++){
|
||||||
var rect = testRectsFitBounds[i];
|
var rect = testRectsFitBounds[i];
|
||||||
@ -1064,20 +1066,20 @@
|
|||||||
var viewport = viewer.viewport;
|
var viewport = viewer.viewport;
|
||||||
|
|
||||||
assert.propEqual(viewport.getRotation, 0, "Original rotation should be 0 degrees");
|
assert.propEqual(viewport.getRotation, 0, "Original rotation should be 0 degrees");
|
||||||
viewport.setRotation(90, true);
|
viewport.setRotation(90, null, true);
|
||||||
assert.propEqual(viewport.getRotation, 90, "Rotation should be 90 degrees");
|
assert.propEqual(viewport.getRotation, 90, "Rotation should be 90 degrees");
|
||||||
viewport.setRotation(-75, true);
|
viewport.setRotation(-75, null, true);
|
||||||
assert.propEqual(viewport.getRotation, -75, "Rotation should be -75 degrees");
|
assert.propEqual(viewport.getRotation, -75, "Rotation should be -75 degrees");
|
||||||
|
|
||||||
viewport.setRotation(0, true);
|
viewport.setRotation(0, null, true);
|
||||||
assert.strictEqual(viewport.getRotation(true), 0, 'viewport has default current rotation');
|
assert.strictEqual(viewport.getRotation(true), 0, 'viewport has default current rotation');
|
||||||
assert.strictEqual(viewport.getRotation(false), 0, 'viewport has default target rotation');
|
assert.strictEqual(viewport.getRotation(false), 0, 'viewport has default target rotation');
|
||||||
|
|
||||||
viewport.setRotation(400);
|
viewport.setRotation(33);
|
||||||
assert.strictEqual(viewport.getRotation(true), 0, 'current rotation is not changed');
|
assert.strictEqual(viewport.getRotation(true), 0, 'current rotation is not changed');
|
||||||
assert.strictEqual(viewport.getRotation(false), 400, 'target rotation is set correctly');
|
assert.strictEqual(viewport.getRotation(false), 33, 'target rotation is set correctly');
|
||||||
|
|
||||||
viewport.setRotation(200, true);
|
viewport.setRotation(200, null, true);
|
||||||
assert.strictEqual(viewport.getRotation(true), 200, 'current rotation is set correctly');
|
assert.strictEqual(viewport.getRotation(true), 200, 'current rotation is set correctly');
|
||||||
assert.strictEqual(viewport.getRotation(false), 200, 'target rotation is set correctly');
|
assert.strictEqual(viewport.getRotation(false), 200, 'target rotation is set correctly');
|
||||||
|
|
||||||
@ -1097,9 +1099,9 @@
|
|||||||
viewport.setFlip(true);
|
viewport.setFlip(true);
|
||||||
|
|
||||||
assert.propEqual(viewport.getRotation, 0, "Original flipped rotation should be 0 degrees");
|
assert.propEqual(viewport.getRotation, 0, "Original flipped rotation should be 0 degrees");
|
||||||
viewport.setRotation(90, true);
|
viewport.setRotation(90, null, true);
|
||||||
assert.propEqual(viewport.getRotation, 90, "Flipped rotation should be 90 degrees");
|
assert.propEqual(viewport.getRotation, 90, "Flipped rotation should be 90 degrees");
|
||||||
viewport.setRotation(-75, true);
|
viewport.setRotation(-75, null, true);
|
||||||
assert.propEqual(viewport.getRotation, -75, "Flipped rotation should be -75 degrees");
|
assert.propEqual(viewport.getRotation, -75, "Flipped rotation should be -75 degrees");
|
||||||
|
|
||||||
done();
|
done();
|
||||||
@ -1116,9 +1118,9 @@
|
|||||||
var viewport = viewer.viewport;
|
var viewport = viewer.viewport;
|
||||||
|
|
||||||
for(var i = 0; i < testPoints.length; i++){
|
for(var i = 0; i < testPoints.length; i++){
|
||||||
var new_size = testPoints[i].times(viewer.source.dimensions.x);
|
var newSize = testPoints[i].times(viewer.source.dimensions.x);
|
||||||
viewport.resize(new_size);
|
viewport.resize(newSize);
|
||||||
assert.propEqual(viewport.getContainerSize(), new_size, "Viewport resized successfully.");
|
assert.propEqual(viewport.getContainerSize(), newSize, "Viewport resized successfully.");
|
||||||
}
|
}
|
||||||
done();
|
done();
|
||||||
};
|
};
|
||||||
@ -1272,12 +1274,12 @@
|
|||||||
loopingTestHelper(assert, {
|
loopingTestHelper(assert, {
|
||||||
testArray: testPoints,
|
testArray: testPoints,
|
||||||
getOrig: function(el, viewport) {
|
getOrig: function(el, viewport) {
|
||||||
var window_boundary = Math.min(window.innerWidth, window.innerHeight);
|
var windowBoundary = Math.min(window.innerWidth, window.innerHeight);
|
||||||
return el.times(window_boundary);
|
return el.times(windowBoundary);
|
||||||
},
|
},
|
||||||
getExpected: function(orig, viewport) {
|
getExpected: function(orig, viewport) {
|
||||||
var pos_point = OpenSeadragon.getElementOffset(viewer.element);
|
var posPoint = OpenSeadragon.getElementOffset(viewer.element);
|
||||||
return orig.minus(pos_point).divide(viewport.getContainerSize().x * ZOOM_FACTOR).plus(VIEWER_PADDING);
|
return orig.minus(posPoint).divide(viewport.getContainerSize().x * ZOOM_FACTOR).plus(VIEWER_PADDING);
|
||||||
},
|
},
|
||||||
method: 'windowToViewportCoordinates'
|
method: 'windowToViewportCoordinates'
|
||||||
});
|
});
|
||||||
@ -1290,8 +1292,8 @@
|
|||||||
return el.times(viewer.source.dimensions.x);
|
return el.times(viewer.source.dimensions.x);
|
||||||
},
|
},
|
||||||
getExpected: function(orig, viewport) {
|
getExpected: function(orig, viewport) {
|
||||||
var pos_point = OpenSeadragon.getElementOffset(viewer.element);
|
var posPoint = OpenSeadragon.getElementOffset(viewer.element);
|
||||||
return orig.plus(pos_point).minus(VIEWER_PADDING.times(viewport.getContainerSize().x * ZOOM_FACTOR));
|
return orig.plus(posPoint).minus(VIEWER_PADDING.times(viewport.getContainerSize().x * ZOOM_FACTOR));
|
||||||
},
|
},
|
||||||
method: 'imageToWindowCoordinates'
|
method: 'imageToWindowCoordinates'
|
||||||
});
|
});
|
||||||
@ -1301,12 +1303,12 @@
|
|||||||
loopingTestHelper(assert, {
|
loopingTestHelper(assert, {
|
||||||
testArray: testPoints,
|
testArray: testPoints,
|
||||||
getOrig: function(el, viewport) {
|
getOrig: function(el, viewport) {
|
||||||
var window_boundary = Math.min(window.innerWidth, window.innerHeight);
|
var windowBoundary = Math.min(window.innerWidth, window.innerHeight);
|
||||||
return el.times(window_boundary);
|
return el.times(windowBoundary);
|
||||||
},
|
},
|
||||||
getExpected: function(orig, viewport) {
|
getExpected: function(orig, viewport) {
|
||||||
var pos_point = OpenSeadragon.getElementOffset(viewer.element);
|
var posPoint = OpenSeadragon.getElementOffset(viewer.element);
|
||||||
return orig.minus(pos_point).divide(viewport.getContainerSize().x * ZOOM_FACTOR).plus(VIEWER_PADDING);
|
return orig.minus(posPoint).divide(viewport.getContainerSize().x * ZOOM_FACTOR).plus(VIEWER_PADDING);
|
||||||
},
|
},
|
||||||
method: 'windowToViewportCoordinates'
|
method: 'windowToViewportCoordinates'
|
||||||
});
|
});
|
||||||
@ -1319,8 +1321,8 @@
|
|||||||
return el.times(viewer.source.dimensions.x);
|
return el.times(viewer.source.dimensions.x);
|
||||||
},
|
},
|
||||||
getExpected: function(orig, viewport) {
|
getExpected: function(orig, viewport) {
|
||||||
var pos_point = OpenSeadragon.getElementOffset(viewer.element);
|
var posPoint = OpenSeadragon.getElementOffset(viewer.element);
|
||||||
return orig.minus(VIEWER_PADDING).times(viewport.getContainerSize().x * ZOOM_FACTOR).plus(pos_point);
|
return orig.minus(VIEWER_PADDING).times(viewport.getContainerSize().x * ZOOM_FACTOR).plus(posPoint);
|
||||||
},
|
},
|
||||||
method: 'viewportToWindowCoordinates'
|
method: 'viewportToWindowCoordinates'
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user