|
2 | 2 | // Use of this source code is governed by a BSD-style license that can be
|
3 | 3 | // found in the LICENSE file.
|
4 | 4 |
|
| 5 | +import 'package:flutter/foundation.dart'; |
5 | 6 | import 'package:flutter/gestures.dart';
|
6 | 7 | import 'package:flutter/widgets.dart';
|
7 | 8 | import 'package:flutter_test/flutter_test.dart';
|
@@ -549,4 +550,42 @@ void main() {
|
549 | 550 | GestureBinding.instance.gestureArena.sweep(2);
|
550 | 551 | expect(events, <String>['down#1', 'up#1']);
|
551 | 552 | });
|
| 553 | + |
| 554 | + // This is a regression test for https://github.com/flutter/flutter/issues/102084. |
| 555 | + testGesture('Does not call onDragEnd if not provided', (GestureTester tester) { |
| 556 | + tapAndDrag = TapAndDragGestureRecognizer() |
| 557 | + ..dragStartBehavior = DragStartBehavior.down |
| 558 | + ..maxConsecutiveTap = 3 |
| 559 | + ..onTapDown = (TapDragDownDetails details) { |
| 560 | + events.add('down#${details.consecutiveTapCount}'); |
| 561 | + }; |
| 562 | + |
| 563 | + FlutterErrorDetails? errorDetails; |
| 564 | + final FlutterExceptionHandler? oldHandler = FlutterError.onError; |
| 565 | + FlutterError.onError = (FlutterErrorDetails details) { |
| 566 | + errorDetails = details; |
| 567 | + }; |
| 568 | + addTearDown(() { |
| 569 | + FlutterError.onError = oldHandler; |
| 570 | + }); |
| 571 | + |
| 572 | + tapAndDrag.addPointer(down5); |
| 573 | + tester.closeArena(5); |
| 574 | + tester.route(down5); |
| 575 | + tester.route(move5); |
| 576 | + tester.route(up5); |
| 577 | + GestureBinding.instance.gestureArena.sweep(5); |
| 578 | + expect(events, <String>['down#1']); |
| 579 | + |
| 580 | + expect(errorDetails, isNull); |
| 581 | + |
| 582 | + events.clear(); |
| 583 | + tester.async.elapse(const Duration(milliseconds: 1000)); |
| 584 | + tapAndDrag.addPointer(down1); |
| 585 | + tester.closeArena(1); |
| 586 | + tester.route(down1); |
| 587 | + tester.route(up1); |
| 588 | + GestureBinding.instance.gestureArena.sweep(1); |
| 589 | + expect(events, <String>['down#1']); |
| 590 | + }); |
552 | 591 | }
|
0 commit comments