mirror of
https://github.com/openseadragon/openseadragon.git
synced 2024-11-24 22:26:10 +03:00
Drawer tests; multi-image test
This commit is contained in:
parent
b7c78812c5
commit
613e03d413
51
test/modules/drawer.js
Normal file
51
test/modules/drawer.js
Normal file
@ -0,0 +1,51 @@
|
||||
/* global module, asyncTest, $, ok, equal, notEqual, start, test, Util, testLog */
|
||||
|
||||
(function() {
|
||||
var viewer;
|
||||
|
||||
module('Drawer', {
|
||||
setup: function () {
|
||||
var example = $('<div id="example"></div>').appendTo("#qunit-fixture");
|
||||
|
||||
testLog.reset();
|
||||
|
||||
viewer = OpenSeadragon({
|
||||
id: 'example',
|
||||
prefixUrl: '/build/openseadragon/images/',
|
||||
springStiffness: 100 // Faster animation = faster tests
|
||||
});
|
||||
},
|
||||
teardown: function () {
|
||||
if (viewer && viewer.close) {
|
||||
viewer.close();
|
||||
}
|
||||
|
||||
viewer = null;
|
||||
}
|
||||
});
|
||||
|
||||
// ----------
|
||||
asyncTest('basics', function() {
|
||||
ok(viewer.drawer, 'Drawer exists');
|
||||
equal(viewer.drawer.canRotate(), OpenSeadragon.supportsCanvas, 'we can rotate if we have canvas');
|
||||
equal(viewer.drawer.getOpacity(), 1, 'starts with full opacity');
|
||||
viewer.drawer.setOpacity(0.4);
|
||||
equal(viewer.drawer.getOpacity(), 0.4, 'setting opacity works');
|
||||
start();
|
||||
});
|
||||
|
||||
// ----------
|
||||
asyncTest('tile-drawing event', function() {
|
||||
viewer.addHandler('tile-drawing', function handler(event) {
|
||||
viewer.removeHandler('tile-drawing', handler);
|
||||
equal(event.eventSource, viewer, 'sender of tile-drawing event was viewer');
|
||||
ok(event.tile, 'tile-drawing event includes a tile');
|
||||
ok(event.context, 'tile-drawing event includes a context');
|
||||
ok(event.rendered, 'tile-drawing event includes a rendered');
|
||||
start();
|
||||
});
|
||||
|
||||
viewer.open('/test/data/testpattern.dzi');
|
||||
});
|
||||
|
||||
})();
|
@ -118,8 +118,8 @@
|
||||
viewer.open( '/test/data/testpattern.dzi' );
|
||||
});
|
||||
|
||||
// ----------
|
||||
asyncTest( 'Sequences as items', function() {
|
||||
|
||||
var options = {
|
||||
tileSource: [{
|
||||
type: 'legacy-image-pyramid',
|
||||
@ -154,4 +154,25 @@
|
||||
viewer.open( '/test/data/testpattern.dzi' );
|
||||
});
|
||||
|
||||
// ----------
|
||||
asyncTest('items are added in order', function() {
|
||||
viewer.addHandler('open', function(event) {
|
||||
equal(viewer.world.getItemAt(0).getContentSize().y, 2000, 'first image is tall');
|
||||
equal(viewer.world.getItemAt(0).getBounds().width, 4, 'first image has 4 width');
|
||||
equal(viewer.world.getItemAt(1).getContentSize().x, 2000, 'second image is wide');
|
||||
equal(viewer.world.getItemAt(1).getBounds().width, 2, 'second image has 2 width');
|
||||
start();
|
||||
});
|
||||
|
||||
viewer.open([
|
||||
{
|
||||
tileSource: '/test/data/tall.dzi',
|
||||
width: 4
|
||||
}, {
|
||||
tileSource: '/test/data/wide.dzi',
|
||||
width: 2
|
||||
}
|
||||
]);
|
||||
});
|
||||
|
||||
})();
|
||||
|
@ -31,7 +31,8 @@
|
||||
<script src="/test/overlays.js"></script>
|
||||
<script src="/test/controls.js"></script>
|
||||
<script src="/test/viewport.js"></script>
|
||||
<script src="/test/world.js"></script>
|
||||
<script src="/test/modules/world.js"></script>
|
||||
<script src="/test/modules/drawer.js"></script>
|
||||
<!-- The navigator tests are the slowest (for now; hopefully they can be sped up)
|
||||
so we put them last. -->
|
||||
<script src="/test/navigator.js"></script>
|
||||
|
Loading…
Reference in New Issue
Block a user