2022-12-03 03:27:43 +03:00
|
|
|
/* eslint-disable new-cap */
|
|
|
|
/* global QUnit, Util, $ */
|
2013-07-02 02:17:45 +04:00
|
|
|
|
2013-03-24 05:06:38 +04:00
|
|
|
(function () {
|
2014-01-17 00:11:35 +04:00
|
|
|
var debug = false,
|
|
|
|
viewer,
|
2013-04-03 05:07:10 +04:00
|
|
|
displayRegion,
|
2017-12-18 01:30:32 +03:00
|
|
|
navigatorElement,
|
2014-01-17 00:11:35 +04:00
|
|
|
navigatorScaleFactor,
|
2013-04-03 19:51:24 +04:00
|
|
|
contentStartFromLeft,
|
|
|
|
contentStartFromTop,
|
|
|
|
displayRegionWidth,
|
2013-06-12 23:06:17 +04:00
|
|
|
displayRegionHeight,
|
|
|
|
topNavigatorClickAdjustment;
|
2013-03-25 20:18:55 +04:00
|
|
|
|
2017-12-18 01:30:32 +03:00
|
|
|
var resetTestVariables = function () {
|
|
|
|
if (viewer) {
|
|
|
|
viewer.close();
|
|
|
|
}
|
|
|
|
displayRegion = null;
|
|
|
|
navigatorElement = null;
|
|
|
|
navigatorScaleFactor = null;
|
|
|
|
contentStartFromLeft = null;
|
|
|
|
contentStartFromTop = null;
|
|
|
|
displayRegionWidth = null;
|
|
|
|
displayRegionHeight = null;
|
|
|
|
topNavigatorClickAdjustment = 0;
|
|
|
|
};
|
|
|
|
|
2017-12-12 06:28:26 +03:00
|
|
|
QUnit.module("navigator", {
|
|
|
|
beforeEach: function () {
|
2013-07-02 02:17:45 +04:00
|
|
|
Util.initializeTestDOM();
|
2013-03-25 20:18:55 +04:00
|
|
|
resetTestVariables();
|
2013-06-07 18:25:26 +04:00
|
|
|
$(document).scrollTop(0);
|
|
|
|
$(document).scrollLeft(0);
|
2013-06-02 00:08:23 +04:00
|
|
|
},
|
2017-12-12 06:28:26 +03:00
|
|
|
afterEach: function () {
|
2013-07-02 02:17:45 +04:00
|
|
|
// jQuery UI creates its controls outside the normal DOM hierarchy which QUnit cleans up:
|
|
|
|
if ($('#exampleNavigator').is(':ui-dialog')) {
|
|
|
|
$('#exampleNavigator').dialog('destroy');
|
|
|
|
}
|
|
|
|
|
2013-06-02 00:08:23 +04:00
|
|
|
resetTestVariables();
|
2013-03-25 20:18:55 +04:00
|
|
|
}
|
|
|
|
});
|
2013-03-21 21:55:36 +04:00
|
|
|
|
2017-12-12 06:28:26 +03:00
|
|
|
var assessNavigatorLocation = function (assert, expectedX, expectedY) {
|
2017-12-18 01:30:32 +03:00
|
|
|
navigatorElement = navigatorElement || $(".navigator");
|
|
|
|
Util.assessNumericValue(assert, expectedX, navigatorElement.offset().left, 10, ' Navigator x Position');
|
|
|
|
Util.assessNumericValue(assert, expectedY, navigatorElement.offset().top, 10, ' Navigator y Position');
|
2013-03-21 21:55:36 +04:00
|
|
|
};
|
|
|
|
|
2017-12-12 06:28:26 +03:00
|
|
|
var assessNavigatorSize = function (assert, expectedWidth, expectedHeight, msg) {
|
2017-12-18 01:30:32 +03:00
|
|
|
msg = msg || "";
|
|
|
|
navigatorElement = navigatorElement || $(".navigator");
|
|
|
|
Util.assessNumericValue(assert, expectedWidth, navigatorElement.width(), 2, ' Navigator Width ' + msg);
|
|
|
|
Util.assessNumericValue(assert, expectedHeight, navigatorElement.height(), 2, ' Navigator Height ' + msg);
|
2014-01-17 00:11:35 +04:00
|
|
|
};
|
|
|
|
|
2017-12-12 06:28:26 +03:00
|
|
|
var assessNavigatorAspectRatio = function (assert, expectedAspectRatio, variance, msg) {
|
2017-12-18 01:30:32 +03:00
|
|
|
msg = msg || "";
|
|
|
|
navigatorElement = navigatorElement || $(".navigator");
|
|
|
|
Util.assessNumericValue(
|
|
|
|
assert,
|
|
|
|
expectedAspectRatio,
|
|
|
|
navigatorElement.width() / navigatorElement.height(),
|
|
|
|
variance,
|
|
|
|
' Navigator Aspect Ratio ' + msg
|
|
|
|
);
|
2014-01-19 06:19:22 +04:00
|
|
|
};
|
|
|
|
|
2017-12-12 06:28:26 +03:00
|
|
|
var assessNavigatorArea = function (assert, expectedArea, msg) {
|
2017-12-18 01:30:32 +03:00
|
|
|
msg = msg || "";
|
|
|
|
navigatorElement = navigatorElement || $(".navigator");
|
|
|
|
Util.assessNumericValue(
|
|
|
|
assert,
|
|
|
|
expectedArea,
|
|
|
|
navigatorElement.width() * navigatorElement.height(),
|
|
|
|
Math.max(navigatorElement.width(), navigatorElement.height()),
|
|
|
|
' Navigator Area ' + msg
|
|
|
|
);
|
2014-01-17 00:11:35 +04:00
|
|
|
};
|
|
|
|
|
2014-01-21 20:44:04 +04:00
|
|
|
var navigatorRegionBoundsInPoints = function () {
|
2013-04-03 05:07:10 +04:00
|
|
|
var regionBoundsInPoints,
|
|
|
|
expectedDisplayRegionWidth,
|
|
|
|
expectedDisplayRegionHeight,
|
|
|
|
expectedDisplayRegionXLocation,
|
|
|
|
expectedDisplayRegionYLocation;
|
2014-01-17 00:11:35 +04:00
|
|
|
|
2017-12-18 01:30:32 +03:00
|
|
|
if (navigatorElement === null) {
|
|
|
|
navigatorElement = $(".navigator");
|
2016-02-16 01:09:31 +03:00
|
|
|
navigatorScaleFactor = Math.min(
|
2017-12-18 01:30:32 +03:00
|
|
|
navigatorElement.width() / viewer.viewport._contentSize.x,
|
|
|
|
navigatorElement.height() / viewer.viewport._contentSize.y
|
|
|
|
);
|
2016-02-16 01:09:31 +03:00
|
|
|
displayRegionWidth = viewer.viewport._contentSize.x * navigatorScaleFactor;
|
|
|
|
displayRegionHeight = viewer.viewport._contentSize.y * navigatorScaleFactor;
|
2017-12-18 01:30:32 +03:00
|
|
|
contentStartFromLeft = (navigatorElement.width() - displayRegionWidth) / 2;
|
|
|
|
contentStartFromTop = (navigatorElement.height() - displayRegionHeight) / 2;
|
2013-03-25 19:01:31 +04:00
|
|
|
}
|
2014-01-17 00:11:35 +04:00
|
|
|
expectedDisplayRegionWidth = viewer.viewport.getBounds().width * displayRegionWidth;
|
|
|
|
expectedDisplayRegionHeight = viewer.viewport.getBounds().height * displayRegionHeight * viewer.source.aspectRatio;
|
|
|
|
expectedDisplayRegionXLocation = viewer.viewport.getBounds().x * displayRegionWidth + contentStartFromLeft;
|
|
|
|
expectedDisplayRegionYLocation = viewer.viewport.getBounds().y * displayRegionHeight * viewer.source.aspectRatio + contentStartFromTop;
|
2017-12-18 01:30:32 +03:00
|
|
|
regionBoundsInPoints = new OpenSeadragon.Rect(
|
|
|
|
expectedDisplayRegionXLocation,
|
|
|
|
expectedDisplayRegionYLocation,
|
|
|
|
expectedDisplayRegionWidth,
|
|
|
|
expectedDisplayRegionHeight
|
|
|
|
);
|
2013-03-31 05:53:22 +04:00
|
|
|
|
2014-01-17 00:11:35 +04:00
|
|
|
if (debug) {
|
2016-02-16 01:09:31 +03:00
|
|
|
console.log('Image width: ' + viewer.viewport._contentSize.x + '\n' +
|
|
|
|
'Image height: ' + viewer.viewport._contentSize.y + '\n' +
|
2017-12-18 01:30:32 +03:00
|
|
|
'navigatorElement.width(): ' + navigatorElement.width() + '\n' +
|
|
|
|
'navigatorElement.height(): ' + navigatorElement.height() + '\n' +
|
2014-01-17 00:11:35 +04:00
|
|
|
'navigatorScaleFactor: ' + navigatorScaleFactor + '\n' +
|
|
|
|
'contentStartFromLeft: ' + contentStartFromLeft + '\n' +
|
|
|
|
'contentStartFromTop: ' + contentStartFromTop + '\n' +
|
|
|
|
'displayRegionWidth: ' + displayRegionWidth + '\n' +
|
|
|
|
'displayRegionHeight: ' + displayRegionHeight + '\n' +
|
|
|
|
'expectedDisplayRegionXLocation: ' + expectedDisplayRegionXLocation + '\n' +
|
|
|
|
'expectedDisplayRegionYLocation: ' + expectedDisplayRegionYLocation + '\n' +
|
|
|
|
'expectedDisplayRegionWidth: ' + expectedDisplayRegionWidth + '\n' +
|
|
|
|
'expectedDisplayRegionHeight: ' + expectedDisplayRegionHeight + '\n'
|
|
|
|
);
|
|
|
|
}
|
2013-03-31 05:53:22 +04:00
|
|
|
return regionBoundsInPoints;
|
|
|
|
};
|
|
|
|
|
2017-12-12 06:28:26 +03:00
|
|
|
var assessDisplayRegion = function (assert, status) {
|
2014-01-17 00:11:35 +04:00
|
|
|
if (debug) {
|
|
|
|
console.log(status);
|
|
|
|
}
|
2014-01-21 20:44:04 +04:00
|
|
|
var expectedBounds = navigatorRegionBoundsInPoints();
|
2017-12-18 01:30:32 +03:00
|
|
|
Util.assessNumericValue(
|
|
|
|
assert,
|
|
|
|
expectedBounds.width,
|
|
|
|
displayRegion.width() + viewer.navigator.totalBorderWidths.x,
|
|
|
|
2,
|
|
|
|
status + ' Width synchronization'
|
|
|
|
);
|
|
|
|
Util.assessNumericValue(
|
|
|
|
assert,
|
|
|
|
expectedBounds.height,
|
|
|
|
displayRegion.height() + viewer.navigator.totalBorderWidths.y,
|
|
|
|
2,
|
|
|
|
status + ' Height synchronization'
|
|
|
|
);
|
2017-12-12 06:28:26 +03:00
|
|
|
Util.assessNumericValue(assert, expectedBounds.x, displayRegion.position().left, 2, status + ' Left synchronization');
|
|
|
|
Util.assessNumericValue(assert, expectedBounds.y, displayRegion.position().top, 2, status + ' Top synchronization');
|
2013-03-21 21:55:36 +04:00
|
|
|
};
|
|
|
|
|
2017-12-18 01:30:32 +03:00
|
|
|
var waitForViewer = function () {
|
|
|
|
return function (assert, handler, count, lastDisplayRegionLeft, lastDisplayWidth) {
|
2013-04-03 05:07:10 +04:00
|
|
|
var viewerAndNavigatorDisplayReady = false,
|
|
|
|
currentDisplayRegionLeft,
|
|
|
|
currentDisplayWidth;
|
2013-04-02 22:09:49 +04:00
|
|
|
if (displayRegion === null) {
|
|
|
|
displayRegion = $(".displayregion");
|
|
|
|
}
|
|
|
|
if (typeof count !== "number") {
|
|
|
|
count = 0;
|
|
|
|
lastDisplayRegionLeft = null;
|
|
|
|
lastDisplayWidth = null;
|
|
|
|
}
|
|
|
|
try {
|
|
|
|
currentDisplayRegionLeft = displayRegion.position().left;
|
|
|
|
currentDisplayWidth = displayRegion.width();
|
|
|
|
viewerAndNavigatorDisplayReady = viewer.drawer !== null &&
|
2014-12-02 22:44:02 +03:00
|
|
|
!viewer.world.needsDraw() &&
|
2013-04-02 22:09:49 +04:00
|
|
|
currentDisplayWidth > 0 &&
|
2018-01-20 01:39:17 +03:00
|
|
|
Util.equalsWithVariance(lastDisplayRegionLeft, currentDisplayRegionLeft, 0.0001) &&
|
|
|
|
Util.equalsWithVariance(lastDisplayWidth, currentDisplayWidth, 0.0001) &&
|
|
|
|
Util.equalsWithVariance(viewer.viewport.getBounds(true).x, viewer.viewport.getBounds().x, 0.0001) &&
|
|
|
|
Util.equalsWithVariance(viewer.viewport.getBounds(true).y, viewer.viewport.getBounds().y, 0.0001) &&
|
|
|
|
Util.equalsWithVariance(viewer.viewport.getBounds(true).width, viewer.viewport.getBounds().width, 0.0001);
|
2013-04-02 22:09:49 +04:00
|
|
|
}
|
|
|
|
catch (err) {
|
2017-12-18 01:30:32 +03:00
|
|
|
if(debug) {
|
|
|
|
console.log(err);
|
|
|
|
}
|
2013-04-02 22:09:49 +04:00
|
|
|
//Ignore. Subsequent code will try again shortly
|
|
|
|
}
|
2018-01-18 21:45:56 +03:00
|
|
|
if (( !viewerAndNavigatorDisplayReady) && count < 50) {
|
2013-04-02 22:09:49 +04:00
|
|
|
count++;
|
|
|
|
setTimeout(function () {
|
2017-12-18 01:30:32 +03:00
|
|
|
waitForViewer(assert, handler, count, currentDisplayRegionLeft, currentDisplayWidth);
|
2018-01-18 21:45:56 +03:00
|
|
|
}, 100);
|
2013-04-02 22:09:49 +04:00
|
|
|
}
|
|
|
|
else {
|
2017-12-18 01:30:32 +03:00
|
|
|
if (debug) {
|
|
|
|
console.log("waitForViewer :" +
|
2014-12-02 22:44:02 +03:00
|
|
|
viewer.drawer + ":" + viewer.world.needsDraw() + ":" +
|
2013-04-02 22:09:49 +04:00
|
|
|
viewerAndNavigatorDisplayReady + ":" +
|
|
|
|
lastDisplayRegionLeft + ":" + currentDisplayRegionLeft + ":" +
|
|
|
|
lastDisplayWidth + ":" + currentDisplayWidth + ":" +
|
|
|
|
viewer.viewport.getBounds(true).x + ":" + viewer.viewport.getBounds().x + ":" +
|
|
|
|
viewer.viewport.getBounds(true).y + ":" + viewer.viewport.getBounds().y + ":" +
|
|
|
|
viewer.viewport.getBounds(true).width + ":" + viewer.viewport.getBounds().width + ":" +
|
|
|
|
count);
|
2013-03-21 21:55:36 +04:00
|
|
|
}
|
2017-12-18 01:30:32 +03:00
|
|
|
if (handler) {
|
|
|
|
handler(assert);
|
|
|
|
}
|
2013-04-02 22:09:49 +04:00
|
|
|
}
|
|
|
|
};
|
2013-03-21 21:55:36 +04:00
|
|
|
}();
|
|
|
|
|
2013-04-02 22:09:49 +04:00
|
|
|
var simulateNavigatorClick = function (viewer, locationX, locationY) {
|
2013-06-07 18:25:26 +04:00
|
|
|
//Assumes that the page has not been scrolled from the top or left
|
2013-04-03 05:07:10 +04:00
|
|
|
var $canvas = $(viewer.element).find('.openseadragon-canvas'),
|
|
|
|
offset = $canvas.offset(),
|
|
|
|
event = {
|
2017-12-18 01:30:32 +03:00
|
|
|
clientX: offset.left + locationX,
|
|
|
|
clientY: offset.top + locationY
|
2013-04-03 05:07:10 +04:00
|
|
|
};
|
2013-03-31 19:00:45 +04:00
|
|
|
$canvas
|
2020-07-25 06:05:39 +03:00
|
|
|
.simulate('mouseenter', event)
|
2013-03-31 19:00:45 +04:00
|
|
|
.simulate('mousedown', event)
|
|
|
|
.simulate('mouseup', event);
|
2013-03-31 19:10:31 +04:00
|
|
|
};
|
2013-03-31 19:00:45 +04:00
|
|
|
|
2013-04-02 22:09:49 +04:00
|
|
|
var simulateNavigatorDrag = function (viewer, distanceX, distanceY) {
|
2021-03-09 02:42:12 +03:00
|
|
|
var $canvas = $(viewer.element).find('.openseadragon-canvas'),
|
|
|
|
offset = $canvas.offset(),
|
|
|
|
event = {};
|
|
|
|
|
|
|
|
event.clientX = offset.left + 1;
|
|
|
|
event.clientY = offset.top + 1;
|
|
|
|
$canvas.simulate( 'mouseenter', event );
|
|
|
|
|
|
|
|
event.button = 0;
|
|
|
|
$canvas.simulate( 'mousedown', event );
|
|
|
|
|
|
|
|
event.clientX += distanceX;
|
|
|
|
event.clientY += distanceY;
|
|
|
|
$canvas.simulate( 'mousemove', event );
|
|
|
|
|
|
|
|
event.button = 0;
|
|
|
|
$canvas.simulate( 'mouseup', event );
|
|
|
|
|
2021-03-09 22:22:34 +03:00
|
|
|
event.clientX = offset.left - 1;
|
|
|
|
event.clientY = offset.top - 1;
|
2021-03-09 02:42:12 +03:00
|
|
|
event.relatedTarget = document.body;
|
|
|
|
$canvas.simulate( 'mouseleave', event );
|
2013-03-31 19:10:31 +04:00
|
|
|
};
|
2013-03-31 19:00:45 +04:00
|
|
|
|
2017-12-18 01:30:32 +03:00
|
|
|
var dragNavigatorBackToCenter = function () {
|
2022-12-11 22:47:52 +03:00
|
|
|
var delta = viewer.viewport.getHomeBounds().getCenter().minus(viewer.viewport.getCenter()).times(displayRegionWidth);
|
|
|
|
simulateNavigatorDrag(viewer.navigator, delta.x, delta.y);
|
2017-12-18 01:30:32 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
var resizeElement = function ($element, width, height) {
|
|
|
|
$element.width(width);
|
|
|
|
$element.height(height);
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
var assessViewerInCenter = function (assert) {
|
|
|
|
var yPositionVariance = 0.04;
|
|
|
|
if (viewer.source.aspectRatio < 1) {
|
|
|
|
yPositionVariance /= viewer.source.aspectRatio;
|
|
|
|
}
|
|
|
|
Util.assessNumericValue(
|
|
|
|
assert,
|
|
|
|
1 / viewer.source.aspectRatio / 2,
|
|
|
|
viewer.viewport.getCenter().y,
|
|
|
|
yPositionVariance,
|
|
|
|
' Viewer at center, y coord'
|
|
|
|
);
|
|
|
|
Util.assessNumericValue(assert, 0.5, viewer.viewport.getCenter().x, 0.4, ' Viewer at center, x coord');
|
|
|
|
};
|
|
|
|
|
|
|
|
var assessViewerInCorner = function (theContentCorner, assert) {
|
2013-04-02 22:09:49 +04:00
|
|
|
return function () {
|
2015-12-25 17:33:07 +03:00
|
|
|
var expectedXCoordinate, expectedYCoordinate;
|
2013-04-02 22:09:49 +04:00
|
|
|
if (theContentCorner === "TOPLEFT") {
|
|
|
|
expectedXCoordinate = 0;
|
2015-12-25 17:33:07 +03:00
|
|
|
expectedYCoordinate = 0;
|
2013-04-02 22:09:49 +04:00
|
|
|
}
|
|
|
|
else if (theContentCorner === "TOPRIGHT") {
|
|
|
|
expectedXCoordinate = 1 - viewer.viewport.getBounds().width;
|
2015-12-25 17:33:07 +03:00
|
|
|
expectedYCoordinate = 0;
|
2013-04-02 22:09:49 +04:00
|
|
|
}
|
|
|
|
else if (theContentCorner === "BOTTOMRIGHT") {
|
|
|
|
expectedXCoordinate = 1 - viewer.viewport.getBounds().width;
|
2015-12-25 17:33:07 +03:00
|
|
|
expectedYCoordinate = 1 / viewer.source.aspectRatio - viewer.viewport.getBounds().height;
|
2013-04-02 22:09:49 +04:00
|
|
|
}
|
|
|
|
else if (theContentCorner === "BOTTOMLEFT") {
|
|
|
|
expectedXCoordinate = 0;
|
2015-12-25 17:33:07 +03:00
|
|
|
expectedYCoordinate = 1 / viewer.source.aspectRatio - viewer.viewport.getBounds().height;
|
2013-04-02 22:09:49 +04:00
|
|
|
}
|
|
|
|
if (viewer.viewport.getBounds().width < 1) {
|
2017-12-18 01:30:32 +03:00
|
|
|
Util.assessNumericValue(
|
|
|
|
assert,
|
|
|
|
expectedXCoordinate,
|
|
|
|
viewer.viewport.getBounds().x,
|
|
|
|
0.04,
|
|
|
|
' Viewer at ' + theContentCorner + ', x coord'
|
|
|
|
);
|
2013-04-02 22:09:49 +04:00
|
|
|
}
|
|
|
|
if (viewer.viewport.getBounds().height < 1 / viewer.source.aspectRatio) {
|
2017-12-18 01:30:32 +03:00
|
|
|
Util.assessNumericValue(
|
|
|
|
assert,
|
|
|
|
expectedYCoordinate,
|
|
|
|
viewer.viewport.getBounds().y,
|
|
|
|
0.04,
|
|
|
|
' Viewer at ' + theContentCorner + ', y coord'
|
|
|
|
);
|
2013-04-02 22:09:49 +04:00
|
|
|
}
|
2013-07-02 02:17:45 +04:00
|
|
|
};
|
2013-04-02 06:33:58 +04:00
|
|
|
};
|
|
|
|
|
2017-12-18 01:30:32 +03:00
|
|
|
var assessNavigatorViewerPlacement = function (assert, seadragonProperties, testProperties) {
|
|
|
|
var done = assert.async();
|
2013-03-31 05:53:22 +04:00
|
|
|
|
2017-12-18 01:30:32 +03:00
|
|
|
seadragonProperties.visibilityRatio = 1;
|
|
|
|
viewer = OpenSeadragon(seadragonProperties);
|
2013-03-31 05:53:22 +04:00
|
|
|
|
2017-12-18 01:30:32 +03:00
|
|
|
var clickOnNavigator = function (theContentCorner) {
|
|
|
|
return function () {
|
|
|
|
var xPos,
|
|
|
|
yPos;
|
|
|
|
if (theContentCorner === "TOPLEFT") {
|
|
|
|
xPos = contentStartFromLeft;
|
|
|
|
yPos = contentStartFromTop + topNavigatorClickAdjustment;
|
|
|
|
}
|
|
|
|
else if (theContentCorner === "TOPRIGHT") {
|
|
|
|
xPos = contentStartFromLeft + displayRegionWidth;
|
|
|
|
yPos = contentStartFromTop + topNavigatorClickAdjustment;
|
|
|
|
}
|
|
|
|
else if (theContentCorner === "BOTTOMRIGHT") {
|
|
|
|
xPos = contentStartFromLeft + displayRegionWidth;
|
|
|
|
yPos = contentStartFromTop + displayRegionHeight;
|
|
|
|
}
|
|
|
|
else if (theContentCorner === "BOTTOMLEFT") {
|
|
|
|
xPos = contentStartFromLeft;
|
|
|
|
yPos = contentStartFromTop + displayRegionHeight;
|
|
|
|
}
|
|
|
|
simulateNavigatorClick(viewer.navigator, xPos, yPos);
|
|
|
|
};
|
|
|
|
};
|
2014-01-19 06:19:22 +04:00
|
|
|
|
2013-04-02 22:09:49 +04:00
|
|
|
var navigatorOperationScenarios = [
|
2017-12-18 01:30:32 +03:00
|
|
|
{interactionOperation: clickOnNavigator("TOPRIGHT"),
|
|
|
|
assessmentOperation: assessViewerInCorner("TOPRIGHT", assert),
|
|
|
|
assessmentMessage: "After click on navigator on top right"},
|
|
|
|
{interactionOperation: dragNavigatorBackToCenter,
|
|
|
|
assessmentOperation: assessViewerInCenter,
|
|
|
|
assessmentMessage: "After drag on navigator from top right"},
|
|
|
|
{interactionOperation: clickOnNavigator("BOTTOMLEFT"),
|
|
|
|
assessmentOperation: assessViewerInCorner("BOTTOMLEFT", assert),
|
|
|
|
assessmentMessage: "After click on navigator on bottom left"},
|
|
|
|
{interactionOperation: dragNavigatorBackToCenter,
|
|
|
|
assessmentOperation: assessViewerInCenter,
|
|
|
|
assessmentMessage: "After drag on navigator from bottom left"},
|
|
|
|
{interactionOperation: clickOnNavigator("BOTTOMRIGHT"),
|
|
|
|
assessmentOperation: assessViewerInCorner("BOTTOMRIGHT", assert),
|
|
|
|
assessmentMessage: "After click on navigator on bottom right"},
|
|
|
|
{interactionOperation: dragNavigatorBackToCenter,
|
|
|
|
assessmentOperation: assessViewerInCenter,
|
|
|
|
assessmentMessage: "After drag on navigator from bottom right"},
|
|
|
|
{interactionOperation: clickOnNavigator("TOPLEFT"),
|
|
|
|
assessmentOperation: assessViewerInCorner("TOPLEFT", assert),
|
|
|
|
assessmentMessage: "After click on navigator on top left"},
|
|
|
|
{interactionOperation: dragNavigatorBackToCenter,
|
|
|
|
assessmentOperation: assessViewerInCenter,
|
|
|
|
assessmentMessage: "After drag on navigator from top left"}
|
2014-01-19 06:19:22 +04:00
|
|
|
],
|
|
|
|
viewerResizeScenarios = [
|
2017-12-18 01:30:32 +03:00
|
|
|
{resizeFactorX: 0.5, resizeFactorY: 1.0, assessmentMessage: "After Viewer Resize (50%, 100%)"},
|
|
|
|
{resizeFactorX: 1.0, resizeFactorY: 0.5, assessmentMessage: "After Viewer Resize (100%, 50%)"},
|
|
|
|
{resizeFactorX: 1.0, resizeFactorY: 1.0, assessmentMessage: "After Viewer Resize (100%, 100%)"}
|
2014-01-19 06:19:22 +04:00
|
|
|
],
|
2014-01-21 20:44:04 +04:00
|
|
|
navigatorResizeScenarios = [
|
2017-12-18 01:30:32 +03:00
|
|
|
{resizeFactorX: 0.75, resizeFactorY: 1.0, assessmentMessage: "After Navigator Resize (75%, 100%)"},
|
|
|
|
{resizeFactorX: 1.0, resizeFactorY: 0.75, assessmentMessage: "After Navigator Resize (100%, 75%)"},
|
|
|
|
{resizeFactorX: 1.0, resizeFactorY: 1.0, assessmentMessage: "After Navigator Resize (100%, 100%)"}
|
2014-01-21 20:44:04 +04:00
|
|
|
],
|
2014-01-19 06:19:22 +04:00
|
|
|
autoFadeWaitTime = 100,
|
|
|
|
navigatorElement = null,
|
|
|
|
viewerElement = null,
|
|
|
|
viewerOriginalSize = null,
|
|
|
|
navigatorOriginalSize = null;
|
2013-04-02 22:09:49 +04:00
|
|
|
|
2013-06-12 23:06:17 +04:00
|
|
|
if ($.isNumeric(testProperties.topNavigatorClickAdjustment))
|
|
|
|
{
|
|
|
|
topNavigatorClickAdjustment = testProperties.topNavigatorClickAdjustment;
|
|
|
|
}
|
|
|
|
|
2013-04-02 22:09:49 +04:00
|
|
|
var assessNavigatorOperationAndTakeNextStep = function (step) {
|
|
|
|
return function () {
|
|
|
|
var nextStep = step + 1;
|
2017-12-12 06:28:26 +03:00
|
|
|
assessDisplayRegion(assert, navigatorOperationScenarios[step].assessmentMessage);
|
2017-12-18 01:30:32 +03:00
|
|
|
navigatorOperationScenarios[step].assessmentOperation(assert);
|
2013-04-02 22:09:49 +04:00
|
|
|
if (step === navigatorOperationScenarios.length - 1) {
|
2017-12-12 06:28:26 +03:00
|
|
|
done();
|
2013-04-02 21:49:15 +04:00
|
|
|
}
|
2013-04-02 22:09:49 +04:00
|
|
|
else {
|
|
|
|
navigatorOperationScenarios[nextStep].interactionOperation();
|
2017-12-18 01:30:32 +03:00
|
|
|
waitForViewer(assert, assessNavigatorOperationAndTakeNextStep(nextStep));
|
2013-04-02 21:49:15 +04:00
|
|
|
}
|
|
|
|
};
|
2013-03-31 05:53:22 +04:00
|
|
|
};
|
|
|
|
|
2017-12-18 01:30:32 +03:00
|
|
|
var assessAfterSnapback = function () {
|
2017-12-12 06:28:26 +03:00
|
|
|
assessDisplayRegion(assert, "After snapback");
|
2013-04-02 22:09:49 +04:00
|
|
|
navigatorOperationScenarios[0].interactionOperation();
|
2017-12-18 01:30:32 +03:00
|
|
|
waitForViewer(assert, assessNavigatorOperationAndTakeNextStep(0));
|
2013-03-21 21:55:36 +04:00
|
|
|
};
|
|
|
|
|
2017-12-18 01:30:32 +03:00
|
|
|
var assessAfterDragOnViewer = function () {
|
2017-12-12 06:28:26 +03:00
|
|
|
assessDisplayRegion(assert, "After pan");
|
2013-06-12 23:06:17 +04:00
|
|
|
viewer.viewport.applyConstraints();
|
2017-12-18 01:30:32 +03:00
|
|
|
waitForViewer(assert, assessAfterSnapback);
|
2013-06-12 23:06:17 +04:00
|
|
|
};
|
|
|
|
|
2017-12-18 01:30:32 +03:00
|
|
|
var assessAfterZoomOnViewer = function () {
|
2013-03-24 05:06:38 +04:00
|
|
|
var target = new OpenSeadragon.Point(0.4, 0.4);
|
2017-12-12 06:28:26 +03:00
|
|
|
assessDisplayRegion(assert, "After image zoom");
|
2013-03-24 05:06:38 +04:00
|
|
|
viewer.viewport.panTo(target);
|
2017-12-18 01:30:32 +03:00
|
|
|
waitForViewer(assert, assessAfterDragOnViewer);
|
2013-03-21 21:55:36 +04:00
|
|
|
};
|
|
|
|
|
2017-12-18 01:30:32 +03:00
|
|
|
var assessAfterResizeNavigator = function () {
|
2014-01-19 06:19:22 +04:00
|
|
|
viewer.viewport.zoomTo(viewer.viewport.getZoom() * 2);
|
2017-12-18 01:30:32 +03:00
|
|
|
waitForViewer(assert, assessAfterZoomOnViewer);
|
2014-01-19 06:19:22 +04:00
|
|
|
};
|
|
|
|
|
2017-12-18 01:30:32 +03:00
|
|
|
var assessNavigatorResizeAndTakeNextStep = function (step) {
|
2014-01-21 20:44:04 +04:00
|
|
|
return function () {
|
|
|
|
var nextStep = step + 1;
|
2017-12-12 06:28:26 +03:00
|
|
|
assessNavigatorSize(assert, navigatorOriginalSize.x * navigatorResizeScenarios[step].resizeFactorX, navigatorOriginalSize.y * navigatorResizeScenarios[step].resizeFactorY, navigatorResizeScenarios[step].assessmentMessage);
|
|
|
|
assessDisplayRegion(assert, navigatorResizeScenarios[step].assessmentMessage);
|
2014-01-21 20:44:04 +04:00
|
|
|
if (step === viewerResizeScenarios.length - 1) {
|
2017-12-18 01:30:32 +03:00
|
|
|
assessAfterResizeNavigator();
|
2014-01-21 20:44:04 +04:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
resizeElement(navigatorElement, navigatorOriginalSize.x * navigatorResizeScenarios[nextStep].resizeFactorX, navigatorOriginalSize.y * navigatorResizeScenarios[nextStep].resizeFactorY);
|
2017-12-18 01:30:32 +03:00
|
|
|
waitForViewer(assert, assessNavigatorResizeAndTakeNextStep(nextStep));
|
2014-01-21 20:44:04 +04:00
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2017-12-18 01:30:32 +03:00
|
|
|
var assessViewerResizeAndTakeNextStep = function (step) {
|
2014-01-19 06:19:22 +04:00
|
|
|
return function () {
|
|
|
|
var nextStep = step + 1;
|
|
|
|
if (seadragonProperties.navigatorId) {
|
|
|
|
// Navigator hosted in outside element...size shouldn't change
|
2017-12-18 01:30:32 +03:00
|
|
|
assessNavigatorSize(
|
|
|
|
assert,
|
|
|
|
navigatorOriginalSize.x,
|
|
|
|
navigatorOriginalSize.y,
|
|
|
|
viewerResizeScenarios[step].assessmentMessage
|
|
|
|
);
|
2014-01-19 06:19:22 +04:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
// Navigator hosted in viewer
|
2022-12-03 03:27:43 +03:00
|
|
|
if (seadragonProperties.navigatorPosition && seadragonProperties.navigatorPosition === 'ABSOLUTE') {
|
2014-01-19 06:19:22 +04:00
|
|
|
// Navigator positioned 'ABSOLUTE'...size shouldn't change
|
2017-12-18 01:30:32 +03:00
|
|
|
|
|
|
|
assessNavigatorSize(
|
|
|
|
assert,
|
|
|
|
navigatorOriginalSize.x,
|
|
|
|
navigatorOriginalSize.y,
|
|
|
|
viewerResizeScenarios[step].assessmentMessage
|
|
|
|
);
|
2014-01-19 06:19:22 +04:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
// Navigator positioned 'TOP_LEFT', 'TOP_RIGHT', 'BOTTOM_LEFT', or 'BOTTOM_RIGHT'
|
|
|
|
if (seadragonProperties.navigatorMaintainSizeRatio) {
|
|
|
|
// Navigator should maintain aspect ratio and size proportioned to viewer size
|
2017-12-18 01:30:32 +03:00
|
|
|
assessNavigatorAspectRatio(
|
|
|
|
assert,
|
|
|
|
viewerElement.width() / viewerElement.height(),
|
|
|
|
0.0001,
|
|
|
|
viewerResizeScenarios[step].assessmentMessage
|
|
|
|
);
|
|
|
|
assessNavigatorSize(
|
|
|
|
assert,
|
|
|
|
viewerElement.width() * seadragonProperties.navigatorSizeRatio,
|
|
|
|
viewerElement.height() * seadragonProperties.navigatorSizeRatio,
|
|
|
|
viewerResizeScenarios[step].assessmentMessage
|
|
|
|
);
|
2014-01-19 06:19:22 +04:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
// Navigator should maintain aspect ratio and area
|
|
|
|
// Variances are loosened up here, since 1 pixel rounding difference in resizing to maintain area
|
|
|
|
// can cause a relatively large difference in area and aspect ratio.
|
2017-12-18 01:30:32 +03:00
|
|
|
assessNavigatorAspectRatio(
|
|
|
|
assert,
|
|
|
|
viewerElement.width() / viewerElement.height(),
|
|
|
|
0.1,
|
|
|
|
viewerResizeScenarios[step].assessmentMessage
|
|
|
|
);
|
|
|
|
assessNavigatorArea(
|
|
|
|
assert,
|
|
|
|
navigatorOriginalSize.x * navigatorOriginalSize.y,
|
|
|
|
viewerResizeScenarios[step].assessmentMessage
|
|
|
|
);
|
2014-01-19 06:19:22 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (step === viewerResizeScenarios.length - 1) {
|
2014-01-21 20:44:04 +04:00
|
|
|
if (seadragonProperties.navigatorId) {
|
|
|
|
// Navigator hosted in outside element...run navigator resize tests
|
|
|
|
resizeElement(navigatorElement, navigatorOriginalSize.x * navigatorResizeScenarios[0].resizeFactorX, navigatorOriginalSize.y * navigatorResizeScenarios[0].resizeFactorY);
|
2017-12-18 01:30:32 +03:00
|
|
|
waitForViewer(assert, assessNavigatorResizeAndTakeNextStep(0));
|
2014-01-21 20:44:04 +04:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
// Navigator hosted in viewer...skip navigator resize tests
|
2017-12-18 01:30:32 +03:00
|
|
|
assessAfterResizeNavigator();
|
2014-01-21 20:44:04 +04:00
|
|
|
}
|
2014-01-19 06:19:22 +04:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
resizeElement(viewerElement, viewerOriginalSize.x * viewerResizeScenarios[nextStep].resizeFactorX, viewerOriginalSize.y * viewerResizeScenarios[nextStep].resizeFactorY);
|
2017-12-18 01:30:32 +03:00
|
|
|
waitForViewer(assert, assessViewerResizeAndTakeNextStep(nextStep));
|
2014-01-19 06:19:22 +04:00
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2013-04-03 19:51:24 +04:00
|
|
|
var captureInitialStateThenAct = function () {
|
2017-12-12 06:28:26 +03:00
|
|
|
assessDisplayRegion(assert, "After image load");
|
2017-12-18 01:30:32 +03:00
|
|
|
testProperties.determineExpectationsAndAssessNavigatorLocation(assert, seadragonProperties, testProperties);
|
2014-01-19 06:19:22 +04:00
|
|
|
viewerOriginalSize = new OpenSeadragon.Point(viewerElement.width(), viewerElement.height());
|
|
|
|
navigatorOriginalSize = new OpenSeadragon.Point(navigatorElement.width(), navigatorElement.height());
|
|
|
|
|
|
|
|
resizeElement(viewerElement, viewerOriginalSize.x * viewerResizeScenarios[0].resizeFactorX, viewerOriginalSize.y * viewerResizeScenarios[0].resizeFactorY);
|
2017-12-18 01:30:32 +03:00
|
|
|
|
|
|
|
waitForViewer(assert, assessViewerResizeAndTakeNextStep(0));
|
2013-03-21 21:55:36 +04:00
|
|
|
};
|
|
|
|
|
2013-06-07 18:25:26 +04:00
|
|
|
var assessAutoFadeTriggered = function () {
|
2017-12-12 06:28:26 +03:00
|
|
|
assert.ok(navigatorElement.parent().css("opacity") < 1, "Expecting navigator to be autofade when in the default location");
|
2017-12-18 01:30:32 +03:00
|
|
|
waitForViewer(assert, captureInitialStateThenAct());
|
2013-03-21 21:55:36 +04:00
|
|
|
};
|
|
|
|
|
2013-06-07 18:25:26 +04:00
|
|
|
var assessAutoFadeDisabled = function () {
|
2017-12-12 06:28:26 +03:00
|
|
|
assert.ok(navigatorElement.parent().css("opacity") > 0, "Expecting navigator to be always visible when in a custom location");
|
2017-12-18 01:30:32 +03:00
|
|
|
waitForViewer(assert, captureInitialStateThenAct());
|
2013-04-03 00:40:52 +04:00
|
|
|
};
|
2013-03-21 21:55:36 +04:00
|
|
|
|
2013-04-03 00:40:52 +04:00
|
|
|
var openHandler = function () {
|
|
|
|
viewer.removeHandler('open', openHandler);
|
2017-12-18 01:30:32 +03:00
|
|
|
navigatorElement = navigatorElement || $(testProperties.navigatorLocator);
|
2014-01-19 06:19:22 +04:00
|
|
|
viewerElement = $("#" + seadragonProperties.id);
|
2017-12-18 01:30:32 +03:00
|
|
|
displayRegion = displayRegion || $(testProperties.displayRegionLocator);
|
|
|
|
|
2014-01-19 06:19:22 +04:00
|
|
|
//TODO This should be testProperties.testAutoFade, but test hangs. Fix this!
|
2013-04-03 05:07:10 +04:00
|
|
|
if (!testProperties.testAutohide) {
|
2017-12-18 01:30:32 +03:00
|
|
|
waitForViewer(assert, captureInitialStateThenAct());
|
2013-04-03 00:40:52 +04:00
|
|
|
}
|
2013-04-03 05:07:10 +04:00
|
|
|
else {
|
2017-12-12 06:28:26 +03:00
|
|
|
assert.ok(navigatorElement.parent().css("opacity") > 0, "Expecting navigator to be visible initially");
|
2013-04-03 00:40:52 +04:00
|
|
|
var event = {
|
2017-12-18 01:30:32 +03:00
|
|
|
clientX: 1,
|
|
|
|
clientY: 1
|
2013-04-03 00:40:52 +04:00
|
|
|
};
|
2013-07-02 02:17:45 +04:00
|
|
|
|
2014-01-21 20:44:04 +04:00
|
|
|
viewerElement.simulate('blur', event);
|
2013-07-02 02:17:45 +04:00
|
|
|
|
2013-06-07 18:25:26 +04:00
|
|
|
if (testProperties.expectedAutoFade) {
|
2017-12-18 01:30:32 +03:00
|
|
|
setTimeout(assessAutoFadeTriggered, autoFadeWaitTime);
|
2013-07-02 02:17:45 +04:00
|
|
|
} else {
|
2017-12-18 01:30:32 +03:00
|
|
|
setTimeout(assessAutoFadeDisabled, autoFadeWaitTime);
|
2013-03-24 05:06:38 +04:00
|
|
|
}
|
2013-04-03 00:40:52 +04:00
|
|
|
}
|
|
|
|
};
|
|
|
|
viewer.addHandler('open', openHandler);
|
|
|
|
};
|
2013-03-21 21:55:36 +04:00
|
|
|
|
2017-12-12 06:28:26 +03:00
|
|
|
QUnit.test('DefaultNavigatorLocationWithWideImageTallViewer', function (assert) {
|
|
|
|
assessNavigatorViewerPlacement(assert, {
|
2017-12-18 01:30:32 +03:00
|
|
|
id: 'tallexample',
|
|
|
|
prefixUrl: '/build/openseadragon/images/',
|
|
|
|
tileSources: '/test/data/wide.dzi',
|
|
|
|
showNavigator: true,
|
|
|
|
navigatorSizeRatio: 0.2,
|
|
|
|
navigatorMaintainSizeRatio: false,
|
|
|
|
animationTime: 0
|
2013-03-24 05:06:38 +04:00
|
|
|
},
|
|
|
|
{
|
2017-12-18 01:30:32 +03:00
|
|
|
displayRegionLocator: '.navigator .displayregion',
|
|
|
|
navigatorLocator: '.navigator',
|
2013-06-07 18:25:26 +04:00
|
|
|
testAutoFade: false,
|
2017-12-18 01:30:32 +03:00
|
|
|
determineExpectationsAndAssessNavigatorLocation: function (assert, seadragonProperties, testProperties) {
|
|
|
|
var mainViewerElement = $("#" + seadragonProperties.id);
|
|
|
|
navigatorElement = navigatorElement || $(testProperties.navigatorLocator);
|
|
|
|
assessNavigatorLocation(
|
|
|
|
assert,
|
|
|
|
mainViewerElement.offset().left + mainViewerElement.width() - navigatorElement.width(),
|
|
|
|
mainViewerElement.offset().top
|
|
|
|
);
|
|
|
|
assessNavigatorSize(
|
|
|
|
assert,
|
|
|
|
mainViewerElement.width() * seadragonProperties.navigatorSizeRatio,
|
|
|
|
mainViewerElement.height() * seadragonProperties.navigatorSizeRatio
|
|
|
|
);
|
2017-12-12 06:28:26 +03:00
|
|
|
assessNavigatorAspectRatio(assert, mainViewerElement.width() / mainViewerElement.height(), 0.0001);
|
2013-03-24 05:06:38 +04:00
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
2013-03-21 21:55:36 +04:00
|
|
|
|
2017-12-12 06:28:26 +03:00
|
|
|
QUnit.test('DefaultNavigatorLocationWithTallImageWideViewer', function (assert) {
|
|
|
|
assessNavigatorViewerPlacement(assert, {
|
2017-12-18 01:30:32 +03:00
|
|
|
id: 'wideexample',
|
|
|
|
prefixUrl: '/build/openseadragon/images/',
|
|
|
|
tileSources: '/test/data/tall.dzi',
|
|
|
|
showNavigator: true,
|
|
|
|
navigatorSizeRatio: 0.2,
|
|
|
|
navigatorMaintainSizeRatio: false,
|
|
|
|
animationTime: 0,
|
|
|
|
controlsFadeDelay: 0,
|
|
|
|
controlsFadeLength: 1
|
2013-03-24 05:06:38 +04:00
|
|
|
},
|
|
|
|
{
|
2017-12-18 01:30:32 +03:00
|
|
|
displayRegionLocator: '.navigator .displayregion',
|
|
|
|
navigatorLocator: '.navigator',
|
2014-01-17 00:11:35 +04:00
|
|
|
testAutoFade: true,
|
|
|
|
expectedAutoFade: true,
|
2017-12-18 01:30:32 +03:00
|
|
|
determineExpectationsAndAssessNavigatorLocation: function (assert, seadragonProperties, testProperties) {
|
|
|
|
var mainViewerElement = $("#" + seadragonProperties.id);
|
|
|
|
navigatorElement = navigatorElement || $(testProperties.navigatorLocator);
|
2017-12-12 06:28:26 +03:00
|
|
|
assessNavigatorLocation(assert, mainViewerElement.offset().left + mainViewerElement.width() - navigatorElement.width(),
|
2014-01-17 00:11:35 +04:00
|
|
|
mainViewerElement.offset().top);
|
2017-12-12 06:28:26 +03:00
|
|
|
assessNavigatorSize(assert, mainViewerElement.width() * seadragonProperties.navigatorSizeRatio, mainViewerElement.height() * seadragonProperties.navigatorSizeRatio);
|
|
|
|
assessNavigatorAspectRatio(assert, mainViewerElement.width() / mainViewerElement.height(), 0.0001);
|
2013-03-24 05:06:38 +04:00
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
2013-03-21 21:55:36 +04:00
|
|
|
|
2017-12-12 06:28:26 +03:00
|
|
|
QUnit.test('TopLeftNavigatorLocation', function (assert) {
|
|
|
|
assessNavigatorViewerPlacement(assert, {
|
2017-12-18 01:30:32 +03:00
|
|
|
id: 'example',
|
|
|
|
prefixUrl: '/build/openseadragon/images/',
|
|
|
|
tileSources: '/test/data/testpattern.dzi',
|
|
|
|
showNavigationControl: false,
|
|
|
|
showNavigator: true,
|
|
|
|
navigatorSizeRatio: 0.2,
|
|
|
|
navigatorMaintainSizeRatio: false,
|
|
|
|
navigatorPosition: 'TOP_LEFT',
|
|
|
|
animationTime: 0,
|
|
|
|
controlsFadeDelay: 0,
|
|
|
|
controlsFadeLength: 1
|
2013-03-24 05:06:38 +04:00
|
|
|
},
|
|
|
|
{
|
2017-12-18 01:30:32 +03:00
|
|
|
displayRegionLocator: '.navigator .displayregion',
|
|
|
|
navigatorLocator: '.navigator',
|
2013-06-07 18:25:26 +04:00
|
|
|
testAutoFade: true,
|
2014-01-17 00:11:35 +04:00
|
|
|
expectedAutoFade: true,
|
2017-12-18 01:30:32 +03:00
|
|
|
determineExpectationsAndAssessNavigatorLocation: function (assert, seadragonProperties, testProperties) {
|
|
|
|
var mainViewerElement = $("#" + seadragonProperties.id);
|
2017-12-12 06:28:26 +03:00
|
|
|
assessNavigatorLocation(assert, mainViewerElement.offset().left,
|
2014-01-17 00:11:35 +04:00
|
|
|
mainViewerElement.offset().top);
|
2017-12-12 06:28:26 +03:00
|
|
|
assessNavigatorSize(assert, mainViewerElement.width() * seadragonProperties.navigatorSizeRatio, mainViewerElement.height() * seadragonProperties.navigatorSizeRatio);
|
|
|
|
assessNavigatorAspectRatio(assert, mainViewerElement.width() / mainViewerElement.height(), 0.0001);
|
2013-03-24 05:06:38 +04:00
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
2013-03-21 21:55:36 +04:00
|
|
|
|
2017-12-12 06:28:26 +03:00
|
|
|
QUnit.test('TopRightNavigatorLocation', function (assert) {
|
|
|
|
assessNavigatorViewerPlacement(assert, {
|
2017-12-18 01:30:32 +03:00
|
|
|
id: 'example',
|
|
|
|
prefixUrl: '/build/openseadragon/images/',
|
|
|
|
tileSources: '/test/data/testpattern.dzi',
|
|
|
|
showNavigationControl: false,
|
|
|
|
showNavigator: true,
|
|
|
|
navigatorSizeRatio: 0.2,
|
|
|
|
navigatorMaintainSizeRatio: true,
|
2014-01-17 00:11:35 +04:00
|
|
|
navigatorPosition: 'TOP_RIGHT',
|
2017-12-18 01:30:32 +03:00
|
|
|
animationTime: 0,
|
|
|
|
controlsFadeDelay: 0,
|
|
|
|
controlsFadeLength: 1
|
2013-03-24 05:06:38 +04:00
|
|
|
},
|
|
|
|
{
|
2017-12-18 01:30:32 +03:00
|
|
|
displayRegionLocator: '.navigator .displayregion',
|
|
|
|
navigatorLocator: '.navigator',
|
2013-06-07 18:25:26 +04:00
|
|
|
testAutoFade: true,
|
|
|
|
expectedAutoFade: true,
|
2017-12-18 01:30:32 +03:00
|
|
|
determineExpectationsAndAssessNavigatorLocation: function (assert, seadragonProperties, testProperties) {
|
|
|
|
var mainViewerElement = $("#" + seadragonProperties.id);
|
|
|
|
navigatorElement = navigatorElement || $(testProperties.navigatorLocator);
|
2017-12-12 06:28:26 +03:00
|
|
|
assessNavigatorLocation(assert, mainViewerElement.offset().left + mainViewerElement.width() - navigatorElement.width(),
|
2013-03-24 05:06:38 +04:00
|
|
|
mainViewerElement.offset().top);
|
2017-12-12 06:28:26 +03:00
|
|
|
assessNavigatorSize(assert, mainViewerElement.width() * seadragonProperties.navigatorSizeRatio, mainViewerElement.height() * seadragonProperties.navigatorSizeRatio);
|
|
|
|
assessNavigatorAspectRatio(assert, mainViewerElement.width() / mainViewerElement.height(), 0.0001);
|
2014-01-17 00:11:35 +04:00
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2017-12-12 06:28:26 +03:00
|
|
|
QUnit.test('BottomLeftNavigatorLocation', function (assert) {
|
|
|
|
assessNavigatorViewerPlacement(assert, {
|
2017-12-18 01:30:32 +03:00
|
|
|
id: 'example',
|
|
|
|
prefixUrl: '/build/openseadragon/images/',
|
|
|
|
tileSources: '/test/data/testpattern.dzi',
|
|
|
|
showNavigationControl: false,
|
|
|
|
showNavigator: true,
|
|
|
|
navigatorSizeRatio: 0.2,
|
|
|
|
navigatorMaintainSizeRatio: false,
|
2014-01-17 00:11:35 +04:00
|
|
|
navigatorPosition: 'BOTTOM_LEFT',
|
2017-12-18 01:30:32 +03:00
|
|
|
animationTime: 0,
|
|
|
|
controlsFadeDelay: 0,
|
|
|
|
controlsFadeLength: 1
|
2014-01-17 00:11:35 +04:00
|
|
|
},
|
|
|
|
{
|
2017-12-18 01:30:32 +03:00
|
|
|
displayRegionLocator: '.navigator .displayregion',
|
|
|
|
navigatorLocator: '.navigator',
|
2014-01-17 00:11:35 +04:00
|
|
|
testAutoFade: true,
|
|
|
|
expectedAutoFade: true,
|
2017-12-18 01:30:32 +03:00
|
|
|
determineExpectationsAndAssessNavigatorLocation: function (assert, seadragonProperties, testProperties) {
|
|
|
|
var mainViewerElement = $("#" + seadragonProperties.id);
|
|
|
|
navigatorElement = navigatorElement || $(testProperties.navigatorLocator);
|
2017-12-12 06:28:26 +03:00
|
|
|
assessNavigatorLocation(assert, mainViewerElement.offset().left,
|
2014-01-17 00:11:35 +04:00
|
|
|
mainViewerElement.offset().top + mainViewerElement.height() - navigatorElement.height());
|
2017-12-12 06:28:26 +03:00
|
|
|
assessNavigatorSize(assert, mainViewerElement.width() * seadragonProperties.navigatorSizeRatio, mainViewerElement.height() * seadragonProperties.navigatorSizeRatio);
|
|
|
|
assessNavigatorAspectRatio(assert, mainViewerElement.width() / mainViewerElement.height(), 0.0001);
|
2014-01-17 00:11:35 +04:00
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2017-12-12 06:28:26 +03:00
|
|
|
QUnit.test('BottomRightNavigatorLocation', function (assert) {
|
|
|
|
assessNavigatorViewerPlacement(assert, {
|
2017-12-18 01:30:32 +03:00
|
|
|
id: 'example',
|
|
|
|
prefixUrl: '/build/openseadragon/images/',
|
|
|
|
tileSources: '/test/data/testpattern.dzi',
|
|
|
|
showNavigationControl: false,
|
|
|
|
showNavigator: true,
|
|
|
|
navigatorSizeRatio: 0.2,
|
|
|
|
navigatorMaintainSizeRatio: false,
|
|
|
|
navigatorPosition: 'BOTTOM_RIGHT',
|
|
|
|
animationTime: 0,
|
|
|
|
controlsFadeDelay: 0,
|
|
|
|
controlsFadeLength: 1
|
2014-01-17 00:11:35 +04:00
|
|
|
},
|
|
|
|
{
|
2017-12-18 01:30:32 +03:00
|
|
|
displayRegionLocator: '.navigator .displayregion',
|
|
|
|
navigatorLocator: '.navigator',
|
2014-01-17 00:11:35 +04:00
|
|
|
testAutoFade: true,
|
|
|
|
expectedAutoFade: true,
|
2017-12-18 01:30:32 +03:00
|
|
|
determineExpectationsAndAssessNavigatorLocation: function (assert, seadragonProperties, testProperties) {
|
|
|
|
var mainViewerElement = $("#" + seadragonProperties.id);
|
|
|
|
navigatorElement = navigatorElement || $(testProperties.navigatorLocator);
|
2017-12-12 06:28:26 +03:00
|
|
|
assessNavigatorLocation(assert, mainViewerElement.offset().left + mainViewerElement.width() - navigatorElement.width(),
|
2014-01-17 00:11:35 +04:00
|
|
|
mainViewerElement.offset().top + mainViewerElement.height() - navigatorElement.height());
|
2017-12-12 06:28:26 +03:00
|
|
|
assessNavigatorSize(assert, mainViewerElement.width() * seadragonProperties.navigatorSizeRatio, mainViewerElement.height() * seadragonProperties.navigatorSizeRatio);
|
|
|
|
assessNavigatorAspectRatio(assert, mainViewerElement.width() / mainViewerElement.height(), 0.0001);
|
2014-01-17 00:11:35 +04:00
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2018-01-04 19:35:40 +03:00
|
|
|
// QUnit.test('AbsoluteNavigatorLocation', function (assert) {
|
|
|
|
// assessNavigatorViewerPlacement(assert, {
|
|
|
|
// id: 'example',
|
|
|
|
// prefixUrl: '/build/openseadragon/images/',
|
|
|
|
// tileSources: '/test/data/testpattern.dzi',
|
|
|
|
// showNavigationControl: false,
|
|
|
|
// showNavigator: true,
|
|
|
|
// navigatorPosition: 'ABSOLUTE',
|
|
|
|
// navigatorTop: 10,
|
|
|
|
// navigatorLeft: 10,
|
|
|
|
// navigatorHeight: 150,// height of 175 makes tests pass
|
|
|
|
// navigatorWidth: 175,
|
|
|
|
// animationTime: 0,
|
|
|
|
// controlsFadeDelay: 0,
|
|
|
|
// controlsFadeLength: 1
|
|
|
|
// },
|
|
|
|
// {
|
|
|
|
// displayRegionLocator: '.navigator .displayregion',
|
|
|
|
// navigatorLocator: '.navigator',
|
|
|
|
// testAutoFade: true,
|
|
|
|
// expectedAutoFade: true,
|
|
|
|
// determineExpectationsAndAssessNavigatorLocation: function (assert, seadragonProperties, testProperties) {
|
|
|
|
// var mainViewerElement = $("#" + seadragonProperties.id);
|
|
|
|
// assessNavigatorLocation(assert, mainViewerElement.offset().left + seadragonProperties.navigatorLeft,
|
|
|
|
// mainViewerElement.offset().top + seadragonProperties.navigatorTop);
|
|
|
|
// assessNavigatorSize(assert, seadragonProperties.navigatorWidth, seadragonProperties.navigatorHeight);
|
|
|
|
// }
|
|
|
|
// });
|
|
|
|
// });
|
|
|
|
|
|
|
|
// QUnit.test('CustomNavigatorElementWithWideImageWideViewer', function (assert) {
|
|
|
|
// assessNavigatorViewerPlacement(assert, {
|
|
|
|
// id: 'wideexample',
|
|
|
|
// navigatorId: 'exampleNavigator',
|
|
|
|
// prefixUrl: '/build/openseadragon/images/',
|
|
|
|
// tileSources: '/test/data/wide.dzi',
|
|
|
|
// showNavigator: true,
|
|
|
|
// animationTime: 0
|
|
|
|
// },
|
|
|
|
// {
|
|
|
|
// displayRegionLocator: '#exampleNavigator .displayregion',
|
|
|
|
// navigatorLocator: '#exampleNavigator',
|
|
|
|
// testAutoFade: false,
|
|
|
|
// determineExpectationsAndAssessNavigatorLocation: function (assert, seadragonProperties, testProperties) {
|
|
|
|
// var mainViewerElement = $("#" + seadragonProperties.id),
|
|
|
|
// navigatorViewerElement = $("#" + seadragonProperties.navigatorId);
|
|
|
|
// assessNavigatorLocation(assert, mainViewerElement.offset().left,
|
|
|
|
// mainViewerElement.offset().top - navigatorViewerElement.parent().height());
|
|
|
|
// }
|
|
|
|
// });
|
|
|
|
// });
|
|
|
|
|
|
|
|
// QUnit.test('CustomDialogNavigatorElementWithTallImageTallViewer', function (assert) {
|
|
|
|
// $('#exampleNavigator').dialog({ width: 150,
|
|
|
|
// height: 100,
|
|
|
|
// open: function (event, ui) {
|
|
|
|
// $('#exampleNavigator').width(150);
|
|
|
|
// $('#exampleNavigator').height(100);
|
|
|
|
// }
|
|
|
|
// //TODO Use this in testing resizable navigator
|
|
|
|
// //resize: function (event, ui) {
|
|
|
|
// // //ui.size.width
|
|
|
|
// // //ui.size.height
|
|
|
|
// // //$('#exampleNavigator').dialog("option", "width", 200);
|
|
|
|
// // //$('#exampleNavigator').dialog("option", "width", 200);
|
|
|
|
// //}
|
|
|
|
// });
|
|
|
|
// assessNavigatorViewerPlacement(assert, {
|
|
|
|
// id: 'tallexample',
|
|
|
|
// navigatorId: 'exampleNavigator',
|
|
|
|
// prefixUrl: '/build/openseadragon/images/',
|
|
|
|
// tileSources: '/test/data/tall.dzi',
|
|
|
|
// showNavigator: true,
|
|
|
|
// animationTime: 0,
|
|
|
|
// controlsFadeDelay: 0,
|
|
|
|
// controlsFadeLength: 1
|
|
|
|
// },
|
|
|
|
// {
|
|
|
|
// displayRegionLocator: '#exampleNavigator .displayregion',
|
|
|
|
// navigatorLocator: '#exampleNavigator',
|
|
|
|
// testAutoFade: true,
|
|
|
|
// expectedAutoFade: false,
|
|
|
|
// //On Firefox at some screen size/resolution/magnification combinations, there is an issue with the
|
|
|
|
// //simulated click. This property is a work around for that problem
|
|
|
|
// topNavigatorClickAdjustment: 15,
|
|
|
|
// determineExpectationsAndAssessNavigatorLocation: function (assert, seadragonProperties, testProperties) {
|
|
|
|
// var jqueryDialog = $(testProperties.navigatorLocator);
|
|
|
|
// assessNavigatorLocation(assert, jqueryDialog.offset().left,
|
|
|
|
// jqueryDialog.offset().top);
|
|
|
|
// assessNavigatorSize(assert, jqueryDialog.width(), jqueryDialog.height());
|
|
|
|
// }
|
|
|
|
// });
|
|
|
|
// });
|
2013-03-21 21:55:36 +04:00
|
|
|
|
2017-12-12 06:28:26 +03:00
|
|
|
QUnit.test('Viewer closing one image and opening another', function(assert) {
|
2017-12-18 01:30:32 +03:00
|
|
|
var timeWatcher = Util.timeWatcher(assert);
|
2013-06-18 22:09:05 +04:00
|
|
|
|
|
|
|
viewer = OpenSeadragon({
|
|
|
|
id: 'example',
|
|
|
|
prefixUrl: '/build/openseadragon/images/',
|
|
|
|
tileSources: '/test/data/testpattern.dzi',
|
|
|
|
springStiffness: 100, // Faster animation = faster tests
|
|
|
|
showNavigator: true
|
|
|
|
});
|
|
|
|
|
2013-10-11 04:00:15 +04:00
|
|
|
var closeHandler1 = function(event) {
|
2013-06-18 22:09:05 +04:00
|
|
|
viewer.removeHandler('close', closeHandler1);
|
2017-12-12 06:28:26 +03:00
|
|
|
assert.ok(true, 'calling open closes the old one');
|
|
|
|
assert.equal(viewer.navigator.source, null, 'navigator source has been cleared');
|
2013-06-18 22:09:05 +04:00
|
|
|
};
|
|
|
|
|
2017-12-18 01:30:32 +03:00
|
|
|
var closeHandler2 = function(event) {
|
|
|
|
viewer.removeHandler('close', closeHandler2);
|
|
|
|
setTimeout(function() {
|
|
|
|
assert.ok(!viewer.navigator._updateRequestId, 'navigator timer is off');
|
|
|
|
timeWatcher.done();
|
|
|
|
}, 100);
|
2013-06-18 22:09:05 +04:00
|
|
|
};
|
|
|
|
|
2013-10-11 04:00:15 +04:00
|
|
|
var navOpenHandler2 = function(event) {
|
2014-11-04 20:38:16 +03:00
|
|
|
viewer.navigator.world.removeHandler('add-item', navOpenHandler2);
|
2017-12-12 06:28:26 +03:00
|
|
|
assert.equal(viewer.navigator.source, viewer.source, 'viewer and navigator have the same source');
|
2013-06-18 22:09:05 +04:00
|
|
|
viewer.addHandler('close', closeHandler2);
|
|
|
|
viewer.close();
|
|
|
|
};
|
|
|
|
|
2017-12-18 01:30:32 +03:00
|
|
|
var openHandler2 = function(event) {
|
|
|
|
viewer.removeHandler('open', openHandler2);
|
|
|
|
viewer.navigator.world.addHandler('add-item', navOpenHandler2);
|
|
|
|
};
|
|
|
|
|
|
|
|
var navOpenHandler1 = function(event) {
|
|
|
|
viewer.navigator.world.removeHandler('add-item', navOpenHandler1);
|
|
|
|
assert.equal(viewer.navigator.source, viewer.source, 'viewer and navigator have the same source');
|
|
|
|
assert.ok(viewer.navigator._updateRequestId, 'navigator timer is on');
|
|
|
|
viewer.addHandler('close', closeHandler1);
|
|
|
|
viewer.addHandler('open', openHandler2);
|
|
|
|
viewer.open('/test/data/tall.dzi');
|
|
|
|
};
|
|
|
|
|
|
|
|
var openHandler1 = function(event) {
|
|
|
|
viewer.removeHandler('open', openHandler1);
|
|
|
|
assert.ok(viewer.navigator, 'navigator exists');
|
|
|
|
viewer.navigator.world.addHandler('add-item', navOpenHandler1);
|
2013-06-18 22:09:05 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
viewer.addHandler('open', openHandler1);
|
|
|
|
});
|
2014-12-20 02:21:57 +03:00
|
|
|
|
2017-12-12 06:28:26 +03:00
|
|
|
QUnit.test('Item positions including collection mode', function(assert) {
|
|
|
|
var done = assert.async();
|
2014-12-20 02:21:57 +03:00
|
|
|
|
|
|
|
viewer = OpenSeadragon({
|
|
|
|
id: 'example',
|
|
|
|
prefixUrl: '/build/openseadragon/images/',
|
|
|
|
tileSources: ['/test/data/testpattern.dzi', '/test/data/testpattern.dzi'],
|
|
|
|
springStiffness: 100, // Faster animation = faster tests
|
|
|
|
showNavigator: true,
|
|
|
|
collectionMode: true
|
|
|
|
});
|
|
|
|
|
|
|
|
var navOpenHandler = function(event) {
|
2015-11-10 03:02:31 +03:00
|
|
|
if (viewer.navigator.world.getItemCount() === 2) {
|
2014-12-20 02:21:57 +03:00
|
|
|
viewer.navigator.world.removeHandler('add-item', navOpenHandler);
|
|
|
|
|
|
|
|
setTimeout(function() {
|
|
|
|
// Test initial formation
|
|
|
|
for (var i = 0; i < 2; i++) {
|
2017-12-18 01:30:32 +03:00
|
|
|
assert.propEqual(viewer.navigator.world.getItemAt(i).getBounds(),
|
2014-12-20 02:21:57 +03:00
|
|
|
viewer.world.getItemAt(i).getBounds(), 'bounds are the same');
|
|
|
|
}
|
|
|
|
|
|
|
|
// Try moving one
|
|
|
|
viewer.world.getItemAt(0).setPosition(new OpenSeadragon.Point(-200, -200));
|
2017-12-18 01:30:32 +03:00
|
|
|
assert.propEqual(viewer.navigator.world.getItemAt(0).getBounds(),
|
2014-12-20 02:21:57 +03:00
|
|
|
viewer.world.getItemAt(0).getBounds(), 'bounds are the same after move');
|
|
|
|
|
2017-12-12 06:28:26 +03:00
|
|
|
done();
|
2014-12-20 02:21:57 +03:00
|
|
|
}, 1);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2017-12-18 01:30:32 +03:00
|
|
|
var openHandler = function() {
|
|
|
|
viewer.removeHandler('open', openHandler);
|
|
|
|
viewer.navigator.world.addHandler('add-item', navOpenHandler);
|
|
|
|
// The navigator may already have added the items.
|
|
|
|
navOpenHandler();
|
|
|
|
};
|
|
|
|
|
2014-12-20 02:21:57 +03:00
|
|
|
viewer.addHandler('open', openHandler);
|
|
|
|
});
|
|
|
|
|
2017-12-12 06:28:26 +03:00
|
|
|
QUnit.test('Item opacity is synchronized', function(assert) {
|
|
|
|
var done = assert.async();
|
2017-05-25 19:10:54 +03:00
|
|
|
viewer = OpenSeadragon({
|
|
|
|
id: 'example',
|
|
|
|
prefixUrl: '/build/openseadragon/images/',
|
|
|
|
tileSources: ['/test/data/testpattern.dzi', '/test/data/testpattern.dzi'],
|
|
|
|
springStiffness: 100, // Faster animation = faster tests
|
|
|
|
showNavigator: true
|
|
|
|
});
|
|
|
|
|
|
|
|
var navOpenHandler = function(event) {
|
|
|
|
if (viewer.navigator.world.getItemCount() === 2) {
|
|
|
|
viewer.navigator.world.removeHandler('add-item', navOpenHandler);
|
|
|
|
|
|
|
|
setTimeout(function() {
|
|
|
|
// Test initial formation
|
|
|
|
for (var i = 0; i < 2; i++) {
|
2017-12-12 06:28:26 +03:00
|
|
|
assert.equal(viewer.navigator.world.getItemAt(i).getOpacity(),
|
2017-05-25 19:10:54 +03:00
|
|
|
viewer.world.getItemAt(i).getOpacity(), 'opacity is the same');
|
|
|
|
}
|
|
|
|
|
|
|
|
// Try changing the opacity of one
|
|
|
|
viewer.world.getItemAt(1).setOpacity(0.5);
|
2017-12-12 06:28:26 +03:00
|
|
|
assert.equal(viewer.navigator.world.getItemAt(1).getOpacity(),
|
2017-05-25 19:10:54 +03:00
|
|
|
viewer.world.getItemAt(1).getOpacity(), 'opacity is the same after change');
|
|
|
|
|
2017-12-12 06:28:26 +03:00
|
|
|
done();
|
2017-05-25 19:10:54 +03:00
|
|
|
}, 1);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
var openHandler = function() {
|
|
|
|
viewer.removeHandler('open', openHandler);
|
|
|
|
viewer.navigator.world.addHandler('add-item', navOpenHandler);
|
|
|
|
// The navigator may already have added the items.
|
|
|
|
navOpenHandler();
|
|
|
|
};
|
|
|
|
|
|
|
|
viewer.addHandler('open', openHandler);
|
|
|
|
});
|
|
|
|
|
2017-12-12 06:28:26 +03:00
|
|
|
QUnit.test('Item composite operation is synchronized', function(assert) {
|
|
|
|
var done = assert.async();
|
2017-05-25 19:10:54 +03:00
|
|
|
viewer = OpenSeadragon({
|
|
|
|
id: 'example',
|
|
|
|
prefixUrl: '/build/openseadragon/images/',
|
|
|
|
tileSources: ['/test/data/testpattern.dzi', '/test/data/testpattern.dzi'],
|
|
|
|
springStiffness: 100, // Faster animation = faster tests
|
|
|
|
showNavigator: true
|
|
|
|
});
|
|
|
|
|
|
|
|
var navOpenHandler = function(event) {
|
|
|
|
if (viewer.navigator.world.getItemCount() === 2) {
|
|
|
|
viewer.navigator.world.removeHandler('add-item', navOpenHandler);
|
|
|
|
|
|
|
|
setTimeout(function() {
|
|
|
|
// Test initial formation
|
|
|
|
for (var i = 0; i < 2; i++) {
|
2017-12-12 06:28:26 +03:00
|
|
|
assert.equal(viewer.navigator.world.getItemAt(i).getCompositeOperation(),
|
2017-05-25 19:10:54 +03:00
|
|
|
viewer.world.getItemAt(i).getCompositeOperation(), 'composite operation is the same');
|
|
|
|
}
|
|
|
|
|
|
|
|
// Try changing the composite operation of one
|
|
|
|
viewer.world.getItemAt(1).setCompositeOperation('multiply');
|
2017-12-12 06:28:26 +03:00
|
|
|
assert.equal(viewer.navigator.world.getItemAt(1).getCompositeOperation(),
|
2017-05-25 19:10:54 +03:00
|
|
|
viewer.world.getItemAt(1).getCompositeOperation(), 'composite operation is the same after change');
|
|
|
|
|
2017-12-12 06:28:26 +03:00
|
|
|
done();
|
2017-05-25 19:10:54 +03:00
|
|
|
}, 1);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
var openHandler = function() {
|
|
|
|
viewer.removeHandler('open', openHandler);
|
|
|
|
viewer.navigator.world.addHandler('add-item', navOpenHandler);
|
|
|
|
// The navigator may already have added the items.
|
|
|
|
navOpenHandler();
|
|
|
|
};
|
|
|
|
|
|
|
|
viewer.addHandler('open', openHandler);
|
|
|
|
});
|
|
|
|
|
2017-12-12 06:28:26 +03:00
|
|
|
QUnit.test('Viewer options transmitted to navigator', function(assert) {
|
2017-12-18 01:30:32 +03:00
|
|
|
var done = assert.async();
|
2015-02-27 01:57:31 +03:00
|
|
|
viewer = OpenSeadragon({
|
|
|
|
id: 'example',
|
|
|
|
prefixUrl: '/build/openseadragon/images/',
|
|
|
|
tileSources: ['/test/data/testpattern.dzi', '/test/data/testpattern.dzi'],
|
|
|
|
springStiffness: 100, // Faster animation = faster tests
|
|
|
|
showNavigator: true,
|
|
|
|
collectionMode: true,
|
|
|
|
crossOriginPolicy: 'Anonymous'
|
|
|
|
});
|
|
|
|
viewer.addHandler('open', function openHandler() {
|
|
|
|
viewer.removeHandler('open', openHandler);
|
|
|
|
|
2017-12-18 01:30:32 +03:00
|
|
|
assert.equal(viewer.navigator.prefixUrl, viewer.prefixUrl,
|
2015-02-27 01:57:31 +03:00
|
|
|
"Prefix URL should be transmitted to the navigator.");
|
2017-12-18 01:30:32 +03:00
|
|
|
assert.equal(viewer.navigator.crossOriginPolicy, viewer.crossOriginPolicy,
|
2015-02-27 01:57:31 +03:00
|
|
|
"Cross origin policy should be transmitted to the navigator.");
|
2017-12-12 06:28:26 +03:00
|
|
|
done();
|
2015-02-27 01:57:31 +03:00
|
|
|
});
|
|
|
|
|
|
|
|
});
|
|
|
|
|
2017-12-12 06:28:26 +03:00
|
|
|
QUnit.test('Viewer rotation applied to navigator by default', function(assert) {
|
|
|
|
var done = assert.async();
|
2016-02-10 03:20:52 +03:00
|
|
|
viewer = OpenSeadragon({
|
|
|
|
id: 'example',
|
|
|
|
prefixUrl: '/build/openseadragon/images/',
|
|
|
|
tileSources: '/test/data/tall.dzi',
|
|
|
|
springStiffness: 100, // Faster animation = faster tests
|
|
|
|
showNavigator: true,
|
|
|
|
degrees: 45
|
|
|
|
});
|
|
|
|
viewer.addHandler('open', function openHandler() {
|
|
|
|
viewer.removeHandler('open', openHandler);
|
|
|
|
|
2017-12-18 01:30:32 +03:00
|
|
|
assert.equal(viewer.navigator.viewport.getRotation(), 45,
|
2016-02-10 03:20:52 +03:00
|
|
|
"Rotation set in constructor should be applied to navigator by default.");
|
|
|
|
|
|
|
|
viewer.viewport.setRotation(90);
|
2017-12-18 01:30:32 +03:00
|
|
|
assert.equal(viewer.navigator.viewport.getRotation(), 90,
|
2016-02-10 03:20:52 +03:00
|
|
|
"Rotation set by setRotation should be applied to navigator by default.");
|
|
|
|
|
2017-12-12 06:28:26 +03:00
|
|
|
done();
|
2016-02-10 03:20:52 +03:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2017-12-12 06:28:26 +03:00
|
|
|
QUnit.test('Viewer rotation not applied to navigator when navigatorRotate=false', function(assert) {
|
|
|
|
var done = assert.async();
|
2016-02-10 03:20:52 +03:00
|
|
|
viewer = OpenSeadragon({
|
|
|
|
id: 'example',
|
|
|
|
prefixUrl: '/build/openseadragon/images/',
|
|
|
|
tileSources: '/test/data/tall.dzi',
|
|
|
|
springStiffness: 100, // Faster animation = faster tests
|
|
|
|
showNavigator: true,
|
|
|
|
degrees: 45,
|
|
|
|
navigatorRotate: false
|
|
|
|
});
|
|
|
|
viewer.addHandler('open', function openHandler() {
|
|
|
|
viewer.removeHandler('open', openHandler);
|
|
|
|
|
2017-12-18 01:30:32 +03:00
|
|
|
assert.equal(viewer.navigator.viewport.getRotation(), 0,
|
2016-02-10 03:20:52 +03:00
|
|
|
"Rotation set in constructor should not be applied to navigator when navigatorRotate is false.");
|
|
|
|
|
|
|
|
viewer.viewport.setRotation(90);
|
2017-12-18 01:30:32 +03:00
|
|
|
assert.equal(viewer.navigator.viewport.getRotation(), 0,
|
2016-02-10 03:20:52 +03:00
|
|
|
"Rotation set by setRotation should not be applied to navigator when navigatorRotate is false.");
|
|
|
|
|
2017-12-12 06:28:26 +03:00
|
|
|
done();
|
2016-02-10 03:20:52 +03:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2019-07-26 21:34:33 +03:00
|
|
|
QUnit.test('Explicit height/width', function(assert) {
|
|
|
|
var done = assert.async();
|
|
|
|
viewer = OpenSeadragon({
|
|
|
|
id: 'example',
|
|
|
|
prefixUrl: '/build/openseadragon/images/',
|
|
|
|
tileSources: '/test/data/tall.dzi',
|
|
|
|
springStiffness: 100, // Faster animation = faster tests
|
|
|
|
showNavigator: true,
|
|
|
|
navigatorWidth: 200,
|
|
|
|
navigatorHeight: 300
|
|
|
|
});
|
|
|
|
viewer.addOnceHandler('open', function() {
|
|
|
|
var $navigator = $('.navigator');
|
|
|
|
|
|
|
|
// With the current configuration, the default values would be 100 x 100 if we hadn't set navigatorWidth and navigatorHeight.
|
|
|
|
assert.equal($navigator.width(), 200, "Navigator starts with the correct width.");
|
|
|
|
assert.equal($navigator.height(), 300, "Navigator starts with the correct height.");
|
|
|
|
|
|
|
|
viewer.navigator.setWidth(400);
|
|
|
|
viewer.navigator.setHeight(500);
|
|
|
|
assert.equal($navigator.width(), 400, "Navigator changes to the correct width.");
|
|
|
|
assert.equal($navigator.height(), 500, "Navigator changes to the correct height.");
|
|
|
|
|
|
|
|
done();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2013-03-21 21:55:36 +04:00
|
|
|
})();
|