Fixed a test that would fail if not scrolled to the top. Improved test speed. Changed some variables to better echo corresponding variables in the application code

This commit is contained in:
houseofyin 2013-06-07 10:25:26 -04:00
parent 8a3ec97596
commit 867e6de85a

View File

@ -16,6 +16,8 @@ QUnit.config.autostart = false;
setup:function () { setup:function () {
Util.resetDom(); Util.resetDom();
resetTestVariables(); resetTestVariables();
$(document).scrollTop(0);
$(document).scrollLeft(0);
}, },
teardown:function () { teardown:function () {
Util.resetDom(); Util.resetDom();
@ -154,6 +156,7 @@ QUnit.config.autostart = false;
}(); }();
var simulateNavigatorClick = function (viewer, locationX, locationY) { var simulateNavigatorClick = function (viewer, locationX, locationY) {
//Assumes that the page has not been scrolled from the top or left
var $canvas = $(viewer.element).find('.openseadragon-canvas'), var $canvas = $(viewer.element).find('.openseadragon-canvas'),
offset = $canvas.offset(), offset = $canvas.offset(),
event = { event = {
@ -275,7 +278,7 @@ QUnit.config.autostart = false;
assessmentOperation:assessViewerInCenter, assessmentOperation:assessViewerInCenter,
assessmentMessage:"After drag on navigator from top left" } assessmentMessage:"After drag on navigator from top left" }
], ],
autoHideWaitTime = 3000; autoFadeWaitTime = 100;
seadragonProperties.visibilityRatio = 1; seadragonProperties.visibilityRatio = 1;
viewer = OpenSeadragon(seadragonProperties); viewer = OpenSeadragon(seadragonProperties);
@ -317,12 +320,12 @@ QUnit.config.autostart = false;
waitForViewer(assessAfterZoomOnViewer); waitForViewer(assessAfterZoomOnViewer);
}; };
var assessAutohideTriggered = function () { var assessAutoFadeTriggered = function () {
ok($(testProperties.navigatorLocator).parent().css("opacity") == 0, "Expecting navigator to be autohide when in the default location"); ok($(testProperties.navigatorLocator).parent().css("opacity") < 1, "Expecting navigator to be autofade when in the default location");
waitForViewer(captureInitialStateThenAct); waitForViewer(captureInitialStateThenAct);
}; };
var assessAutohideDisabled = function () { var assessAutoFadeDisabled = function () {
ok($(testProperties.navigatorLocator).parent().css("opacity") > 0, "Expecting navigator to be always visible when in a custom location"); ok($(testProperties.navigatorLocator).parent().css("opacity") > 0, "Expecting navigator to be always visible when in a custom location");
waitForViewer(captureInitialStateThenAct); waitForViewer(captureInitialStateThenAct);
}; };
@ -338,12 +341,12 @@ QUnit.config.autostart = false;
clientX:1, clientX:1,
clientY:1 clientY:1
}; };
var body = $("body").simulate('mouseover', event); mainViewerElement.simulate('blur', event);
if (testProperties.expectedAutoHide) { if (testProperties.expectedAutoFade) {
setTimeout(assessAutohideTriggered,autoHideWaitTime); setTimeout(assessAutoFadeTriggered,autoFadeWaitTime);
} }
else { else {
setTimeout(assessAutohideDisabled,autoHideWaitTime); setTimeout(assessAutoFadeDisabled,autoFadeWaitTime);
} }
} }
}; };
@ -356,14 +359,12 @@ QUnit.config.autostart = false;
prefixUrl:'/build/openseadragon/images/', prefixUrl:'/build/openseadragon/images/',
tileSources:'/test/data/wide.dzi', tileSources:'/test/data/wide.dzi',
showNavigator:true, showNavigator:true,
animationTime:0, animationTime:0
controlsFadeDelay:0
}, },
{ {
displayRegionLocator:'.navigator .displayregion', displayRegionLocator:'.navigator .displayregion',
navigatorLocator:'.navigator', navigatorLocator:'.navigator',
testAutohide: false, testAutoFade: false,
expectedAutoHide: false,
determineExpectationsAndAssessNavigatorLocation:function (seadragonProperties, testProperties) { determineExpectationsAndAssessNavigatorLocation:function (seadragonProperties, testProperties) {
var mainViewerElement = $("#" + seadragonProperties.id), var mainViewerElement = $("#" + seadragonProperties.id),
navigatorElement = $(testProperties.navigatorLocator); navigatorElement = $(testProperties.navigatorLocator);
@ -380,14 +381,12 @@ QUnit.config.autostart = false;
prefixUrl:'/build/openseadragon/images/', prefixUrl:'/build/openseadragon/images/',
tileSources:'/test/data/wide.dzi', tileSources:'/test/data/wide.dzi',
showNavigator:true, showNavigator:true,
animationTime:0, animationTime:0
controlsFadeDelay:0
}, },
{ {
displayRegionLocator:'#exampleNavigator .displayregion', displayRegionLocator:'#exampleNavigator .displayregion',
navigatorLocator:'#exampleNavigator', navigatorLocator:'#exampleNavigator',
testAutohide: false, testAutoFade: false,
expectedAutoHide: true,
determineExpectationsAndAssessNavigatorLocation:function (seadragonProperties, testProperties) { determineExpectationsAndAssessNavigatorLocation:function (seadragonProperties, testProperties) {
var mainViewerElement = $("#" + seadragonProperties.id), var mainViewerElement = $("#" + seadragonProperties.id),
navigatorViewerElement = $("#" + seadragonProperties.navigatorId); navigatorViewerElement = $("#" + seadragonProperties.navigatorId);
@ -406,13 +405,14 @@ QUnit.config.autostart = false;
tileSources:'/test/data/tall.dzi', tileSources:'/test/data/tall.dzi',
showNavigator:true, showNavigator:true,
animationTime:0, animationTime:0,
controlsFadeDelay:0 controlsFadeDelay:0,
controlsFadeLength:1
}, },
{ {
displayRegionLocator:'#exampleNavigator .displayregion', displayRegionLocator:'#exampleNavigator .displayregion',
navigatorLocator:'#exampleNavigator', navigatorLocator:'#exampleNavigator',
testAutohide: true, testAutoFade: true,
expectedAutoHide: false, expectedAutoFade: false,
determineExpectationsAndAssessNavigatorLocation:function (seadragonProperties, testProperties) { determineExpectationsAndAssessNavigatorLocation:function (seadragonProperties, testProperties) {
var jqueryDialog = $(testProperties.navigatorLocator); var jqueryDialog = $(testProperties.navigatorLocator);
assessNavigatorLocation(jqueryDialog.offset().left, assessNavigatorLocation(jqueryDialog.offset().left,
@ -428,13 +428,14 @@ QUnit.config.autostart = false;
tileSources:'/test/data/tall.dzi', tileSources:'/test/data/tall.dzi',
showNavigator:true, showNavigator:true,
animationTime:0, animationTime:0,
controlsFadeDelay:0 controlsFadeDelay:0,
controlsFadeLength:1
}, },
{ {
displayRegionLocator:'.navigator .displayregion', displayRegionLocator:'.navigator .displayregion',
navigatorLocator:'.navigator', navigatorLocator:'.navigator',
testAutohide: true, testAutoFade: true,
expectedAutoHide: true, expectedAutoFade: true,
determineExpectationsAndAssessNavigatorLocation:function (seadragonProperties, testProperties) { determineExpectationsAndAssessNavigatorLocation:function (seadragonProperties, testProperties) {
var mainViewerElement = $("#" + seadragonProperties.id), var mainViewerElement = $("#" + seadragonProperties.id),
navigatorElement = $(testProperties.navigatorLocator); navigatorElement = $(testProperties.navigatorLocator);