mirror of
https://github.com/openseadragon/openseadragon.git
synced 2024-11-24 22:26:10 +03:00
Add tests for tile-loaded event.
This commit is contained in:
parent
d5c431b1cd
commit
7e39a528c0
@ -968,4 +968,76 @@
|
|||||||
viewer.open( '/test/data/testpattern.dzi' );
|
viewer.open( '/test/data/testpattern.dzi' );
|
||||||
} );
|
} );
|
||||||
|
|
||||||
|
// tile-loaded event tests
|
||||||
|
asyncTest( 'Viewer: tile-loaded event without callback.', function () {
|
||||||
|
|
||||||
|
function tileLoaded ( event ) {
|
||||||
|
viewer.removeHandler( 'tile-loaded', tileLoaded);
|
||||||
|
var tile = event.tile;
|
||||||
|
ok( tile.loading, "The tile should be marked as loading.");
|
||||||
|
notOk( tile.loaded, "The tile should not be marked as loaded.");
|
||||||
|
setTimeout(function() {
|
||||||
|
notOk( tile.loading, "The tile should not be marked as loading.");
|
||||||
|
ok( tile.loaded, "The tile should not be marked as loaded.");
|
||||||
|
start();
|
||||||
|
}, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
viewer.addHandler( 'tile-loaded', tileLoaded);
|
||||||
|
viewer.open( '/test/data/testpattern.dzi' );
|
||||||
|
} );
|
||||||
|
|
||||||
|
asyncTest( 'Viewer: tile-loaded event with 1 callback.', function () {
|
||||||
|
|
||||||
|
function tileLoaded ( event ) {
|
||||||
|
viewer.removeHandler( 'tile-loaded', tileLoaded);
|
||||||
|
var tile = event.tile;
|
||||||
|
var callback = event.getCompletionCallback();
|
||||||
|
ok( tile.loading, "The tile should be marked as loading.");
|
||||||
|
notOk( tile.loaded, "The tile should not be marked as loaded.");
|
||||||
|
ok( callback, "The event should have a callback.");
|
||||||
|
setTimeout(function() {
|
||||||
|
ok( tile.loading, "The tile should be marked as loading.");
|
||||||
|
notOk( tile.loaded, "The tile should not be marked as loaded.");
|
||||||
|
callback();
|
||||||
|
notOk( tile.loading, "The tile should not be marked as loading.");
|
||||||
|
ok( tile.loaded, "The tile should not be marked as loaded.");
|
||||||
|
start();
|
||||||
|
}, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
viewer.addHandler( 'tile-loaded', tileLoaded);
|
||||||
|
viewer.open( '/test/data/testpattern.dzi' );
|
||||||
|
} );
|
||||||
|
|
||||||
|
asyncTest( 'Viewer: tile-loaded event with 2 callbacks.', function () {
|
||||||
|
|
||||||
|
function tileLoaded ( event ) {
|
||||||
|
viewer.removeHandler( 'tile-loaded', tileLoaded);
|
||||||
|
var tile = event.tile;
|
||||||
|
var callback1 = event.getCompletionCallback();
|
||||||
|
var callback2 = event.getCompletionCallback();
|
||||||
|
ok( tile.loading, "The tile should be marked as loading.");
|
||||||
|
notOk( tile.loaded, "The tile should not be marked as loaded.");
|
||||||
|
setTimeout(function() {
|
||||||
|
ok( tile.loading, "The tile should be marked as loading.");
|
||||||
|
notOk( tile.loaded, "The tile should not be marked as loaded.");
|
||||||
|
callback1();
|
||||||
|
ok( tile.loading, "The tile should be marked as loading.");
|
||||||
|
notOk( tile.loaded, "The tile should not be marked as loaded.");
|
||||||
|
setTimeout(function() {
|
||||||
|
ok( tile.loading, "The tile should be marked as loading.");
|
||||||
|
notOk( tile.loaded, "The tile should not be marked as loaded.");
|
||||||
|
callback2();
|
||||||
|
notOk( tile.loading, "The tile should not be marked as loading.");
|
||||||
|
ok( tile.loaded, "The tile should not be marked as loaded.");
|
||||||
|
start();
|
||||||
|
}, 0);
|
||||||
|
}, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
viewer.addHandler( 'tile-loaded', tileLoaded);
|
||||||
|
viewer.open( '/test/data/testpattern.dzi' );
|
||||||
|
} );
|
||||||
|
|
||||||
} )();
|
} )();
|
||||||
|
Loading…
Reference in New Issue
Block a user