@@ -455,6 +455,7 @@ class TestGesture {
455455 /// Dispatch a pointer down event at the given `downLocation` , caching the
456456 /// hit test result.
457457 Future <void > down (Offset downLocation, { Duration timeStamp = Duration .zero }) async {
458+ assert (_pointer.kind != PointerDeviceKind .trackpad, 'Trackpads are expected to send panZoomStart events, not down events.' );
458459 return TestAsyncUtils .guard <void >(() async {
459460 return _dispatcher (_pointer.down (downLocation, timeStamp: timeStamp));
460461 });
@@ -463,6 +464,7 @@ class TestGesture {
463464 /// Dispatch a pointer down event at the given `downLocation` , caching the
464465 /// hit test result with a custom down event.
465466 Future <void > downWithCustomEvent (Offset downLocation, PointerDownEvent event) async {
467+ assert (_pointer.kind != PointerDeviceKind .trackpad, 'Trackpads are expected to send panZoomStart events, not down events' );
466468 _pointer.setDownInfo (event, downLocation);
467469 return TestAsyncUtils .guard <void >(() async {
468470 return _dispatcher (event);
@@ -507,7 +509,15 @@ class TestGesture {
507509 /// * [WidgetController.fling] , a method to simulate a fling.
508510 Future <void > moveBy (Offset offset, { Duration timeStamp = Duration .zero }) {
509511 assert (_pointer.location != null );
510- return moveTo (_pointer.location! + offset, timeStamp: timeStamp);
512+ if (_pointer.isPanZoomActive) {
513+ return panZoomUpdate (
514+ _pointer.location! ,
515+ pan: (_pointer.pan ?? Offset .zero) + offset,
516+ timeStamp: timeStamp
517+ );
518+ } else {
519+ return moveTo (_pointer.location! + offset, timeStamp: timeStamp);
520+ }
511521 }
512522
513523 /// Send a move event moving the pointer to the given location.
@@ -521,6 +531,7 @@ class TestGesture {
521531 /// It sends move events at a given frequency and it is useful when there are listeners involved.
522532 /// * [WidgetController.fling] , a method to simulate a fling.
523533 Future <void > moveTo (Offset location, { Duration timeStamp = Duration .zero }) {
534+ assert (_pointer.kind != PointerDeviceKind .trackpad);
524535 return TestAsyncUtils .guard <void >(() {
525536 if (_pointer._isDown) {
526537 return _dispatcher (_pointer.move (location, timeStamp: timeStamp));
@@ -530,19 +541,27 @@ class TestGesture {
530541 });
531542 }
532543
533- /// End the gesture by releasing the pointer.
544+ /// End the gesture by releasing the pointer. For trackpad pointers this
545+ /// will send a panZoomEnd event instead of an up event.
534546 Future <void > up ({ Duration timeStamp = Duration .zero }) {
535547 return TestAsyncUtils .guard <void >(() async {
536- assert (_pointer._isDown);
537- await _dispatcher (_pointer.up (timeStamp: timeStamp));
538- assert (! _pointer._isDown);
548+ if (_pointer.kind == PointerDeviceKind .trackpad) {
549+ assert (_pointer._isPanZoomActive);
550+ await _dispatcher (_pointer.panZoomEnd (timeStamp: timeStamp));
551+ assert (! _pointer._isPanZoomActive);
552+ } else {
553+ assert (_pointer._isDown);
554+ await _dispatcher (_pointer.up (timeStamp: timeStamp));
555+ assert (! _pointer._isDown);
556+ }
539557 });
540558 }
541559
542560 /// End the gesture by canceling the pointer (as would happen if the
543561 /// system showed a modal dialog on top of the Flutter application,
544562 /// for instance).
545563 Future <void > cancel ({ Duration timeStamp = Duration .zero }) {
564+ assert (_pointer.kind != PointerDeviceKind .trackpad, 'Trackpads do not send cancel events.' );
546565 return TestAsyncUtils .guard <void >(() async {
547566 assert (_pointer._isDown);
548567 await _dispatcher (_pointer.cancel (timeStamp: timeStamp));
@@ -553,6 +572,7 @@ class TestGesture {
553572 /// Dispatch a pointer pan zoom start event at the given `location` , caching the
554573 /// hit test result.
555574 Future <void > panZoomStart (Offset location, { Duration timeStamp = Duration .zero }) async {
575+ assert (_pointer.kind == PointerDeviceKind .trackpad, 'Only trackpads can send PointerPanZoom events.' );
556576 return TestAsyncUtils .guard <void >(() async {
557577 return _dispatcher (_pointer.panZoomStart (location, timeStamp: timeStamp));
558578 });
@@ -566,6 +586,7 @@ class TestGesture {
566586 double rotation = 0 ,
567587 Duration timeStamp = Duration .zero
568588 }) async {
589+ assert (_pointer.kind == PointerDeviceKind .trackpad, 'Only trackpads can send PointerPanZoom events.' );
569590 return TestAsyncUtils .guard <void >(() async {
570591 return _dispatcher (_pointer.panZoomUpdate (location,
571592 pan: pan,
@@ -580,6 +601,7 @@ class TestGesture {
580601 Future <void > panZoomEnd ({
581602 Duration timeStamp = Duration .zero
582603 }) async {
604+ assert (_pointer.kind == PointerDeviceKind .trackpad, 'Only trackpads can send PointerPanZoom events.' );
583605 return TestAsyncUtils .guard <void >(() async {
584606 return _dispatcher (_pointer.panZoomEnd (
585607 timeStamp: timeStamp
0 commit comments