From 613e03d4131bcecf1a51fcb6edd13a8682c39113 Mon Sep 17 00:00:00 2001 From: Ian Gilman Date: Tue, 18 Nov 2014 16:28:08 -0800 Subject: [PATCH] Drawer tests; multi-image test --- test/modules/drawer.js | 51 +++++++++++++++++++++++++++++++++++++ test/{ => modules}/world.js | 0 test/multi-image.js | 23 ++++++++++++++++- test/test.html | 3 ++- 4 files changed, 75 insertions(+), 2 deletions(-) create mode 100644 test/modules/drawer.js rename test/{ => modules}/world.js (100%) diff --git a/test/modules/drawer.js b/test/modules/drawer.js new file mode 100644 index 00000000..694c6f3d --- /dev/null +++ b/test/modules/drawer.js @@ -0,0 +1,51 @@ +/* global module, asyncTest, $, ok, equal, notEqual, start, test, Util, testLog */ + +(function() { + var viewer; + + module('Drawer', { + setup: function () { + var example = $('
').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'); + }); + +})(); diff --git a/test/world.js b/test/modules/world.js similarity index 100% rename from test/world.js rename to test/modules/world.js diff --git a/test/multi-image.js b/test/multi-image.js index f67f5a37..c875757c 100644 --- a/test/multi-image.js +++ b/test/multi-image.js @@ -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 + } + ]); + }); + })(); diff --git a/test/test.html b/test/test.html index 54b5de05..acff4452 100644 --- a/test/test.html +++ b/test/test.html @@ -31,7 +31,8 @@ - + +