2013-02-14 22:21:07 +04:00
|
|
|
(function() {
|
|
|
|
|
2013-05-09 22:02:51 +04:00
|
|
|
module('Basic');
|
2013-06-19 21:33:25 +04:00
|
|
|
|
2013-03-22 00:44:22 +04:00
|
|
|
// TODO: Test drag
|
|
|
|
|
2013-03-07 23:52:01 +04:00
|
|
|
var viewer = null;
|
|
|
|
|
|
|
|
// ----------
|
|
|
|
asyncTest('Open', function() {
|
2013-03-07 22:44:08 +04:00
|
|
|
$(document).ready(function() {
|
2013-03-07 23:52:01 +04:00
|
|
|
viewer = OpenSeadragon({
|
2013-03-07 22:44:08 +04:00
|
|
|
id: 'example',
|
|
|
|
prefixUrl: '/build/openseadragon/images/',
|
2013-05-13 21:57:16 +04:00
|
|
|
tileSources: '/test/data/testpattern.dzi',
|
2013-06-18 22:08:16 +04:00
|
|
|
springStiffness: 100 // Faster animation = faster tests
|
2013-03-07 22:44:08 +04:00
|
|
|
});
|
|
|
|
|
|
|
|
ok(viewer, 'Viewer exists');
|
2013-03-07 23:52:01 +04:00
|
|
|
|
|
|
|
var openHandler = function(eventSender, eventData) {
|
|
|
|
viewer.removeHandler('open', openHandler);
|
2013-03-07 22:44:08 +04:00
|
|
|
ok(true, 'Open event was sent');
|
2013-03-22 00:44:22 +04:00
|
|
|
equal(eventSender, viewer, 'Sender of open event was viewer');
|
2013-03-07 22:44:08 +04:00
|
|
|
ok(eventData, 'Handler also received event data');
|
2013-03-07 23:52:01 +04:00
|
|
|
ok(viewer.viewport, 'Viewport exists');
|
2013-06-18 22:08:33 +04:00
|
|
|
ok(viewer.source, 'source exists');
|
|
|
|
ok(viewer._updateRequestId, 'timer is on');
|
2013-03-07 22:44:08 +04:00
|
|
|
start();
|
2013-03-07 23:52:01 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
viewer.addHandler('open', openHandler);
|
2013-03-07 22:44:08 +04:00
|
|
|
});
|
2013-03-07 23:52:01 +04:00
|
|
|
});
|
|
|
|
|
|
|
|
// ----------
|
|
|
|
asyncTest('Zoom', function() {
|
|
|
|
var viewport = viewer.viewport;
|
2013-03-22 00:44:22 +04:00
|
|
|
equal(viewport.getZoom(), 1, 'We start out unzoomed');
|
2013-03-07 23:52:01 +04:00
|
|
|
|
|
|
|
var zoomHandler = function() {
|
|
|
|
viewer.removeHandler('animationfinish', zoomHandler);
|
2013-03-22 00:44:22 +04:00
|
|
|
equal(viewport.getZoom(), 2, 'Zoomed correctly');
|
2013-03-07 23:52:01 +04:00
|
|
|
start();
|
|
|
|
};
|
|
|
|
|
|
|
|
viewer.addHandler('animationfinish', zoomHandler);
|
|
|
|
viewport.zoomTo(2);
|
|
|
|
});
|
|
|
|
|
|
|
|
// ----------
|
|
|
|
asyncTest('Pan', function() {
|
|
|
|
var viewport = viewer.viewport;
|
|
|
|
var center = viewport.getCenter();
|
|
|
|
ok(center.x === 0.5 && center.y === 0.5, 'We start out unpanned');
|
|
|
|
|
|
|
|
var panHandler = function() {
|
|
|
|
viewer.removeHandler('animationfinish', panHandler);
|
|
|
|
center = viewport.getCenter();
|
|
|
|
ok(center.x === 0.1 && center.y === 0.1, 'Panned correctly');
|
|
|
|
start();
|
|
|
|
};
|
|
|
|
|
|
|
|
viewer.addHandler('animationfinish', panHandler);
|
|
|
|
viewport.panTo(new OpenSeadragon.Point(0.1, 0.1));
|
|
|
|
});
|
|
|
|
|
2013-03-22 00:44:22 +04:00
|
|
|
// ----------
|
|
|
|
asyncTest('Home', function() {
|
|
|
|
var viewport = viewer.viewport;
|
|
|
|
var center = viewport.getCenter();
|
|
|
|
ok(center.x !== 0.5 && center.y !== 0.5, 'We start out panned');
|
|
|
|
notEqual(viewport.getZoom(), 1, 'We start out zoomed');
|
|
|
|
|
|
|
|
var homeHandler = function() {
|
|
|
|
viewer.removeHandler('animationfinish', homeHandler);
|
|
|
|
center = viewport.getCenter();
|
|
|
|
ok(center.x === 0.5 && center.y === 0.5, 'We end up unpanned');
|
|
|
|
equal(viewport.getZoom(), 1, 'We end up unzoomed');
|
|
|
|
start();
|
|
|
|
};
|
|
|
|
|
|
|
|
viewer.addHandler('animationfinish', homeHandler);
|
|
|
|
viewport.goHome(true);
|
|
|
|
});
|
|
|
|
|
|
|
|
// ----------
|
|
|
|
asyncTest('Click', function() {
|
|
|
|
var viewport = viewer.viewport;
|
|
|
|
center = viewport.getCenter();
|
|
|
|
ok(center.x === 0.5 && center.y === 0.5, 'We start out unpanned');
|
|
|
|
equal(viewport.getZoom(), 1, 'We start out unzoomed');
|
|
|
|
|
|
|
|
var clickHandler = function() {
|
|
|
|
viewer.removeHandler('animationfinish', clickHandler);
|
|
|
|
center = viewport.getCenter();
|
|
|
|
ok(center.x > 0.37 && center.x < 0.38 && center.y > 0.37 && center.y < 0.38, 'Panned correctly');
|
|
|
|
equal(viewport.getZoom(), 2, 'Zoomed correctly');
|
|
|
|
start();
|
|
|
|
};
|
|
|
|
|
|
|
|
viewer.addHandler('animationfinish', clickHandler);
|
|
|
|
Util.simulateViewerClick(viewer, 0.25, 0.25);
|
|
|
|
});
|
|
|
|
|
2013-05-14 06:35:27 +04:00
|
|
|
// ----------
|
|
|
|
test('Fullscreen', function() {
|
|
|
|
ok(!viewer.isFullPage(), 'Started out not fullpage');
|
|
|
|
ok(!$(viewer.element).hasClass('fullpage'),
|
|
|
|
'No fullpage class on div');
|
|
|
|
|
|
|
|
viewer.setFullPage(true);
|
|
|
|
ok(viewer.isFullPage(), 'Enabled fullpage');
|
|
|
|
ok($(viewer.element).hasClass('fullpage'),
|
|
|
|
'Fullpage class added to div');
|
|
|
|
|
|
|
|
viewer.setFullPage(false);
|
|
|
|
ok(!viewer.isFullPage(), 'Disabled fullpage');
|
|
|
|
ok(!$(viewer.element).hasClass('fullpage'),
|
|
|
|
'Fullpage class removed from div');
|
|
|
|
});
|
|
|
|
|
2013-03-07 23:52:01 +04:00
|
|
|
// ----------
|
|
|
|
asyncTest('Close', function() {
|
|
|
|
var closeHandler = function() {
|
|
|
|
viewer.removeHandler('close', closeHandler);
|
2013-06-18 22:08:33 +04:00
|
|
|
ok(!viewer.source, 'no source');
|
2013-05-09 22:02:51 +04:00
|
|
|
$('#example').empty();
|
2013-03-07 23:52:01 +04:00
|
|
|
ok(true, 'Close event was sent');
|
2013-06-18 22:08:33 +04:00
|
|
|
ok(!viewer._updateRequestId, 'timer is off');
|
|
|
|
setTimeout(function() {
|
|
|
|
ok(!viewer._updateRequestId, 'timer is still off');
|
|
|
|
start();
|
|
|
|
}, 100);
|
2013-03-07 23:52:01 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
viewer.addHandler('close', closeHandler);
|
|
|
|
viewer.close();
|
|
|
|
});
|
2013-06-19 21:33:25 +04:00
|
|
|
|
2013-02-14 22:21:07 +04:00
|
|
|
})();
|