mirror of
https://github.com/openseadragon/openseadragon.git
synced 2024-11-26 07:06: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 () {
|
var waitForViewer = function () {
|
||||||
return function () {
|
|
||||||
return function (handler, count, lastDisplayRegionLeft, lastDisplayWidth) {
|
return function (handler, count, lastDisplayRegionLeft, lastDisplayWidth) {
|
||||||
|
// return function () {
|
||||||
var currentDisplayRegionLeft;
|
var currentDisplayRegionLeft;
|
||||||
var currentDisplayWidth;
|
var currentDisplayWidth;
|
||||||
if (displayRegion === null)
|
if (displayRegion === null)
|
||||||
@ -178,7 +178,7 @@ QUnit.config.autostart = false;
|
|||||||
handler();
|
handler();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}();
|
// }();
|
||||||
}();
|
}();
|
||||||
|
|
||||||
var simulateNavigatorClick = function(viewer, locationX, locationY) {
|
var simulateNavigatorClick = function(viewer, locationX, locationY) {
|
||||||
@ -207,6 +207,8 @@ QUnit.config.autostart = false;
|
|||||||
};
|
};
|
||||||
|
|
||||||
var assessViewerInCorner = function(theContentCorner)
|
var assessViewerInCorner = function(theContentCorner)
|
||||||
|
{
|
||||||
|
return function()
|
||||||
{
|
{
|
||||||
var expectedXCoordinate, expecteYCoordinate;
|
var expectedXCoordinate, expecteYCoordinate;
|
||||||
if (theContentCorner === "TOPLEFT")
|
if (theContentCorner === "TOPLEFT")
|
||||||
@ -237,6 +239,7 @@ QUnit.config.autostart = false;
|
|||||||
{
|
{
|
||||||
assessNumericValueWithSomeVariance(expecteYCoordinate, viewer.viewport.getBounds().y,.04, ' Viewer at ' + theContentCorner + ', y coord');
|
assessNumericValueWithSomeVariance(expecteYCoordinate, viewer.viewport.getBounds().y,.04, ' Viewer at ' + theContentCorner + ', y coord');
|
||||||
}
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
var assessViewerInCenter = function()
|
var assessViewerInCenter = function()
|
||||||
@ -252,6 +255,8 @@ QUnit.config.autostart = false;
|
|||||||
|
|
||||||
|
|
||||||
var clickOnNavigator = function(theContentCorner)
|
var clickOnNavigator = function(theContentCorner)
|
||||||
|
{
|
||||||
|
return function()
|
||||||
{
|
{
|
||||||
var xPos, yPos;
|
var xPos, yPos;
|
||||||
if (theContentCorner === "TOPLEFT")
|
if (theContentCorner === "TOPLEFT")
|
||||||
@ -275,6 +280,7 @@ QUnit.config.autostart = false;
|
|||||||
yPos = spaceFromTopEdgeOfViewerToContentStart + heightOfViewerContentOnNavigator;
|
yPos = spaceFromTopEdgeOfViewerToContentStart + heightOfViewerContentOnNavigator;
|
||||||
}
|
}
|
||||||
simulateNavigatorClick(viewer.navigator, xPos, yPos);
|
simulateNavigatorClick(viewer.navigator, xPos, yPos);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
var dragNavigatorBackToCenter = function()
|
var dragNavigatorBackToCenter = function()
|
||||||
@ -296,65 +302,43 @@ QUnit.config.autostart = false;
|
|||||||
seadragonProperties.visibilityRatio = 1;
|
seadragonProperties.visibilityRatio = 1;
|
||||||
viewer = OpenSeadragon(seadragonProperties);
|
viewer = OpenSeadragon(seadragonProperties);
|
||||||
|
|
||||||
var assessAfterDragNavigatorFromTopLeft = function() {
|
var navigatorInteractionOperations = [ clickOnNavigator("TOPRIGHT"),dragNavigatorBackToCenter,
|
||||||
assessNavigatorDisplayRegionAndMainViewerState("After drag on navigator from top left");
|
clickOnNavigator("BOTTOMLEFT"),dragNavigatorBackToCenter,
|
||||||
assessViewerInCenter();
|
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();
|
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 () {
|
var assessAfterDragOnViewer = function () {
|
||||||
assessNavigatorDisplayRegionAndMainViewerState("After pan");
|
assessNavigatorDisplayRegionAndMainViewerState("After pan");
|
||||||
clickOnNavigator("TOPRIGHT");
|
navigatorInteractionOperations[0]();
|
||||||
waitForViewer(assessAfterClickOnNavigatorTopRight);
|
waitForViewer(assessNavigatorOperationAndTakeNextStep(0));
|
||||||
};
|
};
|
||||||
|
|
||||||
var assessAfterZoomOnViewer = function () {
|
var assessAfterZoomOnViewer = function () {
|
||||||
|
Loading…
Reference in New Issue
Block a user