mirror of
https://github.com/openseadragon/openseadragon.git
synced 2024-11-29 08:36:10 +03:00
Unit tests for canvas drag, release, click events
This commit is contained in:
parent
1a005573f5
commit
0bbf6bc58a
@ -42,8 +42,8 @@
|
|||||||
|
|
||||||
// ----------
|
// ----------
|
||||||
asyncTest( 'addHandler with userData', function () {
|
asyncTest( 'addHandler with userData', function () {
|
||||||
var userData = { item1: 'Test user data', item2: Math.random() };
|
var userData = { item1: 'Test user data', item2: Math.random() },
|
||||||
var originalUserData = { item1: userData.item1, item2: userData.item2 };
|
originalUserData = { item1: userData.item1, item2: userData.item2 };
|
||||||
|
|
||||||
var openHandler = function ( eventSender, eventData ) {
|
var openHandler = function ( eventSender, eventData ) {
|
||||||
viewer.removeHandler( 'open', openHandler );
|
viewer.removeHandler( 'open', openHandler );
|
||||||
@ -62,8 +62,10 @@
|
|||||||
|
|
||||||
// ----------
|
// ----------
|
||||||
asyncTest( 'canvas-drag canvas-release canvas-click', function () {
|
asyncTest( 'canvas-drag canvas-release canvas-click', function () {
|
||||||
var dragCount = 10;
|
var dragCount = 10,
|
||||||
var dragMovesHandled = 0;
|
dragMovesHandled = 0,
|
||||||
|
releasesHandled = 0,
|
||||||
|
releasesExpected = 1;
|
||||||
|
|
||||||
var openHandler = function ( eventSender, eventData ) {
|
var openHandler = function ( eventSender, eventData ) {
|
||||||
viewer.removeHandler( 'open', openHandler );
|
viewer.removeHandler( 'open', openHandler );
|
||||||
@ -83,19 +85,19 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
var canvasDragHandler = function ( eventSender, eventData ) {
|
var canvasDragHandler = function ( eventSender, eventData ) {
|
||||||
dragMovesHandled += 1;
|
dragMovesHandled++;
|
||||||
};
|
};
|
||||||
|
|
||||||
var canvasReleaseHandler = function ( eventSender, eventData ) {
|
var canvasReleaseHandler = function ( eventSender, eventData ) {
|
||||||
ok( true, 'canvas-release event handled' );
|
releasesHandled++;
|
||||||
};
|
};
|
||||||
|
|
||||||
var canvasClickHandler = function ( eventSender, eventData ) {
|
var canvasClickHandler = function ( eventSender, eventData ) {
|
||||||
viewer.removeHandler( 'canvas-drag', canvasDragHandler );
|
viewer.removeHandler( 'canvas-drag', canvasDragHandler );
|
||||||
viewer.removeHandler( 'canvas-release', canvasReleaseHandler );
|
viewer.removeHandler( 'canvas-release', canvasReleaseHandler );
|
||||||
viewer.removeHandler( 'canvas-click', canvasClickHandler );
|
viewer.removeHandler( 'canvas-click', canvasClickHandler );
|
||||||
ok( true, 'canvas-click event handled' );
|
equal( dragMovesHandled, dragCount, "'canvas-drag' event count matches 'mousemove' event count (" + dragCount + ")" );
|
||||||
equal( dragMovesHandled, dragCount, "'canvas-drag' event count matches 'mousemove' event count" );
|
equal( releasesHandled, releasesExpected, "'canvas-release' event count matches expected (" + releasesExpected + ")" );
|
||||||
viewer.close();
|
viewer.close();
|
||||||
start();
|
start();
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user