mirror of
https://github.com/openseadragon/openseadragon.git
synced 2024-11-26 15:16:10 +03:00
Checkpoint. Some more cleanup. Adjusted to work under PhantomJS
This commit is contained in:
parent
6d73456c66
commit
1e8acf5466
@ -63,10 +63,6 @@ QUnit.config.autostart = false;
|
|||||||
var navigatorRegionBoundsInPoints = function (theDisplayRegionSelector)
|
var navigatorRegionBoundsInPoints = function (theDisplayRegionSelector)
|
||||||
{
|
{
|
||||||
var regionBoundsInPoints;
|
var regionBoundsInPoints;
|
||||||
if (displayRegion === null)
|
|
||||||
{
|
|
||||||
displayRegion = $(theDisplayRegionSelector);
|
|
||||||
}
|
|
||||||
if (navigator === null)
|
if (navigator === null)
|
||||||
{
|
{
|
||||||
navigator = $(".navigator");
|
navigator = $(".navigator");
|
||||||
@ -113,13 +109,13 @@ QUnit.config.autostart = false;
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
var assessNavigatorDisplayRegionAndMainViewerState = function (theViewer, theDisplayRegionSelector, status) {
|
var assessNavigatorDisplayRegionAndMainViewerState = function (theDisplayRegionSelector, status) {
|
||||||
|
|
||||||
var expectedBounds = navigatorRegionBoundsInPoints(theDisplayRegionSelector);
|
var expectedBounds = navigatorRegionBoundsInPoints(theDisplayRegionSelector);
|
||||||
assessNumericValueWithSomeVariance(expectedBounds.width, displayRegion.width() + viewer.navigator.totalBorderWidths.x, 2, status + ' Width synchronization');
|
assessNumericValueWithSomeVariance(expectedBounds.width, displayRegion.width() + viewer.navigator.totalBorderWidths.x, 2, status + ' Width synchronization');
|
||||||
assessNumericValueWithSomeVariance(expectedBounds.height, displayRegion.height() + viewer.navigator.totalBorderWidths.y, 2, status + ' Height synchronization');
|
assessNumericValueWithSomeVariance(expectedBounds.height, displayRegion.height() + viewer.navigator.totalBorderWidths.y, 2, status + ' Height synchronization');
|
||||||
assessNumericValueWithSomeVariance(expectedBounds.x, displayRegion.position().left, 4, status + ' Left synchronization');
|
assessNumericValueWithSomeVariance(expectedBounds.x, displayRegion.position().left, 2, status + ' Left synchronization');
|
||||||
assessNumericValueWithSomeVariance(expectedBounds.y, displayRegion.position().top, 4, status + ' Top synchronization');
|
assessNumericValueWithSomeVariance(expectedBounds.y, displayRegion.position().top, 2, status + ' Top synchronization');
|
||||||
};
|
};
|
||||||
|
|
||||||
var filterToDetectThatDisplayRegionHasBeenDrawn = function () {
|
var filterToDetectThatDisplayRegionHasBeenDrawn = function () {
|
||||||
@ -145,7 +141,10 @@ QUnit.config.autostart = false;
|
|||||||
}, 50)
|
}, 50)
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
if (count === 20)
|
||||||
|
{
|
||||||
console.log( "waitUntilFilterSatisfied:" + found + ":" + $this.length + ":" + count );
|
console.log( "waitUntilFilterSatisfied:" + found + ":" + $this.length + ":" + count );
|
||||||
|
}
|
||||||
handler();
|
handler();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -154,7 +153,7 @@ QUnit.config.autostart = false;
|
|||||||
|
|
||||||
var waitForViewer = function () {
|
var waitForViewer = function () {
|
||||||
return function () {
|
return function () {
|
||||||
return function (theViewer, handler, count, lastDisplayRegionLeft, lastDisplayWidth) {
|
return function (handler, count, lastDisplayRegionLeft, lastDisplayWidth) {
|
||||||
var currentDisplayRegionLeft;
|
var currentDisplayRegionLeft;
|
||||||
var currentDisplayWidth;
|
var currentDisplayWidth;
|
||||||
if (displayRegion === null)
|
if (displayRegion === null)
|
||||||
@ -167,36 +166,36 @@ QUnit.config.autostart = false;
|
|||||||
lastDisplayRegionLeft = null;
|
lastDisplayRegionLeft = null;
|
||||||
lastDisplayWidth = null;
|
lastDisplayWidth = null;
|
||||||
}
|
}
|
||||||
if (theViewer.drawer !== null) {
|
if (viewer.drawer !== null) {
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
currentDisplayRegionLeft = displayRegion.position().left;
|
currentDisplayRegionLeft = displayRegion.position().left;
|
||||||
currentDisplayWidth = displayRegion.width();
|
currentDisplayWidth = displayRegion.width();
|
||||||
propertyAchieved = equalsWithSomeVariance(lastDisplayRegionLeft, currentDisplayRegionLeft,.0001) &&
|
propertyAchieved = equalsWithSomeVariance(lastDisplayRegionLeft, currentDisplayRegionLeft,.0001) &&
|
||||||
equalsWithSomeVariance(lastDisplayWidth,currentDisplayWidth,.0001) &&
|
equalsWithSomeVariance(lastDisplayWidth,currentDisplayWidth,.0001) &&
|
||||||
equalsWithSomeVariance(theViewer.viewport.getBounds(true).x,theViewer.viewport.getBounds().x,.0001) &&
|
equalsWithSomeVariance(viewer.viewport.getBounds(true).x,viewer.viewport.getBounds().x,.0001) &&
|
||||||
equalsWithSomeVariance(theViewer.viewport.getBounds(true).width,theViewer.viewport.getBounds().width,.0001);
|
equalsWithSomeVariance(viewer.viewport.getBounds(true).width,viewer.viewport.getBounds().width,.0001);
|
||||||
}
|
}
|
||||||
catch(err)
|
catch(err)
|
||||||
{
|
{
|
||||||
//Ignore. Subsequent code will try again shortly
|
//Ignore. Subsequent code will try again shortly
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ((theViewer.drawer === null || theViewer.drawer.needsUpdate() || !propertyAchieved) && count < 40) {
|
if ((viewer.drawer === null || !propertyAchieved) && count < 40) { //|| viewer.drawer.needsUpdate()
|
||||||
count++;
|
count++;
|
||||||
setTimeout(function () {
|
setTimeout(function () {waitForViewer(handler, count, currentDisplayRegionLeft, currentDisplayWidth);}, 100)
|
||||||
waitForViewer(theViewer, handler, count, currentDisplayRegionLeft, currentDisplayWidth);
|
|
||||||
}, 100)
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
try
|
if (count === 40)
|
||||||
{
|
{
|
||||||
console.log( "waitForViewer:" + theViewer.drawer + ":" + theViewer.drawer.needsUpdate() + ":" + propertyAchieved + ":" + lastDisplayRegionLeft + ":" + currentDisplayRegionLeft + ":" + lastDisplayWidth + ":" + currentDisplayWidth + ":" + count );
|
console.log( "waitForViewer:" +
|
||||||
|
viewer.drawer + ":" + viewer.drawer.needsUpdate() + ":" +
|
||||||
}
|
propertyAchieved + ":" +
|
||||||
catch (err)
|
lastDisplayRegionLeft + ":" + currentDisplayRegionLeft + ":" +
|
||||||
{
|
lastDisplayWidth + ":" + currentDisplayWidth + ":" +
|
||||||
console.log( "stophere:");
|
viewer.viewport.getBounds(true).x + ":" + viewer.viewport.getBounds().x + ":" +
|
||||||
|
viewer.viewport.getBounds(true).width + ":" + viewer.viewport.getBounds().width + ":" +
|
||||||
|
count );
|
||||||
}
|
}
|
||||||
handler();
|
handler();
|
||||||
}
|
}
|
||||||
@ -243,53 +242,45 @@ QUnit.config.autostart = false;
|
|||||||
viewer = OpenSeadragon(seadragonProperties);
|
viewer = OpenSeadragon(seadragonProperties);
|
||||||
|
|
||||||
var assessAfterDragNavigatorFromTopRight = function() {
|
var assessAfterDragNavigatorFromTopRight = function() {
|
||||||
assessNavigatorDisplayRegionAndMainViewerState(viewer, testProperties.displayRegionLocator, "After drag on navigator");
|
assessNavigatorDisplayRegionAndMainViewerState(testProperties.displayRegionLocator + ":" + seadragonProperties.tileSources, "After drag on navigator");
|
||||||
start();
|
start();
|
||||||
};
|
};
|
||||||
|
|
||||||
var assessAfterClickOnNavigatorTopRight = function() {
|
var assessAfterClickOnNavigatorTopRight = function() {
|
||||||
var dragVector = new OpenSeadragon.Point(0.1,0.1);
|
assessNavigatorDisplayRegionAndMainViewerState(testProperties.displayRegionLocator, "After click on navigator");
|
||||||
var expectedCenter = new OpenSeadragon.Point(0.5, viewer.source.aspectRatio/2).plus(dragVector);
|
|
||||||
assessNavigatorDisplayRegionAndMainViewerState(viewer, testProperties.displayRegionLocator, "After click on navigator");
|
|
||||||
dragNavigatorBackToCenter();
|
dragNavigatorBackToCenter();
|
||||||
waitForViewer(viewer, assessAfterDragNavigatorFromTopRight);
|
waitForViewer(assessAfterDragNavigatorFromTopRight);
|
||||||
};
|
};
|
||||||
|
|
||||||
var assessAfterDragOnViewer = function () {
|
var assessAfterDragOnViewer = function () {
|
||||||
var navigatorCenter = viewer.navigator.viewport.getCenter();
|
assessNavigatorDisplayRegionAndMainViewerState(testProperties.displayRegionLocator, "After pan");
|
||||||
var expectedCenter = new OpenSeadragon.Point(0.5, viewer.source.aspectRatio/2);
|
|
||||||
assessNavigatorDisplayRegionAndMainViewerState(viewer, testProperties.displayRegionLocator, "After pan");
|
|
||||||
clickOnNavigator("TOPRIGHT");
|
clickOnNavigator("TOPRIGHT");
|
||||||
waitForViewer(viewer, assessAfterClickOnNavigatorTopRight);
|
waitForViewer(assessAfterClickOnNavigatorTopRight);
|
||||||
};
|
};
|
||||||
|
|
||||||
var assessAfterZoomOnViewer = function () {
|
var assessAfterZoomOnViewer = function () {
|
||||||
var target = new OpenSeadragon.Point(0.4, 0.4);
|
var target = new OpenSeadragon.Point(0.4, 0.4);
|
||||||
assessNavigatorDisplayRegionAndMainViewerState(viewer, testProperties.displayRegionLocator, "After image zoom");
|
assessNavigatorDisplayRegionAndMainViewerState(testProperties.displayRegionLocator, "After image zoom");
|
||||||
viewer.viewport.panTo(target);
|
viewer.viewport.panTo(target);
|
||||||
waitForViewer(viewer, assessAfterDragOnViewer);
|
waitForViewer(assessAfterDragOnViewer);
|
||||||
};
|
};
|
||||||
|
|
||||||
var captureInitialStateAfterOpenAndThenAct = function () {
|
var captureInitialStateAfterOpenAndThenAct = function () {
|
||||||
assessNavigatorDisplayRegionAndMainViewerState(viewer, testProperties.displayRegionLocator, "After image load");
|
assessNavigatorDisplayRegionAndMainViewerState(testProperties.displayRegionLocator, "After image load");
|
||||||
|
|
||||||
testProperties.determineExpectationsAndAssessNavigatorLocation(seadragonProperties, testProperties);
|
testProperties.determineExpectationsAndAssessNavigatorLocation(seadragonProperties, testProperties);
|
||||||
|
|
||||||
viewer.viewport.zoomTo(viewer.viewport.getZoom() * 2);
|
viewer.viewport.zoomTo(viewer.viewport.getZoom() * 2);
|
||||||
waitForViewer(viewer, assessAfterZoomOnViewer);
|
waitForViewer(assessAfterZoomOnViewer);
|
||||||
};
|
};
|
||||||
|
|
||||||
var proceedOnceTheIntialImagesAreLoaded = function () {
|
var proceedOnceTheIntialImagesAreLoaded = function () {
|
||||||
waitUntilFilterSatisfied(testProperties.displayRegionLocator, filterToDetectThatDisplayRegionHasBeenDrawn, captureInitialStateAfterOpenAndThenAct);
|
waitUntilFilterSatisfied(testProperties.displayRegionLocator, filterToDetectThatDisplayRegionHasBeenDrawn, captureInitialStateAfterOpenAndThenAct);
|
||||||
};
|
};
|
||||||
|
|
||||||
var waitForNavigator = function () {
|
|
||||||
waitForViewer(viewer.navigator, proceedOnceTheIntialImagesAreLoaded);
|
|
||||||
};
|
|
||||||
|
|
||||||
var openHandler = function () {
|
var openHandler = function () {
|
||||||
viewer.removeHandler('open', openHandler);
|
viewer.removeHandler('open', openHandler);
|
||||||
waitForViewer(viewer, waitForNavigator);
|
waitForViewer(proceedOnceTheIntialImagesAreLoaded);
|
||||||
};
|
};
|
||||||
|
|
||||||
viewer.addHandler('open', openHandler);
|
viewer.addHandler('open', openHandler);
|
||||||
|
Loading…
Reference in New Issue
Block a user