mirror of
https://github.com/openseadragon/openseadragon.git
synced 2024-11-25 06:36:11 +03:00
Testing deprecations
This commit is contained in:
parent
68fbdc7beb
commit
36831d3434
@ -129,9 +129,9 @@ $.Drawer = function( options ) {
|
|||||||
* @memberof OpenSeadragon.Viewer
|
* @memberof OpenSeadragon.Viewer
|
||||||
* @type {object}
|
* @type {object}
|
||||||
* @property {OpenSeadragon.Viewer} eventSource - A reference to the Viewer which raised the event.
|
* @property {OpenSeadragon.Viewer} eventSource - A reference to the Viewer which raised the event.
|
||||||
* @property {OpenSeadragon.Tile} tile - The Tile being drawn.
|
* @property {OpenSeadragon.Tile} tile - The Tile being drawn.
|
||||||
* @property {OpenSeadragon.Tile} context - The HTML canvas context being drawn into.
|
* @property {OpenSeadragon.Tile} context - The HTML canvas context being drawn into.
|
||||||
* @property {OpenSeadragon.Tile} rendered - The HTML canvas context containing the tile imagery.
|
* @property {OpenSeadragon.Tile} rendered - The HTML canvas context containing the tile imagery.
|
||||||
* @property {?Object} userData - Arbitrary subscriber-defined object.
|
* @property {?Object} userData - Arbitrary subscriber-defined object.
|
||||||
*/
|
*/
|
||||||
_this.viewer.raiseEvent('tile-drawing', args);
|
_this.viewer.raiseEvent('tile-drawing', args);
|
||||||
@ -189,25 +189,28 @@ $.Drawer.prototype = /** @lends OpenSeadragon.Drawer.prototype */{
|
|||||||
|
|
||||||
// deprecated
|
// deprecated
|
||||||
needsUpdate: function() {
|
needsUpdate: function() {
|
||||||
$.console.error( "[Drawer.needsUpdate] this function is deprecated." );
|
$.console.error( "[Drawer.needsUpdate] this function is deprecated. Use World.needsUpdate instead." );
|
||||||
return false;
|
return this.viewer.world.needsUpdate();
|
||||||
},
|
},
|
||||||
|
|
||||||
// deprecated
|
// deprecated
|
||||||
numTilesLoaded: function() {
|
numTilesLoaded: function() {
|
||||||
$.console.error( "[Drawer.numTilesLoaded] this function is deprecated." );
|
$.console.error( "[Drawer.numTilesLoaded] this function is deprecated. Use TileCache.numTilesLoaded instead." );
|
||||||
return 0;
|
return this.viewer.tileCache.numTilesLoaded();
|
||||||
},
|
},
|
||||||
|
|
||||||
// deprecated
|
// deprecated
|
||||||
reset: function() {
|
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;
|
return this;
|
||||||
},
|
},
|
||||||
|
|
||||||
// deprecated
|
// deprecated
|
||||||
update: function() {
|
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;
|
return this;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -70,6 +70,8 @@
|
|||||||
<script src="/test/modules/drawer.js"></script>
|
<script src="/test/modules/drawer.js"></script>
|
||||||
<script src="/test/modules/tiledimage.js"></script>
|
<script src="/test/modules/tiledimage.js"></script>
|
||||||
<script src="/test/modules/tilecache.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)
|
<!-- The navigator tests are the slowest (for now; hopefully they can be sped up)
|
||||||
so we put them last. -->
|
so we put them last. -->
|
||||||
<script src="/test/modules/navigator.js"></script>
|
<script src="/test/modules/navigator.js"></script>
|
||||||
|
@ -103,6 +103,31 @@
|
|||||||
|
|
||||||
return result;
|
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));
|
}, 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() {
|
asyncTest('basics', function() {
|
||||||
createViewer();
|
createViewer();
|
||||||
@ -111,14 +86,14 @@
|
|||||||
// ----------
|
// ----------
|
||||||
asyncTest('deprecations', function() {
|
asyncTest('deprecations', function() {
|
||||||
createViewer();
|
createViewer();
|
||||||
testDeprecation(viewer.drawer, 'addOverlay', viewer, 'addOverlay');
|
Util.testDeprecation(viewer.drawer, 'addOverlay', viewer, 'addOverlay');
|
||||||
testDeprecation(viewer.drawer, 'updateOverlay', viewer, 'updateOverlay');
|
Util.testDeprecation(viewer.drawer, 'updateOverlay', viewer, 'updateOverlay');
|
||||||
testDeprecation(viewer.drawer, 'removeOverlay', viewer, 'removeOverlay');
|
Util.testDeprecation(viewer.drawer, 'removeOverlay', viewer, 'removeOverlay');
|
||||||
testDeprecation(viewer.drawer, 'clearOverlays', viewer, 'clearOverlays');
|
Util.testDeprecation(viewer.drawer, 'clearOverlays', viewer, 'clearOverlays');
|
||||||
testDeprecation(viewer.drawer, 'needsUpdate');
|
Util.testDeprecation(viewer.drawer, 'needsUpdate', viewer.world, 'needsUpdate');
|
||||||
testDeprecation(viewer.drawer, 'numTilesLoaded');
|
Util.testDeprecation(viewer.drawer, 'numTilesLoaded', viewer.tileCache, 'numTilesLoaded');
|
||||||
testDeprecation(viewer.drawer, 'reset');
|
Util.testDeprecation(viewer.drawer, 'reset', viewer.world, 'resetItems');
|
||||||
testDeprecation(viewer.drawer, 'update');
|
Util.testDeprecation(viewer.drawer, 'update', viewer.world, 'update');
|
||||||
start();
|
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/drawer.js"></script>
|
||||||
<script src="/test/modules/tiledimage.js"></script>
|
<script src="/test/modules/tiledimage.js"></script>
|
||||||
<script src="/test/modules/tilecache.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)
|
<!-- The navigator tests are the slowest (for now; hopefully they can be sped up)
|
||||||
so we put them last. -->
|
so we put them last. -->
|
||||||
<script src="/test/modules/navigator.js"></script>
|
<script src="/test/modules/navigator.js"></script>
|
||||||
|
Loading…
Reference in New Issue
Block a user