2013-05-09 11:03:31 -07:00
|
|
|
(function() {
|
|
|
|
|
2013-05-13 10:50:43 -07:00
|
|
|
// This module tests whether our various file formats can be opened.
|
|
|
|
// TODO: Add more file formats (with corresponding test data).
|
|
|
|
|
2013-07-01 18:17:45 -04:00
|
|
|
module('Formats', {
|
|
|
|
setup: function () {
|
|
|
|
var example = document.createElement("div");
|
|
|
|
example.id = "example";
|
|
|
|
document.getElementById("qunit-fixture").appendChild(example);
|
|
|
|
}
|
|
|
|
});
|
2013-05-09 11:03:31 -07:00
|
|
|
|
|
|
|
var viewer = null;
|
|
|
|
|
|
|
|
// ----------
|
2015-07-30 16:44:41 -04:00
|
|
|
var testOpenUrl = function(relativeUrl) {
|
|
|
|
testOpen('/test/data/' + relativeUrl);
|
|
|
|
};
|
|
|
|
|
|
|
|
var testOpen = function(tileSource) {
|
2013-05-09 11:03:31 -07:00
|
|
|
$(document).ready(function() {
|
2013-05-17 22:29:08 -04:00
|
|
|
var timeWatcher = Util.timeWatcher(7000);
|
2013-05-10 11:53:49 -07:00
|
|
|
|
2013-05-09 11:03:31 -07:00
|
|
|
viewer = OpenSeadragon({
|
|
|
|
id: 'example',
|
|
|
|
prefixUrl: '/build/openseadragon/images/',
|
2015-07-30 16:44:41 -04:00
|
|
|
tileSources: tileSource
|
2013-05-09 11:03:31 -07:00
|
|
|
});
|
|
|
|
|
|
|
|
ok(viewer, 'Viewer exists');
|
|
|
|
|
2013-10-10 17:00:15 -07:00
|
|
|
var openHandler = function(event) {
|
2013-05-09 11:03:31 -07:00
|
|
|
viewer.removeHandler('open', openHandler);
|
|
|
|
ok(true, 'Open event was sent');
|
|
|
|
viewer.addHandler('tile-drawn', tileDrawnHandler);
|
|
|
|
};
|
|
|
|
|
2013-10-10 17:00:15 -07:00
|
|
|
var tileDrawnHandler = function(event) {
|
2013-05-09 11:03:31 -07:00
|
|
|
viewer.removeHandler('tile-drawn', tileDrawnHandler);
|
|
|
|
ok(true, 'A tile has been drawn');
|
2013-05-13 10:50:43 -07:00
|
|
|
viewer.addHandler('close', closeHandler);
|
|
|
|
viewer.close();
|
|
|
|
};
|
|
|
|
|
2013-10-10 17:00:15 -07:00
|
|
|
var closeHandler = function(event) {
|
2013-05-13 10:50:43 -07:00
|
|
|
viewer.removeHandler('close', closeHandler);
|
|
|
|
$('#example').empty();
|
|
|
|
ok(true, 'Close event was sent');
|
2013-05-10 11:53:49 -07:00
|
|
|
timeWatcher.done();
|
2013-05-09 11:03:31 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
viewer.addHandler('open', openHandler);
|
|
|
|
});
|
2013-05-13 10:50:43 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
// ----------
|
|
|
|
asyncTest('DZI', function() {
|
2015-07-30 16:44:41 -04:00
|
|
|
testOpenUrl('testpattern.dzi');
|
2013-05-09 11:03:31 -07:00
|
|
|
});
|
|
|
|
|
|
|
|
// ----------
|
2013-05-13 10:50:43 -07:00
|
|
|
asyncTest('DZI JSONp', function() {
|
2015-07-30 16:44:41 -04:00
|
|
|
testOpenUrl('testpattern.js');
|
2013-05-10 11:32:43 -07:00
|
|
|
});
|
2013-05-13 10:50:43 -07:00
|
|
|
|
|
|
|
// ----------
|
|
|
|
asyncTest('DZI XML', function() {
|
2015-07-30 16:44:41 -04:00
|
|
|
testOpenUrl('testpattern.xml');
|
2013-05-13 10:50:43 -07:00
|
|
|
});
|
|
|
|
|
2013-09-26 17:24:02 -04:00
|
|
|
// ----------
|
2014-04-10 14:08:19 -06:00
|
|
|
asyncTest('DZI XML with query parameter', function() {
|
2015-07-30 16:44:41 -04:00
|
|
|
testOpenUrl('testpattern.xml?param=value');
|
2014-04-10 14:08:19 -06:00
|
|
|
});
|
|
|
|
|
|
|
|
// ----------
|
2013-09-30 19:42:16 -04:00
|
|
|
asyncTest('IIIF 1.0 JSON', function() {
|
2015-07-30 16:44:41 -04:00
|
|
|
testOpenUrl('iiif_1_0_files/info.json');
|
2013-09-26 17:24:02 -04:00
|
|
|
});
|
|
|
|
|
2013-09-30 19:42:16 -04:00
|
|
|
// ----------
|
|
|
|
asyncTest('IIIF 1.0 XML', function() {
|
2015-07-30 16:44:41 -04:00
|
|
|
testOpenUrl('iiif_1_0_files/info.xml');
|
2013-09-30 19:42:16 -04:00
|
|
|
});
|
2013-09-26 17:24:02 -04:00
|
|
|
|
2013-09-30 19:42:16 -04:00
|
|
|
// ----------
|
|
|
|
asyncTest('IIIF 1.1 JSON', function() {
|
2015-07-30 16:44:41 -04:00
|
|
|
testOpenUrl('iiif_1_1_tiled/info.json');
|
2013-09-30 19:42:16 -04:00
|
|
|
});
|
2013-09-26 17:24:02 -04:00
|
|
|
|
2014-01-02 19:59:10 -05:00
|
|
|
// ----------
|
|
|
|
asyncTest('IIIF No Tiles, Less than 256', function() {
|
2015-07-30 16:44:41 -04:00
|
|
|
testOpenUrl('iiif_1_1_no_tiles_255/info.json');
|
2014-01-02 19:59:10 -05:00
|
|
|
});
|
|
|
|
|
|
|
|
// ----------
|
|
|
|
asyncTest('IIIF No Tiles, Bet. 256 and 512', function() {
|
2015-07-30 16:44:41 -04:00
|
|
|
testOpenUrl('iiif_1_1_no_tiles_384/info.json');
|
2014-01-02 19:59:10 -05:00
|
|
|
});
|
|
|
|
|
|
|
|
// ----------
|
|
|
|
asyncTest('IIIF No Tiles, Bet. 512 and 1024', function() {
|
2015-07-30 16:44:41 -04:00
|
|
|
testOpenUrl('iiif_1_1_no_tiles_768/info.json');
|
2014-01-02 19:59:10 -05:00
|
|
|
});
|
|
|
|
|
|
|
|
// ----------
|
|
|
|
asyncTest('IIIF No Tiles, Larger than 1024', function() {
|
2015-07-30 16:44:41 -04:00
|
|
|
testOpenUrl('iiif_1_1_no_tiles_1048/info.json');
|
2013-11-18 12:52:55 -05:00
|
|
|
});
|
|
|
|
|
2014-07-28 12:45:52 -07:00
|
|
|
// ----------
|
|
|
|
asyncTest('IIIF 2.0 JSON', function() {
|
2015-07-30 16:44:41 -04:00
|
|
|
testOpenUrl('iiif_2_0_tiled/info.json');
|
|
|
|
});
|
|
|
|
|
|
|
|
// ----------
|
|
|
|
asyncTest('IIIF 2.0 JSON String', function() {
|
|
|
|
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"' +
|
|
|
|
' ]' +
|
|
|
|
' }' +
|
|
|
|
' ]' +
|
|
|
|
'}');
|
2015-06-11 10:49:32 -04:00
|
|
|
});
|
2014-07-28 12:45:52 -07:00
|
|
|
|
2013-05-09 11:03:31 -07:00
|
|
|
})();
|