From ce8b0358ffa11c2223b25108541ec33ef8a88e92 Mon Sep 17 00:00:00 2001 From: Ian Gilman Date: Fri, 19 Dec 2014 15:21:57 -0800 Subject: [PATCH] Test for item positions + navigator --- test/modules/navigator.js | 46 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 45 insertions(+), 1 deletion(-) diff --git a/test/modules/navigator.js b/test/modules/navigator.js index 8ee325e2..7799f06d 100644 --- a/test/modules/navigator.js +++ b/test/modules/navigator.js @@ -1,4 +1,4 @@ -/* global QUnit, module, Util, $, console, test, asyncTest, start, ok, equal */ +/* global QUnit, module, Util, $, console, test, asyncTest, start, ok, equal, propEqual */ (function () { var debug = false, @@ -799,4 +799,48 @@ viewer.addHandler('open', openHandler1); }); + + asyncTest('Item positions including collection mode', function() { + var navAddCount = 0; + + viewer = OpenSeadragon({ + id: 'example', + prefixUrl: '/build/openseadragon/images/', + tileSources: ['/test/data/testpattern.dzi', '/test/data/testpattern.dzi'], + springStiffness: 100, // Faster animation = faster tests + showNavigator: true, + collectionMode: true + }); + + var openHandler = function() { + viewer.removeHandler('open', openHandler); + viewer.navigator.world.addHandler('add-item', navOpenHandler); + }; + + var navOpenHandler = function(event) { + navAddCount++; + if (navAddCount === 2) { + viewer.navigator.world.removeHandler('add-item', navOpenHandler); + + setTimeout(function() { + // Test initial formation + equal(viewer.navigator.world.getItemCount(), 2, 'navigator has both items'); + for (var i = 0; i < 2; i++) { + propEqual(viewer.navigator.world.getItemAt(i).getBounds(), + viewer.world.getItemAt(i).getBounds(), 'bounds are the same'); + } + + // Try moving one + viewer.world.getItemAt(0).setPosition(new OpenSeadragon.Point(-200, -200)); + propEqual(viewer.navigator.world.getItemAt(0).getBounds(), + viewer.world.getItemAt(0).getBounds(), 'bounds are the same after move'); + + start(); + }, 1); + } + }; + + viewer.addHandler('open', openHandler); + }); + })();