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 () {
|
2013-04-05 06:30:59 +04:00
|
|
|
Util.resetDom();
|
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
|
|
|
},
|
|
|
|
teardown:function () {
|
|
|
|
Util.resetDom();
|
|
|
|
resetTestVariables();
|
2013-03-25 20:18:55 +04:00
|
|
|
}
|
|
|
|
});
|
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-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-05 06:30:59 +04:00
|
|
|
Util.assessNumericValue(expectedX, navigator.offset().left, 4, ' Navigator x position');
|
|
|
|
Util.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-05 06:30:59 +04:00
|
|
|
Util.assessNumericValue(expectedBounds.width, displayRegion.width() + viewer.navigator.totalBorderWidths.x, 2, status + ' Width synchronization');
|
|
|
|
Util.assessNumericValue(expectedBounds.height, displayRegion.height() + viewer.navigator.totalBorderWidths.y, 2, status + ' Height synchronization');
|
|
|
|
Util.assessNumericValue(expectedBounds.x, displayRegion.position().left, 2, status + ' Left synchronization');
|
|
|
|
Util.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-05 06:30:59 +04:00
|
|
|
Util.equalsWithVariance(lastDisplayRegionLeft, currentDisplayRegionLeft, .0001) &&
|
|
|
|
Util.equalsWithVariance(lastDisplayWidth, currentDisplayWidth, .0001) &&
|
|
|
|
Util.equalsWithVariance(viewer.viewport.getBounds(true).x, viewer.viewport.getBounds().x, .0001) &&
|
|
|
|
Util.equalsWithVariance(viewer.viewport.getBounds(true).y, viewer.viewport.getBounds().y, .0001) &&
|
|
|
|
Util.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-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 = {
|
|
|
|
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-05 06:30:59 +04:00
|
|
|
Util.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-05 06:30:59 +04:00
|
|
|
Util.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-05 06:30:59 +04:00
|
|
|
Util.assessNumericValue(1 / viewer.source.aspectRatio / 2, viewer.viewport.getCenter().y, yPositionVariance, ' Viewer at center, y coord');
|
|
|
|
Util.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
|
|
|
],
|
2013-06-07 18:25:26 +04:00
|
|
|
autoFadeWaitTime = 100;
|
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-06-07 18:25:26 +04:00
|
|
|
var assessAutoFadeTriggered = function () {
|
|
|
|
ok($(testProperties.navigatorLocator).parent().css("opacity") < 1, "Expecting navigator to be autofade when in the default location");
|
2013-04-03 19:51:24 +04:00
|
|
|
waitForViewer(captureInitialStateThenAct);
|
2013-03-21 21:55:36 +04:00
|
|
|
};
|
|
|
|
|
2013-06-07 18:25:26 +04:00
|
|
|
var assessAutoFadeDisabled = 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
|
|
|
|
};
|
2013-06-07 18:25:26 +04:00
|
|
|
mainViewerElement.simulate('blur', event);
|
|
|
|
if (testProperties.expectedAutoFade) {
|
|
|
|
setTimeout(assessAutoFadeTriggered,autoFadeWaitTime);
|
2013-03-24 05:06:38 +04:00
|
|
|
}
|
2013-04-03 05:07:10 +04:00
|
|
|
else {
|
2013-06-07 18:25:26 +04: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
|
|
|
|
2013-03-24 05:06:38 +04:00
|
|
|
asyncTest('DefaultNavigatorLocationWithWideImageTallViewer', function () {
|
|
|
|
assessNavigatorViewerPlacement({
|
|
|
|
id:'tallexample',
|
|
|
|
prefixUrl:'/build/openseadragon/images/',
|
|
|
|
tileSources:'/test/data/wide.dzi',
|
2013-06-02 00:08:23 +04:00
|
|
|
showNavigator:true,
|
2013-06-07 18:25:26 +04:00
|
|
|
animationTime:0
|
2013-03-24 05:06:38 +04:00
|
|
|
},
|
|
|
|
{
|
|
|
|
displayRegionLocator:'.navigator .displayregion',
|
|
|
|
navigatorLocator:'.navigator',
|
2013-06-07 18:25:26 +04:00
|
|
|
testAutoFade: 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',
|
2013-06-02 00:08:23 +04:00
|
|
|
showNavigator:true,
|
2013-06-07 18:25:26 +04:00
|
|
|
animationTime:0
|
2013-03-24 05:06:38 +04:00
|
|
|
},
|
|
|
|
{
|
2013-04-03 00:40:52 +04:00
|
|
|
displayRegionLocator:'#exampleNavigator .displayregion',
|
|
|
|
navigatorLocator:'#exampleNavigator',
|
2013-06-07 18:25:26 +04:00
|
|
|
testAutoFade: 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),
|
|
|
|
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',
|
2013-06-02 00:08:23 +04:00
|
|
|
showNavigator:true,
|
|
|
|
animationTime:0,
|
2013-06-07 18:25:26 +04:00
|
|
|
controlsFadeDelay:0,
|
|
|
|
controlsFadeLength:1
|
2013-03-24 05:06:38 +04:00
|
|
|
},
|
|
|
|
{
|
2013-04-03 00:40:52 +04:00
|
|
|
displayRegionLocator:'#exampleNavigator .displayregion',
|
|
|
|
navigatorLocator:'#exampleNavigator',
|
2013-06-07 18:25:26 +04:00
|
|
|
testAutoFade: true,
|
|
|
|
expectedAutoFade: 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',
|
2013-06-02 00:08:23 +04:00
|
|
|
showNavigator:true,
|
|
|
|
animationTime:0,
|
2013-06-07 18:25:26 +04:00
|
|
|
controlsFadeDelay:0,
|
|
|
|
controlsFadeLength:1
|
2013-03-24 05:06:38 +04:00
|
|
|
},
|
|
|
|
{
|
|
|
|
displayRegionLocator:'.navigator .displayregion',
|
|
|
|
navigatorLocator:'.navigator',
|
2013-06-07 18:25:26 +04:00
|
|
|
testAutoFade: true,
|
|
|
|
expectedAutoFade: 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
|
|
|
});
|
|
|
|
|
|
|
|
})();
|