2017-12-05 03:45:44 +03:00
|
|
|
/* global QUnit, Util */
|
|
|
|
|
2013-05-09 22:03:31 +04:00
|
|
|
(function() {
|
|
|
|
|
2013-05-13 21:50:43 +04:00
|
|
|
// This module tests whether our various file formats can be opened.
|
|
|
|
// TODO: Add more file formats (with corresponding test data).
|
|
|
|
|
2023-06-27 04:29:08 +03:00
|
|
|
var viewer = null;
|
|
|
|
|
2017-12-05 03:45:44 +03:00
|
|
|
QUnit.module('Formats', {
|
|
|
|
beforeEach: function () {
|
2013-07-02 02:17:45 +04:00
|
|
|
var example = document.createElement("div");
|
|
|
|
example.id = "example";
|
|
|
|
document.getElementById("qunit-fixture").appendChild(example);
|
2023-06-27 04:29:08 +03:00
|
|
|
},
|
|
|
|
afterEach: function () {
|
|
|
|
if ( viewer && viewer.close ) {
|
|
|
|
viewer.close();
|
|
|
|
}
|
|
|
|
if (viewer && viewer.destroy){
|
|
|
|
viewer.destroy();
|
|
|
|
}
|
|
|
|
|
|
|
|
viewer = null;
|
2013-07-02 02:17:45 +04:00
|
|
|
}
|
|
|
|
});
|
2013-05-09 22:03:31 +04:00
|
|
|
|
|
|
|
|
|
|
|
// ----------
|
2017-12-05 03:45:44 +03:00
|
|
|
var testOpenUrl = function(relativeUrl, assert) {
|
|
|
|
testOpen('/test/data/' + relativeUrl, assert);
|
2015-07-30 23:44:41 +03:00
|
|
|
};
|
|
|
|
|
2017-12-05 03:45:44 +03:00
|
|
|
var testOpen = function(tileSource, assert) {
|
2017-12-07 04:20:39 +03:00
|
|
|
var timeWatcher = Util.timeWatcher(assert, 7000);
|
2017-12-05 03:45:44 +03:00
|
|
|
|
|
|
|
viewer = OpenSeadragon({
|
|
|
|
id: 'example',
|
|
|
|
prefixUrl: '/build/openseadragon/images/',
|
|
|
|
tileSources: tileSource
|
2013-05-09 22:03:31 +04:00
|
|
|
});
|
2017-12-05 03:45:44 +03:00
|
|
|
|
|
|
|
assert.ok(viewer, 'Viewer exists');
|
|
|
|
|
|
|
|
var openHandler = function(event) {
|
|
|
|
viewer.removeHandler('open', openHandler);
|
|
|
|
assert.ok(true, 'Open event was sent');
|
2023-06-27 20:57:02 +03:00
|
|
|
viewer.addHandler('tiled-image-drawn', tileDrawnHandler);
|
2017-12-05 03:45:44 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
var tileDrawnHandler = function(event) {
|
2023-06-27 20:57:02 +03:00
|
|
|
viewer.removeHandler('tiled-image-drawn', tileDrawnHandler);
|
|
|
|
assert.ok(true, 'A tiled image has been drawn');
|
2017-12-05 03:45:44 +03:00
|
|
|
viewer.addHandler('close', closeHandler);
|
|
|
|
viewer.close();
|
|
|
|
};
|
|
|
|
|
|
|
|
var closeHandler = function(event) {
|
|
|
|
viewer.removeHandler('close', closeHandler);
|
|
|
|
$('#example').empty();
|
|
|
|
assert.ok(true, 'Close event was sent');
|
|
|
|
timeWatcher.done();
|
|
|
|
};
|
|
|
|
viewer.addHandler('open', openHandler);
|
2013-05-13 21:50:43 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
// ----------
|
2017-12-05 03:45:44 +03:00
|
|
|
QUnit.test('DZI', function(assert) {
|
|
|
|
testOpenUrl('testpattern.dzi', assert);
|
2013-05-09 22:03:31 +04:00
|
|
|
});
|
|
|
|
|
|
|
|
// ----------
|
2017-12-05 03:45:44 +03:00
|
|
|
QUnit.test('DZI JSONp', function(assert) {
|
|
|
|
testOpenUrl('testpattern.js', assert);
|
2013-05-10 22:32:43 +04:00
|
|
|
});
|
2013-05-13 21:50:43 +04:00
|
|
|
|
|
|
|
// ----------
|
2017-12-05 03:45:44 +03:00
|
|
|
QUnit.test('DZI XML', function(assert) {
|
|
|
|
testOpenUrl('testpattern.xml', assert);
|
2013-05-13 21:50:43 +04:00
|
|
|
});
|
|
|
|
|
2013-09-27 01:24:02 +04:00
|
|
|
// ----------
|
2017-12-05 03:45:44 +03:00
|
|
|
QUnit.test('DZI XML with query parameter', function(assert) {
|
|
|
|
testOpenUrl('testpattern.xml?param=value', assert);
|
2014-04-11 00:08:19 +04:00
|
|
|
});
|
|
|
|
|
|
|
|
// ----------
|
2017-12-05 03:45:44 +03:00
|
|
|
QUnit.test('IIIF 1.0 JSON', function(assert) {
|
|
|
|
testOpenUrl('iiif_1_0_files/info.json', assert);
|
2013-09-27 01:24:02 +04:00
|
|
|
});
|
|
|
|
|
2013-10-01 03:42:16 +04:00
|
|
|
// ----------
|
2017-12-05 03:45:44 +03:00
|
|
|
QUnit.test('IIIF 1.0 XML', function(assert) {
|
|
|
|
testOpenUrl('iiif_1_0_files/info.xml', assert);
|
2013-10-01 03:42:16 +04:00
|
|
|
});
|
2013-09-27 01:24:02 +04:00
|
|
|
|
2013-10-01 03:42:16 +04:00
|
|
|
// ----------
|
2017-12-05 03:45:44 +03:00
|
|
|
QUnit.test('IIIF 1.1 JSON', function(assert) {
|
|
|
|
testOpenUrl('iiif_1_1_tiled/info.json', assert);
|
2013-10-01 03:42:16 +04:00
|
|
|
});
|
2013-09-27 01:24:02 +04:00
|
|
|
|
2014-01-03 04:59:10 +04:00
|
|
|
// ----------
|
2017-12-05 03:45:44 +03:00
|
|
|
QUnit.test('IIIF No Tiles, Less than 256', function(assert) {
|
|
|
|
testOpenUrl('iiif_1_1_no_tiles_255/info.json', assert);
|
2014-01-03 04:59:10 +04:00
|
|
|
});
|
|
|
|
|
|
|
|
// ----------
|
2017-12-05 03:45:44 +03:00
|
|
|
QUnit.test('IIIF No Tiles, Bet. 256 and 512', function(assert) {
|
|
|
|
testOpenUrl('iiif_1_1_no_tiles_384/info.json', assert);
|
2014-01-03 04:59:10 +04:00
|
|
|
});
|
|
|
|
|
|
|
|
// ----------
|
2017-12-05 03:45:44 +03:00
|
|
|
QUnit.test('IIIF No Tiles, Bet. 512 and 1024', function(assert) {
|
|
|
|
testOpenUrl('iiif_1_1_no_tiles_768/info.json', assert);
|
2014-01-03 04:59:10 +04:00
|
|
|
});
|
|
|
|
|
|
|
|
// ----------
|
2017-12-05 03:45:44 +03:00
|
|
|
QUnit.test('IIIF No Tiles, Larger than 1024', function(assert) {
|
|
|
|
testOpenUrl('iiif_1_1_no_tiles_1048/info.json', assert);
|
2013-11-18 21:52:55 +04:00
|
|
|
});
|
|
|
|
|
2014-07-28 23:45:52 +04:00
|
|
|
// ----------
|
2017-12-05 03:45:44 +03:00
|
|
|
QUnit.test('IIIF 2.0 JSON', function(assert) {
|
|
|
|
testOpenUrl('iiif_2_0_tiled/info.json', assert);
|
2015-07-30 23:44:41 +03:00
|
|
|
});
|
|
|
|
|
2018-02-16 23:14:28 +03:00
|
|
|
// ----------
|
|
|
|
QUnit.test('IIIF 2.0 JSON scaleFactors [1]', function(assert) {
|
|
|
|
testOpenUrl('iiif_2_0_tiled_sf1/info.json', assert);
|
|
|
|
});
|
|
|
|
|
2015-12-14 00:32:21 +03:00
|
|
|
// ----------
|
2017-12-05 03:45:44 +03:00
|
|
|
QUnit.test('IIIF 2.0 JSON, sizes array only', function(assert) {
|
|
|
|
testOpenUrl('iiif_2_0_sizes/info.json', assert);
|
2015-12-14 00:32:21 +03:00
|
|
|
});
|
|
|
|
|
2015-07-30 23:44:41 +03:00
|
|
|
// ----------
|
2017-12-05 03:45:44 +03:00
|
|
|
QUnit.test('IIIF 2.0 JSON String', function(assert) {
|
2015-07-30 23:44:41 +03:00
|
|
|
testOpen(
|
|
|
|
'{' +
|
|
|
|
' "@context": "http://iiif.io/api/image/2/context.json",' +
|
|
|
|
' "@id": "http://localhost:8000/test/data/iiif_2_0_tiled",' +
|
|
|
|
' "protocol": "http://iiif.io/api/image",' +
|
|
|
|
' "height": 1024,' +
|
|
|
|
' "width": 775,' +
|
|
|
|
' "tiles" : [{"width":256, "scaleFactors":[1,2,4,8]}],' +
|
|
|
|
' "profile": ["http://iiif.io/api/image/2/level1.json",' +
|
|
|
|
' {' +
|
|
|
|
' "qualities": [' +
|
|
|
|
' "native",' +
|
|
|
|
' "bitonal",' +
|
|
|
|
' "grey",' +
|
|
|
|
' "color"' +
|
|
|
|
' ],' +
|
|
|
|
' "formats": [' +
|
|
|
|
' "jpg",' +
|
|
|
|
' "png",' +
|
|
|
|
' "gif"' +
|
|
|
|
' ]' +
|
|
|
|
' }' +
|
|
|
|
' ]' +
|
2017-12-05 03:45:44 +03:00
|
|
|
'}', assert);
|
2015-06-11 17:49:32 +03:00
|
|
|
});
|
2014-07-28 23:45:52 +04:00
|
|
|
|
2022-06-16 13:58:41 +03:00
|
|
|
QUnit.test('IIIF 3.0 JSON', function(assert) {
|
|
|
|
testOpenUrl('iiif_3_0_tiled/info.json', assert);
|
|
|
|
});
|
|
|
|
|
|
|
|
// ----------
|
|
|
|
QUnit.test('IIIF 3.0 JSON scaleFactors [1]', function(assert) {
|
|
|
|
testOpenUrl('iiif_3_0_tiled_sf1/info.json', assert);
|
|
|
|
});
|
|
|
|
|
|
|
|
// ----------
|
|
|
|
QUnit.test('IIIF 3.0 JSON, sizes array only', function(assert) {
|
|
|
|
testOpenUrl('iiif_3_0_sizes/info.json', assert);
|
|
|
|
});
|
|
|
|
|
2015-11-01 18:23:02 +03:00
|
|
|
// ----------
|
2017-12-05 03:45:44 +03:00
|
|
|
QUnit.test('ImageTileSource', function(assert) {
|
2015-11-01 18:23:02 +03:00
|
|
|
testOpen({
|
|
|
|
type: "image",
|
|
|
|
url: "/test/data/A.png"
|
2017-12-05 03:45:44 +03:00
|
|
|
}, assert);
|
2015-11-01 18:23:02 +03:00
|
|
|
});
|
2016-02-25 13:51:16 +03:00
|
|
|
// ----------
|
2017-12-05 03:45:44 +03:00
|
|
|
QUnit.test('Zoomify', function(assert) {
|
2016-02-25 13:51:16 +03:00
|
|
|
testOpen({
|
2017-12-05 03:45:44 +03:00
|
|
|
type: "zoomifytileservice",
|
2016-02-25 13:51:16 +03:00
|
|
|
tileSize: 256,
|
|
|
|
width: 1000,
|
|
|
|
height: 1000,
|
|
|
|
tilesUrl: "/test/data/zoomify/"
|
2017-12-05 03:45:44 +03:00
|
|
|
}, assert);
|
|
|
|
});
|
|
|
|
|
|
|
|
|
2015-12-14 00:32:21 +03:00
|
|
|
// ----------
|
2017-12-05 03:45:44 +03:00
|
|
|
QUnit.test('Legacy Image Pyramid', function(assert) {
|
2015-12-14 00:32:21 +03:00
|
|
|
// Although it is using image paths that happen to be in IIIF format, this is not a IIIFTileSource.
|
|
|
|
// The url values are opaque, just image locations.
|
2017-12-05 03:45:44 +03:00
|
|
|
// When emulating a legacy pyramid, IIIFTileSource calls functions from LegacyTileSource, so this
|
2015-12-14 00:32:21 +03:00
|
|
|
// adds a test for the legacy functionality too.
|
|
|
|
testOpen({
|
|
|
|
type: 'legacy-image-pyramid',
|
2017-12-05 03:45:44 +03:00
|
|
|
levels: [{
|
2015-12-14 00:32:21 +03:00
|
|
|
url: '/test/data/iiif_2_0_sizes/full/400,/0/default.jpg',
|
|
|
|
height: 291,
|
|
|
|
width: 400
|
2017-12-05 03:45:44 +03:00
|
|
|
}, {
|
2015-12-14 00:32:21 +03:00
|
|
|
url: '/test/data/iiif_2_0_sizes/full/800,/0/default.jpg',
|
|
|
|
height: 582,
|
|
|
|
width: 800
|
2017-12-05 03:45:44 +03:00
|
|
|
}, {
|
2015-12-14 00:32:21 +03:00
|
|
|
url: '/test/data/iiif_2_0_sizes/full/1600,/0/default.jpg',
|
|
|
|
height: 1164,
|
|
|
|
width: 1600
|
2017-12-05 03:45:44 +03:00
|
|
|
}, {
|
2015-12-14 00:32:21 +03:00
|
|
|
url: '/test/data/iiif_2_0_sizes/full/3200,/0/default.jpg',
|
|
|
|
height: 2328,
|
|
|
|
width: 3200
|
2017-12-05 03:45:44 +03:00
|
|
|
}, {
|
2015-12-14 00:32:21 +03:00
|
|
|
url: '/test/data/iiif_2_0_sizes/full/6976,/0/default.jpg',
|
|
|
|
height: 5074,
|
|
|
|
width: 6976
|
|
|
|
}]
|
2017-12-05 03:45:44 +03:00
|
|
|
}, assert);
|
2015-12-14 00:32:21 +03:00
|
|
|
});
|
2015-11-01 18:23:02 +03:00
|
|
|
|
2013-05-09 22:03:31 +04:00
|
|
|
})();
|