Unit tests for canvas drag, release, click events

This commit is contained in:
Mark Salsbery 2013-08-30 10:09:22 -07:00
parent 1a005573f5
commit 0bbf6bc58a

View File

@ -42,8 +42,8 @@
// ----------
asyncTest( 'addHandler with userData', function () {
var userData = { item1: 'Test user data', item2: Math.random() };
var originalUserData = { item1: userData.item1, item2: userData.item2 };
var userData = { item1: 'Test user data', item2: Math.random() },
originalUserData = { item1: userData.item1, item2: userData.item2 };
var openHandler = function ( eventSender, eventData ) {
viewer.removeHandler( 'open', openHandler );
@ -62,8 +62,10 @@
// ----------
asyncTest( 'canvas-drag canvas-release canvas-click', function () {
var dragCount = 10;
var dragMovesHandled = 0;
var dragCount = 10,
dragMovesHandled = 0,
releasesHandled = 0,
releasesExpected = 1;
var openHandler = function ( eventSender, eventData ) {
viewer.removeHandler( 'open', openHandler );
@ -72,30 +74,30 @@
viewer.addHandler( 'canvas-release', canvasReleaseHandler );
viewer.addHandler( 'canvas-click', canvasClickHandler );
Util.simulateViewerClickWithDrag( {
viewer: viewer,
widthFactor: 0.25,
heightFactor: 0.25,
dragCount: dragCount,
dragDx: 1,
dragDy: 1
Util.simulateViewerClickWithDrag( {
viewer: viewer,
widthFactor: 0.25,
heightFactor: 0.25,
dragCount: dragCount,
dragDx: 1,
dragDy: 1
} );
};
var canvasDragHandler = function ( eventSender, eventData ) {
dragMovesHandled += 1;
dragMovesHandled++;
};
var canvasReleaseHandler = function ( eventSender, eventData ) {
ok( true, 'canvas-release event handled' );
releasesHandled++;
};
var canvasClickHandler = function ( eventSender, eventData ) {
viewer.removeHandler( 'canvas-drag', canvasDragHandler );
viewer.removeHandler( 'canvas-release', canvasReleaseHandler );
viewer.removeHandler( 'canvas-click', canvasClickHandler );
ok( true, 'canvas-click event handled' );
equal( dragMovesHandled, dragCount, "'canvas-drag' event count matches 'mousemove' event count" );
equal( dragMovesHandled, dragCount, "'canvas-drag' event count matches 'mousemove' event count (" + dragCount + ")" );
equal( releasesHandled, releasesExpected, "'canvas-release' event count matches expected (" + releasesExpected + ")" );
viewer.close();
start();
};