mirror of
https://github.com/openseadragon/openseadragon.git
synced 2024-11-22 13:16:10 +03:00
Refactored to remove duplicated code
This commit is contained in:
parent
858487f8c6
commit
6b97ab4424
@ -127,8 +127,8 @@ QUnit.config.autostart = false;
|
||||
};
|
||||
|
||||
var waitForViewer = function () {
|
||||
return function () {
|
||||
return function (handler, count, lastDisplayRegionLeft, lastDisplayWidth) {
|
||||
// return function () {
|
||||
var currentDisplayRegionLeft;
|
||||
var currentDisplayWidth;
|
||||
if (displayRegion === null)
|
||||
@ -178,7 +178,7 @@ QUnit.config.autostart = false;
|
||||
handler();
|
||||
}
|
||||
};
|
||||
}();
|
||||
// }();
|
||||
}();
|
||||
|
||||
var simulateNavigatorClick = function(viewer, locationX, locationY) {
|
||||
@ -207,6 +207,8 @@ QUnit.config.autostart = false;
|
||||
};
|
||||
|
||||
var assessViewerInCorner = function(theContentCorner)
|
||||
{
|
||||
return function()
|
||||
{
|
||||
var expectedXCoordinate, expecteYCoordinate;
|
||||
if (theContentCorner === "TOPLEFT")
|
||||
@ -237,6 +239,7 @@ QUnit.config.autostart = false;
|
||||
{
|
||||
assessNumericValueWithSomeVariance(expecteYCoordinate, viewer.viewport.getBounds().y,.04, ' Viewer at ' + theContentCorner + ', y coord');
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
var assessViewerInCenter = function()
|
||||
@ -252,6 +255,8 @@ QUnit.config.autostart = false;
|
||||
|
||||
|
||||
var clickOnNavigator = function(theContentCorner)
|
||||
{
|
||||
return function()
|
||||
{
|
||||
var xPos, yPos;
|
||||
if (theContentCorner === "TOPLEFT")
|
||||
@ -275,6 +280,7 @@ QUnit.config.autostart = false;
|
||||
yPos = spaceFromTopEdgeOfViewerToContentStart + heightOfViewerContentOnNavigator;
|
||||
}
|
||||
simulateNavigatorClick(viewer.navigator, xPos, yPos);
|
||||
}
|
||||
};
|
||||
|
||||
var dragNavigatorBackToCenter = function()
|
||||
@ -296,65 +302,43 @@ QUnit.config.autostart = false;
|
||||
seadragonProperties.visibilityRatio = 1;
|
||||
viewer = OpenSeadragon(seadragonProperties);
|
||||
|
||||
var assessAfterDragNavigatorFromTopLeft = function() {
|
||||
assessNavigatorDisplayRegionAndMainViewerState("After drag on navigator from top left");
|
||||
assessViewerInCenter();
|
||||
var navigatorInteractionOperations = [ clickOnNavigator("TOPRIGHT"),dragNavigatorBackToCenter,
|
||||
clickOnNavigator("BOTTOMLEFT"),dragNavigatorBackToCenter,
|
||||
clickOnNavigator("BOTTOMRIGHT"),dragNavigatorBackToCenter,
|
||||
clickOnNavigator("TOPLEFT"),dragNavigatorBackToCenter ];
|
||||
var navigatorAssessmentOperations = [assessViewerInCorner("TOPRIGHT"),assessViewerInCenter,
|
||||
assessViewerInCorner("BOTTOMLEFT"),assessViewerInCenter,
|
||||
assessViewerInCorner("BOTTOMRIGHT"),assessViewerInCenter,
|
||||
assessViewerInCorner("TOPLEFT"),assessViewerInCenter];
|
||||
|
||||
var navigatorAssessmentMessages = ["After click on navigator on top right","After drag on navigator from top right",
|
||||
"After click on navigator on bottom left","After drag on navigator from bottom left",
|
||||
"After click on navigator on bottom right","After drag on navigator from bottom right",
|
||||
"After click on navigator on top right","After drag on navigator from top right"];
|
||||
|
||||
var assessNavigatorOperationAndTakeNextStep = function(step)
|
||||
{
|
||||
return function()
|
||||
{
|
||||
var nextStep = step+1;
|
||||
assessNavigatorDisplayRegionAndMainViewerState(navigatorAssessmentMessages[step]);
|
||||
navigatorAssessmentOperations[step]();
|
||||
if (step === navigatorInteractionOperations.length-1)
|
||||
{
|
||||
start();
|
||||
}
|
||||
else
|
||||
{
|
||||
navigatorInteractionOperations[nextStep]();
|
||||
waitForViewer(assessNavigatorOperationAndTakeNextStep(nextStep));
|
||||
}
|
||||
};
|
||||
|
||||
var assessAfterClickOnNavigatorTopLeft = function() {
|
||||
assessNavigatorDisplayRegionAndMainViewerState("After click on navigator on top left");
|
||||
assessViewerInCorner("TOPLEFT");
|
||||
dragNavigatorBackToCenter();
|
||||
waitForViewer(assessAfterDragNavigatorFromTopLeft);
|
||||
};
|
||||
|
||||
var assessAfterDragNavigatorFromBottomRight = function() {
|
||||
assessNavigatorDisplayRegionAndMainViewerState("After drag on navigator from bottom right");
|
||||
assessViewerInCenter();
|
||||
clickOnNavigator("TOPLEFT");
|
||||
waitForViewer(assessAfterClickOnNavigatorTopLeft);
|
||||
};
|
||||
|
||||
var assessAfterClickOnNavigatorBottomRight = function() {
|
||||
assessNavigatorDisplayRegionAndMainViewerState("After click on navigator on bottom right");
|
||||
assessViewerInCorner("BOTTOMRIGHT");
|
||||
dragNavigatorBackToCenter();
|
||||
waitForViewer(assessAfterDragNavigatorFromBottomRight);
|
||||
};
|
||||
|
||||
var assessAfterDragNavigatorFromBottomLeft = function() {
|
||||
assessNavigatorDisplayRegionAndMainViewerState("After drag on navigator from top left");
|
||||
assessViewerInCenter();
|
||||
clickOnNavigator("BOTTOMRIGHT");
|
||||
waitForViewer(assessAfterClickOnNavigatorBottomRight);
|
||||
};
|
||||
|
||||
var assessAfterClickOnNavigatorBottomLeft = function() {
|
||||
assessNavigatorDisplayRegionAndMainViewerState("After click on navigator on bottom left");
|
||||
assessViewerInCorner("BOTTOMLEFT");
|
||||
dragNavigatorBackToCenter();
|
||||
waitForViewer(assessAfterDragNavigatorFromBottomLeft);
|
||||
};
|
||||
|
||||
var assessAfterDragNavigatorFromTopRight = function() {
|
||||
assessNavigatorDisplayRegionAndMainViewerState("After drag on navigato from top rightr");
|
||||
assessViewerInCenter();
|
||||
clickOnNavigator("BOTTOMLEFT");
|
||||
waitForViewer(assessAfterClickOnNavigatorBottomLeft);
|
||||
};
|
||||
|
||||
var assessAfterClickOnNavigatorTopRight = function() {
|
||||
assessNavigatorDisplayRegionAndMainViewerState("After click on navigator on top right");
|
||||
assessViewerInCorner("TOPRIGHT");
|
||||
dragNavigatorBackToCenter();
|
||||
waitForViewer(assessAfterDragNavigatorFromTopRight);
|
||||
};
|
||||
|
||||
var assessAfterDragOnViewer = function () {
|
||||
assessNavigatorDisplayRegionAndMainViewerState("After pan");
|
||||
clickOnNavigator("TOPRIGHT");
|
||||
waitForViewer(assessAfterClickOnNavigatorTopRight);
|
||||
navigatorInteractionOperations[0]();
|
||||
waitForViewer(assessNavigatorOperationAndTakeNextStep(0));
|
||||
};
|
||||
|
||||
var assessAfterZoomOnViewer = function () {
|
||||
|
Loading…
Reference in New Issue
Block a user