mirror of
https://github.com/openseadragon/openseadragon.git
synced 2024-11-22 05:06:09 +03:00
Testing deprecations
This commit is contained in:
parent
68fbdc7beb
commit
36831d3434
@ -189,25 +189,28 @@ $.Drawer.prototype = /** @lends OpenSeadragon.Drawer.prototype */{
|
||||
|
||||
// deprecated
|
||||
needsUpdate: function() {
|
||||
$.console.error( "[Drawer.needsUpdate] this function is deprecated." );
|
||||
return false;
|
||||
$.console.error( "[Drawer.needsUpdate] this function is deprecated. Use World.needsUpdate instead." );
|
||||
return this.viewer.world.needsUpdate();
|
||||
},
|
||||
|
||||
// deprecated
|
||||
numTilesLoaded: function() {
|
||||
$.console.error( "[Drawer.numTilesLoaded] this function is deprecated." );
|
||||
return 0;
|
||||
$.console.error( "[Drawer.numTilesLoaded] this function is deprecated. Use TileCache.numTilesLoaded instead." );
|
||||
return this.viewer.tileCache.numTilesLoaded();
|
||||
},
|
||||
|
||||
// deprecated
|
||||
reset: function() {
|
||||
$.console.error( "[Drawer.reset] this function is deprecated." );
|
||||
$.console.error( "[Drawer.reset] this function is deprecated. Use World.resetItems instead." );
|
||||
this.viewer.world.resetItems();
|
||||
return this;
|
||||
},
|
||||
|
||||
// deprecated
|
||||
update: function() {
|
||||
$.console.error( "[Drawer.update] this function is deprecated." );
|
||||
$.console.error( "[Drawer.update] this function is deprecated. Use Drawer.clear and World.update instead." );
|
||||
this.clear();
|
||||
this.viewer.world.update();
|
||||
return this;
|
||||
},
|
||||
|
||||
|
@ -70,6 +70,8 @@
|
||||
<script src="/test/modules/drawer.js"></script>
|
||||
<script src="/test/modules/tiledimage.js"></script>
|
||||
<script src="/test/modules/tilecache.js"></script>
|
||||
<script src="/test/modules/referencestrip.js"></script>
|
||||
<script src="/test/modules/tilesourcecollection.js"></script>
|
||||
<!-- The navigator tests are the slowest (for now; hopefully they can be sped up)
|
||||
so we put them last. -->
|
||||
<script src="/test/modules/navigator.js"></script>
|
||||
|
@ -103,6 +103,31 @@
|
||||
|
||||
return result;
|
||||
};
|
||||
},
|
||||
|
||||
// ----------
|
||||
testDeprecation: function(obj0, member0, obj1, member1) {
|
||||
var called = false;
|
||||
var errored = false;
|
||||
|
||||
if (obj1 && member1) {
|
||||
this.spyOnce(obj1, member1, function() {
|
||||
called = true;
|
||||
return false;
|
||||
});
|
||||
} else {
|
||||
called = true;
|
||||
}
|
||||
|
||||
this.spyOnce(OpenSeadragon.console, 'error', function(message) {
|
||||
if (/deprecated/.test(message)) {
|
||||
errored = true;
|
||||
}
|
||||
});
|
||||
|
||||
obj0[member0]();
|
||||
equal(called, true, 'called through for ' + member0);
|
||||
equal(errored, true, 'errored for ' + member0);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -28,31 +28,6 @@
|
||||
}, options));
|
||||
};
|
||||
|
||||
// ----------
|
||||
var testDeprecation = function(obj0, member0, obj1, member1) {
|
||||
var called = false;
|
||||
var errored = false;
|
||||
|
||||
if (obj1 && member1) {
|
||||
Util.spyOnce(obj1, member1, function() {
|
||||
called = true;
|
||||
return false;
|
||||
});
|
||||
} else {
|
||||
called = true;
|
||||
}
|
||||
|
||||
Util.spyOnce(OpenSeadragon.console, 'error', function(message) {
|
||||
if (/deprecated/.test(message)) {
|
||||
errored = true;
|
||||
}
|
||||
});
|
||||
|
||||
obj0[member0]();
|
||||
equal(called, true, 'called through for ' + member0);
|
||||
equal(errored, true, 'errored for ' + member0);
|
||||
};
|
||||
|
||||
// ----------
|
||||
asyncTest('basics', function() {
|
||||
createViewer();
|
||||
@ -111,14 +86,14 @@
|
||||
// ----------
|
||||
asyncTest('deprecations', function() {
|
||||
createViewer();
|
||||
testDeprecation(viewer.drawer, 'addOverlay', viewer, 'addOverlay');
|
||||
testDeprecation(viewer.drawer, 'updateOverlay', viewer, 'updateOverlay');
|
||||
testDeprecation(viewer.drawer, 'removeOverlay', viewer, 'removeOverlay');
|
||||
testDeprecation(viewer.drawer, 'clearOverlays', viewer, 'clearOverlays');
|
||||
testDeprecation(viewer.drawer, 'needsUpdate');
|
||||
testDeprecation(viewer.drawer, 'numTilesLoaded');
|
||||
testDeprecation(viewer.drawer, 'reset');
|
||||
testDeprecation(viewer.drawer, 'update');
|
||||
Util.testDeprecation(viewer.drawer, 'addOverlay', viewer, 'addOverlay');
|
||||
Util.testDeprecation(viewer.drawer, 'updateOverlay', viewer, 'updateOverlay');
|
||||
Util.testDeprecation(viewer.drawer, 'removeOverlay', viewer, 'removeOverlay');
|
||||
Util.testDeprecation(viewer.drawer, 'clearOverlays', viewer, 'clearOverlays');
|
||||
Util.testDeprecation(viewer.drawer, 'needsUpdate', viewer.world, 'needsUpdate');
|
||||
Util.testDeprecation(viewer.drawer, 'numTilesLoaded', viewer.tileCache, 'numTilesLoaded');
|
||||
Util.testDeprecation(viewer.drawer, 'reset', viewer.world, 'resetItems');
|
||||
Util.testDeprecation(viewer.drawer, 'update', viewer.world, 'update');
|
||||
start();
|
||||
});
|
||||
|
||||
|
46
test/modules/referencestrip.js
Normal file
46
test/modules/referencestrip.js
Normal file
@ -0,0 +1,46 @@
|
||||
/* global module, asyncTest, $, ok, equal, notEqual, start, test, Util, testLog */
|
||||
|
||||
(function() {
|
||||
var viewer;
|
||||
|
||||
module('ReferenceStrip', {
|
||||
setup: function () {
|
||||
var example = $('<div id="example"></div>').appendTo("#qunit-fixture");
|
||||
|
||||
testLog.reset();
|
||||
},
|
||||
teardown: function () {
|
||||
if (viewer && viewer.close) {
|
||||
viewer.close();
|
||||
}
|
||||
|
||||
viewer = null;
|
||||
}
|
||||
});
|
||||
|
||||
// ----------
|
||||
var createViewer = function(options) {
|
||||
options = options || {};
|
||||
viewer = OpenSeadragon(OpenSeadragon.extend({
|
||||
id: 'example',
|
||||
prefixUrl: '/build/openseadragon/images/',
|
||||
springStiffness: 100 // Faster animation = faster tests
|
||||
}, options));
|
||||
};
|
||||
|
||||
// ----------
|
||||
asyncTest('basics', function() {
|
||||
createViewer({
|
||||
sequenceMode: true,
|
||||
showReferenceStrip: true,
|
||||
tileSources: [
|
||||
'/test/data/tall.dzi',
|
||||
'/test/data/wide.dzi',
|
||||
]
|
||||
});
|
||||
|
||||
ok(viewer.referenceStrip, 'referenceStrip exists');
|
||||
start();
|
||||
});
|
||||
|
||||
})();
|
20
test/modules/tilesourcecollection.js
Normal file
20
test/modules/tilesourcecollection.js
Normal file
@ -0,0 +1,20 @@
|
||||
/* global module, asyncTest, $, ok, equal, notEqual, start, test, Util, testLog */
|
||||
|
||||
(function() {
|
||||
var viewer;
|
||||
|
||||
module('TileSourceCollection', {
|
||||
setup: function () {
|
||||
testLog.reset();
|
||||
},
|
||||
teardown: function () {
|
||||
}
|
||||
});
|
||||
|
||||
// ----------
|
||||
asyncTest('deprecation', function() {
|
||||
Util.testDeprecation(OpenSeadragon, 'TileSourceCollection');
|
||||
start();
|
||||
});
|
||||
|
||||
})();
|
@ -35,6 +35,8 @@
|
||||
<script src="/test/modules/drawer.js"></script>
|
||||
<script src="/test/modules/tiledimage.js"></script>
|
||||
<script src="/test/modules/tilecache.js"></script>
|
||||
<script src="/test/modules/referencestrip.js"></script>
|
||||
<script src="/test/modules/tilesourcecollection.js"></script>
|
||||
<!-- The navigator tests are the slowest (for now; hopefully they can be sped up)
|
||||
so we put them last. -->
|
||||
<script src="/test/modules/navigator.js"></script>
|
||||
|
Loading…
Reference in New Issue
Block a user