2017-12-07 04:20:39 +03:00
|
|
|
/* global QUnit, $, testLog */
|
2017-05-12 07:36:27 +03:00
|
|
|
|
|
|
|
(function() {
|
|
|
|
var viewer,
|
|
|
|
baseOptions = {
|
|
|
|
id: 'example',
|
|
|
|
prefixUrl: '/build/openseadragon/images/',
|
|
|
|
springStiffness: 100 // Faster animation = faster tests
|
|
|
|
};
|
|
|
|
|
2017-12-07 04:20:39 +03:00
|
|
|
QUnit.module('ImageLoader', {
|
|
|
|
beforeEach: function () {
|
|
|
|
$('<div id="example"></div>').appendTo("#qunit-fixture");
|
2017-05-12 07:36:27 +03:00
|
|
|
|
|
|
|
testLog.reset();
|
|
|
|
},
|
2017-12-07 04:20:39 +03:00
|
|
|
afterEach: function () {
|
2024-01-10 20:13:00 +03:00
|
|
|
if (viewer){
|
2024-01-19 00:05:35 +03:00
|
|
|
viewer.destroy();
|
|
|
|
}
|
2017-05-12 07:36:27 +03:00
|
|
|
|
|
|
|
viewer = null;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
// ----------
|
|
|
|
|
2017-12-07 04:20:39 +03:00
|
|
|
QUnit.test('Default timeout', function(assert) {
|
2017-05-12 07:36:27 +03:00
|
|
|
var actual,
|
|
|
|
expected = OpenSeadragon.DEFAULT_SETTINGS.timeout,
|
|
|
|
message,
|
|
|
|
options = OpenSeadragon.extend(true, baseOptions, {
|
|
|
|
imageLoaderLimit: 1
|
2017-12-07 04:20:39 +03:00
|
|
|
}),
|
2017-05-12 07:36:27 +03:00
|
|
|
viewer = OpenSeadragon(options),
|
|
|
|
imageLoader = viewer.imageLoader;
|
|
|
|
|
|
|
|
message = 'ImageLoader timeout should be set to the default value of ' + expected + ' when none is specified';
|
|
|
|
actual = imageLoader.timeout;
|
2017-12-07 04:20:39 +03:00
|
|
|
assert.equal(actual, expected, message);
|
2017-05-12 07:36:27 +03:00
|
|
|
|
|
|
|
// Manually seize the ImageLoader
|
|
|
|
imageLoader.jobsInProgress = imageLoader.jobLimit;
|
|
|
|
imageLoader.addJob({
|
|
|
|
src: 'test',
|
|
|
|
loadWithAjax: false,
|
|
|
|
crossOriginPolicy: 'test',
|
|
|
|
ajaxWithCredentials: false,
|
|
|
|
abort: function() {}
|
|
|
|
});
|
|
|
|
|
|
|
|
message = 'ImageJob should inherit the ImageLoader timeout value';
|
|
|
|
actual = imageLoader.jobQueue.shift().timeout;
|
2017-12-07 04:20:39 +03:00
|
|
|
assert.equal(actual, expected, message);
|
2017-05-12 07:36:27 +03:00
|
|
|
});
|
|
|
|
|
|
|
|
// ----------
|
2017-12-07 04:20:39 +03:00
|
|
|
|
|
|
|
QUnit.test('Configure timeout', function(assert) {
|
2017-05-12 07:36:27 +03:00
|
|
|
var actual,
|
|
|
|
expected = 123456,
|
|
|
|
message,
|
|
|
|
options = OpenSeadragon.extend(true, baseOptions, {
|
|
|
|
imageLoaderLimit: 1,
|
|
|
|
timeout: expected
|
|
|
|
}),
|
|
|
|
viewer = OpenSeadragon(options),
|
|
|
|
imageLoader = viewer.imageLoader;
|
|
|
|
|
|
|
|
message = 'ImageLoader timeout should be configurable';
|
|
|
|
actual = imageLoader.timeout;
|
2017-12-07 04:20:39 +03:00
|
|
|
assert.equal(actual, expected, message);
|
2017-05-12 07:36:27 +03:00
|
|
|
|
|
|
|
imageLoader.jobsInProgress = imageLoader.jobLimit;
|
|
|
|
imageLoader.addJob({
|
|
|
|
src: 'test',
|
|
|
|
loadWithAjax: false,
|
|
|
|
crossOriginPolicy: 'test',
|
|
|
|
ajaxWithCredentials: false,
|
|
|
|
abort: function() {}
|
|
|
|
});
|
|
|
|
|
|
|
|
message = 'ImageJob should inherit the ImageLoader timeout value';
|
|
|
|
actual = imageLoader.jobQueue.shift().timeout;
|
2017-12-07 04:20:39 +03:00
|
|
|
assert.equal(actual, expected, message);
|
2017-05-12 07:36:27 +03:00
|
|
|
});
|
|
|
|
|
|
|
|
})();
|