2013-03-21 21:55:36 +04:00
|
|
|
QUnit.config.autostart = false;
|
|
|
|
|
2013-03-24 05:06:38 +04:00
|
|
|
(function () {
|
2013-03-21 21:55:36 +04:00
|
|
|
var viewer = null;
|
2013-03-25 20:18:55 +04:00
|
|
|
var displayRegion = null;
|
|
|
|
var navigator = null;
|
|
|
|
var navigatorAspectRatio = null;
|
|
|
|
var leftScalingFactor = null;
|
2013-03-31 19:00:45 +04:00
|
|
|
var maxHeightFactor = null;
|
|
|
|
var spaceFromLeftEdgeOfViewerToContentStart = null;
|
|
|
|
var spaceFromTopEdgeOfViewerToContentStart = null;
|
2013-04-02 06:33:58 +04:00
|
|
|
var widthOfViewerContentOnNavigator = null;
|
|
|
|
var heightOfViewerContentOnNavigator = null;
|
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-03-25 20:18:55 +04:00
|
|
|
var resetTestVariables = function()
|
|
|
|
{
|
|
|
|
if (viewer != null) {
|
|
|
|
viewer.close();
|
|
|
|
}
|
|
|
|
displayRegion = null;
|
|
|
|
navigator = null;
|
|
|
|
navigatorAspectRatio = null;
|
|
|
|
leftScalingFactor = null;
|
2013-03-31 19:00:45 +04:00
|
|
|
maxHeightFactor = null;
|
|
|
|
spaceFromLeftEdgeOfViewerToContentStart = null;
|
|
|
|
spaceFromTopEdgeOfViewerToContentStart = null;
|
2013-04-02 06:33:58 +04:00
|
|
|
widthOfViewerContentOnNavigator = null;
|
|
|
|
heightOfViewerContentOnNavigator = null;
|
2013-03-21 21:55:36 +04:00
|
|
|
};
|
|
|
|
|
2013-03-25 20:18:55 +04:00
|
|
|
var resetDom = function()
|
|
|
|
{
|
|
|
|
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-03-31 05:53:22 +04:00
|
|
|
var equalsWithSomeVariance = function (value1, value2, variance) {
|
|
|
|
return Math.abs(value1 - value2) <= variance;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2013-03-25 20:18:55 +04:00
|
|
|
var assessNumericValueWithSomeVariance = function (value1, value2, variance, message) {
|
2013-03-31 05:53:22 +04:00
|
|
|
ok(equalsWithSomeVariance(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-03-25 20:18:55 +04:00
|
|
|
assessNumericValueWithSomeVariance(expectedX, navigator.offset().left, 4, ' Navigator x position');
|
|
|
|
assessNumericValueWithSomeVariance(expectedY, navigator.offset().top, 4, ' Navigator y position');
|
2013-03-21 21:55:36 +04:00
|
|
|
};
|
|
|
|
|
2013-03-31 18:53:33 +04:00
|
|
|
var navigatorRegionBoundsInPoints = function ()
|
2013-03-31 05:53:22 +04:00
|
|
|
{
|
|
|
|
var regionBoundsInPoints;
|
2013-03-25 20:18:55 +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");
|
|
|
|
navigatorAspectRatio = navigator.height() /navigator.width();
|
2013-03-31 05:53:22 +04:00
|
|
|
leftScalingFactor = navigatorAspectRatio * viewer.source.aspectRatio;
|
2013-03-31 18:53:33 +04:00
|
|
|
if (viewer.source.aspectRatio < 1)
|
2013-03-25 19:01:31 +04:00
|
|
|
{
|
2013-03-31 18:53:33 +04:00
|
|
|
if (viewer.source.aspectRatio < navigatorAspectRatio)
|
|
|
|
{
|
|
|
|
maxHeightFactor = viewer.source.aspectRatio * navigatorAspectRatio;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
maxHeightFactor = viewer.source.aspectRatio;
|
|
|
|
}
|
|
|
|
spaceFromLeftEdgeOfViewerToContentStart = ((1/maxHeightFactor)-1) / 2 * maxHeightFactor * navigator.width();
|
2013-04-02 06:33:58 +04:00
|
|
|
spaceFromTopEdgeOfViewerToContentStart = 0;
|
2013-03-25 19:01:31 +04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-03-31 18:53:33 +04:00
|
|
|
if (viewer.source.aspectRatio < navigatorAspectRatio)
|
|
|
|
{
|
|
|
|
spaceFromTopEdgeOfViewerToContentStart = (navigatorAspectRatio - (1/viewer.source.aspectRatio)) / 2 /navigatorAspectRatio * navigator.height();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
spaceFromTopEdgeOfViewerToContentStart = (navigatorAspectRatio - (1/viewer.source.aspectRatio)) / 2 /navigatorAspectRatio * navigator.height();
|
|
|
|
leftScalingFactor = 1;
|
|
|
|
}
|
2013-03-25 19:01:31 +04:00
|
|
|
}
|
2013-04-02 06:33:58 +04:00
|
|
|
widthOfViewerContentOnNavigator = navigator.width() - 2 * spaceFromLeftEdgeOfViewerToContentStart;
|
|
|
|
heightOfViewerContentOnNavigator = navigator.height() - 2 * spaceFromTopEdgeOfViewerToContentStart;
|
2013-03-25 19:01:31 +04:00
|
|
|
}
|
2013-03-31 18:53:33 +04:00
|
|
|
|
2013-03-31 05:53:22 +04:00
|
|
|
var expectedDisplayRegionWidth = navigator.width() / viewer.viewport.getZoom() * maxHeightFactor;
|
|
|
|
var expectedDisplayRegionHeight = navigator.height() / viewer.viewport.getZoom() * maxHeightFactor;
|
2013-03-31 18:53:33 +04:00
|
|
|
var expectedDisplayRegionXLocation = viewer.viewport.getBounds().x * maxHeightFactor * navigator.width() + spaceFromLeftEdgeOfViewerToContentStart;
|
|
|
|
var expectedDisplayRegionYLocation = viewer.viewport.getBounds().y * leftScalingFactor * navigator.width() + spaceFromTopEdgeOfViewerToContentStart ;
|
2013-03-31 05:53:22 +04:00
|
|
|
regionBoundsInPoints = new OpenSeadragon.Rect(expectedDisplayRegionXLocation,expectedDisplayRegionYLocation,expectedDisplayRegionWidth,expectedDisplayRegionHeight);
|
|
|
|
|
|
|
|
|
|
|
|
return regionBoundsInPoints;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
2013-03-31 18:53:33 +04:00
|
|
|
var assessNavigatorDisplayRegionAndMainViewerState = function (status) {
|
2013-03-25 19:01:31 +04:00
|
|
|
|
2013-03-31 18:53:33 +04:00
|
|
|
var expectedBounds = navigatorRegionBoundsInPoints();
|
2013-03-31 05:53:22 +04:00
|
|
|
assessNumericValueWithSomeVariance(expectedBounds.width, displayRegion.width() + viewer.navigator.totalBorderWidths.x, 2, status + ' Width synchronization');
|
|
|
|
assessNumericValueWithSomeVariance(expectedBounds.height, displayRegion.height() + viewer.navigator.totalBorderWidths.y, 2, status + ' Height synchronization');
|
2013-03-31 07:27:33 +04:00
|
|
|
assessNumericValueWithSomeVariance(expectedBounds.x, displayRegion.position().left, 2, status + ' Left synchronization');
|
|
|
|
assessNumericValueWithSomeVariance(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) {
|
|
|
|
// return function () {
|
2013-03-31 05:53:22 +04:00
|
|
|
var currentDisplayRegionLeft;
|
|
|
|
var currentDisplayWidth;
|
|
|
|
if (displayRegion === null)
|
|
|
|
{
|
|
|
|
displayRegion = $(".displayregion");
|
|
|
|
}
|
2013-03-31 18:42:35 +04:00
|
|
|
var viewerAndNavigatorDisplayReady = false;
|
2013-03-31 06:15:02 +04:00
|
|
|
if (typeof count !== "number") {
|
2013-03-21 21:55:36 +04:00
|
|
|
count = 0;
|
2013-03-31 05:53:22 +04:00
|
|
|
lastDisplayRegionLeft = null;
|
|
|
|
lastDisplayWidth = null;
|
2013-03-21 21:55:36 +04:00
|
|
|
}
|
2013-03-24 05:06:38 +04:00
|
|
|
try
|
|
|
|
{
|
2013-03-31 05:53:22 +04:00
|
|
|
currentDisplayRegionLeft = displayRegion.position().left;
|
|
|
|
currentDisplayWidth = displayRegion.width();
|
2013-03-31 18:42:35 +04:00
|
|
|
viewerAndNavigatorDisplayReady = viewer.drawer !== null &&
|
2013-04-02 06:33:58 +04:00
|
|
|
!viewer.drawer.needsUpdate() &&
|
2013-03-31 18:42:35 +04:00
|
|
|
currentDisplayWidth > 0 &&
|
|
|
|
equalsWithSomeVariance(lastDisplayRegionLeft, currentDisplayRegionLeft,.0001) &&
|
2013-03-31 07:27:33 +04:00
|
|
|
equalsWithSomeVariance(lastDisplayWidth,currentDisplayWidth,.0001) &&
|
|
|
|
equalsWithSomeVariance(viewer.viewport.getBounds(true).x,viewer.viewport.getBounds().x,.0001) &&
|
2013-04-02 06:33:58 +04:00
|
|
|
equalsWithSomeVariance(viewer.viewport.getBounds(true).y,viewer.viewport.getBounds().y,.0001) &&
|
2013-03-31 07:27:33 +04:00
|
|
|
equalsWithSomeVariance(viewer.viewport.getBounds(true).width,viewer.viewport.getBounds().width,.0001);
|
2013-03-24 05:06:38 +04:00
|
|
|
}
|
|
|
|
catch(err)
|
|
|
|
{
|
|
|
|
//Ignore. Subsequent code will try again shortly
|
|
|
|
}
|
2013-04-02 07:30:05 +04:00
|
|
|
if (( !viewerAndNavigatorDisplayReady) && count < 50) {
|
2013-03-21 21:55:36 +04:00
|
|
|
count++;
|
2013-03-31 07:27:33 +04:00
|
|
|
setTimeout(function () {waitForViewer(handler, count, currentDisplayRegionLeft, currentDisplayWidth);}, 100)
|
2013-03-21 21:55:36 +04:00
|
|
|
}
|
|
|
|
else {
|
2013-03-31 07:27:33 +04:00
|
|
|
if (count === 40)
|
2013-03-31 05:53:22 +04:00
|
|
|
{
|
2013-03-31 07:27:33 +04:00
|
|
|
console.log( "waitForViewer:" +
|
|
|
|
viewer.drawer + ":" + viewer.drawer.needsUpdate() + ":" +
|
2013-04-02 07:30:05 +04:00
|
|
|
viewerAndNavigatorDisplayReady + ":" +
|
2013-03-31 07:27:33 +04:00
|
|
|
lastDisplayRegionLeft + ":" + currentDisplayRegionLeft + ":" +
|
|
|
|
lastDisplayWidth + ":" + currentDisplayWidth + ":" +
|
|
|
|
viewer.viewport.getBounds(true).x + ":" + viewer.viewport.getBounds().x + ":" +
|
2013-04-02 06:33:58 +04:00
|
|
|
viewer.viewport.getBounds(true).y + ":" + viewer.viewport.getBounds().y + ":" +
|
2013-03-31 07:27:33 +04:00
|
|
|
viewer.viewport.getBounds(true).width + ":" + viewer.viewport.getBounds().width + ":" +
|
|
|
|
count );
|
2013-03-31 05:53:22 +04:00
|
|
|
}
|
2013-03-24 05:06:38 +04:00
|
|
|
handler();
|
2013-03-21 21:55:36 +04:00
|
|
|
}
|
|
|
|
};
|
2013-04-02 21:49:15 +04:00
|
|
|
// }();
|
2013-03-21 21:55:36 +04:00
|
|
|
}();
|
|
|
|
|
2013-03-31 19:00:45 +04:00
|
|
|
var simulateNavigatorClick = function(viewer, locationX, locationY) {
|
|
|
|
var $canvas = $(viewer.element).find('.openseadragon-canvas');
|
|
|
|
var offset = $canvas.offset();
|
|
|
|
var event = {
|
2013-03-31 19:10:31 +04:00
|
|
|
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
|
|
|
|
|
|
|
var simulateNavigatorDrag = function(viewer, distanceX, distanceY) {
|
|
|
|
var $canvas = $(viewer.element).find('.displayregion');
|
|
|
|
var event = {
|
2013-04-02 06:33:58 +04:00
|
|
|
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 06:33:58 +04:00
|
|
|
var assessViewerInCorner = function(theContentCorner)
|
|
|
|
{
|
2013-04-02 21:49:15 +04:00
|
|
|
return function()
|
|
|
|
{
|
2013-04-02 06:33:58 +04:00
|
|
|
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;
|
2013-04-02 18:44:42 +04:00
|
|
|
expecteYCoordinate = 1/viewer.source.aspectRatio - viewer.viewport.getBounds().height;
|
2013-04-02 06:33:58 +04:00
|
|
|
}
|
|
|
|
else if (theContentCorner === "BOTTOMLEFT")
|
|
|
|
{
|
|
|
|
expectedXCoordinate = 0;
|
2013-04-02 18:44:42 +04:00
|
|
|
expecteYCoordinate = 1/viewer.source.aspectRatio - viewer.viewport.getBounds().height;
|
2013-04-02 06:33:58 +04:00
|
|
|
}
|
|
|
|
if (viewer.viewport.getBounds().width < 1)
|
|
|
|
{
|
|
|
|
assessNumericValueWithSomeVariance(expectedXCoordinate, viewer.viewport.getBounds().x,.04, ' Viewer at ' + theContentCorner + ', x coord');
|
|
|
|
}
|
|
|
|
if (viewer.viewport.getBounds().height < 1/viewer.source.aspectRatio)
|
|
|
|
{
|
|
|
|
assessNumericValueWithSomeVariance(expecteYCoordinate, viewer.viewport.getBounds().y,.04, ' Viewer at ' + theContentCorner + ', y coord');
|
|
|
|
}
|
2013-04-02 21:49:15 +04:00
|
|
|
}
|
2013-04-02 06:33:58 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
var assessViewerInCenter = function()
|
|
|
|
{
|
|
|
|
var yPositionVariance = .04;
|
|
|
|
if (viewer.source.aspectRatio < 1)
|
|
|
|
{
|
|
|
|
yPositionVariance = yPositionVariance / viewer.source.aspectRatio;
|
|
|
|
}
|
|
|
|
assessNumericValueWithSomeVariance(1/viewer.source.aspectRatio/2, viewer.viewport.getCenter().y,yPositionVariance, ' Viewer at center, y coord');
|
|
|
|
assessNumericValueWithSomeVariance(.5, viewer.viewport.getCenter().x,.4, ' Viewer at center, x coord');
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2013-03-31 05:53:22 +04:00
|
|
|
var clickOnNavigator = function(theContentCorner)
|
|
|
|
{
|
2013-04-02 21:49:15 +04:00
|
|
|
return function()
|
2013-03-31 05:53:22 +04:00
|
|
|
{
|
2013-04-02 21:49:15 +04:00
|
|
|
var xPos, yPos;
|
|
|
|
if (theContentCorner === "TOPLEFT")
|
|
|
|
{
|
|
|
|
xPos = spaceFromLeftEdgeOfViewerToContentStart;
|
|
|
|
yPos = spaceFromTopEdgeOfViewerToContentStart;
|
|
|
|
}
|
|
|
|
else if (theContentCorner === "TOPRIGHT")
|
|
|
|
{
|
|
|
|
xPos = spaceFromLeftEdgeOfViewerToContentStart + widthOfViewerContentOnNavigator;
|
|
|
|
yPos = spaceFromTopEdgeOfViewerToContentStart;
|
|
|
|
}
|
|
|
|
else if (theContentCorner === "BOTTOMRIGHT")
|
|
|
|
{
|
|
|
|
xPos = spaceFromLeftEdgeOfViewerToContentStart + widthOfViewerContentOnNavigator;
|
|
|
|
yPos = spaceFromTopEdgeOfViewerToContentStart + heightOfViewerContentOnNavigator;
|
|
|
|
}
|
|
|
|
else if (theContentCorner === "BOTTOMLEFT")
|
|
|
|
{
|
|
|
|
xPos = spaceFromLeftEdgeOfViewerToContentStart;
|
|
|
|
yPos = spaceFromTopEdgeOfViewerToContentStart + heightOfViewerContentOnNavigator;
|
|
|
|
}
|
|
|
|
simulateNavigatorClick(viewer.navigator, xPos, yPos);
|
2013-03-31 05:53:22 +04:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
var dragNavigatorBackToCenter = function()
|
|
|
|
{
|
|
|
|
var start = viewer.viewport.getBounds().getTopLeft();
|
2013-04-02 06:33:58 +04:00
|
|
|
var target = new OpenSeadragon.Point(0.5 - viewer.viewport.getBounds().width/2,
|
|
|
|
1/viewer.source.aspectRatio/2 - viewer.viewport.getBounds().height/2);
|
2013-03-31 05:53:22 +04:00
|
|
|
var delta = target.minus(start);
|
2013-04-02 06:33:58 +04:00
|
|
|
if (viewer.source.aspectRatio < 1)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
delta.y = delta.y * viewer.source.aspectRatio;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
simulateNavigatorDrag(viewer.navigator, delta.x * widthOfViewerContentOnNavigator, delta.y * heightOfViewerContentOnNavigator);
|
2013-03-31 05:53:22 +04:00
|
|
|
};
|
|
|
|
|
2013-03-24 05:06:38 +04:00
|
|
|
var assessNavigatorViewerPlacement = function (seadragonProperties, testProperties) {
|
2013-04-02 06:33:58 +04:00
|
|
|
seadragonProperties.visibilityRatio = 1;
|
2013-03-24 05:06:38 +04:00
|
|
|
viewer = OpenSeadragon(seadragonProperties);
|
2013-03-21 21:55:36 +04:00
|
|
|
|
2013-04-02 21:49:15 +04:00
|
|
|
var navigatorInteractionOperations = [ clickOnNavigator("TOPRIGHT"),dragNavigatorBackToCenter,
|
|
|
|
clickOnNavigator("BOTTOMLEFT"),dragNavigatorBackToCenter,
|
|
|
|
clickOnNavigator("BOTTOMRIGHT"),dragNavigatorBackToCenter,
|
|
|
|
clickOnNavigator("TOPLEFT"),dragNavigatorBackToCenter ];
|
|
|
|
var navigatorAssessmentOperations = [assessViewerInCorner("TOPRIGHT"),assessViewerInCenter,
|
|
|
|
assessViewerInCorner("BOTTOMLEFT"),assessViewerInCenter,
|
|
|
|
assessViewerInCorner("BOTTOMRIGHT"),assessViewerInCenter,
|
|
|
|
assessViewerInCorner("TOPLEFT"),assessViewerInCenter];
|
|
|
|
|
|
|
|
var navigatorAssessmentMessages = ["After click on navigator on top right","After drag on navigator from top right",
|
|
|
|
"After click on navigator on bottom left","After drag on navigator from bottom left",
|
|
|
|
"After click on navigator on bottom right","After drag on navigator from bottom right",
|
|
|
|
"After click on navigator on top right","After drag on navigator from top right"];
|
|
|
|
|
|
|
|
var assessNavigatorOperationAndTakeNextStep = function(step)
|
|
|
|
{
|
|
|
|
return function()
|
|
|
|
{
|
|
|
|
var nextStep = step+1;
|
|
|
|
assessNavigatorDisplayRegionAndMainViewerState(navigatorAssessmentMessages[step]);
|
|
|
|
navigatorAssessmentOperations[step]();
|
|
|
|
if (step === navigatorInteractionOperations.length-1)
|
|
|
|
{
|
|
|
|
start();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
navigatorInteractionOperations[nextStep]();
|
|
|
|
waitForViewer(assessNavigatorOperationAndTakeNextStep(nextStep));
|
|
|
|
}
|
|
|
|
};
|
2013-03-31 05:53:22 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
var assessAfterDragOnViewer = function () {
|
2013-03-31 18:53:33 +04:00
|
|
|
assessNavigatorDisplayRegionAndMainViewerState("After pan");
|
2013-04-02 21:49:15 +04:00
|
|
|
navigatorInteractionOperations[0]();
|
|
|
|
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-03-31 18:53:33 +04:00
|
|
|
assessNavigatorDisplayRegionAndMainViewerState("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
|
|
|
};
|
|
|
|
|
|
|
|
var captureInitialStateAfterOpenAndThenAct = function () {
|
2013-03-31 18:53:33 +04:00
|
|
|
assessNavigatorDisplayRegionAndMainViewerState("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
|
|
|
};
|
|
|
|
|
|
|
|
var openHandler = function () {
|
2013-03-24 05:06:38 +04:00
|
|
|
viewer.removeHandler('open', openHandler);
|
2013-03-31 18:42:35 +04:00
|
|
|
waitForViewer(captureInitialStateAfterOpenAndThenAct);
|
2013-03-21 21:55:36 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
viewer.addHandler('open', openHandler);
|
|
|
|
|
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('ZoomAndDragOnCustomNavigatorLocation', function () {
|
|
|
|
assessNavigatorViewerPlacement({
|
|
|
|
id:'example',
|
|
|
|
navigatorId:'exampleNavigator',
|
|
|
|
prefixUrl:'/build/openseadragon/images/',
|
|
|
|
tileSources:'/test/data/testpattern.dzi',
|
|
|
|
showNavigator:true
|
|
|
|
},
|
|
|
|
{
|
|
|
|
displayRegionLocator:'#exampleNavigator .displayregion',
|
|
|
|
navigatorLocator:'#exampleNavigator',
|
|
|
|
determineExpectationsAndAssessNavigatorLocation:function (seadragonProperties, testProperties) {
|
|
|
|
var mainViewerElement = $("#" + seadragonProperties.id);
|
|
|
|
assessNavigatorLocation(mainViewerElement.offset().left,
|
|
|
|
mainViewerElement.offset().top + mainViewerElement.height());
|
|
|
|
}
|
|
|
|
});
|
2013-03-21 21:55:36 +04:00
|
|
|
});
|
|
|
|
|
|
|
|
asyncTest('DefaultNavigatorLocation', function () {
|
2013-03-24 05:06:38 +04:00
|
|
|
assessNavigatorViewerPlacement({
|
|
|
|
id:'example',
|
|
|
|
prefixUrl:'/build/openseadragon/images/',
|
|
|
|
tileSources:'/test/data/testpattern.dzi',
|
|
|
|
showNavigator:true
|
|
|
|
},
|
|
|
|
{
|
|
|
|
displayRegionLocator:'.navigator .displayregion',
|
|
|
|
navigatorLocator:'.navigator',
|
|
|
|
determineExpectationsAndAssessNavigatorLocation:function (seadragonProperties, testProperties) {
|
|
|
|
var mainViewerElement = $("#" + seadragonProperties.id);
|
|
|
|
var navigatorElement = $(testProperties.navigatorLocator);
|
|
|
|
assessNavigatorLocation(mainViewerElement.offset().left + mainViewerElement.width() - navigatorElement.width(),
|
|
|
|
mainViewerElement.offset().top);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
2013-03-21 21:55:36 +04:00
|
|
|
|
2013-03-24 05:06:38 +04:00
|
|
|
asyncTest('NavigatorOnJQueryDialog', function () {
|
2013-04-02 07:30:05 +04:00
|
|
|
$('#exampleNavigator').dialog();
|
2013-03-24 05:06:38 +04:00
|
|
|
assessNavigatorViewerPlacement({
|
|
|
|
id:'example',
|
|
|
|
navigatorId:'exampleNavigator',
|
|
|
|
prefixUrl:'/build/openseadragon/images/',
|
|
|
|
tileSources:'/test/data/testpattern.dzi',
|
|
|
|
showNavigator:true
|
|
|
|
},
|
|
|
|
{
|
|
|
|
displayRegionLocator:'#exampleNavigator .displayregion',
|
|
|
|
navigatorLocator:'#exampleNavigator',
|
|
|
|
determineExpectationsAndAssessNavigatorLocation:function (seadragonProperties, testProperties) {
|
|
|
|
var jqueryDialog = $(testProperties.navigatorLocator);
|
|
|
|
assessNavigatorLocation(jqueryDialog.offset().left,
|
|
|
|
jqueryDialog.offset().top);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
2013-03-21 21:55:36 +04:00
|
|
|
|
2013-03-24 05:06:38 +04:00
|
|
|
asyncTest('DefaultNavigatorLocationWithWideImageSquareViewer', function () {
|
|
|
|
assessNavigatorViewerPlacement({
|
|
|
|
id:'example',
|
|
|
|
prefixUrl:'/build/openseadragon/images/',
|
|
|
|
tileSources:'/test/data/wide.dzi',
|
|
|
|
showNavigator:true
|
|
|
|
},
|
|
|
|
{
|
|
|
|
displayRegionLocator:'.navigator .displayregion',
|
|
|
|
navigatorLocator:'.navigator',
|
|
|
|
determineExpectationsAndAssessNavigatorLocation:function (seadragonProperties, testProperties) {
|
|
|
|
var mainViewerElement = $("#" + seadragonProperties.id);
|
|
|
|
var navigatorElement = $(testProperties.navigatorLocator);
|
|
|
|
assessNavigatorLocation(mainViewerElement.offset().left + mainViewerElement.width() - navigatorElement.width(),
|
|
|
|
mainViewerElement.offset().top);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
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',
|
|
|
|
determineExpectationsAndAssessNavigatorLocation:function (seadragonProperties, testProperties) {
|
|
|
|
var mainViewerElement = $("#" + seadragonProperties.id);
|
|
|
|
var navigatorElement = $(testProperties.navigatorLocator);
|
|
|
|
assessNavigatorLocation(mainViewerElement.offset().left + mainViewerElement.width() - navigatorElement.width(),
|
|
|
|
mainViewerElement.offset().top);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
2013-03-21 21:55:36 +04:00
|
|
|
|
2013-03-24 05:06:38 +04:00
|
|
|
asyncTest('DefaultNavigatorLocationWithWideImageWideViewer', function () {
|
|
|
|
assessNavigatorViewerPlacement({
|
|
|
|
id:'wideexample',
|
|
|
|
prefixUrl:'/build/openseadragon/images/',
|
|
|
|
tileSources:'/test/data/wide.dzi',
|
|
|
|
showNavigator:true
|
|
|
|
},
|
|
|
|
{
|
|
|
|
displayRegionLocator:'.navigator .displayregion',
|
|
|
|
navigatorLocator:'.navigator',
|
|
|
|
determineExpectationsAndAssessNavigatorLocation:function (seadragonProperties, testProperties) {
|
|
|
|
var mainViewerElement = $("#" + seadragonProperties.id);
|
|
|
|
var navigatorElement = $(testProperties.navigatorLocator);
|
|
|
|
assessNavigatorLocation(mainViewerElement.offset().left + mainViewerElement.width() - navigatorElement.width(),
|
|
|
|
mainViewerElement.offset().top);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
2013-03-21 21:55:36 +04:00
|
|
|
|
2013-03-24 05:06:38 +04:00
|
|
|
asyncTest('DefaultNavigatorLocationWithTallImageSquareViewer', function () {
|
|
|
|
assessNavigatorViewerPlacement({
|
|
|
|
id:'example',
|
|
|
|
prefixUrl:'/build/openseadragon/images/',
|
|
|
|
tileSources:'/test/data/tall.dzi',
|
|
|
|
showNavigator:true
|
|
|
|
},
|
|
|
|
{
|
|
|
|
displayRegionLocator:'.navigator .displayregion',
|
|
|
|
navigatorLocator:'.navigator',
|
|
|
|
determineExpectationsAndAssessNavigatorLocation:function (seadragonProperties, testProperties) {
|
|
|
|
var mainViewerElement = $("#" + seadragonProperties.id);
|
|
|
|
var navigatorElement = $(testProperties.navigatorLocator);
|
|
|
|
assessNavigatorLocation(mainViewerElement.offset().left + mainViewerElement.width() - navigatorElement.width(),
|
|
|
|
mainViewerElement.offset().top);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
2013-03-21 21:55:36 +04:00
|
|
|
|
2013-03-25 19:01:31 +04:00
|
|
|
asyncTest('DefaultNavigatorLocationWithTallImageTallViewer', function () {
|
2013-03-24 05:06:38 +04:00
|
|
|
assessNavigatorViewerPlacement({
|
|
|
|
id:'tallexample',
|
|
|
|
prefixUrl:'/build/openseadragon/images/',
|
|
|
|
tileSources:'/test/data/tall.dzi',
|
|
|
|
showNavigator:true
|
|
|
|
},
|
|
|
|
{
|
|
|
|
displayRegionLocator:'.navigator .displayregion',
|
|
|
|
navigatorLocator:'.navigator',
|
|
|
|
determineExpectationsAndAssessNavigatorLocation:function (seadragonProperties, testProperties) {
|
|
|
|
var mainViewerElement = $("#" + seadragonProperties.id);
|
|
|
|
var navigatorElement = $(testProperties.navigatorLocator);
|
|
|
|
assessNavigatorLocation(mainViewerElement.offset().left + mainViewerElement.width() - navigatorElement.width(),
|
|
|
|
mainViewerElement.offset().top);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
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',
|
|
|
|
determineExpectationsAndAssessNavigatorLocation:function (seadragonProperties, testProperties) {
|
|
|
|
var mainViewerElement = $("#" + seadragonProperties.id);
|
|
|
|
var navigatorElement = $(testProperties.navigatorLocator);
|
|
|
|
assessNavigatorLocation(mainViewerElement.offset().left + mainViewerElement.width() - navigatorElement.width(),
|
|
|
|
mainViewerElement.offset().top);
|
|
|
|
}
|
|
|
|
});
|
2013-03-21 21:55:36 +04:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
//Try with different navigator locations, in a jquery dialog and in a default location
|
|
|
|
//Test whether showNavigator works
|
|
|
|
//Test whether the initial locations works
|
|
|
|
|
|
|
|
//Other tests that require additional sample images
|
|
|
|
//Switch content, make sure things work
|
|
|
|
|
2013-03-25 20:18:55 +04:00
|
|
|
//Other tests that require a reasonable event simulation approach
|
2013-03-21 21:55:36 +04:00
|
|
|
//Test autohide
|
|
|
|
//Operate on the navigator
|
|
|
|
|
|
|
|
|
|
|
|
})();
|