Fix test for the preload hack (and fix the parentheses to always call updateMulti).

This commit is contained in:
Aiosa 2023-12-10 16:49:56 +01:00
parent a690b50eee
commit cf2413e0c9
2 changed files with 15 additions and 12 deletions

View File

@ -356,7 +356,7 @@ $.Viewer = function( options ) {
//if we are not throttling
if (_this.imageLoader.canAcceptNewJob()) {
//todo small hack, we could make this builtin speedup more sophisticated
//todo small hack, we could make this builtin speedup more sophisticated, breaks tests --> commented out
const item = event.item;
const origOpacity = item.opacity;
const origMaxTiles = item.maxTilesPerFrame;
@ -367,11 +367,11 @@ $.Viewer = function( options ) {
item._needsDraw = true; //we did not draw
item.opacity = origOpacity;
item.maxTilesPerFrame = origMaxTiles;
}
if (!_this._updateRequestId) {
_this._updateRequestId = scheduleUpdate( _this, updateMulti );
}
}
});
this.world.addHandler('remove-item', function(event) {

View File

@ -1288,22 +1288,25 @@
QUnit.test( 'Viewer: tile-unloaded event.', function(assert) {
var tiledImage;
var tile;
var tiles = [];
var done = assert.async();
function tileLoaded( event ) {
viewer.removeHandler( 'tile-loaded', tileLoaded);
tiledImage = event.tiledImage;
tile = event.tile;
tiles.push(event.tile);
if (tiles.length === 1) {
setTimeout(function() {
tiledImage.reset();
}, 0);
}
}
function tileUnloaded( event ) {
viewer.removeHandler( 'tile-loaded', tileLoaded);
viewer.removeHandler( 'tile-unloaded', tileUnloaded );
assert.equal( tile, event.tile,
"The unloaded tile should be the same than the loaded one." );
assert.equal( tiles.find(t => t === event.tile), event.tile,
"The unloaded tile should be one of the loaded tiles." );
assert.equal( tiledImage, event.tiledImage,
"The tiledImage of the unloaded tile should be the same than the one of the loaded one." );
done();