mirror of
https://github.com/flutter/flutter.git
synced 2025-06-03 00:51:18 +00:00
Migrate gestures, physics and scheduler tests to null safety. (#62701)
This commit is contained in:
parent
f3d9bf7b7c
commit
01e8c39534
@ -2,8 +2,6 @@
|
|||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
// @dart = 2.8
|
|
||||||
|
|
||||||
import 'package:flutter/gestures.dart';
|
import 'package:flutter/gestures.dart';
|
||||||
|
|
||||||
import '../flutter_test_alternative.dart';
|
import '../flutter_test_alternative.dart';
|
||||||
@ -34,12 +32,12 @@ class GestureTester {
|
|||||||
TestGestureArenaMember first = TestGestureArenaMember();
|
TestGestureArenaMember first = TestGestureArenaMember();
|
||||||
TestGestureArenaMember second = TestGestureArenaMember();
|
TestGestureArenaMember second = TestGestureArenaMember();
|
||||||
|
|
||||||
GestureArenaEntry firstEntry;
|
late GestureArenaEntry firstEntry;
|
||||||
void addFirst() {
|
void addFirst() {
|
||||||
firstEntry = arena.add(primaryKey, first);
|
firstEntry = arena.add(primaryKey, first);
|
||||||
}
|
}
|
||||||
|
|
||||||
GestureArenaEntry secondEntry;
|
late GestureArenaEntry secondEntry;
|
||||||
void addSecond() {
|
void addSecond() {
|
||||||
secondEntry = arena.add(primaryKey, second);
|
secondEntry = arena.add(primaryKey, second);
|
||||||
}
|
}
|
||||||
|
@ -2,8 +2,6 @@
|
|||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
// @dart = 2.8
|
|
||||||
|
|
||||||
import 'package:flutter/foundation.dart';
|
import 'package:flutter/foundation.dart';
|
||||||
import 'package:flutter/gestures.dart';
|
import 'package:flutter/gestures.dart';
|
||||||
import 'package:flutter_test/flutter_test.dart';
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
@ -14,7 +12,7 @@ void main() {
|
|||||||
debugPrintGestureArenaDiagnostics = true;
|
debugPrintGestureArenaDiagnostics = true;
|
||||||
final DebugPrintCallback oldCallback = debugPrint;
|
final DebugPrintCallback oldCallback = debugPrint;
|
||||||
final List<String> log = <String>[];
|
final List<String> log = <String>[];
|
||||||
debugPrint = (String s, { int wrapWidth }) { log.add(s); };
|
debugPrint = (String? s, { int? wrapWidth }) { log.add(s ?? ''); };
|
||||||
|
|
||||||
final TapGestureRecognizer tap = TapGestureRecognizer()
|
final TapGestureRecognizer tap = TapGestureRecognizer()
|
||||||
..onTapDown = (TapDownDetails details) { }
|
..onTapDown = (TapDownDetails details) { }
|
||||||
@ -30,19 +28,19 @@ void main() {
|
|||||||
expect(log[1], equalsIgnoringHashCodes('Gesture arena 1 ❙ Adding: TapGestureRecognizer#00000(state: ready, button: 1)'));
|
expect(log[1], equalsIgnoringHashCodes('Gesture arena 1 ❙ Adding: TapGestureRecognizer#00000(state: ready, button: 1)'));
|
||||||
log.clear();
|
log.clear();
|
||||||
|
|
||||||
GestureBinding.instance.gestureArena.close(1);
|
GestureBinding.instance!.gestureArena.close(1);
|
||||||
expect(log, hasLength(1));
|
expect(log, hasLength(1));
|
||||||
expect(log[0], equalsIgnoringHashCodes('Gesture arena 1 ❙ Closing with 1 member.'));
|
expect(log[0], equalsIgnoringHashCodes('Gesture arena 1 ❙ Closing with 1 member.'));
|
||||||
log.clear();
|
log.clear();
|
||||||
|
|
||||||
GestureBinding.instance.pointerRouter.route(event);
|
GestureBinding.instance!.pointerRouter.route(event);
|
||||||
expect(log, isEmpty);
|
expect(log, isEmpty);
|
||||||
|
|
||||||
event = const PointerUpEvent(pointer: 1, position: Offset(12.0, 8.0));
|
event = const PointerUpEvent(pointer: 1, position: Offset(12.0, 8.0));
|
||||||
GestureBinding.instance.pointerRouter.route(event);
|
GestureBinding.instance!.pointerRouter.route(event);
|
||||||
expect(log, isEmpty);
|
expect(log, isEmpty);
|
||||||
|
|
||||||
GestureBinding.instance.gestureArena.sweep(1);
|
GestureBinding.instance!.gestureArena.sweep(1);
|
||||||
expect(log, hasLength(2));
|
expect(log, hasLength(2));
|
||||||
expect(log[0], equalsIgnoringHashCodes('Gesture arena 1 ❙ Sweeping with 1 member.'));
|
expect(log[0], equalsIgnoringHashCodes('Gesture arena 1 ❙ Sweeping with 1 member.'));
|
||||||
expect(log[1], equalsIgnoringHashCodes('Gesture arena 1 ❙ Winner: TapGestureRecognizer#00000(state: ready, finalPosition: Offset(12.0, 8.0), button: 1)'));
|
expect(log[1], equalsIgnoringHashCodes('Gesture arena 1 ❙ Winner: TapGestureRecognizer#00000(state: ready, finalPosition: Offset(12.0, 8.0), button: 1)'));
|
||||||
@ -60,7 +58,7 @@ void main() {
|
|||||||
debugPrintRecognizerCallbacksTrace = true;
|
debugPrintRecognizerCallbacksTrace = true;
|
||||||
final DebugPrintCallback oldCallback = debugPrint;
|
final DebugPrintCallback oldCallback = debugPrint;
|
||||||
final List<String> log = <String>[];
|
final List<String> log = <String>[];
|
||||||
debugPrint = (String s, { int wrapWidth }) { log.add(s); };
|
debugPrint = (String? s, { int? wrapWidth }) { log.add(s ?? ''); };
|
||||||
|
|
||||||
final TapGestureRecognizer tap = TapGestureRecognizer()
|
final TapGestureRecognizer tap = TapGestureRecognizer()
|
||||||
..onTapDown = (TapDownDetails details) { }
|
..onTapDown = (TapDownDetails details) { }
|
||||||
@ -73,17 +71,17 @@ void main() {
|
|||||||
tap.addPointer(event as PointerDownEvent);
|
tap.addPointer(event as PointerDownEvent);
|
||||||
expect(log, isEmpty);
|
expect(log, isEmpty);
|
||||||
|
|
||||||
GestureBinding.instance.gestureArena.close(1);
|
GestureBinding.instance!.gestureArena.close(1);
|
||||||
expect(log, isEmpty);
|
expect(log, isEmpty);
|
||||||
|
|
||||||
GestureBinding.instance.pointerRouter.route(event);
|
GestureBinding.instance!.pointerRouter.route(event);
|
||||||
expect(log, isEmpty);
|
expect(log, isEmpty);
|
||||||
|
|
||||||
event = const PointerUpEvent(pointer: 1, position: Offset(12.0, 8.0));
|
event = const PointerUpEvent(pointer: 1, position: Offset(12.0, 8.0));
|
||||||
GestureBinding.instance.pointerRouter.route(event);
|
GestureBinding.instance!.pointerRouter.route(event);
|
||||||
expect(log, isEmpty);
|
expect(log, isEmpty);
|
||||||
|
|
||||||
GestureBinding.instance.gestureArena.sweep(1);
|
GestureBinding.instance!.gestureArena.sweep(1);
|
||||||
expect(log, hasLength(3));
|
expect(log, hasLength(3));
|
||||||
expect(log[0], equalsIgnoringHashCodes('TapGestureRecognizer#00000(state: ready, finalPosition: Offset(12.0, 8.0), button: 1) calling onTapDown callback.'));
|
expect(log[0], equalsIgnoringHashCodes('TapGestureRecognizer#00000(state: ready, finalPosition: Offset(12.0, 8.0), button: 1) calling onTapDown callback.'));
|
||||||
expect(log[1], equalsIgnoringHashCodes('TapGestureRecognizer#00000(state: ready, won arena, finalPosition: Offset(12.0, 8.0), button: 1, sent tap down) calling onTapUp callback.'));
|
expect(log[1], equalsIgnoringHashCodes('TapGestureRecognizer#00000(state: ready, won arena, finalPosition: Offset(12.0, 8.0), button: 1, sent tap down) calling onTapUp callback.'));
|
||||||
@ -103,7 +101,7 @@ void main() {
|
|||||||
debugPrintRecognizerCallbacksTrace = true;
|
debugPrintRecognizerCallbacksTrace = true;
|
||||||
final DebugPrintCallback oldCallback = debugPrint;
|
final DebugPrintCallback oldCallback = debugPrint;
|
||||||
final List<String> log = <String>[];
|
final List<String> log = <String>[];
|
||||||
debugPrint = (String s, { int wrapWidth }) { log.add(s); };
|
debugPrint = (String? s, { int? wrapWidth }) { log.add(s ?? ''); };
|
||||||
|
|
||||||
final TapGestureRecognizer tap = TapGestureRecognizer()
|
final TapGestureRecognizer tap = TapGestureRecognizer()
|
||||||
..onTapDown = (TapDownDetails details) { }
|
..onTapDown = (TapDownDetails details) { }
|
||||||
@ -119,19 +117,19 @@ void main() {
|
|||||||
expect(log[1], equalsIgnoringHashCodes('Gesture arena 1 ❙ Adding: TapGestureRecognizer#00000(state: ready, button: 1)'));
|
expect(log[1], equalsIgnoringHashCodes('Gesture arena 1 ❙ Adding: TapGestureRecognizer#00000(state: ready, button: 1)'));
|
||||||
log.clear();
|
log.clear();
|
||||||
|
|
||||||
GestureBinding.instance.gestureArena.close(1);
|
GestureBinding.instance!.gestureArena.close(1);
|
||||||
expect(log, hasLength(1));
|
expect(log, hasLength(1));
|
||||||
expect(log[0], equalsIgnoringHashCodes('Gesture arena 1 ❙ Closing with 1 member.'));
|
expect(log[0], equalsIgnoringHashCodes('Gesture arena 1 ❙ Closing with 1 member.'));
|
||||||
log.clear();
|
log.clear();
|
||||||
|
|
||||||
GestureBinding.instance.pointerRouter.route(event);
|
GestureBinding.instance!.pointerRouter.route(event);
|
||||||
expect(log, isEmpty);
|
expect(log, isEmpty);
|
||||||
|
|
||||||
event = const PointerUpEvent(pointer: 1, position: Offset(12.0, 8.0));
|
event = const PointerUpEvent(pointer: 1, position: Offset(12.0, 8.0));
|
||||||
GestureBinding.instance.pointerRouter.route(event);
|
GestureBinding.instance!.pointerRouter.route(event);
|
||||||
expect(log, isEmpty);
|
expect(log, isEmpty);
|
||||||
|
|
||||||
GestureBinding.instance.gestureArena.sweep(1);
|
GestureBinding.instance!.gestureArena.sweep(1);
|
||||||
expect(log, hasLength(5));
|
expect(log, hasLength(5));
|
||||||
expect(log[0], equalsIgnoringHashCodes('Gesture arena 1 ❙ Sweeping with 1 member.'));
|
expect(log[0], equalsIgnoringHashCodes('Gesture arena 1 ❙ Sweeping with 1 member.'));
|
||||||
expect(log[1], equalsIgnoringHashCodes('Gesture arena 1 ❙ Winner: TapGestureRecognizer#00000(state: ready, finalPosition: Offset(12.0, 8.0), button: 1)'));
|
expect(log[1], equalsIgnoringHashCodes('Gesture arena 1 ❙ Winner: TapGestureRecognizer#00000(state: ready, finalPosition: Offset(12.0, 8.0), button: 1)'));
|
||||||
|
@ -2,8 +2,6 @@
|
|||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
// @dart = 2.8
|
|
||||||
|
|
||||||
import 'package:flutter/gestures.dart';
|
import 'package:flutter/gestures.dart';
|
||||||
import 'package:fake_async/fake_async.dart';
|
import 'package:fake_async/fake_async.dart';
|
||||||
|
|
||||||
@ -26,10 +24,10 @@ class TestGestureArenaMember extends GestureArenaMember {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
DoubleTapGestureRecognizer tap;
|
late DoubleTapGestureRecognizer tap;
|
||||||
bool doubleTapRecognized;
|
bool doubleTapRecognized = false;
|
||||||
TapDownDetails doubleTapDownDetails;
|
TapDownDetails? doubleTapDownDetails;
|
||||||
bool doubleTapCanceled;
|
bool doubleTapCanceled = false;
|
||||||
|
|
||||||
setUp(() {
|
setUp(() {
|
||||||
ensureGestureBinding();
|
ensureGestureBinding();
|
||||||
@ -135,21 +133,21 @@ void main() {
|
|||||||
tester.closeArena(1);
|
tester.closeArena(1);
|
||||||
tester.route(down1);
|
tester.route(down1);
|
||||||
tester.route(up1);
|
tester.route(up1);
|
||||||
GestureBinding.instance.gestureArena.sweep(1);
|
GestureBinding.instance!.gestureArena.sweep(1);
|
||||||
expect(doubleTapDownDetails, isNull);
|
expect(doubleTapDownDetails, isNull);
|
||||||
|
|
||||||
tester.async.elapse(const Duration(milliseconds: 100));
|
tester.async.elapse(const Duration(milliseconds: 100));
|
||||||
tap.addPointer(down2);
|
tap.addPointer(down2);
|
||||||
tester.closeArena(2);
|
tester.closeArena(2);
|
||||||
expect(doubleTapDownDetails, isNotNull);
|
expect(doubleTapDownDetails, isNotNull);
|
||||||
expect(doubleTapDownDetails.globalPosition, down2.position);
|
expect(doubleTapDownDetails!.globalPosition, down2.position);
|
||||||
expect(doubleTapDownDetails.localPosition, down2.localPosition);
|
expect(doubleTapDownDetails!.localPosition, down2.localPosition);
|
||||||
tester.route(down2);
|
tester.route(down2);
|
||||||
expect(doubleTapRecognized, isFalse);
|
expect(doubleTapRecognized, isFalse);
|
||||||
|
|
||||||
tester.route(up2);
|
tester.route(up2);
|
||||||
expect(doubleTapRecognized, isTrue);
|
expect(doubleTapRecognized, isTrue);
|
||||||
GestureBinding.instance.gestureArena.sweep(2);
|
GestureBinding.instance!.gestureArena.sweep(2);
|
||||||
expect(doubleTapCanceled, isFalse);
|
expect(doubleTapCanceled, isFalse);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -158,13 +156,13 @@ void main() {
|
|||||||
tester.closeArena(1);
|
tester.closeArena(1);
|
||||||
tester.route(down1);
|
tester.route(down1);
|
||||||
tester.route(up1);
|
tester.route(up1);
|
||||||
GestureBinding.instance.gestureArena.sweep(1);
|
GestureBinding.instance!.gestureArena.sweep(1);
|
||||||
|
|
||||||
tap.addPointer(down3);
|
tap.addPointer(down3);
|
||||||
tester.closeArena(3);
|
tester.closeArena(3);
|
||||||
tester.route(down3);
|
tester.route(down3);
|
||||||
tester.route(up3);
|
tester.route(up3);
|
||||||
GestureBinding.instance.gestureArena.sweep(3);
|
GestureBinding.instance!.gestureArena.sweep(3);
|
||||||
|
|
||||||
expect(doubleTapRecognized, isFalse);
|
expect(doubleTapRecognized, isFalse);
|
||||||
expect(doubleTapDownDetails, isNull);
|
expect(doubleTapDownDetails, isNull);
|
||||||
@ -178,13 +176,13 @@ void main() {
|
|||||||
|
|
||||||
tester.route(move4);
|
tester.route(move4);
|
||||||
tester.route(up4);
|
tester.route(up4);
|
||||||
GestureBinding.instance.gestureArena.sweep(4);
|
GestureBinding.instance!.gestureArena.sweep(4);
|
||||||
|
|
||||||
tap.addPointer(down1);
|
tap.addPointer(down1);
|
||||||
tester.closeArena(1);
|
tester.closeArena(1);
|
||||||
tester.route(down2);
|
tester.route(down2);
|
||||||
tester.route(up1);
|
tester.route(up1);
|
||||||
GestureBinding.instance.gestureArena.sweep(1);
|
GestureBinding.instance!.gestureArena.sweep(1);
|
||||||
|
|
||||||
expect(doubleTapRecognized, isFalse);
|
expect(doubleTapRecognized, isFalse);
|
||||||
expect(doubleTapDownDetails, isNull);
|
expect(doubleTapDownDetails, isNull);
|
||||||
@ -196,14 +194,14 @@ void main() {
|
|||||||
tester.closeArena(1);
|
tester.closeArena(1);
|
||||||
tester.route(down1);
|
tester.route(down1);
|
||||||
tester.route(up1);
|
tester.route(up1);
|
||||||
GestureBinding.instance.gestureArena.sweep(1);
|
GestureBinding.instance!.gestureArena.sweep(1);
|
||||||
|
|
||||||
tester.async.elapse(const Duration(milliseconds: 5000));
|
tester.async.elapse(const Duration(milliseconds: 5000));
|
||||||
tap.addPointer(down2);
|
tap.addPointer(down2);
|
||||||
tester.closeArena(2);
|
tester.closeArena(2);
|
||||||
tester.route(down2);
|
tester.route(down2);
|
||||||
tester.route(up2);
|
tester.route(up2);
|
||||||
GestureBinding.instance.gestureArena.sweep(2);
|
GestureBinding.instance!.gestureArena.sweep(2);
|
||||||
|
|
||||||
expect(doubleTapRecognized, isFalse);
|
expect(doubleTapRecognized, isFalse);
|
||||||
expect(doubleTapDownDetails, isNull);
|
expect(doubleTapDownDetails, isNull);
|
||||||
@ -215,14 +213,14 @@ void main() {
|
|||||||
tester.closeArena(1);
|
tester.closeArena(1);
|
||||||
tester.route(down1);
|
tester.route(down1);
|
||||||
tester.route(up1);
|
tester.route(up1);
|
||||||
GestureBinding.instance.gestureArena.sweep(1);
|
GestureBinding.instance!.gestureArena.sweep(1);
|
||||||
|
|
||||||
tester.async.elapse(const Duration(milliseconds: 5000));
|
tester.async.elapse(const Duration(milliseconds: 5000));
|
||||||
tap.addPointer(down2);
|
tap.addPointer(down2);
|
||||||
tester.closeArena(2);
|
tester.closeArena(2);
|
||||||
tester.route(down2);
|
tester.route(down2);
|
||||||
tester.route(up2);
|
tester.route(up2);
|
||||||
GestureBinding.instance.gestureArena.sweep(2);
|
GestureBinding.instance!.gestureArena.sweep(2);
|
||||||
expect(doubleTapDownDetails, isNull);
|
expect(doubleTapDownDetails, isNull);
|
||||||
|
|
||||||
tester.async.elapse(const Duration(milliseconds: 100));
|
tester.async.elapse(const Duration(milliseconds: 100));
|
||||||
@ -231,12 +229,12 @@ void main() {
|
|||||||
tester.route(down5);
|
tester.route(down5);
|
||||||
expect(doubleTapRecognized, isFalse);
|
expect(doubleTapRecognized, isFalse);
|
||||||
expect(doubleTapDownDetails, isNotNull);
|
expect(doubleTapDownDetails, isNotNull);
|
||||||
expect(doubleTapDownDetails.globalPosition, down5.position);
|
expect(doubleTapDownDetails!.globalPosition, down5.position);
|
||||||
expect(doubleTapDownDetails.localPosition, down5.localPosition);
|
expect(doubleTapDownDetails!.localPosition, down5.localPosition);
|
||||||
|
|
||||||
tester.route(up5);
|
tester.route(up5);
|
||||||
expect(doubleTapRecognized, isTrue);
|
expect(doubleTapRecognized, isTrue);
|
||||||
GestureBinding.instance.gestureArena.sweep(5);
|
GestureBinding.instance!.gestureArena.sweep(5);
|
||||||
expect(doubleTapCanceled, isFalse);
|
expect(doubleTapCanceled, isFalse);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -246,7 +244,7 @@ void main() {
|
|||||||
tester.route(down1);
|
tester.route(down1);
|
||||||
tester.async.elapse(const Duration(milliseconds: 1000));
|
tester.async.elapse(const Duration(milliseconds: 1000));
|
||||||
tester.route(up1);
|
tester.route(up1);
|
||||||
GestureBinding.instance.gestureArena.sweep(1);
|
GestureBinding.instance!.gestureArena.sweep(1);
|
||||||
expect(doubleTapDownDetails, isNull);
|
expect(doubleTapDownDetails, isNull);
|
||||||
|
|
||||||
tap.addPointer(down2);
|
tap.addPointer(down2);
|
||||||
@ -254,12 +252,12 @@ void main() {
|
|||||||
tester.route(down2);
|
tester.route(down2);
|
||||||
expect(doubleTapRecognized, isFalse);
|
expect(doubleTapRecognized, isFalse);
|
||||||
expect(doubleTapDownDetails, isNotNull);
|
expect(doubleTapDownDetails, isNotNull);
|
||||||
expect(doubleTapDownDetails.globalPosition, down2.position);
|
expect(doubleTapDownDetails!.globalPosition, down2.position);
|
||||||
expect(doubleTapDownDetails.localPosition, down2.localPosition);
|
expect(doubleTapDownDetails!.localPosition, down2.localPosition);
|
||||||
|
|
||||||
tester.route(up2);
|
tester.route(up2);
|
||||||
expect(doubleTapRecognized, isTrue);
|
expect(doubleTapRecognized, isTrue);
|
||||||
GestureBinding.instance.gestureArena.sweep(2);
|
GestureBinding.instance!.gestureArena.sweep(2);
|
||||||
expect(doubleTapCanceled, isFalse);
|
expect(doubleTapCanceled, isFalse);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -273,10 +271,10 @@ void main() {
|
|||||||
tester.route(down1);
|
tester.route(down1);
|
||||||
|
|
||||||
tester.route(up1);
|
tester.route(up1);
|
||||||
GestureBinding.instance.gestureArena.sweep(1);
|
GestureBinding.instance!.gestureArena.sweep(1);
|
||||||
|
|
||||||
tester.route(up2);
|
tester.route(up2);
|
||||||
GestureBinding.instance.gestureArena.sweep(2);
|
GestureBinding.instance!.gestureArena.sweep(2);
|
||||||
|
|
||||||
expect(doubleTapRecognized, isFalse);
|
expect(doubleTapRecognized, isFalse);
|
||||||
expect(doubleTapDownDetails, isNull);
|
expect(doubleTapDownDetails, isNull);
|
||||||
@ -293,10 +291,10 @@ void main() {
|
|||||||
tester.route(down1);
|
tester.route(down1);
|
||||||
|
|
||||||
tester.route(up1);
|
tester.route(up1);
|
||||||
GestureBinding.instance.gestureArena.sweep(1);
|
GestureBinding.instance!.gestureArena.sweep(1);
|
||||||
|
|
||||||
tester.route(up2);
|
tester.route(up2);
|
||||||
GestureBinding.instance.gestureArena.sweep(2);
|
GestureBinding.instance!.gestureArena.sweep(2);
|
||||||
expect(doubleTapDownDetails, isNull);
|
expect(doubleTapDownDetails, isNull);
|
||||||
|
|
||||||
tester.async.elapse(const Duration(milliseconds: 100));
|
tester.async.elapse(const Duration(milliseconds: 100));
|
||||||
@ -305,32 +303,32 @@ void main() {
|
|||||||
tester.route(down1);
|
tester.route(down1);
|
||||||
expect(doubleTapRecognized, isFalse);
|
expect(doubleTapRecognized, isFalse);
|
||||||
expect(doubleTapDownDetails, isNotNull);
|
expect(doubleTapDownDetails, isNotNull);
|
||||||
expect(doubleTapDownDetails.globalPosition, down1.position);
|
expect(doubleTapDownDetails!.globalPosition, down1.position);
|
||||||
expect(doubleTapDownDetails.localPosition, down1.localPosition);
|
expect(doubleTapDownDetails!.localPosition, down1.localPosition);
|
||||||
|
|
||||||
tester.route(up1);
|
tester.route(up1);
|
||||||
expect(doubleTapRecognized, isTrue);
|
expect(doubleTapRecognized, isTrue);
|
||||||
GestureBinding.instance.gestureArena.sweep(1);
|
GestureBinding.instance!.gestureArena.sweep(1);
|
||||||
expect(doubleTapCanceled, isFalse);
|
expect(doubleTapCanceled, isFalse);
|
||||||
});
|
});
|
||||||
|
|
||||||
testGesture('Should cancel on arena reject during first tap', (GestureTester tester) {
|
testGesture('Should cancel on arena reject during first tap', (GestureTester tester) {
|
||||||
tap.addPointer(down1);
|
tap.addPointer(down1);
|
||||||
final TestGestureArenaMember member = TestGestureArenaMember();
|
final TestGestureArenaMember member = TestGestureArenaMember();
|
||||||
final GestureArenaEntry entry = GestureBinding.instance.gestureArena.add(1, member);
|
final GestureArenaEntry entry = GestureBinding.instance!.gestureArena.add(1, member);
|
||||||
tester.closeArena(1);
|
tester.closeArena(1);
|
||||||
tester.route(down1);
|
tester.route(down1);
|
||||||
|
|
||||||
tester.route(up1);
|
tester.route(up1);
|
||||||
entry.resolve(GestureDisposition.accepted);
|
entry.resolve(GestureDisposition.accepted);
|
||||||
expect(member.accepted, isTrue);
|
expect(member.accepted, isTrue);
|
||||||
GestureBinding.instance.gestureArena.sweep(1);
|
GestureBinding.instance!.gestureArena.sweep(1);
|
||||||
|
|
||||||
tap.addPointer(down2);
|
tap.addPointer(down2);
|
||||||
tester.closeArena(2);
|
tester.closeArena(2);
|
||||||
tester.route(down2);
|
tester.route(down2);
|
||||||
tester.route(up2);
|
tester.route(up2);
|
||||||
GestureBinding.instance.gestureArena.sweep(2);
|
GestureBinding.instance!.gestureArena.sweep(2);
|
||||||
|
|
||||||
expect(doubleTapRecognized, isFalse);
|
expect(doubleTapRecognized, isFalse);
|
||||||
expect(doubleTapDownDetails, isNull);
|
expect(doubleTapDownDetails, isNull);
|
||||||
@ -340,11 +338,11 @@ void main() {
|
|||||||
testGesture('Should cancel on arena reject between taps', (GestureTester tester) {
|
testGesture('Should cancel on arena reject between taps', (GestureTester tester) {
|
||||||
tap.addPointer(down1);
|
tap.addPointer(down1);
|
||||||
final TestGestureArenaMember member = TestGestureArenaMember();
|
final TestGestureArenaMember member = TestGestureArenaMember();
|
||||||
final GestureArenaEntry entry = GestureBinding.instance.gestureArena.add(1, member);
|
final GestureArenaEntry entry = GestureBinding.instance!.gestureArena.add(1, member);
|
||||||
tester.closeArena(1);
|
tester.closeArena(1);
|
||||||
tester.route(down1);
|
tester.route(down1);
|
||||||
tester.route(up1);
|
tester.route(up1);
|
||||||
GestureBinding.instance.gestureArena.sweep(1);
|
GestureBinding.instance!.gestureArena.sweep(1);
|
||||||
|
|
||||||
entry.resolve(GestureDisposition.accepted);
|
entry.resolve(GestureDisposition.accepted);
|
||||||
expect(member.accepted, isTrue);
|
expect(member.accepted, isTrue);
|
||||||
@ -353,7 +351,7 @@ void main() {
|
|||||||
tester.closeArena(2);
|
tester.closeArena(2);
|
||||||
tester.route(down2);
|
tester.route(down2);
|
||||||
tester.route(up2);
|
tester.route(up2);
|
||||||
GestureBinding.instance.gestureArena.sweep(2);
|
GestureBinding.instance!.gestureArena.sweep(2);
|
||||||
|
|
||||||
expect(doubleTapRecognized, isFalse);
|
expect(doubleTapRecognized, isFalse);
|
||||||
expect(doubleTapDownDetails, isNull);
|
expect(doubleTapDownDetails, isNull);
|
||||||
@ -363,11 +361,11 @@ void main() {
|
|||||||
testGesture('Should cancel on arena reject during last tap', (GestureTester tester) {
|
testGesture('Should cancel on arena reject during last tap', (GestureTester tester) {
|
||||||
tap.addPointer(down1);
|
tap.addPointer(down1);
|
||||||
final TestGestureArenaMember member = TestGestureArenaMember();
|
final TestGestureArenaMember member = TestGestureArenaMember();
|
||||||
final GestureArenaEntry entry = GestureBinding.instance.gestureArena.add(1, member);
|
final GestureArenaEntry entry = GestureBinding.instance!.gestureArena.add(1, member);
|
||||||
tester.closeArena(1);
|
tester.closeArena(1);
|
||||||
tester.route(down1);
|
tester.route(down1);
|
||||||
tester.route(up1);
|
tester.route(up1);
|
||||||
GestureBinding.instance.gestureArena.sweep(1);
|
GestureBinding.instance!.gestureArena.sweep(1);
|
||||||
expect(doubleTapDownDetails, isNull);
|
expect(doubleTapDownDetails, isNull);
|
||||||
|
|
||||||
tester.async.elapse(const Duration(milliseconds: 100));
|
tester.async.elapse(const Duration(milliseconds: 100));
|
||||||
@ -375,8 +373,8 @@ void main() {
|
|||||||
tester.closeArena(2);
|
tester.closeArena(2);
|
||||||
tester.route(down2);
|
tester.route(down2);
|
||||||
expect(doubleTapDownDetails, isNotNull);
|
expect(doubleTapDownDetails, isNotNull);
|
||||||
expect(doubleTapDownDetails.globalPosition, down2.position);
|
expect(doubleTapDownDetails!.globalPosition, down2.position);
|
||||||
expect(doubleTapDownDetails.localPosition, down2.localPosition);
|
expect(doubleTapDownDetails!.localPosition, down2.localPosition);
|
||||||
expect(doubleTapCanceled, isFalse);
|
expect(doubleTapCanceled, isFalse);
|
||||||
|
|
||||||
entry.resolve(GestureDisposition.accepted);
|
entry.resolve(GestureDisposition.accepted);
|
||||||
@ -384,7 +382,7 @@ void main() {
|
|||||||
expect(doubleTapCanceled, isTrue);
|
expect(doubleTapCanceled, isTrue);
|
||||||
|
|
||||||
tester.route(up2);
|
tester.route(up2);
|
||||||
GestureBinding.instance.gestureArena.sweep(2);
|
GestureBinding.instance!.gestureArena.sweep(2);
|
||||||
expect(doubleTapRecognized, isFalse);
|
expect(doubleTapRecognized, isFalse);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -392,11 +390,11 @@ void main() {
|
|||||||
FakeAsync().run((FakeAsync async) {
|
FakeAsync().run((FakeAsync async) {
|
||||||
tap.addPointer(down1);
|
tap.addPointer(down1);
|
||||||
final TestGestureArenaMember member = TestGestureArenaMember();
|
final TestGestureArenaMember member = TestGestureArenaMember();
|
||||||
GestureBinding.instance.gestureArena.add(1, member);
|
GestureBinding.instance!.gestureArena.add(1, member);
|
||||||
tester.closeArena(1);
|
tester.closeArena(1);
|
||||||
tester.route(down1);
|
tester.route(down1);
|
||||||
tester.route(up1);
|
tester.route(up1);
|
||||||
GestureBinding.instance.gestureArena.sweep(1);
|
GestureBinding.instance!.gestureArena.sweep(1);
|
||||||
|
|
||||||
expect(member.accepted, isFalse);
|
expect(member.accepted, isFalse);
|
||||||
async.elapse(const Duration(milliseconds: 5000));
|
async.elapse(const Duration(milliseconds: 5000));
|
||||||
@ -413,14 +411,14 @@ void main() {
|
|||||||
tester.closeArena(1);
|
tester.closeArena(1);
|
||||||
tester.route(down1);
|
tester.route(down1);
|
||||||
tester.route(up1);
|
tester.route(up1);
|
||||||
GestureBinding.instance.gestureArena.sweep(1);
|
GestureBinding.instance!.gestureArena.sweep(1);
|
||||||
|
|
||||||
tester.async.elapse(const Duration(milliseconds: 10));
|
tester.async.elapse(const Duration(milliseconds: 10));
|
||||||
tap.addPointer(down2);
|
tap.addPointer(down2);
|
||||||
tester.closeArena(2);
|
tester.closeArena(2);
|
||||||
tester.route(down2);
|
tester.route(down2);
|
||||||
tester.route(up2);
|
tester.route(up2);
|
||||||
GestureBinding.instance.gestureArena.sweep(2);
|
GestureBinding.instance!.gestureArena.sweep(2);
|
||||||
|
|
||||||
expect(doubleTapRecognized, isFalse);
|
expect(doubleTapRecognized, isFalse);
|
||||||
expect(doubleTapDownDetails, isNull);
|
expect(doubleTapDownDetails, isNull);
|
||||||
@ -432,14 +430,14 @@ void main() {
|
|||||||
tester.closeArena(1);
|
tester.closeArena(1);
|
||||||
tester.route(down1);
|
tester.route(down1);
|
||||||
tester.route(up1);
|
tester.route(up1);
|
||||||
GestureBinding.instance.gestureArena.sweep(1);
|
GestureBinding.instance!.gestureArena.sweep(1);
|
||||||
|
|
||||||
tester.async.elapse(const Duration(milliseconds: 10));
|
tester.async.elapse(const Duration(milliseconds: 10));
|
||||||
tap.addPointer(down2);
|
tap.addPointer(down2);
|
||||||
tester.closeArena(2);
|
tester.closeArena(2);
|
||||||
tester.route(down2);
|
tester.route(down2);
|
||||||
tester.route(up2);
|
tester.route(up2);
|
||||||
GestureBinding.instance.gestureArena.sweep(2);
|
GestureBinding.instance!.gestureArena.sweep(2);
|
||||||
expect(doubleTapDownDetails, isNull);
|
expect(doubleTapDownDetails, isNull);
|
||||||
|
|
||||||
tester.async.elapse(const Duration(milliseconds: 100));
|
tester.async.elapse(const Duration(milliseconds: 100));
|
||||||
@ -448,12 +446,12 @@ void main() {
|
|||||||
tester.route(down5);
|
tester.route(down5);
|
||||||
expect(doubleTapRecognized, isFalse);
|
expect(doubleTapRecognized, isFalse);
|
||||||
expect(doubleTapDownDetails, isNotNull);
|
expect(doubleTapDownDetails, isNotNull);
|
||||||
expect(doubleTapDownDetails.globalPosition, down5.position);
|
expect(doubleTapDownDetails!.globalPosition, down5.position);
|
||||||
expect(doubleTapDownDetails.localPosition, down5.localPosition);
|
expect(doubleTapDownDetails!.localPosition, down5.localPosition);
|
||||||
|
|
||||||
tester.route(up5);
|
tester.route(up5);
|
||||||
expect(doubleTapRecognized, isTrue);
|
expect(doubleTapRecognized, isTrue);
|
||||||
GestureBinding.instance.gestureArena.sweep(5);
|
GestureBinding.instance!.gestureArena.sweep(5);
|
||||||
expect(doubleTapCanceled, isFalse);
|
expect(doubleTapCanceled, isFalse);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -470,7 +468,7 @@ void main() {
|
|||||||
tester.closeArena(1);
|
tester.closeArena(1);
|
||||||
tester.route(down1);
|
tester.route(down1);
|
||||||
tester.route(up1);
|
tester.route(up1);
|
||||||
GestureBinding.instance.gestureArena.sweep(1);
|
GestureBinding.instance!.gestureArena.sweep(1);
|
||||||
|
|
||||||
tester.async.elapse(interval);
|
tester.async.elapse(interval);
|
||||||
|
|
||||||
@ -478,7 +476,7 @@ void main() {
|
|||||||
tester.closeArena(6);
|
tester.closeArena(6);
|
||||||
tester.route(down6);
|
tester.route(down6);
|
||||||
tester.route(up6);
|
tester.route(up6);
|
||||||
GestureBinding.instance.gestureArena.sweep(6);
|
GestureBinding.instance!.gestureArena.sweep(6);
|
||||||
|
|
||||||
tester.async.elapse(interval);
|
tester.async.elapse(interval);
|
||||||
expect(doubleTapRecognized, isFalse);
|
expect(doubleTapRecognized, isFalse);
|
||||||
@ -487,7 +485,7 @@ void main() {
|
|||||||
tester.closeArena(2);
|
tester.closeArena(2);
|
||||||
tester.route(down2);
|
tester.route(down2);
|
||||||
tester.route(up2);
|
tester.route(up2);
|
||||||
GestureBinding.instance.gestureArena.sweep(2);
|
GestureBinding.instance!.gestureArena.sweep(2);
|
||||||
|
|
||||||
expect(doubleTapRecognized, isFalse);
|
expect(doubleTapRecognized, isFalse);
|
||||||
expect(doubleTapDownDetails, isNull);
|
expect(doubleTapDownDetails, isNull);
|
||||||
@ -505,7 +503,7 @@ void main() {
|
|||||||
tester.closeArena(6);
|
tester.closeArena(6);
|
||||||
tester.route(down6);
|
tester.route(down6);
|
||||||
tester.route(up6);
|
tester.route(up6);
|
||||||
GestureBinding.instance.gestureArena.sweep(6);
|
GestureBinding.instance!.gestureArena.sweep(6);
|
||||||
|
|
||||||
tester.async.elapse(interval);
|
tester.async.elapse(interval);
|
||||||
|
|
||||||
@ -513,7 +511,7 @@ void main() {
|
|||||||
tester.closeArena(1);
|
tester.closeArena(1);
|
||||||
tester.route(down1);
|
tester.route(down1);
|
||||||
tester.route(up1);
|
tester.route(up1);
|
||||||
GestureBinding.instance.gestureArena.sweep(1);
|
GestureBinding.instance!.gestureArena.sweep(1);
|
||||||
|
|
||||||
expect(doubleTapRecognized, isFalse);
|
expect(doubleTapRecognized, isFalse);
|
||||||
expect(doubleTapDownDetails, isNull);
|
expect(doubleTapDownDetails, isNull);
|
||||||
@ -523,10 +521,10 @@ void main() {
|
|||||||
tester.closeArena(2);
|
tester.closeArena(2);
|
||||||
tester.route(down2);
|
tester.route(down2);
|
||||||
expect(doubleTapDownDetails, isNotNull);
|
expect(doubleTapDownDetails, isNotNull);
|
||||||
expect(doubleTapDownDetails.globalPosition, down2.position);
|
expect(doubleTapDownDetails!.globalPosition, down2.position);
|
||||||
expect(doubleTapDownDetails.localPosition, down2.localPosition);
|
expect(doubleTapDownDetails!.localPosition, down2.localPosition);
|
||||||
tester.route(up2);
|
tester.route(up2);
|
||||||
GestureBinding.instance.gestureArena.sweep(2);
|
GestureBinding.instance!.gestureArena.sweep(2);
|
||||||
|
|
||||||
expect(doubleTapRecognized, isTrue);
|
expect(doubleTapRecognized, isTrue);
|
||||||
expect(doubleTapCanceled, isFalse);
|
expect(doubleTapCanceled, isFalse);
|
||||||
@ -542,9 +540,9 @@ void main() {
|
|||||||
// competition with a tap gesture recognizer listening on a different button.
|
// competition with a tap gesture recognizer listening on a different button.
|
||||||
|
|
||||||
final List<String> recognized = <String>[];
|
final List<String> recognized = <String>[];
|
||||||
TapGestureRecognizer tapPrimary;
|
late TapGestureRecognizer tapPrimary;
|
||||||
TapGestureRecognizer tapSecondary;
|
late TapGestureRecognizer tapSecondary;
|
||||||
DoubleTapGestureRecognizer doubleTap;
|
late DoubleTapGestureRecognizer doubleTap;
|
||||||
setUp(() {
|
setUp(() {
|
||||||
tapPrimary = TapGestureRecognizer()
|
tapPrimary = TapGestureRecognizer()
|
||||||
..onTapDown = (TapDownDetails details) {
|
..onTapDown = (TapDownDetails details) {
|
||||||
@ -612,7 +610,7 @@ void main() {
|
|||||||
tester.closeArena(6);
|
tester.closeArena(6);
|
||||||
tester.route(down6);
|
tester.route(down6);
|
||||||
tester.route(up6);
|
tester.route(up6);
|
||||||
GestureBinding.instance.gestureArena.sweep(6);
|
GestureBinding.instance!.gestureArena.sweep(6);
|
||||||
|
|
||||||
tester.async.elapse(const Duration(milliseconds: 100));
|
tester.async.elapse(const Duration(milliseconds: 100));
|
||||||
doubleTap.addPointer(down7);
|
doubleTap.addPointer(down7);
|
||||||
|
@ -2,8 +2,6 @@
|
|||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
// @dart = 2.8
|
|
||||||
|
|
||||||
import 'package:flutter_test/flutter_test.dart';
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
import 'package:flutter/gestures.dart';
|
import 'package:flutter/gestures.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
@ -24,7 +22,7 @@ void main() {
|
|||||||
didStartPan = true;
|
didStartPan = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
Offset updatedScrollDelta;
|
Offset? updatedScrollDelta;
|
||||||
pan.onUpdate = (DragUpdateDetails details) {
|
pan.onUpdate = (DragUpdateDetails details) {
|
||||||
updatedScrollDelta = details.delta;
|
updatedScrollDelta = details.delta;
|
||||||
};
|
};
|
||||||
@ -81,13 +79,13 @@ void main() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
testGesture('Should report most recent point to onStart by default', (GestureTester tester) {
|
testGesture('Should report most recent point to onStart by default', (GestureTester tester) {
|
||||||
HorizontalDragGestureRecognizer drag = HorizontalDragGestureRecognizer();
|
final HorizontalDragGestureRecognizer drag = HorizontalDragGestureRecognizer();
|
||||||
VerticalDragGestureRecognizer competingDrag = VerticalDragGestureRecognizer()
|
final VerticalDragGestureRecognizer competingDrag = VerticalDragGestureRecognizer()
|
||||||
..onStart = (_) {};
|
..onStart = (_) {};
|
||||||
addTearDown(() => drag?.dispose);
|
addTearDown(() => drag.dispose);
|
||||||
addTearDown(() => competingDrag?.dispose);
|
addTearDown(() => competingDrag.dispose);
|
||||||
|
|
||||||
Offset positionAtOnStart;
|
late Offset positionAtOnStart;
|
||||||
drag.onStart = (DragStartDetails details) {
|
drag.onStart = (DragStartDetails details) {
|
||||||
positionAtOnStart = details.globalPosition;
|
positionAtOnStart = details.globalPosition;
|
||||||
};
|
};
|
||||||
@ -100,26 +98,21 @@ void main() {
|
|||||||
tester.route(down);
|
tester.route(down);
|
||||||
|
|
||||||
tester.route(pointer.move(const Offset(30.0, 0.0)));
|
tester.route(pointer.move(const Offset(30.0, 0.0)));
|
||||||
drag.dispose();
|
|
||||||
drag = null;
|
|
||||||
competingDrag.dispose();
|
|
||||||
competingDrag = null;
|
|
||||||
|
|
||||||
expect(positionAtOnStart, const Offset(30.0, 00.0));
|
expect(positionAtOnStart, const Offset(30.0, 00.0));
|
||||||
});
|
});
|
||||||
|
|
||||||
testGesture('Should report most recent point to onStart with a start configuration', (GestureTester tester) {
|
testGesture('Should report most recent point to onStart with a start configuration', (GestureTester tester) {
|
||||||
HorizontalDragGestureRecognizer drag = HorizontalDragGestureRecognizer();
|
final HorizontalDragGestureRecognizer drag = HorizontalDragGestureRecognizer();
|
||||||
VerticalDragGestureRecognizer competingDrag = VerticalDragGestureRecognizer()
|
final VerticalDragGestureRecognizer competingDrag = VerticalDragGestureRecognizer()
|
||||||
..onStart = (_) {};
|
..onStart = (_) {};
|
||||||
addTearDown(() => drag?.dispose);
|
addTearDown(() => drag.dispose);
|
||||||
addTearDown(() => competingDrag?.dispose);
|
addTearDown(() => competingDrag.dispose);
|
||||||
|
|
||||||
Offset positionAtOnStart;
|
Offset? positionAtOnStart;
|
||||||
drag.onStart = (DragStartDetails details) {
|
drag.onStart = (DragStartDetails details) {
|
||||||
positionAtOnStart = details.globalPosition;
|
positionAtOnStart = details.globalPosition;
|
||||||
};
|
};
|
||||||
Offset updateOffset;
|
Offset? updateOffset;
|
||||||
drag.onUpdate = (DragUpdateDetails details) {
|
drag.onUpdate = (DragUpdateDetails details) {
|
||||||
updateOffset = details.globalPosition;
|
updateOffset = details.globalPosition;
|
||||||
};
|
};
|
||||||
@ -132,10 +125,6 @@ void main() {
|
|||||||
tester.route(down);
|
tester.route(down);
|
||||||
|
|
||||||
tester.route(pointer.move(const Offset(30.0, 0.0)));
|
tester.route(pointer.move(const Offset(30.0, 0.0)));
|
||||||
drag.dispose();
|
|
||||||
drag = null;
|
|
||||||
competingDrag.dispose();
|
|
||||||
competingDrag = null;
|
|
||||||
|
|
||||||
expect(positionAtOnStart, const Offset(30.0, 0.0));
|
expect(positionAtOnStart, const Offset(30.0, 0.0));
|
||||||
expect(updateOffset, null);
|
expect(updateOffset, null);
|
||||||
@ -150,7 +139,7 @@ void main() {
|
|||||||
didStartDrag = true;
|
didStartDrag = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
double updatedDelta;
|
double? updatedDelta;
|
||||||
drag.onUpdate = (DragUpdateDetails details) {
|
drag.onUpdate = (DragUpdateDetails details) {
|
||||||
updatedDelta = details.primaryDelta;
|
updatedDelta = details.primaryDelta;
|
||||||
};
|
};
|
||||||
@ -197,12 +186,12 @@ void main() {
|
|||||||
final HorizontalDragGestureRecognizer drag = HorizontalDragGestureRecognizer() ..dragStartBehavior = DragStartBehavior.down;
|
final HorizontalDragGestureRecognizer drag = HorizontalDragGestureRecognizer() ..dragStartBehavior = DragStartBehavior.down;
|
||||||
addTearDown(drag.dispose);
|
addTearDown(drag.dispose);
|
||||||
|
|
||||||
Duration startTimestamp;
|
Duration? startTimestamp;
|
||||||
drag.onStart = (DragStartDetails details) {
|
drag.onStart = (DragStartDetails details) {
|
||||||
startTimestamp = details.sourceTimeStamp;
|
startTimestamp = details.sourceTimeStamp;
|
||||||
};
|
};
|
||||||
|
|
||||||
Duration updatedTimestamp;
|
Duration? updatedTimestamp;
|
||||||
drag.onUpdate = (DragUpdateDetails details) {
|
drag.onUpdate = (DragUpdateDetails details) {
|
||||||
updatedTimestamp = details.sourceTimeStamp;
|
updatedTimestamp = details.sourceTimeStamp;
|
||||||
};
|
};
|
||||||
@ -224,20 +213,20 @@ void main() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
testGesture('Should report initial down point to onStart with a down configuration', (GestureTester tester) {
|
testGesture('Should report initial down point to onStart with a down configuration', (GestureTester tester) {
|
||||||
HorizontalDragGestureRecognizer drag = HorizontalDragGestureRecognizer()
|
final HorizontalDragGestureRecognizer drag = HorizontalDragGestureRecognizer()
|
||||||
..dragStartBehavior = DragStartBehavior.down;
|
..dragStartBehavior = DragStartBehavior.down;
|
||||||
VerticalDragGestureRecognizer competingDrag = VerticalDragGestureRecognizer()
|
final VerticalDragGestureRecognizer competingDrag = VerticalDragGestureRecognizer()
|
||||||
..dragStartBehavior = DragStartBehavior.down
|
..dragStartBehavior = DragStartBehavior.down
|
||||||
..onStart = (_) {};
|
..onStart = (_) {};
|
||||||
addTearDown(() => drag?.dispose);
|
addTearDown(() => drag.dispose);
|
||||||
addTearDown(() => competingDrag?.dispose);
|
addTearDown(() => competingDrag.dispose);
|
||||||
|
|
||||||
Offset positionAtOnStart;
|
Offset? positionAtOnStart;
|
||||||
drag.onStart = (DragStartDetails details) {
|
drag.onStart = (DragStartDetails details) {
|
||||||
positionAtOnStart = details.globalPosition;
|
positionAtOnStart = details.globalPosition;
|
||||||
};
|
};
|
||||||
Offset updateOffset;
|
Offset? updateOffset;
|
||||||
Offset updateDelta;
|
Offset? updateDelta;
|
||||||
drag.onUpdate = (DragUpdateDetails details) {
|
drag.onUpdate = (DragUpdateDetails details) {
|
||||||
updateOffset = details.globalPosition;
|
updateOffset = details.globalPosition;
|
||||||
updateDelta = details.delta;
|
updateDelta = details.delta;
|
||||||
@ -251,11 +240,6 @@ void main() {
|
|||||||
tester.route(down);
|
tester.route(down);
|
||||||
|
|
||||||
tester.route(pointer.move(const Offset(30.0, 0.0)));
|
tester.route(pointer.move(const Offset(30.0, 0.0)));
|
||||||
drag.dispose();
|
|
||||||
drag = null;
|
|
||||||
competingDrag.dispose();
|
|
||||||
competingDrag = null;
|
|
||||||
|
|
||||||
expect(positionAtOnStart, const Offset(10.0, 10.0));
|
expect(positionAtOnStart, const Offset(10.0, 10.0));
|
||||||
|
|
||||||
// The drag is horizontal so we're going to ignore the vertical delta position
|
// The drag is horizontal so we're going to ignore the vertical delta position
|
||||||
@ -265,12 +249,12 @@ void main() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
testGesture('Drag with multiple pointers in down behavior', (GestureTester tester) {
|
testGesture('Drag with multiple pointers in down behavior', (GestureTester tester) {
|
||||||
HorizontalDragGestureRecognizer drag1 =
|
final HorizontalDragGestureRecognizer drag1 =
|
||||||
HorizontalDragGestureRecognizer() ..dragStartBehavior = DragStartBehavior.down;
|
HorizontalDragGestureRecognizer() ..dragStartBehavior = DragStartBehavior.down;
|
||||||
VerticalDragGestureRecognizer drag2 =
|
final VerticalDragGestureRecognizer drag2 =
|
||||||
VerticalDragGestureRecognizer() ..dragStartBehavior = DragStartBehavior.down;
|
VerticalDragGestureRecognizer() ..dragStartBehavior = DragStartBehavior.down;
|
||||||
addTearDown(() => drag1?.dispose);
|
addTearDown(() => drag1.dispose);
|
||||||
addTearDown(() => drag2?.dispose);
|
addTearDown(() => drag2.dispose);
|
||||||
|
|
||||||
final List<String> log = <String>[];
|
final List<String> log = <String>[];
|
||||||
drag1.onDown = (_) { log.add('drag1-down'); };
|
drag1.onDown = (_) { log.add('drag1-down'); };
|
||||||
@ -313,11 +297,6 @@ void main() {
|
|||||||
tester.route(pointer5.up());
|
tester.route(pointer5.up());
|
||||||
tester.route(pointer6.up());
|
tester.route(pointer6.up());
|
||||||
|
|
||||||
drag1.dispose();
|
|
||||||
drag1 = null;
|
|
||||||
drag2.dispose();
|
|
||||||
drag2 = null;
|
|
||||||
|
|
||||||
expect(log, <String>[
|
expect(log, <String>[
|
||||||
'drag1-down',
|
'drag1-down',
|
||||||
'drag2-down',
|
'drag2-down',
|
||||||
@ -343,8 +322,8 @@ void main() {
|
|||||||
final HorizontalDragGestureRecognizer drag = HorizontalDragGestureRecognizer() ..dragStartBehavior = DragStartBehavior.down;
|
final HorizontalDragGestureRecognizer drag = HorizontalDragGestureRecognizer() ..dragStartBehavior = DragStartBehavior.down;
|
||||||
addTearDown(drag.dispose);
|
addTearDown(drag.dispose);
|
||||||
|
|
||||||
Velocity velocity;
|
late Velocity velocity;
|
||||||
double primaryVelocity;
|
double? primaryVelocity;
|
||||||
drag.onEnd = (DragEndDetails details) {
|
drag.onEnd = (DragEndDetails details) {
|
||||||
velocity = details.velocity;
|
velocity = details.velocity;
|
||||||
primaryVelocity = details.primaryVelocity;
|
primaryVelocity = details.primaryVelocity;
|
||||||
@ -376,7 +355,7 @@ void main() {
|
|||||||
final HorizontalDragGestureRecognizer drag = HorizontalDragGestureRecognizer() ..dragStartBehavior = DragStartBehavior.down;
|
final HorizontalDragGestureRecognizer drag = HorizontalDragGestureRecognizer() ..dragStartBehavior = DragStartBehavior.down;
|
||||||
addTearDown(drag.dispose);
|
addTearDown(drag.dispose);
|
||||||
|
|
||||||
Velocity velocity;
|
late Velocity velocity;
|
||||||
drag.onEnd = (DragEndDetails details) {
|
drag.onEnd = (DragEndDetails details) {
|
||||||
velocity = details.velocity;
|
velocity = details.velocity;
|
||||||
};
|
};
|
||||||
@ -409,7 +388,7 @@ void main() {
|
|||||||
final HorizontalDragGestureRecognizer drag = HorizontalDragGestureRecognizer() ..dragStartBehavior = DragStartBehavior.down;
|
final HorizontalDragGestureRecognizer drag = HorizontalDragGestureRecognizer() ..dragStartBehavior = DragStartBehavior.down;
|
||||||
addTearDown(drag.dispose);
|
addTearDown(drag.dispose);
|
||||||
|
|
||||||
Velocity velocity;
|
late Velocity velocity;
|
||||||
drag.onEnd = (DragEndDetails details) {
|
drag.onEnd = (DragEndDetails details) {
|
||||||
velocity = details.velocity;
|
velocity = details.velocity;
|
||||||
};
|
};
|
||||||
@ -443,8 +422,8 @@ void main() {
|
|||||||
didStartDrag = true;
|
didStartDrag = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
Offset updateDelta;
|
Offset? updateDelta;
|
||||||
double updatePrimaryDelta;
|
double? updatePrimaryDelta;
|
||||||
drag.onUpdate = (DragUpdateDetails details) {
|
drag.onUpdate = (DragUpdateDetails details) {
|
||||||
updateDelta = details.delta;
|
updateDelta = details.delta;
|
||||||
updatePrimaryDelta = details.primaryDelta;
|
updatePrimaryDelta = details.primaryDelta;
|
||||||
@ -500,11 +479,11 @@ void main() {
|
|||||||
final HorizontalDragGestureRecognizer drag = HorizontalDragGestureRecognizer() ..dragStartBehavior = DragStartBehavior.down;
|
final HorizontalDragGestureRecognizer drag = HorizontalDragGestureRecognizer() ..dragStartBehavior = DragStartBehavior.down;
|
||||||
addTearDown(drag.dispose);
|
addTearDown(drag.dispose);
|
||||||
|
|
||||||
Offset latestGlobalPosition;
|
Offset? latestGlobalPosition;
|
||||||
drag.onStart = (DragStartDetails details) {
|
drag.onStart = (DragStartDetails details) {
|
||||||
latestGlobalPosition = details.globalPosition;
|
latestGlobalPosition = details.globalPosition;
|
||||||
};
|
};
|
||||||
Offset latestDelta;
|
Offset? latestDelta;
|
||||||
drag.onUpdate = (DragUpdateDetails details) {
|
drag.onUpdate = (DragUpdateDetails details) {
|
||||||
latestGlobalPosition = details.globalPosition;
|
latestGlobalPosition = details.globalPosition;
|
||||||
latestDelta = details.delta;
|
latestDelta = details.delta;
|
||||||
@ -543,7 +522,7 @@ void main() {
|
|||||||
didStartDrag = true;
|
didStartDrag = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
double updatedDelta;
|
double? updatedDelta;
|
||||||
drag.onUpdate = (DragUpdateDetails details) {
|
drag.onUpdate = (DragUpdateDetails details) {
|
||||||
updatedDelta = details.primaryDelta;
|
updatedDelta = details.primaryDelta;
|
||||||
};
|
};
|
||||||
@ -609,8 +588,8 @@ void main() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
group('Enforce consistent-button restriction:', () {
|
group('Enforce consistent-button restriction:', () {
|
||||||
PanGestureRecognizer pan;
|
late PanGestureRecognizer pan;
|
||||||
TapGestureRecognizer tap;
|
late TapGestureRecognizer tap;
|
||||||
final List<String> logs = <String>[];
|
final List<String> logs = <String>[];
|
||||||
|
|
||||||
setUp(() {
|
setUp(() {
|
||||||
@ -750,9 +729,9 @@ void main() {
|
|||||||
// competition with a tap gesture recognizer listening on a different button.
|
// competition with a tap gesture recognizer listening on a different button.
|
||||||
|
|
||||||
final List<String> recognized = <String>[];
|
final List<String> recognized = <String>[];
|
||||||
TapGestureRecognizer tapPrimary;
|
late TapGestureRecognizer tapPrimary;
|
||||||
TapGestureRecognizer tapSecondary;
|
late TapGestureRecognizer tapSecondary;
|
||||||
PanGestureRecognizer pan;
|
late PanGestureRecognizer pan;
|
||||||
setUp(() {
|
setUp(() {
|
||||||
tapPrimary = TapGestureRecognizer()
|
tapPrimary = TapGestureRecognizer()
|
||||||
..onTapDown = (TapDownDetails details) {
|
..onTapDown = (TapDownDetails details) {
|
||||||
@ -938,12 +917,12 @@ void main() {
|
|||||||
logs.clear();
|
logs.clear();
|
||||||
|
|
||||||
tester.route(pointer1.up());
|
tester.route(pointer1.up());
|
||||||
GestureBinding.instance.gestureArena.sweep(pointer1.pointer);
|
GestureBinding.instance!.gestureArena.sweep(pointer1.pointer);
|
||||||
expect(logs, <String>['downT', 'upT']);
|
expect(logs, <String>['downT', 'upT']);
|
||||||
logs.clear();
|
logs.clear();
|
||||||
|
|
||||||
tester.route(pointer2.up());
|
tester.route(pointer2.up());
|
||||||
GestureBinding.instance.gestureArena.sweep(pointer2.pointer);
|
GestureBinding.instance!.gestureArena.sweep(pointer2.pointer);
|
||||||
expect(logs, <String>['cancelH']);
|
expect(logs, <String>['cancelH']);
|
||||||
logs.clear();
|
logs.clear();
|
||||||
},
|
},
|
||||||
@ -991,13 +970,13 @@ void main() {
|
|||||||
logs.clear();
|
logs.clear();
|
||||||
|
|
||||||
tester.route(pointer2.up());
|
tester.route(pointer2.up());
|
||||||
GestureBinding.instance.gestureArena.sweep(pointer2.pointer);
|
GestureBinding.instance!.gestureArena.sweep(pointer2.pointer);
|
||||||
// Tap is not triggered because pointer2 is not its primary pointer
|
// Tap is not triggered because pointer2 is not its primary pointer
|
||||||
expect(logs, <String>[]);
|
expect(logs, <String>[]);
|
||||||
logs.clear();
|
logs.clear();
|
||||||
|
|
||||||
tester.route(pointer1.up());
|
tester.route(pointer1.up());
|
||||||
GestureBinding.instance.gestureArena.sweep(pointer1.pointer);
|
GestureBinding.instance!.gestureArena.sweep(pointer1.pointer);
|
||||||
expect(logs, <String>['cancelH', 'downT', 'upT']);
|
expect(logs, <String>['cancelH', 'downT', 'upT']);
|
||||||
logs.clear();
|
logs.clear();
|
||||||
},
|
},
|
||||||
@ -1049,12 +1028,12 @@ void main() {
|
|||||||
logs.clear();
|
logs.clear();
|
||||||
|
|
||||||
tester.route(pointer2.up());
|
tester.route(pointer2.up());
|
||||||
GestureBinding.instance.gestureArena.sweep(pointer2.pointer);
|
GestureBinding.instance!.gestureArena.sweep(pointer2.pointer);
|
||||||
expect(logs, <String>[]);
|
expect(logs, <String>[]);
|
||||||
logs.clear();
|
logs.clear();
|
||||||
|
|
||||||
tester.route(pointer1.up());
|
tester.route(pointer1.up());
|
||||||
GestureBinding.instance.gestureArena.sweep(pointer1.pointer);
|
GestureBinding.instance!.gestureArena.sweep(pointer1.pointer);
|
||||||
expect(logs, <String>['endH']);
|
expect(logs, <String>['endH']);
|
||||||
logs.clear();
|
logs.clear();
|
||||||
},
|
},
|
||||||
@ -1102,7 +1081,7 @@ void main() {
|
|||||||
logs.clear();
|
logs.clear();
|
||||||
|
|
||||||
tester.route(pointer1.up());
|
tester.route(pointer1.up());
|
||||||
GestureBinding.instance.gestureArena.sweep(pointer1.pointer);
|
GestureBinding.instance!.gestureArena.sweep(pointer1.pointer);
|
||||||
expect(logs, <String>['downT', 'upT']);
|
expect(logs, <String>['downT', 'upT']);
|
||||||
logs.clear();
|
logs.clear();
|
||||||
|
|
||||||
@ -1111,7 +1090,7 @@ void main() {
|
|||||||
logs.clear();
|
logs.clear();
|
||||||
|
|
||||||
tester.route(pointer2.up());
|
tester.route(pointer2.up());
|
||||||
GestureBinding.instance.gestureArena.sweep(pointer2.pointer);
|
GestureBinding.instance!.gestureArena.sweep(pointer2.pointer);
|
||||||
expect(logs, <String>['endH']);
|
expect(logs, <String>['endH']);
|
||||||
logs.clear();
|
logs.clear();
|
||||||
},
|
},
|
||||||
@ -1167,7 +1146,7 @@ void main() {
|
|||||||
logs.clear();
|
logs.clear();
|
||||||
|
|
||||||
tester.route(pointer2.up());
|
tester.route(pointer2.up());
|
||||||
GestureBinding.instance.gestureArena.sweep(pointer2.pointer);
|
GestureBinding.instance!.gestureArena.sweep(pointer2.pointer);
|
||||||
expect(logs, <String>['endH']);
|
expect(logs, <String>['endH']);
|
||||||
logs.clear();
|
logs.clear();
|
||||||
},
|
},
|
||||||
|
@ -2,8 +2,6 @@
|
|||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
// @dart = 2.8
|
|
||||||
|
|
||||||
import 'package:flutter/widgets.dart';
|
import 'package:flutter/widgets.dart';
|
||||||
import 'package:flutter_test/flutter_test.dart';
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
import 'package:flutter/gestures.dart';
|
import 'package:flutter/gestures.dart';
|
||||||
@ -801,10 +799,10 @@ void main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void _expectTransformedEvent({
|
void _expectTransformedEvent({
|
||||||
@required PointerEvent original,
|
required PointerEvent original,
|
||||||
@required Matrix4 transform,
|
required Matrix4 transform,
|
||||||
Offset localDelta,
|
Offset? localDelta,
|
||||||
Offset localPosition,
|
Offset? localPosition,
|
||||||
}) {
|
}) {
|
||||||
expect(original.position, original.localPosition);
|
expect(original.position, original.localPosition);
|
||||||
expect(original.delta, original.localDelta);
|
expect(original.delta, original.localDelta);
|
||||||
|
@ -2,8 +2,6 @@
|
|||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
// @dart = 2.8
|
|
||||||
|
|
||||||
import 'package:flutter_test/flutter_test.dart';
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
import 'package:flutter/gestures.dart';
|
import 'package:flutter/gestures.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
@ -28,7 +26,7 @@ void main() {
|
|||||||
int updated = 0;
|
int updated = 0;
|
||||||
int ended = 0;
|
int ended = 0;
|
||||||
|
|
||||||
Offset startGlobalPosition;
|
Offset? startGlobalPosition;
|
||||||
|
|
||||||
void onStart(ForcePressDetails details) {
|
void onStart(ForcePressDetails details) {
|
||||||
startGlobalPosition = details.globalPosition;
|
startGlobalPosition = details.globalPosition;
|
||||||
@ -411,7 +409,7 @@ void main() {
|
|||||||
int updated = 0;
|
int updated = 0;
|
||||||
int ended = 0;
|
int ended = 0;
|
||||||
|
|
||||||
Offset startGlobalPosition;
|
Offset? startGlobalPosition;
|
||||||
|
|
||||||
void onStart(ForcePressDetails details) {
|
void onStart(ForcePressDetails details) {
|
||||||
startGlobalPosition = details.globalPosition;
|
startGlobalPosition = details.globalPosition;
|
||||||
|
@ -2,8 +2,6 @@
|
|||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
// @dart = 2.8
|
|
||||||
|
|
||||||
import 'dart:ui' as ui;
|
import 'dart:ui' as ui;
|
||||||
|
|
||||||
import 'package:flutter/foundation.dart';
|
import 'package:flutter/foundation.dart';
|
||||||
@ -15,21 +13,21 @@ import '../flutter_test_alternative.dart';
|
|||||||
typedef HandleEventCallback = void Function(PointerEvent event);
|
typedef HandleEventCallback = void Function(PointerEvent event);
|
||||||
|
|
||||||
class TestGestureFlutterBinding extends BindingBase with GestureBinding, SchedulerBinding {
|
class TestGestureFlutterBinding extends BindingBase with GestureBinding, SchedulerBinding {
|
||||||
HandleEventCallback callback;
|
HandleEventCallback? callback;
|
||||||
FrameCallback frameCallback;
|
FrameCallback? frameCallback;
|
||||||
Duration frameTime;
|
Duration? frameTime;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void handleEvent(PointerEvent event, HitTestEntry entry) {
|
void handleEvent(PointerEvent event, HitTestEntry entry) {
|
||||||
super.handleEvent(event, entry);
|
super.handleEvent(event, entry);
|
||||||
if (callback != null)
|
if (callback != null)
|
||||||
callback(event);
|
callback?.call(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Duration get currentSystemFrameTimeStamp {
|
Duration get currentSystemFrameTimeStamp {
|
||||||
assert(frameTime != null);
|
assert(frameTime != null);
|
||||||
return frameTime;
|
return frameTime!;
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -39,7 +37,7 @@ class TestGestureFlutterBinding extends BindingBase with GestureBinding, Schedul
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
TestGestureFlutterBinding _binding = TestGestureFlutterBinding();
|
TestGestureFlutterBinding? _binding;
|
||||||
|
|
||||||
void ensureTestGestureBinding() {
|
void ensureTestGestureBinding() {
|
||||||
_binding ??= TestGestureFlutterBinding();
|
_binding ??= TestGestureFlutterBinding();
|
||||||
@ -59,9 +57,9 @@ void main() {
|
|||||||
);
|
);
|
||||||
|
|
||||||
final List<PointerEvent> events = <PointerEvent>[];
|
final List<PointerEvent> events = <PointerEvent>[];
|
||||||
_binding.callback = events.add;
|
_binding!.callback = events.add;
|
||||||
|
|
||||||
ui.window.onPointerDataPacket(packet);
|
ui.window.onPointerDataPacket?.call(packet);
|
||||||
expect(events.length, 2);
|
expect(events.length, 2);
|
||||||
expect(events[0], isA<PointerDownEvent>());
|
expect(events[0], isA<PointerDownEvent>());
|
||||||
expect(events[1], isA<PointerUpEvent>());
|
expect(events[1], isA<PointerUpEvent>());
|
||||||
@ -77,9 +75,9 @@ void main() {
|
|||||||
);
|
);
|
||||||
|
|
||||||
final List<PointerEvent> events = <PointerEvent>[];
|
final List<PointerEvent> events = <PointerEvent>[];
|
||||||
_binding.callback = events.add;
|
_binding!.callback = events.add;
|
||||||
|
|
||||||
ui.window.onPointerDataPacket(packet);
|
ui.window.onPointerDataPacket?.call(packet);
|
||||||
expect(events.length, 3);
|
expect(events.length, 3);
|
||||||
expect(events[0], isA<PointerDownEvent>());
|
expect(events[0], isA<PointerDownEvent>());
|
||||||
expect(events[1], isA<PointerMoveEvent>());
|
expect(events[1], isA<PointerMoveEvent>());
|
||||||
@ -99,12 +97,12 @@ void main() {
|
|||||||
);
|
);
|
||||||
|
|
||||||
final List<PointerEvent> pointerRouterEvents = <PointerEvent>[];
|
final List<PointerEvent> pointerRouterEvents = <PointerEvent>[];
|
||||||
GestureBinding.instance.pointerRouter.addGlobalRoute(pointerRouterEvents.add);
|
GestureBinding.instance!.pointerRouter.addGlobalRoute(pointerRouterEvents.add);
|
||||||
|
|
||||||
final List<PointerEvent> events = <PointerEvent>[];
|
final List<PointerEvent> events = <PointerEvent>[];
|
||||||
_binding.callback = events.add;
|
_binding!.callback = events.add;
|
||||||
|
|
||||||
ui.window.onPointerDataPacket(packet);
|
ui.window.onPointerDataPacket?.call(packet);
|
||||||
expect(events.length, 3);
|
expect(events.length, 3);
|
||||||
expect(events[0], isA<PointerHoverEvent>());
|
expect(events[0], isA<PointerHoverEvent>());
|
||||||
expect(events[1], isA<PointerHoverEvent>());
|
expect(events[1], isA<PointerHoverEvent>());
|
||||||
@ -128,9 +126,9 @@ void main() {
|
|||||||
);
|
);
|
||||||
|
|
||||||
final List<PointerEvent> events = <PointerEvent>[];
|
final List<PointerEvent> events = <PointerEvent>[];
|
||||||
_binding.callback = events.add;
|
_binding!.callback = events.add;
|
||||||
|
|
||||||
ui.window.onPointerDataPacket(packet);
|
ui.window.onPointerDataPacket?.call(packet);
|
||||||
expect(events.length, 2);
|
expect(events.length, 2);
|
||||||
expect(events[0], isA<PointerDownEvent>());
|
expect(events[0], isA<PointerDownEvent>());
|
||||||
expect(events[1], isA<PointerCancelEvent>());
|
expect(events[1], isA<PointerCancelEvent>());
|
||||||
@ -145,13 +143,13 @@ void main() {
|
|||||||
);
|
);
|
||||||
|
|
||||||
final List<PointerEvent> events = <PointerEvent>[];
|
final List<PointerEvent> events = <PointerEvent>[];
|
||||||
_binding.callback = (PointerEvent event) {
|
_binding!.callback = (PointerEvent event) {
|
||||||
events.add(event);
|
events.add(event);
|
||||||
if (event is PointerDownEvent)
|
if (event is PointerDownEvent)
|
||||||
_binding.cancelPointer(event.pointer);
|
_binding!.cancelPointer(event.pointer);
|
||||||
};
|
};
|
||||||
|
|
||||||
ui.window.onPointerDataPacket(packet);
|
ui.window.onPointerDataPacket?.call(packet);
|
||||||
expect(events.length, 2);
|
expect(events.length, 2);
|
||||||
expect(events[0], isA<PointerDownEvent>());
|
expect(events[0], isA<PointerDownEvent>());
|
||||||
expect(events[1], isA<PointerCancelEvent>());
|
expect(events[1], isA<PointerCancelEvent>());
|
||||||
|
@ -2,8 +2,6 @@
|
|||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
// @dart = 2.8
|
|
||||||
|
|
||||||
import 'package:flutter/foundation.dart';
|
import 'package:flutter/foundation.dart';
|
||||||
import 'package:flutter/gestures.dart';
|
import 'package:flutter/gestures.dart';
|
||||||
import 'package:meta/meta.dart';
|
import 'package:meta/meta.dart';
|
||||||
@ -25,11 +23,11 @@ class GestureTester {
|
|||||||
final FakeAsync async;
|
final FakeAsync async;
|
||||||
|
|
||||||
void closeArena(int pointer) {
|
void closeArena(int pointer) {
|
||||||
GestureBinding.instance.gestureArena.close(pointer);
|
GestureBinding.instance!.gestureArena.close(pointer);
|
||||||
}
|
}
|
||||||
|
|
||||||
void route(PointerEvent event) {
|
void route(PointerEvent event) {
|
||||||
GestureBinding.instance.pointerRouter.route(event);
|
GestureBinding.instance!.pointerRouter.route(event);
|
||||||
async.flushMicrotasks();
|
async.flushMicrotasks();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,8 +2,6 @@
|
|||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
// @dart = 2.8
|
|
||||||
|
|
||||||
import 'package:flutter/gestures.dart';
|
import 'package:flutter/gestures.dart';
|
||||||
import 'package:vector_math/vector_math_64.dart';
|
import 'package:vector_math/vector_math_64.dart';
|
||||||
|
|
||||||
@ -38,7 +36,7 @@ void main() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('HitTestResult should correctly push and pop transforms', () {
|
test('HitTestResult should correctly push and pop transforms', () {
|
||||||
Matrix4 currentTransform(HitTestResult targetResult) {
|
Matrix4? currentTransform(HitTestResult targetResult) {
|
||||||
final HitTestEntry entry = HitTestEntry(_DummyHitTestTarget());
|
final HitTestEntry entry = HitTestEntry(_DummyHitTestTarget());
|
||||||
targetResult.add(entry);
|
targetResult.add(entry);
|
||||||
return entry.transform;
|
return entry.transform;
|
||||||
@ -78,7 +76,7 @@ void main() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('HitTestResult should correctly push and pop offsets', () {
|
test('HitTestResult should correctly push and pop offsets', () {
|
||||||
Matrix4 currentTransform(HitTestResult targetResult) {
|
Matrix4? currentTransform(HitTestResult targetResult) {
|
||||||
final HitTestEntry entry = HitTestEntry(_DummyHitTestTarget());
|
final HitTestEntry entry = HitTestEntry(_DummyHitTestTarget());
|
||||||
targetResult.add(entry);
|
targetResult.add(entry);
|
||||||
return entry.transform;
|
return entry.transform;
|
||||||
|
@ -2,8 +2,6 @@
|
|||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
// @dart = 2.8
|
|
||||||
|
|
||||||
import 'dart:ui' as ui;
|
import 'dart:ui' as ui;
|
||||||
|
|
||||||
import 'package:flutter/foundation.dart';
|
import 'package:flutter/foundation.dart';
|
||||||
@ -14,12 +12,12 @@ import '../flutter_test_alternative.dart';
|
|||||||
typedef HandleEventCallback = void Function(PointerEvent event);
|
typedef HandleEventCallback = void Function(PointerEvent event);
|
||||||
|
|
||||||
class TestGestureFlutterBinding extends BindingBase with GestureBinding {
|
class TestGestureFlutterBinding extends BindingBase with GestureBinding {
|
||||||
HandleEventCallback callback;
|
HandleEventCallback? callback;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void handleEvent(PointerEvent event, HitTestEntry entry) {
|
void handleEvent(PointerEvent event, HitTestEntry entry) {
|
||||||
if (callback != null)
|
if (callback != null)
|
||||||
callback(event);
|
callback?.call(event);
|
||||||
super.handleEvent(event, entry);
|
super.handleEvent(event, entry);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -33,21 +31,17 @@ class TestGestureFlutterBinding extends BindingBase with GestureBinding {
|
|||||||
Future<void> test(VoidCallback callback) {
|
Future<void> test(VoidCallback callback) {
|
||||||
assert(callback != null);
|
assert(callback != null);
|
||||||
return _binding.lockEvents(() async {
|
return _binding.lockEvents(() async {
|
||||||
ui.window.onPointerDataPacket(packet);
|
ui.window.onPointerDataPacket?.call(packet);
|
||||||
callback();
|
callback();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
TestGestureFlutterBinding _binding = TestGestureFlutterBinding();
|
late TestGestureFlutterBinding _binding;
|
||||||
|
|
||||||
void ensureTestGestureBinding() {
|
|
||||||
_binding ??= TestGestureFlutterBinding();
|
|
||||||
assert(GestureBinding.instance != null);
|
|
||||||
}
|
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
setUp(ensureTestGestureBinding);
|
_binding = TestGestureFlutterBinding();
|
||||||
|
assert(GestureBinding.instance != null);
|
||||||
|
|
||||||
test('Pointer events are locked during reassemble', () async {
|
test('Pointer events are locked during reassemble', () async {
|
||||||
final List<PointerEvent> events = <PointerEvent>[];
|
final List<PointerEvent> events = <PointerEvent>[];
|
||||||
|
@ -2,8 +2,6 @@
|
|||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
// @dart = 2.8
|
|
||||||
|
|
||||||
import 'package:flutter/gestures.dart';
|
import 'package:flutter/gestures.dart';
|
||||||
|
|
||||||
import '../flutter_test_alternative.dart';
|
import '../flutter_test_alternative.dart';
|
||||||
@ -64,9 +62,9 @@ void main() {
|
|||||||
setUp(ensureGestureBinding);
|
setUp(ensureGestureBinding);
|
||||||
|
|
||||||
group('Long press', () {
|
group('Long press', () {
|
||||||
LongPressGestureRecognizer longPress;
|
late LongPressGestureRecognizer longPress;
|
||||||
bool longPressDown;
|
late bool longPressDown;
|
||||||
bool longPressUp;
|
late bool longPressUp;
|
||||||
|
|
||||||
setUp(() {
|
setUp(() {
|
||||||
longPress = LongPressGestureRecognizer();
|
longPress = LongPressGestureRecognizer();
|
||||||
@ -293,10 +291,10 @@ void main() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
group('long press drag', () {
|
group('long press drag', () {
|
||||||
LongPressGestureRecognizer longPressDrag;
|
late LongPressGestureRecognizer longPressDrag;
|
||||||
bool longPressStart;
|
late bool longPressStart;
|
||||||
bool longPressUp;
|
late bool longPressUp;
|
||||||
Offset longPressDragUpdate;
|
Offset? longPressDragUpdate;
|
||||||
|
|
||||||
setUp(() {
|
setUp(() {
|
||||||
longPressDrag = LongPressGestureRecognizer();
|
longPressDrag = LongPressGestureRecognizer();
|
||||||
@ -392,7 +390,7 @@ void main() {
|
|||||||
|
|
||||||
final List<String> recognized = <String>[];
|
final List<String> recognized = <String>[];
|
||||||
|
|
||||||
LongPressGestureRecognizer longPress;
|
late LongPressGestureRecognizer longPress;
|
||||||
|
|
||||||
setUp(() {
|
setUp(() {
|
||||||
longPress = LongPressGestureRecognizer()
|
longPress = LongPressGestureRecognizer()
|
||||||
@ -532,9 +530,9 @@ void main() {
|
|||||||
// competition with a tap gesture recognizer listening on a different button.
|
// competition with a tap gesture recognizer listening on a different button.
|
||||||
|
|
||||||
final List<String> recognized = <String>[];
|
final List<String> recognized = <String>[];
|
||||||
TapGestureRecognizer tapPrimary;
|
late TapGestureRecognizer tapPrimary;
|
||||||
TapGestureRecognizer tapSecondary;
|
late TapGestureRecognizer tapSecondary;
|
||||||
LongPressGestureRecognizer longPress;
|
late LongPressGestureRecognizer longPress;
|
||||||
setUp(() {
|
setUp(() {
|
||||||
tapPrimary = TapGestureRecognizer()
|
tapPrimary = TapGestureRecognizer()
|
||||||
..onTapDown = (TapDownDetails details) {
|
..onTapDown = (TapDownDetails details) {
|
||||||
|
@ -2,8 +2,6 @@
|
|||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
// @dart = 2.8
|
|
||||||
|
|
||||||
import 'package:flutter/gestures.dart';
|
import 'package:flutter/gestures.dart';
|
||||||
|
|
||||||
import '../flutter_test_alternative.dart';
|
import '../flutter_test_alternative.dart';
|
||||||
@ -20,7 +18,7 @@ void main() {
|
|||||||
final List<double> w = <double>[1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0];
|
final List<double> w = <double>[1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0];
|
||||||
|
|
||||||
final LeastSquaresSolver solver = LeastSquaresSolver(x, y, w);
|
final LeastSquaresSolver solver = LeastSquaresSolver(x, y, w);
|
||||||
final PolynomialFit fit = solver.solve(1);
|
final PolynomialFit fit = solver.solve(1)!;
|
||||||
|
|
||||||
expect(fit.coefficients.length, 2);
|
expect(fit.coefficients.length, 2);
|
||||||
expect(approx(fit.coefficients[0], 1.0), isTrue);
|
expect(approx(fit.coefficients[0], 1.0), isTrue);
|
||||||
@ -34,7 +32,7 @@ void main() {
|
|||||||
final List<double> w = <double>[1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0];
|
final List<double> w = <double>[1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0];
|
||||||
|
|
||||||
final LeastSquaresSolver solver = LeastSquaresSolver(x, y, w);
|
final LeastSquaresSolver solver = LeastSquaresSolver(x, y, w);
|
||||||
final PolynomialFit fit = solver.solve(1);
|
final PolynomialFit fit = solver.solve(1)!;
|
||||||
|
|
||||||
expect(fit.coefficients.length, 2);
|
expect(fit.coefficients.length, 2);
|
||||||
expect(approx(fit.coefficients[0], 1.0), isTrue);
|
expect(approx(fit.coefficients[0], 1.0), isTrue);
|
||||||
@ -48,7 +46,7 @@ void main() {
|
|||||||
final List<double> w = <double>[1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0];
|
final List<double> w = <double>[1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0];
|
||||||
|
|
||||||
final LeastSquaresSolver solver = LeastSquaresSolver(x, y, w);
|
final LeastSquaresSolver solver = LeastSquaresSolver(x, y, w);
|
||||||
final PolynomialFit fit = solver.solve(2);
|
final PolynomialFit fit = solver.solve(2)!;
|
||||||
|
|
||||||
expect(fit.coefficients.length, 3);
|
expect(fit.coefficients.length, 3);
|
||||||
expect(approx(fit.coefficients[0], 1.0), isTrue);
|
expect(approx(fit.coefficients[0], 1.0), isTrue);
|
||||||
@ -63,7 +61,7 @@ void main() {
|
|||||||
final List<double> w = <double>[1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0];
|
final List<double> w = <double>[1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0];
|
||||||
|
|
||||||
final LeastSquaresSolver solver = LeastSquaresSolver(x, y, w);
|
final LeastSquaresSolver solver = LeastSquaresSolver(x, y, w);
|
||||||
final PolynomialFit fit = solver.solve(2);
|
final PolynomialFit fit = solver.solve(2)!;
|
||||||
|
|
||||||
expect(fit.coefficients.length, 3);
|
expect(fit.coefficients.length, 3);
|
||||||
expect(approx(fit.coefficients[0], 1.0), isTrue);
|
expect(approx(fit.coefficients[0], 1.0), isTrue);
|
||||||
|
@ -2,8 +2,6 @@
|
|||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
// @dart = 2.8
|
|
||||||
|
|
||||||
import 'package:flutter_test/flutter_test.dart';
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
import 'package:flutter/gestures.dart';
|
import 'package:flutter/gestures.dart';
|
||||||
|
|
||||||
|
@ -2,8 +2,6 @@
|
|||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
// @dart = 2.8
|
|
||||||
|
|
||||||
import 'package:flutter_test/flutter_test.dart';
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
import 'package:flutter/gestures.dart';
|
import 'package:flutter/gestures.dart';
|
||||||
|
|
||||||
|
@ -2,8 +2,6 @@
|
|||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
// @dart = 2.8
|
|
||||||
|
|
||||||
import 'package:flutter_test/flutter_test.dart';
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
import 'package:flutter/foundation.dart';
|
import 'package:flutter/foundation.dart';
|
||||||
import 'package:flutter/gestures.dart';
|
import 'package:flutter/gestures.dart';
|
||||||
@ -136,7 +134,7 @@ void main() {
|
|||||||
log.add('per-pointer 3');
|
log.add('per-pointer 3');
|
||||||
});
|
});
|
||||||
|
|
||||||
final FlutterExceptionHandler previousErrorHandler = FlutterError.onError;
|
final FlutterExceptionHandler? previousErrorHandler = FlutterError.onError;
|
||||||
FlutterError.onError = (FlutterErrorDetails details) {
|
FlutterError.onError = (FlutterErrorDetails details) {
|
||||||
log.add('error report');
|
log.add('error report');
|
||||||
};
|
};
|
||||||
|
@ -2,8 +2,6 @@
|
|||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
// @dart = 2.8
|
|
||||||
|
|
||||||
import 'package:flutter/gestures.dart';
|
import 'package:flutter/gestures.dart';
|
||||||
import 'package:vector_math/vector_math_64.dart';
|
import 'package:vector_math/vector_math_64.dart';
|
||||||
|
|
||||||
|
@ -2,13 +2,11 @@
|
|||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
// @dart = 2.8
|
|
||||||
|
|
||||||
import 'package:flutter_test/flutter_test.dart';
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
import 'package:flutter/gestures.dart';
|
import 'package:flutter/gestures.dart';
|
||||||
|
|
||||||
class TestGestureRecognizer extends GestureRecognizer {
|
class TestGestureRecognizer extends GestureRecognizer {
|
||||||
TestGestureRecognizer({ Object debugOwner }) : super(debugOwner: debugOwner);
|
TestGestureRecognizer({ Object? debugOwner }) : super(debugOwner: debugOwner);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String get debugDescription => 'debugDescription content';
|
String get debugDescription => 'debugDescription content';
|
||||||
|
@ -2,8 +2,6 @@
|
|||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
// @dart = 2.8
|
|
||||||
|
|
||||||
import 'dart:math' as math;
|
import 'dart:math' as math;
|
||||||
|
|
||||||
import 'package:flutter_test/flutter_test.dart';
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
@ -19,15 +17,15 @@ void main() {
|
|||||||
final TapGestureRecognizer tap = TapGestureRecognizer();
|
final TapGestureRecognizer tap = TapGestureRecognizer();
|
||||||
|
|
||||||
bool didStartScale = false;
|
bool didStartScale = false;
|
||||||
Offset updatedFocalPoint;
|
Offset? updatedFocalPoint;
|
||||||
scale.onStart = (ScaleStartDetails details) {
|
scale.onStart = (ScaleStartDetails details) {
|
||||||
didStartScale = true;
|
didStartScale = true;
|
||||||
updatedFocalPoint = details.focalPoint;
|
updatedFocalPoint = details.focalPoint;
|
||||||
};
|
};
|
||||||
|
|
||||||
double updatedScale;
|
double? updatedScale;
|
||||||
double updatedHorizontalScale;
|
double? updatedHorizontalScale;
|
||||||
double updatedVerticalScale;
|
double? updatedVerticalScale;
|
||||||
scale.onUpdate = (ScaleUpdateDetails details) {
|
scale.onUpdate = (ScaleUpdateDetails details) {
|
||||||
updatedScale = details.scale;
|
updatedScale = details.scale;
|
||||||
updatedHorizontalScale = details.horizontalScale;
|
updatedHorizontalScale = details.horizontalScale;
|
||||||
@ -230,7 +228,7 @@ void main() {
|
|||||||
didStartScale = true;
|
didStartScale = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
double updatedScale;
|
double? updatedScale;
|
||||||
scale.onUpdate = (ScaleUpdateDetails details) {
|
scale.onUpdate = (ScaleUpdateDetails details) {
|
||||||
updatedScale = details.scale;
|
updatedScale = details.scale;
|
||||||
};
|
};
|
||||||
@ -258,13 +256,13 @@ void main() {
|
|||||||
final ScaleGestureRecognizer scale = ScaleGestureRecognizer(kind: PointerDeviceKind.touch);
|
final ScaleGestureRecognizer scale = ScaleGestureRecognizer(kind: PointerDeviceKind.touch);
|
||||||
|
|
||||||
bool didStartScale = false;
|
bool didStartScale = false;
|
||||||
Offset updatedFocalPoint;
|
Offset? updatedFocalPoint;
|
||||||
scale.onStart = (ScaleStartDetails details) {
|
scale.onStart = (ScaleStartDetails details) {
|
||||||
didStartScale = true;
|
didStartScale = true;
|
||||||
updatedFocalPoint = details.focalPoint;
|
updatedFocalPoint = details.focalPoint;
|
||||||
};
|
};
|
||||||
|
|
||||||
double updatedScale;
|
double? updatedScale;
|
||||||
scale.onUpdate = (ScaleUpdateDetails details) {
|
scale.onUpdate = (ScaleUpdateDetails details) {
|
||||||
updatedScale = details.scale;
|
updatedScale = details.scale;
|
||||||
updatedFocalPoint = details.focalPoint;
|
updatedFocalPoint = details.focalPoint;
|
||||||
@ -404,13 +402,13 @@ void main() {
|
|||||||
final TapGestureRecognizer tap = TapGestureRecognizer();
|
final TapGestureRecognizer tap = TapGestureRecognizer();
|
||||||
|
|
||||||
bool didStartScale = false;
|
bool didStartScale = false;
|
||||||
Offset updatedFocalPoint;
|
Offset? updatedFocalPoint;
|
||||||
scale.onStart = (ScaleStartDetails details) {
|
scale.onStart = (ScaleStartDetails details) {
|
||||||
didStartScale = true;
|
didStartScale = true;
|
||||||
updatedFocalPoint = details.focalPoint;
|
updatedFocalPoint = details.focalPoint;
|
||||||
};
|
};
|
||||||
|
|
||||||
double updatedRotation;
|
double? updatedRotation;
|
||||||
scale.onUpdate = (ScaleUpdateDetails details) {
|
scale.onUpdate = (ScaleUpdateDetails details) {
|
||||||
updatedRotation = details.rotation;
|
updatedRotation = details.rotation;
|
||||||
updatedFocalPoint = details.focalPoint;
|
updatedFocalPoint = details.focalPoint;
|
||||||
|
@ -2,8 +2,6 @@
|
|||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
// @dart = 2.8
|
|
||||||
|
|
||||||
import 'package:flutter/foundation.dart';
|
import 'package:flutter/foundation.dart';
|
||||||
import 'package:flutter/gestures.dart';
|
import 'package:flutter/gestures.dart';
|
||||||
import 'package:flutter_test/flutter_test.dart';
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
@ -115,7 +113,7 @@ void main() {
|
|||||||
|
|
||||||
tester.route(up1);
|
tester.route(up1);
|
||||||
expect(tapRecognized, isTrue);
|
expect(tapRecognized, isTrue);
|
||||||
GestureBinding.instance.gestureArena.sweep(1);
|
GestureBinding.instance!.gestureArena.sweep(1);
|
||||||
expect(tapRecognized, isTrue);
|
expect(tapRecognized, isTrue);
|
||||||
|
|
||||||
tap.dispose();
|
tap.dispose();
|
||||||
@ -124,8 +122,8 @@ void main() {
|
|||||||
testGesture('Details contain the correct device kind', (GestureTester tester) {
|
testGesture('Details contain the correct device kind', (GestureTester tester) {
|
||||||
final TapGestureRecognizer tap = TapGestureRecognizer();
|
final TapGestureRecognizer tap = TapGestureRecognizer();
|
||||||
|
|
||||||
TapDownDetails lastDownDetails;
|
TapDownDetails? lastDownDetails;
|
||||||
TapUpDetails lastUpDetails;
|
TapUpDetails? lastUpDetails;
|
||||||
|
|
||||||
tap.onTapDown = (TapDownDetails details) {
|
tap.onTapDown = (TapDownDetails details) {
|
||||||
lastDownDetails = details;
|
lastDownDetails = details;
|
||||||
@ -142,10 +140,10 @@ void main() {
|
|||||||
tap.addPointer(mouseDown);
|
tap.addPointer(mouseDown);
|
||||||
tester.closeArena(1);
|
tester.closeArena(1);
|
||||||
tester.route(mouseDown);
|
tester.route(mouseDown);
|
||||||
expect(lastDownDetails.kind, PointerDeviceKind.mouse);
|
expect(lastDownDetails?.kind, PointerDeviceKind.mouse);
|
||||||
|
|
||||||
tester.route(mouseUp);
|
tester.route(mouseUp);
|
||||||
expect(lastUpDetails.kind, PointerDeviceKind.mouse);
|
expect(lastUpDetails?.kind, PointerDeviceKind.mouse);
|
||||||
|
|
||||||
tap.dispose();
|
tap.dispose();
|
||||||
});
|
});
|
||||||
@ -166,7 +164,7 @@ void main() {
|
|||||||
|
|
||||||
tester.route(up1);
|
tester.route(up1);
|
||||||
expect(tapsRecognized, 1);
|
expect(tapsRecognized, 1);
|
||||||
GestureBinding.instance.gestureArena.sweep(1);
|
GestureBinding.instance!.gestureArena.sweep(1);
|
||||||
expect(tapsRecognized, 1);
|
expect(tapsRecognized, 1);
|
||||||
|
|
||||||
tap.addPointer(down1);
|
tap.addPointer(down1);
|
||||||
@ -177,7 +175,7 @@ void main() {
|
|||||||
|
|
||||||
tester.route(up1);
|
tester.route(up1);
|
||||||
expect(tapsRecognized, 2);
|
expect(tapsRecognized, 2);
|
||||||
GestureBinding.instance.gestureArena.sweep(1);
|
GestureBinding.instance!.gestureArena.sweep(1);
|
||||||
expect(tapsRecognized, 2);
|
expect(tapsRecognized, 2);
|
||||||
|
|
||||||
tap.dispose();
|
tap.dispose();
|
||||||
@ -206,12 +204,12 @@ void main() {
|
|||||||
|
|
||||||
tester.route(up1);
|
tester.route(up1);
|
||||||
expect(tapsRecognized, 1);
|
expect(tapsRecognized, 1);
|
||||||
GestureBinding.instance.gestureArena.sweep(1);
|
GestureBinding.instance!.gestureArena.sweep(1);
|
||||||
expect(tapsRecognized, 1);
|
expect(tapsRecognized, 1);
|
||||||
|
|
||||||
tester.route(up2);
|
tester.route(up2);
|
||||||
expect(tapsRecognized, 1);
|
expect(tapsRecognized, 1);
|
||||||
GestureBinding.instance.gestureArena.sweep(2);
|
GestureBinding.instance!.gestureArena.sweep(2);
|
||||||
expect(tapsRecognized, 1);
|
expect(tapsRecognized, 1);
|
||||||
|
|
||||||
tap.dispose();
|
tap.dispose();
|
||||||
@ -240,12 +238,12 @@ void main() {
|
|||||||
|
|
||||||
tester.route(up2);
|
tester.route(up2);
|
||||||
expect(tapsRecognized, 0);
|
expect(tapsRecognized, 0);
|
||||||
GestureBinding.instance.gestureArena.sweep(2);
|
GestureBinding.instance!.gestureArena.sweep(2);
|
||||||
expect(tapsRecognized, 0);
|
expect(tapsRecognized, 0);
|
||||||
|
|
||||||
tester.route(up1);
|
tester.route(up1);
|
||||||
expect(tapsRecognized, 1);
|
expect(tapsRecognized, 1);
|
||||||
GestureBinding.instance.gestureArena.sweep(1);
|
GestureBinding.instance!.gestureArena.sweep(1);
|
||||||
expect(tapsRecognized, 1);
|
expect(tapsRecognized, 1);
|
||||||
|
|
||||||
tap.dispose();
|
tap.dispose();
|
||||||
@ -277,7 +275,7 @@ void main() {
|
|||||||
tester.route(up3);
|
tester.route(up3);
|
||||||
expect(tapRecognized, isFalse);
|
expect(tapRecognized, isFalse);
|
||||||
expect(tapCanceled, isTrue);
|
expect(tapCanceled, isTrue);
|
||||||
GestureBinding.instance.gestureArena.sweep(3);
|
GestureBinding.instance!.gestureArena.sweep(3);
|
||||||
expect(tapRecognized, isFalse);
|
expect(tapRecognized, isFalse);
|
||||||
expect(tapCanceled, isTrue);
|
expect(tapCanceled, isTrue);
|
||||||
|
|
||||||
@ -310,7 +308,7 @@ void main() {
|
|||||||
tester.route(up4);
|
tester.route(up4);
|
||||||
expect(tapRecognized, isTrue);
|
expect(tapRecognized, isTrue);
|
||||||
expect(tapCanceled, isFalse);
|
expect(tapCanceled, isFalse);
|
||||||
GestureBinding.instance.gestureArena.sweep(4);
|
GestureBinding.instance!.gestureArena.sweep(4);
|
||||||
expect(tapRecognized, isTrue);
|
expect(tapRecognized, isTrue);
|
||||||
expect(tapCanceled, isFalse);
|
expect(tapCanceled, isFalse);
|
||||||
|
|
||||||
@ -335,7 +333,7 @@ void main() {
|
|||||||
expect(tapRecognized, isFalse);
|
expect(tapRecognized, isFalse);
|
||||||
tester.route(up1);
|
tester.route(up1);
|
||||||
expect(tapRecognized, isTrue);
|
expect(tapRecognized, isTrue);
|
||||||
GestureBinding.instance.gestureArena.sweep(1);
|
GestureBinding.instance!.gestureArena.sweep(1);
|
||||||
expect(tapRecognized, isTrue);
|
expect(tapRecognized, isTrue);
|
||||||
|
|
||||||
tap.dispose();
|
tap.dispose();
|
||||||
@ -351,8 +349,8 @@ void main() {
|
|||||||
|
|
||||||
tap.addPointer(down1);
|
tap.addPointer(down1);
|
||||||
final TestGestureArenaMember member = TestGestureArenaMember();
|
final TestGestureArenaMember member = TestGestureArenaMember();
|
||||||
final GestureArenaEntry entry = GestureBinding.instance.gestureArena.add(1, member);
|
final GestureArenaEntry entry = GestureBinding.instance!.gestureArena.add(1, member);
|
||||||
GestureBinding.instance.gestureArena.hold(1);
|
GestureBinding.instance!.gestureArena.hold(1);
|
||||||
tester.closeArena(1);
|
tester.closeArena(1);
|
||||||
expect(tapRecognized, isFalse);
|
expect(tapRecognized, isFalse);
|
||||||
tester.route(down1);
|
tester.route(down1);
|
||||||
@ -360,7 +358,7 @@ void main() {
|
|||||||
|
|
||||||
tester.route(up1);
|
tester.route(up1);
|
||||||
expect(tapRecognized, isFalse);
|
expect(tapRecognized, isFalse);
|
||||||
GestureBinding.instance.gestureArena.sweep(1);
|
GestureBinding.instance!.gestureArena.sweep(1);
|
||||||
expect(tapRecognized, isFalse);
|
expect(tapRecognized, isFalse);
|
||||||
|
|
||||||
entry.resolve(GestureDisposition.accepted);
|
entry.resolve(GestureDisposition.accepted);
|
||||||
@ -379,8 +377,8 @@ void main() {
|
|||||||
|
|
||||||
tap.addPointer(down1);
|
tap.addPointer(down1);
|
||||||
final TestGestureArenaMember member = TestGestureArenaMember();
|
final TestGestureArenaMember member = TestGestureArenaMember();
|
||||||
final GestureArenaEntry entry = GestureBinding.instance.gestureArena.add(1, member);
|
final GestureArenaEntry entry = GestureBinding.instance!.gestureArena.add(1, member);
|
||||||
GestureBinding.instance.gestureArena.hold(1);
|
GestureBinding.instance!.gestureArena.hold(1);
|
||||||
tester.closeArena(1);
|
tester.closeArena(1);
|
||||||
expect(tapRecognized, isFalse);
|
expect(tapRecognized, isFalse);
|
||||||
tester.route(down1);
|
tester.route(down1);
|
||||||
@ -388,7 +386,7 @@ void main() {
|
|||||||
|
|
||||||
tester.route(up1);
|
tester.route(up1);
|
||||||
expect(tapRecognized, isFalse);
|
expect(tapRecognized, isFalse);
|
||||||
GestureBinding.instance.gestureArena.sweep(1);
|
GestureBinding.instance!.gestureArena.sweep(1);
|
||||||
expect(tapRecognized, isFalse);
|
expect(tapRecognized, isFalse);
|
||||||
|
|
||||||
entry.resolve(GestureDisposition.rejected);
|
entry.resolve(GestureDisposition.rejected);
|
||||||
@ -405,7 +403,7 @@ void main() {
|
|||||||
throw Exception(test);
|
throw Exception(test);
|
||||||
};
|
};
|
||||||
|
|
||||||
final FlutterExceptionHandler previousErrorHandler = FlutterError.onError;
|
final FlutterExceptionHandler? previousErrorHandler = FlutterError.onError;
|
||||||
bool gotError = false;
|
bool gotError = false;
|
||||||
FlutterError.onError = (FlutterErrorDetails details) {
|
FlutterError.onError = (FlutterErrorDetails details) {
|
||||||
gotError = true;
|
gotError = true;
|
||||||
@ -430,7 +428,7 @@ void main() {
|
|||||||
throw Exception(test);
|
throw Exception(test);
|
||||||
};
|
};
|
||||||
|
|
||||||
final FlutterExceptionHandler previousErrorHandler = FlutterError.onError;
|
final FlutterExceptionHandler? previousErrorHandler = FlutterError.onError;
|
||||||
bool gotError = false;
|
bool gotError = false;
|
||||||
FlutterError.onError = (FlutterErrorDetails details) {
|
FlutterError.onError = (FlutterErrorDetails details) {
|
||||||
expect(details.toString().contains('"spontaneous onTapCancel"') , isTrue);
|
expect(details.toString().contains('"spontaneous onTapCancel"') , isTrue);
|
||||||
@ -474,7 +472,7 @@ void main() {
|
|||||||
log.add('routed 1 down');
|
log.add('routed 1 down');
|
||||||
tester.route(up1);
|
tester.route(up1);
|
||||||
log.add('routed 1 up');
|
log.add('routed 1 up');
|
||||||
GestureBinding.instance.gestureArena.sweep(1);
|
GestureBinding.instance!.gestureArena.sweep(1);
|
||||||
log.add('swept 1');
|
log.add('swept 1');
|
||||||
tapA.addPointer(down2);
|
tapA.addPointer(down2);
|
||||||
log.add('down 2 to A');
|
log.add('down 2 to A');
|
||||||
@ -486,7 +484,7 @@ void main() {
|
|||||||
log.add('routed 2 down');
|
log.add('routed 2 down');
|
||||||
tester.route(up2);
|
tester.route(up2);
|
||||||
log.add('routed 2 up');
|
log.add('routed 2 up');
|
||||||
GestureBinding.instance.gestureArena.sweep(2);
|
GestureBinding.instance!.gestureArena.sweep(2);
|
||||||
log.add('swept 2');
|
log.add('swept 2');
|
||||||
tapA.dispose();
|
tapA.dispose();
|
||||||
log.add('disposed A');
|
log.add('disposed A');
|
||||||
@ -618,7 +616,7 @@ void main() {
|
|||||||
drag.addPointer(down3);
|
drag.addPointer(down3);
|
||||||
tester.closeArena(3);
|
tester.closeArena(3);
|
||||||
tester.route(move3);
|
tester.route(move3);
|
||||||
GestureBinding.instance.gestureArena.sweep(3);
|
GestureBinding.instance!.gestureArena.sweep(3);
|
||||||
expect(recognized, isEmpty);
|
expect(recognized, isEmpty);
|
||||||
|
|
||||||
tap.dispose();
|
tap.dispose();
|
||||||
@ -655,7 +653,7 @@ void main() {
|
|||||||
expect(recognized, isEmpty);
|
expect(recognized, isEmpty);
|
||||||
|
|
||||||
tester.route(up1);
|
tester.route(up1);
|
||||||
GestureBinding.instance.gestureArena.sweep(down1.pointer);
|
GestureBinding.instance!.gestureArena.sweep(down1.pointer);
|
||||||
expect(recognized, <String>['down', 'up', 'tap']);
|
expect(recognized, <String>['down', 'up', 'tap']);
|
||||||
recognized.clear();
|
recognized.clear();
|
||||||
|
|
||||||
@ -664,7 +662,7 @@ void main() {
|
|||||||
expect(recognized, isEmpty);
|
expect(recognized, isEmpty);
|
||||||
|
|
||||||
tester.route(up2);
|
tester.route(up2);
|
||||||
GestureBinding.instance.gestureArena.sweep(down2.pointer);
|
GestureBinding.instance!.gestureArena.sweep(down2.pointer);
|
||||||
expect(recognized, isEmpty);
|
expect(recognized, isEmpty);
|
||||||
|
|
||||||
tap.dispose();
|
tap.dispose();
|
||||||
@ -684,7 +682,7 @@ void main() {
|
|||||||
);
|
);
|
||||||
|
|
||||||
final List<String> recognized = <String>[];
|
final List<String> recognized = <String>[];
|
||||||
TapGestureRecognizer tap;
|
late TapGestureRecognizer tap;
|
||||||
setUp(() {
|
setUp(() {
|
||||||
tap = TapGestureRecognizer()
|
tap = TapGestureRecognizer()
|
||||||
..onTapDown = (TapDownDetails details) {
|
..onTapDown = (TapDownDetails details) {
|
||||||
@ -765,14 +763,14 @@ void main() {
|
|||||||
tester.route(move1lr);
|
tester.route(move1lr);
|
||||||
tester.route(move1r);
|
tester.route(move1r);
|
||||||
tester.route(up1);
|
tester.route(up1);
|
||||||
GestureBinding.instance.gestureArena.sweep(1);
|
GestureBinding.instance!.gestureArena.sweep(1);
|
||||||
expect(recognized, <String>['down', 'cancel']);
|
expect(recognized, <String>['down', 'cancel']);
|
||||||
|
|
||||||
tap.addPointer(down2);
|
tap.addPointer(down2);
|
||||||
tester.closeArena(2);
|
tester.closeArena(2);
|
||||||
tester.async.elapse(const Duration(milliseconds: 1000));
|
tester.async.elapse(const Duration(milliseconds: 1000));
|
||||||
tester.route(up2);
|
tester.route(up2);
|
||||||
GestureBinding.instance.gestureArena.sweep(2);
|
GestureBinding.instance!.gestureArena.sweep(2);
|
||||||
expect(recognized, <String>['down', 'cancel', 'down', 'up']);
|
expect(recognized, <String>['down', 'cancel', 'down', 'up']);
|
||||||
|
|
||||||
tap.dispose();
|
tap.dispose();
|
||||||
@ -786,10 +784,10 @@ void main() {
|
|||||||
// listening on different buttons do not form competition.
|
// listening on different buttons do not form competition.
|
||||||
|
|
||||||
final List<String> recognized = <String>[];
|
final List<String> recognized = <String>[];
|
||||||
TapGestureRecognizer primary;
|
late TapGestureRecognizer primary;
|
||||||
TapGestureRecognizer primary2;
|
late TapGestureRecognizer primary2;
|
||||||
TapGestureRecognizer secondary;
|
late TapGestureRecognizer secondary;
|
||||||
TapGestureRecognizer tertiary;
|
late TapGestureRecognizer tertiary;
|
||||||
setUp(() {
|
setUp(() {
|
||||||
primary = TapGestureRecognizer()
|
primary = TapGestureRecognizer()
|
||||||
..onTapDown = (TapDownDetails details) {
|
..onTapDown = (TapDownDetails details) {
|
||||||
@ -882,7 +880,7 @@ void main() {
|
|||||||
|
|
||||||
group('Gestures of different buttons trigger correct callbacks:', () {
|
group('Gestures of different buttons trigger correct callbacks:', () {
|
||||||
final List<String> recognized = <String>[];
|
final List<String> recognized = <String>[];
|
||||||
TapGestureRecognizer tap;
|
late TapGestureRecognizer tap;
|
||||||
const PointerCancelEvent cancel1 = PointerCancelEvent(
|
const PointerCancelEvent cancel1 = PointerCancelEvent(
|
||||||
pointer: 1,
|
pointer: 1,
|
||||||
);
|
);
|
||||||
@ -942,7 +940,7 @@ void main() {
|
|||||||
|
|
||||||
tester.route(up1);
|
tester.route(up1);
|
||||||
expect(recognized, <String>['primaryUp', 'primary']);
|
expect(recognized, <String>['primaryUp', 'primary']);
|
||||||
GestureBinding.instance.gestureArena.sweep(down1.pointer);
|
GestureBinding.instance!.gestureArena.sweep(down1.pointer);
|
||||||
});
|
});
|
||||||
|
|
||||||
testGesture('A primary tap cancel trigger primary callbacks', (GestureTester tester) {
|
testGesture('A primary tap cancel trigger primary callbacks', (GestureTester tester) {
|
||||||
@ -955,7 +953,7 @@ void main() {
|
|||||||
|
|
||||||
tester.route(cancel1);
|
tester.route(cancel1);
|
||||||
expect(recognized, <String>['primaryCancel']);
|
expect(recognized, <String>['primaryCancel']);
|
||||||
GestureBinding.instance.gestureArena.sweep(down1.pointer);
|
GestureBinding.instance!.gestureArena.sweep(down1.pointer);
|
||||||
});
|
});
|
||||||
|
|
||||||
testGesture('A secondary tap should trigger secondary callbacks', (GestureTester tester) {
|
testGesture('A secondary tap should trigger secondary callbacks', (GestureTester tester) {
|
||||||
@ -967,7 +965,7 @@ void main() {
|
|||||||
recognized.clear();
|
recognized.clear();
|
||||||
|
|
||||||
tester.route(up5);
|
tester.route(up5);
|
||||||
GestureBinding.instance.gestureArena.sweep(down5.pointer);
|
GestureBinding.instance!.gestureArena.sweep(down5.pointer);
|
||||||
expect(recognized, <String>['secondaryUp']);
|
expect(recognized, <String>['secondaryUp']);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -980,7 +978,7 @@ void main() {
|
|||||||
recognized.clear();
|
recognized.clear();
|
||||||
|
|
||||||
tester.route(up6);
|
tester.route(up6);
|
||||||
GestureBinding.instance.gestureArena.sweep(down6.pointer);
|
GestureBinding.instance!.gestureArena.sweep(down6.pointer);
|
||||||
expect(recognized, <String>['tertiaryUp']);
|
expect(recognized, <String>['tertiaryUp']);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -993,7 +991,7 @@ void main() {
|
|||||||
recognized.clear();
|
recognized.clear();
|
||||||
|
|
||||||
tester.route(cancel5);
|
tester.route(cancel5);
|
||||||
GestureBinding.instance.gestureArena.sweep(down5.pointer);
|
GestureBinding.instance!.gestureArena.sweep(down5.pointer);
|
||||||
expect(recognized, <String>['secondaryCancel']);
|
expect(recognized, <String>['secondaryCancel']);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -1006,7 +1004,7 @@ void main() {
|
|||||||
recognized.clear();
|
recognized.clear();
|
||||||
|
|
||||||
tester.route(cancel6);
|
tester.route(cancel6);
|
||||||
GestureBinding.instance.gestureArena.sweep(down6.pointer);
|
GestureBinding.instance!.gestureArena.sweep(down6.pointer);
|
||||||
expect(recognized, <String>['tertiaryCancel']);
|
expect(recognized, <String>['tertiaryCancel']);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -2,8 +2,6 @@
|
|||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
// @dart = 2.8
|
|
||||||
|
|
||||||
import 'package:flutter_test/flutter_test.dart';
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
import 'package:flutter/gestures.dart';
|
import 'package:flutter/gestures.dart';
|
||||||
|
|
||||||
@ -108,7 +106,7 @@ void main() {
|
|||||||
typedef GestureAcceptedCallback = void Function();
|
typedef GestureAcceptedCallback = void Function();
|
||||||
|
|
||||||
class PassiveGestureRecognizer extends OneSequenceGestureRecognizer {
|
class PassiveGestureRecognizer extends OneSequenceGestureRecognizer {
|
||||||
GestureAcceptedCallback onGestureAccepted;
|
GestureAcceptedCallback? onGestureAccepted;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void addPointer(PointerDownEvent event) {
|
void addPointer(PointerDownEvent event) {
|
||||||
@ -133,7 +131,7 @@ class PassiveGestureRecognizer extends OneSequenceGestureRecognizer {
|
|||||||
@override
|
@override
|
||||||
void acceptGesture(int pointer) {
|
void acceptGesture(int pointer) {
|
||||||
if (onGestureAccepted != null) {
|
if (onGestureAccepted != null) {
|
||||||
onGestureAccepted();
|
onGestureAccepted!();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,8 +2,6 @@
|
|||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
// @dart = 2.8
|
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/widgets.dart';
|
import 'package:flutter/widgets.dart';
|
||||||
import 'package:flutter_test/flutter_test.dart';
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
|
@ -2,8 +2,6 @@
|
|||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
// @dart = 2.8
|
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/widgets.dart';
|
import 'package:flutter/widgets.dart';
|
||||||
import 'package:flutter_test/flutter_test.dart';
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
|
@ -2,8 +2,6 @@
|
|||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
// @dart = 2.8
|
|
||||||
|
|
||||||
import 'dart:math' as math;
|
import 'dart:math' as math;
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
@ -63,7 +61,7 @@ void main() {
|
|||||||
const Offset(100, 0),
|
const Offset(100, 0),
|
||||||
);
|
);
|
||||||
expect(
|
expect(
|
||||||
updateDetails.fold(0.0, (double offset, DragUpdateDetails details) => offset + details.primaryDelta),
|
updateDetails.fold(0.0, (double offset, DragUpdateDetails details) => offset + (details.primaryDelta ?? 0)),
|
||||||
100.0,
|
100.0,
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
@ -391,7 +389,7 @@ void main() {
|
|||||||
const Offset(0, 100),
|
const Offset(0, 100),
|
||||||
);
|
);
|
||||||
expect(
|
expect(
|
||||||
updateDetails.fold(0.0, (double offset, DragUpdateDetails details) => offset + details.primaryDelta),
|
updateDetails.fold(0.0, (double offset, DragUpdateDetails details) => offset + (details.primaryDelta ?? 0)),
|
||||||
100.0,
|
100.0,
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
@ -2,8 +2,6 @@
|
|||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
// @dart = 2.8
|
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/widgets.dart';
|
import 'package:flutter/widgets.dart';
|
||||||
import 'package:flutter_test/flutter_test.dart';
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
|
@ -2,8 +2,6 @@
|
|||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
// @dart = 2.8
|
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/widgets.dart';
|
import 'package:flutter/widgets.dart';
|
||||||
import 'package:flutter_test/flutter_test.dart';
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
|
@ -2,8 +2,6 @@
|
|||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
// @dart = 2.8
|
|
||||||
|
|
||||||
import 'package:flutter/gestures.dart';
|
import 'package:flutter/gestures.dart';
|
||||||
|
|
||||||
const List<PointerEvent> velocityEventData = <PointerEvent>[
|
const List<PointerEvent> velocityEventData = <PointerEvent>[
|
||||||
|
@ -2,8 +2,6 @@
|
|||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
// @dart = 2.8
|
|
||||||
|
|
||||||
import 'package:flutter/gestures.dart';
|
import 'package:flutter/gestures.dart';
|
||||||
import 'package:flutter_test/flutter_test.dart';
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
import 'velocity_tracker_data.dart';
|
import 'velocity_tracker_data.dart';
|
||||||
@ -81,7 +79,7 @@ void main() {
|
|||||||
|
|
||||||
test('FreeScrollStartVelocityTracker.getVelocity throws when no points', () {
|
test('FreeScrollStartVelocityTracker.getVelocity throws when no points', () {
|
||||||
final IOSScrollViewFlingVelocityTracker tracker = IOSScrollViewFlingVelocityTracker(PointerDeviceKind.touch);
|
final IOSScrollViewFlingVelocityTracker tracker = IOSScrollViewFlingVelocityTracker(PointerDeviceKind.touch);
|
||||||
AssertionError exception;
|
AssertionError? exception;
|
||||||
try {
|
try {
|
||||||
tracker.getVelocity();
|
tracker.getVelocity();
|
||||||
} on AssertionError catch (e) {
|
} on AssertionError catch (e) {
|
||||||
@ -93,7 +91,7 @@ void main() {
|
|||||||
|
|
||||||
test('FreeScrollStartVelocityTracker.getVelocity throws when the new point precedes the previous point', () {
|
test('FreeScrollStartVelocityTracker.getVelocity throws when the new point precedes the previous point', () {
|
||||||
final IOSScrollViewFlingVelocityTracker tracker = IOSScrollViewFlingVelocityTracker(PointerDeviceKind.touch);
|
final IOSScrollViewFlingVelocityTracker tracker = IOSScrollViewFlingVelocityTracker(PointerDeviceKind.touch);
|
||||||
AssertionError exception;
|
AssertionError? exception;
|
||||||
|
|
||||||
tracker.addPosition(const Duration(hours: 1), Offset.zero);
|
tracker.addPosition(const Duration(hours: 1), Offset.zero);
|
||||||
try {
|
try {
|
||||||
@ -112,7 +110,7 @@ void main() {
|
|||||||
Duration time = Duration.zero;
|
Duration time = Duration.zero;
|
||||||
const Offset positionDelta = Offset(0, -1);
|
const Offset positionDelta = Offset(0, -1);
|
||||||
const Duration durationDelta = Duration(seconds: 1);
|
const Duration durationDelta = Duration(seconds: 1);
|
||||||
AssertionError exception;
|
AssertionError? exception;
|
||||||
|
|
||||||
for (int i = 0; i < 5; i+=1) {
|
for (int i = 0; i < 5; i+=1) {
|
||||||
position += positionDelta;
|
position += positionDelta;
|
||||||
|
@ -2,8 +2,6 @@
|
|||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
// @dart = 2.8
|
|
||||||
|
|
||||||
import 'package:flutter/foundation.dart';
|
import 'package:flutter/foundation.dart';
|
||||||
import 'package:flutter/scheduler.dart';
|
import 'package:flutter/scheduler.dart';
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
@ -22,7 +20,7 @@ void main() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('Can cancel queued callback', () {
|
test('Can cancel queued callback', () {
|
||||||
int secondId;
|
late int secondId;
|
||||||
|
|
||||||
bool firstCallbackRan = false;
|
bool firstCallbackRan = false;
|
||||||
bool secondCallbackRan = false;
|
bool secondCallbackRan = false;
|
||||||
|
@ -2,8 +2,6 @@
|
|||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
// @dart = 2.8
|
|
||||||
|
|
||||||
import 'package:flutter/foundation.dart';
|
import 'package:flutter/foundation.dart';
|
||||||
import 'package:flutter/widgets.dart';
|
import 'package:flutter/widgets.dart';
|
||||||
import 'package:flutter_test/flutter_test.dart';
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
@ -14,10 +12,10 @@ class TestBinding extends LiveTestWidgetsFlutterBinding {
|
|||||||
int framesBegun = 0;
|
int framesBegun = 0;
|
||||||
int framesDrawn = 0;
|
int framesDrawn = 0;
|
||||||
|
|
||||||
bool handleBeginFrameMicrotaskRun;
|
late bool handleBeginFrameMicrotaskRun;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void handleBeginFrame(Duration rawTimeStamp) {
|
void handleBeginFrame(Duration? rawTimeStamp) {
|
||||||
handleBeginFrameMicrotaskRun = false;
|
handleBeginFrameMicrotaskRun = false;
|
||||||
framesBegun += 1;
|
framesBegun += 1;
|
||||||
Future<void>.microtask(() { handleBeginFrameMicrotaskRun = true; });
|
Future<void>.microtask(() { handleBeginFrameMicrotaskRun = true; });
|
||||||
@ -35,7 +33,7 @@ class TestBinding extends LiveTestWidgetsFlutterBinding {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
TestBinding binding;
|
late TestBinding binding;
|
||||||
|
|
||||||
setUp(() {
|
setUp(() {
|
||||||
binding = TestBinding();
|
binding = TestBinding();
|
||||||
|
@ -2,8 +2,6 @@
|
|||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
// @dart = 2.8
|
|
||||||
|
|
||||||
import 'package:flutter/scheduler.dart';
|
import 'package:flutter/scheduler.dart';
|
||||||
import 'package:flutter_test/flutter_test.dart';
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
|
|
||||||
|
@ -2,8 +2,6 @@
|
|||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
// @dart = 2.8
|
|
||||||
|
|
||||||
import 'package:flutter/scheduler.dart';
|
import 'package:flutter/scheduler.dart';
|
||||||
|
|
||||||
import '../flutter_test_alternative.dart';
|
import '../flutter_test_alternative.dart';
|
||||||
|
@ -2,8 +2,6 @@
|
|||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
// @dart = 2.8
|
|
||||||
|
|
||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
import 'dart:ui' show window;
|
import 'dart:ui' show window;
|
||||||
|
|
||||||
@ -30,13 +28,13 @@ class TestSchedulerBinding extends BindingBase with SchedulerBinding, ServicesBi
|
|||||||
class TestStrategy {
|
class TestStrategy {
|
||||||
int allowedPriority = 10000;
|
int allowedPriority = 10000;
|
||||||
|
|
||||||
bool shouldRunTaskWithPriority({ int priority, SchedulerBinding scheduler }) {
|
bool shouldRunTaskWithPriority({ required int priority, required SchedulerBinding scheduler }) {
|
||||||
return priority >= allowedPriority;
|
return priority >= allowedPriority;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
TestSchedulerBinding scheduler;
|
late TestSchedulerBinding scheduler;
|
||||||
|
|
||||||
setUpAll(() {
|
setUpAll(() {
|
||||||
scheduler = TestSchedulerBinding();
|
scheduler = TestSchedulerBinding();
|
||||||
@ -122,7 +120,7 @@ void main() {
|
|||||||
createTimer: (Zone self, ZoneDelegate parent, Zone zone, Duration duration, void f()) {
|
createTimer: (Zone self, ZoneDelegate parent, Zone zone, Duration duration, void f()) {
|
||||||
// Don't actually run the tasks, just record that it was scheduled.
|
// Don't actually run the tasks, just record that it was scheduled.
|
||||||
timerQueueTasks.add(f);
|
timerQueueTasks.add(f);
|
||||||
return null;
|
return DummyTimer();
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
@ -134,7 +132,7 @@ void main() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('Flutter.Frame event fired', () async {
|
test('Flutter.Frame event fired', () async {
|
||||||
window.onReportTimings(<FrameTiming>[FrameTiming(
|
window.onReportTimings!(<FrameTiming>[FrameTiming(
|
||||||
vsyncStart: 5000,
|
vsyncStart: 5000,
|
||||||
buildStart: 10000,
|
buildStart: 10000,
|
||||||
buildFinish: 15000,
|
buildFinish: 15000,
|
||||||
@ -155,20 +153,20 @@ void main() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('TimingsCallback exceptions are caught', () {
|
test('TimingsCallback exceptions are caught', () {
|
||||||
FlutterErrorDetails errorCaught;
|
FlutterErrorDetails? errorCaught;
|
||||||
FlutterError.onError = (FlutterErrorDetails details) {
|
FlutterError.onError = (FlutterErrorDetails details) {
|
||||||
errorCaught = details;
|
errorCaught = details;
|
||||||
};
|
};
|
||||||
SchedulerBinding.instance.addTimingsCallback((List<FrameTiming> timings) {
|
SchedulerBinding.instance!.addTimingsCallback((List<FrameTiming> timings) {
|
||||||
throw Exception('Test');
|
throw Exception('Test');
|
||||||
});
|
});
|
||||||
window.onReportTimings(<FrameTiming>[]);
|
window.onReportTimings!(<FrameTiming>[]);
|
||||||
expect(errorCaught.exceptionAsString(), equals('Exception: Test'));
|
expect(errorCaught!.exceptionAsString(), equals('Exception: Test'));
|
||||||
});
|
});
|
||||||
|
|
||||||
test('currentSystemFrameTimeStamp is the raw timestamp', () {
|
test('currentSystemFrameTimeStamp is the raw timestamp', () {
|
||||||
Duration lastTimeStamp;
|
late Duration lastTimeStamp;
|
||||||
Duration lastSystemTimeStamp;
|
late Duration lastSystemTimeStamp;
|
||||||
|
|
||||||
void frameCallback(Duration timeStamp) {
|
void frameCallback(Duration timeStamp) {
|
||||||
expect(timeStamp, scheduler.currentFrameTimeStamp);
|
expect(timeStamp, scheduler.currentFrameTimeStamp);
|
||||||
@ -198,3 +196,14 @@ void main() {
|
|||||||
expect(lastSystemTimeStamp, const Duration(seconds: 8));
|
expect(lastSystemTimeStamp, const Duration(seconds: 8));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class DummyTimer implements Timer {
|
||||||
|
@override
|
||||||
|
void cancel() {}
|
||||||
|
|
||||||
|
@override
|
||||||
|
bool get isActive => false;
|
||||||
|
|
||||||
|
@override
|
||||||
|
int get tick => 0;
|
||||||
|
}
|
||||||
|
@ -2,8 +2,6 @@
|
|||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
// @dart = 2.8
|
|
||||||
|
|
||||||
import 'package:flutter/scheduler.dart';
|
import 'package:flutter/scheduler.dart';
|
||||||
|
|
||||||
@Deprecated('scheduler_tester is not compatible with dart:async') // ignore: flutter_deprecation_syntax (see analyze.dart)
|
@Deprecated('scheduler_tester is not compatible with dart:async') // ignore: flutter_deprecation_syntax (see analyze.dart)
|
||||||
@ -12,6 +10,6 @@ class Future { } // so that people can't import us and dart:async
|
|||||||
void tick(Duration duration) {
|
void tick(Duration duration) {
|
||||||
// We don't bother running microtasks between these two calls
|
// We don't bother running microtasks between these two calls
|
||||||
// because we don't use Futures in these tests and so don't care.
|
// because we don't use Futures in these tests and so don't care.
|
||||||
SchedulerBinding.instance.handleBeginFrame(duration);
|
SchedulerBinding.instance!.handleBeginFrame(duration);
|
||||||
SchedulerBinding.instance.handleDrawFrame();
|
SchedulerBinding.instance!.handleDrawFrame();
|
||||||
}
|
}
|
||||||
|
@ -2,8 +2,6 @@
|
|||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
// @dart = 2.8
|
|
||||||
|
|
||||||
import 'package:flutter/foundation.dart';
|
import 'package:flutter/foundation.dart';
|
||||||
import 'package:flutter/scheduler.dart';
|
import 'package:flutter/scheduler.dart';
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
@ -27,14 +25,14 @@ void main() {
|
|||||||
expect(ticker.isActive, isTrue);
|
expect(ticker.isActive, isTrue);
|
||||||
expect(tickCount, equals(0));
|
expect(tickCount, equals(0));
|
||||||
|
|
||||||
FlutterError error;
|
FlutterError? error;
|
||||||
try {
|
try {
|
||||||
ticker.start();
|
ticker.start();
|
||||||
} on FlutterError catch (e) {
|
} on FlutterError catch (e) {
|
||||||
error = e;
|
error = e;
|
||||||
}
|
}
|
||||||
expect(error, isNotNull);
|
expect(error, isNotNull);
|
||||||
expect(error.diagnostics.length, 3);
|
expect(error!.diagnostics.length, 3);
|
||||||
expect(error.diagnostics.last, isA<DiagnosticsProperty<Ticker>>());
|
expect(error.diagnostics.last, isA<DiagnosticsProperty<Ticker>>());
|
||||||
expect(
|
expect(
|
||||||
error.toStringDeep(),
|
error.toStringDeep(),
|
||||||
@ -93,7 +91,7 @@ void main() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
testWidgets('Ticker control test', (WidgetTester tester) async {
|
testWidgets('Ticker control test', (WidgetTester tester) async {
|
||||||
Ticker ticker;
|
late Ticker ticker;
|
||||||
|
|
||||||
void testFunction() {
|
void testFunction() {
|
||||||
ticker = Ticker((Duration _) { });
|
ticker = Ticker((Duration _) { });
|
||||||
@ -107,7 +105,7 @@ void main() {
|
|||||||
|
|
||||||
testWidgets('Ticker can be sped up with time dilation', (WidgetTester tester) async {
|
testWidgets('Ticker can be sped up with time dilation', (WidgetTester tester) async {
|
||||||
timeDilation = 0.5; // Move twice as fast.
|
timeDilation = 0.5; // Move twice as fast.
|
||||||
Duration lastDuration;
|
late Duration lastDuration;
|
||||||
void handleTick(Duration duration) {
|
void handleTick(Duration duration) {
|
||||||
lastDuration = duration;
|
lastDuration = duration;
|
||||||
}
|
}
|
||||||
@ -123,7 +121,7 @@ void main() {
|
|||||||
|
|
||||||
testWidgets('Ticker can be slowed down with time dilation', (WidgetTester tester) async {
|
testWidgets('Ticker can be slowed down with time dilation', (WidgetTester tester) async {
|
||||||
timeDilation = 2.0; // Move half as fast.
|
timeDilation = 2.0; // Move half as fast.
|
||||||
Duration lastDuration;
|
late Duration lastDuration;
|
||||||
void handleTick(Duration duration) {
|
void handleTick(Duration duration) {
|
||||||
lastDuration = duration;
|
lastDuration = duration;
|
||||||
}
|
}
|
||||||
@ -150,8 +148,8 @@ void main() {
|
|||||||
expect(ticker.isActive, isTrue);
|
expect(ticker.isActive, isTrue);
|
||||||
expect(tickCount, equals(0));
|
expect(tickCount, equals(0));
|
||||||
|
|
||||||
final ByteData message = const StringCodec().encodeMessage('AppLifecycleState.paused');
|
final ByteData? message = const StringCodec().encodeMessage('AppLifecycleState.paused');
|
||||||
await ServicesBinding.instance.defaultBinaryMessenger.handlePlatformMessage('flutter/lifecycle', message, (_) { });
|
await ServicesBinding.instance!.defaultBinaryMessenger.handlePlatformMessage('flutter/lifecycle', message, (_) { });
|
||||||
expect(ticker.isTicking, isFalse);
|
expect(ticker.isTicking, isFalse);
|
||||||
expect(ticker.isActive, isTrue);
|
expect(ticker.isActive, isTrue);
|
||||||
|
|
||||||
@ -159,8 +157,8 @@ void main() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
testWidgets('Ticker can be created before application unpauses', (WidgetTester tester) async {
|
testWidgets('Ticker can be created before application unpauses', (WidgetTester tester) async {
|
||||||
final ByteData pausedMessage = const StringCodec().encodeMessage('AppLifecycleState.paused');
|
final ByteData? pausedMessage = const StringCodec().encodeMessage('AppLifecycleState.paused');
|
||||||
await ServicesBinding.instance.defaultBinaryMessenger.handlePlatformMessage('flutter/lifecycle', pausedMessage, (_) { });
|
await ServicesBinding.instance!.defaultBinaryMessenger.handlePlatformMessage('flutter/lifecycle', pausedMessage, (_) { });
|
||||||
|
|
||||||
int tickCount = 0;
|
int tickCount = 0;
|
||||||
void handleTick(Duration duration) {
|
void handleTick(Duration duration) {
|
||||||
@ -178,8 +176,8 @@ void main() {
|
|||||||
expect(tickCount, equals(0));
|
expect(tickCount, equals(0));
|
||||||
expect(ticker.isTicking, isFalse);
|
expect(ticker.isTicking, isFalse);
|
||||||
|
|
||||||
final ByteData resumedMessage = const StringCodec().encodeMessage('AppLifecycleState.resumed');
|
final ByteData? resumedMessage = const StringCodec().encodeMessage('AppLifecycleState.resumed');
|
||||||
await ServicesBinding.instance.defaultBinaryMessenger.handlePlatformMessage('flutter/lifecycle', resumedMessage, (_) { });
|
await ServicesBinding.instance!.defaultBinaryMessenger.handlePlatformMessage('flutter/lifecycle', resumedMessage, (_) { });
|
||||||
|
|
||||||
await tester.pump(const Duration(milliseconds: 10));
|
await tester.pump(const Duration(milliseconds: 10));
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user