mirror of
https://github.com/openseadragon/openseadragon.git
synced 2024-11-21 20:56:09 +03:00
test drawers separately
This commit is contained in:
parent
834795b4b8
commit
8be2ca2dfb
@ -2,6 +2,10 @@
|
||||
|
||||
(function() {
|
||||
var viewer;
|
||||
const drawerTypes = ['webgl','canvas','html'];
|
||||
drawerTypes.forEach(runDrawerTests);
|
||||
|
||||
function runDrawerTests(drawerType){
|
||||
|
||||
QUnit.module('Drawer', {
|
||||
beforeEach: function () {
|
||||
@ -24,27 +28,38 @@
|
||||
viewer = OpenSeadragon(OpenSeadragon.extend({
|
||||
id: 'example',
|
||||
prefixUrl: '/build/openseadragon/images/',
|
||||
springStiffness: 100 // Faster animation = faster tests
|
||||
springStiffness: 100, // Faster animation = faster tests
|
||||
drawer: drawerType,
|
||||
}, options));
|
||||
};
|
||||
|
||||
// ----------
|
||||
QUnit.test('basics', function(assert) {
|
||||
QUnit.test('basics-'+drawerType, function(assert) {
|
||||
var done = assert.async();
|
||||
createViewer();
|
||||
assert.ok(viewer.drawer, 'Drawer exists');
|
||||
assert.equal(viewer.drawer.canRotate(), OpenSeadragon.supportsCanvas, 'we can rotate if we have canvas');
|
||||
assert.equal(viewer.drawer.canRotate(), ['webgl','canvas'].includes(drawerType), 'we can rotate if we have canvas');
|
||||
done();
|
||||
});
|
||||
|
||||
// ----------
|
||||
QUnit.test('rotation', function(assert) {
|
||||
QUnit.test('rotation-'+drawerType, function(assert) {
|
||||
var done = assert.async();
|
||||
|
||||
createViewer({
|
||||
tileSources: '/test/data/testpattern.dzi',
|
||||
drawer: 'canvas', // this test only makes sense for certain drawers
|
||||
tileSources: '/test/data/testpattern.dzi'
|
||||
});
|
||||
|
||||
// this test only makes sense for canvas drawer because of how it is
|
||||
// detected by watching for the canvas context rotate function
|
||||
// TODO: add test for actual rotation of the drawn image in a way that
|
||||
// applies to the webgl drawer as well as the canvas drawer.
|
||||
if(viewer.drawer.getType() !== 'canvas'){
|
||||
assert.expect(0);
|
||||
done();
|
||||
};
|
||||
|
||||
|
||||
viewer.addHandler('open', function handler(event) {
|
||||
viewer.viewport.setRotation(30, true);
|
||||
Util.spyOnce(viewer.drawer.context, 'rotate', function() {
|
||||
@ -55,13 +70,18 @@
|
||||
});
|
||||
|
||||
// ----------
|
||||
QUnit.test('debug', function(assert) {
|
||||
QUnit.test('debug-'+drawerType, function(assert) {
|
||||
var done = assert.async();
|
||||
createViewer({
|
||||
tileSources: '/test/data/testpattern.dzi',
|
||||
debugMode: true
|
||||
});
|
||||
|
||||
// only test this for canvas and webgl drawers
|
||||
if( !['canvas','webgl'].includes(viewer.drawer.getType() )){
|
||||
assert.expect(0);
|
||||
done()
|
||||
}
|
||||
Util.spyOnce(viewer.drawer, '_drawDebugInfo', function() {
|
||||
assert.ok(true, '_drawDebugInfo is called');
|
||||
done();
|
||||
@ -69,14 +89,20 @@
|
||||
});
|
||||
|
||||
// ----------
|
||||
QUnit.test('sketchCanvas', function(assert) {
|
||||
QUnit.test('sketchCanvas-'+drawerType, function(assert) {
|
||||
var done = assert.async();
|
||||
|
||||
createViewer({
|
||||
tileSources: '/test/data/testpattern.dzi',
|
||||
drawer: 'canvas' // test only makes sense for this drawer
|
||||
});
|
||||
var drawer = viewer.drawer;
|
||||
|
||||
// this test only makes sense for canvas drawer
|
||||
if(viewer.drawer.getType() !== 'canvas'){
|
||||
assert.expect(0);
|
||||
done();
|
||||
};
|
||||
|
||||
viewer.addHandler('tile-drawn', function noOpacityHandler() {
|
||||
viewer.removeHandler('tile-drawn', noOpacityHandler);
|
||||
assert.equal(drawer.sketchCanvas, null,
|
||||
@ -111,7 +137,7 @@
|
||||
});
|
||||
|
||||
// ----------
|
||||
QUnit.test('deprecations', function(assert) {
|
||||
QUnit.test('deprecations-'+drawerType, function(assert) {
|
||||
var done = assert.async();
|
||||
|
||||
createViewer({
|
||||
@ -124,4 +150,6 @@
|
||||
});
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
})();
|
||||
|
Loading…
Reference in New Issue
Block a user