2013-03-21 21:55:36 +04:00
|
|
|
QUnit.config.autostart = false;
|
|
|
|
|
2013-03-24 05:06:38 +04:00
|
|
|
(function () {
|
2013-04-03 05:07:10 +04:00
|
|
|
var viewer,
|
|
|
|
displayRegion,
|
|
|
|
navigator,
|
|
|
|
navigatorAspectRatio,
|
|
|
|
leftScalingFactor,
|
|
|
|
maxHeightFactor,
|
2013-04-03 19:51:24 +04:00
|
|
|
contentStartFromLeft,
|
|
|
|
contentStartFromTop,
|
|
|
|
displayRegionWidth,
|
|
|
|
displayRegionHeight;
|
2013-03-25 20:18:55 +04:00
|
|
|
|
|
|
|
module("navigator", {
|
|
|
|
setup:function () {
|
|
|
|
resetDom();
|
|
|
|
resetTestVariables();
|
|
|
|
}
|
|
|
|
});
|
2013-03-21 21:55:36 +04:00
|
|
|
|
2013-03-24 05:06:38 +04:00
|
|
|
$(document).ready(function () {
|
2013-03-21 21:55:36 +04:00
|
|
|
start();
|
|
|
|
});
|
|
|
|
|
2013-04-02 22:09:49 +04:00
|
|
|
var resetTestVariables = function () {
|
|
|
|
if (viewer != null) {
|
|
|
|
viewer.close();
|
|
|
|
}
|
|
|
|
displayRegion = null;
|
|
|
|
navigator = null;
|
|
|
|
navigatorAspectRatio = null;
|
|
|
|
leftScalingFactor = null;
|
|
|
|
maxHeightFactor = null;
|
2013-04-03 19:51:24 +04:00
|
|
|
contentStartFromLeft = null;
|
|
|
|
contentStartFromTop = null;
|
|
|
|
displayRegionWidth = null;
|
|
|
|
displayRegionHeight = null;
|
2013-03-21 21:55:36 +04:00
|
|
|
};
|
|
|
|
|
2013-04-02 22:09:49 +04:00
|
|
|
var resetDom = function () {
|
2013-03-25 20:18:55 +04:00
|
|
|
if ($('#exampleNavigator').is(':ui-dialog')) {
|
|
|
|
$('#exampleNavigator').dialog('destroy');
|
|
|
|
}
|
|
|
|
$("#exampleNavigator").remove();
|
|
|
|
$(".navigator").remove();
|
|
|
|
$("#example").empty();
|
|
|
|
$("#tallexample").empty();
|
|
|
|
$("#wideexample").empty();
|
|
|
|
$("#example").parent().append('<div id="exampleNavigator"></div>');
|
2013-03-25 19:01:31 +04:00
|
|
|
};
|
|
|
|
|
2013-04-03 19:51:24 +04:00
|
|
|
var equalsWithVariance = function (value1, value2, variance) {
|
2013-03-31 05:53:22 +04:00
|
|
|
return Math.abs(value1 - value2) <= variance;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2013-04-03 19:51:24 +04:00
|
|
|
var assessNumericValue = function (value1, value2, variance, message) {
|
|
|
|
ok(equalsWithVariance(value1, value2, variance), message + " Expected:" + value1 + " Found: " + value2 + " Variance: " + variance);
|
2013-03-25 20:18:55 +04:00
|
|
|
};
|
2013-03-25 19:01:31 +04:00
|
|
|
|
2013-03-24 05:06:38 +04:00
|
|
|
var assessNavigatorLocation = function (expectedX, expectedY) {
|
|
|
|
var navigator = $(".navigator");
|
2013-03-21 21:55:36 +04:00
|
|
|
|
2013-04-03 19:51:24 +04:00
|
|
|
assessNumericValue(expectedX, navigator.offset().left, 4, ' Navigator x position');
|
|
|
|
assessNumericValue(expectedY, navigator.offset().top, 4, ' Navigator y position');
|
2013-03-21 21:55:36 +04:00
|
|
|
};
|
|
|
|
|
2013-04-02 22:09:49 +04:00
|
|
|
var navigatorRegionBoundsInPoints = function () {
|
2013-04-03 05:07:10 +04:00
|
|
|
var regionBoundsInPoints,
|
|
|
|
expectedDisplayRegionWidth,
|
|
|
|
expectedDisplayRegionHeight,
|
|
|
|
expectedDisplayRegionXLocation,
|
|
|
|
expectedDisplayRegionYLocation;
|
2013-04-02 22:09:49 +04:00
|
|
|
if (navigator === null) {
|
2013-03-31 19:00:45 +04:00
|
|
|
maxHeightFactor = 1;
|
2013-03-25 20:18:55 +04:00
|
|
|
navigator = $(".navigator");
|
2013-04-02 22:09:49 +04:00
|
|
|
navigatorAspectRatio = navigator.height() / navigator.width();
|
2013-03-31 05:53:22 +04:00
|
|
|
leftScalingFactor = navigatorAspectRatio * viewer.source.aspectRatio;
|
2013-04-02 22:09:49 +04:00
|
|
|
if (viewer.source.aspectRatio < 1) {
|
|
|
|
if (viewer.source.aspectRatio < navigatorAspectRatio) {
|
|
|
|
maxHeightFactor = viewer.source.aspectRatio * navigatorAspectRatio;
|
2013-03-31 18:53:33 +04:00
|
|
|
}
|
2013-04-02 22:09:49 +04:00
|
|
|
else {
|
|
|
|
maxHeightFactor = viewer.source.aspectRatio;
|
2013-03-31 18:53:33 +04:00
|
|
|
}
|
2013-04-03 19:51:24 +04:00
|
|
|
contentStartFromLeft = ((1 / maxHeightFactor) - 1) / 2 * maxHeightFactor * navigator.width();
|
|
|
|
contentStartFromTop = 0;
|
2013-03-25 19:01:31 +04:00
|
|
|
}
|
2013-04-02 22:09:49 +04:00
|
|
|
else {
|
|
|
|
if (viewer.source.aspectRatio < navigatorAspectRatio) {
|
2013-04-03 19:51:24 +04:00
|
|
|
contentStartFromTop = (navigatorAspectRatio - (1 / viewer.source.aspectRatio)) / 2 / navigatorAspectRatio * navigator.height();
|
2013-03-31 18:53:33 +04:00
|
|
|
}
|
2013-04-02 22:09:49 +04:00
|
|
|
else {
|
2013-04-03 19:51:24 +04:00
|
|
|
contentStartFromTop = (navigatorAspectRatio - (1 / viewer.source.aspectRatio)) / 2 / navigatorAspectRatio * navigator.height();
|
2013-03-31 18:53:33 +04:00
|
|
|
leftScalingFactor = 1;
|
|
|
|
}
|
2013-03-25 19:01:31 +04:00
|
|
|
}
|
2013-04-03 19:51:24 +04:00
|
|
|
displayRegionWidth = navigator.width() - 2 * contentStartFromLeft;
|
|
|
|
displayRegionHeight = navigator.height() - 2 * contentStartFromTop;
|
2013-03-25 19:01:31 +04:00
|
|
|
}
|
2013-03-31 18:53:33 +04:00
|
|
|
|
2013-04-03 05:07:10 +04:00
|
|
|
expectedDisplayRegionWidth = navigator.width() / viewer.viewport.getZoom() * maxHeightFactor;
|
|
|
|
expectedDisplayRegionHeight = navigator.height() / viewer.viewport.getZoom() * maxHeightFactor;
|
2013-04-03 19:51:24 +04:00
|
|
|
expectedDisplayRegionXLocation = viewer.viewport.getBounds().x * maxHeightFactor * navigator.width() + contentStartFromLeft;
|
|
|
|
expectedDisplayRegionYLocation = viewer.viewport.getBounds().y * leftScalingFactor * navigator.width() + contentStartFromTop;
|
2013-04-02 22:09:49 +04:00
|
|
|
regionBoundsInPoints = new OpenSeadragon.Rect(expectedDisplayRegionXLocation, expectedDisplayRegionYLocation, expectedDisplayRegionWidth, expectedDisplayRegionHeight);
|
2013-03-31 05:53:22 +04:00
|
|
|
|
|
|
|
return regionBoundsInPoints;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
2013-04-03 19:51:24 +04:00
|
|
|
var assessDisplayRegion = function (status) {
|
2013-03-25 19:01:31 +04:00
|
|
|
|
2013-03-31 18:53:33 +04:00
|
|
|
var expectedBounds = navigatorRegionBoundsInPoints();
|
2013-04-03 19:51:24 +04:00
|
|
|
assessNumericValue(expectedBounds.width, displayRegion.width() + viewer.navigator.totalBorderWidths.x, 2, status + ' Width synchronization');
|
|
|
|
assessNumericValue(expectedBounds.height, displayRegion.height() + viewer.navigator.totalBorderWidths.y, 2, status + ' Height synchronization');
|
|
|
|
assessNumericValue(expectedBounds.x, displayRegion.position().left, 2, status + ' Left synchronization');
|
|
|
|
assessNumericValue(expectedBounds.y, displayRegion.position().top, 2, status + ' Top synchronization');
|
2013-03-21 21:55:36 +04:00
|
|
|
};
|
|
|
|
|
2013-03-24 05:06:38 +04:00
|
|
|
var waitForViewer = function () {
|
2013-04-02 21:49:15 +04:00
|
|
|
return function (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 &&
|
|
|
|
!viewer.drawer.needsUpdate() &&
|
|
|
|
currentDisplayWidth > 0 &&
|
2013-04-03 19:51:24 +04:00
|
|
|
equalsWithVariance(lastDisplayRegionLeft, currentDisplayRegionLeft, .0001) &&
|
|
|
|
equalsWithVariance(lastDisplayWidth, currentDisplayWidth, .0001) &&
|
|
|
|
equalsWithVariance(viewer.viewport.getBounds(true).x, viewer.viewport.getBounds().x, .0001) &&
|
|
|
|
equalsWithVariance(viewer.viewport.getBounds(true).y, viewer.viewport.getBounds().y, .0001) &&
|
|
|
|
equalsWithVariance(viewer.viewport.getBounds(true).width, viewer.viewport.getBounds().width, .0001);
|
2013-04-02 22:09:49 +04:00
|
|
|
}
|
|
|
|
catch (err) {
|
|
|
|
//Ignore. Subsequent code will try again shortly
|
|
|
|
}
|
|
|
|
if (( !viewerAndNavigatorDisplayReady) && count < 50) {
|
|
|
|
count++;
|
|
|
|
setTimeout(function () {
|
|
|
|
waitForViewer(handler, count, currentDisplayRegionLeft, currentDisplayWidth);
|
|
|
|
}, 100)
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
if (count === 40) {
|
|
|
|
console.log("waitForViewer:" +
|
|
|
|
viewer.drawer + ":" + viewer.drawer.needsUpdate() + ":" +
|
|
|
|
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
|
|
|
}
|
2013-04-02 22:09:49 +04:00
|
|
|
handler();
|
|
|
|
}
|
|
|
|
};
|
2013-03-21 21:55:36 +04:00
|
|
|
}();
|
|
|
|
|
2013-04-02 22:09:49 +04:00
|
|
|
var simulateNavigatorClick = function (viewer, locationX, locationY) {
|
2013-04-03 05:07:10 +04:00
|
|
|
var $canvas = $(viewer.element).find('.openseadragon-canvas'),
|
|
|
|
offset = $canvas.offset(),
|
|
|
|
event = {
|
|
|
|
clientX:offset.left + locationX,
|
|
|
|
clientY:offset.top + locationY
|
|
|
|
};
|
2013-03-31 19:00:45 +04:00
|
|
|
$canvas
|
|
|
|
.simulate('mouseover', event)
|
|
|
|
.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) {
|
2013-04-03 05:07:10 +04:00
|
|
|
var $canvas = $(viewer.element).find('.displayregion'),
|
|
|
|
event = {
|
|
|
|
dx:Math.floor(distanceX),
|
|
|
|
dy:Math.floor(distanceY)
|
|
|
|
};
|
2013-03-31 19:00:45 +04:00
|
|
|
$canvas
|
|
|
|
.simulate('drag', 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 assessViewerInCorner = function (theContentCorner) {
|
|
|
|
return function () {
|
|
|
|
var expectedXCoordinate, expecteYCoordinate;
|
|
|
|
if (theContentCorner === "TOPLEFT") {
|
|
|
|
expectedXCoordinate = 0;
|
|
|
|
expecteYCoordinate = 0;
|
|
|
|
}
|
|
|
|
else if (theContentCorner === "TOPRIGHT") {
|
|
|
|
expectedXCoordinate = 1 - viewer.viewport.getBounds().width;
|
|
|
|
expecteYCoordinate = 0;
|
|
|
|
}
|
|
|
|
else if (theContentCorner === "BOTTOMRIGHT") {
|
|
|
|
expectedXCoordinate = 1 - viewer.viewport.getBounds().width;
|
|
|
|
expecteYCoordinate = 1 / viewer.source.aspectRatio - viewer.viewport.getBounds().height;
|
|
|
|
}
|
|
|
|
else if (theContentCorner === "BOTTOMLEFT") {
|
|
|
|
expectedXCoordinate = 0;
|
|
|
|
expecteYCoordinate = 1 / viewer.source.aspectRatio - viewer.viewport.getBounds().height;
|
|
|
|
}
|
|
|
|
if (viewer.viewport.getBounds().width < 1) {
|
2013-04-03 19:51:24 +04:00
|
|
|
assessNumericValue(expectedXCoordinate, viewer.viewport.getBounds().x, .04, ' Viewer at ' + theContentCorner + ', x coord');
|
2013-04-02 22:09:49 +04:00
|
|
|
}
|
|
|
|
if (viewer.viewport.getBounds().height < 1 / viewer.source.aspectRatio) {
|
2013-04-03 19:51:24 +04:00
|
|
|
assessNumericValue(expecteYCoordinate, viewer.viewport.getBounds().y, .04, ' Viewer at ' + theContentCorner + ', y coord');
|
2013-04-02 22:09:49 +04:00
|
|
|
}
|
2013-04-02 06:33:58 +04:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2013-04-02 22:09:49 +04:00
|
|
|
var assessViewerInCenter = function () {
|
2013-04-02 06:33:58 +04:00
|
|
|
var yPositionVariance = .04;
|
2013-04-02 22:09:49 +04:00
|
|
|
if (viewer.source.aspectRatio < 1) {
|
2013-04-02 06:33:58 +04:00
|
|
|
yPositionVariance = yPositionVariance / viewer.source.aspectRatio;
|
|
|
|
}
|
2013-04-03 19:51:24 +04:00
|
|
|
assessNumericValue(1 / viewer.source.aspectRatio / 2, viewer.viewport.getCenter().y, yPositionVariance, ' Viewer at center, y coord');
|
|
|
|
assessNumericValue(.5, viewer.viewport.getCenter().x, .4, ' Viewer at center, x coord');
|
2013-04-02 06:33:58 +04:00
|
|
|
};
|
|
|
|
|
2013-04-02 22:09:49 +04:00
|
|
|
var clickOnNavigator = function (theContentCorner) {
|
|
|
|
return function () {
|
2013-04-03 05:07:10 +04:00
|
|
|
var xPos,
|
|
|
|
yPos;
|
2013-04-02 22:09:49 +04:00
|
|
|
if (theContentCorner === "TOPLEFT") {
|
2013-04-03 19:51:24 +04:00
|
|
|
xPos = contentStartFromLeft;
|
|
|
|
yPos = contentStartFromTop;
|
2013-04-02 22:09:49 +04:00
|
|
|
}
|
|
|
|
else if (theContentCorner === "TOPRIGHT") {
|
2013-04-03 19:51:24 +04:00
|
|
|
xPos = contentStartFromLeft + displayRegionWidth;
|
|
|
|
yPos = contentStartFromTop;
|
2013-04-02 22:09:49 +04:00
|
|
|
}
|
|
|
|
else if (theContentCorner === "BOTTOMRIGHT") {
|
2013-04-03 19:51:24 +04:00
|
|
|
xPos = contentStartFromLeft + displayRegionWidth;
|
|
|
|
yPos = contentStartFromTop + displayRegionHeight;
|
2013-04-02 22:09:49 +04:00
|
|
|
}
|
|
|
|
else if (theContentCorner === "BOTTOMLEFT") {
|
2013-04-03 19:51:24 +04:00
|
|
|
xPos = contentStartFromLeft;
|
|
|
|
yPos = contentStartFromTop + displayRegionHeight;
|
2013-04-02 22:09:49 +04:00
|
|
|
}
|
2013-04-02 21:49:15 +04:00
|
|
|
simulateNavigatorClick(viewer.navigator, xPos, yPos);
|
2013-04-02 22:09:49 +04:00
|
|
|
}
|
2013-03-31 05:53:22 +04:00
|
|
|
};
|
|
|
|
|
2013-04-02 22:09:49 +04:00
|
|
|
var dragNavigatorBackToCenter = function () {
|
2013-04-03 05:07:10 +04:00
|
|
|
var start = viewer.viewport.getBounds().getTopLeft(),
|
|
|
|
target = new OpenSeadragon.Point(0.5 - viewer.viewport.getBounds().width / 2,
|
|
|
|
1 / viewer.source.aspectRatio / 2 - viewer.viewport.getBounds().height / 2),
|
|
|
|
delta = target.minus(start);
|
2013-04-02 22:09:49 +04:00
|
|
|
if (viewer.source.aspectRatio < 1) {
|
|
|
|
delta.y = delta.y * viewer.source.aspectRatio;
|
2013-04-02 06:33:58 +04:00
|
|
|
}
|
2013-04-03 19:51:24 +04:00
|
|
|
simulateNavigatorDrag(viewer.navigator, delta.x * displayRegionWidth, delta.y * displayRegionHeight);
|
2013-03-31 05:53:22 +04:00
|
|
|
};
|
|
|
|
|
2013-03-24 05:06:38 +04:00
|
|
|
var assessNavigatorViewerPlacement = function (seadragonProperties, testProperties) {
|
2013-04-02 22:09:49 +04:00
|
|
|
var navigatorOperationScenarios = [
|
|
|
|
{interactionOperation:clickOnNavigator("TOPRIGHT"),
|
|
|
|
assessmentOperation:assessViewerInCorner("TOPRIGHT"),
|
|
|
|
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"),
|
|
|
|
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"),
|
|
|
|
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"),
|
|
|
|
assessmentMessage:"After click on navigator on top left" },
|
|
|
|
{interactionOperation:dragNavigatorBackToCenter,
|
|
|
|
assessmentOperation:assessViewerInCenter,
|
|
|
|
assessmentMessage:"After drag on navigator from top left" }
|
2013-04-03 19:51:24 +04:00
|
|
|
],
|
|
|
|
autoHideWaitTime = 7500;
|
2013-04-02 22:09:49 +04:00
|
|
|
|
2013-04-03 05:07:10 +04:00
|
|
|
seadragonProperties.visibilityRatio = 1;
|
|
|
|
viewer = OpenSeadragon(seadragonProperties);
|
|
|
|
|
2013-04-02 22:09:49 +04:00
|
|
|
var assessNavigatorOperationAndTakeNextStep = function (step) {
|
|
|
|
return function () {
|
|
|
|
var nextStep = step + 1;
|
2013-04-03 19:51:24 +04:00
|
|
|
assessDisplayRegion(navigatorOperationScenarios[step].assessmentMessage);
|
2013-04-02 22:09:49 +04:00
|
|
|
navigatorOperationScenarios[step].assessmentOperation();
|
|
|
|
if (step === navigatorOperationScenarios.length - 1) {
|
2013-04-02 21:49:15 +04:00
|
|
|
start();
|
|
|
|
}
|
2013-04-02 22:09:49 +04:00
|
|
|
else {
|
|
|
|
navigatorOperationScenarios[nextStep].interactionOperation();
|
2013-04-02 21:49:15 +04:00
|
|
|
waitForViewer(assessNavigatorOperationAndTakeNextStep(nextStep));
|
|
|
|
}
|
|
|
|
};
|
2013-03-31 05:53:22 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
var assessAfterDragOnViewer = function () {
|
2013-04-03 19:51:24 +04:00
|
|
|
assessDisplayRegion("After pan");
|
2013-04-02 22:09:49 +04:00
|
|
|
navigatorOperationScenarios[0].interactionOperation();
|
2013-04-02 21:49:15 +04:00
|
|
|
waitForViewer(assessNavigatorOperationAndTakeNextStep(0));
|
2013-03-21 21:55:36 +04:00
|
|
|
};
|
|
|
|
|
2013-03-31 05:53:22 +04:00
|
|
|
var assessAfterZoomOnViewer = function () {
|
2013-03-24 05:06:38 +04:00
|
|
|
var target = new OpenSeadragon.Point(0.4, 0.4);
|
2013-04-03 19:51:24 +04:00
|
|
|
assessDisplayRegion("After image zoom");
|
2013-03-24 05:06:38 +04:00
|
|
|
viewer.viewport.panTo(target);
|
2013-03-31 07:27:33 +04:00
|
|
|
waitForViewer(assessAfterDragOnViewer);
|
2013-03-21 21:55:36 +04:00
|
|
|
};
|
|
|
|
|
2013-04-03 19:51:24 +04:00
|
|
|
var captureInitialStateThenAct = function () {
|
|
|
|
assessDisplayRegion("After image load");
|
2013-03-21 21:55:36 +04:00
|
|
|
|
2013-03-24 05:06:38 +04:00
|
|
|
testProperties.determineExpectationsAndAssessNavigatorLocation(seadragonProperties, testProperties);
|
2013-03-21 21:55:36 +04:00
|
|
|
|
2013-03-24 05:06:38 +04:00
|
|
|
viewer.viewport.zoomTo(viewer.viewport.getZoom() * 2);
|
2013-03-31 07:27:33 +04:00
|
|
|
waitForViewer(assessAfterZoomOnViewer);
|
2013-03-21 21:55:36 +04:00
|
|
|
};
|
|
|
|
|
2013-04-03 00:40:52 +04:00
|
|
|
var assessAutohideTriggered = function () {
|
2013-04-03 19:51:24 +04:00
|
|
|
ok($(testProperties.navigatorLocator).parent().css("opacity") == 0, "Expecting navigator to be autohide when in the default location");
|
|
|
|
waitForViewer(captureInitialStateThenAct);
|
2013-03-21 21:55:36 +04:00
|
|
|
};
|
|
|
|
|
2013-04-03 00:40:52 +04:00
|
|
|
var assessAutohideDisabled = function () {
|
2013-04-03 19:51:24 +04:00
|
|
|
ok($(testProperties.navigatorLocator).parent().css("opacity") > 0, "Expecting navigator to be always visible when in a custom location");
|
|
|
|
waitForViewer(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);
|
2013-04-03 05:07:10 +04:00
|
|
|
if (!testProperties.testAutohide) {
|
2013-04-03 19:51:24 +04:00
|
|
|
waitForViewer(captureInitialStateThenAct);
|
2013-04-03 00:40:52 +04:00
|
|
|
}
|
2013-04-03 05:07:10 +04:00
|
|
|
else {
|
2013-04-03 19:51:24 +04:00
|
|
|
ok($(testProperties.navigatorLocator).parent().css("opacity") > 0, "Expecting navigator to be visible initially");
|
2013-04-03 00:40:52 +04:00
|
|
|
var event = {
|
|
|
|
clientX:1,
|
|
|
|
clientY:1
|
|
|
|
};
|
|
|
|
var body = $("body").simulate('mouseover', event);
|
2013-04-03 05:07:10 +04:00
|
|
|
if (testProperties.expectedAutoHide) {
|
2013-04-03 19:51:24 +04:00
|
|
|
setTimeout(assessAutohideTriggered,autoHideWaitTime);
|
2013-03-24 05:06:38 +04:00
|
|
|
}
|
2013-04-03 05:07:10 +04:00
|
|
|
else {
|
2013-04-03 19:51:24 +04:00
|
|
|
setTimeout(assessAutohideDisabled,autoHideWaitTime);
|
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
|
|
|
|
2013-03-24 05:06:38 +04:00
|
|
|
asyncTest('DefaultNavigatorLocationWithWideImageTallViewer', function () {
|
|
|
|
assessNavigatorViewerPlacement({
|
|
|
|
id:'tallexample',
|
|
|
|
prefixUrl:'/build/openseadragon/images/',
|
|
|
|
tileSources:'/test/data/wide.dzi',
|
|
|
|
showNavigator:true
|
|
|
|
},
|
|
|
|
{
|
|
|
|
displayRegionLocator:'.navigator .displayregion',
|
|
|
|
navigatorLocator:'.navigator',
|
2013-04-03 00:40:52 +04:00
|
|
|
testAutohide: false,
|
|
|
|
expectedAutoHide: false,
|
2013-03-24 05:06:38 +04:00
|
|
|
determineExpectationsAndAssessNavigatorLocation:function (seadragonProperties, testProperties) {
|
2013-04-03 05:07:10 +04:00
|
|
|
var mainViewerElement = $("#" + seadragonProperties.id),
|
|
|
|
navigatorElement = $(testProperties.navigatorLocator);
|
2013-03-24 05:06:38 +04:00
|
|
|
assessNavigatorLocation(mainViewerElement.offset().left + mainViewerElement.width() - navigatorElement.width(),
|
|
|
|
mainViewerElement.offset().top);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
2013-03-21 21:55:36 +04:00
|
|
|
|
2013-04-03 00:40:52 +04:00
|
|
|
asyncTest('CustomNavigatorLocationWithWideImageWideViewer', function () {
|
2013-03-24 05:06:38 +04:00
|
|
|
assessNavigatorViewerPlacement({
|
|
|
|
id:'wideexample',
|
2013-04-03 00:40:52 +04:00
|
|
|
navigatorId:'exampleNavigator',
|
2013-03-24 05:06:38 +04:00
|
|
|
prefixUrl:'/build/openseadragon/images/',
|
|
|
|
tileSources:'/test/data/wide.dzi',
|
|
|
|
showNavigator:true
|
|
|
|
},
|
|
|
|
{
|
2013-04-03 00:40:52 +04:00
|
|
|
displayRegionLocator:'#exampleNavigator .displayregion',
|
|
|
|
navigatorLocator:'#exampleNavigator',
|
|
|
|
testAutohide: false,
|
|
|
|
expectedAutoHide: true,
|
2013-03-24 05:06:38 +04:00
|
|
|
determineExpectationsAndAssessNavigatorLocation:function (seadragonProperties, testProperties) {
|
2013-04-03 05:07:10 +04:00
|
|
|
var mainViewerElement = $("#" + seadragonProperties.id),
|
|
|
|
navigatorViewerElement = $("#" + seadragonProperties.navigatorId);
|
2013-04-03 00:40:52 +04:00
|
|
|
assessNavigatorLocation(mainViewerElement.offset().left,
|
|
|
|
mainViewerElement.offset().top - navigatorViewerElement.parent().height());
|
2013-03-24 05:06:38 +04:00
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
2013-03-21 21:55:36 +04:00
|
|
|
|
2013-04-03 00:40:52 +04:00
|
|
|
asyncTest('CustomDialogNavigatorLocationWithTallImageTallViewer', function () {
|
|
|
|
$('#exampleNavigator').dialog();
|
2013-03-24 05:06:38 +04:00
|
|
|
assessNavigatorViewerPlacement({
|
|
|
|
id:'tallexample',
|
2013-04-03 00:40:52 +04:00
|
|
|
navigatorId:'exampleNavigator',
|
2013-03-24 05:06:38 +04:00
|
|
|
prefixUrl:'/build/openseadragon/images/',
|
|
|
|
tileSources:'/test/data/tall.dzi',
|
|
|
|
showNavigator:true
|
|
|
|
},
|
|
|
|
{
|
2013-04-03 00:40:52 +04:00
|
|
|
displayRegionLocator:'#exampleNavigator .displayregion',
|
|
|
|
navigatorLocator:'#exampleNavigator',
|
|
|
|
testAutohide: true,
|
|
|
|
expectedAutoHide: false,
|
2013-03-24 05:06:38 +04:00
|
|
|
determineExpectationsAndAssessNavigatorLocation:function (seadragonProperties, testProperties) {
|
2013-04-03 00:40:52 +04:00
|
|
|
var jqueryDialog = $(testProperties.navigatorLocator);
|
|
|
|
assessNavigatorLocation(jqueryDialog.offset().left,
|
|
|
|
jqueryDialog.offset().top);
|
2013-03-24 05:06:38 +04:00
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
2013-03-21 21:55:36 +04:00
|
|
|
|
2013-03-24 05:06:38 +04:00
|
|
|
asyncTest('DefaultNavigatorLocationWithTallImageWideViewer', function () {
|
|
|
|
assessNavigatorViewerPlacement({
|
|
|
|
id:'wideexample',
|
|
|
|
prefixUrl:'/build/openseadragon/images/',
|
|
|
|
tileSources:'/test/data/tall.dzi',
|
|
|
|
showNavigator:true
|
|
|
|
},
|
|
|
|
{
|
|
|
|
displayRegionLocator:'.navigator .displayregion',
|
|
|
|
navigatorLocator:'.navigator',
|
2013-04-03 00:40:52 +04:00
|
|
|
testAutohide: true,
|
|
|
|
expectedAutoHide: true,
|
2013-03-24 05:06:38 +04:00
|
|
|
determineExpectationsAndAssessNavigatorLocation:function (seadragonProperties, testProperties) {
|
2013-04-03 05:07:10 +04:00
|
|
|
var mainViewerElement = $("#" + seadragonProperties.id),
|
|
|
|
navigatorElement = $(testProperties.navigatorLocator);
|
2013-03-24 05:06:38 +04:00
|
|
|
assessNavigatorLocation(mainViewerElement.offset().left + mainViewerElement.width() - navigatorElement.width(),
|
|
|
|
mainViewerElement.offset().top);
|
|
|
|
}
|
|
|
|
});
|
2013-03-21 21:55:36 +04:00
|
|
|
});
|
|
|
|
|
|
|
|
})();
|