mirror of
https://github.com/openseadragon/openseadragon.git
synced 2024-11-25 22:56:11 +03:00
Formats tests
This commit is contained in:
parent
c29715cbe8
commit
73be93b995
@ -1,10 +1,12 @@
|
|||||||
|
/* global QUnit, Util */
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
|
|
||||||
// This module tests whether our various file formats can be opened.
|
// This module tests whether our various file formats can be opened.
|
||||||
// TODO: Add more file formats (with corresponding test data).
|
// TODO: Add more file formats (with corresponding test data).
|
||||||
|
|
||||||
module('Formats', {
|
QUnit.module('Formats', {
|
||||||
setup: function () {
|
beforeEach: function () {
|
||||||
var example = document.createElement("div");
|
var example = document.createElement("div");
|
||||||
example.id = "example";
|
example.id = "example";
|
||||||
document.getElementById("qunit-fixture").appendChild(example);
|
document.getElementById("qunit-fixture").appendChild(example);
|
||||||
@ -14,13 +16,12 @@
|
|||||||
var viewer = null;
|
var viewer = null;
|
||||||
|
|
||||||
// ----------
|
// ----------
|
||||||
var testOpenUrl = function(relativeUrl) {
|
var testOpenUrl = function(relativeUrl, assert) {
|
||||||
testOpen('/test/data/' + relativeUrl);
|
testOpen('/test/data/' + relativeUrl, assert);
|
||||||
};
|
};
|
||||||
|
|
||||||
var testOpen = function(tileSource) {
|
var testOpen = function(tileSource, assert) {
|
||||||
$(document).ready(function() {
|
var timeWatcher = Util.timeWatcher(7000, assert);
|
||||||
var timeWatcher = Util.timeWatcher(7000);
|
|
||||||
|
|
||||||
viewer = OpenSeadragon({
|
viewer = OpenSeadragon({
|
||||||
id: 'example',
|
id: 'example',
|
||||||
@ -28,17 +29,17 @@
|
|||||||
tileSources: tileSource
|
tileSources: tileSource
|
||||||
});
|
});
|
||||||
|
|
||||||
ok(viewer, 'Viewer exists');
|
assert.ok(viewer, 'Viewer exists');
|
||||||
|
|
||||||
var openHandler = function(event) {
|
var openHandler = function(event) {
|
||||||
viewer.removeHandler('open', openHandler);
|
viewer.removeHandler('open', openHandler);
|
||||||
ok(true, 'Open event was sent');
|
assert.ok(true, 'Open event was sent');
|
||||||
viewer.addHandler('tile-drawn', tileDrawnHandler);
|
viewer.addHandler('tile-drawn', tileDrawnHandler);
|
||||||
};
|
};
|
||||||
|
|
||||||
var tileDrawnHandler = function(event) {
|
var tileDrawnHandler = function(event) {
|
||||||
viewer.removeHandler('tile-drawn', tileDrawnHandler);
|
viewer.removeHandler('tile-drawn', tileDrawnHandler);
|
||||||
ok(true, 'A tile has been drawn');
|
assert.ok(true, 'A tile has been drawn');
|
||||||
viewer.addHandler('close', closeHandler);
|
viewer.addHandler('close', closeHandler);
|
||||||
viewer.close();
|
viewer.close();
|
||||||
};
|
};
|
||||||
@ -46,81 +47,79 @@
|
|||||||
var closeHandler = function(event) {
|
var closeHandler = function(event) {
|
||||||
viewer.removeHandler('close', closeHandler);
|
viewer.removeHandler('close', closeHandler);
|
||||||
$('#example').empty();
|
$('#example').empty();
|
||||||
ok(true, 'Close event was sent');
|
assert.ok(true, 'Close event was sent');
|
||||||
timeWatcher.done();
|
timeWatcher.done();
|
||||||
};
|
};
|
||||||
|
|
||||||
viewer.addHandler('open', openHandler);
|
viewer.addHandler('open', openHandler);
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// ----------
|
// ----------
|
||||||
asyncTest('DZI', function() {
|
QUnit.test('DZI', function(assert) {
|
||||||
testOpenUrl('testpattern.dzi');
|
testOpenUrl('testpattern.dzi', assert);
|
||||||
});
|
});
|
||||||
|
|
||||||
// ----------
|
// ----------
|
||||||
asyncTest('DZI JSONp', function() {
|
QUnit.test('DZI JSONp', function(assert) {
|
||||||
testOpenUrl('testpattern.js');
|
testOpenUrl('testpattern.js', assert);
|
||||||
});
|
});
|
||||||
|
|
||||||
// ----------
|
// ----------
|
||||||
asyncTest('DZI XML', function() {
|
QUnit.test('DZI XML', function(assert) {
|
||||||
testOpenUrl('testpattern.xml');
|
testOpenUrl('testpattern.xml', assert);
|
||||||
});
|
});
|
||||||
|
|
||||||
// ----------
|
// ----------
|
||||||
asyncTest('DZI XML with query parameter', function() {
|
QUnit.test('DZI XML with query parameter', function(assert) {
|
||||||
testOpenUrl('testpattern.xml?param=value');
|
testOpenUrl('testpattern.xml?param=value', assert);
|
||||||
});
|
});
|
||||||
|
|
||||||
// ----------
|
// ----------
|
||||||
asyncTest('IIIF 1.0 JSON', function() {
|
QUnit.test('IIIF 1.0 JSON', function(assert) {
|
||||||
testOpenUrl('iiif_1_0_files/info.json');
|
testOpenUrl('iiif_1_0_files/info.json', assert);
|
||||||
});
|
});
|
||||||
|
|
||||||
// ----------
|
// ----------
|
||||||
asyncTest('IIIF 1.0 XML', function() {
|
QUnit.test('IIIF 1.0 XML', function(assert) {
|
||||||
testOpenUrl('iiif_1_0_files/info.xml');
|
testOpenUrl('iiif_1_0_files/info.xml', assert);
|
||||||
});
|
});
|
||||||
|
|
||||||
// ----------
|
// ----------
|
||||||
asyncTest('IIIF 1.1 JSON', function() {
|
QUnit.test('IIIF 1.1 JSON', function(assert) {
|
||||||
testOpenUrl('iiif_1_1_tiled/info.json');
|
testOpenUrl('iiif_1_1_tiled/info.json', assert);
|
||||||
});
|
});
|
||||||
|
|
||||||
// ----------
|
// ----------
|
||||||
asyncTest('IIIF No Tiles, Less than 256', function() {
|
QUnit.test('IIIF No Tiles, Less than 256', function(assert) {
|
||||||
testOpenUrl('iiif_1_1_no_tiles_255/info.json');
|
testOpenUrl('iiif_1_1_no_tiles_255/info.json', assert);
|
||||||
});
|
});
|
||||||
|
|
||||||
// ----------
|
// ----------
|
||||||
asyncTest('IIIF No Tiles, Bet. 256 and 512', function() {
|
QUnit.test('IIIF No Tiles, Bet. 256 and 512', function(assert) {
|
||||||
testOpenUrl('iiif_1_1_no_tiles_384/info.json');
|
testOpenUrl('iiif_1_1_no_tiles_384/info.json', assert);
|
||||||
});
|
});
|
||||||
|
|
||||||
// ----------
|
// ----------
|
||||||
asyncTest('IIIF No Tiles, Bet. 512 and 1024', function() {
|
QUnit.test('IIIF No Tiles, Bet. 512 and 1024', function(assert) {
|
||||||
testOpenUrl('iiif_1_1_no_tiles_768/info.json');
|
testOpenUrl('iiif_1_1_no_tiles_768/info.json', assert);
|
||||||
});
|
});
|
||||||
|
|
||||||
// ----------
|
// ----------
|
||||||
asyncTest('IIIF No Tiles, Larger than 1024', function() {
|
QUnit.test('IIIF No Tiles, Larger than 1024', function(assert) {
|
||||||
testOpenUrl('iiif_1_1_no_tiles_1048/info.json');
|
testOpenUrl('iiif_1_1_no_tiles_1048/info.json', assert);
|
||||||
});
|
});
|
||||||
|
|
||||||
// ----------
|
// ----------
|
||||||
asyncTest('IIIF 2.0 JSON', function() {
|
QUnit.test('IIIF 2.0 JSON', function(assert) {
|
||||||
testOpenUrl('iiif_2_0_tiled/info.json');
|
testOpenUrl('iiif_2_0_tiled/info.json', assert);
|
||||||
});
|
});
|
||||||
|
|
||||||
// ----------
|
// ----------
|
||||||
asyncTest('IIIF 2.0 JSON, sizes array only', function() {
|
QUnit.test('IIIF 2.0 JSON, sizes array only', function(assert) {
|
||||||
testOpenUrl('iiif_2_0_sizes/info.json');
|
testOpenUrl('iiif_2_0_sizes/info.json', assert);
|
||||||
});
|
});
|
||||||
|
|
||||||
// ----------
|
// ----------
|
||||||
asyncTest('IIIF 2.0 JSON String', function() {
|
QUnit.test('IIIF 2.0 JSON String', function(assert) {
|
||||||
testOpen(
|
testOpen(
|
||||||
'{' +
|
'{' +
|
||||||
' "@context": "http://iiif.io/api/image/2/context.json",' +
|
' "@context": "http://iiif.io/api/image/2/context.json",' +
|
||||||
@ -144,58 +143,58 @@
|
|||||||
' ]' +
|
' ]' +
|
||||||
' }' +
|
' }' +
|
||||||
' ]' +
|
' ]' +
|
||||||
'}');
|
'}', assert);
|
||||||
});
|
});
|
||||||
|
|
||||||
// ----------
|
// ----------
|
||||||
asyncTest('ImageTileSource', function () {
|
QUnit.test('ImageTileSource', function(assert) {
|
||||||
testOpen({
|
testOpen({
|
||||||
type: "image",
|
type: "image",
|
||||||
url: "/test/data/A.png"
|
url: "/test/data/A.png"
|
||||||
});
|
}, assert);
|
||||||
});
|
});
|
||||||
// ----------
|
// ----------
|
||||||
asyncTest('Zoomify', function () {
|
QUnit.test('Zoomify', function(assert) {
|
||||||
testOpen({
|
testOpen({
|
||||||
type: "zoomifytileservice",
|
type: "zoomifytileservice",
|
||||||
tileSize: 256,
|
tileSize: 256,
|
||||||
width: 1000,
|
width: 1000,
|
||||||
height: 1000,
|
height: 1000,
|
||||||
tilesUrl: "/test/data/zoomify/"
|
tilesUrl: "/test/data/zoomify/"
|
||||||
});
|
}, assert);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
// ----------
|
// ----------
|
||||||
asyncTest('Legacy Image Pyramid', function() {
|
QUnit.test('Legacy Image Pyramid', function(assert) {
|
||||||
// Although it is using image paths that happen to be in IIIF format, this is not a IIIFTileSource.
|
// 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.
|
// The url values are opaque, just image locations.
|
||||||
// When emulating a legacy pyramid, IIIFTileSource calls functions from LegacyTileSource, so this
|
// When emulating a legacy pyramid, IIIFTileSource calls functions from LegacyTileSource, so this
|
||||||
// adds a test for the legacy functionality too.
|
// adds a test for the legacy functionality too.
|
||||||
testOpen({
|
testOpen({
|
||||||
type: 'legacy-image-pyramid',
|
type: 'legacy-image-pyramid',
|
||||||
levels:[{
|
levels: [{
|
||||||
url: '/test/data/iiif_2_0_sizes/full/400,/0/default.jpg',
|
url: '/test/data/iiif_2_0_sizes/full/400,/0/default.jpg',
|
||||||
height: 291,
|
height: 291,
|
||||||
width: 400
|
width: 400
|
||||||
},{
|
}, {
|
||||||
url: '/test/data/iiif_2_0_sizes/full/800,/0/default.jpg',
|
url: '/test/data/iiif_2_0_sizes/full/800,/0/default.jpg',
|
||||||
height: 582,
|
height: 582,
|
||||||
width: 800
|
width: 800
|
||||||
},{
|
}, {
|
||||||
url: '/test/data/iiif_2_0_sizes/full/1600,/0/default.jpg',
|
url: '/test/data/iiif_2_0_sizes/full/1600,/0/default.jpg',
|
||||||
height: 1164,
|
height: 1164,
|
||||||
width: 1600
|
width: 1600
|
||||||
},{
|
}, {
|
||||||
url: '/test/data/iiif_2_0_sizes/full/3200,/0/default.jpg',
|
url: '/test/data/iiif_2_0_sizes/full/3200,/0/default.jpg',
|
||||||
height: 2328,
|
height: 2328,
|
||||||
width: 3200
|
width: 3200
|
||||||
},{
|
}, {
|
||||||
url: '/test/data/iiif_2_0_sizes/full/6976,/0/default.jpg',
|
url: '/test/data/iiif_2_0_sizes/full/6976,/0/default.jpg',
|
||||||
height: 5074,
|
height: 5074,
|
||||||
width: 6976
|
width: 6976
|
||||||
}]
|
}]
|
||||||
});
|
}, assert);
|
||||||
});
|
});
|
||||||
|
|
||||||
})();
|
})();
|
||||||
|
@ -25,7 +25,7 @@
|
|||||||
<script src="/test/modules/basic.js"></script>
|
<script src="/test/modules/basic.js"></script>
|
||||||
<script src="/test/modules/strings.js"></script>
|
<script src="/test/modules/strings.js"></script>
|
||||||
<script src="/test/modules/formats.js"></script>
|
<script src="/test/modules/formats.js"></script>
|
||||||
<script src="/test/modules/utils.js"></script>
|
<!-- <script src="/test/modules/utils.js"></script>
|
||||||
<script src="/test/modules/events.js"></script>
|
<script src="/test/modules/events.js"></script>
|
||||||
<script src="/test/modules/units.js"></script>
|
<script src="/test/modules/units.js"></script>
|
||||||
<script src="/test/modules/multi-image.js"></script>
|
<script src="/test/modules/multi-image.js"></script>
|
||||||
@ -41,11 +41,11 @@
|
|||||||
<script src="/test/modules/dzitilesource.js"></script>
|
<script src="/test/modules/dzitilesource.js"></script>
|
||||||
<script src="/test/modules/tilesourcecollection.js"></script>
|
<script src="/test/modules/tilesourcecollection.js"></script>
|
||||||
<script src="/test/modules/spring.js"></script>
|
<script src="/test/modules/spring.js"></script>
|
||||||
<script src="/test/modules/rectangle.js"></script>
|
<script src="/test/modules/rectangle.js"></script> -->
|
||||||
<script src="/test/modules/ajax-tiles.js"></script>
|
<script src="/test/modules/ajax-tiles.js"></script>
|
||||||
<script src="/test/modules/imageloader.js"></script>
|
<!-- <script src="/test/modules/imageloader.js"></script>
|
||||||
<!-- The navigator tests are the slowest (for now; hopefully they can be sped up)
|
The navigator tests are the slowest (for now; hopefully they can be sped up)
|
||||||
so we put them last. -->
|
so we put them last.
|
||||||
<script src="/test/modules/navigator.js"></script>
|
<script src="/test/modules/navigator.js"></script> -->
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
Loading…
Reference in New Issue
Block a user