mirror of
https://github.com/openseadragon/openseadragon.git
synced 2024-11-22 05:06:09 +03:00
Controls and viewport
This commit is contained in:
parent
52a275808f
commit
b096e369d0
224
test/modules/controls.js
vendored
224
test/modules/controls.js
vendored
@ -1,11 +1,11 @@
|
|||||||
/* global module, asyncTest, $, ok, equal, notEqual, start, test, Util, testLog */
|
/* global QUnit, $, testLog */
|
||||||
|
|
||||||
(function () {
|
(function () {
|
||||||
var viewer;
|
var viewer;
|
||||||
|
|
||||||
module('Controls', {
|
QUnit.module('Controls', {
|
||||||
setup: function () {
|
beforeEach: function () {
|
||||||
var example = $('<div id="controlsTests"></div>')
|
$('<div id="controlsTests"></div>')
|
||||||
.css({
|
.css({
|
||||||
width: 1000,
|
width: 1000,
|
||||||
height: 1000
|
height: 1000
|
||||||
@ -15,7 +15,7 @@
|
|||||||
testLog.reset();
|
testLog.reset();
|
||||||
|
|
||||||
},
|
},
|
||||||
teardown: function () {
|
afterEach: function () {
|
||||||
if (viewer && viewer.close) {
|
if (viewer && viewer.close) {
|
||||||
viewer.close();
|
viewer.close();
|
||||||
}
|
}
|
||||||
@ -24,16 +24,16 @@
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
asyncTest('ZoomControlOff', function () {
|
QUnit.test('ZoomControlOff', function (assert) {
|
||||||
|
var done = assert.async();
|
||||||
var openHandler = function () {
|
var openHandler = function () {
|
||||||
viewer.removeHandler('open', openHandler);
|
viewer.removeHandler('open', openHandler);
|
||||||
ok(!viewer.showZoomControl, 'showZoomControl should be off');
|
assert.ok(!viewer.showZoomControl, 'showZoomControl should be off');
|
||||||
ok(!viewer.zoomInButton, "zoomIn button should be null");
|
assert.ok(!viewer.zoomInButton, "zoomIn button should be null");
|
||||||
ok(!viewer.zoomOutButton, "zoomOut button should be null");
|
assert.ok(!viewer.zoomOutButton, "zoomOut button should be null");
|
||||||
|
|
||||||
viewer.close();
|
viewer.close();
|
||||||
start();
|
done();
|
||||||
};
|
};
|
||||||
|
|
||||||
viewer = OpenSeadragon({
|
viewer = OpenSeadragon({
|
||||||
@ -46,29 +46,29 @@
|
|||||||
viewer.open('/test/data/testpattern.dzi');
|
viewer.open('/test/data/testpattern.dzi');
|
||||||
});
|
});
|
||||||
|
|
||||||
asyncTest('ZoomControlOn', function () {
|
QUnit.test('ZoomControlOn', function (assert) {
|
||||||
|
var done = assert.async();
|
||||||
var openHandler = function () {
|
var openHandler = function () {
|
||||||
viewer.removeHandler('open', openHandler);
|
viewer.removeHandler('open', openHandler);
|
||||||
ok(viewer.showZoomControl, 'showZoomControl should be on');
|
assert.ok(viewer.showZoomControl, 'showZoomControl should be on');
|
||||||
ok(!!viewer.zoomInButton, "zoomIn button should not be null");
|
assert.ok(!!viewer.zoomInButton, "zoomIn button should not be null");
|
||||||
ok(!!viewer.zoomOutButton, "zoomOut button should not be null");
|
assert.ok(!!viewer.zoomOutButton, "zoomOut button should not be null");
|
||||||
notEqual(viewer.buttons.buttons.indexOf(viewer.zoomInButton), -1,
|
assert.notEqual(viewer.buttons.buttons.indexOf(viewer.zoomInButton), -1,
|
||||||
"The zoomIn button should be present");
|
"The zoomIn button should be present");
|
||||||
notEqual(viewer.buttons.buttons.indexOf(viewer.zoomOutButton), -1,
|
assert.notEqual(viewer.buttons.buttons.indexOf(viewer.zoomOutButton), -1,
|
||||||
"The zoomOut button should be present");
|
"The zoomOut button should be present");
|
||||||
|
|
||||||
var oldZoom = viewer.viewport.getZoom();
|
var oldZoom = viewer.viewport.getZoom();
|
||||||
viewer.zoomInButton.onClick();
|
viewer.zoomInButton.onClick();
|
||||||
var newZoom = viewer.viewport.getZoom();
|
var newZoom = viewer.viewport.getZoom();
|
||||||
ok(oldZoom < newZoom, "OSD should have zoomed in.");
|
assert.ok(oldZoom < newZoom, "OSD should have zoomed in.");
|
||||||
oldZoom = newZoom;
|
oldZoom = newZoom;
|
||||||
viewer.zoomOutButton.onClick();
|
viewer.zoomOutButton.onClick();
|
||||||
newZoom = viewer.viewport.getZoom();
|
newZoom = viewer.viewport.getZoom();
|
||||||
ok(oldZoom > newZoom, "OSD should have zoomed out.");
|
assert.ok(oldZoom > newZoom, "OSD should have zoomed out.");
|
||||||
|
|
||||||
viewer.close();
|
viewer.close();
|
||||||
start();
|
done();
|
||||||
};
|
};
|
||||||
|
|
||||||
viewer = OpenSeadragon({
|
viewer = OpenSeadragon({
|
||||||
@ -81,15 +81,15 @@
|
|||||||
viewer.open('/test/data/testpattern.dzi');
|
viewer.open('/test/data/testpattern.dzi');
|
||||||
});
|
});
|
||||||
|
|
||||||
asyncTest('HomeControlOff', function () {
|
QUnit.test('HomeControlOff', function (assert) {
|
||||||
|
var done = assert.async();
|
||||||
var openHandler = function () {
|
var openHandler = function () {
|
||||||
viewer.removeHandler('open', openHandler);
|
viewer.removeHandler('open', openHandler);
|
||||||
ok(!viewer.showHomeControl, 'showHomeControl should be off');
|
assert.ok(!viewer.showHomeControl, 'showHomeControl should be off');
|
||||||
ok(!viewer.homeButton, "Home button should be null");
|
assert.ok(!viewer.homeButton, "Home button should be null");
|
||||||
|
|
||||||
viewer.close();
|
viewer.close();
|
||||||
start();
|
done();
|
||||||
};
|
};
|
||||||
|
|
||||||
viewer = OpenSeadragon({
|
viewer = OpenSeadragon({
|
||||||
@ -102,32 +102,32 @@
|
|||||||
viewer.open('/test/data/testpattern.dzi');
|
viewer.open('/test/data/testpattern.dzi');
|
||||||
});
|
});
|
||||||
|
|
||||||
asyncTest('HomeControlOn', function () {
|
QUnit.test('HomeControlOn', function (assert) {
|
||||||
|
var done = assert.async();
|
||||||
var openHandler = function () {
|
var openHandler = function () {
|
||||||
viewer.removeHandler('open', openHandler);
|
viewer.removeHandler('open', openHandler);
|
||||||
ok(viewer.showHomeControl, 'showHomeControl should be on');
|
assert.ok(viewer.showHomeControl, 'showHomeControl should be on');
|
||||||
ok(!!viewer.homeButton, "Home button should not be null");
|
assert.ok(!!viewer.homeButton, "Home button should not be null");
|
||||||
notEqual(viewer.buttons.buttons.indexOf(viewer.homeButton), -1,
|
assert.notEqual(viewer.buttons.buttons.indexOf(viewer.homeButton), -1,
|
||||||
"The home button should be present");
|
"The home button should be present");
|
||||||
|
|
||||||
viewer.viewport.zoomBy(1.1);
|
viewer.viewport.zoomBy(1.1);
|
||||||
var bounds = viewer.viewport.getBounds();
|
var bounds = viewer.viewport.getBounds();
|
||||||
var homeBounds = viewer.viewport.getHomeBounds();
|
var homeBounds = viewer.viewport.getHomeBounds();
|
||||||
ok(bounds.x !== homeBounds.x ||
|
assert.ok(bounds.x !== homeBounds.x ||
|
||||||
bounds.y !== homeBounds.y ||
|
bounds.y !== homeBounds.y ||
|
||||||
bounds.width !== homeBounds.width ||
|
bounds.width !== homeBounds.width ||
|
||||||
bounds.height !== homeBounds.height,
|
bounds.height !== homeBounds.height,
|
||||||
"OSD should not be at home.");
|
"OSD should not be at home.");
|
||||||
viewer.homeButton.onRelease();
|
viewer.homeButton.onRelease();
|
||||||
bounds = viewer.viewport.getBounds();
|
bounds = viewer.viewport.getBounds();
|
||||||
ok(bounds.x === homeBounds.x &&
|
assert.ok(bounds.x === homeBounds.x &&
|
||||||
bounds.y === homeBounds.y &&
|
bounds.y === homeBounds.y &&
|
||||||
bounds.width === homeBounds.width &&
|
bounds.width === homeBounds.width &&
|
||||||
bounds.height === homeBounds.height, "OSD should have get home.");
|
bounds.height === homeBounds.height, "OSD should have get home.");
|
||||||
|
|
||||||
viewer.close();
|
viewer.close();
|
||||||
start();
|
done();
|
||||||
};
|
};
|
||||||
|
|
||||||
viewer = OpenSeadragon({
|
viewer = OpenSeadragon({
|
||||||
@ -140,15 +140,15 @@
|
|||||||
viewer.open('/test/data/testpattern.dzi');
|
viewer.open('/test/data/testpattern.dzi');
|
||||||
});
|
});
|
||||||
|
|
||||||
asyncTest('FullPageControlOff', function () {
|
QUnit.test('FullPageControlOff', function (assert) {
|
||||||
|
var done = assert.async();
|
||||||
var openHandler = function () {
|
var openHandler = function () {
|
||||||
viewer.removeHandler('open', openHandler);
|
viewer.removeHandler('open', openHandler);
|
||||||
ok(!viewer.showFullPageControl, 'showFullPageControl should be off');
|
assert.ok(!viewer.showFullPageControl, 'showFullPageControl should be off');
|
||||||
ok(!viewer.fullPageButton, "FullPage button should be null");
|
assert.ok(!viewer.fullPageButton, "FullPage button should be null");
|
||||||
|
|
||||||
viewer.close();
|
viewer.close();
|
||||||
start();
|
done();
|
||||||
};
|
};
|
||||||
|
|
||||||
viewer = OpenSeadragon({
|
viewer = OpenSeadragon({
|
||||||
@ -161,23 +161,23 @@
|
|||||||
viewer.open('/test/data/testpattern.dzi');
|
viewer.open('/test/data/testpattern.dzi');
|
||||||
});
|
});
|
||||||
|
|
||||||
asyncTest('FullPageControlOn', function () {
|
QUnit.test('FullPageControlOn', function (assert) {
|
||||||
|
var done = assert.async();
|
||||||
var openHandler = function () {
|
var openHandler = function () {
|
||||||
viewer.removeHandler('open', openHandler);
|
viewer.removeHandler('open', openHandler);
|
||||||
ok(viewer.showHomeControl, 'showFullPageControl should be on');
|
assert.ok(viewer.showHomeControl, 'showFullPageControl should be on');
|
||||||
ok(!!viewer.fullPageButton, "FullPage button should not be null");
|
assert.ok(!!viewer.fullPageButton, "FullPage button should not be null");
|
||||||
notEqual(viewer.buttons.buttons.indexOf(viewer.fullPageButton), -1,
|
assert.notEqual(viewer.buttons.buttons.indexOf(viewer.fullPageButton), -1,
|
||||||
"The full page button should be present");
|
"The full page button should be present");
|
||||||
|
|
||||||
ok(!viewer.isFullPage(), "OSD should not be in full page.");
|
assert.ok(!viewer.isFullPage(), "OSD should not be in full page.");
|
||||||
viewer.fullPageButton.onRelease();
|
viewer.fullPageButton.onRelease();
|
||||||
ok(viewer.isFullPage(), "OSD should be in full page.");
|
assert.ok(viewer.isFullPage(), "OSD should be in full page.");
|
||||||
viewer.fullPageButton.onRelease();
|
viewer.fullPageButton.onRelease();
|
||||||
ok(!viewer.isFullPage(), "OSD should not be in full page.");
|
assert.ok(!viewer.isFullPage(), "OSD should not be in full page.");
|
||||||
|
|
||||||
viewer.close();
|
viewer.close();
|
||||||
start();
|
done();
|
||||||
};
|
};
|
||||||
|
|
||||||
viewer = OpenSeadragon({
|
viewer = OpenSeadragon({
|
||||||
@ -190,19 +190,19 @@
|
|||||||
viewer.open('/test/data/testpattern.dzi');
|
viewer.open('/test/data/testpattern.dzi');
|
||||||
});
|
});
|
||||||
|
|
||||||
asyncTest('RotateControlOff', function () {
|
QUnit.test('RotateControlOff', function (assert) {
|
||||||
|
var done = assert.async();
|
||||||
var openHandler = function (event) {
|
var openHandler = function (event) {
|
||||||
viewer.removeHandler('open', openHandler);
|
viewer.removeHandler('open', openHandler);
|
||||||
ok(true, 'Open event was sent');
|
assert.ok(true, 'Open event was sent');
|
||||||
ok(viewer.drawer, 'Drawer exists');
|
assert.ok(viewer.drawer, 'Drawer exists');
|
||||||
ok(viewer.drawer.canRotate(), 'drawer.canRotate needs to be true');
|
assert.ok(viewer.drawer.canRotate(), 'drawer.canRotate needs to be true');
|
||||||
ok(!viewer.showRotationControl, 'showRotationControl should be off');
|
assert.ok(!viewer.showRotationControl, 'showRotationControl should be off');
|
||||||
ok(!viewer.rotateLeftButton, "rotateLeft button should be null");
|
assert.ok(!viewer.rotateLeftButton, "rotateLeft button should be null");
|
||||||
ok(!viewer.rotateRightButton, "rotateRight button should be null");
|
assert.ok(!viewer.rotateRightButton, "rotateRight button should be null");
|
||||||
|
|
||||||
viewer.close();
|
viewer.close();
|
||||||
start();
|
done();
|
||||||
};
|
};
|
||||||
|
|
||||||
viewer = OpenSeadragon({
|
viewer = OpenSeadragon({
|
||||||
@ -215,29 +215,29 @@
|
|||||||
viewer.open('/test/data/testpattern.dzi');
|
viewer.open('/test/data/testpattern.dzi');
|
||||||
});
|
});
|
||||||
|
|
||||||
asyncTest('RotateControlOn', function () {
|
QUnit.test('RotateControlOn', function (assert) {
|
||||||
|
var done = assert.async();
|
||||||
var openHandler = function (event) {
|
var openHandler = function (event) {
|
||||||
viewer.removeHandler('open', openHandler);
|
viewer.removeHandler('open', openHandler);
|
||||||
ok(true, 'Open event was sent');
|
assert.ok(true, 'Open event was sent');
|
||||||
ok(viewer.drawer, 'Drawer exists');
|
assert.ok(viewer.drawer, 'Drawer exists');
|
||||||
ok(viewer.drawer.canRotate(), 'drawer.canRotate needs to be true');
|
assert.ok(viewer.drawer.canRotate(), 'drawer.canRotate needs to be true');
|
||||||
ok(viewer.showRotationControl, 'showRotationControl should be true');
|
assert.ok(viewer.showRotationControl, 'showRotationControl should be true');
|
||||||
notEqual(viewer.buttons.buttons.indexOf(viewer.rotateLeftButton), -1,
|
assert.notEqual(viewer.buttons.buttons.indexOf(viewer.rotateLeftButton), -1,
|
||||||
"rotateLeft should be found");
|
"rotateLeft should be found");
|
||||||
notEqual(viewer.buttons.buttons.indexOf(viewer.rotateRightButton), -1,
|
assert.notEqual(viewer.buttons.buttons.indexOf(viewer.rotateRightButton), -1,
|
||||||
"rotateRight should be found");
|
"rotateRight should be found");
|
||||||
|
|
||||||
// Now simulate the left/right button clicks.
|
// Now simulate the left/right button clicks.
|
||||||
// TODO: re-factor simulateViewerClickWithDrag so it'll accept any element, and use that.
|
// TODO: re-factor simulateViewerClickWithDrag so it'll accept any element, and use that.
|
||||||
equal(viewer.viewport.degrees, 0, "Image should start at 0 degrees rotation");
|
assert.equal(viewer.viewport.degrees, 0, "Image should start at 0 degrees rotation");
|
||||||
viewer.rotateLeftButton.onRelease();
|
viewer.rotateLeftButton.onRelease();
|
||||||
equal(viewer.viewport.degrees, 270, "Image should be 270 degrees rotation (left)");
|
assert.equal(viewer.viewport.degrees, 270, "Image should be 270 degrees rotation (left)");
|
||||||
viewer.rotateRightButton.onRelease();
|
viewer.rotateRightButton.onRelease();
|
||||||
equal(viewer.viewport.degrees, 0, "Image should be 270 degrees rotation (right)");
|
assert.equal(viewer.viewport.degrees, 0, "Image should be 270 degrees rotation (right)");
|
||||||
|
|
||||||
viewer.close();
|
viewer.close();
|
||||||
start();
|
done();
|
||||||
};
|
};
|
||||||
|
|
||||||
viewer = OpenSeadragon({
|
viewer = OpenSeadragon({
|
||||||
@ -250,16 +250,16 @@
|
|||||||
viewer.open('/test/data/testpattern.dzi');
|
viewer.open('/test/data/testpattern.dzi');
|
||||||
});
|
});
|
||||||
|
|
||||||
asyncTest('SequenceControlOff', function () {
|
QUnit.test('SequenceControlOff', function (assert) {
|
||||||
|
var done = assert.async();
|
||||||
var openHandler = function () {
|
var openHandler = function () {
|
||||||
viewer.removeHandler('open', openHandler);
|
viewer.removeHandler('open', openHandler);
|
||||||
ok(!viewer.showSequenceControl, 'showSequenceControl should be off');
|
assert.ok(!viewer.showSequenceControl, 'showSequenceControl should be off');
|
||||||
ok(!viewer.previousButton, "Previous button should be null");
|
assert.ok(!viewer.previousButton, "Previous button should be null");
|
||||||
ok(!viewer.nextButton, "Next button should be null");
|
assert.ok(!viewer.nextButton, "Next button should be null");
|
||||||
|
|
||||||
viewer.close();
|
viewer.close();
|
||||||
start();
|
done();
|
||||||
};
|
};
|
||||||
|
|
||||||
viewer = OpenSeadragon({
|
viewer = OpenSeadragon({
|
||||||
@ -276,47 +276,47 @@
|
|||||||
viewer.addHandler('open', openHandler);
|
viewer.addHandler('open', openHandler);
|
||||||
});
|
});
|
||||||
|
|
||||||
asyncTest('SequenceControlOnPrevNextWrapOff', function () {
|
QUnit.test('SequenceControlOnPrevNextWrapOff', function (assert) {
|
||||||
|
var done = assert.async();
|
||||||
var openHandler = function () {
|
var openHandler = function () {
|
||||||
viewer.removeHandler('open', openHandler);
|
viewer.removeHandler('open', openHandler);
|
||||||
ok(viewer.showSequenceControl, 'showSequenceControl should be on');
|
assert.ok(viewer.showSequenceControl, 'showSequenceControl should be on');
|
||||||
ok(!!viewer.previousButton, "Previous button should not be null");
|
assert.ok(!!viewer.previousButton, "Previous button should not be null");
|
||||||
ok(!!viewer.nextButton, "Next button should not be null");
|
assert.ok(!!viewer.nextButton, "Next button should not be null");
|
||||||
notEqual(viewer.paging.buttons.indexOf(viewer.previousButton), -1,
|
assert.notEqual(viewer.paging.buttons.indexOf(viewer.previousButton), -1,
|
||||||
"The previous button should be present");
|
"The previous button should be present");
|
||||||
notEqual(viewer.paging.buttons.indexOf(viewer.nextButton), -1,
|
assert.notEqual(viewer.paging.buttons.indexOf(viewer.nextButton), -1,
|
||||||
"The next button should be present");
|
"The next button should be present");
|
||||||
|
|
||||||
equal(viewer.currentPage(), 0, "OSD should open on first page.");
|
assert.equal(viewer.currentPage(), 0, "OSD should open on first page.");
|
||||||
ok(viewer.previousButton.element.disabled,
|
assert.ok(viewer.previousButton.element.disabled,
|
||||||
"Previous should be disabled on first page.");
|
"Previous should be disabled on first page.");
|
||||||
ok(!viewer.nextButton.element.disabled,
|
assert.ok(!viewer.nextButton.element.disabled,
|
||||||
"Next should be enabled on first page.");
|
"Next should be enabled on first page.");
|
||||||
|
|
||||||
viewer.nextButton.onRelease();
|
viewer.nextButton.onRelease();
|
||||||
equal(viewer.currentPage(), 1, "OSD should be on second page.");
|
assert.equal(viewer.currentPage(), 1, "OSD should be on second page.");
|
||||||
ok(!viewer.previousButton.element.disabled,
|
assert.ok(!viewer.previousButton.element.disabled,
|
||||||
"Previous should be enabled on second page.");
|
"Previous should be enabled on second page.");
|
||||||
ok(!viewer.nextButton.element.disabled,
|
assert.ok(!viewer.nextButton.element.disabled,
|
||||||
"Next should be enabled on second page.");
|
"Next should be enabled on second page.");
|
||||||
|
|
||||||
viewer.nextButton.onRelease();
|
viewer.nextButton.onRelease();
|
||||||
equal(viewer.currentPage(), 2, "OSD should be on third page.");
|
assert.equal(viewer.currentPage(), 2, "OSD should be on third page.");
|
||||||
ok(!viewer.previousButton.element.disabled,
|
assert.ok(!viewer.previousButton.element.disabled,
|
||||||
"Previous should be enabled on third page.");
|
"Previous should be enabled on third page.");
|
||||||
ok(viewer.nextButton.element.disabled,
|
assert.ok(viewer.nextButton.element.disabled,
|
||||||
"Next should be disabled on third page.");
|
"Next should be disabled on third page.");
|
||||||
|
|
||||||
viewer.previousButton.onRelease();
|
viewer.previousButton.onRelease();
|
||||||
equal(viewer.currentPage(), 1, "OSD should be on second page.");
|
assert.equal(viewer.currentPage(), 1, "OSD should be on second page.");
|
||||||
ok(!viewer.previousButton.element.disabled,
|
assert.ok(!viewer.previousButton.element.disabled,
|
||||||
"Previous should be enabled on second page.");
|
"Previous should be enabled on second page.");
|
||||||
ok(!viewer.nextButton.element.disabled,
|
assert.ok(!viewer.nextButton.element.disabled,
|
||||||
"Next should be enabled on second page.");
|
"Next should be enabled on second page.");
|
||||||
|
|
||||||
viewer.close();
|
viewer.close();
|
||||||
start();
|
done();
|
||||||
};
|
};
|
||||||
|
|
||||||
viewer = OpenSeadragon({
|
viewer = OpenSeadragon({
|
||||||
@ -335,40 +335,40 @@
|
|||||||
viewer.addHandler('open', openHandler);
|
viewer.addHandler('open', openHandler);
|
||||||
});
|
});
|
||||||
|
|
||||||
asyncTest('SequenceControlOnPrevNextWrapOn', function () {
|
QUnit.test('SequenceControlOnPrevNextWrapOn', function (assert) {
|
||||||
|
var done = assert.async();
|
||||||
var openHandler = function () {
|
var openHandler = function () {
|
||||||
viewer.removeHandler('open', openHandler);
|
viewer.removeHandler('open', openHandler);
|
||||||
ok(viewer.showSequenceControl, 'showSequenceControl should be on');
|
assert.ok(viewer.showSequenceControl, 'showSequenceControl should be on');
|
||||||
ok(!!viewer.previousButton, "Previous button should not be null");
|
assert.ok(!!viewer.previousButton, "Previous button should not be null");
|
||||||
ok(!!viewer.nextButton, "Next button should not be null");
|
assert.ok(!!viewer.nextButton, "Next button should not be null");
|
||||||
notEqual(viewer.paging.buttons.indexOf(viewer.previousButton), -1,
|
assert.notEqual(viewer.paging.buttons.indexOf(viewer.previousButton), -1,
|
||||||
"The previous button should be present");
|
"The previous button should be present");
|
||||||
notEqual(viewer.paging.buttons.indexOf(viewer.nextButton), -1,
|
assert.notEqual(viewer.paging.buttons.indexOf(viewer.nextButton), -1,
|
||||||
"The next button should be present");
|
"The next button should be present");
|
||||||
|
|
||||||
equal(viewer.currentPage(), 0, "OSD should open on first page.");
|
assert.equal(viewer.currentPage(), 0, "OSD should open on first page.");
|
||||||
ok(!viewer.previousButton.element.disabled,
|
assert.ok(!viewer.previousButton.element.disabled,
|
||||||
"Previous should be enabled on first page.");
|
"Previous should be enabled on first page.");
|
||||||
ok(!viewer.nextButton.element.disabled,
|
assert.ok(!viewer.nextButton.element.disabled,
|
||||||
"Next should be enabled on first page.");
|
"Next should be enabled on first page.");
|
||||||
|
|
||||||
viewer.previousButton.onRelease();
|
viewer.previousButton.onRelease();
|
||||||
equal(viewer.currentPage(), 2, "OSD should be on third page.");
|
assert.equal(viewer.currentPage(), 2, "OSD should be on third page.");
|
||||||
ok(!viewer.previousButton.element.disabled,
|
assert.ok(!viewer.previousButton.element.disabled,
|
||||||
"Previous should be enabled on third page.");
|
"Previous should be enabled on third page.");
|
||||||
ok(!viewer.nextButton.element.disabled,
|
assert.ok(!viewer.nextButton.element.disabled,
|
||||||
"Next should be enabled on third page.");
|
"Next should be enabled on third page.");
|
||||||
|
|
||||||
viewer.nextButton.onRelease();
|
viewer.nextButton.onRelease();
|
||||||
equal(viewer.currentPage(), 0, "OSD should be on first page.");
|
assert.equal(viewer.currentPage(), 0, "OSD should be on first page.");
|
||||||
ok(!viewer.previousButton.element.disabled,
|
assert.ok(!viewer.previousButton.element.disabled,
|
||||||
"Previous should be enabled on first page.");
|
"Previous should be enabled on first page.");
|
||||||
ok(!viewer.nextButton.element.disabled,
|
assert.ok(!viewer.nextButton.element.disabled,
|
||||||
"Next should be enabled on first page.");
|
"Next should be enabled on first page.");
|
||||||
|
|
||||||
viewer.close();
|
viewer.close();
|
||||||
start();
|
done();
|
||||||
};
|
};
|
||||||
|
|
||||||
viewer = OpenSeadragon({
|
viewer = OpenSeadragon({
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* global module, asyncTest, $, ok, equal, notEqual, start, test, Util, testLog, propEqual, console */
|
/* global QUnit, $, Util, testLog, console */
|
||||||
|
|
||||||
(function () {
|
(function () {
|
||||||
var viewer;
|
var viewer;
|
||||||
@ -7,9 +7,9 @@
|
|||||||
var SPRING_STIFFNESS = 100; // Faster animation = faster tests
|
var SPRING_STIFFNESS = 100; // Faster animation = faster tests
|
||||||
var EPSILON = 0.0000000001;
|
var EPSILON = 0.0000000001;
|
||||||
|
|
||||||
module("viewport", {
|
QUnit.module("viewport", {
|
||||||
setup: function () {
|
beforeEach: function () {
|
||||||
var example = $('<div id="example"></div>').appendTo("#qunit-fixture");
|
$('<div id="example"></div>').appendTo("#qunit-fixture");
|
||||||
|
|
||||||
testLog.reset();
|
testLog.reset();
|
||||||
|
|
||||||
@ -19,7 +19,7 @@
|
|||||||
springStiffness: SPRING_STIFFNESS
|
springStiffness: SPRING_STIFFNESS
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
teardown: function () {
|
afterEach: function () {
|
||||||
if (viewer && viewer.close) {
|
if (viewer && viewer.close) {
|
||||||
viewer.close();
|
viewer.close();
|
||||||
}
|
}
|
||||||
@ -56,14 +56,15 @@
|
|||||||
|
|
||||||
// Test helper - a lot of these tests loop through a few possible
|
// Test helper - a lot of these tests loop through a few possible
|
||||||
// values for zoom levels, and reopen the viewer for each iteration.
|
// values for zoom levels, and reopen the viewer for each iteration.
|
||||||
var reopenViewerHelper = function(config) {
|
var reopenViewerHelper = function(assert, config) {
|
||||||
|
var done = assert.async();
|
||||||
var expected, level, actual, i = 0;
|
var expected, level, actual, i = 0;
|
||||||
var openHandler = function(event) {
|
var openHandler = function(event) {
|
||||||
var viewport = viewer.viewport;
|
var viewport = viewer.viewport;
|
||||||
expected = config.processExpected(level, expected);
|
expected = config.processExpected(level, expected);
|
||||||
actual = viewport[config.method]();
|
actual = viewport[config.method]();
|
||||||
|
|
||||||
propEqual(
|
assert.propEqual(
|
||||||
actual,
|
actual,
|
||||||
expected,
|
expected,
|
||||||
"Test " + config.method + " with zoom level of " + level + ". Expected : " + expected + ", got " + actual
|
"Test " + config.method + " with zoom level of " + level + ". Expected : " + expected + ", got " + actual
|
||||||
@ -82,7 +83,7 @@
|
|||||||
viewer.addOnceHandler('open', openHandler);
|
viewer.addOnceHandler('open', openHandler);
|
||||||
viewer.open(DZI_PATH);
|
viewer.open(DZI_PATH);
|
||||||
} else {
|
} else {
|
||||||
start();
|
done();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
level = expected = testZoomLevels[i];
|
level = expected = testZoomLevels[i];
|
||||||
@ -100,7 +101,8 @@
|
|||||||
|
|
||||||
// Test helper - a lot of these tests loop through a test data
|
// Test helper - a lot of these tests loop through a test data
|
||||||
// array and test different values. This helper does not reopen the viewer.
|
// array and test different values. This helper does not reopen the viewer.
|
||||||
var loopingTestHelper = function(config) {
|
var loopingTestHelper = function(assert, config) {
|
||||||
|
var done = assert.async();
|
||||||
var openHandler = function(event) {
|
var openHandler = function(event) {
|
||||||
viewer.removeHandler('open', openHandler);
|
viewer.removeHandler('open', openHandler);
|
||||||
var viewport = viewer.viewport;
|
var viewport = viewer.viewport;
|
||||||
@ -111,78 +113,91 @@
|
|||||||
orig = config.getOrig(config.testArray[i], viewport);
|
orig = config.getOrig(config.testArray[i], viewport);
|
||||||
expected = config.getExpected(orig, viewport);
|
expected = config.getExpected(orig, viewport);
|
||||||
actual = viewport[config.method](orig);
|
actual = viewport[config.method](orig);
|
||||||
var assert = config.assert || propEqual;
|
if(config.assert) {
|
||||||
assert(
|
config.assert(
|
||||||
actual,
|
assert,
|
||||||
expected,
|
actual,
|
||||||
"Correctly converted coordinates " + orig
|
expected,
|
||||||
);
|
"Correctly converted coordinates " + orig
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
assert.propEqual(
|
||||||
|
actual,
|
||||||
|
expected,
|
||||||
|
"Correctly converted coordinates " + orig
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
start();
|
done();
|
||||||
};
|
};
|
||||||
viewer.addHandler('open', openHandler);
|
viewer.addHandler('open', openHandler);
|
||||||
viewer.open(DZI_PATH);
|
viewer.open(DZI_PATH);
|
||||||
};
|
};
|
||||||
|
|
||||||
function assertPointsEquals(actual, expected, message) {
|
function assertPointsEquals(assert, actual, expected, message) {
|
||||||
Util.assertPointsEquals(actual, expected, 1e-15, message);
|
Util.assertPointsEquals(assert, actual, expected, 1e-15, message);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Tests start here.
|
// Tests start here.
|
||||||
|
|
||||||
asyncTest('getContainerSize', function() {
|
QUnit.test('getContainerSize', function(assert) {
|
||||||
|
var done = assert.async();
|
||||||
var openHandler = function(event) {
|
var openHandler = function(event) {
|
||||||
viewer.removeHandler('open', openHandler);
|
viewer.removeHandler('open', openHandler);
|
||||||
var viewport = viewer.viewport;
|
var viewport = viewer.viewport;
|
||||||
viewport.zoomTo(ZOOM_FACTOR, null, true);
|
viewport.zoomTo(ZOOM_FACTOR, null, true);
|
||||||
|
|
||||||
propEqual(viewport.getContainerSize(), new OpenSeadragon.Point(500, 500), "Test container size");
|
assert.propEqual(viewport.getContainerSize(), new OpenSeadragon.Point(500, 500), "Test container size");
|
||||||
start();
|
done();
|
||||||
};
|
};
|
||||||
viewer.addHandler('open', openHandler);
|
viewer.addHandler('open', openHandler);
|
||||||
viewer.open(DZI_PATH);
|
viewer.open(DZI_PATH);
|
||||||
});
|
});
|
||||||
|
|
||||||
asyncTest('getAspectRatio', function() {
|
QUnit.test('getAspectRatio', function(assert) {
|
||||||
|
var done = assert.async();
|
||||||
var openHandler = function(event) {
|
var openHandler = function(event) {
|
||||||
viewer.removeHandler('open', openHandler);
|
viewer.removeHandler('open', openHandler);
|
||||||
var viewport = viewer.viewport;
|
var viewport = viewer.viewport;
|
||||||
viewport.zoomTo(ZOOM_FACTOR, null, true);
|
viewport.zoomTo(ZOOM_FACTOR, null, true);
|
||||||
|
|
||||||
equal(viewport.getAspectRatio(), 1, "Test aspect ratio");
|
assert.equal(viewport.getAspectRatio(), 1, "Test aspect ratio");
|
||||||
start();
|
done();
|
||||||
};
|
};
|
||||||
viewer.addHandler('open', openHandler);
|
viewer.addHandler('open', openHandler);
|
||||||
viewer.open(DZI_PATH);
|
viewer.open(DZI_PATH);
|
||||||
});
|
});
|
||||||
|
|
||||||
asyncTest('getMinZoomDefault', function() {
|
QUnit.test('getMinZoomDefault', function(assert) {
|
||||||
|
var done = assert.async();
|
||||||
var openHandler = function(event) {
|
var openHandler = function(event) {
|
||||||
viewer.removeHandler('open', openHandler);
|
viewer.removeHandler('open', openHandler);
|
||||||
var viewport = viewer.viewport;
|
var viewport = viewer.viewport;
|
||||||
|
|
||||||
equal(viewport.getMinZoom(), 0.9, "Test default min zoom level");
|
assert.equal(viewport.getMinZoom(), 0.9, "Test default min zoom level");
|
||||||
start();
|
done();
|
||||||
};
|
};
|
||||||
viewer.addHandler('open', openHandler);
|
viewer.addHandler('open', openHandler);
|
||||||
viewer.open(DZI_PATH);
|
viewer.open(DZI_PATH);
|
||||||
});
|
});
|
||||||
|
|
||||||
asyncTest('getMaxZoomDefault', function() {
|
QUnit.test('getMaxZoomDefault', function(assert) {
|
||||||
|
var done = assert.async();
|
||||||
var openHandler = function(event) {
|
var openHandler = function(event) {
|
||||||
viewer.removeHandler('open', openHandler);
|
viewer.removeHandler('open', openHandler);
|
||||||
var viewport = viewer.viewport;
|
var viewport = viewer.viewport;
|
||||||
|
|
||||||
equal(viewport.getMaxZoom(), 2.2, "Test default max zoom level");
|
assert.equal(viewport.getMaxZoom(), 2.2, "Test default max zoom level");
|
||||||
start();
|
done();
|
||||||
};
|
};
|
||||||
viewer.addHandler('open', openHandler);
|
viewer.addHandler('open', openHandler);
|
||||||
viewer.open(DZI_PATH);
|
viewer.open(DZI_PATH);
|
||||||
});
|
});
|
||||||
|
|
||||||
asyncTest('getMinZoom', function() {
|
QUnit.test('getMinZoom', function(assert) {
|
||||||
reopenViewerHelper({
|
reopenViewerHelper(assert, {
|
||||||
property: 'minZoomLevel',
|
property: 'minZoomLevel',
|
||||||
method: 'getMinZoom',
|
method: 'getMinZoom',
|
||||||
processExpected: function(level, expected){
|
processExpected: function(level, expected){
|
||||||
@ -196,8 +211,8 @@
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
asyncTest('getMaxZoom', function() {
|
QUnit.test('getMaxZoom', function(assert) {
|
||||||
reopenViewerHelper({
|
reopenViewerHelper(assert, {
|
||||||
property: 'maxZoomLevel',
|
property: 'maxZoomLevel',
|
||||||
method: 'getMaxZoom',
|
method: 'getMaxZoom',
|
||||||
processExpected: function(level, expected) {
|
processExpected: function(level, expected) {
|
||||||
@ -212,8 +227,8 @@
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
asyncTest('getHomeBounds', function() {
|
QUnit.test('getHomeBounds', function(assert) {
|
||||||
reopenViewerHelper({
|
reopenViewerHelper(assert, {
|
||||||
property: 'defaultZoomLevel',
|
property: 'defaultZoomLevel',
|
||||||
method: 'getHomeBounds',
|
method: 'getHomeBounds',
|
||||||
processExpected: function(level, expected) {
|
processExpected: function(level, expected) {
|
||||||
@ -224,12 +239,14 @@
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
asyncTest('getHomeBoundsNoRotate with rotation', function() {
|
QUnit.test('getHomeBoundsNoRotate with rotation', function(assert) {
|
||||||
|
var done = assert.async();
|
||||||
function openHandler() {
|
function openHandler() {
|
||||||
viewer.removeHandler('open', openHandler);
|
viewer.removeHandler('open', openHandler);
|
||||||
var viewport = viewer.viewport;
|
var viewport = viewer.viewport;
|
||||||
viewport.setRotation(-675);
|
viewport.setRotation(-675);
|
||||||
Util.assertRectangleEquals(
|
Util.assertRectangleEquals(
|
||||||
|
assert,
|
||||||
viewport.getHomeBoundsNoRotate(),
|
viewport.getHomeBoundsNoRotate(),
|
||||||
new OpenSeadragon.Rect(
|
new OpenSeadragon.Rect(
|
||||||
(1 - Math.sqrt(2)) / 2,
|
(1 - Math.sqrt(2)) / 2,
|
||||||
@ -238,18 +255,20 @@
|
|||||||
Math.sqrt(2)),
|
Math.sqrt(2)),
|
||||||
0.00000001,
|
0.00000001,
|
||||||
"Test getHomeBoundsNoRotate with degrees = -675");
|
"Test getHomeBoundsNoRotate with degrees = -675");
|
||||||
start();
|
done();
|
||||||
}
|
}
|
||||||
viewer.addHandler('open', openHandler);
|
viewer.addHandler('open', openHandler);
|
||||||
viewer.open(DZI_PATH);
|
viewer.open(DZI_PATH);
|
||||||
});
|
});
|
||||||
|
|
||||||
asyncTest('getHomeBounds with rotation', function() {
|
QUnit.test('getHomeBounds with rotation', function(assert) {
|
||||||
|
var done = assert.async();
|
||||||
function openHandler() {
|
function openHandler() {
|
||||||
viewer.removeHandler('open', openHandler);
|
viewer.removeHandler('open', openHandler);
|
||||||
var viewport = viewer.viewport;
|
var viewport = viewer.viewport;
|
||||||
viewport.setRotation(-675);
|
viewport.setRotation(-675);
|
||||||
Util.assertRectangleEquals(
|
Util.assertRectangleEquals(
|
||||||
|
assert,
|
||||||
viewport.getHomeBounds(),
|
viewport.getHomeBounds(),
|
||||||
new OpenSeadragon.Rect(
|
new OpenSeadragon.Rect(
|
||||||
0.5,
|
0.5,
|
||||||
@ -259,22 +278,24 @@
|
|||||||
45),
|
45),
|
||||||
0.00000001,
|
0.00000001,
|
||||||
"Test getHomeBounds with degrees = -675");
|
"Test getHomeBounds with degrees = -675");
|
||||||
start();
|
done();
|
||||||
}
|
}
|
||||||
viewer.addHandler('open', openHandler);
|
viewer.addHandler('open', openHandler);
|
||||||
viewer.open(DZI_PATH);
|
viewer.open(DZI_PATH);
|
||||||
});
|
});
|
||||||
|
|
||||||
asyncTest('getHomeBoundsWithMultiImages', function() {
|
QUnit.test('getHomeBoundsWithMultiImages', function(assert) {
|
||||||
|
var done = assert.async();
|
||||||
function openHandler() {
|
function openHandler() {
|
||||||
viewer.removeHandler('open', openHandler);
|
viewer.removeHandler('open', openHandler);
|
||||||
var viewport = viewer.viewport;
|
var viewport = viewer.viewport;
|
||||||
Util.assertRectangleEquals(
|
Util.assertRectangleEquals(
|
||||||
|
assert,
|
||||||
new OpenSeadragon.Rect(0, 0, 4, 4),
|
new OpenSeadragon.Rect(0, 0, 4, 4),
|
||||||
viewport.getHomeBounds(),
|
viewport.getHomeBounds(),
|
||||||
0.00000001,
|
0.00000001,
|
||||||
"Test getHomeBoundsWithMultiImages");
|
"Test getHomeBoundsWithMultiImages");
|
||||||
start();
|
done();
|
||||||
}
|
}
|
||||||
viewer.addHandler('open', openHandler);
|
viewer.addHandler('open', openHandler);
|
||||||
viewer.open([{
|
viewer.open([{
|
||||||
@ -290,16 +311,18 @@
|
|||||||
}]);
|
}]);
|
||||||
});
|
});
|
||||||
|
|
||||||
asyncTest('getHomeBoundsWithMultiImagesAndClipping', function() {
|
QUnit.test('getHomeBoundsWithMultiImagesAndClipping', function(assert) {
|
||||||
|
var done = assert.async();
|
||||||
function openHandler() {
|
function openHandler() {
|
||||||
viewer.removeHandler('open', openHandler);
|
viewer.removeHandler('open', openHandler);
|
||||||
var viewport = viewer.viewport;
|
var viewport = viewer.viewport;
|
||||||
Util.assertRectangleEquals(
|
Util.assertRectangleEquals(
|
||||||
|
assert,
|
||||||
new OpenSeadragon.Rect(1, 1, 4, 4),
|
new OpenSeadragon.Rect(1, 1, 4, 4),
|
||||||
viewport.getHomeBounds(),
|
viewport.getHomeBounds(),
|
||||||
0.00000001,
|
0.00000001,
|
||||||
"Test getHomeBoundsWithMultiImagesAndClipping");
|
"Test getHomeBoundsWithMultiImagesAndClipping");
|
||||||
start();
|
done();
|
||||||
}
|
}
|
||||||
viewer.addHandler('open', openHandler);
|
viewer.addHandler('open', openHandler);
|
||||||
viewer.open([{
|
viewer.open([{
|
||||||
@ -316,8 +339,8 @@
|
|||||||
}]);
|
}]);
|
||||||
});
|
});
|
||||||
|
|
||||||
asyncTest('getHomeZoom', function() {
|
QUnit.test('getHomeZoom', function(assert) {
|
||||||
reopenViewerHelper({
|
reopenViewerHelper(assert, {
|
||||||
property: 'defaultZoomLevel',
|
property: 'defaultZoomLevel',
|
||||||
method: 'getHomeZoom',
|
method: 'getHomeZoom',
|
||||||
processExpected: function(level, expected){
|
processExpected: function(level, expected){
|
||||||
@ -332,13 +355,14 @@
|
|||||||
|
|
||||||
// I don't use the helper for this one because it sets a couple more
|
// I don't use the helper for this one because it sets a couple more
|
||||||
// properties that would need special casing.
|
// properties that would need special casing.
|
||||||
asyncTest('getHomeZoomWithHomeFillsViewer', function() {
|
QUnit.test('getHomeZoomWithHomeFillsViewer', function(assert) {
|
||||||
|
var done = assert.async();
|
||||||
var i = 0;
|
var i = 0;
|
||||||
var openHandler = function(event) {
|
var openHandler = function(event) {
|
||||||
var viewport = viewer.viewport;
|
var viewport = viewer.viewport;
|
||||||
viewport.zoomTo(ZOOM_FACTOR, null, true);
|
viewport.zoomTo(ZOOM_FACTOR, null, true);
|
||||||
|
|
||||||
equal(
|
assert.equal(
|
||||||
viewport.getHomeZoom(),
|
viewport.getHomeZoom(),
|
||||||
testZoomLevels[i],
|
testZoomLevels[i],
|
||||||
"Test getHomeZoom with homeFillsViewer = true and default zoom level of " + testZoomLevels[i]
|
"Test getHomeZoom with homeFillsViewer = true and default zoom level of " + testZoomLevels[i]
|
||||||
@ -355,7 +379,7 @@
|
|||||||
viewer.addOnceHandler('open', openHandler);
|
viewer.addOnceHandler('open', openHandler);
|
||||||
viewer.open(TALL_PATH); // use a different image for homeFillsViewer
|
viewer.open(TALL_PATH); // use a different image for homeFillsViewer
|
||||||
} else {
|
} else {
|
||||||
start();
|
done();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
viewer = OpenSeadragon({
|
viewer = OpenSeadragon({
|
||||||
@ -369,7 +393,8 @@
|
|||||||
viewer.open(TALL_PATH); // use a different image for homeFillsViewer
|
viewer.open(TALL_PATH); // use a different image for homeFillsViewer
|
||||||
});
|
});
|
||||||
|
|
||||||
asyncTest('resetContentSize', function(){
|
QUnit.test('resetContentSize', function(assert) {
|
||||||
|
var done = assert.async();
|
||||||
var openHandler = function(event) {
|
var openHandler = function(event) {
|
||||||
viewer.removeHandler('open', openHandler);
|
viewer.removeHandler('open', openHandler);
|
||||||
var viewport = viewer.viewport;
|
var viewport = viewer.viewport;
|
||||||
@ -377,19 +402,20 @@
|
|||||||
for(var i = 0; i < testRects.length; i++){
|
for(var i = 0; i < testRects.length; i++){
|
||||||
var rect = testRects[i].times(viewport.getContainerSize());
|
var rect = testRects[i].times(viewport.getContainerSize());
|
||||||
viewport.resetContentSize(rect.getSize());
|
viewport.resetContentSize(rect.getSize());
|
||||||
propEqual(
|
assert.propEqual(
|
||||||
viewport._contentSize,
|
viewport._contentSize,
|
||||||
rect.getSize(),
|
rect.getSize(),
|
||||||
"Reset content size correctly."
|
"Reset content size correctly."
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
start();
|
done();
|
||||||
};
|
};
|
||||||
viewer.addHandler('open', openHandler);
|
viewer.addHandler('open', openHandler);
|
||||||
viewer.open(DZI_PATH);
|
viewer.open(DZI_PATH);
|
||||||
});
|
});
|
||||||
|
|
||||||
asyncTest('goHome', function(){
|
QUnit.test('goHome', function(assert) {
|
||||||
|
var done = assert.async();
|
||||||
var openHandler = function(event) {
|
var openHandler = function(event) {
|
||||||
viewer.removeHandler('open', openHandler);
|
viewer.removeHandler('open', openHandler);
|
||||||
var viewport = viewer.viewport;
|
var viewport = viewer.viewport;
|
||||||
@ -398,18 +424,19 @@
|
|||||||
viewport.zoomTo(ZOOM_FACTOR, true);
|
viewport.zoomTo(ZOOM_FACTOR, true);
|
||||||
|
|
||||||
viewport.goHome(true);
|
viewport.goHome(true);
|
||||||
propEqual(
|
assert.propEqual(
|
||||||
viewport.getBounds(),
|
viewport.getBounds(),
|
||||||
viewport.getHomeBounds(),
|
viewport.getHomeBounds(),
|
||||||
"Went home."
|
"Went home."
|
||||||
);
|
);
|
||||||
start();
|
done();
|
||||||
};
|
};
|
||||||
viewer.addHandler('open', openHandler);
|
viewer.addHandler('open', openHandler);
|
||||||
viewer.open(DZI_PATH);
|
viewer.open(DZI_PATH);
|
||||||
});
|
});
|
||||||
|
|
||||||
asyncTest('ensureVisible', function() {
|
QUnit.test('ensureVisible', function(assert) {
|
||||||
|
var done = assert.async();
|
||||||
var openHandler = function(event) {
|
var openHandler = function(event) {
|
||||||
viewer.removeHandler('open', openHandler);
|
viewer.removeHandler('open', openHandler);
|
||||||
var viewport = viewer.viewport;
|
var viewport = viewer.viewport;
|
||||||
@ -420,14 +447,15 @@
|
|||||||
|
|
||||||
viewport.ensureVisible(true);
|
viewport.ensureVisible(true);
|
||||||
var bounds = viewport.getBounds();
|
var bounds = viewport.getBounds();
|
||||||
ok(bounds.getSize().x > 1 && bounds.getSize().y > 1, "Moved viewport so that image is visible.");
|
assert.ok(bounds.getSize().x > 1 && bounds.getSize().y > 1, "Moved viewport so that image is visible.");
|
||||||
start();
|
done();
|
||||||
};
|
};
|
||||||
viewer.addHandler('open', openHandler);
|
viewer.addHandler('open', openHandler);
|
||||||
viewer.open(DZI_PATH);
|
viewer.open(DZI_PATH);
|
||||||
});
|
});
|
||||||
|
|
||||||
asyncTest('applyConstraints', function() {
|
QUnit.test('applyConstraints', function(assert) {
|
||||||
|
var done = assert.async();
|
||||||
var openHandler = function() {
|
var openHandler = function() {
|
||||||
viewer.removeHandler('open', openHandler);
|
viewer.removeHandler('open', openHandler);
|
||||||
var viewport = viewer.viewport;
|
var viewport = viewer.viewport;
|
||||||
@ -437,17 +465,19 @@
|
|||||||
viewport.applyConstraints(true);
|
viewport.applyConstraints(true);
|
||||||
var bounds = viewport.getBounds();
|
var bounds = viewport.getBounds();
|
||||||
Util.assertRectangleEquals(
|
Util.assertRectangleEquals(
|
||||||
|
assert,
|
||||||
new OpenSeadragon.Rect(0.7, 0.7, 1, 1),
|
new OpenSeadragon.Rect(0.7, 0.7, 1, 1),
|
||||||
bounds,
|
bounds,
|
||||||
EPSILON,
|
EPSILON,
|
||||||
"Viewport.applyConstraints should move viewport.");
|
"Viewport.applyConstraints should move viewport.");
|
||||||
start();
|
done();
|
||||||
};
|
};
|
||||||
viewer.addHandler('open', openHandler);
|
viewer.addHandler('open', openHandler);
|
||||||
viewer.open(DZI_PATH);
|
viewer.open(DZI_PATH);
|
||||||
});
|
});
|
||||||
|
|
||||||
asyncTest('applyConstraints with visibilityRatio = 1 shouldn\'t bounce around', function() {
|
QUnit.test('applyConstraints with visibilityRatio = 1 shouldn\'t bounce around', function(assert) {
|
||||||
|
var done = assert.async();
|
||||||
var openHandler = function() {
|
var openHandler = function() {
|
||||||
viewer.removeHandler('open', openHandler);
|
viewer.removeHandler('open', openHandler);
|
||||||
var viewport = viewer.viewport;
|
var viewport = viewer.viewport;
|
||||||
@ -458,17 +488,19 @@
|
|||||||
viewport.applyConstraints(true);
|
viewport.applyConstraints(true);
|
||||||
var bounds = viewport.getBounds();
|
var bounds = viewport.getBounds();
|
||||||
Util.assertRectangleEquals(
|
Util.assertRectangleEquals(
|
||||||
|
assert,
|
||||||
new OpenSeadragon.Rect(-0.5, 1, 2, 2),
|
new OpenSeadragon.Rect(-0.5, 1, 2, 2),
|
||||||
bounds,
|
bounds,
|
||||||
EPSILON,
|
EPSILON,
|
||||||
"Viewport.applyConstraints should move viewport to the center, not to a side.");
|
"Viewport.applyConstraints should move viewport to the center, not to a side.");
|
||||||
start();
|
done();
|
||||||
};
|
};
|
||||||
viewer.addHandler('open', openHandler);
|
viewer.addHandler('open', openHandler);
|
||||||
viewer.open(TALL_PATH);
|
viewer.open(TALL_PATH);
|
||||||
});
|
});
|
||||||
|
|
||||||
asyncTest('applyConstraints with rotation', function() {
|
QUnit.test('applyConstraints with rotation', function(assert) {
|
||||||
|
var done = assert.async();
|
||||||
var openHandler = function() {
|
var openHandler = function() {
|
||||||
viewer.removeHandler('open', openHandler);
|
viewer.removeHandler('open', openHandler);
|
||||||
var viewport = viewer.viewport;
|
var viewport = viewer.viewport;
|
||||||
@ -477,11 +509,12 @@
|
|||||||
viewport.applyConstraints(true);
|
viewport.applyConstraints(true);
|
||||||
var bounds = viewport.getBounds();
|
var bounds = viewport.getBounds();
|
||||||
Util.assertRectangleEquals(
|
Util.assertRectangleEquals(
|
||||||
|
assert,
|
||||||
bounds,
|
bounds,
|
||||||
new OpenSeadragon.Rect(1, 0, Math.sqrt(2), Math.sqrt(2), 45),
|
new OpenSeadragon.Rect(1, 0, Math.sqrt(2), Math.sqrt(2), 45),
|
||||||
EPSILON,
|
EPSILON,
|
||||||
"Viewport.applyConstraints with rotation should move viewport.");
|
"Viewport.applyConstraints with rotation should move viewport.");
|
||||||
start();
|
done();
|
||||||
};
|
};
|
||||||
viewer.addHandler('open', openHandler);
|
viewer.addHandler('open', openHandler);
|
||||||
viewer.open(DZI_PATH);
|
viewer.open(DZI_PATH);
|
||||||
@ -545,7 +578,8 @@
|
|||||||
new OpenSeadragon.Rect(0.25, 0.25, 0.5, 0.5)
|
new OpenSeadragon.Rect(0.25, 0.25, 0.5, 0.5)
|
||||||
];
|
];
|
||||||
|
|
||||||
asyncTest('fitBounds', function(){
|
QUnit.test('fitBounds', function(assert) {
|
||||||
|
var done = assert.async();
|
||||||
var openHandler = function(event) {
|
var openHandler = function(event) {
|
||||||
viewer.removeHandler('open', openHandler);
|
viewer.removeHandler('open', openHandler);
|
||||||
var viewport = viewer.viewport;
|
var viewport = viewer.viewport;
|
||||||
@ -553,19 +587,20 @@
|
|||||||
for(var i = 0; i < testRectsFitBounds.length; i++){
|
for(var i = 0; i < testRectsFitBounds.length; i++){
|
||||||
var rect = testRectsFitBounds[i];
|
var rect = testRectsFitBounds[i];
|
||||||
viewport.fitBounds(rect, true);
|
viewport.fitBounds(rect, true);
|
||||||
propEqual(
|
assert.propEqual(
|
||||||
viewport.getBounds(),
|
viewport.getBounds(),
|
||||||
expectedRectsFitBounds[i],
|
expectedRectsFitBounds[i],
|
||||||
"Fit bounds correctly."
|
"Fit bounds correctly."
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
start();
|
done();
|
||||||
};
|
};
|
||||||
viewer.addHandler('open', openHandler);
|
viewer.addHandler('open', openHandler);
|
||||||
viewer.open(DZI_PATH);
|
viewer.open(DZI_PATH);
|
||||||
});
|
});
|
||||||
|
|
||||||
asyncTest('fitBounds with viewport rotation', function(){
|
QUnit.test('fitBounds with viewport rotation', function(assert) {
|
||||||
|
var done = assert.async();
|
||||||
var openHandler = function(event) {
|
var openHandler = function(event) {
|
||||||
viewer.removeHandler('open', openHandler);
|
viewer.removeHandler('open', openHandler);
|
||||||
var viewport = viewer.viewport;
|
var viewport = viewer.viewport;
|
||||||
@ -575,19 +610,21 @@
|
|||||||
var rect = testRectsFitBounds[i];
|
var rect = testRectsFitBounds[i];
|
||||||
viewport.fitBounds(rect, true);
|
viewport.fitBounds(rect, true);
|
||||||
Util.assertRectangleEquals(
|
Util.assertRectangleEquals(
|
||||||
|
assert,
|
||||||
viewport.getBounds(),
|
viewport.getBounds(),
|
||||||
expectedRectsFitBoundsWithRotation[i],
|
expectedRectsFitBoundsWithRotation[i],
|
||||||
EPSILON,
|
EPSILON,
|
||||||
"Fit bounds correctly."
|
"Fit bounds correctly."
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
start();
|
done();
|
||||||
};
|
};
|
||||||
viewer.addHandler('open', openHandler);
|
viewer.addHandler('open', openHandler);
|
||||||
viewer.open(DZI_PATH);
|
viewer.open(DZI_PATH);
|
||||||
});
|
});
|
||||||
|
|
||||||
asyncTest('fitBoundsWithConstraints', function(){
|
QUnit.test('fitBoundsWithConstraints', function(assert) {
|
||||||
|
var done = assert.async();
|
||||||
var openHandler = function(event) {
|
var openHandler = function(event) {
|
||||||
viewer.removeHandler('open', openHandler);
|
viewer.removeHandler('open', openHandler);
|
||||||
var viewport = viewer.viewport;
|
var viewport = viewer.viewport;
|
||||||
@ -596,90 +633,95 @@
|
|||||||
var rect = testRectsFitBounds[i];
|
var rect = testRectsFitBounds[i];
|
||||||
|
|
||||||
viewport.fitBoundsWithConstraints(rect, true);
|
viewport.fitBoundsWithConstraints(rect, true);
|
||||||
propEqual(
|
assert.propEqual(
|
||||||
viewport.getBounds(),
|
viewport.getBounds(),
|
||||||
expectedRectsFitBoundsWithConstraints[i],
|
expectedRectsFitBoundsWithConstraints[i],
|
||||||
"Fit bounds correctly."
|
"Fit bounds correctly."
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
start();
|
done();
|
||||||
};
|
};
|
||||||
viewer.addHandler('open', openHandler);
|
viewer.addHandler('open', openHandler);
|
||||||
viewer.open(DZI_PATH);
|
viewer.open(DZI_PATH);
|
||||||
});
|
});
|
||||||
|
|
||||||
asyncTest('fitBounds with almost same zoom', function() {
|
QUnit.test('fitBounds with almost same zoom', function(assert) {
|
||||||
|
var done = assert.async();
|
||||||
var openHandler = function() {
|
var openHandler = function() {
|
||||||
var viewport = viewer.viewport;
|
var viewport = viewer.viewport;
|
||||||
var rect1 = new OpenSeadragon.Rect(0, 0, 1, 1);
|
var rect1 = new OpenSeadragon.Rect(0, 0, 1, 1);
|
||||||
viewport.fitBounds(rect1, true);
|
viewport.fitBounds(rect1, true);
|
||||||
Util.assertRectangleEquals(rect1, viewport.getBounds(), 1e-6,
|
Util.assertRectangleEquals(assert, rect1, viewport.getBounds(), 1e-6,
|
||||||
'Bounds should be ' + rect1);
|
'Bounds should be ' + rect1);
|
||||||
|
|
||||||
// Zoom and pan
|
// Zoom and pan
|
||||||
var rect2 = new OpenSeadragon.Rect(1, 1, 1 + 1e-8, 1 + 1e-8);
|
var rect2 = new OpenSeadragon.Rect(1, 1, 1 + 1e-8, 1 + 1e-8);
|
||||||
viewport.fitBounds(rect2);
|
viewport.fitBounds(rect2);
|
||||||
Util.assertRectangleEquals(rect2, viewport.getBounds(), 1e-6,
|
Util.assertRectangleEquals(assert, rect2, viewport.getBounds(), 1e-6,
|
||||||
'Bounds should be ' + rect2);
|
'Bounds should be ' + rect2);
|
||||||
start();
|
done();
|
||||||
};
|
};
|
||||||
viewer.addOnceHandler('open', openHandler);
|
viewer.addOnceHandler('open', openHandler);
|
||||||
viewer.open(DZI_PATH);
|
viewer.open(DZI_PATH);
|
||||||
});
|
});
|
||||||
|
|
||||||
asyncTest('fitBounds with big rectangle', function() {
|
QUnit.test('fitBounds with big rectangle', function(assert) {
|
||||||
|
var done = assert.async();
|
||||||
var openHandler = function() {
|
var openHandler = function() {
|
||||||
var viewport = viewer.viewport;
|
var viewport = viewer.viewport;
|
||||||
var rect1 = new OpenSeadragon.Rect(0, 0, 1e9, 1e9);
|
var rect1 = new OpenSeadragon.Rect(0, 0, 1e9, 1e9);
|
||||||
viewport.fitBounds(rect1, true);
|
viewport.fitBounds(rect1, true);
|
||||||
Util.assertRectangleEquals(rect1, viewport.getBounds(), 1e-6,
|
Util.assertRectangleEquals(assert, rect1, viewport.getBounds(), 1e-6,
|
||||||
'Bounds should be ' + rect1);
|
'Bounds should be ' + rect1);
|
||||||
|
|
||||||
// Zoom and pan
|
// Zoom and pan
|
||||||
var rect2 = new OpenSeadragon.Rect(1, 1, 2e9, 2e9);
|
var rect2 = new OpenSeadragon.Rect(1, 1, 2e9, 2e9);
|
||||||
viewport.fitBounds(rect2);
|
viewport.fitBounds(rect2);
|
||||||
Util.assertRectangleEquals(rect2, viewport.getBounds(), 1e-6,
|
Util.assertRectangleEquals(assert, rect2, viewport.getBounds(), 1e-6,
|
||||||
'Bounds should be ' + rect2);
|
'Bounds should be ' + rect2);
|
||||||
start();
|
done();
|
||||||
};
|
};
|
||||||
viewer.addOnceHandler('open', openHandler);
|
viewer.addOnceHandler('open', openHandler);
|
||||||
viewer.open(DZI_PATH);
|
viewer.open(DZI_PATH);
|
||||||
});
|
});
|
||||||
|
|
||||||
asyncTest('fitHorizontally', function(){
|
QUnit.test('fitHorizontally', function(assert) {
|
||||||
|
var done = assert.async();
|
||||||
var openHandler = function(event) {
|
var openHandler = function(event) {
|
||||||
viewer.removeHandler('open', openHandler);
|
viewer.removeHandler('open', openHandler);
|
||||||
var viewport = viewer.viewport;
|
var viewport = viewer.viewport;
|
||||||
viewport.fitHorizontally(true);
|
viewport.fitHorizontally(true);
|
||||||
propEqual(
|
assert.propEqual(
|
||||||
viewport.getBounds(),
|
viewport.getBounds(),
|
||||||
new OpenSeadragon.Rect(0, 1.5, 1, 1),
|
new OpenSeadragon.Rect(0, 1.5, 1, 1),
|
||||||
"Viewport fit a tall image horizontally."
|
"Viewport fit a tall image horizontally."
|
||||||
);
|
);
|
||||||
start();
|
done();
|
||||||
};
|
};
|
||||||
viewer.addHandler('open', openHandler);
|
viewer.addHandler('open', openHandler);
|
||||||
viewer.open(TALL_PATH);
|
viewer.open(TALL_PATH);
|
||||||
});
|
});
|
||||||
|
|
||||||
asyncTest('fitVertically', function(){
|
QUnit.test('fitVertically', function(assert) {
|
||||||
|
var done = assert.async();
|
||||||
var openHandler = function(event) {
|
var openHandler = function(event) {
|
||||||
viewer.removeHandler('open', openHandler);
|
viewer.removeHandler('open', openHandler);
|
||||||
var viewport = viewer.viewport;
|
var viewport = viewer.viewport;
|
||||||
viewport.fitVertically(true);
|
viewport.fitVertically(true);
|
||||||
propEqual(
|
assert.propEqual(
|
||||||
viewport.getBounds(),
|
viewport.getBounds(),
|
||||||
new OpenSeadragon.Rect(0.375, 0, 0.25, 0.25),
|
new OpenSeadragon.Rect(0.375, 0, 0.25, 0.25),
|
||||||
"Viewport fit a wide image vertically."
|
"Viewport fit a wide image vertically."
|
||||||
);
|
);
|
||||||
start();
|
done();
|
||||||
};
|
};
|
||||||
viewer.addHandler('open', openHandler);
|
viewer.addHandler('open', openHandler);
|
||||||
viewer.open(WIDE_PATH);
|
viewer.open(WIDE_PATH);
|
||||||
});
|
});
|
||||||
// End fitBounds tests.
|
// End fitBounds tests.
|
||||||
|
|
||||||
asyncTest('panBy', function(){
|
QUnit.test('panBy', function(assert) {
|
||||||
|
var done = assert.async();
|
||||||
var openHandler = function(event) {
|
var openHandler = function(event) {
|
||||||
viewer.removeHandler('open', openHandler);
|
viewer.removeHandler('open', openHandler);
|
||||||
var viewport = viewer.viewport;
|
var viewport = viewer.viewport;
|
||||||
@ -687,60 +729,63 @@
|
|||||||
for (var i = 0; i < testPoints.length; i++){
|
for (var i = 0; i < testPoints.length; i++){
|
||||||
var expected = viewport.getCenter().plus(testPoints[i]);
|
var expected = viewport.getCenter().plus(testPoints[i]);
|
||||||
viewport.panBy(testPoints[i], true);
|
viewport.panBy(testPoints[i], true);
|
||||||
propEqual(
|
assert.propEqual(
|
||||||
viewport.getCenter(),
|
viewport.getCenter(),
|
||||||
expected,
|
expected,
|
||||||
"Panned by the correct amount."
|
"Panned by the correct amount."
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
start();
|
done();
|
||||||
};
|
};
|
||||||
viewer.addHandler('open', openHandler);
|
viewer.addHandler('open', openHandler);
|
||||||
viewer.open(DZI_PATH);
|
viewer.open(DZI_PATH);
|
||||||
});
|
});
|
||||||
|
|
||||||
asyncTest('panTo', function(){
|
QUnit.test('panTo', function(assert) {
|
||||||
|
var done = assert.async();
|
||||||
var openHandler = function(event) {
|
var openHandler = function(event) {
|
||||||
viewer.removeHandler('open', openHandler);
|
viewer.removeHandler('open', openHandler);
|
||||||
var viewport = viewer.viewport;
|
var viewport = viewer.viewport;
|
||||||
|
|
||||||
for (var i = 0; i < testPoints.length; i++){
|
for (var i = 0; i < testPoints.length; i++){
|
||||||
viewport.panTo(testPoints[i], true);
|
viewport.panTo(testPoints[i], true);
|
||||||
propEqual(
|
assert.propEqual(
|
||||||
viewport.getCenter(),
|
viewport.getCenter(),
|
||||||
testPoints[i],
|
testPoints[i],
|
||||||
"Panned to the correct location."
|
"Panned to the correct location."
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
start();
|
done();
|
||||||
};
|
};
|
||||||
viewer.addHandler('open', openHandler);
|
viewer.addHandler('open', openHandler);
|
||||||
viewer.open(DZI_PATH);
|
viewer.open(DZI_PATH);
|
||||||
});
|
});
|
||||||
|
|
||||||
asyncTest('zoomBy no ref point', function() {
|
QUnit.test('zoomBy no ref point', function(assert) {
|
||||||
|
var done = assert.async();
|
||||||
var openHandler = function(event) {
|
var openHandler = function(event) {
|
||||||
viewer.removeHandler('open', openHandler);
|
viewer.removeHandler('open', openHandler);
|
||||||
var viewport = viewer.viewport;
|
var viewport = viewer.viewport;
|
||||||
|
|
||||||
for (var i = 0; i < testZoomLevels.length; i++) {
|
for (var i = 0; i < testZoomLevels.length; i++) {
|
||||||
viewport.zoomBy(testZoomLevels[i], null, true);
|
viewport.zoomBy(testZoomLevels[i], null, true);
|
||||||
propEqual(
|
assert.propEqual(
|
||||||
viewport.getZoom(),
|
viewport.getZoom(),
|
||||||
testZoomLevels[i],
|
testZoomLevels[i],
|
||||||
"Zoomed by the correct amount."
|
"Zoomed by the correct amount."
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
start();
|
done();
|
||||||
};
|
};
|
||||||
viewer.addHandler('open', openHandler);
|
viewer.addHandler('open', openHandler);
|
||||||
viewer.open(DZI_PATH);
|
viewer.open(DZI_PATH);
|
||||||
});
|
});
|
||||||
|
|
||||||
asyncTest('zoomBy with ref point', function() {
|
QUnit.test('zoomBy with ref point', function(assert) {
|
||||||
|
var done = assert.async();
|
||||||
var openHandler = function(event) {
|
var openHandler = function(event) {
|
||||||
viewer.removeHandler('open', openHandler);
|
viewer.removeHandler('open', openHandler);
|
||||||
var viewport = viewer.viewport;
|
var viewport = viewer.viewport;
|
||||||
@ -756,12 +801,13 @@
|
|||||||
|
|
||||||
for (var i = 0; i < testZoomLevels.length; i++) {
|
for (var i = 0; i < testZoomLevels.length; i++) {
|
||||||
viewport.zoomBy(testZoomLevels[i], testPoints[i], true);
|
viewport.zoomBy(testZoomLevels[i], testPoints[i], true);
|
||||||
propEqual(
|
assert.propEqual(
|
||||||
viewport.getZoom(),
|
viewport.getZoom(),
|
||||||
testZoomLevels[i],
|
testZoomLevels[i],
|
||||||
"Zoomed by the correct amount."
|
"Zoomed by the correct amount."
|
||||||
);
|
);
|
||||||
assertPointsEquals(
|
assertPointsEquals(
|
||||||
|
assert,
|
||||||
viewport.getCenter(),
|
viewport.getCenter(),
|
||||||
expectedCenters[i],
|
expectedCenters[i],
|
||||||
1e-14,
|
1e-14,
|
||||||
@ -769,33 +815,35 @@
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
start();
|
done();
|
||||||
};
|
};
|
||||||
viewer.addHandler('open', openHandler);
|
viewer.addHandler('open', openHandler);
|
||||||
viewer.open(DZI_PATH);
|
viewer.open(DZI_PATH);
|
||||||
});
|
});
|
||||||
|
|
||||||
asyncTest('zoomTo no ref point', function() {
|
QUnit.test('zoomTo no ref point', function(assert) {
|
||||||
|
var done = assert.async();
|
||||||
var openHandler = function(event) {
|
var openHandler = function(event) {
|
||||||
viewer.removeHandler('open', openHandler);
|
viewer.removeHandler('open', openHandler);
|
||||||
var viewport = viewer.viewport;
|
var viewport = viewer.viewport;
|
||||||
|
|
||||||
for (var i = 0; i < testZoomLevels.length; i++) {
|
for (var i = 0; i < testZoomLevels.length; i++) {
|
||||||
viewport.zoomTo(testZoomLevels[i], null, true);
|
viewport.zoomTo(testZoomLevels[i], null, true);
|
||||||
propEqual(
|
assert.propEqual(
|
||||||
viewport.getZoom(),
|
viewport.getZoom(),
|
||||||
testZoomLevels[i],
|
testZoomLevels[i],
|
||||||
"Zoomed to the correct level."
|
"Zoomed to the correct level."
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
start();
|
done();
|
||||||
};
|
};
|
||||||
viewer.addHandler('open', openHandler);
|
viewer.addHandler('open', openHandler);
|
||||||
viewer.open(DZI_PATH);
|
viewer.open(DZI_PATH);
|
||||||
});
|
});
|
||||||
|
|
||||||
asyncTest('zoomTo with ref point', function() {
|
QUnit.test('zoomTo with ref point', function(assert) {
|
||||||
|
var done = assert.async();
|
||||||
var openHandler = function(event) {
|
var openHandler = function(event) {
|
||||||
viewer.removeHandler('open', openHandler);
|
viewer.removeHandler('open', openHandler);
|
||||||
var viewport = viewer.viewport;
|
var viewport = viewer.viewport;
|
||||||
@ -811,12 +859,13 @@
|
|||||||
|
|
||||||
for (var i = 0; i < testZoomLevels.length; i++) {
|
for (var i = 0; i < testZoomLevels.length; i++) {
|
||||||
viewport.zoomTo(testZoomLevels[i], testPoints[i], true);
|
viewport.zoomTo(testZoomLevels[i], testPoints[i], true);
|
||||||
propEqual(
|
assert.propEqual(
|
||||||
viewport.getZoom(),
|
viewport.getZoom(),
|
||||||
testZoomLevels[i],
|
testZoomLevels[i],
|
||||||
"Zoomed to the correct level."
|
"Zoomed to the correct level."
|
||||||
);
|
);
|
||||||
assertPointsEquals(
|
assertPointsEquals(
|
||||||
|
assert,
|
||||||
viewport.getCenter(),
|
viewport.getCenter(),
|
||||||
expectedCenters[i],
|
expectedCenters[i],
|
||||||
1e-14,
|
1e-14,
|
||||||
@ -824,30 +873,32 @@
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
start();
|
done();
|
||||||
};
|
};
|
||||||
viewer.addHandler('open', openHandler);
|
viewer.addHandler('open', openHandler);
|
||||||
viewer.open(DZI_PATH);
|
viewer.open(DZI_PATH);
|
||||||
});
|
});
|
||||||
|
|
||||||
asyncTest('rotation', function(){
|
QUnit.test('rotation', function(assert){
|
||||||
|
var done = assert.async();
|
||||||
var openHandler = function(event) {
|
var openHandler = function(event) {
|
||||||
viewer.removeHandler('open', openHandler);
|
viewer.removeHandler('open', openHandler);
|
||||||
var viewport = viewer.viewport;
|
var viewport = viewer.viewport;
|
||||||
|
|
||||||
propEqual(viewport.getRotation, 0, "Original rotation should be 0 degrees");
|
assert.propEqual(viewport.getRotation, 0, "Original rotation should be 0 degrees");
|
||||||
viewport.setRotation(90);
|
viewport.setRotation(90);
|
||||||
propEqual(viewport.getRotation, 90, "Rotation should be 90 degrees");
|
assert.propEqual(viewport.getRotation, 90, "Rotation should be 90 degrees");
|
||||||
viewport.setRotation(-75);
|
viewport.setRotation(-75);
|
||||||
propEqual(viewport.getRotation, -75, "Rotation should be -75 degrees");
|
assert.propEqual(viewport.getRotation, -75, "Rotation should be -75 degrees");
|
||||||
start();
|
done();
|
||||||
};
|
};
|
||||||
|
|
||||||
viewer.addHandler('open', openHandler);
|
viewer.addHandler('open', openHandler);
|
||||||
viewer.open(DZI_PATH);
|
viewer.open(DZI_PATH);
|
||||||
});
|
});
|
||||||
|
|
||||||
asyncTest('resize', function() {
|
QUnit.test('resize', function(assert) {
|
||||||
|
var done = assert.async();
|
||||||
var openHandler = function(event) {
|
var openHandler = function(event) {
|
||||||
viewer.removeHandler('open', openHandler);
|
viewer.removeHandler('open', openHandler);
|
||||||
var viewport = viewer.viewport;
|
var viewport = viewer.viewport;
|
||||||
@ -855,16 +906,16 @@
|
|||||||
for(var i = 0; i < testPoints.length; i++){
|
for(var i = 0; i < testPoints.length; i++){
|
||||||
var new_size = testPoints[i].times(viewer.source.dimensions.x);
|
var new_size = testPoints[i].times(viewer.source.dimensions.x);
|
||||||
viewport.resize(new_size);
|
viewport.resize(new_size);
|
||||||
propEqual(viewport.getContainerSize(), new_size, "Viewport resized successfully.");
|
assert.propEqual(viewport.getContainerSize(), new_size, "Viewport resized successfully.");
|
||||||
}
|
}
|
||||||
start();
|
done();
|
||||||
};
|
};
|
||||||
viewer.addHandler('open', openHandler);
|
viewer.addHandler('open', openHandler);
|
||||||
viewer.open(DZI_PATH);
|
viewer.open(DZI_PATH);
|
||||||
});
|
});
|
||||||
|
|
||||||
asyncTest('deltaPixelsFromPoints', function() {
|
QUnit.test('deltaPixelsFromPoints', function(assert) {
|
||||||
loopingTestHelper({
|
loopingTestHelper(assert, {
|
||||||
testArray: testPoints,
|
testArray: testPoints,
|
||||||
getOrig: function(el, viewport){
|
getOrig: function(el, viewport){
|
||||||
return el.times(viewer.source.dimensions.x);
|
return el.times(viewer.source.dimensions.x);
|
||||||
@ -876,8 +927,8 @@
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
asyncTest('deltaPointsFromPixels', function() {
|
QUnit.test('deltaPointsFromPixels', function(assert) {
|
||||||
loopingTestHelper({
|
loopingTestHelper(assert, {
|
||||||
testArray: testPoints,
|
testArray: testPoints,
|
||||||
getOrig: function(el, viewport) {
|
getOrig: function(el, viewport) {
|
||||||
return el.times(viewport.getContainerSize().x);
|
return el.times(viewport.getContainerSize().x);
|
||||||
@ -889,8 +940,8 @@
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
asyncTest('pixelFromPoint', function() {
|
QUnit.test('pixelFromPoint', function(assert) {
|
||||||
loopingTestHelper({
|
loopingTestHelper(assert, {
|
||||||
testArray: testPoints,
|
testArray: testPoints,
|
||||||
getOrig: function(el, viewport) {
|
getOrig: function(el, viewport) {
|
||||||
return el.times(viewer.source.dimensions.x);
|
return el.times(viewer.source.dimensions.x);
|
||||||
@ -902,8 +953,8 @@
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
asyncTest('pointFromPixel', function() {
|
QUnit.test('pointFromPixel', function(assert) {
|
||||||
loopingTestHelper({
|
loopingTestHelper(assert, {
|
||||||
testArray: testPoints,
|
testArray: testPoints,
|
||||||
getOrig: function(el, viewport) {
|
getOrig: function(el, viewport) {
|
||||||
return el.times(viewport.getContainerSize().x);
|
return el.times(viewport.getContainerSize().x);
|
||||||
@ -915,8 +966,8 @@
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
asyncTest('viewportToImageCoordinates', function() {
|
QUnit.test('viewportToImageCoordinates', function(assert) {
|
||||||
loopingTestHelper({
|
loopingTestHelper(assert, {
|
||||||
testArray: testPoints,
|
testArray: testPoints,
|
||||||
getOrig: function(el, viewport) {
|
getOrig: function(el, viewport) {
|
||||||
return el.times(viewport.getContainerSize().x);
|
return el.times(viewport.getContainerSize().x);
|
||||||
@ -929,8 +980,8 @@
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
asyncTest('imageToViewportCoordinates', function() {
|
QUnit.test('imageToViewportCoordinates', function(assert) {
|
||||||
loopingTestHelper({
|
loopingTestHelper(assert, {
|
||||||
testArray: testPoints,
|
testArray: testPoints,
|
||||||
getOrig: function(el, viewport) {
|
getOrig: function(el, viewport) {
|
||||||
return el.times(viewer.source.dimensions.x);
|
return el.times(viewer.source.dimensions.x);
|
||||||
@ -942,8 +993,8 @@
|
|||||||
assert: assertPointsEquals
|
assert: assertPointsEquals
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
asyncTest('imageToViewportRectangle', function() {
|
QUnit.test('imageToViewportRectangle', function(assert) {
|
||||||
loopingTestHelper({
|
loopingTestHelper(assert, {
|
||||||
testArray: testRects,
|
testArray: testRects,
|
||||||
getOrig: function(el, viewport) {
|
getOrig: function(el, viewport) {
|
||||||
return el.times(viewer.source.dimensions.x);
|
return el.times(viewer.source.dimensions.x);
|
||||||
@ -961,8 +1012,8 @@
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
asyncTest('viewportToImageRectangle', function() {
|
QUnit.test('viewportToImageRectangle', function(assert) {
|
||||||
loopingTestHelper({
|
loopingTestHelper(assert, {
|
||||||
testArray: testRects,
|
testArray: testRects,
|
||||||
getOrig: function(el, viewport) {
|
getOrig: function(el, viewport) {
|
||||||
return el.times(viewport.getContainerSize().x);
|
return el.times(viewport.getContainerSize().x);
|
||||||
@ -979,8 +1030,8 @@
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
asyncTest('viewerElementToImageCoordinates', function() {
|
QUnit.test('viewerElementToImageCoordinates', function(assert) {
|
||||||
loopingTestHelper({
|
loopingTestHelper(assert, {
|
||||||
testArray: testPoints,
|
testArray: testPoints,
|
||||||
getOrig: function(el, viewport) {
|
getOrig: function(el, viewport) {
|
||||||
return el.times(viewport.getContainerSize().x);
|
return el.times(viewport.getContainerSize().x);
|
||||||
@ -992,8 +1043,8 @@
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
asyncTest('imageToViewerElementCoordinates', function() {
|
QUnit.test('imageToViewerElementCoordinates', function(assert) {
|
||||||
loopingTestHelper({
|
loopingTestHelper(assert, {
|
||||||
testArray: testPoints,
|
testArray: testPoints,
|
||||||
getOrig: function(el, viewport) {
|
getOrig: function(el, viewport) {
|
||||||
return el.times(viewer.source.dimensions.x);
|
return el.times(viewer.source.dimensions.x);
|
||||||
@ -1005,8 +1056,8 @@
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
asyncTest('windowToImageCoordinates', function() {
|
QUnit.test('windowToImageCoordinates', function(assert) {
|
||||||
loopingTestHelper({
|
loopingTestHelper(assert, {
|
||||||
testArray: testPoints,
|
testArray: testPoints,
|
||||||
getOrig: function(el, viewport) {
|
getOrig: function(el, viewport) {
|
||||||
var window_boundary = Math.min(window.innerWidth, window.innerHeight);
|
var window_boundary = Math.min(window.innerWidth, window.innerHeight);
|
||||||
@ -1020,8 +1071,8 @@
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
asyncTest('imageToWindowCoordinates', function() {
|
QUnit.test('imageToWindowCoordinates', function(assert) {
|
||||||
loopingTestHelper({
|
loopingTestHelper(assert, {
|
||||||
testArray: testPoints,
|
testArray: testPoints,
|
||||||
getOrig: function(el, viewport) {
|
getOrig: function(el, viewport) {
|
||||||
return el.times(viewer.source.dimensions.x);
|
return el.times(viewer.source.dimensions.x);
|
||||||
@ -1034,8 +1085,8 @@
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
asyncTest('windowToViewportCoordinates', function() {
|
QUnit.test('windowToViewportCoordinates', function(assert) {
|
||||||
loopingTestHelper({
|
loopingTestHelper(assert, {
|
||||||
testArray: testPoints,
|
testArray: testPoints,
|
||||||
getOrig: function(el, viewport) {
|
getOrig: function(el, viewport) {
|
||||||
var window_boundary = Math.min(window.innerWidth, window.innerHeight);
|
var window_boundary = Math.min(window.innerWidth, window.innerHeight);
|
||||||
@ -1049,8 +1100,8 @@
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
asyncTest('viewportToWindowCoordinates', function() {
|
QUnit.test('viewportToWindowCoordinates', function(assert) {
|
||||||
loopingTestHelper({
|
loopingTestHelper(assert, {
|
||||||
testArray: testPoints,
|
testArray: testPoints,
|
||||||
getOrig: function(el, viewport) {
|
getOrig: function(el, viewport) {
|
||||||
return el.times(viewer.source.dimensions.x);
|
return el.times(viewer.source.dimensions.x);
|
||||||
@ -1063,8 +1114,8 @@
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
asyncTest('viewportToImageZoom', function() {
|
QUnit.test('viewportToImageZoom', function(assert) {
|
||||||
loopingTestHelper({
|
loopingTestHelper(assert, {
|
||||||
testArray: testPoints,
|
testArray: testPoints,
|
||||||
getOrig: function(el, viewport) {
|
getOrig: function(el, viewport) {
|
||||||
return el;
|
return el;
|
||||||
@ -1076,8 +1127,8 @@
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
asyncTest('imageToViewportZoom', function() {
|
QUnit.test('imageToViewportZoom', function(assert) {
|
||||||
loopingTestHelper({
|
loopingTestHelper(assert, {
|
||||||
testArray: testPoints,
|
testArray: testPoints,
|
||||||
getOrig: function(el, viewport) {
|
getOrig: function(el, viewport) {
|
||||||
return el;
|
return el;
|
||||||
|
@ -30,9 +30,9 @@
|
|||||||
<script src="/test/modules/units.js"></script>
|
<script src="/test/modules/units.js"></script>
|
||||||
<script src="/test/modules/multi-image.js"></script>
|
<script src="/test/modules/multi-image.js"></script>
|
||||||
<script src="/test/modules/overlays.js"></script>
|
<script src="/test/modules/overlays.js"></script>
|
||||||
<!--<script src="/test/modules/controls.js"></script>
|
<script src="/test/modules/controls.js"></script>
|
||||||
<script src="/test/modules/viewport.js"></script>
|
<script src="/test/modules/viewport.js"></script>
|
||||||
<script src="/test/modules/world.js"></script>
|
<!--<script src="/test/modules/world.js"></script>
|
||||||
<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>
|
||||||
|
Loading…
Reference in New Issue
Block a user