More work on navigator tests

This commit is contained in:
nein09 2017-12-17 14:30:32 -08:00
parent b8a28ce838
commit 80e8065e2f
2 changed files with 439 additions and 359 deletions

View File

@ -4,7 +4,7 @@
var debug = false, var debug = false,
viewer, viewer,
displayRegion, displayRegion,
navigator, navigatorElement,
navigatorScaleFactor, navigatorScaleFactor,
contentStartFromLeft, contentStartFromLeft,
contentStartFromTop, contentStartFromTop,
@ -12,6 +12,20 @@
displayRegionHeight, displayRegionHeight,
topNavigatorClickAdjustment; topNavigatorClickAdjustment;
var resetTestVariables = function () {
if (viewer) {
viewer.close();
}
displayRegion = null;
navigatorElement = null;
navigatorScaleFactor = null;
contentStartFromLeft = null;
contentStartFromTop = null;
displayRegionWidth = null;
displayRegionHeight = null;
topNavigatorClickAdjustment = 0;
};
QUnit.module("navigator", { QUnit.module("navigator", {
beforeEach: function () { beforeEach: function () {
Util.initializeTestDOM(); Util.initializeTestDOM();
@ -29,44 +43,41 @@
} }
}); });
var resetTestVariables = function () {
if (viewer) {
viewer.close();
}
displayRegion = null;
navigator = null;
navigatorScaleFactor = null;
contentStartFromLeft = null;
contentStartFromTop = null;
displayRegionWidth = null;
displayRegionHeight = null;
topNavigatorClickAdjustment = 0;
};
var assessNavigatorLocation = function (assert, expectedX, expectedY) { var assessNavigatorLocation = function (assert, expectedX, expectedY) {
var navigator = $(".navigator"); navigatorElement = navigatorElement || $(".navigator");
Util.assessNumericValue(assert, expectedX, navigatorElement.offset().left, 10, ' Navigator x Position');
Util.assessNumericValue(assert, expectedX, navigator.offset().left, 10, ' Navigator x Position'); Util.assessNumericValue(assert, expectedY, navigatorElement.offset().top, 10, ' Navigator y Position');
Util.assessNumericValue(assert, expectedY, navigator.offset().top, 10, ' Navigator y Position');
}; };
var assessNavigatorSize = function (assert, expectedWidth, expectedHeight, msg) { var assessNavigatorSize = function (assert, expectedWidth, expectedHeight, msg) {
var navigator = $(".navigator"); msg = msg || "";
navigatorElement = navigatorElement || $(".navigator");
Util.assessNumericValue(assert, expectedWidth, navigator.width(), 2, ' Navigator Width ' + (msg ? msg : '')); Util.assessNumericValue(assert, expectedWidth, navigatorElement.width(), 2, ' Navigator Width ' + msg);
Util.assessNumericValue(assert, expectedHeight, navigator.height(), 2, ' Navigator Height ' + (msg ? msg : '')); Util.assessNumericValue(assert, expectedHeight, navigatorElement.height(), 2, ' Navigator Height ' + msg);
}; };
var assessNavigatorAspectRatio = function (assert, expectedAspectRatio, variance, msg) { var assessNavigatorAspectRatio = function (assert, expectedAspectRatio, variance, msg) {
var navigator = $(".navigator"); msg = msg || "";
navigatorElement = navigatorElement || $(".navigator");
Util.assessNumericValue(assert, expectedAspectRatio, navigator.width() / navigator.height(), variance, ' Navigator Aspect Ratio ' + (msg ? msg : '')); Util.assessNumericValue(
assert,
expectedAspectRatio,
navigatorElement.width() / navigatorElement.height(),
variance,
' Navigator Aspect Ratio ' + msg
);
}; };
var assessNavigatorArea = function (assert, expectedArea, msg) { var assessNavigatorArea = function (assert, expectedArea, msg) {
var navigator = $(".navigator"); msg = msg || "";
navigatorElement = navigatorElement || $(".navigator");
Util.assessNumericValue(assert, expectedArea, navigator.width() * navigator.height(), Math.max(navigator.width(), navigator.height()), ' Navigator Area ' + (msg ? msg : '')); Util.assessNumericValue(
assert,
expectedArea,
navigatorElement.width() * navigatorElement.height(),
Math.max(navigatorElement.width(), navigatorElement.height()),
' Navigator Area ' + msg
);
}; };
var navigatorRegionBoundsInPoints = function () { var navigatorRegionBoundsInPoints = function () {
@ -76,27 +87,33 @@
expectedDisplayRegionXLocation, expectedDisplayRegionXLocation,
expectedDisplayRegionYLocation; expectedDisplayRegionYLocation;
if (navigator === null) { if (navigatorElement === null) {
navigator = $(".navigator"); navigatorElement = $(".navigator");
navigatorScaleFactor = Math.min( navigatorScaleFactor = Math.min(
navigator.width() / viewer.viewport._contentSize.x, navigatorElement.width() / viewer.viewport._contentSize.x,
navigator.height() / viewer.viewport._contentSize.y); navigatorElement.height() / viewer.viewport._contentSize.y
);
displayRegionWidth = viewer.viewport._contentSize.x * navigatorScaleFactor; displayRegionWidth = viewer.viewport._contentSize.x * navigatorScaleFactor;
displayRegionHeight = viewer.viewport._contentSize.y * navigatorScaleFactor; displayRegionHeight = viewer.viewport._contentSize.y * navigatorScaleFactor;
contentStartFromLeft = (navigator.width() - displayRegionWidth) / 2; contentStartFromLeft = (navigatorElement.width() - displayRegionWidth) / 2;
contentStartFromTop = (navigator.height() - displayRegionHeight) / 2; contentStartFromTop = (navigatorElement.height() - displayRegionHeight) / 2;
} }
expectedDisplayRegionWidth = viewer.viewport.getBounds().width * displayRegionWidth; expectedDisplayRegionWidth = viewer.viewport.getBounds().width * displayRegionWidth;
expectedDisplayRegionHeight = viewer.viewport.getBounds().height * displayRegionHeight * viewer.source.aspectRatio; expectedDisplayRegionHeight = viewer.viewport.getBounds().height * displayRegionHeight * viewer.source.aspectRatio;
expectedDisplayRegionXLocation = viewer.viewport.getBounds().x * displayRegionWidth + contentStartFromLeft; expectedDisplayRegionXLocation = viewer.viewport.getBounds().x * displayRegionWidth + contentStartFromLeft;
expectedDisplayRegionYLocation = viewer.viewport.getBounds().y * displayRegionHeight * viewer.source.aspectRatio + contentStartFromTop; expectedDisplayRegionYLocation = viewer.viewport.getBounds().y * displayRegionHeight * viewer.source.aspectRatio + contentStartFromTop;
regionBoundsInPoints = new OpenSeadragon.Rect(expectedDisplayRegionXLocation, expectedDisplayRegionYLocation, expectedDisplayRegionWidth, expectedDisplayRegionHeight); regionBoundsInPoints = new OpenSeadragon.Rect(
expectedDisplayRegionXLocation,
expectedDisplayRegionYLocation,
expectedDisplayRegionWidth,
expectedDisplayRegionHeight
);
if (debug) { if (debug) {
console.log('Image width: ' + viewer.viewport._contentSize.x + '\n' + console.log('Image width: ' + viewer.viewport._contentSize.x + '\n' +
'Image height: ' + viewer.viewport._contentSize.y + '\n' + 'Image height: ' + viewer.viewport._contentSize.y + '\n' +
'navigator.width(): ' + navigator.width() + '\n' + 'navigatorElement.width(): ' + navigatorElement.width() + '\n' +
'navigator.height(): ' + navigator.height() + '\n' + 'navigatorElement.height(): ' + navigatorElement.height() + '\n' +
'navigatorScaleFactor: ' + navigatorScaleFactor + '\n' + 'navigatorScaleFactor: ' + navigatorScaleFactor + '\n' +
'contentStartFromLeft: ' + contentStartFromLeft + '\n' + 'contentStartFromLeft: ' + contentStartFromLeft + '\n' +
'contentStartFromTop: ' + contentStartFromTop + '\n' + 'contentStartFromTop: ' + contentStartFromTop + '\n' +
@ -108,25 +125,34 @@
'expectedDisplayRegionHeight: ' + expectedDisplayRegionHeight + '\n' 'expectedDisplayRegionHeight: ' + expectedDisplayRegionHeight + '\n'
); );
} }
return regionBoundsInPoints; return regionBoundsInPoints;
}; };
var assessDisplayRegion = function (assert, status) { var assessDisplayRegion = function (assert, status) {
if (debug) { if (debug) {
console.log(status); console.log(status);
} }
var expectedBounds = navigatorRegionBoundsInPoints(); var expectedBounds = navigatorRegionBoundsInPoints();
Util.assessNumericValue(assert, expectedBounds.width, displayRegion.width() + viewer.navigator.totalBorderWidths.x, 2, status + ' Width synchronization'); Util.assessNumericValue(
Util.assessNumericValue(assert, expectedBounds.height, displayRegion.height() + viewer.navigator.totalBorderWidths.y, 2, status + ' Height synchronization'); 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'
);
Util.assessNumericValue(assert, expectedBounds.x, displayRegion.position().left, 2, status + ' Left synchronization'); Util.assessNumericValue(assert, expectedBounds.x, displayRegion.position().left, 2, status + ' Left synchronization');
Util.assessNumericValue(assert, expectedBounds.y, displayRegion.position().top, 2, status + ' Top synchronization'); Util.assessNumericValue(assert, expectedBounds.y, displayRegion.position().top, 2, status + ' Top synchronization');
}; };
var waitForViewer(assert, = function (assert) { var waitForViewer = function () {
return function (handler, count, lastDisplayRegionLeft, lastDisplayWidth) { return function (assert, handler, count, lastDisplayRegionLeft, lastDisplayWidth) {
var viewerAndNavigatorDisplayReady = false, var viewerAndNavigatorDisplayReady = false,
currentDisplayRegionLeft, currentDisplayRegionLeft,
currentDisplayWidth; currentDisplayWidth;
@ -151,17 +177,20 @@
Util.equalsWithVariance(assert, viewer.viewport.getBounds(true).width, viewer.viewport.getBounds().width, 0.0001); Util.equalsWithVariance(assert, viewer.viewport.getBounds(true).width, viewer.viewport.getBounds().width, 0.0001);
} }
catch (err) { catch (err) {
if(debug) {
console.log(err);
}
//Ignore. Subsequent code will try again shortly //Ignore. Subsequent code will try again shortly
} }
if (( !viewerAndNavigatorDisplayReady) && count < 50) { if (( !viewerAndNavigatorDisplayReady) && count < 200) {
count++; count++;
setTimeout(function () { setTimeout(function () {
waitForViewer(assert, (handler, count, currentDisplayRegionLeft, currentDisplayWidth); waitForViewer(assert, handler, count, currentDisplayRegionLeft, currentDisplayWidth);
}, 100); }, 50);
} }
else { else {
if (count === 40) { if (debug) {
console.log("waitForViewer(assert, :" + console.log("waitForViewer :" +
viewer.drawer + ":" + viewer.world.needsDraw() + ":" + viewer.drawer + ":" + viewer.world.needsDraw() + ":" +
viewerAndNavigatorDisplayReady + ":" + viewerAndNavigatorDisplayReady + ":" +
lastDisplayRegionLeft + ":" + currentDisplayRegionLeft + ":" + lastDisplayRegionLeft + ":" + currentDisplayRegionLeft + ":" +
@ -171,7 +200,9 @@
viewer.viewport.getBounds(true).width + ":" + viewer.viewport.getBounds().width + ":" + viewer.viewport.getBounds(true).width + ":" + viewer.viewport.getBounds().width + ":" +
count); count);
} }
handler(); if (handler) {
handler(assert);
}
} }
}; };
}(); }();
@ -200,7 +231,39 @@
.simulate('drag', event); .simulate('drag', event);
}; };
var assessViewerInCorner = function (assert, theContentCorner) { var dragNavigatorBackToCenter = function () {
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);
if (viewer.source.aspectRatio < 1) {
delta.y *= viewer.source.aspectRatio;
}
simulateNavigatorDrag(viewer.navigator, delta.x * displayRegionWidth, delta.y * displayRegionHeight);
};
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) {
return function () { return function () {
var expectedXCoordinate, expectedYCoordinate; var expectedXCoordinate, expectedYCoordinate;
if (theContentCorner === "TOPLEFT") { if (theContentCorner === "TOPLEFT") {
@ -220,22 +283,31 @@
expectedYCoordinate = 1 / viewer.source.aspectRatio - viewer.viewport.getBounds().height; expectedYCoordinate = 1 / viewer.source.aspectRatio - viewer.viewport.getBounds().height;
} }
if (viewer.viewport.getBounds().width < 1) { if (viewer.viewport.getBounds().width < 1) {
Util.assessNumericValue(assert, expectedXCoordinate, viewer.viewport.getBounds().x, 0.04, ' Viewer at ' + theContentCorner + ', x coord'); Util.assessNumericValue(
assert,
expectedXCoordinate,
viewer.viewport.getBounds().x,
0.04,
' Viewer at ' + theContentCorner + ', x coord'
);
} }
if (viewer.viewport.getBounds().height < 1 / viewer.source.aspectRatio) { if (viewer.viewport.getBounds().height < 1 / viewer.source.aspectRatio) {
Util.assessNumericValue(assert, expectedYCoordinate, viewer.viewport.getBounds().y, 0.04, ' Viewer at ' + theContentCorner + ', y coord'); Util.assessNumericValue(
assert,
expectedYCoordinate,
viewer.viewport.getBounds().y,
0.04,
' Viewer at ' + theContentCorner + ', y coord'
);
} }
}; };
}; };
var assessViewerInCenter = function (assert) { var assessNavigatorViewerPlacement = function (assert, seadragonProperties, testProperties) {
var yPositionVariance = 0.04; var done = assert.async();
if (viewer.source.aspectRatio < 1) {
yPositionVariance = yPositionVariance / viewer.source.aspectRatio; seadragonProperties.visibilityRatio = 1;
} viewer = OpenSeadragon(seadragonProperties);
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 clickOnNavigator = function (theContentCorner) { var clickOnNavigator = function (theContentCorner) {
return function () { return function () {
@ -261,48 +333,30 @@
}; };
}; };
var dragNavigatorBackToCenter = function () {
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);
if (viewer.source.aspectRatio < 1) {
delta.y = delta.y * viewer.source.aspectRatio;
}
simulateNavigatorDrag(viewer.navigator, delta.x * displayRegionWidth, delta.y * displayRegionHeight);
};
var resizeElement = function ($element, width, height) {
$element.width(width);
$element.height(height);
};
var assessNavigatorViewerPlacement = function (assert, seadragonProperties, testProperties) {
var done = assert.async();
var navigatorOperationScenarios = [ var navigatorOperationScenarios = [
{interactionOperation: clickOnNavigator("TOPRIGHT"), {interactionOperation: clickOnNavigator("TOPRIGHT"),
assessmentOperation:assessViewerInCorner(assert, "TOPRIGHT"), assessmentOperation: assessViewerInCorner("TOPRIGHT", assert),
assessmentMessage: "After click on navigator on top right"}, assessmentMessage: "After click on navigator on top right"},
{interactionOperation: dragNavigatorBackToCenter, {interactionOperation: dragNavigatorBackToCenter,
assessmentOperation:assessViewerInCenter(assert), assessmentOperation: assessViewerInCenter,
assessmentMessage: "After drag on navigator from top right"}, assessmentMessage: "After drag on navigator from top right"},
{interactionOperation: clickOnNavigator("BOTTOMLEFT"), {interactionOperation: clickOnNavigator("BOTTOMLEFT"),
assessmentOperation:assessViewerInCorner(assert, "BOTTOMLEFT"), assessmentOperation: assessViewerInCorner("BOTTOMLEFT", assert),
assessmentMessage: "After click on navigator on bottom left"}, assessmentMessage: "After click on navigator on bottom left"},
{interactionOperation: dragNavigatorBackToCenter, {interactionOperation: dragNavigatorBackToCenter,
assessmentOperation:assessViewerInCenter(assert), assessmentOperation: assessViewerInCenter,
assessmentMessage: "After drag on navigator from bottom left"}, assessmentMessage: "After drag on navigator from bottom left"},
{interactionOperation: clickOnNavigator("BOTTOMRIGHT"), {interactionOperation: clickOnNavigator("BOTTOMRIGHT"),
assessmentOperation:assessViewerInCorner(assert, "BOTTOMRIGHT"), assessmentOperation: assessViewerInCorner("BOTTOMRIGHT", assert),
assessmentMessage: "After click on navigator on bottom right"}, assessmentMessage: "After click on navigator on bottom right"},
{interactionOperation: dragNavigatorBackToCenter, {interactionOperation: dragNavigatorBackToCenter,
assessmentOperation:assessViewerInCenter(assert), assessmentOperation: assessViewerInCenter,
assessmentMessage: "After drag on navigator from bottom right"}, assessmentMessage: "After drag on navigator from bottom right"},
{interactionOperation: clickOnNavigator("TOPLEFT"), {interactionOperation: clickOnNavigator("TOPLEFT"),
assessmentOperation:assessViewerInCorner(assert, "TOPLEFT"), assessmentOperation: assessViewerInCorner("TOPLEFT", assert),
assessmentMessage: "After click on navigator on top left"}, assessmentMessage: "After click on navigator on top left"},
{interactionOperation: dragNavigatorBackToCenter, {interactionOperation: dragNavigatorBackToCenter,
assessmentOperation:assessViewerInCenter(assert), assessmentOperation: assessViewerInCenter,
assessmentMessage: "After drag on navigator from top left"} assessmentMessage: "After drag on navigator from top left"}
], ],
viewerResizeScenarios = [ viewerResizeScenarios = [
@ -321,9 +375,6 @@
viewerOriginalSize = null, viewerOriginalSize = null,
navigatorOriginalSize = null; navigatorOriginalSize = null;
seadragonProperties.visibilityRatio = 1;
viewer = OpenSeadragon(seadragonProperties);
if ($.isNumeric(testProperties.topNavigatorClickAdjustment)) if ($.isNumeric(testProperties.topNavigatorClickAdjustment))
{ {
topNavigatorClickAdjustment = testProperties.topNavigatorClickAdjustment; topNavigatorClickAdjustment = testProperties.topNavigatorClickAdjustment;
@ -333,82 +384,112 @@
return function () { return function () {
var nextStep = step + 1; var nextStep = step + 1;
assessDisplayRegion(assert, navigatorOperationScenarios[step].assessmentMessage); assessDisplayRegion(assert, navigatorOperationScenarios[step].assessmentMessage);
navigatorOperationScenarios[step].assessmentOperation(); navigatorOperationScenarios[step].assessmentOperation(assert);
if (step === navigatorOperationScenarios.length - 1) { if (step === navigatorOperationScenarios.length - 1) {
done(); done();
} }
else { else {
navigatorOperationScenarios[nextStep].interactionOperation(); navigatorOperationScenarios[nextStep].interactionOperation();
waitForViewer(assert, (assessNavigatorOperationAndTakeNextStep(nextStep)); waitForViewer(assert, assessNavigatorOperationAndTakeNextStep(nextStep));
} }
}; };
}; };
var assessAfterSnapback = function (assert) { var assessAfterSnapback = function () {
assessDisplayRegion(assert, "After snapback"); assessDisplayRegion(assert, "After snapback");
navigatorOperationScenarios[0].interactionOperation(); navigatorOperationScenarios[0].interactionOperation();
waitForViewer(assert, (assessNavigatorOperationAndTakeNextStep(0)); waitForViewer(assert, assessNavigatorOperationAndTakeNextStep(0));
}; };
var assessAfterDragOnViewer = function (assert) { var assessAfterDragOnViewer = function () {
assessDisplayRegion(assert, "After pan"); assessDisplayRegion(assert, "After pan");
viewer.viewport.applyConstraints(); viewer.viewport.applyConstraints();
waitForViewer(assert, assessAfterSnapback(assert)); waitForViewer(assert, assessAfterSnapback);
}; };
var assessAfterZoomOnViewer = function (assert) { var assessAfterZoomOnViewer = function () {
var target = new OpenSeadragon.Point(0.4, 0.4); var target = new OpenSeadragon.Point(0.4, 0.4);
assessDisplayRegion(assert, "After image zoom"); assessDisplayRegion(assert, "After image zoom");
viewer.viewport.panTo(target); viewer.viewport.panTo(target);
waitForViewer(assert, (assessAfterDragOnViewer(assert)); waitForViewer(assert, assessAfterDragOnViewer);
}; };
var assessAfterResizeNavigator = function (assert) { var assessAfterResizeNavigator = function () {
viewer.viewport.zoomTo(viewer.viewport.getZoom() * 2); viewer.viewport.zoomTo(viewer.viewport.getZoom() * 2);
waitForViewer(assert, (assessAfterZoomOnViewer(assert)); waitForViewer(assert, assessAfterZoomOnViewer);
}; };
var assessNavigatorResizeAndTakeNextStep = function (assert, step) { var assessNavigatorResizeAndTakeNextStep = function (step) {
return function () { return function () {
var nextStep = step + 1; var nextStep = step + 1;
assessNavigatorSize(assert, navigatorOriginalSize.x * navigatorResizeScenarios[step].resizeFactorX, navigatorOriginalSize.y * navigatorResizeScenarios[step].resizeFactorY, navigatorResizeScenarios[step].assessmentMessage); assessNavigatorSize(assert, navigatorOriginalSize.x * navigatorResizeScenarios[step].resizeFactorX, navigatorOriginalSize.y * navigatorResizeScenarios[step].resizeFactorY, navigatorResizeScenarios[step].assessmentMessage);
assessDisplayRegion(assert, navigatorResizeScenarios[step].assessmentMessage); assessDisplayRegion(assert, navigatorResizeScenarios[step].assessmentMessage);
if (step === viewerResizeScenarios.length - 1) { if (step === viewerResizeScenarios.length - 1) {
assessAfterResizeNavigator(assert); assessAfterResizeNavigator();
} }
else { else {
resizeElement(navigatorElement, navigatorOriginalSize.x * navigatorResizeScenarios[nextStep].resizeFactorX, navigatorOriginalSize.y * navigatorResizeScenarios[nextStep].resizeFactorY); resizeElement(navigatorElement, navigatorOriginalSize.x * navigatorResizeScenarios[nextStep].resizeFactorX, navigatorOriginalSize.y * navigatorResizeScenarios[nextStep].resizeFactorY);
waitForViewer(assert, (assessNavigatorResizeAndTakeNextStep(assert, nextStep)); waitForViewer(assert, assessNavigatorResizeAndTakeNextStep(nextStep));
} }
}; };
}; };
var assessViewerResizeAndTakeNextStep = function (assert, step) { var assessViewerResizeAndTakeNextStep = function (step) {
return function () { return function () {
var nextStep = step + 1; var nextStep = step + 1;
if (seadragonProperties.navigatorId) { if (seadragonProperties.navigatorId) {
// Navigator hosted in outside element...size shouldn't change // Navigator hosted in outside element...size shouldn't change
assessNavigatorSize(assert, navigatorOriginalSize.x, navigatorOriginalSize.y, viewerResizeScenarios[step].assessmentMessage); assessNavigatorSize(
assert,
navigatorOriginalSize.x,
navigatorOriginalSize.y,
viewerResizeScenarios[step].assessmentMessage
);
} }
else { else {
// Navigator hosted in viewer // Navigator hosted in viewer
if (seadragonProperties.navigatorPosition && seadragonProperties.navigatorPosition == 'ABSOLUTE') { if (seadragonProperties.navigatorPosition && seadragonProperties.navigatorPosition == 'ABSOLUTE') {
// Navigator positioned 'ABSOLUTE'...size shouldn't change // Navigator positioned 'ABSOLUTE'...size shouldn't change
assessNavigatorSize(assert, navigatorOriginalSize.x, navigatorOriginalSize.y, viewerResizeScenarios[step].assessmentMessage);
assessNavigatorSize(
assert,
navigatorOriginalSize.x,
navigatorOriginalSize.y,
viewerResizeScenarios[step].assessmentMessage
);
} }
else { else {
// Navigator positioned 'TOP_LEFT', 'TOP_RIGHT', 'BOTTOM_LEFT', or 'BOTTOM_RIGHT' // Navigator positioned 'TOP_LEFT', 'TOP_RIGHT', 'BOTTOM_LEFT', or 'BOTTOM_RIGHT'
if (seadragonProperties.navigatorMaintainSizeRatio) { if (seadragonProperties.navigatorMaintainSizeRatio) {
// Navigator should maintain aspect ratio and size proportioned to viewer size // Navigator should maintain aspect ratio and size proportioned to viewer size
assessNavigatorAspectRatio(assert, viewerElement.width() / viewerElement.height(), 0.0001, viewerResizeScenarios[step].assessmentMessage); assessNavigatorAspectRatio(
assessNavigatorSize(assert, viewerElement.width() * seadragonProperties.navigatorSizeRatio, viewerElement.height() * seadragonProperties.navigatorSizeRatio, viewerResizeScenarios[step].assessmentMessage); assert,
viewerElement.width() / viewerElement.height(),
0.0001,
viewerResizeScenarios[step].assessmentMessage
);
assessNavigatorSize(
assert,
viewerElement.width() * seadragonProperties.navigatorSizeRatio,
viewerElement.height() * seadragonProperties.navigatorSizeRatio,
viewerResizeScenarios[step].assessmentMessage
);
} }
else { else {
// Navigator should maintain aspect ratio and area // Navigator should maintain aspect ratio and area
// Variances are loosened up here, since 1 pixel rounding difference in resizing to maintain 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. // can cause a relatively large difference in area and aspect ratio.
assessNavigatorAspectRatio(assert, viewerElement.width() / viewerElement.height(), 0.1, viewerResizeScenarios[step].assessmentMessage); assessNavigatorAspectRatio(
assessNavigatorArea(assert, navigatorOriginalSize.x * navigatorOriginalSize.y, viewerResizeScenarios[step].assessmentMessage); assert,
viewerElement.width() / viewerElement.height(),
0.1,
viewerResizeScenarios[step].assessmentMessage
);
assessNavigatorArea(
assert,
navigatorOriginalSize.x * navigatorOriginalSize.y,
viewerResizeScenarios[step].assessmentMessage
);
} }
} }
} }
@ -417,49 +498,50 @@
if (seadragonProperties.navigatorId) { if (seadragonProperties.navigatorId) {
// Navigator hosted in outside element...run navigator resize tests // Navigator hosted in outside element...run navigator resize tests
resizeElement(navigatorElement, navigatorOriginalSize.x * navigatorResizeScenarios[0].resizeFactorX, navigatorOriginalSize.y * navigatorResizeScenarios[0].resizeFactorY); resizeElement(navigatorElement, navigatorOriginalSize.x * navigatorResizeScenarios[0].resizeFactorX, navigatorOriginalSize.y * navigatorResizeScenarios[0].resizeFactorY);
waitForViewer(assert, (assessNavigatorResizeAndTakeNextStep(assert, 0)); waitForViewer(assert, assessNavigatorResizeAndTakeNextStep(0));
} }
else { else {
// Navigator hosted in viewer...skip navigator resize tests // Navigator hosted in viewer...skip navigator resize tests
assessAfterResizeNavigator(assert); assessAfterResizeNavigator();
} }
} }
else { else {
resizeElement(viewerElement, viewerOriginalSize.x * viewerResizeScenarios[nextStep].resizeFactorX, viewerOriginalSize.y * viewerResizeScenarios[nextStep].resizeFactorY); resizeElement(viewerElement, viewerOriginalSize.x * viewerResizeScenarios[nextStep].resizeFactorX, viewerOriginalSize.y * viewerResizeScenarios[nextStep].resizeFactorY);
waitForViewer(assert, (assessViewerResizeAndTakeNextStep(assert, (nextStep)); waitForViewer(assert, assessViewerResizeAndTakeNextStep(nextStep));
} }
}; };
}; };
var captureInitialStateThenAct = function () { var captureInitialStateThenAct = function () {
assessDisplayRegion(assert, "After image load"); assessDisplayRegion(assert, "After image load");
testProperties.determineExpectationsAndAssessNavigatorLocation(assert, seadragonProperties, testProperties);
testProperties.determineExpectationsAndAssessNavigatorLocation(seadragonProperties, testProperties);
viewerOriginalSize = new OpenSeadragon.Point(viewerElement.width(), viewerElement.height()); viewerOriginalSize = new OpenSeadragon.Point(viewerElement.width(), viewerElement.height());
navigatorOriginalSize = new OpenSeadragon.Point(navigatorElement.width(), navigatorElement.height()); navigatorOriginalSize = new OpenSeadragon.Point(navigatorElement.width(), navigatorElement.height());
resizeElement(viewerElement, viewerOriginalSize.x * viewerResizeScenarios[0].resizeFactorX, viewerOriginalSize.y * viewerResizeScenarios[0].resizeFactorY); resizeElement(viewerElement, viewerOriginalSize.x * viewerResizeScenarios[0].resizeFactorX, viewerOriginalSize.y * viewerResizeScenarios[0].resizeFactorY);
waitForViewer(assert, (assessViewerResizeAndTakeNextStep(assert, (0));
waitForViewer(assert, assessViewerResizeAndTakeNextStep(0));
}; };
var assessAutoFadeTriggered = function () { var assessAutoFadeTriggered = function () {
assert.ok(navigatorElement.parent().css("opacity") < 1, "Expecting navigator to be autofade when in the default location"); assert.ok(navigatorElement.parent().css("opacity") < 1, "Expecting navigator to be autofade when in the default location");
waitForViewer(assert, (captureInitialStateThenAct); waitForViewer(assert, captureInitialStateThenAct());
}; };
var assessAutoFadeDisabled = function () { var assessAutoFadeDisabled = function () {
assert.ok(navigatorElement.parent().css("opacity") > 0, "Expecting navigator to be always visible when in a custom location"); assert.ok(navigatorElement.parent().css("opacity") > 0, "Expecting navigator to be always visible when in a custom location");
waitForViewer(assert, (captureInitialStateThenAct); waitForViewer(assert, captureInitialStateThenAct());
}; };
var openHandler = function () { var openHandler = function () {
viewer.removeHandler('open', openHandler); viewer.removeHandler('open', openHandler);
navigatorElement = $(testProperties.navigatorLocator); navigatorElement = navigatorElement || $(testProperties.navigatorLocator);
viewerElement = $("#" + seadragonProperties.id); viewerElement = $("#" + seadragonProperties.id);
displayRegion = displayRegion || $(testProperties.displayRegionLocator);
//TODO This should be testProperties.testAutoFade, but test hangs. Fix this! //TODO This should be testProperties.testAutoFade, but test hangs. Fix this!
if (!testProperties.testAutohide) { if (!testProperties.testAutohide) {
waitForViewer(assert, (captureInitialStateThenAct); waitForViewer(assert, captureInitialStateThenAct());
} }
else { else {
assert.ok(navigatorElement.parent().css("opacity") > 0, "Expecting navigator to be visible initially"); assert.ok(navigatorElement.parent().css("opacity") > 0, "Expecting navigator to be visible initially");
@ -494,12 +576,19 @@
displayRegionLocator: '.navigator .displayregion', displayRegionLocator: '.navigator .displayregion',
navigatorLocator: '.navigator', navigatorLocator: '.navigator',
testAutoFade: false, testAutoFade: false,
determineExpectationsAndAssessNavigatorLocation:function (seadragonProperties, testProperties) { determineExpectationsAndAssessNavigatorLocation: function (assert, seadragonProperties, testProperties) {
var mainViewerElement = $("#" + seadragonProperties.id), var mainViewerElement = $("#" + seadragonProperties.id);
navigatorElement = $(testProperties.navigatorLocator); navigatorElement = navigatorElement || $(testProperties.navigatorLocator);
assessNavigatorLocation(assert, mainViewerElement.offset().left + mainViewerElement.width() - navigatorElement.width(), assessNavigatorLocation(
mainViewerElement.offset().top); assert,
assessNavigatorSize(assert, mainViewerElement.width() * seadragonProperties.navigatorSizeRatio, mainViewerElement.height() * seadragonProperties.navigatorSizeRatio); mainViewerElement.offset().left + mainViewerElement.width() - navigatorElement.width(),
mainViewerElement.offset().top
);
assessNavigatorSize(
assert,
mainViewerElement.width() * seadragonProperties.navigatorSizeRatio,
mainViewerElement.height() * seadragonProperties.navigatorSizeRatio
);
assessNavigatorAspectRatio(assert, mainViewerElement.width() / mainViewerElement.height(), 0.0001); assessNavigatorAspectRatio(assert, mainViewerElement.width() / mainViewerElement.height(), 0.0001);
} }
}); });
@ -522,9 +611,9 @@
navigatorLocator: '.navigator', navigatorLocator: '.navigator',
testAutoFade: true, testAutoFade: true,
expectedAutoFade: true, expectedAutoFade: true,
determineExpectationsAndAssessNavigatorLocation:function (seadragonProperties, testProperties) { determineExpectationsAndAssessNavigatorLocation: function (assert, seadragonProperties, testProperties) {
var mainViewerElement = $("#" + seadragonProperties.id), var mainViewerElement = $("#" + seadragonProperties.id);
navigatorElement = $(testProperties.navigatorLocator); navigatorElement = navigatorElement || $(testProperties.navigatorLocator);
assessNavigatorLocation(assert, mainViewerElement.offset().left + mainViewerElement.width() - navigatorElement.width(), assessNavigatorLocation(assert, mainViewerElement.offset().left + mainViewerElement.width() - navigatorElement.width(),
mainViewerElement.offset().top); mainViewerElement.offset().top);
assessNavigatorSize(assert, mainViewerElement.width() * seadragonProperties.navigatorSizeRatio, mainViewerElement.height() * seadragonProperties.navigatorSizeRatio); assessNavigatorSize(assert, mainViewerElement.width() * seadragonProperties.navigatorSizeRatio, mainViewerElement.height() * seadragonProperties.navigatorSizeRatio);
@ -552,9 +641,8 @@
navigatorLocator: '.navigator', navigatorLocator: '.navigator',
testAutoFade: true, testAutoFade: true,
expectedAutoFade: true, expectedAutoFade: true,
determineExpectationsAndAssessNavigatorLocation:function (seadragonProperties, testProperties) { determineExpectationsAndAssessNavigatorLocation: function (assert, seadragonProperties, testProperties) {
var mainViewerElement = $("#" + seadragonProperties.id), var mainViewerElement = $("#" + seadragonProperties.id);
navigatorElement = $(testProperties.navigatorLocator);
assessNavigatorLocation(assert, mainViewerElement.offset().left, assessNavigatorLocation(assert, mainViewerElement.offset().left,
mainViewerElement.offset().top); mainViewerElement.offset().top);
assessNavigatorSize(assert, mainViewerElement.width() * seadragonProperties.navigatorSizeRatio, mainViewerElement.height() * seadragonProperties.navigatorSizeRatio); assessNavigatorSize(assert, mainViewerElement.width() * seadragonProperties.navigatorSizeRatio, mainViewerElement.height() * seadragonProperties.navigatorSizeRatio);
@ -582,9 +670,9 @@
navigatorLocator: '.navigator', navigatorLocator: '.navigator',
testAutoFade: true, testAutoFade: true,
expectedAutoFade: true, expectedAutoFade: true,
determineExpectationsAndAssessNavigatorLocation:function (seadragonProperties, testProperties) { determineExpectationsAndAssessNavigatorLocation: function (assert, seadragonProperties, testProperties) {
var mainViewerElement = $("#" + seadragonProperties.id), var mainViewerElement = $("#" + seadragonProperties.id);
navigatorElement = $(testProperties.navigatorLocator); navigatorElement = navigatorElement || $(testProperties.navigatorLocator);
assessNavigatorLocation(assert, mainViewerElement.offset().left + mainViewerElement.width() - navigatorElement.width(), assessNavigatorLocation(assert, mainViewerElement.offset().left + mainViewerElement.width() - navigatorElement.width(),
mainViewerElement.offset().top); mainViewerElement.offset().top);
assessNavigatorSize(assert, mainViewerElement.width() * seadragonProperties.navigatorSizeRatio, mainViewerElement.height() * seadragonProperties.navigatorSizeRatio); assessNavigatorSize(assert, mainViewerElement.width() * seadragonProperties.navigatorSizeRatio, mainViewerElement.height() * seadragonProperties.navigatorSizeRatio);
@ -612,9 +700,9 @@
navigatorLocator: '.navigator', navigatorLocator: '.navigator',
testAutoFade: true, testAutoFade: true,
expectedAutoFade: true, expectedAutoFade: true,
determineExpectationsAndAssessNavigatorLocation:function (seadragonProperties, testProperties) { determineExpectationsAndAssessNavigatorLocation: function (assert, seadragonProperties, testProperties) {
var mainViewerElement = $("#" + seadragonProperties.id), var mainViewerElement = $("#" + seadragonProperties.id);
navigatorElement = $(testProperties.navigatorLocator); navigatorElement = navigatorElement || $(testProperties.navigatorLocator);
assessNavigatorLocation(assert, mainViewerElement.offset().left, assessNavigatorLocation(assert, mainViewerElement.offset().left,
mainViewerElement.offset().top + mainViewerElement.height() - navigatorElement.height()); mainViewerElement.offset().top + mainViewerElement.height() - navigatorElement.height());
assessNavigatorSize(assert, mainViewerElement.width() * seadragonProperties.navigatorSizeRatio, mainViewerElement.height() * seadragonProperties.navigatorSizeRatio); assessNavigatorSize(assert, mainViewerElement.width() * seadragonProperties.navigatorSizeRatio, mainViewerElement.height() * seadragonProperties.navigatorSizeRatio);
@ -642,9 +730,9 @@
navigatorLocator: '.navigator', navigatorLocator: '.navigator',
testAutoFade: true, testAutoFade: true,
expectedAutoFade: true, expectedAutoFade: true,
determineExpectationsAndAssessNavigatorLocation:function (seadragonProperties, testProperties) { determineExpectationsAndAssessNavigatorLocation: function (assert, seadragonProperties, testProperties) {
var mainViewerElement = $("#" + seadragonProperties.id), var mainViewerElement = $("#" + seadragonProperties.id);
navigatorElement = $(testProperties.navigatorLocator); navigatorElement = navigatorElement || $(testProperties.navigatorLocator);
assessNavigatorLocation(assert, mainViewerElement.offset().left + mainViewerElement.width() - navigatorElement.width(), assessNavigatorLocation(assert, mainViewerElement.offset().left + mainViewerElement.width() - navigatorElement.width(),
mainViewerElement.offset().top + mainViewerElement.height() - navigatorElement.height()); mainViewerElement.offset().top + mainViewerElement.height() - navigatorElement.height());
assessNavigatorSize(assert, mainViewerElement.width() * seadragonProperties.navigatorSizeRatio, mainViewerElement.height() * seadragonProperties.navigatorSizeRatio); assessNavigatorSize(assert, mainViewerElement.width() * seadragonProperties.navigatorSizeRatio, mainViewerElement.height() * seadragonProperties.navigatorSizeRatio);
@ -674,9 +762,8 @@
navigatorLocator: '.navigator', navigatorLocator: '.navigator',
testAutoFade: true, testAutoFade: true,
expectedAutoFade: true, expectedAutoFade: true,
determineExpectationsAndAssessNavigatorLocation:function (seadragonProperties, testProperties) { determineExpectationsAndAssessNavigatorLocation: function (assert, seadragonProperties, testProperties) {
var mainViewerElement = $("#" + seadragonProperties.id), var mainViewerElement = $("#" + seadragonProperties.id);
navigatorElement = $(testProperties.navigatorLocator);
assessNavigatorLocation(assert, mainViewerElement.offset().left + seadragonProperties.navigatorLeft, assessNavigatorLocation(assert, mainViewerElement.offset().left + seadragonProperties.navigatorLeft,
mainViewerElement.offset().top + seadragonProperties.navigatorTop); mainViewerElement.offset().top + seadragonProperties.navigatorTop);
assessNavigatorSize(assert, seadragonProperties.navigatorWidth, seadragonProperties.navigatorHeight); assessNavigatorSize(assert, seadragonProperties.navigatorWidth, seadragonProperties.navigatorHeight);
@ -697,7 +784,7 @@
displayRegionLocator: '#exampleNavigator .displayregion', displayRegionLocator: '#exampleNavigator .displayregion',
navigatorLocator: '#exampleNavigator', navigatorLocator: '#exampleNavigator',
testAutoFade: false, testAutoFade: false,
determineExpectationsAndAssessNavigatorLocation:function (seadragonProperties, testProperties) { determineExpectationsAndAssessNavigatorLocation: function (assert, seadragonProperties, testProperties) {
var mainViewerElement = $("#" + seadragonProperties.id), var mainViewerElement = $("#" + seadragonProperties.id),
navigatorViewerElement = $("#" + seadragonProperties.navigatorId); navigatorViewerElement = $("#" + seadragonProperties.navigatorId);
assessNavigatorLocation(assert, mainViewerElement.offset().left, assessNavigatorLocation(assert, mainViewerElement.offset().left,
@ -739,7 +826,7 @@
//On Firefox at some screen size/resolution/magnification combinations, there is an issue with the //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 //simulated click. This property is a work around for that problem
topNavigatorClickAdjustment: 15, topNavigatorClickAdjustment: 15,
determineExpectationsAndAssessNavigatorLocation:function (seadragonProperties, testProperties) { determineExpectationsAndAssessNavigatorLocation: function (assert, seadragonProperties, testProperties) {
var jqueryDialog = $(testProperties.navigatorLocator); var jqueryDialog = $(testProperties.navigatorLocator);
assessNavigatorLocation(assert, jqueryDialog.offset().left, assessNavigatorLocation(assert, jqueryDialog.offset().left,
jqueryDialog.offset().top); jqueryDialog.offset().top);
@ -749,8 +836,7 @@
}); });
QUnit.test('Viewer closing one image and opening another', function(assert) { QUnit.test('Viewer closing one image and opening another', function(assert) {
var done = assert.async(); var timeWatcher = Util.timeWatcher(assert);
var timeWatcher = Util.timeWatcher();
viewer = OpenSeadragon({ viewer = OpenSeadragon({
id: 'example', id: 'example',
@ -760,10 +846,30 @@
showNavigator: true showNavigator: true
}); });
var openHandler1 = function(event) { var closeHandler1 = function(event) {
viewer.removeHandler('open', openHandler1); viewer.removeHandler('close', closeHandler1);
assert.ok(viewer.navigator, 'navigator exists'); assert.ok(true, 'calling open closes the old one');
viewer.navigator.world.addHandler('add-item', navOpenHandler1); assert.equal(viewer.navigator.source, null, 'navigator source has been cleared');
};
var closeHandler2 = function(event) {
viewer.removeHandler('close', closeHandler2);
setTimeout(function() {
assert.ok(!viewer.navigator._updateRequestId, 'navigator timer is off');
timeWatcher.done();
}, 100);
};
var navOpenHandler2 = function(event) {
viewer.navigator.world.removeHandler('add-item', navOpenHandler2);
assert.equal(viewer.navigator.source, viewer.source, 'viewer and navigator have the same source');
viewer.addHandler('close', closeHandler2);
viewer.close();
};
var openHandler2 = function(event) {
viewer.removeHandler('open', openHandler2);
viewer.navigator.world.addHandler('add-item', navOpenHandler2);
}; };
var navOpenHandler1 = function(event) { var navOpenHandler1 = function(event) {
@ -775,30 +881,10 @@
viewer.open('/test/data/tall.dzi'); viewer.open('/test/data/tall.dzi');
}; };
var closeHandler1 = function(event) { var openHandler1 = function(event) {
viewer.removeHandler('close', closeHandler1); viewer.removeHandler('open', openHandler1);
assert.ok(true, 'calling open closes the old one'); assert.ok(viewer.navigator, 'navigator exists');
assert.equal(viewer.navigator.source, null, 'navigator source has been cleared'); viewer.navigator.world.addHandler('add-item', navOpenHandler1);
};
var openHandler2 = function(event) {
viewer.removeHandler('open', openHandler2);
viewer.navigator.world.addHandler('add-item', navOpenHandler2);
};
var navOpenHandler2 = function(event) {
viewer.navigator.world.removeHandler('add-item', navOpenHandler2);
assert.equal(viewer.navigator.source, viewer.source, 'viewer and navigator have the same source');
viewer.addHandler('close', closeHandler2);
viewer.close();
};
var closeHandler2 = function(event) {
viewer.removeHandler('close', closeHandler2);
setTimeout(function() {
assert.ok(!viewer.navigator._updateRequestId, 'navigator timer is off');
timeWatcher.done();
}, 100);
}; };
viewer.addHandler('open', openHandler1); viewer.addHandler('open', openHandler1);
@ -816,13 +902,6 @@
collectionMode: true collectionMode: true
}); });
var openHandler = function() {
viewer.removeHandler('open', openHandler);
viewer.navigator.world.addHandler('add-item', navOpenHandler);
// The navigator may already have added the items.
navOpenHandler();
};
var navOpenHandler = function(event) { var navOpenHandler = function(event) {
if (viewer.navigator.world.getItemCount() === 2) { if (viewer.navigator.world.getItemCount() === 2) {
viewer.navigator.world.removeHandler('add-item', navOpenHandler); viewer.navigator.world.removeHandler('add-item', navOpenHandler);
@ -830,13 +909,13 @@
setTimeout(function() { setTimeout(function() {
// Test initial formation // Test initial formation
for (var i = 0; i < 2; i++) { for (var i = 0; i < 2; i++) {
propEqual(viewer.navigator.world.getItemAt(i).getBounds(), assert.propEqual(viewer.navigator.world.getItemAt(i).getBounds(),
viewer.world.getItemAt(i).getBounds(), 'bounds are the same'); viewer.world.getItemAt(i).getBounds(), 'bounds are the same');
} }
// Try moving one // Try moving one
viewer.world.getItemAt(0).setPosition(new OpenSeadragon.Point(-200, -200)); viewer.world.getItemAt(0).setPosition(new OpenSeadragon.Point(-200, -200));
propEqual(viewer.navigator.world.getItemAt(0).getBounds(), assert.propEqual(viewer.navigator.world.getItemAt(0).getBounds(),
viewer.world.getItemAt(0).getBounds(), 'bounds are the same after move'); viewer.world.getItemAt(0).getBounds(), 'bounds are the same after move');
done(); done();
@ -844,6 +923,13 @@
} }
}; };
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); viewer.addHandler('open', openHandler);
}); });
@ -930,7 +1016,7 @@
}); });
QUnit.test('Viewer options transmitted to navigator', function(assert) { QUnit.test('Viewer options transmitted to navigator', function(assert) {
var done = assert.async();a var done = assert.async();
viewer = OpenSeadragon({ viewer = OpenSeadragon({
id: 'example', id: 'example',
prefixUrl: '/build/openseadragon/images/', prefixUrl: '/build/openseadragon/images/',
@ -943,11 +1029,9 @@
viewer.addHandler('open', function openHandler() { viewer.addHandler('open', function openHandler() {
viewer.removeHandler('open', openHandler); viewer.removeHandler('open', openHandler);
var navigator = viewer.navigator; assert.equal(viewer.navigator.prefixUrl, viewer.prefixUrl,
assert.equal(navigator.prefixUrl, viewer.prefixUrl,
"Prefix URL should be transmitted to the navigator."); "Prefix URL should be transmitted to the navigator.");
assert.equal(navigator.crossOriginPolicy, viewer.crossOriginPolicy, assert.equal(viewer.navigator.crossOriginPolicy, viewer.crossOriginPolicy,
"Cross origin policy should be transmitted to the navigator."); "Cross origin policy should be transmitted to the navigator.");
done(); done();
}); });
@ -967,13 +1051,11 @@
viewer.addHandler('open', function openHandler() { viewer.addHandler('open', function openHandler() {
viewer.removeHandler('open', openHandler); viewer.removeHandler('open', openHandler);
var navigator = viewer.navigator; assert.equal(viewer.navigator.viewport.getRotation(), 45,
assert.equal(navigator.viewport.getRotation(), 45,
"Rotation set in constructor should be applied to navigator by default."); "Rotation set in constructor should be applied to navigator by default.");
viewer.viewport.setRotation(90); viewer.viewport.setRotation(90);
assert.equal(navigator.viewport.getRotation(), 90, assert.equal(viewer.navigator.viewport.getRotation(), 90,
"Rotation set by setRotation should be applied to navigator by default."); "Rotation set by setRotation should be applied to navigator by default.");
done(); done();
@ -994,13 +1076,11 @@
viewer.addHandler('open', function openHandler() { viewer.addHandler('open', function openHandler() {
viewer.removeHandler('open', openHandler); viewer.removeHandler('open', openHandler);
var navigator = viewer.navigator; assert.equal(viewer.navigator.viewport.getRotation(), 0,
assert.equal(navigator.viewport.getRotation(), 0,
"Rotation set in constructor should not be applied to navigator when navigatorRotate is false."); "Rotation set in constructor should not be applied to navigator when navigatorRotate is false.");
viewer.viewport.setRotation(90); viewer.viewport.setRotation(90);
assert.equal(navigator.viewport.getRotation(), 0, assert.equal(viewer.navigator.viewport.getRotation(), 0,
"Rotation set by setRotation should not be applied to navigator when navigatorRotate is false."); "Rotation set by setRotation should not be applied to navigator when navigatorRotate is false.");
done(); done();

View File

@ -45,7 +45,7 @@
<script src="/test/modules/ajax-tiles.js"></script> <script src="/test/modules/ajax-tiles.js"></script>
<script src="/test/modules/imageloader.js"></script> <script src="/test/modules/imageloader.js"></script>
<!--The navigator tests are the slowest (for now; hopefully they can be sped up) <!--The navigator tests are the slowest (for now; hopefully they can be sped up)
so we put them last. so we put them last. -->
<script src="/test/modules/navigator.js"></script> --> <script src="/test/modules/navigator.js"></script>
</body> </body>
</html> </html>