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 we are not throttling
if (_this.imageLoader.canAcceptNewJob()) { 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 item = event.item;
const origOpacity = item.opacity; const origOpacity = item.opacity;
const origMaxTiles = item.maxTilesPerFrame; const origMaxTiles = item.maxTilesPerFrame;
@ -367,10 +367,10 @@ $.Viewer = function( options ) {
item._needsDraw = true; //we did not draw item._needsDraw = true; //we did not draw
item.opacity = origOpacity; item.opacity = origOpacity;
item.maxTilesPerFrame = origMaxTiles; item.maxTilesPerFrame = origMaxTiles;
}
if (!_this._updateRequestId) { if (!_this._updateRequestId) {
_this._updateRequestId = scheduleUpdate( _this, updateMulti ); _this._updateRequestId = scheduleUpdate( _this, updateMulti );
}
} }
}); });

View File

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