mirror of
https://github.com/openseadragon/openseadragon.git
synced 2024-11-22 13:16:10 +03:00
Navigator tests
This commit is contained in:
parent
6f789e7e88
commit
b8a28ce838
@ -1,4 +1,4 @@
|
|||||||
/* global QUnit, module, Util, $, console, test, asyncTest, start, ok, equal, propEqual */
|
/* global QUnit, module, Util, $, console, propEqual */
|
||||||
|
|
||||||
(function () {
|
(function () {
|
||||||
var debug = false,
|
var debug = false,
|
||||||
@ -12,14 +12,14 @@
|
|||||||
displayRegionHeight,
|
displayRegionHeight,
|
||||||
topNavigatorClickAdjustment;
|
topNavigatorClickAdjustment;
|
||||||
|
|
||||||
module("navigator", {
|
QUnit.module("navigator", {
|
||||||
setup: function () {
|
beforeEach: function () {
|
||||||
Util.initializeTestDOM();
|
Util.initializeTestDOM();
|
||||||
resetTestVariables();
|
resetTestVariables();
|
||||||
$(document).scrollTop(0);
|
$(document).scrollTop(0);
|
||||||
$(document).scrollLeft(0);
|
$(document).scrollLeft(0);
|
||||||
},
|
},
|
||||||
teardown: function () {
|
afterEach: function () {
|
||||||
// jQuery UI creates its controls outside the normal DOM hierarchy which QUnit cleans up:
|
// jQuery UI creates its controls outside the normal DOM hierarchy which QUnit cleans up:
|
||||||
if ($('#exampleNavigator').is(':ui-dialog')) {
|
if ($('#exampleNavigator').is(':ui-dialog')) {
|
||||||
$('#exampleNavigator').dialog('destroy');
|
$('#exampleNavigator').dialog('destroy');
|
||||||
@ -43,30 +43,30 @@
|
|||||||
topNavigatorClickAdjustment = 0;
|
topNavigatorClickAdjustment = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
var assessNavigatorLocation = function (expectedX, expectedY) {
|
var assessNavigatorLocation = function (assert, expectedX, expectedY) {
|
||||||
var navigator = $(".navigator");
|
var navigator = $(".navigator");
|
||||||
|
|
||||||
Util.assessNumericValue(expectedX, navigator.offset().left, 10, ' Navigator x Position');
|
Util.assessNumericValue(assert, expectedX, navigator.offset().left, 10, ' Navigator x Position');
|
||||||
Util.assessNumericValue(expectedY, navigator.offset().top, 10, ' Navigator y Position');
|
Util.assessNumericValue(assert, expectedY, navigator.offset().top, 10, ' Navigator y Position');
|
||||||
};
|
};
|
||||||
|
|
||||||
var assessNavigatorSize = function (expectedWidth, expectedHeight, msg) {
|
var assessNavigatorSize = function (assert, expectedWidth, expectedHeight, msg) {
|
||||||
var navigator = $(".navigator");
|
var navigator = $(".navigator");
|
||||||
|
|
||||||
Util.assessNumericValue(expectedWidth, navigator.width(), 2, ' Navigator Width ' + (msg ? msg : ''));
|
Util.assessNumericValue(assert, expectedWidth, navigator.width(), 2, ' Navigator Width ' + (msg ? msg : ''));
|
||||||
Util.assessNumericValue(expectedHeight, navigator.height(), 2, ' Navigator Height ' + (msg ? msg : ''));
|
Util.assessNumericValue(assert, expectedHeight, navigator.height(), 2, ' Navigator Height ' + (msg ? msg : ''));
|
||||||
};
|
};
|
||||||
|
|
||||||
var assessNavigatorAspectRatio = function (expectedAspectRatio, variance, msg) {
|
var assessNavigatorAspectRatio = function (assert, expectedAspectRatio, variance, msg) {
|
||||||
var navigator = $(".navigator");
|
var navigator = $(".navigator");
|
||||||
|
|
||||||
Util.assessNumericValue(expectedAspectRatio, navigator.width() / navigator.height(), variance, ' Navigator Aspect Ratio ' + (msg ? msg : ''));
|
Util.assessNumericValue(assert, expectedAspectRatio, navigator.width() / navigator.height(), variance, ' Navigator Aspect Ratio ' + (msg ? msg : ''));
|
||||||
};
|
};
|
||||||
|
|
||||||
var assessNavigatorArea = function (expectedArea, msg) {
|
var assessNavigatorArea = function (assert, expectedArea, msg) {
|
||||||
var navigator = $(".navigator");
|
var navigator = $(".navigator");
|
||||||
|
|
||||||
Util.assessNumericValue(expectedArea, navigator.width() * navigator.height(), Math.max(navigator.width(), navigator.height()), ' Navigator Area ' + (msg ? msg : ''));
|
Util.assessNumericValue(assert, expectedArea, navigator.width() * navigator.height(), Math.max(navigator.width(), navigator.height()), ' Navigator Area ' + (msg ? msg : ''));
|
||||||
};
|
};
|
||||||
|
|
||||||
var navigatorRegionBoundsInPoints = function () {
|
var navigatorRegionBoundsInPoints = function () {
|
||||||
@ -113,19 +113,19 @@
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
var assessDisplayRegion = function (status) {
|
var assessDisplayRegion = function (assert, status) {
|
||||||
|
|
||||||
if (debug) {
|
if (debug) {
|
||||||
console.log(status);
|
console.log(status);
|
||||||
}
|
}
|
||||||
var expectedBounds = navigatorRegionBoundsInPoints();
|
var expectedBounds = navigatorRegionBoundsInPoints();
|
||||||
Util.assessNumericValue(expectedBounds.width, displayRegion.width() + viewer.navigator.totalBorderWidths.x, 2, status + ' Width synchronization');
|
Util.assessNumericValue(assert, 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(assert, 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(assert, expectedBounds.x, displayRegion.position().left, 2, status + ' Left synchronization');
|
||||||
Util.assessNumericValue(expectedBounds.y, displayRegion.position().top, 2, status + ' Top synchronization');
|
Util.assessNumericValue(assert, expectedBounds.y, displayRegion.position().top, 2, status + ' Top synchronization');
|
||||||
};
|
};
|
||||||
|
|
||||||
var waitForViewer = function () {
|
var waitForViewer(assert, = function (assert) {
|
||||||
return function (handler, count, lastDisplayRegionLeft, lastDisplayWidth) {
|
return function (handler, count, lastDisplayRegionLeft, lastDisplayWidth) {
|
||||||
var viewerAndNavigatorDisplayReady = false,
|
var viewerAndNavigatorDisplayReady = false,
|
||||||
currentDisplayRegionLeft,
|
currentDisplayRegionLeft,
|
||||||
@ -144,11 +144,11 @@
|
|||||||
viewerAndNavigatorDisplayReady = viewer.drawer !== null &&
|
viewerAndNavigatorDisplayReady = viewer.drawer !== null &&
|
||||||
!viewer.world.needsDraw() &&
|
!viewer.world.needsDraw() &&
|
||||||
currentDisplayWidth > 0 &&
|
currentDisplayWidth > 0 &&
|
||||||
Util.equalsWithVariance(lastDisplayRegionLeft, currentDisplayRegionLeft, 0.0001) &&
|
Util.equalsWithVariance(assert, lastDisplayRegionLeft, currentDisplayRegionLeft, 0.0001) &&
|
||||||
Util.equalsWithVariance(lastDisplayWidth, currentDisplayWidth, 0.0001) &&
|
Util.equalsWithVariance(assert, lastDisplayWidth, currentDisplayWidth, 0.0001) &&
|
||||||
Util.equalsWithVariance(viewer.viewport.getBounds(true).x, viewer.viewport.getBounds().x, 0.0001) &&
|
Util.equalsWithVariance(assert, viewer.viewport.getBounds(true).x, viewer.viewport.getBounds().x, 0.0001) &&
|
||||||
Util.equalsWithVariance(viewer.viewport.getBounds(true).y, viewer.viewport.getBounds().y, 0.0001) &&
|
Util.equalsWithVariance(assert, viewer.viewport.getBounds(true).y, viewer.viewport.getBounds().y, 0.0001) &&
|
||||||
Util.equalsWithVariance(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) {
|
||||||
//Ignore. Subsequent code will try again shortly
|
//Ignore. Subsequent code will try again shortly
|
||||||
@ -156,12 +156,12 @@
|
|||||||
if (( !viewerAndNavigatorDisplayReady) && count < 50) {
|
if (( !viewerAndNavigatorDisplayReady) && count < 50) {
|
||||||
count++;
|
count++;
|
||||||
setTimeout(function () {
|
setTimeout(function () {
|
||||||
waitForViewer(handler, count, currentDisplayRegionLeft, currentDisplayWidth);
|
waitForViewer(assert, (handler, count, currentDisplayRegionLeft, currentDisplayWidth);
|
||||||
}, 100);
|
}, 100);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (count === 40) {
|
if (count === 40) {
|
||||||
console.log("waitForViewer:" +
|
console.log("waitForViewer(assert, :" +
|
||||||
viewer.drawer + ":" + viewer.world.needsDraw() + ":" +
|
viewer.drawer + ":" + viewer.world.needsDraw() + ":" +
|
||||||
viewerAndNavigatorDisplayReady + ":" +
|
viewerAndNavigatorDisplayReady + ":" +
|
||||||
lastDisplayRegionLeft + ":" + currentDisplayRegionLeft + ":" +
|
lastDisplayRegionLeft + ":" + currentDisplayRegionLeft + ":" +
|
||||||
@ -200,7 +200,7 @@
|
|||||||
.simulate('drag', event);
|
.simulate('drag', event);
|
||||||
};
|
};
|
||||||
|
|
||||||
var assessViewerInCorner = function (theContentCorner) {
|
var assessViewerInCorner = function (assert, theContentCorner) {
|
||||||
return function () {
|
return function () {
|
||||||
var expectedXCoordinate, expectedYCoordinate;
|
var expectedXCoordinate, expectedYCoordinate;
|
||||||
if (theContentCorner === "TOPLEFT") {
|
if (theContentCorner === "TOPLEFT") {
|
||||||
@ -220,21 +220,21 @@
|
|||||||
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(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(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 () {
|
var assessViewerInCenter = function (assert) {
|
||||||
var yPositionVariance = 0.04;
|
var yPositionVariance = 0.04;
|
||||||
if (viewer.source.aspectRatio < 1) {
|
if (viewer.source.aspectRatio < 1) {
|
||||||
yPositionVariance = yPositionVariance / viewer.source.aspectRatio;
|
yPositionVariance = yPositionVariance / viewer.source.aspectRatio;
|
||||||
}
|
}
|
||||||
Util.assessNumericValue(1 / viewer.source.aspectRatio / 2, viewer.viewport.getCenter().y, yPositionVariance, ' Viewer at center, y coord');
|
Util.assessNumericValue(assert, 1 / viewer.source.aspectRatio / 2, viewer.viewport.getCenter().y, yPositionVariance, ' Viewer at center, y coord');
|
||||||
Util.assessNumericValue(0.5, viewer.viewport.getCenter().x, 0.4, ' Viewer at center, x 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) {
|
||||||
@ -277,31 +277,32 @@
|
|||||||
$element.height(height);
|
$element.height(height);
|
||||||
};
|
};
|
||||||
|
|
||||||
var assessNavigatorViewerPlacement = function (seadragonProperties, testProperties) {
|
var assessNavigatorViewerPlacement = function (assert, seadragonProperties, testProperties) {
|
||||||
|
var done = assert.async();
|
||||||
var navigatorOperationScenarios = [
|
var navigatorOperationScenarios = [
|
||||||
{interactionOperation:clickOnNavigator("TOPRIGHT"),
|
{interactionOperation:clickOnNavigator("TOPRIGHT"),
|
||||||
assessmentOperation:assessViewerInCorner("TOPRIGHT"),
|
assessmentOperation:assessViewerInCorner(assert, "TOPRIGHT"),
|
||||||
assessmentMessage:"After click on navigator on top right" },
|
assessmentMessage:"After click on navigator on top right" },
|
||||||
{interactionOperation:dragNavigatorBackToCenter,
|
{interactionOperation:dragNavigatorBackToCenter,
|
||||||
assessmentOperation:assessViewerInCenter,
|
assessmentOperation:assessViewerInCenter(assert),
|
||||||
assessmentMessage:"After drag on navigator from top right" },
|
assessmentMessage:"After drag on navigator from top right" },
|
||||||
{interactionOperation:clickOnNavigator("BOTTOMLEFT"),
|
{interactionOperation:clickOnNavigator("BOTTOMLEFT"),
|
||||||
assessmentOperation:assessViewerInCorner("BOTTOMLEFT"),
|
assessmentOperation:assessViewerInCorner(assert, "BOTTOMLEFT"),
|
||||||
assessmentMessage:"After click on navigator on bottom left" },
|
assessmentMessage:"After click on navigator on bottom left" },
|
||||||
{interactionOperation:dragNavigatorBackToCenter,
|
{interactionOperation:dragNavigatorBackToCenter,
|
||||||
assessmentOperation:assessViewerInCenter,
|
assessmentOperation:assessViewerInCenter(assert),
|
||||||
assessmentMessage:"After drag on navigator from bottom left" },
|
assessmentMessage:"After drag on navigator from bottom left" },
|
||||||
{interactionOperation:clickOnNavigator("BOTTOMRIGHT"),
|
{interactionOperation:clickOnNavigator("BOTTOMRIGHT"),
|
||||||
assessmentOperation:assessViewerInCorner("BOTTOMRIGHT"),
|
assessmentOperation:assessViewerInCorner(assert, "BOTTOMRIGHT"),
|
||||||
assessmentMessage:"After click on navigator on bottom right" },
|
assessmentMessage:"After click on navigator on bottom right" },
|
||||||
{interactionOperation:dragNavigatorBackToCenter,
|
{interactionOperation:dragNavigatorBackToCenter,
|
||||||
assessmentOperation:assessViewerInCenter,
|
assessmentOperation:assessViewerInCenter(assert),
|
||||||
assessmentMessage:"After drag on navigator from bottom right" },
|
assessmentMessage:"After drag on navigator from bottom right" },
|
||||||
{interactionOperation:clickOnNavigator("TOPLEFT"),
|
{interactionOperation:clickOnNavigator("TOPLEFT"),
|
||||||
assessmentOperation:assessViewerInCorner("TOPLEFT"),
|
assessmentOperation:assessViewerInCorner(assert, "TOPLEFT"),
|
||||||
assessmentMessage:"After click on navigator on top left" },
|
assessmentMessage:"After click on navigator on top left" },
|
||||||
{interactionOperation:dragNavigatorBackToCenter,
|
{interactionOperation:dragNavigatorBackToCenter,
|
||||||
assessmentOperation:assessViewerInCenter,
|
assessmentOperation:assessViewerInCenter(assert),
|
||||||
assessmentMessage:"After drag on navigator from top left" }
|
assessmentMessage:"After drag on navigator from top left" }
|
||||||
],
|
],
|
||||||
viewerResizeScenarios = [
|
viewerResizeScenarios = [
|
||||||
@ -331,83 +332,83 @@
|
|||||||
var assessNavigatorOperationAndTakeNextStep = function (step) {
|
var assessNavigatorOperationAndTakeNextStep = function (step) {
|
||||||
return function () {
|
return function () {
|
||||||
var nextStep = step + 1;
|
var nextStep = step + 1;
|
||||||
assessDisplayRegion(navigatorOperationScenarios[step].assessmentMessage);
|
assessDisplayRegion(assert, navigatorOperationScenarios[step].assessmentMessage);
|
||||||
navigatorOperationScenarios[step].assessmentOperation();
|
navigatorOperationScenarios[step].assessmentOperation();
|
||||||
if (step === navigatorOperationScenarios.length - 1) {
|
if (step === navigatorOperationScenarios.length - 1) {
|
||||||
start();
|
done();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
navigatorOperationScenarios[nextStep].interactionOperation();
|
navigatorOperationScenarios[nextStep].interactionOperation();
|
||||||
waitForViewer(assessNavigatorOperationAndTakeNextStep(nextStep));
|
waitForViewer(assert, (assessNavigatorOperationAndTakeNextStep(nextStep));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
var assessAfterSnapback = function () {
|
var assessAfterSnapback = function (assert) {
|
||||||
assessDisplayRegion("After snapback");
|
assessDisplayRegion(assert, "After snapback");
|
||||||
navigatorOperationScenarios[0].interactionOperation();
|
navigatorOperationScenarios[0].interactionOperation();
|
||||||
waitForViewer(assessNavigatorOperationAndTakeNextStep(0));
|
waitForViewer(assert, (assessNavigatorOperationAndTakeNextStep(0));
|
||||||
};
|
};
|
||||||
|
|
||||||
var assessAfterDragOnViewer = function () {
|
var assessAfterDragOnViewer = function (assert) {
|
||||||
assessDisplayRegion("After pan");
|
assessDisplayRegion(assert, "After pan");
|
||||||
viewer.viewport.applyConstraints();
|
viewer.viewport.applyConstraints();
|
||||||
waitForViewer(assessAfterSnapback);
|
waitForViewer(assert, assessAfterSnapback(assert));
|
||||||
};
|
};
|
||||||
|
|
||||||
var assessAfterZoomOnViewer = function () {
|
var assessAfterZoomOnViewer = function (assert) {
|
||||||
var target = new OpenSeadragon.Point(0.4, 0.4);
|
var target = new OpenSeadragon.Point(0.4, 0.4);
|
||||||
assessDisplayRegion("After image zoom");
|
assessDisplayRegion(assert, "After image zoom");
|
||||||
viewer.viewport.panTo(target);
|
viewer.viewport.panTo(target);
|
||||||
waitForViewer(assessAfterDragOnViewer);
|
waitForViewer(assert, (assessAfterDragOnViewer(assert));
|
||||||
};
|
};
|
||||||
|
|
||||||
var assessAfterResizeNavigator = function () {
|
var assessAfterResizeNavigator = function (assert) {
|
||||||
viewer.viewport.zoomTo(viewer.viewport.getZoom() * 2);
|
viewer.viewport.zoomTo(viewer.viewport.getZoom() * 2);
|
||||||
waitForViewer(assessAfterZoomOnViewer);
|
waitForViewer(assert, (assessAfterZoomOnViewer(assert));
|
||||||
};
|
};
|
||||||
|
|
||||||
var assessNavigatorResizeAndTakeNextStep = function (step) {
|
var assessNavigatorResizeAndTakeNextStep = function (assert, step) {
|
||||||
return function () {
|
return function () {
|
||||||
var nextStep = step + 1;
|
var nextStep = step + 1;
|
||||||
assessNavigatorSize(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(navigatorResizeScenarios[step].assessmentMessage);
|
assessDisplayRegion(assert, navigatorResizeScenarios[step].assessmentMessage);
|
||||||
if (step === viewerResizeScenarios.length - 1) {
|
if (step === viewerResizeScenarios.length - 1) {
|
||||||
assessAfterResizeNavigator();
|
assessAfterResizeNavigator(assert);
|
||||||
}
|
}
|
||||||
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(assessNavigatorResizeAndTakeNextStep(nextStep));
|
waitForViewer(assert, (assessNavigatorResizeAndTakeNextStep(assert, nextStep));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
var assessViewerResizeAndTakeNextStep = function (step) {
|
var assessViewerResizeAndTakeNextStep = function (assert, 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(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(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(viewerElement.width() / viewerElement.height(), 0.0001, viewerResizeScenarios[step].assessmentMessage);
|
assessNavigatorAspectRatio(assert, viewerElement.width() / viewerElement.height(), 0.0001, viewerResizeScenarios[step].assessmentMessage);
|
||||||
assessNavigatorSize(viewerElement.width() * seadragonProperties.navigatorSizeRatio, viewerElement.height() * seadragonProperties.navigatorSizeRatio, 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(viewerElement.width() / viewerElement.height(), 0.1, viewerResizeScenarios[step].assessmentMessage);
|
assessNavigatorAspectRatio(assert, viewerElement.width() / viewerElement.height(), 0.1, viewerResizeScenarios[step].assessmentMessage);
|
||||||
assessNavigatorArea(navigatorOriginalSize.x * navigatorOriginalSize.y, viewerResizeScenarios[step].assessmentMessage);
|
assessNavigatorArea(assert, navigatorOriginalSize.x * navigatorOriginalSize.y, viewerResizeScenarios[step].assessmentMessage);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -416,22 +417,22 @@
|
|||||||
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(assessNavigatorResizeAndTakeNextStep(0));
|
waitForViewer(assert, (assessNavigatorResizeAndTakeNextStep(assert, 0));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// Navigator hosted in viewer...skip navigator resize tests
|
// Navigator hosted in viewer...skip navigator resize tests
|
||||||
assessAfterResizeNavigator();
|
assessAfterResizeNavigator(assert);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
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(assessViewerResizeAndTakeNextStep(nextStep));
|
waitForViewer(assert, (assessViewerResizeAndTakeNextStep(assert, (nextStep));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
var captureInitialStateThenAct = function () {
|
var captureInitialStateThenAct = function () {
|
||||||
assessDisplayRegion("After image load");
|
assessDisplayRegion(assert, "After image load");
|
||||||
|
|
||||||
testProperties.determineExpectationsAndAssessNavigatorLocation(seadragonProperties, testProperties);
|
testProperties.determineExpectationsAndAssessNavigatorLocation(seadragonProperties, testProperties);
|
||||||
|
|
||||||
@ -439,17 +440,17 @@
|
|||||||
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(assessViewerResizeAndTakeNextStep(0));
|
waitForViewer(assert, (assessViewerResizeAndTakeNextStep(assert, (0));
|
||||||
};
|
};
|
||||||
|
|
||||||
var assessAutoFadeTriggered = function () {
|
var assessAutoFadeTriggered = function () {
|
||||||
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(captureInitialStateThenAct);
|
waitForViewer(assert, (captureInitialStateThenAct);
|
||||||
};
|
};
|
||||||
|
|
||||||
var assessAutoFadeDisabled = function () {
|
var assessAutoFadeDisabled = function () {
|
||||||
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(captureInitialStateThenAct);
|
waitForViewer(assert, (captureInitialStateThenAct);
|
||||||
};
|
};
|
||||||
|
|
||||||
var openHandler = function () {
|
var openHandler = function () {
|
||||||
@ -458,10 +459,10 @@
|
|||||||
viewerElement = $("#" + seadragonProperties.id);
|
viewerElement = $("#" + seadragonProperties.id);
|
||||||
//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(captureInitialStateThenAct);
|
waitForViewer(assert, (captureInitialStateThenAct);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
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");
|
||||||
var event = {
|
var event = {
|
||||||
clientX:1,
|
clientX:1,
|
||||||
clientY:1
|
clientY:1
|
||||||
@ -479,8 +480,8 @@
|
|||||||
viewer.addHandler('open', openHandler);
|
viewer.addHandler('open', openHandler);
|
||||||
};
|
};
|
||||||
|
|
||||||
asyncTest('DefaultNavigatorLocationWithWideImageTallViewer', function () {
|
QUnit.test('DefaultNavigatorLocationWithWideImageTallViewer', function (assert) {
|
||||||
assessNavigatorViewerPlacement({
|
assessNavigatorViewerPlacement(assert, {
|
||||||
id:'tallexample',
|
id:'tallexample',
|
||||||
prefixUrl:'/build/openseadragon/images/',
|
prefixUrl:'/build/openseadragon/images/',
|
||||||
tileSources:'/test/data/wide.dzi',
|
tileSources:'/test/data/wide.dzi',
|
||||||
@ -496,16 +497,16 @@
|
|||||||
determineExpectationsAndAssessNavigatorLocation:function (seadragonProperties, testProperties) {
|
determineExpectationsAndAssessNavigatorLocation:function (seadragonProperties, testProperties) {
|
||||||
var mainViewerElement = $("#" + seadragonProperties.id),
|
var mainViewerElement = $("#" + seadragonProperties.id),
|
||||||
navigatorElement = $(testProperties.navigatorLocator);
|
navigatorElement = $(testProperties.navigatorLocator);
|
||||||
assessNavigatorLocation(mainViewerElement.offset().left + mainViewerElement.width() - navigatorElement.width(),
|
assessNavigatorLocation(assert, mainViewerElement.offset().left + mainViewerElement.width() - navigatorElement.width(),
|
||||||
mainViewerElement.offset().top);
|
mainViewerElement.offset().top);
|
||||||
assessNavigatorSize(mainViewerElement.width() * seadragonProperties.navigatorSizeRatio, mainViewerElement.height() * seadragonProperties.navigatorSizeRatio);
|
assessNavigatorSize(assert, mainViewerElement.width() * seadragonProperties.navigatorSizeRatio, mainViewerElement.height() * seadragonProperties.navigatorSizeRatio);
|
||||||
assessNavigatorAspectRatio(mainViewerElement.width() / mainViewerElement.height(), 0.0001);
|
assessNavigatorAspectRatio(assert, mainViewerElement.width() / mainViewerElement.height(), 0.0001);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
asyncTest('DefaultNavigatorLocationWithTallImageWideViewer', function () {
|
QUnit.test('DefaultNavigatorLocationWithTallImageWideViewer', function (assert) {
|
||||||
assessNavigatorViewerPlacement({
|
assessNavigatorViewerPlacement(assert, {
|
||||||
id:'wideexample',
|
id:'wideexample',
|
||||||
prefixUrl:'/build/openseadragon/images/',
|
prefixUrl:'/build/openseadragon/images/',
|
||||||
tileSources:'/test/data/tall.dzi',
|
tileSources:'/test/data/tall.dzi',
|
||||||
@ -524,16 +525,16 @@
|
|||||||
determineExpectationsAndAssessNavigatorLocation:function (seadragonProperties, testProperties) {
|
determineExpectationsAndAssessNavigatorLocation:function (seadragonProperties, testProperties) {
|
||||||
var mainViewerElement = $("#" + seadragonProperties.id),
|
var mainViewerElement = $("#" + seadragonProperties.id),
|
||||||
navigatorElement = $(testProperties.navigatorLocator);
|
navigatorElement = $(testProperties.navigatorLocator);
|
||||||
assessNavigatorLocation(mainViewerElement.offset().left + mainViewerElement.width() - navigatorElement.width(),
|
assessNavigatorLocation(assert, mainViewerElement.offset().left + mainViewerElement.width() - navigatorElement.width(),
|
||||||
mainViewerElement.offset().top);
|
mainViewerElement.offset().top);
|
||||||
assessNavigatorSize(mainViewerElement.width() * seadragonProperties.navigatorSizeRatio, mainViewerElement.height() * seadragonProperties.navigatorSizeRatio);
|
assessNavigatorSize(assert, mainViewerElement.width() * seadragonProperties.navigatorSizeRatio, mainViewerElement.height() * seadragonProperties.navigatorSizeRatio);
|
||||||
assessNavigatorAspectRatio(mainViewerElement.width() / mainViewerElement.height(), 0.0001);
|
assessNavigatorAspectRatio(assert, mainViewerElement.width() / mainViewerElement.height(), 0.0001);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
asyncTest('TopLeftNavigatorLocation', function () {
|
QUnit.test('TopLeftNavigatorLocation', function (assert) {
|
||||||
assessNavigatorViewerPlacement({
|
assessNavigatorViewerPlacement(assert, {
|
||||||
id:'example',
|
id:'example',
|
||||||
prefixUrl:'/build/openseadragon/images/',
|
prefixUrl:'/build/openseadragon/images/',
|
||||||
tileSources:'/test/data/testpattern.dzi',
|
tileSources:'/test/data/testpattern.dzi',
|
||||||
@ -554,16 +555,16 @@
|
|||||||
determineExpectationsAndAssessNavigatorLocation:function (seadragonProperties, testProperties) {
|
determineExpectationsAndAssessNavigatorLocation:function (seadragonProperties, testProperties) {
|
||||||
var mainViewerElement = $("#" + seadragonProperties.id),
|
var mainViewerElement = $("#" + seadragonProperties.id),
|
||||||
navigatorElement = $(testProperties.navigatorLocator);
|
navigatorElement = $(testProperties.navigatorLocator);
|
||||||
assessNavigatorLocation(mainViewerElement.offset().left,
|
assessNavigatorLocation(assert, mainViewerElement.offset().left,
|
||||||
mainViewerElement.offset().top);
|
mainViewerElement.offset().top);
|
||||||
assessNavigatorSize(mainViewerElement.width() * seadragonProperties.navigatorSizeRatio, mainViewerElement.height() * seadragonProperties.navigatorSizeRatio);
|
assessNavigatorSize(assert, mainViewerElement.width() * seadragonProperties.navigatorSizeRatio, mainViewerElement.height() * seadragonProperties.navigatorSizeRatio);
|
||||||
assessNavigatorAspectRatio(mainViewerElement.width() / mainViewerElement.height(), 0.0001);
|
assessNavigatorAspectRatio(assert, mainViewerElement.width() / mainViewerElement.height(), 0.0001);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
asyncTest('TopRightNavigatorLocation', function () {
|
QUnit.test('TopRightNavigatorLocation', function (assert) {
|
||||||
assessNavigatorViewerPlacement({
|
assessNavigatorViewerPlacement(assert, {
|
||||||
id:'example',
|
id:'example',
|
||||||
prefixUrl:'/build/openseadragon/images/',
|
prefixUrl:'/build/openseadragon/images/',
|
||||||
tileSources:'/test/data/testpattern.dzi',
|
tileSources:'/test/data/testpattern.dzi',
|
||||||
@ -584,16 +585,16 @@
|
|||||||
determineExpectationsAndAssessNavigatorLocation:function (seadragonProperties, testProperties) {
|
determineExpectationsAndAssessNavigatorLocation:function (seadragonProperties, testProperties) {
|
||||||
var mainViewerElement = $("#" + seadragonProperties.id),
|
var mainViewerElement = $("#" + seadragonProperties.id),
|
||||||
navigatorElement = $(testProperties.navigatorLocator);
|
navigatorElement = $(testProperties.navigatorLocator);
|
||||||
assessNavigatorLocation(mainViewerElement.offset().left + mainViewerElement.width() - navigatorElement.width(),
|
assessNavigatorLocation(assert, mainViewerElement.offset().left + mainViewerElement.width() - navigatorElement.width(),
|
||||||
mainViewerElement.offset().top);
|
mainViewerElement.offset().top);
|
||||||
assessNavigatorSize(mainViewerElement.width() * seadragonProperties.navigatorSizeRatio, mainViewerElement.height() * seadragonProperties.navigatorSizeRatio);
|
assessNavigatorSize(assert, mainViewerElement.width() * seadragonProperties.navigatorSizeRatio, mainViewerElement.height() * seadragonProperties.navigatorSizeRatio);
|
||||||
assessNavigatorAspectRatio(mainViewerElement.width() / mainViewerElement.height(), 0.0001);
|
assessNavigatorAspectRatio(assert, mainViewerElement.width() / mainViewerElement.height(), 0.0001);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
asyncTest('BottomLeftNavigatorLocation', function () {
|
QUnit.test('BottomLeftNavigatorLocation', function (assert) {
|
||||||
assessNavigatorViewerPlacement({
|
assessNavigatorViewerPlacement(assert, {
|
||||||
id:'example',
|
id:'example',
|
||||||
prefixUrl:'/build/openseadragon/images/',
|
prefixUrl:'/build/openseadragon/images/',
|
||||||
tileSources:'/test/data/testpattern.dzi',
|
tileSources:'/test/data/testpattern.dzi',
|
||||||
@ -614,16 +615,16 @@
|
|||||||
determineExpectationsAndAssessNavigatorLocation:function (seadragonProperties, testProperties) {
|
determineExpectationsAndAssessNavigatorLocation:function (seadragonProperties, testProperties) {
|
||||||
var mainViewerElement = $("#" + seadragonProperties.id),
|
var mainViewerElement = $("#" + seadragonProperties.id),
|
||||||
navigatorElement = $(testProperties.navigatorLocator);
|
navigatorElement = $(testProperties.navigatorLocator);
|
||||||
assessNavigatorLocation(mainViewerElement.offset().left,
|
assessNavigatorLocation(assert, mainViewerElement.offset().left,
|
||||||
mainViewerElement.offset().top + mainViewerElement.height() - navigatorElement.height());
|
mainViewerElement.offset().top + mainViewerElement.height() - navigatorElement.height());
|
||||||
assessNavigatorSize(mainViewerElement.width() * seadragonProperties.navigatorSizeRatio, mainViewerElement.height() * seadragonProperties.navigatorSizeRatio);
|
assessNavigatorSize(assert, mainViewerElement.width() * seadragonProperties.navigatorSizeRatio, mainViewerElement.height() * seadragonProperties.navigatorSizeRatio);
|
||||||
assessNavigatorAspectRatio(mainViewerElement.width() / mainViewerElement.height(), 0.0001);
|
assessNavigatorAspectRatio(assert, mainViewerElement.width() / mainViewerElement.height(), 0.0001);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
asyncTest('BottomRightNavigatorLocation', function () {
|
QUnit.test('BottomRightNavigatorLocation', function (assert) {
|
||||||
assessNavigatorViewerPlacement({
|
assessNavigatorViewerPlacement(assert, {
|
||||||
id:'example',
|
id:'example',
|
||||||
prefixUrl:'/build/openseadragon/images/',
|
prefixUrl:'/build/openseadragon/images/',
|
||||||
tileSources:'/test/data/testpattern.dzi',
|
tileSources:'/test/data/testpattern.dzi',
|
||||||
@ -644,16 +645,16 @@
|
|||||||
determineExpectationsAndAssessNavigatorLocation:function (seadragonProperties, testProperties) {
|
determineExpectationsAndAssessNavigatorLocation:function (seadragonProperties, testProperties) {
|
||||||
var mainViewerElement = $("#" + seadragonProperties.id),
|
var mainViewerElement = $("#" + seadragonProperties.id),
|
||||||
navigatorElement = $(testProperties.navigatorLocator);
|
navigatorElement = $(testProperties.navigatorLocator);
|
||||||
assessNavigatorLocation(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(mainViewerElement.width() * seadragonProperties.navigatorSizeRatio, mainViewerElement.height() * seadragonProperties.navigatorSizeRatio);
|
assessNavigatorSize(assert, mainViewerElement.width() * seadragonProperties.navigatorSizeRatio, mainViewerElement.height() * seadragonProperties.navigatorSizeRatio);
|
||||||
assessNavigatorAspectRatio(mainViewerElement.width() / mainViewerElement.height(), 0.0001);
|
assessNavigatorAspectRatio(assert, mainViewerElement.width() / mainViewerElement.height(), 0.0001);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
asyncTest('AbsoluteNavigatorLocation', function () {
|
QUnit.test('AbsoluteNavigatorLocation', function (assert) {
|
||||||
assessNavigatorViewerPlacement({
|
assessNavigatorViewerPlacement(assert, {
|
||||||
id:'example',
|
id:'example',
|
||||||
prefixUrl:'/build/openseadragon/images/',
|
prefixUrl:'/build/openseadragon/images/',
|
||||||
tileSources:'/test/data/testpattern.dzi',
|
tileSources:'/test/data/testpattern.dzi',
|
||||||
@ -676,15 +677,15 @@
|
|||||||
determineExpectationsAndAssessNavigatorLocation:function (seadragonProperties, testProperties) {
|
determineExpectationsAndAssessNavigatorLocation:function (seadragonProperties, testProperties) {
|
||||||
var mainViewerElement = $("#" + seadragonProperties.id),
|
var mainViewerElement = $("#" + seadragonProperties.id),
|
||||||
navigatorElement = $(testProperties.navigatorLocator);
|
navigatorElement = $(testProperties.navigatorLocator);
|
||||||
assessNavigatorLocation(mainViewerElement.offset().left + seadragonProperties.navigatorLeft,
|
assessNavigatorLocation(assert, mainViewerElement.offset().left + seadragonProperties.navigatorLeft,
|
||||||
mainViewerElement.offset().top + seadragonProperties.navigatorTop);
|
mainViewerElement.offset().top + seadragonProperties.navigatorTop);
|
||||||
assessNavigatorSize(seadragonProperties.navigatorWidth, seadragonProperties.navigatorHeight);
|
assessNavigatorSize(assert, seadragonProperties.navigatorWidth, seadragonProperties.navigatorHeight);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
asyncTest('CustomNavigatorElementWithWideImageWideViewer', function () {
|
QUnit.test('CustomNavigatorElementWithWideImageWideViewer', function (assert) {
|
||||||
assessNavigatorViewerPlacement({
|
assessNavigatorViewerPlacement(assert, {
|
||||||
id:'wideexample',
|
id:'wideexample',
|
||||||
navigatorId:'exampleNavigator',
|
navigatorId:'exampleNavigator',
|
||||||
prefixUrl:'/build/openseadragon/images/',
|
prefixUrl:'/build/openseadragon/images/',
|
||||||
@ -699,13 +700,13 @@
|
|||||||
determineExpectationsAndAssessNavigatorLocation:function (seadragonProperties, testProperties) {
|
determineExpectationsAndAssessNavigatorLocation:function (seadragonProperties, testProperties) {
|
||||||
var mainViewerElement = $("#" + seadragonProperties.id),
|
var mainViewerElement = $("#" + seadragonProperties.id),
|
||||||
navigatorViewerElement = $("#" + seadragonProperties.navigatorId);
|
navigatorViewerElement = $("#" + seadragonProperties.navigatorId);
|
||||||
assessNavigatorLocation(mainViewerElement.offset().left,
|
assessNavigatorLocation(assert, mainViewerElement.offset().left,
|
||||||
mainViewerElement.offset().top - navigatorViewerElement.parent().height());
|
mainViewerElement.offset().top - navigatorViewerElement.parent().height());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
asyncTest('CustomDialogNavigatorElementWithTallImageTallViewer', function () {
|
QUnit.test('CustomDialogNavigatorElementWithTallImageTallViewer', function (assert) {
|
||||||
$('#exampleNavigator').dialog({ width: 150,
|
$('#exampleNavigator').dialog({ width: 150,
|
||||||
height:100,
|
height:100,
|
||||||
open: function (event, ui) {
|
open: function (event, ui) {
|
||||||
@ -720,7 +721,7 @@
|
|||||||
// //$('#exampleNavigator').dialog("option", "width", 200);
|
// //$('#exampleNavigator').dialog("option", "width", 200);
|
||||||
//}
|
//}
|
||||||
});
|
});
|
||||||
assessNavigatorViewerPlacement({
|
assessNavigatorViewerPlacement(assert, {
|
||||||
id:'tallexample',
|
id:'tallexample',
|
||||||
navigatorId:'exampleNavigator',
|
navigatorId:'exampleNavigator',
|
||||||
prefixUrl:'/build/openseadragon/images/',
|
prefixUrl:'/build/openseadragon/images/',
|
||||||
@ -740,14 +741,15 @@
|
|||||||
topNavigatorClickAdjustment: 15,
|
topNavigatorClickAdjustment: 15,
|
||||||
determineExpectationsAndAssessNavigatorLocation:function (seadragonProperties, testProperties) {
|
determineExpectationsAndAssessNavigatorLocation:function (seadragonProperties, testProperties) {
|
||||||
var jqueryDialog = $(testProperties.navigatorLocator);
|
var jqueryDialog = $(testProperties.navigatorLocator);
|
||||||
assessNavigatorLocation(jqueryDialog.offset().left,
|
assessNavigatorLocation(assert, jqueryDialog.offset().left,
|
||||||
jqueryDialog.offset().top);
|
jqueryDialog.offset().top);
|
||||||
assessNavigatorSize(jqueryDialog.width(), jqueryDialog.height());
|
assessNavigatorSize(assert, jqueryDialog.width(), jqueryDialog.height());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
asyncTest('Viewer closing one image and opening another', function() {
|
QUnit.test('Viewer closing one image and opening another', function(assert) {
|
||||||
|
var done = assert.async();
|
||||||
var timeWatcher = Util.timeWatcher();
|
var timeWatcher = Util.timeWatcher();
|
||||||
|
|
||||||
viewer = OpenSeadragon({
|
viewer = OpenSeadragon({
|
||||||
@ -760,14 +762,14 @@
|
|||||||
|
|
||||||
var openHandler1 = function(event) {
|
var openHandler1 = function(event) {
|
||||||
viewer.removeHandler('open', openHandler1);
|
viewer.removeHandler('open', openHandler1);
|
||||||
ok(viewer.navigator, 'navigator exists');
|
assert.ok(viewer.navigator, 'navigator exists');
|
||||||
viewer.navigator.world.addHandler('add-item', navOpenHandler1);
|
viewer.navigator.world.addHandler('add-item', navOpenHandler1);
|
||||||
};
|
};
|
||||||
|
|
||||||
var navOpenHandler1 = function(event) {
|
var navOpenHandler1 = function(event) {
|
||||||
viewer.navigator.world.removeHandler('add-item', navOpenHandler1);
|
viewer.navigator.world.removeHandler('add-item', navOpenHandler1);
|
||||||
equal(viewer.navigator.source, viewer.source, 'viewer and navigator have the same source');
|
assert.equal(viewer.navigator.source, viewer.source, 'viewer and navigator have the same source');
|
||||||
ok(viewer.navigator._updateRequestId, 'navigator timer is on');
|
assert.ok(viewer.navigator._updateRequestId, 'navigator timer is on');
|
||||||
viewer.addHandler('close', closeHandler1);
|
viewer.addHandler('close', closeHandler1);
|
||||||
viewer.addHandler('open', openHandler2);
|
viewer.addHandler('open', openHandler2);
|
||||||
viewer.open('/test/data/tall.dzi');
|
viewer.open('/test/data/tall.dzi');
|
||||||
@ -775,8 +777,8 @@
|
|||||||
|
|
||||||
var closeHandler1 = function(event) {
|
var closeHandler1 = function(event) {
|
||||||
viewer.removeHandler('close', closeHandler1);
|
viewer.removeHandler('close', closeHandler1);
|
||||||
ok(true, 'calling open closes the old one');
|
assert.ok(true, 'calling open closes the old one');
|
||||||
equal(viewer.navigator.source, null, 'navigator source has been cleared');
|
assert.equal(viewer.navigator.source, null, 'navigator source has been cleared');
|
||||||
};
|
};
|
||||||
|
|
||||||
var openHandler2 = function(event) {
|
var openHandler2 = function(event) {
|
||||||
@ -786,7 +788,7 @@
|
|||||||
|
|
||||||
var navOpenHandler2 = function(event) {
|
var navOpenHandler2 = function(event) {
|
||||||
viewer.navigator.world.removeHandler('add-item', navOpenHandler2);
|
viewer.navigator.world.removeHandler('add-item', navOpenHandler2);
|
||||||
equal(viewer.navigator.source, viewer.source, 'viewer and navigator have the same source');
|
assert.equal(viewer.navigator.source, viewer.source, 'viewer and navigator have the same source');
|
||||||
viewer.addHandler('close', closeHandler2);
|
viewer.addHandler('close', closeHandler2);
|
||||||
viewer.close();
|
viewer.close();
|
||||||
};
|
};
|
||||||
@ -794,7 +796,7 @@
|
|||||||
var closeHandler2 = function(event) {
|
var closeHandler2 = function(event) {
|
||||||
viewer.removeHandler('close', closeHandler2);
|
viewer.removeHandler('close', closeHandler2);
|
||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
ok(!viewer.navigator._updateRequestId, 'navigator timer is off');
|
assert.ok(!viewer.navigator._updateRequestId, 'navigator timer is off');
|
||||||
timeWatcher.done();
|
timeWatcher.done();
|
||||||
}, 100);
|
}, 100);
|
||||||
};
|
};
|
||||||
@ -802,7 +804,8 @@
|
|||||||
viewer.addHandler('open', openHandler1);
|
viewer.addHandler('open', openHandler1);
|
||||||
});
|
});
|
||||||
|
|
||||||
asyncTest('Item positions including collection mode', function() {
|
QUnit.test('Item positions including collection mode', function(assert) {
|
||||||
|
var done = assert.async();
|
||||||
|
|
||||||
viewer = OpenSeadragon({
|
viewer = OpenSeadragon({
|
||||||
id: 'example',
|
id: 'example',
|
||||||
@ -836,7 +839,7 @@
|
|||||||
propEqual(viewer.navigator.world.getItemAt(0).getBounds(),
|
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');
|
||||||
|
|
||||||
start();
|
done();
|
||||||
}, 1);
|
}, 1);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -844,8 +847,8 @@
|
|||||||
viewer.addHandler('open', openHandler);
|
viewer.addHandler('open', openHandler);
|
||||||
});
|
});
|
||||||
|
|
||||||
asyncTest('Item opacity is synchronized', function() {
|
QUnit.test('Item opacity is synchronized', function(assert) {
|
||||||
|
var done = assert.async();
|
||||||
viewer = OpenSeadragon({
|
viewer = OpenSeadragon({
|
||||||
id: 'example',
|
id: 'example',
|
||||||
prefixUrl: '/build/openseadragon/images/',
|
prefixUrl: '/build/openseadragon/images/',
|
||||||
@ -861,16 +864,16 @@
|
|||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
// Test initial formation
|
// Test initial formation
|
||||||
for (var i = 0; i < 2; i++) {
|
for (var i = 0; i < 2; i++) {
|
||||||
equal(viewer.navigator.world.getItemAt(i).getOpacity(),
|
assert.equal(viewer.navigator.world.getItemAt(i).getOpacity(),
|
||||||
viewer.world.getItemAt(i).getOpacity(), 'opacity is the same');
|
viewer.world.getItemAt(i).getOpacity(), 'opacity is the same');
|
||||||
}
|
}
|
||||||
|
|
||||||
// Try changing the opacity of one
|
// Try changing the opacity of one
|
||||||
viewer.world.getItemAt(1).setOpacity(0.5);
|
viewer.world.getItemAt(1).setOpacity(0.5);
|
||||||
equal(viewer.navigator.world.getItemAt(1).getOpacity(),
|
assert.equal(viewer.navigator.world.getItemAt(1).getOpacity(),
|
||||||
viewer.world.getItemAt(1).getOpacity(), 'opacity is the same after change');
|
viewer.world.getItemAt(1).getOpacity(), 'opacity is the same after change');
|
||||||
|
|
||||||
start();
|
done();
|
||||||
}, 1);
|
}, 1);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -885,8 +888,8 @@
|
|||||||
viewer.addHandler('open', openHandler);
|
viewer.addHandler('open', openHandler);
|
||||||
});
|
});
|
||||||
|
|
||||||
asyncTest('Item composite operation is synchronized', function() {
|
QUnit.test('Item composite operation is synchronized', function(assert) {
|
||||||
|
var done = assert.async();
|
||||||
viewer = OpenSeadragon({
|
viewer = OpenSeadragon({
|
||||||
id: 'example',
|
id: 'example',
|
||||||
prefixUrl: '/build/openseadragon/images/',
|
prefixUrl: '/build/openseadragon/images/',
|
||||||
@ -902,16 +905,16 @@
|
|||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
// Test initial formation
|
// Test initial formation
|
||||||
for (var i = 0; i < 2; i++) {
|
for (var i = 0; i < 2; i++) {
|
||||||
equal(viewer.navigator.world.getItemAt(i).getCompositeOperation(),
|
assert.equal(viewer.navigator.world.getItemAt(i).getCompositeOperation(),
|
||||||
viewer.world.getItemAt(i).getCompositeOperation(), 'composite operation is the same');
|
viewer.world.getItemAt(i).getCompositeOperation(), 'composite operation is the same');
|
||||||
}
|
}
|
||||||
|
|
||||||
// Try changing the composite operation of one
|
// Try changing the composite operation of one
|
||||||
viewer.world.getItemAt(1).setCompositeOperation('multiply');
|
viewer.world.getItemAt(1).setCompositeOperation('multiply');
|
||||||
equal(viewer.navigator.world.getItemAt(1).getCompositeOperation(),
|
assert.equal(viewer.navigator.world.getItemAt(1).getCompositeOperation(),
|
||||||
viewer.world.getItemAt(1).getCompositeOperation(), 'composite operation is the same after change');
|
viewer.world.getItemAt(1).getCompositeOperation(), 'composite operation is the same after change');
|
||||||
|
|
||||||
start();
|
done();
|
||||||
}, 1);
|
}, 1);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -926,8 +929,8 @@
|
|||||||
viewer.addHandler('open', openHandler);
|
viewer.addHandler('open', openHandler);
|
||||||
});
|
});
|
||||||
|
|
||||||
asyncTest('Viewer options transmitted to navigator', function() {
|
QUnit.test('Viewer options transmitted to navigator', function(assert) {
|
||||||
|
var done = assert.async();a
|
||||||
viewer = OpenSeadragon({
|
viewer = OpenSeadragon({
|
||||||
id: 'example',
|
id: 'example',
|
||||||
prefixUrl: '/build/openseadragon/images/',
|
prefixUrl: '/build/openseadragon/images/',
|
||||||
@ -942,17 +945,17 @@
|
|||||||
|
|
||||||
var navigator = viewer.navigator;
|
var navigator = viewer.navigator;
|
||||||
|
|
||||||
equal(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.");
|
||||||
equal(navigator.crossOriginPolicy, viewer.crossOriginPolicy,
|
assert.equal(navigator.crossOriginPolicy, viewer.crossOriginPolicy,
|
||||||
"Cross origin policy should be transmitted to the navigator.");
|
"Cross origin policy should be transmitted to the navigator.");
|
||||||
start();
|
done();
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
asyncTest('Viewer rotation applied to navigator by default', function() {
|
QUnit.test('Viewer rotation applied to navigator by default', function(assert) {
|
||||||
|
var done = assert.async();
|
||||||
viewer = OpenSeadragon({
|
viewer = OpenSeadragon({
|
||||||
id: 'example',
|
id: 'example',
|
||||||
prefixUrl: '/build/openseadragon/images/',
|
prefixUrl: '/build/openseadragon/images/',
|
||||||
@ -966,19 +969,19 @@
|
|||||||
|
|
||||||
var navigator = viewer.navigator;
|
var navigator = viewer.navigator;
|
||||||
|
|
||||||
equal(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);
|
||||||
equal(navigator.viewport.getRotation(), 90,
|
assert.equal(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.");
|
||||||
|
|
||||||
start();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
asyncTest('Viewer rotation not applied to navigator when navigatorRotate=false', function() {
|
QUnit.test('Viewer rotation not applied to navigator when navigatorRotate=false', function(assert) {
|
||||||
|
var done = assert.async();
|
||||||
viewer = OpenSeadragon({
|
viewer = OpenSeadragon({
|
||||||
id: 'example',
|
id: 'example',
|
||||||
prefixUrl: '/build/openseadragon/images/',
|
prefixUrl: '/build/openseadragon/images/',
|
||||||
@ -993,14 +996,14 @@
|
|||||||
|
|
||||||
var navigator = viewer.navigator;
|
var navigator = viewer.navigator;
|
||||||
|
|
||||||
equal(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);
|
||||||
equal(navigator.viewport.getRotation(), 0,
|
assert.equal(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.");
|
||||||
|
|
||||||
start();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user