mirror of
https://github.com/openseadragon/openseadragon.git
synced 2025-01-31 23:21:42 +03:00
Fix and add unit tests.
This commit is contained in:
parent
9e1433dd66
commit
d671049a17
@ -223,7 +223,7 @@ $.TileCache.prototype = /** @lends OpenSeadragon.TileCache.prototype */{
|
||||
for ( var i = 0; i < this._tilesLoaded.length; ++i ) {
|
||||
tileRecord = this._tilesLoaded[ i ];
|
||||
if ( tileRecord.tiledImage === tiledImage ) {
|
||||
this._unloadTile(tileRecord.tile);
|
||||
this._unloadTile(tileRecord);
|
||||
this._tilesLoaded.splice( i, 1 );
|
||||
i--;
|
||||
}
|
||||
|
@ -1040,4 +1040,31 @@
|
||||
viewer.open( '/test/data/testpattern.dzi' );
|
||||
} );
|
||||
|
||||
asyncTest( 'Viewer: tile-unloaded event.', function() {
|
||||
var tiledImage;
|
||||
var tile;
|
||||
|
||||
function tileLoaded( event ) {
|
||||
viewer.removeHandler( 'tile-loaded', tileLoaded);
|
||||
tiledImage = event.tiledImage;
|
||||
tile = event.tile;
|
||||
setTimeout(function() {
|
||||
tiledImage.reset();
|
||||
}, 0);
|
||||
}
|
||||
|
||||
function tileUnloaded( event ) {
|
||||
viewer.removeHandler( 'tile-unloaded', tileUnloaded );
|
||||
equal( tile, event.tile,
|
||||
"The unloaded tile should be the same than the loaded one." );
|
||||
equal( tiledImage, event.tiledImage,
|
||||
"The tiledImage of the unloaded tile should be the same than the one of the loaded one." );
|
||||
start();
|
||||
}
|
||||
|
||||
viewer.addHandler( 'tile-loaded', tileLoaded );
|
||||
viewer.addHandler( 'tile-unloaded', tileUnloaded );
|
||||
viewer.open( '/test/data/testpattern.dzi' );
|
||||
} );
|
||||
|
||||
} )();
|
||||
|
@ -13,8 +13,15 @@
|
||||
|
||||
// ----------
|
||||
asyncTest('basics', function() {
|
||||
var fakeTiledImage0 = {};
|
||||
var fakeTiledImage1 = {};
|
||||
var fakeViewer = {
|
||||
raiseEvent: function() {}
|
||||
};
|
||||
var fakeTiledImage0 = {
|
||||
viewer: fakeViewer
|
||||
};
|
||||
var fakeTiledImage1 = {
|
||||
viewer: fakeViewer
|
||||
};
|
||||
|
||||
var fakeTile0 = {
|
||||
url: 'foo.jpg',
|
||||
@ -58,7 +65,12 @@
|
||||
|
||||
// ----------
|
||||
asyncTest('maxImageCacheCount', function() {
|
||||
var fakeTiledImage0 = {};
|
||||
var fakeViewer = {
|
||||
raiseEvent: function() {}
|
||||
};
|
||||
var fakeTiledImage0 = {
|
||||
viewer: fakeViewer
|
||||
};
|
||||
|
||||
var fakeTile0 = {
|
||||
url: 'different.jpg',
|
||||
|
Loading…
x
Reference in New Issue
Block a user