]>
git.proxmox.com Git - mirror_novnc.git/blob - tests/test.gesturehandler.js
1 const expect
= chai
.expect
;
3 import EventTargetMixin
from '../core/util/eventtarget.js';
5 import GestureHandler
from '../core/input/gesturehandler.js';
7 class DummyTarget
extends EventTargetMixin
{
10 describe('Gesture handler', function () {
17 clock
= sinon
.useFakeTimers();
24 beforeEach(function () {
25 target
= new DummyTarget();
26 gestures
= sinon
.spy();
27 target
.addEventListener('gesturestart', gestures
);
28 target
.addEventListener('gesturemove', gestures
);
29 target
.addEventListener('gestureend', gestures
);
31 handler
= new GestureHandler();
32 handler
.attach(target
);
35 afterEach(function () {
43 function touchStart(id
, x
, y
) {
44 let touch
= { identifier
: id
,
45 clientX
: x
, clientY
: y
};
47 let ev
= { type
: 'touchstart',
49 targetTouches
: touches
,
50 changedTouches
: [ touch
],
51 stopPropagation
: sinon
.spy(),
52 preventDefault
: sinon
.spy() };
53 target
.dispatchEvent(ev
);
56 function touchMove(id
, x
, y
) {
57 let touch
= touches
.find(t
=> t
.identifier
=== id
);
60 let ev
= { type
: 'touchmove',
62 targetTouches
: touches
,
63 changedTouches
: [ touch
],
64 stopPropagation
: sinon
.spy(),
65 preventDefault
: sinon
.spy() };
66 target
.dispatchEvent(ev
);
69 function touchEnd(id
) {
70 let idx
= touches
.findIndex(t
=> t
.identifier
=== id
);
71 let touch
= touches
.splice(idx
, 1)[0];
72 let ev
= { type
: 'touchend',
74 targetTouches
: touches
,
75 changedTouches
: [ touch
],
76 stopPropagation
: sinon
.spy(),
77 preventDefault
: sinon
.spy() };
78 target
.dispatchEvent(ev
);
81 describe('Single finger tap', function () {
82 it('should handle single finger tap', function () {
83 touchStart(1, 20.0, 30.0);
85 expect(gestures
).to
.not
.have
.been
.called
;
89 expect(gestures
).to
.have
.been
.calledTwice
;
91 expect(gestures
.firstCall
).to
.have
.been
.calledWith(
92 sinon
.match({ type
: 'gesturestart',
93 detail
: { type
: 'onetap',
97 expect(gestures
.secondCall
).to
.have
.been
.calledWith(
98 sinon
.match({ type
: 'gestureend',
99 detail
: { type
: 'onetap',
105 describe('Two finger tap', function () {
106 it('should handle two finger tap', function () {
107 touchStart(1, 20.0, 30.0);
108 touchStart(2, 30.0, 50.0);
110 expect(gestures
).to
.not
.have
.been
.called
;
114 expect(gestures
).to
.not
.have
.been
.called
;
118 expect(gestures
).to
.have
.been
.calledTwice
;
120 expect(gestures
.firstCall
).to
.have
.been
.calledWith(
121 sinon
.match({ type
: 'gesturestart',
122 detail
: { type
: 'twotap',
126 expect(gestures
.secondCall
).to
.have
.been
.calledWith(
127 sinon
.match({ type
: 'gestureend',
128 detail
: { type
: 'twotap',
133 it('should ignore slow starting two finger tap', function () {
134 touchStart(1, 20.0, 30.0);
138 touchStart(2, 30.0, 50.0);
142 expect(gestures
).to
.not
.have
.been
.called
;
145 it('should ignore slow ending two finger tap', function () {
146 touchStart(1, 20.0, 30.0);
147 touchStart(2, 30.0, 50.0);
154 expect(gestures
).to
.not
.have
.been
.called
;
157 it('should ignore slow two finger tap', function () {
158 touchStart(1, 20.0, 30.0);
159 touchStart(2, 30.0, 50.0);
166 expect(gestures
).to
.not
.have
.been
.called
;
170 describe('Three finger tap', function () {
171 it('should handle three finger tap', function () {
172 touchStart(1, 20.0, 30.0);
173 touchStart(2, 30.0, 50.0);
174 touchStart(3, 40.0, 40.0);
176 expect(gestures
).to
.not
.have
.been
.called
;
180 expect(gestures
).to
.not
.have
.been
.called
;
184 expect(gestures
).to
.not
.have
.been
.called
;
188 expect(gestures
).to
.have
.been
.calledTwice
;
190 expect(gestures
.firstCall
).to
.have
.been
.calledWith(
191 sinon
.match({ type
: 'gesturestart',
192 detail
: { type
: 'threetap',
196 expect(gestures
.secondCall
).to
.have
.been
.calledWith(
197 sinon
.match({ type
: 'gestureend',
198 detail
: { type
: 'threetap',
203 it('should ignore slow starting three finger tap', function () {
204 touchStart(1, 20.0, 30.0);
205 touchStart(2, 30.0, 50.0);
209 touchStart(3, 40.0, 40.0);
214 expect(gestures
).to
.not
.have
.been
.called
;
217 it('should ignore slow ending three finger tap', function () {
218 touchStart(1, 20.0, 30.0);
219 touchStart(2, 30.0, 50.0);
220 touchStart(3, 40.0, 40.0);
228 expect(gestures
).to
.not
.have
.been
.called
;
231 it('should ignore three finger drag', function () {
232 touchStart(1, 20.0, 30.0);
233 touchStart(2, 30.0, 50.0);
234 touchStart(3, 40.0, 40.0);
236 touchMove(1, 120.0, 130.0);
237 touchMove(2, 130.0, 150.0);
238 touchMove(3, 140.0, 140.0);
244 expect(gestures
).to
.not
.have
.been
.called
;
247 it('should ignore slow three finger tap', function () {
248 touchStart(1, 20.0, 30.0);
249 touchStart(2, 30.0, 50.0);
250 touchStart(3, 40.0, 40.0);
258 expect(gestures
).to
.not
.have
.been
.called
;
262 describe('Single finger drag', function () {
263 it('should handle horizontal single finger drag', function () {
264 touchStart(1, 20.0, 30.0);
266 expect(gestures
).to
.not
.have
.been
.called
;
268 touchMove(1, 40.0, 30.0);
270 expect(gestures
).to
.not
.have
.been
.called
;
272 touchMove(1, 80.0, 30.0);
274 expect(gestures
).to
.have
.been
.calledTwice
;
276 expect(gestures
.firstCall
).to
.have
.been
.calledWith(
277 sinon
.match({ type
: 'gesturestart',
278 detail
: { type
: 'drag',
282 expect(gestures
.secondCall
).to
.have
.been
.calledWith(
283 sinon
.match({ type
: 'gesturemove',
284 detail
: { type
: 'drag',
288 gestures
.resetHistory();
292 expect(gestures
).to
.have
.been
.calledOnceWith(
293 sinon
.match({ type
: 'gestureend',
294 detail
: { type
: 'drag',
299 it('should handle vertical single finger drag', function () {
300 touchStart(1, 20.0, 30.0);
302 expect(gestures
).to
.not
.have
.been
.called
;
304 touchMove(1, 20.0, 50.0);
306 expect(gestures
).to
.not
.have
.been
.called
;
308 touchMove(1, 20.0, 90.0);
310 expect(gestures
).to
.have
.been
.calledTwice
;
312 expect(gestures
.firstCall
).to
.have
.been
.calledWith(
313 sinon
.match({ type
: 'gesturestart',
314 detail
: { type
: 'drag',
318 expect(gestures
.secondCall
).to
.have
.been
.calledWith(
319 sinon
.match({ type
: 'gesturemove',
320 detail
: { type
: 'drag',
324 gestures
.resetHistory();
328 expect(gestures
).to
.have
.been
.calledOnceWith(
329 sinon
.match({ type
: 'gestureend',
330 detail
: { type
: 'drag',
335 it('should handle diagonal single finger drag', function () {
336 touchStart(1, 120.0, 130.0);
338 expect(gestures
).to
.not
.have
.been
.called
;
340 touchMove(1, 90.0, 100.0);
342 expect(gestures
).to
.not
.have
.been
.called
;
344 touchMove(1, 60.0, 70.0);
346 expect(gestures
).to
.have
.been
.calledTwice
;
348 expect(gestures
.firstCall
).to
.have
.been
.calledWith(
349 sinon
.match({ type
: 'gesturestart',
350 detail
: { type
: 'drag',
352 clientY
: 130.0 } }));
354 expect(gestures
.secondCall
).to
.have
.been
.calledWith(
355 sinon
.match({ type
: 'gesturemove',
356 detail
: { type
: 'drag',
360 gestures
.resetHistory();
364 expect(gestures
).to
.have
.been
.calledOnceWith(
365 sinon
.match({ type
: 'gestureend',
366 detail
: { type
: 'drag',
372 describe('Long press', function () {
373 it('should handle long press', function () {
374 touchStart(1, 20.0, 30.0);
376 expect(gestures
).to
.not
.have
.been
.called
;
380 expect(gestures
).to
.have
.been
.calledOnceWith(
381 sinon
.match({ type
: 'gesturestart',
382 detail
: { type
: 'longpress',
386 gestures
.resetHistory();
390 expect(gestures
).to
.have
.been
.calledOnceWith(
391 sinon
.match({ type
: 'gestureend',
392 detail
: { type
: 'longpress',
397 it('should handle long press drag', function () {
398 touchStart(1, 20.0, 30.0);
400 expect(gestures
).to
.not
.have
.been
.called
;
404 expect(gestures
).to
.have
.been
.calledOnceWith(
405 sinon
.match({ type
: 'gesturestart',
406 detail
: { type
: 'longpress',
410 gestures
.resetHistory();
412 touchMove(1, 120.0, 50.0);
414 expect(gestures
).to
.have
.been
.calledOnceWith(
415 sinon
.match({ type
: 'gesturemove',
416 detail
: { type
: 'longpress',
420 gestures
.resetHistory();
424 expect(gestures
).to
.have
.been
.calledOnceWith(
425 sinon
.match({ type
: 'gestureend',
426 detail
: { type
: 'longpress',
432 describe('Two finger drag', function () {
433 it('should handle fast and distinct horizontal two finger drag', function () {
434 touchStart(1, 20.0, 30.0);
435 touchStart(2, 30.0, 30.0);
437 expect(gestures
).to
.not
.have
.been
.called
;
439 touchMove(1, 40.0, 30.0);
440 touchMove(2, 50.0, 30.0);
442 expect(gestures
).to
.not
.have
.been
.called
;
444 touchMove(2, 90.0, 30.0);
445 touchMove(1, 80.0, 30.0);
447 expect(gestures
).to
.have
.been
.calledTwice
;
449 expect(gestures
.firstCall
).to
.have
.been
.calledWith(
450 sinon
.match({ type
: 'gesturestart',
451 detail
: { type
: 'twodrag',
455 magnitudeY
: 0.0 } }));
457 expect(gestures
.secondCall
).to
.have
.been
.calledWith(
458 sinon
.match({ type
: 'gesturemove',
459 detail
: { type
: 'twodrag',
463 magnitudeY
: 0.0 } }));
465 gestures
.resetHistory();
469 expect(gestures
).to
.have
.been
.calledOnceWith(
470 sinon
.match({ type
: 'gestureend',
471 detail
: { type
: 'twodrag',
475 magnitudeY
: 0.0 } }));
478 it('should handle fast and distinct vertical two finger drag', function () {
479 touchStart(1, 20.0, 30.0);
480 touchStart(2, 30.0, 30.0);
482 expect(gestures
).to
.not
.have
.been
.called
;
484 touchMove(1, 20.0, 100.0);
485 touchMove(2, 30.0, 40.0);
487 expect(gestures
).to
.not
.have
.been
.called
;
489 touchMove(2, 30.0, 90.0);
491 expect(gestures
).to
.have
.been
.calledTwice
;
493 expect(gestures
.firstCall
).to
.have
.been
.calledWith(
494 sinon
.match({ type
: 'gesturestart',
495 detail
: { type
: 'twodrag',
499 magnitudeY
: 0.0 } }));
501 expect(gestures
.secondCall
).to
.have
.been
.calledWith(
502 sinon
.match({ type
: 'gesturemove',
503 detail
: { type
: 'twodrag',
507 magnitudeY
: 65.0 } }));
509 gestures
.resetHistory();
513 expect(gestures
).to
.have
.been
.calledOnceWith(
514 sinon
.match({ type
: 'gestureend',
515 detail
: { type
: 'twodrag',
519 magnitudeY
: 65.0 } }));
522 it('should handle fast and distinct diagonal two finger drag', function () {
523 touchStart(1, 120.0, 130.0);
524 touchStart(2, 130.0, 130.0);
526 expect(gestures
).to
.not
.have
.been
.called
;
528 touchMove(1, 80.0, 90.0);
529 touchMove(2, 100.0, 130.0);
531 expect(gestures
).to
.not
.have
.been
.called
;
533 touchMove(2, 60.0, 70.0);
535 expect(gestures
).to
.have
.been
.calledTwice
;
537 expect(gestures
.firstCall
).to
.have
.been
.calledWith(
538 sinon
.match({ type
: 'gesturestart',
539 detail
: { type
: 'twodrag',
543 magnitudeY
: 0.0 } }));
545 expect(gestures
.secondCall
).to
.have
.been
.calledWith(
546 sinon
.match({ type
: 'gesturemove',
547 detail
: { type
: 'twodrag',
551 magnitudeY
: -50.0 } }));
553 gestures
.resetHistory();
557 expect(gestures
).to
.have
.been
.calledOnceWith(
558 sinon
.match({ type
: 'gestureend',
559 detail
: { type
: 'twodrag',
563 magnitudeY
: -50.0 } }));
566 it('should ignore fast almost two finger dragging', function () {
567 touchStart(1, 20.0, 30.0);
568 touchStart(2, 30.0, 30.0);
569 touchMove(1, 80.0, 30.0);
570 touchMove(2, 70.0, 30.0);
574 expect(gestures
).to
.not
.have
.been
.called
;
578 expect(gestures
).to
.not
.have
.been
.called
;
581 it('should handle slow horizontal two finger drag', function () {
582 touchStart(1, 50.0, 40.0);
583 touchStart(2, 60.0, 40.0);
584 touchMove(1, 80.0, 40.0);
585 touchMove(2, 110.0, 40.0);
587 expect(gestures
).to
.not
.have
.been
.called
;
591 expect(gestures
).to
.have
.been
.calledTwice
;
593 expect(gestures
.firstCall
).to
.have
.been
.calledWith(
594 sinon
.match({ type
: 'gesturestart',
595 detail
: { type
: 'twodrag',
599 magnitudeY
: 0.0 } }));
601 expect(gestures
.secondCall
).to
.have
.been
.calledWith(
602 sinon
.match({ type
: 'gesturemove',
603 detail
: { type
: 'twodrag',
607 magnitudeY
: 0.0 } }));
610 it('should handle slow vertical two finger drag', function () {
611 touchStart(1, 40.0, 40.0);
612 touchStart(2, 40.0, 60.0);
613 touchMove(2, 40.0, 80.0);
614 touchMove(1, 40.0, 100.0);
616 expect(gestures
).to
.not
.have
.been
.called
;
620 expect(gestures
).to
.have
.been
.calledTwice
;
622 expect(gestures
.firstCall
).to
.have
.been
.calledWith(
623 sinon
.match({ type
: 'gesturestart',
624 detail
: { type
: 'twodrag',
628 magnitudeY
: 0.0 } }));
630 expect(gestures
.secondCall
).to
.have
.been
.calledWith(
631 sinon
.match({ type
: 'gesturemove',
632 detail
: { type
: 'twodrag',
636 magnitudeY
: 40.0 } }));
639 it('should handle slow diagonal two finger drag', function () {
640 touchStart(1, 50.0, 40.0);
641 touchStart(2, 40.0, 60.0);
642 touchMove(1, 70.0, 60.0);
643 touchMove(2, 90.0, 110.0);
645 expect(gestures
).to
.not
.have
.been
.called
;
649 expect(gestures
).to
.have
.been
.calledTwice
;
651 expect(gestures
.firstCall
).to
.have
.been
.calledWith(
652 sinon
.match({ type
: 'gesturestart',
653 detail
: { type
: 'twodrag',
657 magnitudeY
: 0.0 } }));
659 expect(gestures
.secondCall
).to
.have
.been
.calledWith(
660 sinon
.match({ type
: 'gesturemove',
661 detail
: { type
: 'twodrag',
665 magnitudeY
: 35.0 } }));
668 it('should ignore too slow two finger drag', function () {
669 touchStart(1, 20.0, 30.0);
673 touchStart(2, 30.0, 30.0);
674 touchMove(1, 40.0, 30.0);
675 touchMove(2, 50.0, 30.0);
676 touchMove(1, 80.0, 30.0);
678 expect(gestures
).to
.not
.have
.been
.called
;
682 describe('Pinch', function () {
683 it('should handle pinching distinctly and fast inwards', function () {
684 touchStart(1, 0.0, 0.0);
685 touchStart(2, 130.0, 130.0);
687 expect(gestures
).to
.not
.have
.been
.called
;
689 touchMove(1, 50.0, 40.0);
690 touchMove(2, 100.0, 130.0);
692 expect(gestures
).to
.not
.have
.been
.called
;
694 touchMove(2, 60.0, 70.0);
696 expect(gestures
).to
.have
.been
.calledTwice
;
698 expect(gestures
.firstCall
).to
.have
.been
.calledWith(
699 sinon
.match({ type
: 'gesturestart',
700 detail
: { type
: 'pinch',
704 magnitudeY
: 130.0 } }));
706 expect(gestures
.secondCall
).to
.have
.been
.calledWith(
707 sinon
.match({ type
: 'gesturemove',
708 detail
: { type
: 'pinch',
712 magnitudeY
: 30.0 } }));
714 gestures
.resetHistory();
718 expect(gestures
).to
.have
.been
.calledOnceWith(
719 sinon
.match({ type
: 'gestureend',
720 detail
: { type
: 'pinch',
724 magnitudeY
: 30.0 } }));
727 it('should handle pinching fast and distinctly outwards', function () {
728 touchStart(1, 100.0, 100.0);
729 touchStart(2, 110.0, 100.0);
731 expect(gestures
).to
.not
.have
.been
.called
;
733 touchMove(1, 130.0, 70.0);
734 touchMove(2, 0.0, 200.0);
736 expect(gestures
).to
.not
.have
.been
.called
;
738 touchMove(1, 180.0, 20.0);
740 expect(gestures
).to
.have
.been
.calledTwice
;
742 expect(gestures
.firstCall
).to
.have
.been
.calledWith(
743 sinon
.match({ type
: 'gesturestart',
744 detail
: { type
: 'pinch',
748 magnitudeY
: 0.0 } }));
750 expect(gestures
.secondCall
).to
.have
.been
.calledWith(
751 sinon
.match({ type
: 'gesturemove',
752 detail
: { type
: 'pinch',
756 magnitudeY
: 180.0 } }));
758 gestures
.resetHistory();
762 expect(gestures
).to
.have
.been
.calledOnceWith(
763 sinon
.match({ type
: 'gestureend',
764 detail
: { type
: 'pinch',
768 magnitudeY
: 180.0 } }));
771 it('should ignore fast almost pinching', function () {
772 touchStart(1, 20.0, 30.0);
773 touchStart(2, 130.0, 130.0);
774 touchMove(1, 80.0, 70.0);
778 expect(gestures
).to
.not
.have
.been
.called
;
782 expect(gestures
).to
.not
.have
.been
.called
;
785 it('should handle pinching inwards slowly', function () {
786 touchStart(1, 0.0, 0.0);
787 touchStart(2, 130.0, 130.0);
788 touchMove(1, 50.0, 40.0);
789 touchMove(2, 100.0, 130.0);
791 expect(gestures
).to
.not
.have
.been
.called
;
795 expect(gestures
).to
.have
.been
.calledTwice
;
797 expect(gestures
.firstCall
).to
.have
.been
.calledWith(
798 sinon
.match({ type
: 'gesturestart',
799 detail
: { type
: 'pinch',
803 magnitudeY
: 130.0 } }));
805 expect(gestures
.secondCall
).to
.have
.been
.calledWith(
806 sinon
.match({ type
: 'gesturemove',
807 detail
: { type
: 'pinch',
811 magnitudeY
: 90.0 } }));
814 it('should handle pinching outwards slowly', function () {
815 touchStart(1, 100.0, 130.0);
816 touchStart(2, 110.0, 130.0);
817 touchMove(2, 200.0, 130.0);
819 expect(gestures
).to
.not
.have
.been
.called
;
823 expect(gestures
).to
.have
.been
.calledTwice
;
825 expect(gestures
.firstCall
).to
.have
.been
.calledWith(
826 sinon
.match({ type
: 'gesturestart',
827 detail
: { type
: 'pinch',
831 magnitudeY
: 0.0 } }));
833 expect(gestures
.secondCall
).to
.have
.been
.calledWith(
834 sinon
.match({ type
: 'gesturemove',
835 detail
: { type
: 'pinch',
839 magnitudeY
: 0.0 } }));
842 it('should ignore pinching too slowly', function () {
843 touchStart(1, 0.0, 0.0);
847 touchStart(2, 130.0, 130.0);
848 touchMove(2, 100.0, 130.0);
849 touchMove(1, 50.0, 40.0);
851 expect(gestures
).to
.not
.have
.been
.called
;
855 describe('Ignoring', function () {
856 it('should ignore extra touches during gesture', function () {
857 touchStart(1, 20.0, 30.0);
858 touchMove(1, 40.0, 30.0);
859 touchMove(1, 80.0, 30.0);
861 expect(gestures
).to
.have
.been
.calledTwice
;
863 expect(gestures
.firstCall
).to
.have
.been
.calledWith(
864 sinon
.match({ type
: 'gesturestart',
865 detail
: { type
: 'drag' } }));
866 expect(gestures
.secondCall
).to
.have
.been
.calledWith(
867 sinon
.match({ type
: 'gesturemove',
868 detail
: { type
: 'drag' } }));
870 gestures
.resetHistory();
872 touchStart(2, 10.0, 10.0);
874 expect(gestures
).to
.not
.have
.been
.called
;
876 touchMove(1, 100.0, 50.0);
878 expect(gestures
).to
.have
.been
.calledOnceWith(
879 sinon
.match({ type
: 'gesturemove',
880 detail
: { type
: 'drag',
884 gestures
.resetHistory();
888 expect(gestures
).to
.have
.been
.calledOnceWith(
889 sinon
.match({ type
: 'gestureend',
890 detail
: { type
: 'drag',
895 it('should ignore extra touches when waiting for gesture to end', function () {
896 touchStart(1, 20.0, 30.0);
897 touchStart(2, 30.0, 30.0);
898 touchMove(1, 40.0, 30.0);
899 touchMove(2, 90.0, 30.0);
900 touchMove(1, 80.0, 30.0);
902 expect(gestures
).to
.have
.been
.calledTwice
;
904 expect(gestures
.firstCall
).to
.have
.been
.calledWith(
905 sinon
.match({ type
: 'gesturestart',
906 detail
: { type
: 'twodrag' } }));
907 expect(gestures
.secondCall
).to
.have
.been
.calledWith(
908 sinon
.match({ type
: 'gesturemove',
909 detail
: { type
: 'twodrag' } }));
911 gestures
.resetHistory();
915 expect(gestures
).to
.have
.been
.calledOnceWith(
916 sinon
.match({ type
: 'gestureend',
917 detail
: { type
: 'twodrag' } }));
919 gestures
.resetHistory();
921 touchStart(3, 10.0, 10.0);
924 expect(gestures
).to
.not
.have
.been
.called
;
927 it('should ignore extra touches after gesture', function () {
928 touchStart(1, 20.0, 30.0);
929 touchMove(1, 40.0, 30.0);
930 touchMove(1, 80.0, 30.0);
932 expect(gestures
).to
.have
.been
.calledTwice
;
934 expect(gestures
.firstCall
).to
.have
.been
.calledWith(
935 sinon
.match({ type
: 'gesturestart',
936 detail
: { type
: 'drag' } }));
937 expect(gestures
.secondCall
).to
.have
.been
.calledWith(
938 sinon
.match({ type
: 'gesturemove',
939 detail
: { type
: 'drag' } }));
941 gestures
.resetHistory();
943 touchStart(2, 10.0, 10.0);
945 expect(gestures
).to
.not
.have
.been
.called
;
947 touchMove(1, 100.0, 50.0);
949 expect(gestures
).to
.have
.been
.calledOnceWith(
950 sinon
.match({ type
: 'gesturemove',
951 detail
: { type
: 'drag' } }));
953 gestures
.resetHistory();
957 expect(gestures
).to
.have
.been
.calledOnceWith(
958 sinon
.match({ type
: 'gestureend',
959 detail
: { type
: 'drag' } }));
961 gestures
.resetHistory();
965 expect(gestures
).to
.not
.have
.been
.called
;
967 // Check that everything is reseted after trailing ignores are released
969 touchStart(3, 20.0, 30.0);
972 expect(gestures
).to
.have
.been
.calledTwice
;
974 expect(gestures
.firstCall
).to
.have
.been
.calledWith(
975 sinon
.match({ type
: 'gesturestart',
976 detail
: { type
: 'onetap' } }));
977 expect(gestures
.secondCall
).to
.have
.been
.calledWith(
978 sinon
.match({ type
: 'gestureend',
979 detail
: { type
: 'onetap' } }));
982 it('should properly reset after a gesture', function () {
983 touchStart(1, 20.0, 30.0);
985 expect(gestures
).to
.not
.have
.been
.called
;
989 expect(gestures
).to
.have
.been
.calledTwice
;
991 expect(gestures
.firstCall
).to
.have
.been
.calledWith(
992 sinon
.match({ type
: 'gesturestart',
993 detail
: { type
: 'onetap',
997 expect(gestures
.secondCall
).to
.have
.been
.calledWith(
998 sinon
.match({ type
: 'gestureend',
999 detail
: { type
: 'onetap',
1001 clientY
: 30.0 } }));
1003 gestures
.resetHistory();
1005 touchStart(2, 70.0, 80.0);
1007 expect(gestures
).to
.not
.have
.been
.called
;
1011 expect(gestures
).to
.have
.been
.calledTwice
;
1013 expect(gestures
.firstCall
).to
.have
.been
.calledWith(
1014 sinon
.match({ type
: 'gesturestart',
1015 detail
: { type
: 'onetap',
1017 clientY
: 80.0 } }));
1019 expect(gestures
.secondCall
).to
.have
.been
.calledWith(
1020 sinon
.match({ type
: 'gestureend',
1021 detail
: { type
: 'onetap',
1023 clientY
: 80.0 } }));