Unverified Commit b11c5aca authored by Tong Mu's avatar Tong Mu Committed by GitHub

Ensure that tests remove pointers by using addTearDown (#37524)

Guard removePointer with addTearDown to avoid cascading test crash.
parent 6fb0325d
...@@ -2293,6 +2293,7 @@ void main() { ...@@ -2293,6 +2293,7 @@ void main() {
final Offset gPos = textOffsetToPosition(tester, testValue.indexOf('g')); final Offset gPos = textOffsetToPosition(tester, testValue.indexOf('g'));
final TestGesture gesture = await tester.startGesture(ePos, kind: PointerDeviceKind.mouse); final TestGesture gesture = await tester.startGesture(ePos, kind: PointerDeviceKind.mouse);
addTearDown(gesture.removePointer);
await tester.pump(); await tester.pump();
await gesture.moveTo(gPos); await gesture.moveTo(gPos);
await tester.pump(); await tester.pump();
...@@ -2301,8 +2302,6 @@ void main() { ...@@ -2301,8 +2302,6 @@ void main() {
expect(controller.selection.baseOffset, testValue.indexOf('e')); expect(controller.selection.baseOffset, testValue.indexOf('e'));
expect(controller.selection.extentOffset, testValue.indexOf('g')); expect(controller.selection.extentOffset, testValue.indexOf('g'));
await gesture.removePointer();
}); });
testWidgets('Continuous dragging does not cause flickering', (WidgetTester tester) async { testWidgets('Continuous dragging does not cause flickering', (WidgetTester tester) async {
...@@ -2335,6 +2334,7 @@ void main() { ...@@ -2335,6 +2334,7 @@ void main() {
// Drag from 'c' to 'g'. // Drag from 'c' to 'g'.
final TestGesture gesture = await tester.startGesture(cPos, kind: PointerDeviceKind.mouse); final TestGesture gesture = await tester.startGesture(cPos, kind: PointerDeviceKind.mouse);
addTearDown(gesture.removePointer);
await tester.pump(); await tester.pump();
await gesture.moveTo(gPos); await gesture.moveTo(gPos);
await tester.pumpAndSettle(); await tester.pumpAndSettle();
...@@ -2358,8 +2358,6 @@ void main() { ...@@ -2358,8 +2358,6 @@ void main() {
expect(selectionChangedCount, 1); expect(selectionChangedCount, 1);
expect(controller.selection.baseOffset, 2); expect(controller.selection.baseOffset, 2);
expect(controller.selection.extentOffset, 9); expect(controller.selection.extentOffset, 9);
await gesture.removePointer();
}); });
testWidgets('Tap does not show handles nor toolbar', (WidgetTester tester) async { testWidgets('Tap does not show handles nor toolbar', (WidgetTester tester) async {
...@@ -2487,6 +2485,7 @@ void main() { ...@@ -2487,6 +2485,7 @@ void main() {
textFieldPos, textFieldPos,
kind: PointerDeviceKind.mouse, kind: PointerDeviceKind.mouse,
); );
addTearDown(gesture.removePointer);
await tester.pump(const Duration(seconds: 2)); await tester.pump(const Duration(seconds: 2));
await gesture.up(); await gesture.up();
await tester.pump(); await tester.pump();
...@@ -2494,8 +2493,6 @@ void main() { ...@@ -2494,8 +2493,6 @@ void main() {
final EditableTextState editableText = tester.state(find.byType(EditableText)); final EditableTextState editableText = tester.state(find.byType(EditableText));
expect(editableText.selectionOverlay.toolbarIsVisible, isFalse); expect(editableText.selectionOverlay.toolbarIsVisible, isFalse);
expect(editableText.selectionOverlay.handlesAreVisible, isFalse); expect(editableText.selectionOverlay.handlesAreVisible, isFalse);
await gesture.removePointer();
}, },
); );
...@@ -2540,6 +2537,7 @@ void main() { ...@@ -2540,6 +2537,7 @@ void main() {
hPos, hPos,
kind: PointerDeviceKind.mouse, kind: PointerDeviceKind.mouse,
); );
addTearDown(gesture.removePointer);
await tester.pump(const Duration(milliseconds: 50)); await tester.pump(const Duration(milliseconds: 50));
await gesture.up(); await gesture.up();
await tester.pump(); await tester.pump();
...@@ -2550,8 +2548,6 @@ void main() { ...@@ -2550,8 +2548,6 @@ void main() {
expect(editableText.selectionOverlay.handlesAreVisible, isFalse); expect(editableText.selectionOverlay.handlesAreVisible, isFalse);
expect(editableText.selectionOverlay.toolbarIsVisible, isFalse); expect(editableText.selectionOverlay.toolbarIsVisible, isFalse);
await gesture.removePointer();
}, },
); );
......
...@@ -389,6 +389,7 @@ void main() { ...@@ -389,6 +389,7 @@ void main() {
kind: PointerDeviceKind.mouse, kind: PointerDeviceKind.mouse,
); );
await gesture.addPointer(); await gesture.addPointer();
addTearDown(gesture.removePointer);
await gesture.moveTo(center); await gesture.moveTo(center);
await tester.pumpAndSettle(); await tester.pumpAndSettle();
expect(textColor(), hoverColor); expect(textColor(), hoverColor);
...@@ -398,7 +399,6 @@ void main() { ...@@ -398,7 +399,6 @@ void main() {
await tester.pump(); // Start the splash and highlight animations. await tester.pump(); // Start the splash and highlight animations.
await tester.pump(const Duration(milliseconds: 800)); // Wait for splash and highlight to be well under way. await tester.pump(const Duration(milliseconds: 800)); // Wait for splash and highlight to be well under way.
expect(textColor(), pressedColor); expect(textColor(), pressedColor);
await gesture.removePointer();
}, },
semanticsEnabled: true, semanticsEnabled: true,
); );
......
...@@ -514,6 +514,7 @@ void main() { ...@@ -514,6 +514,7 @@ void main() {
// Hover elevation overrides focus // Hover elevation overrides focus
TestGesture gesture = await tester.createGesture(kind: PointerDeviceKind.mouse); TestGesture gesture = await tester.createGesture(kind: PointerDeviceKind.mouse);
await gesture.addPointer(); await gesture.addPointer();
addTearDown(() => gesture?.removePointer());
await gesture.moveTo(tester.getCenter(find.byType(MaterialButton))); await gesture.moveTo(tester.getCenter(find.byType(MaterialButton)));
await tester.pumpAndSettle(); await tester.pumpAndSettle();
material = tester.widget<Material>(rawButtonMaterial); material = tester.widget<Material>(rawButtonMaterial);
...@@ -521,15 +522,17 @@ void main() { ...@@ -521,15 +522,17 @@ void main() {
expect(inkFeatures, paints..rect(color: focusColor)..rect(color: hoverColor)); expect(inkFeatures, paints..rect(color: focusColor)..rect(color: hoverColor));
expect(material.elevation, equals(hoverElevation)); expect(material.elevation, equals(hoverElevation));
await gesture.removePointer(); await gesture.removePointer();
gesture = null;
// Highlight elevation overrides hover // Highlight elevation overrides hover
gesture = await tester.startGesture(tester.getCenter(find.byType(MaterialButton))); final TestGesture gesture2 = await tester.startGesture(tester.getCenter(find.byType(MaterialButton)));
addTearDown(gesture2.removePointer);
await tester.pumpAndSettle(); await tester.pumpAndSettle();
material = tester.widget<Material>(rawButtonMaterial); material = tester.widget<Material>(rawButtonMaterial);
inkFeatures = tester.allRenderObjects.firstWhere((RenderObject object) => object.runtimeType.toString() == '_RenderInkFeatures'); inkFeatures = tester.allRenderObjects.firstWhere((RenderObject object) => object.runtimeType.toString() == '_RenderInkFeatures');
expect(inkFeatures, paints..rect(color: focusColor)..rect(color: highlightColor)); expect(inkFeatures, paints..rect(color: focusColor)..rect(color: highlightColor));
expect(material.elevation, equals(highlightElevation)); expect(material.elevation, equals(highlightElevation));
await gesture.up(); await gesture2.up();
}); });
testWidgets('Does FlatButton contribute semantics', (WidgetTester tester) async { testWidgets('Does FlatButton contribute semantics', (WidgetTester tester) async {
......
...@@ -64,6 +64,7 @@ void main() { ...@@ -64,6 +64,7 @@ void main() {
kind: PointerDeviceKind.mouse, kind: PointerDeviceKind.mouse,
); );
await gesture.addPointer(); await gesture.addPointer();
addTearDown(gesture.removePointer);
await gesture.moveTo(center); await gesture.moveTo(center);
await tester.pumpAndSettle(); await tester.pumpAndSettle();
await expectLater(tester, meetsGuideline(textContrastGuideline)); await expectLater(tester, meetsGuideline(textContrastGuideline));
...@@ -73,7 +74,6 @@ void main() { ...@@ -73,7 +74,6 @@ void main() {
await tester.pump(); // Start the splash and highlight animations. await tester.pump(); // Start the splash and highlight animations.
await tester.pump(const Duration(milliseconds: 800)); // Wait for splash and highlight to be well under way. await tester.pump(const Duration(milliseconds: 800)); // Wait for splash and highlight to be well under way.
await expectLater(tester, meetsGuideline(textContrastGuideline)); await expectLater(tester, meetsGuideline(textContrastGuideline));
await gesture.removePointer();
}, },
semanticsEnabled: true, semanticsEnabled: true,
skip: isBrowser, skip: isBrowser,
...@@ -129,6 +129,7 @@ void main() { ...@@ -129,6 +129,7 @@ void main() {
kind: PointerDeviceKind.mouse, kind: PointerDeviceKind.mouse,
); );
await gesture.addPointer(); await gesture.addPointer();
addTearDown(gesture.removePointer);
await gesture.moveTo(center); await gesture.moveTo(center);
await tester.pumpAndSettle(); await tester.pumpAndSettle();
await expectLater(tester, meetsGuideline(textContrastGuideline)); await expectLater(tester, meetsGuideline(textContrastGuideline));
...@@ -138,7 +139,6 @@ void main() { ...@@ -138,7 +139,6 @@ void main() {
await tester.pump(); // Start the splash and highlight animations. await tester.pump(); // Start the splash and highlight animations.
await tester.pump(const Duration(milliseconds: 800)); // Wait for splash and highlight to be well under way. await tester.pump(const Duration(milliseconds: 800)); // Wait for splash and highlight to be well under way.
await expectLater(tester, meetsGuideline(textContrastGuideline)); await expectLater(tester, meetsGuideline(textContrastGuideline));
await gesture.removePointer();
}, },
semanticsEnabled: true, semanticsEnabled: true,
skip: isBrowser, skip: isBrowser,
...@@ -198,6 +198,7 @@ void main() { ...@@ -198,6 +198,7 @@ void main() {
kind: PointerDeviceKind.mouse, kind: PointerDeviceKind.mouse,
); );
await gesture.addPointer(); await gesture.addPointer();
addTearDown(gesture.removePointer);
await gesture.moveTo(center); await gesture.moveTo(center);
await tester.pumpAndSettle(); await tester.pumpAndSettle();
expect(textColor(), hoverColor); expect(textColor(), hoverColor);
...@@ -207,7 +208,6 @@ void main() { ...@@ -207,7 +208,6 @@ void main() {
await tester.pump(); // Start the splash and highlight animations. await tester.pump(); // Start the splash and highlight animations.
await tester.pump(const Duration(milliseconds: 800)); // Wait for splash and highlight to be well under way. await tester.pump(const Duration(milliseconds: 800)); // Wait for splash and highlight to be well under way.
expect(textColor(), pressedColor); expect(textColor(), pressedColor);
await gesture.removePointer();
}); });
testWidgets('FlatButton uses stateful color for icon color in different states', (WidgetTester tester) async { testWidgets('FlatButton uses stateful color for icon color in different states', (WidgetTester tester) async {
...@@ -264,6 +264,7 @@ void main() { ...@@ -264,6 +264,7 @@ void main() {
kind: PointerDeviceKind.mouse, kind: PointerDeviceKind.mouse,
); );
await gesture.addPointer(); await gesture.addPointer();
addTearDown(gesture.removePointer);
await gesture.moveTo(center); await gesture.moveTo(center);
await tester.pumpAndSettle(); await tester.pumpAndSettle();
expect(iconColor(), hoverColor); expect(iconColor(), hoverColor);
...@@ -273,7 +274,6 @@ void main() { ...@@ -273,7 +274,6 @@ void main() {
await tester.pump(); // Start the splash and highlight animations. await tester.pump(); // Start the splash and highlight animations.
await tester.pump(const Duration(milliseconds: 800)); // Wait for splash and highlight to be well under way. await tester.pump(const Duration(milliseconds: 800)); // Wait for splash and highlight to be well under way.
expect(iconColor(), pressedColor); expect(iconColor(), pressedColor);
await gesture.removePointer();
}); });
testWidgets('FlatButton ignores disabled text color if text color is stateful', (WidgetTester tester) async { testWidgets('FlatButton ignores disabled text color if text color is stateful', (WidgetTester tester) async {
......
...@@ -107,8 +107,9 @@ void main() { ...@@ -107,8 +107,9 @@ void main() {
expect(find.text('Add'), findsNothing); expect(find.text('Add'), findsNothing);
// Test hover for tooltip. // Test hover for tooltip.
final TestGesture gesture = await tester.createGesture(kind: PointerDeviceKind.mouse); TestGesture gesture = await tester.createGesture(kind: PointerDeviceKind.mouse);
await gesture.addPointer(); await gesture.addPointer();
addTearDown(() => gesture?.removePointer());
await gesture.moveTo(tester.getCenter(find.byType(FloatingActionButton))); await gesture.moveTo(tester.getCenter(find.byType(FloatingActionButton)));
await tester.pumpAndSettle(); await tester.pumpAndSettle();
...@@ -116,6 +117,7 @@ void main() { ...@@ -116,6 +117,7 @@ void main() {
await gesture.moveTo(Offset.zero); await gesture.moveTo(Offset.zero);
await gesture.removePointer(); await gesture.removePointer();
gesture = null;
await tester.pumpAndSettle(); await tester.pumpAndSettle();
expect(find.text('Add'), findsNothing); expect(find.text('Add'), findsNothing);
...@@ -142,18 +144,17 @@ void main() { ...@@ -142,18 +144,17 @@ void main() {
expect(find.text('Add'), findsNothing); expect(find.text('Add'), findsNothing);
// Test hover for tooltip. // Test hover for tooltip.
final TestGesture gesture = await tester.createGesture(kind: PointerDeviceKind.mouse); TestGesture gesture = await tester.createGesture(kind: PointerDeviceKind.mouse);
try { await gesture.addPointer();
await gesture.addPointer(); addTearDown(() => gesture?.removePointer());
await gesture.moveTo(tester.getCenter(find.byType(FloatingActionButton))); await gesture.moveTo(tester.getCenter(find.byType(FloatingActionButton)));
await tester.pumpAndSettle(); await tester.pumpAndSettle();
expect(find.text('Add'), findsOneWidget); expect(find.text('Add'), findsOneWidget);
await gesture.moveTo(Offset.zero); await gesture.moveTo(Offset.zero);
} finally { await gesture.removePointer();
await gesture.removePointer(); gesture = null;
}
await tester.pumpAndSettle(); await tester.pumpAndSettle();
expect(find.text('Add'), findsNothing); expect(find.text('Add'), findsNothing);
......
...@@ -113,12 +113,11 @@ void main() { ...@@ -113,12 +113,11 @@ void main() {
)); ));
final TestGesture gesture = await tester.createGesture(kind: PointerDeviceKind.mouse); final TestGesture gesture = await tester.createGesture(kind: PointerDeviceKind.mouse);
await gesture.addPointer(); await gesture.addPointer();
addTearDown(gesture.removePointer);
await gesture.moveTo(tester.getCenter(find.byType(Container))); await gesture.moveTo(tester.getCenter(find.byType(Container)));
await tester.pumpAndSettle(); await tester.pumpAndSettle();
final RenderObject inkFeatures = tester.allRenderObjects.firstWhere((RenderObject object) => object.runtimeType.toString() == '_RenderInkFeatures'); final RenderObject inkFeatures = tester.allRenderObjects.firstWhere((RenderObject object) => object.runtimeType.toString() == '_RenderInkFeatures');
expect(inkFeatures, paints..rect(rect: const Rect.fromLTRB(350.0, 250.0, 450.0, 350.0), color: const Color(0xff00ff00))); expect(inkFeatures, paints..rect(rect: const Rect.fromLTRB(350.0, 250.0, 450.0, 350.0), color: const Color(0xff00ff00)));
await gesture.removePointer();
}); });
testWidgets('ink response changes color on focus', (WidgetTester tester) async { testWidgets('ink response changes color on focus', (WidgetTester tester) async {
......
...@@ -67,6 +67,7 @@ void main() { ...@@ -67,6 +67,7 @@ void main() {
kind: PointerDeviceKind.mouse, kind: PointerDeviceKind.mouse,
); );
await gesture.addPointer(); await gesture.addPointer();
addTearDown(gesture.removePointer);
await gesture.moveTo(center); await gesture.moveTo(center);
await tester.pumpAndSettle(); await tester.pumpAndSettle();
await expectLater(tester, meetsGuideline(textContrastGuideline)); await expectLater(tester, meetsGuideline(textContrastGuideline));
...@@ -76,7 +77,6 @@ void main() { ...@@ -76,7 +77,6 @@ void main() {
await tester.pump(); // Start the splash and highlight animations. await tester.pump(); // Start the splash and highlight animations.
await tester.pump(const Duration(milliseconds: 800)); // Wait for splash and highlight to be well under way. await tester.pump(const Duration(milliseconds: 800)); // Wait for splash and highlight to be well under way.
await expectLater(tester, meetsGuideline(textContrastGuideline)); await expectLater(tester, meetsGuideline(textContrastGuideline));
await gesture.removePointer();
}, },
semanticsEnabled: true, semanticsEnabled: true,
skip: isBrowser, skip: isBrowser,
...@@ -132,6 +132,7 @@ void main() { ...@@ -132,6 +132,7 @@ void main() {
kind: PointerDeviceKind.mouse, kind: PointerDeviceKind.mouse,
); );
await gesture.addPointer(); await gesture.addPointer();
addTearDown(gesture.removePointer);
await gesture.moveTo(center); await gesture.moveTo(center);
await tester.pumpAndSettle(); await tester.pumpAndSettle();
await expectLater(tester, meetsGuideline(textContrastGuideline)); await expectLater(tester, meetsGuideline(textContrastGuideline));
...@@ -141,7 +142,6 @@ void main() { ...@@ -141,7 +142,6 @@ void main() {
await tester.pump(); // Start the splash and highlight animations. await tester.pump(); // Start the splash and highlight animations.
await tester.pump(const Duration(milliseconds: 800)); // Wait for splash and highlight to be well under way. await tester.pump(const Duration(milliseconds: 800)); // Wait for splash and highlight to be well under way.
await expectLater(tester, meetsGuideline(textContrastGuideline)); await expectLater(tester, meetsGuideline(textContrastGuideline));
await gesture.removePointer();
}, },
skip: isBrowser, skip: isBrowser,
semanticsEnabled: true, semanticsEnabled: true,
...@@ -201,6 +201,7 @@ void main() { ...@@ -201,6 +201,7 @@ void main() {
kind: PointerDeviceKind.mouse, kind: PointerDeviceKind.mouse,
); );
await gesture.addPointer(); await gesture.addPointer();
addTearDown(gesture.removePointer);
await gesture.moveTo(center); await gesture.moveTo(center);
await tester.pumpAndSettle(); await tester.pumpAndSettle();
expect(textColor(), hoverColor); expect(textColor(), hoverColor);
...@@ -210,7 +211,6 @@ void main() { ...@@ -210,7 +211,6 @@ void main() {
await tester.pump(); // Start the splash and highlight animations. await tester.pump(); // Start the splash and highlight animations.
await tester.pump(const Duration(milliseconds: 800)); // Wait for splash and highlight to be well under way. await tester.pump(const Duration(milliseconds: 800)); // Wait for splash and highlight to be well under way.
expect(textColor(), pressedColor); expect(textColor(), pressedColor);
await gesture.removePointer();
}); });
testWidgets('OutlineButton uses stateful color for icon color in different states', (WidgetTester tester) async { testWidgets('OutlineButton uses stateful color for icon color in different states', (WidgetTester tester) async {
...@@ -267,6 +267,7 @@ void main() { ...@@ -267,6 +267,7 @@ void main() {
kind: PointerDeviceKind.mouse, kind: PointerDeviceKind.mouse,
); );
await gesture.addPointer(); await gesture.addPointer();
addTearDown(gesture.removePointer);
await gesture.moveTo(center); await gesture.moveTo(center);
await tester.pumpAndSettle(); await tester.pumpAndSettle();
expect(iconColor(), hoverColor); expect(iconColor(), hoverColor);
...@@ -276,7 +277,6 @@ void main() { ...@@ -276,7 +277,6 @@ void main() {
await tester.pump(); // Start the splash and highlight animations. await tester.pump(); // Start the splash and highlight animations.
await tester.pump(const Duration(milliseconds: 800)); // Wait for splash and highlight to be well under way. await tester.pump(const Duration(milliseconds: 800)); // Wait for splash and highlight to be well under way.
expect(iconColor(), pressedColor); expect(iconColor(), pressedColor);
await gesture.removePointer();
}); });
testWidgets('OutlineButton ignores disabled text color if text color is stateful', (WidgetTester tester) async { testWidgets('OutlineButton ignores disabled text color if text color is stateful', (WidgetTester tester) async {
...@@ -370,6 +370,7 @@ void main() { ...@@ -370,6 +370,7 @@ void main() {
kind: PointerDeviceKind.mouse, kind: PointerDeviceKind.mouse,
); );
await gesture.addPointer(); await gesture.addPointer();
addTearDown(gesture.removePointer);
await gesture.moveTo(center); await gesture.moveTo(center);
await tester.pumpAndSettle(); await tester.pumpAndSettle();
expect(outlineButton, paints..path(color: hoverColor)); expect(outlineButton, paints..path(color: hoverColor));
...@@ -378,7 +379,6 @@ void main() { ...@@ -378,7 +379,6 @@ void main() {
await gesture.down(center); await gesture.down(center);
await tester.pumpAndSettle(); await tester.pumpAndSettle();
expect(outlineButton, paints..path(color: pressedColor)); expect(outlineButton, paints..path(color: pressedColor));
await gesture.removePointer();
}); });
testWidgets('OutlineButton ignores highlightBorderColor if border color is stateful', (WidgetTester tester) async { testWidgets('OutlineButton ignores highlightBorderColor if border color is stateful', (WidgetTester tester) async {
......
...@@ -64,6 +64,7 @@ void main() { ...@@ -64,6 +64,7 @@ void main() {
kind: PointerDeviceKind.mouse, kind: PointerDeviceKind.mouse,
); );
await gesture.addPointer(); await gesture.addPointer();
addTearDown(gesture.removePointer);
await gesture.moveTo(center); await gesture.moveTo(center);
await tester.pumpAndSettle(); await tester.pumpAndSettle();
await expectLater(tester, meetsGuideline(textContrastGuideline)); await expectLater(tester, meetsGuideline(textContrastGuideline));
...@@ -73,7 +74,6 @@ void main() { ...@@ -73,7 +74,6 @@ void main() {
await tester.pump(); // Start the splash and highlight animations. await tester.pump(); // Start the splash and highlight animations.
await tester.pump(const Duration(milliseconds: 800)); // Wait for splash and highlight to be well under way. await tester.pump(const Duration(milliseconds: 800)); // Wait for splash and highlight to be well under way.
await expectLater(tester, meetsGuideline(textContrastGuideline)); await expectLater(tester, meetsGuideline(textContrastGuideline));
await gesture.removePointer();
}, },
skip: isBrowser, skip: isBrowser,
semanticsEnabled: true, semanticsEnabled: true,
...@@ -133,6 +133,7 @@ void main() { ...@@ -133,6 +133,7 @@ void main() {
kind: PointerDeviceKind.mouse, kind: PointerDeviceKind.mouse,
); );
await gesture.addPointer(); await gesture.addPointer();
addTearDown(gesture.removePointer);
await gesture.moveTo(center); await gesture.moveTo(center);
await tester.pumpAndSettle(); await tester.pumpAndSettle();
expect(textColor(), hoverColor); expect(textColor(), hoverColor);
...@@ -142,7 +143,6 @@ void main() { ...@@ -142,7 +143,6 @@ void main() {
await tester.pump(); // Start the splash and highlight animations. await tester.pump(); // Start the splash and highlight animations.
await tester.pump(const Duration(milliseconds: 800)); // Wait for splash and highlight to be well under way. await tester.pump(const Duration(milliseconds: 800)); // Wait for splash and highlight to be well under way.
expect(textColor(), pressedColor); expect(textColor(), pressedColor);
await gesture.removePointer();
}); });
...@@ -200,6 +200,7 @@ void main() { ...@@ -200,6 +200,7 @@ void main() {
kind: PointerDeviceKind.mouse, kind: PointerDeviceKind.mouse,
); );
await gesture.addPointer(); await gesture.addPointer();
addTearDown(gesture.removePointer);
await gesture.moveTo(center); await gesture.moveTo(center);
await tester.pumpAndSettle(); await tester.pumpAndSettle();
expect(iconColor(), hoverColor); expect(iconColor(), hoverColor);
...@@ -209,7 +210,6 @@ void main() { ...@@ -209,7 +210,6 @@ void main() {
await tester.pump(); // Start the splash and highlight animations. await tester.pump(); // Start the splash and highlight animations.
await tester.pump(const Duration(milliseconds: 800)); // Wait for splash and highlight to be well under way. await tester.pump(const Duration(milliseconds: 800)); // Wait for splash and highlight to be well under way.
expect(iconColor(), pressedColor); expect(iconColor(), pressedColor);
await gesture.removePointer();
}); });
testWidgets('RaisedButton ignores disabled text color if text color is stateful', (WidgetTester tester) async { testWidgets('RaisedButton ignores disabled text color if text color is stateful', (WidgetTester tester) async {
......
...@@ -257,13 +257,12 @@ void main() { ...@@ -257,13 +257,12 @@ void main() {
final RenderBox box = Material.of(tester.element(find.byType(InkWell))) as dynamic; final RenderBox box = Material.of(tester.element(find.byType(InkWell))) as dynamic;
final TestGesture gesture = await tester.createGesture(kind: PointerDeviceKind.mouse); final TestGesture gesture = await tester.createGesture(kind: PointerDeviceKind.mouse);
await gesture.addPointer(); await gesture.addPointer();
addTearDown(gesture.removePointer);
expect(box, isNot(paints..rect(color: hoverColor))); expect(box, isNot(paints..rect(color: hoverColor)));
await gesture.moveTo(tester.getCenter(find.byType(RawMaterialButton))); await gesture.moveTo(tester.getCenter(find.byType(RawMaterialButton)));
await tester.pumpAndSettle(const Duration(seconds: 1)); await tester.pumpAndSettle(const Duration(seconds: 1));
expect(box, paints..rect(color: hoverColor)); expect(box, paints..rect(color: hoverColor));
await gesture.removePointer();
}); });
} }
...@@ -857,6 +857,7 @@ void main() { ...@@ -857,6 +857,7 @@ void main() {
final int eIndex = testValue.indexOf('e'); final int eIndex = testValue.indexOf('e');
final Offset ePos = textOffsetToPosition(tester, eIndex); final Offset ePos = textOffsetToPosition(tester, eIndex);
final TestGesture gesture = await tester.startGesture(ePos, kind: PointerDeviceKind.mouse); final TestGesture gesture = await tester.startGesture(ePos, kind: PointerDeviceKind.mouse);
addTearDown(gesture.removePointer);
await tester.pump(const Duration(seconds: 2)); await tester.pump(const Duration(seconds: 2));
await gesture.up(); await gesture.up();
await tester.pump(); await tester.pump();
...@@ -864,8 +865,6 @@ void main() { ...@@ -864,8 +865,6 @@ void main() {
// The cursor is placed just like a regular tap. // The cursor is placed just like a regular tap.
expect(controller.selection.baseOffset, eIndex); expect(controller.selection.baseOffset, eIndex);
expect(controller.selection.extentOffset, eIndex); expect(controller.selection.extentOffset, eIndex);
await gesture.removePointer();
}); });
testWidgets('Read only text field basic', (WidgetTester tester) async { testWidgets('Read only text field basic', (WidgetTester tester) async {
...@@ -1153,6 +1152,7 @@ void main() { ...@@ -1153,6 +1152,7 @@ void main() {
final Offset gPos = textOffsetToPosition(tester, testValue.indexOf('g')); final Offset gPos = textOffsetToPosition(tester, testValue.indexOf('g'));
final TestGesture gesture = await tester.startGesture(ePos, kind: PointerDeviceKind.mouse); final TestGesture gesture = await tester.startGesture(ePos, kind: PointerDeviceKind.mouse);
addTearDown(gesture.removePointer);
await tester.pump(); await tester.pump();
await gesture.moveTo(gPos); await gesture.moveTo(gPos);
await tester.pump(); await tester.pump();
...@@ -1161,8 +1161,6 @@ void main() { ...@@ -1161,8 +1161,6 @@ void main() {
expect(controller.selection.baseOffset, testValue.indexOf('e')); expect(controller.selection.baseOffset, testValue.indexOf('e'));
expect(controller.selection.extentOffset, testValue.indexOf('g')); expect(controller.selection.extentOffset, testValue.indexOf('g'));
await gesture.removePointer();
}); });
testWidgets('Continuous dragging does not cause flickering', (WidgetTester tester) async { testWidgets('Continuous dragging does not cause flickering', (WidgetTester tester) async {
...@@ -1192,6 +1190,7 @@ void main() { ...@@ -1192,6 +1190,7 @@ void main() {
// Drag from 'c' to 'g'. // Drag from 'c' to 'g'.
final TestGesture gesture = await tester.startGesture(cPos, kind: PointerDeviceKind.mouse); final TestGesture gesture = await tester.startGesture(cPos, kind: PointerDeviceKind.mouse);
addTearDown(gesture.removePointer);
await tester.pump(); await tester.pump();
await gesture.moveTo(gPos); await gesture.moveTo(gPos);
await tester.pumpAndSettle(); await tester.pumpAndSettle();
...@@ -1215,8 +1214,6 @@ void main() { ...@@ -1215,8 +1214,6 @@ void main() {
expect(selectionChangedCount, 1); expect(selectionChangedCount, 1);
expect(controller.selection.baseOffset, 2); expect(controller.selection.baseOffset, 2);
expect(controller.selection.extentOffset, 9); expect(controller.selection.extentOffset, 9);
await gesture.removePointer();
}); });
testWidgets('Dragging in opposite direction also works', (WidgetTester tester) async { testWidgets('Dragging in opposite direction also works', (WidgetTester tester) async {
...@@ -1241,6 +1238,7 @@ void main() { ...@@ -1241,6 +1238,7 @@ void main() {
final Offset gPos = textOffsetToPosition(tester, testValue.indexOf('g')); final Offset gPos = textOffsetToPosition(tester, testValue.indexOf('g'));
final TestGesture gesture = await tester.startGesture(gPos, kind: PointerDeviceKind.mouse); final TestGesture gesture = await tester.startGesture(gPos, kind: PointerDeviceKind.mouse);
addTearDown(gesture.removePointer);
await tester.pump(); await tester.pump();
await gesture.moveTo(ePos); await gesture.moveTo(ePos);
await tester.pump(); await tester.pump();
...@@ -1249,8 +1247,6 @@ void main() { ...@@ -1249,8 +1247,6 @@ void main() {
expect(controller.selection.baseOffset, testValue.indexOf('e')); expect(controller.selection.baseOffset, testValue.indexOf('e'));
expect(controller.selection.extentOffset, testValue.indexOf('g')); expect(controller.selection.extentOffset, testValue.indexOf('g'));
await gesture.removePointer();
}); });
testWidgets('Slow mouse dragging also selects text', (WidgetTester tester) async { testWidgets('Slow mouse dragging also selects text', (WidgetTester tester) async {
...@@ -1275,6 +1271,7 @@ void main() { ...@@ -1275,6 +1271,7 @@ void main() {
final Offset gPos = textOffsetToPosition(tester, testValue.indexOf('g')); final Offset gPos = textOffsetToPosition(tester, testValue.indexOf('g'));
final TestGesture gesture = await tester.startGesture(ePos, kind: PointerDeviceKind.mouse); final TestGesture gesture = await tester.startGesture(ePos, kind: PointerDeviceKind.mouse);
addTearDown(gesture.removePointer);
await tester.pump(const Duration(seconds: 2)); await tester.pump(const Duration(seconds: 2));
await gesture.moveTo(gPos); await gesture.moveTo(gPos);
await tester.pump(); await tester.pump();
...@@ -1282,8 +1279,6 @@ void main() { ...@@ -1282,8 +1279,6 @@ void main() {
expect(controller.selection.baseOffset, testValue.indexOf('e')); expect(controller.selection.baseOffset, testValue.indexOf('e'));
expect(controller.selection.extentOffset, testValue.indexOf('g')); expect(controller.selection.extentOffset, testValue.indexOf('g'));
await gesture.removePointer();
}); });
testWidgets('Can drag handles to change selection', (WidgetTester tester) async { testWidgets('Can drag handles to change selection', (WidgetTester tester) async {
...@@ -6806,6 +6801,7 @@ void main() { ...@@ -6806,6 +6801,7 @@ void main() {
pointer: 7, pointer: 7,
kind: PointerDeviceKind.mouse, kind: PointerDeviceKind.mouse,
); );
addTearDown(gesture.removePointer);
await tester.pump(); await tester.pump();
await gesture.up(); await gesture.up();
await tester.pump(); await tester.pump();
...@@ -6813,8 +6809,6 @@ void main() { ...@@ -6813,8 +6809,6 @@ void main() {
final EditableTextState editableText = tester.state(find.byType(EditableText)); final EditableTextState editableText = tester.state(find.byType(EditableText));
expect(editableText.selectionOverlay.toolbarIsVisible, isFalse); expect(editableText.selectionOverlay.toolbarIsVisible, isFalse);
expect(editableText.selectionOverlay.handlesAreVisible, isFalse); expect(editableText.selectionOverlay.handlesAreVisible, isFalse);
await gesture.removePointer();
}, },
); );
...@@ -6840,6 +6834,7 @@ void main() { ...@@ -6840,6 +6834,7 @@ void main() {
pointer: 7, pointer: 7,
kind: PointerDeviceKind.mouse, kind: PointerDeviceKind.mouse,
); );
addTearDown(gesture.removePointer);
await tester.pump(const Duration(seconds: 2)); await tester.pump(const Duration(seconds: 2));
await gesture.up(); await gesture.up();
await tester.pump(); await tester.pump();
...@@ -6847,8 +6842,6 @@ void main() { ...@@ -6847,8 +6842,6 @@ void main() {
final EditableTextState editableText = tester.state(find.byType(EditableText)); final EditableTextState editableText = tester.state(find.byType(EditableText));
expect(editableText.selectionOverlay.toolbarIsVisible, isFalse); expect(editableText.selectionOverlay.toolbarIsVisible, isFalse);
expect(editableText.selectionOverlay.handlesAreVisible, isFalse); expect(editableText.selectionOverlay.handlesAreVisible, isFalse);
await gesture.removePointer();
}, },
); );
...@@ -6874,6 +6867,7 @@ void main() { ...@@ -6874,6 +6867,7 @@ void main() {
pointer: 7, pointer: 7,
kind: PointerDeviceKind.mouse, kind: PointerDeviceKind.mouse,
); );
addTearDown(gesture.removePointer);
await tester.pump(const Duration(milliseconds: 50)); await tester.pump(const Duration(milliseconds: 50));
await gesture.up(); await gesture.up();
await tester.pump(); await tester.pump();
...@@ -6885,8 +6879,6 @@ void main() { ...@@ -6885,8 +6879,6 @@ void main() {
final EditableTextState editableText = tester.state(find.byType(EditableText)); final EditableTextState editableText = tester.state(find.byType(EditableText));
expect(editableText.selectionOverlay.toolbarIsVisible, isFalse); expect(editableText.selectionOverlay.toolbarIsVisible, isFalse);
expect(editableText.selectionOverlay.handlesAreVisible, isFalse); expect(editableText.selectionOverlay.handlesAreVisible, isFalse);
await gesture.removePointer();
}, },
); );
......
...@@ -703,7 +703,11 @@ void main() { ...@@ -703,7 +703,11 @@ void main() {
testWidgets('Tooltip shows/hides when hovered', (WidgetTester tester) async { testWidgets('Tooltip shows/hides when hovered', (WidgetTester tester) async {
const Duration waitDuration = Duration(milliseconds: 0); const Duration waitDuration = Duration(milliseconds: 0);
final TestGesture gesture = await tester.createGesture(kind: PointerDeviceKind.mouse); TestGesture gesture = await tester.createGesture(kind: PointerDeviceKind.mouse);
addTearDown(() async {
if (gesture != null)
return gesture.removePointer();
});
await gesture.addPointer(); await gesture.addPointer();
await gesture.moveTo(const Offset(1.0, 1.0)); await gesture.moveTo(const Offset(1.0, 1.0));
await tester.pump(); await tester.pump();
...@@ -745,6 +749,7 @@ void main() { ...@@ -745,6 +749,7 @@ void main() {
// Wait for it to disappear. // Wait for it to disappear.
await tester.pumpAndSettle(); await tester.pumpAndSettle();
await gesture.removePointer(); await gesture.removePointer();
gesture = null;
expect(find.text(tooltipText), findsNothing); expect(find.text(tooltipText), findsNothing);
}); });
......
...@@ -824,6 +824,7 @@ void main() { ...@@ -824,6 +824,7 @@ void main() {
const Duration customWaitDuration = Duration(milliseconds: 500); const Duration customWaitDuration = Duration(milliseconds: 500);
final TestGesture gesture = await tester.createGesture(kind: PointerDeviceKind.mouse); final TestGesture gesture = await tester.createGesture(kind: PointerDeviceKind.mouse);
await gesture.addPointer(); await gesture.addPointer();
addTearDown(gesture.removePointer);
await gesture.moveTo(const Offset(1.0, 1.0)); await gesture.moveTo(const Offset(1.0, 1.0));
await tester.pump(); await tester.pump();
await gesture.moveTo(Offset.zero); await gesture.moveTo(Offset.zero);
...@@ -865,13 +866,13 @@ void main() { ...@@ -865,13 +866,13 @@ void main() {
// Wait for it to disappear. // Wait for it to disappear.
await tester.pump(const Duration(milliseconds: 0)); // Should immediately disappear await tester.pump(const Duration(milliseconds: 0)); // Should immediately disappear
expect(find.text(tooltipText), findsNothing); expect(find.text(tooltipText), findsNothing);
await gesture.removePointer();
}); });
testWidgets('Tooltip waitDuration - TooltipTheme', (WidgetTester tester) async { testWidgets('Tooltip waitDuration - TooltipTheme', (WidgetTester tester) async {
const Duration customWaitDuration = Duration(milliseconds: 500); const Duration customWaitDuration = Duration(milliseconds: 500);
final TestGesture gesture = await tester.createGesture(kind: PointerDeviceKind.mouse); final TestGesture gesture = await tester.createGesture(kind: PointerDeviceKind.mouse);
await gesture.addPointer(); await gesture.addPointer();
addTearDown(gesture.removePointer);
await gesture.moveTo(const Offset(1.0, 1.0)); await gesture.moveTo(const Offset(1.0, 1.0));
await tester.pump(); await tester.pump();
await gesture.moveTo(Offset.zero); await gesture.moveTo(Offset.zero);
...@@ -909,7 +910,6 @@ void main() { ...@@ -909,7 +910,6 @@ void main() {
// Wait for it to disappear. // Wait for it to disappear.
await tester.pump(const Duration(milliseconds: 0)); // Should immediately disappear await tester.pump(const Duration(milliseconds: 0)); // Should immediately disappear
expect(find.text(tooltipText), findsNothing); expect(find.text(tooltipText), findsNothing);
await gesture.removePointer();
}); });
testWidgets('Tooltip showDuration - ThemeData.tooltipTheme', (WidgetTester tester) async { testWidgets('Tooltip showDuration - ThemeData.tooltipTheme', (WidgetTester tester) async {
......
...@@ -104,6 +104,7 @@ void main() { ...@@ -104,6 +104,7 @@ void main() {
), ),
)); ));
final TestGesture gesture = await tester.createGesture(kind: PointerDeviceKind.mouse); final TestGesture gesture = await tester.createGesture(kind: PointerDeviceKind.mouse);
addTearDown(gesture.removePointer);
await gesture.moveTo(const Offset(400.0, 300.0)); await gesture.moveTo(const Offset(400.0, 300.0));
await tester.pump(); await tester.pump();
expect(move, isNotNull); expect(move, isNotNull);
...@@ -111,8 +112,6 @@ void main() { ...@@ -111,8 +112,6 @@ void main() {
expect(enter, isNotNull); expect(enter, isNotNull);
expect(enter.position, equals(const Offset(400.0, 300.0))); expect(enter.position, equals(const Offset(400.0, 300.0)));
expect(exit, isNull); expect(exit, isNull);
await gesture.removePointer();
}); });
testWidgets('detects pointer exiting', (WidgetTester tester) async { testWidgets('detects pointer exiting', (WidgetTester tester) async {
PointerEnterEvent enter; PointerEnterEvent enter;
...@@ -130,6 +129,7 @@ void main() { ...@@ -130,6 +129,7 @@ void main() {
), ),
)); ));
final TestGesture gesture = await tester.createGesture(kind: PointerDeviceKind.mouse); final TestGesture gesture = await tester.createGesture(kind: PointerDeviceKind.mouse);
addTearDown(gesture.removePointer);
await gesture.moveTo(const Offset(400.0, 300.0)); await gesture.moveTo(const Offset(400.0, 300.0));
await tester.pump(); await tester.pump();
move = null; move = null;
...@@ -140,8 +140,6 @@ void main() { ...@@ -140,8 +140,6 @@ void main() {
expect(enter, isNull); expect(enter, isNull);
expect(exit, isNotNull); expect(exit, isNotNull);
expect(exit.position, equals(const Offset(1.0, 1.0))); expect(exit.position, equals(const Offset(1.0, 1.0)));
await gesture.removePointer();
}); });
testWidgets('detects pointer exit when widget disappears', (WidgetTester tester) async { testWidgets('detects pointer exit when widget disappears', (WidgetTester tester) async {
PointerEnterEvent enter; PointerEnterEvent enter;
...@@ -160,6 +158,7 @@ void main() { ...@@ -160,6 +158,7 @@ void main() {
)); ));
final RenderMouseRegion renderListener = tester.renderObject(find.byType(MouseRegion)); final RenderMouseRegion renderListener = tester.renderObject(find.byType(MouseRegion));
final TestGesture gesture = await tester.createGesture(kind: PointerDeviceKind.mouse); final TestGesture gesture = await tester.createGesture(kind: PointerDeviceKind.mouse);
addTearDown(gesture.removePointer);
await gesture.moveTo(const Offset(400.0, 300.0)); await gesture.moveTo(const Offset(400.0, 300.0));
await tester.pump(); await tester.pump();
expect(move, isNotNull); expect(move, isNotNull);
...@@ -176,8 +175,6 @@ void main() { ...@@ -176,8 +175,6 @@ void main() {
expect(exit, isNotNull); expect(exit, isNotNull);
expect(exit.position, equals(const Offset(400.0, 300.0))); expect(exit.position, equals(const Offset(400.0, 300.0)));
expect(tester.binding.mouseTracker.isAnnotationAttached(renderListener.hoverAnnotation), isFalse); expect(tester.binding.mouseTracker.isAnnotationAttached(renderListener.hoverAnnotation), isFalse);
await gesture.removePointer();
}); });
testWidgets('Hover works with nested listeners', (WidgetTester tester) async { testWidgets('Hover works with nested listeners', (WidgetTester tester) async {
final UniqueKey key1 = UniqueKey(); final UniqueKey key1 = UniqueKey();
...@@ -199,6 +196,7 @@ void main() { ...@@ -199,6 +196,7 @@ void main() {
await tester.pumpWidget(Container()); await tester.pumpWidget(Container());
final TestGesture gesture = await tester.createGesture(kind: PointerDeviceKind.mouse); final TestGesture gesture = await tester.createGesture(kind: PointerDeviceKind.mouse);
addTearDown(gesture.removePointer);
await gesture.moveTo(const Offset(400.0, 0.0)); await gesture.moveTo(const Offset(400.0, 0.0));
await tester.pump(); await tester.pump();
await tester.pumpWidget( await tester.pumpWidget(
...@@ -260,8 +258,6 @@ void main() { ...@@ -260,8 +258,6 @@ void main() {
expect(tester.binding.mouseTracker.isAnnotationAttached(renderListener1.hoverAnnotation), isTrue); expect(tester.binding.mouseTracker.isAnnotationAttached(renderListener1.hoverAnnotation), isTrue);
expect(tester.binding.mouseTracker.isAnnotationAttached(renderListener2.hoverAnnotation), isTrue); expect(tester.binding.mouseTracker.isAnnotationAttached(renderListener2.hoverAnnotation), isTrue);
clearLists(); clearLists();
await gesture.removePointer();
}); });
testWidgets('Hover transfers between two listeners', (WidgetTester tester) async { testWidgets('Hover transfers between two listeners', (WidgetTester tester) async {
final UniqueKey key1 = UniqueKey(); final UniqueKey key1 = UniqueKey();
...@@ -283,6 +279,7 @@ void main() { ...@@ -283,6 +279,7 @@ void main() {
await tester.pumpWidget(Container()); await tester.pumpWidget(Container());
final TestGesture gesture = await tester.createGesture(kind: PointerDeviceKind.mouse); final TestGesture gesture = await tester.createGesture(kind: PointerDeviceKind.mouse);
addTearDown(gesture.removePointer);
await gesture.moveTo(const Offset(400.0, 0.0)); await gesture.moveTo(const Offset(400.0, 0.0));
await tester.pump(); await tester.pump();
await tester.pumpWidget( await tester.pumpWidget(
...@@ -366,8 +363,6 @@ void main() { ...@@ -366,8 +363,6 @@ void main() {
expect(exit2, isEmpty); expect(exit2, isEmpty);
expect(tester.binding.mouseTracker.isAnnotationAttached(renderListener1.hoverAnnotation), isFalse); expect(tester.binding.mouseTracker.isAnnotationAttached(renderListener1.hoverAnnotation), isFalse);
expect(tester.binding.mouseTracker.isAnnotationAttached(renderListener2.hoverAnnotation), isFalse); expect(tester.binding.mouseTracker.isAnnotationAttached(renderListener2.hoverAnnotation), isFalse);
await gesture.removePointer();
}); });
testWidgets('needsCompositing set when parent class needsCompositing is set', (WidgetTester tester) async { testWidgets('needsCompositing set when parent class needsCompositing is set', (WidgetTester tester) async {
...@@ -436,6 +431,7 @@ void main() { ...@@ -436,6 +431,7 @@ void main() {
final TestGesture gesture = await tester.createGesture(kind: PointerDeviceKind.mouse); final TestGesture gesture = await tester.createGesture(kind: PointerDeviceKind.mouse);
await gesture.addPointer(); await gesture.addPointer();
addTearDown(gesture.removePointer);
await gesture.moveTo(topLeft - const Offset(1, 1)); await gesture.moveTo(topLeft - const Offset(1, 1));
await tester.pump(); await tester.pump();
expect(events, isEmpty); expect(events, isEmpty);
...@@ -457,14 +453,13 @@ void main() { ...@@ -457,14 +453,13 @@ void main() {
await tester.pump(); await tester.pump();
expect(events.single, isA<PointerExitEvent>()); expect(events.single, isA<PointerExitEvent>());
events.clear(); events.clear();
await gesture.removePointer();
}); });
testWidgets('needsCompositing updates correctly and is respected', (WidgetTester tester) async { testWidgets('needsCompositing updates correctly and is respected', (WidgetTester tester) async {
// Pretend that we have a mouse connected. // Pretend that we have a mouse connected.
final TestGesture gesture = await tester.createGesture(kind: PointerDeviceKind.mouse); final TestGesture gesture = await tester.createGesture(kind: PointerDeviceKind.mouse);
await gesture.addPointer(); await gesture.addPointer();
addTearDown(gesture.removePointer);
await tester.pumpWidget( await tester.pumpWidget(
Transform.scale( Transform.scale(
...@@ -508,13 +503,12 @@ void main() { ...@@ -508,13 +503,12 @@ void main() {
// TransformLayer for `Transform.scale` is removed again as transform is // TransformLayer for `Transform.scale` is removed again as transform is
// executed directly on the canvas. // executed directly on the canvas.
expect(tester.layers.whereType<TransformLayer>(), hasLength(1)); expect(tester.layers.whereType<TransformLayer>(), hasLength(1));
await gesture.removePointer();
}); });
testWidgets("Callbacks aren't called during build", (WidgetTester tester) async { testWidgets("Callbacks aren't called during build", (WidgetTester tester) async {
final TestGesture gesture = await tester.createGesture(kind: PointerDeviceKind.mouse); final TestGesture gesture = await tester.createGesture(kind: PointerDeviceKind.mouse);
await gesture.addPointer(); await gesture.addPointer();
addTearDown(gesture.removePointer);
await tester.pumpWidget( await tester.pumpWidget(
const Center(child: HoverFeedback()), const Center(child: HoverFeedback()),
...@@ -539,14 +533,13 @@ void main() { ...@@ -539,14 +533,13 @@ void main() {
await tester.pump(); await tester.pump();
expect(HoverClientState.numEntries, equals(2)); expect(HoverClientState.numEntries, equals(2));
expect(HoverClientState.numExits, equals(1)); expect(HoverClientState.numExits, equals(1));
await gesture.removePointer();
}); });
testWidgets("Listener activate/deactivate don't duplicate annotations", (WidgetTester tester) async { testWidgets("Listener activate/deactivate don't duplicate annotations", (WidgetTester tester) async {
final GlobalKey feedbackKey = GlobalKey(); final GlobalKey feedbackKey = GlobalKey();
final TestGesture gesture = await tester.createGesture(kind: PointerDeviceKind.mouse); final TestGesture gesture = await tester.createGesture(kind: PointerDeviceKind.mouse);
await gesture.addPointer(); await gesture.addPointer();
addTearDown(gesture.removePointer);
await tester.pumpWidget( await tester.pumpWidget(
Center(child: HoverFeedback(key: feedbackKey)), Center(child: HoverFeedback(key: feedbackKey)),
...@@ -570,8 +563,6 @@ void main() { ...@@ -570,8 +563,6 @@ void main() {
await tester.pump(); await tester.pump();
expect(HoverClientState.numEntries, equals(2)); expect(HoverClientState.numEntries, equals(2));
expect(HoverClientState.numExits, equals(2)); expect(HoverClientState.numExits, equals(2));
await gesture.removePointer();
}); });
testWidgets('Exit event when unplugging mouse should have a position', (WidgetTester tester) async { testWidgets('Exit event when unplugging mouse should have a position', (WidgetTester tester) async {
...@@ -594,8 +585,12 @@ void main() { ...@@ -594,8 +585,12 @@ void main() {
); );
// Plug-in a mouse and move it to the center of the container. // Plug-in a mouse and move it to the center of the container.
final TestGesture gesture = await tester.createGesture(kind: PointerDeviceKind.mouse); TestGesture gesture = await tester.createGesture(kind: PointerDeviceKind.mouse);
await gesture.addPointer(); await gesture.addPointer();
addTearDown(() async {
if (gesture != null)
return gesture.removePointer();
});
await gesture.moveTo(tester.getCenter(find.byType(Container))); await gesture.moveTo(tester.getCenter(find.byType(Container)));
await tester.pumpAndSettle(); await tester.pumpAndSettle();
...@@ -611,6 +606,7 @@ void main() { ...@@ -611,6 +606,7 @@ void main() {
// Unplug the mouse. // Unplug the mouse.
await gesture.removePointer(); await gesture.removePointer();
gesture = null;
await tester.pumpAndSettle(); await tester.pumpAndSettle();
expect(enter.length, 0); expect(enter.length, 0);
......
...@@ -155,6 +155,7 @@ void main() { ...@@ -155,6 +155,7 @@ void main() {
const Offset moved = Offset(20, 30); const Offset moved = Offset(20, 30);
final Offset center = tester.getCenter(find.byKey(key)); final Offset center = tester.getCenter(find.byKey(key));
final TestGesture gesture = await tester.startGesture(center); final TestGesture gesture = await tester.startGesture(center);
addTearDown(gesture.removePointer);
await gesture.moveBy(moved); await gesture.moveBy(moved);
await gesture.up(); await gesture.up();
...@@ -193,8 +194,6 @@ void main() { ...@@ -193,8 +194,6 @@ void main() {
expect(events.single.delta, Offset.zero); expect(events.single.delta, Offset.zero);
expect(events.single.localDelta, Offset.zero); expect(events.single.localDelta, Offset.zero);
expect(events.single.transform, expectedTransform); expect(events.single.transform, expectedTransform);
await gesture.removePointer();
}); });
testWidgets('scaled and offset for touch/signal', (WidgetTester tester) async { testWidgets('scaled and offset for touch/signal', (WidgetTester tester) async {
...@@ -234,6 +233,7 @@ void main() { ...@@ -234,6 +233,7 @@ void main() {
final Offset center = tester.getCenter(find.byKey(key)); final Offset center = tester.getCenter(find.byKey(key));
final Offset topLeft = tester.getTopLeft(find.byKey(key)); final Offset topLeft = tester.getTopLeft(find.byKey(key));
final TestGesture gesture = await tester.startGesture(center); final TestGesture gesture = await tester.startGesture(center);
addTearDown(gesture.removePointer);
await gesture.moveBy(moved); await gesture.moveBy(moved);
await gesture.up(); await gesture.up();
...@@ -273,8 +273,6 @@ void main() { ...@@ -273,8 +273,6 @@ void main() {
expect(events.single.delta, Offset.zero); expect(events.single.delta, Offset.zero);
expect(events.single.localDelta, Offset.zero); expect(events.single.localDelta, Offset.zero);
expect(events.single.transform, expectedTransform); expect(events.single.transform, expectedTransform);
await gesture.removePointer();
}); });
testWidgets('rotated for touch/signal', (WidgetTester tester) async { testWidgets('rotated for touch/signal', (WidgetTester tester) async {
...@@ -312,6 +310,7 @@ void main() { ...@@ -312,6 +310,7 @@ void main() {
const Offset moved = Offset(20, 30); const Offset moved = Offset(20, 30);
final Offset downPosition = tester.getCenter(find.byKey(key)) + const Offset(10, 5); final Offset downPosition = tester.getCenter(find.byKey(key)) + const Offset(10, 5);
final TestGesture gesture = await tester.startGesture(downPosition); final TestGesture gesture = await tester.startGesture(downPosition);
addTearDown(gesture.removePointer);
await gesture.moveBy(moved); await gesture.moveBy(moved);
await gesture.up(); await gesture.up();
...@@ -352,8 +351,6 @@ void main() { ...@@ -352,8 +351,6 @@ void main() {
expect(events.single.delta, Offset.zero); expect(events.single.delta, Offset.zero);
expect(events.single.localDelta, Offset.zero); expect(events.single.localDelta, Offset.zero);
expect(events.single.transform, expectedTransform); expect(events.single.transform, expectedTransform);
await gesture.removePointer();
}); });
}); });
} }
......
...@@ -100,6 +100,7 @@ void main() { ...@@ -100,6 +100,7 @@ void main() {
), ),
)); ));
final TestGesture gesture = await tester.createGesture(kind: PointerDeviceKind.mouse); final TestGesture gesture = await tester.createGesture(kind: PointerDeviceKind.mouse);
addTearDown(gesture.removePointer);
await gesture.moveTo(const Offset(400.0, 300.0)); await gesture.moveTo(const Offset(400.0, 300.0));
await tester.pump(); await tester.pump();
expect(move, isNotNull); expect(move, isNotNull);
...@@ -107,8 +108,6 @@ void main() { ...@@ -107,8 +108,6 @@ void main() {
expect(enter, isNotNull); expect(enter, isNotNull);
expect(enter.position, equals(const Offset(400.0, 300.0))); expect(enter.position, equals(const Offset(400.0, 300.0)));
expect(exit, isNull); expect(exit, isNull);
await gesture.removePointer();
}); });
testWidgets('detects pointer exiting', (WidgetTester tester) async { testWidgets('detects pointer exiting', (WidgetTester tester) async {
PointerEnterEvent enter; PointerEnterEvent enter;
...@@ -126,6 +125,7 @@ void main() { ...@@ -126,6 +125,7 @@ void main() {
), ),
)); ));
final TestGesture gesture = await tester.createGesture(kind: PointerDeviceKind.mouse); final TestGesture gesture = await tester.createGesture(kind: PointerDeviceKind.mouse);
addTearDown(gesture.removePointer);
await gesture.moveTo(const Offset(400.0, 300.0)); await gesture.moveTo(const Offset(400.0, 300.0));
await tester.pump(); await tester.pump();
move = null; move = null;
...@@ -136,8 +136,6 @@ void main() { ...@@ -136,8 +136,6 @@ void main() {
expect(enter, isNull); expect(enter, isNull);
expect(exit, isNotNull); expect(exit, isNotNull);
expect(exit.position, equals(const Offset(1.0, 1.0))); expect(exit.position, equals(const Offset(1.0, 1.0)));
await gesture.removePointer();
}); });
testWidgets('detects pointer exit when widget disappears', (WidgetTester tester) async { testWidgets('detects pointer exit when widget disappears', (WidgetTester tester) async {
PointerEnterEvent enter; PointerEnterEvent enter;
...@@ -156,6 +154,7 @@ void main() { ...@@ -156,6 +154,7 @@ void main() {
)); ));
final RenderMouseRegion renderListener = tester.renderObject(find.byType(MouseRegion)); final RenderMouseRegion renderListener = tester.renderObject(find.byType(MouseRegion));
final TestGesture gesture = await tester.createGesture(kind: PointerDeviceKind.mouse); final TestGesture gesture = await tester.createGesture(kind: PointerDeviceKind.mouse);
addTearDown(gesture.removePointer);
await gesture.moveTo(const Offset(400.0, 300.0)); await gesture.moveTo(const Offset(400.0, 300.0));
await tester.pump(); await tester.pump();
expect(move, isNotNull); expect(move, isNotNull);
...@@ -172,8 +171,6 @@ void main() { ...@@ -172,8 +171,6 @@ void main() {
expect(exit, isNotNull); expect(exit, isNotNull);
expect(exit.position, equals(const Offset(400.0, 300.0))); expect(exit.position, equals(const Offset(400.0, 300.0)));
expect(tester.binding.mouseTracker.isAnnotationAttached(renderListener.hoverAnnotation), isFalse); expect(tester.binding.mouseTracker.isAnnotationAttached(renderListener.hoverAnnotation), isFalse);
await gesture.removePointer();
}); });
testWidgets('Hover works with nested listeners', (WidgetTester tester) async { testWidgets('Hover works with nested listeners', (WidgetTester tester) async {
final UniqueKey key1 = UniqueKey(); final UniqueKey key1 = UniqueKey();
...@@ -195,6 +192,7 @@ void main() { ...@@ -195,6 +192,7 @@ void main() {
await tester.pumpWidget(Container()); await tester.pumpWidget(Container());
final TestGesture gesture = await tester.createGesture(kind: PointerDeviceKind.mouse); final TestGesture gesture = await tester.createGesture(kind: PointerDeviceKind.mouse);
addTearDown(gesture.removePointer);
await gesture.moveTo(const Offset(400.0, 0.0)); await gesture.moveTo(const Offset(400.0, 0.0));
await tester.pump(); await tester.pump();
await tester.pumpWidget( await tester.pumpWidget(
...@@ -255,8 +253,6 @@ void main() { ...@@ -255,8 +253,6 @@ void main() {
expect(tester.binding.mouseTracker.isAnnotationAttached(renderListener1.hoverAnnotation), isTrue); expect(tester.binding.mouseTracker.isAnnotationAttached(renderListener1.hoverAnnotation), isTrue);
expect(tester.binding.mouseTracker.isAnnotationAttached(renderListener2.hoverAnnotation), isTrue); expect(tester.binding.mouseTracker.isAnnotationAttached(renderListener2.hoverAnnotation), isTrue);
clearLists(); clearLists();
await gesture.removePointer();
}); });
testWidgets('Hover transfers between two listeners', (WidgetTester tester) async { testWidgets('Hover transfers between two listeners', (WidgetTester tester) async {
final UniqueKey key1 = UniqueKey(); final UniqueKey key1 = UniqueKey();
...@@ -278,6 +274,7 @@ void main() { ...@@ -278,6 +274,7 @@ void main() {
await tester.pumpWidget(Container()); await tester.pumpWidget(Container());
final TestGesture gesture = await tester.createGesture(kind: PointerDeviceKind.mouse); final TestGesture gesture = await tester.createGesture(kind: PointerDeviceKind.mouse);
addTearDown(gesture.removePointer);
await gesture.moveTo(const Offset(400.0, 0.0)); await gesture.moveTo(const Offset(400.0, 0.0));
await tester.pump(); await tester.pump();
await tester.pumpWidget( await tester.pumpWidget(
...@@ -360,8 +357,6 @@ void main() { ...@@ -360,8 +357,6 @@ void main() {
expect(exit2, isEmpty); expect(exit2, isEmpty);
expect(tester.binding.mouseTracker.isAnnotationAttached(renderListener1.hoverAnnotation), isFalse); expect(tester.binding.mouseTracker.isAnnotationAttached(renderListener1.hoverAnnotation), isFalse);
expect(tester.binding.mouseTracker.isAnnotationAttached(renderListener2.hoverAnnotation), isFalse); expect(tester.binding.mouseTracker.isAnnotationAttached(renderListener2.hoverAnnotation), isFalse);
await gesture.removePointer();
}); });
testWidgets('needsCompositing set when parent class needsCompositing is set', (WidgetTester tester) async { testWidgets('needsCompositing set when parent class needsCompositing is set', (WidgetTester tester) async {
...@@ -430,6 +425,7 @@ void main() { ...@@ -430,6 +425,7 @@ void main() {
final TestGesture gesture = await tester.createGesture(kind: PointerDeviceKind.mouse); final TestGesture gesture = await tester.createGesture(kind: PointerDeviceKind.mouse);
await gesture.addPointer(); await gesture.addPointer();
addTearDown(gesture.removePointer);
await gesture.moveTo(topLeft - const Offset(1, 1)); await gesture.moveTo(topLeft - const Offset(1, 1));
await tester.pump(); await tester.pump();
expect(events, isEmpty); expect(events, isEmpty);
...@@ -451,14 +447,13 @@ void main() { ...@@ -451,14 +447,13 @@ void main() {
await tester.pump(); await tester.pump();
expect(events.single, isA<PointerExitEvent>()); expect(events.single, isA<PointerExitEvent>());
events.clear(); events.clear();
await gesture.removePointer();
}); });
testWidgets('needsCompositing updates correctly and is respected', (WidgetTester tester) async { testWidgets('needsCompositing updates correctly and is respected', (WidgetTester tester) async {
// Pretend that we have a mouse connected. // Pretend that we have a mouse connected.
final TestGesture gesture = await tester.createGesture(kind: PointerDeviceKind.mouse); final TestGesture gesture = await tester.createGesture(kind: PointerDeviceKind.mouse);
await gesture.addPointer(); await gesture.addPointer();
addTearDown(gesture.removePointer);
await tester.pumpWidget( await tester.pumpWidget(
Transform.scale( Transform.scale(
...@@ -498,13 +493,12 @@ void main() { ...@@ -498,13 +493,12 @@ void main() {
// TransformLayer for `Transform.scale` is removed again as transform is // TransformLayer for `Transform.scale` is removed again as transform is
// executed directly on the canvas. // executed directly on the canvas.
expect(tester.layers.whereType<TransformLayer>(), hasLength(1)); expect(tester.layers.whereType<TransformLayer>(), hasLength(1));
await gesture.removePointer();
}); });
testWidgets("Callbacks aren't called during build", (WidgetTester tester) async { testWidgets("Callbacks aren't called during build", (WidgetTester tester) async {
final TestGesture gesture = await tester.createGesture(kind: PointerDeviceKind.mouse); final TestGesture gesture = await tester.createGesture(kind: PointerDeviceKind.mouse);
await gesture.addPointer(); await gesture.addPointer();
addTearDown(gesture.removePointer);
int numEntries = 0; int numEntries = 0;
int numExits = 0; int numExits = 0;
...@@ -538,14 +532,13 @@ void main() { ...@@ -538,14 +532,13 @@ void main() {
await tester.pump(); await tester.pump();
expect(numEntries, equals(2)); expect(numEntries, equals(2));
expect(numExits, equals(1)); expect(numExits, equals(1));
await gesture.removePointer();
}); });
testWidgets("MouseRegion activate/deactivate don't duplicate annotations", (WidgetTester tester) async { testWidgets("MouseRegion activate/deactivate don't duplicate annotations", (WidgetTester tester) async {
final GlobalKey feedbackKey = GlobalKey(); final GlobalKey feedbackKey = GlobalKey();
final TestGesture gesture = await tester.createGesture(kind: PointerDeviceKind.mouse); final TestGesture gesture = await tester.createGesture(kind: PointerDeviceKind.mouse);
await gesture.addPointer(); await gesture.addPointer();
addTearDown(gesture.removePointer);
int numEntries = 0; int numEntries = 0;
int numExits = 0; int numExits = 0;
...@@ -580,8 +573,6 @@ void main() { ...@@ -580,8 +573,6 @@ void main() {
await tester.pump(); await tester.pump();
expect(numEntries, equals(2)); expect(numEntries, equals(2));
expect(numExits, equals(2)); expect(numExits, equals(2));
await gesture.removePointer();
}); });
testWidgets('Exit event when unplugging mouse should have a position', (WidgetTester tester) async { testWidgets('Exit event when unplugging mouse should have a position', (WidgetTester tester) async {
...@@ -604,8 +595,9 @@ void main() { ...@@ -604,8 +595,9 @@ void main() {
); );
// Plug-in a mouse and move it to the center of the container. // Plug-in a mouse and move it to the center of the container.
final TestGesture gesture = await tester.createGesture(kind: PointerDeviceKind.mouse); TestGesture gesture = await tester.createGesture(kind: PointerDeviceKind.mouse);
await gesture.addPointer(); await gesture.addPointer();
addTearDown(() => gesture?.removePointer());
await gesture.moveTo(tester.getCenter(find.byType(Container))); await gesture.moveTo(tester.getCenter(find.byType(Container)));
await tester.pumpAndSettle(); await tester.pumpAndSettle();
...@@ -621,6 +613,7 @@ void main() { ...@@ -621,6 +613,7 @@ void main() {
// Unplug the mouse. // Unplug the mouse.
await gesture.removePointer(); await gesture.removePointer();
gesture = null;
await tester.pumpAndSettle(); await tester.pumpAndSettle();
expect(enter.length, 0); expect(enter.length, 0);
......
...@@ -549,6 +549,7 @@ void main() { ...@@ -549,6 +549,7 @@ void main() {
const int eIndex = 5; const int eIndex = 5;
final Offset ePos = textOffsetToPosition(tester, eIndex); final Offset ePos = textOffsetToPosition(tester, eIndex);
final TestGesture gesture = await tester.startGesture(ePos, kind: PointerDeviceKind.mouse); final TestGesture gesture = await tester.startGesture(ePos, kind: PointerDeviceKind.mouse);
addTearDown(gesture.removePointer);
await tester.pump(const Duration(seconds: 2)); await tester.pump(const Duration(seconds: 2));
await gesture.up(); await gesture.up();
await tester.pump(); await tester.pump();
...@@ -556,8 +557,6 @@ void main() { ...@@ -556,8 +557,6 @@ void main() {
// The cursor is placed just like a regular tap. // The cursor is placed just like a regular tap.
expect(editableText.controller.selection.baseOffset, eIndex); expect(editableText.controller.selection.baseOffset, eIndex);
expect(editableText.controller.selection.extentOffset, eIndex); expect(editableText.controller.selection.extentOffset, eIndex);
await gesture.removePointer();
}); });
testWidgets('selectable text basic', (WidgetTester tester) async { testWidgets('selectable text basic', (WidgetTester tester) async {
...@@ -631,6 +630,7 @@ void main() { ...@@ -631,6 +630,7 @@ void main() {
final Offset gPos = textOffsetToPosition(tester, 8); final Offset gPos = textOffsetToPosition(tester, 8);
final TestGesture gesture = await tester.startGesture(ePos, kind: PointerDeviceKind.mouse); final TestGesture gesture = await tester.startGesture(ePos, kind: PointerDeviceKind.mouse);
addTearDown(gesture.removePointer);
await tester.pump(); await tester.pump();
await gesture.moveTo(gPos); await gesture.moveTo(gPos);
await tester.pump(); await tester.pump();
...@@ -639,8 +639,6 @@ void main() { ...@@ -639,8 +639,6 @@ void main() {
expect(controller.selection.baseOffset, 5); expect(controller.selection.baseOffset, 5);
expect(controller.selection.extentOffset, 8); expect(controller.selection.extentOffset, 8);
await gesture.removePointer();
}); });
testWidgets('Continuous dragging does not cause flickering', (WidgetTester tester) async { testWidgets('Continuous dragging does not cause flickering', (WidgetTester tester) async {
...@@ -670,6 +668,7 @@ void main() { ...@@ -670,6 +668,7 @@ void main() {
// Drag from 'c' to 'g'. // Drag from 'c' to 'g'.
final TestGesture gesture = await tester.startGesture(cPos, kind: PointerDeviceKind.mouse); final TestGesture gesture = await tester.startGesture(cPos, kind: PointerDeviceKind.mouse);
addTearDown(gesture.removePointer);
await tester.pump(); await tester.pump();
await gesture.moveTo(gPos); await gesture.moveTo(gPos);
await tester.pumpAndSettle(); await tester.pumpAndSettle();
...@@ -693,8 +692,6 @@ void main() { ...@@ -693,8 +692,6 @@ void main() {
expect(selectionChangedCount, 1); expect(selectionChangedCount, 1);
expect(controller.selection.baseOffset, 2); expect(controller.selection.baseOffset, 2);
expect(controller.selection.extentOffset, 9); expect(controller.selection.extentOffset, 9);
await gesture.removePointer();
}); });
testWidgets('Dragging in opposite direction also works', (WidgetTester tester) async { testWidgets('Dragging in opposite direction also works', (WidgetTester tester) async {
...@@ -715,6 +712,7 @@ void main() { ...@@ -715,6 +712,7 @@ void main() {
final Offset gPos = textOffsetToPosition(tester, 8); final Offset gPos = textOffsetToPosition(tester, 8);
final TestGesture gesture = await tester.startGesture(gPos, kind: PointerDeviceKind.mouse); final TestGesture gesture = await tester.startGesture(gPos, kind: PointerDeviceKind.mouse);
addTearDown(gesture.removePointer);
await tester.pump(); await tester.pump();
await gesture.moveTo(ePos); await gesture.moveTo(ePos);
await tester.pump(); await tester.pump();
...@@ -723,8 +721,6 @@ void main() { ...@@ -723,8 +721,6 @@ void main() {
expect(controller.selection.baseOffset, 5); expect(controller.selection.baseOffset, 5);
expect(controller.selection.extentOffset, 8); expect(controller.selection.extentOffset, 8);
await gesture.removePointer();
}); });
testWidgets('Slow mouse dragging also selects text', (WidgetTester tester) async { testWidgets('Slow mouse dragging also selects text', (WidgetTester tester) async {
...@@ -745,6 +741,7 @@ void main() { ...@@ -745,6 +741,7 @@ void main() {
final Offset gPos = textOffsetToPosition(tester,8); final Offset gPos = textOffsetToPosition(tester,8);
final TestGesture gesture = await tester.startGesture(ePos, kind: PointerDeviceKind.mouse); final TestGesture gesture = await tester.startGesture(ePos, kind: PointerDeviceKind.mouse);
addTearDown(gesture.removePointer);
await tester.pump(const Duration(seconds: 2)); await tester.pump(const Duration(seconds: 2));
await gesture.moveTo(gPos); await gesture.moveTo(gPos);
await tester.pump(); await tester.pump();
...@@ -752,8 +749,6 @@ void main() { ...@@ -752,8 +749,6 @@ void main() {
expect(controller.selection.baseOffset, 5); expect(controller.selection.baseOffset, 5);
expect(controller.selection.extentOffset,8); expect(controller.selection.extentOffset,8);
await gesture.removePointer();
}); });
testWidgets('Can drag handles to change selection', (WidgetTester tester) async { testWidgets('Can drag handles to change selection', (WidgetTester tester) async {
...@@ -3665,6 +3660,7 @@ void main() { ...@@ -3665,6 +3660,7 @@ void main() {
pointer: 7, pointer: 7,
kind: PointerDeviceKind.mouse, kind: PointerDeviceKind.mouse,
); );
addTearDown(gesture.removePointer);
await tester.pump(); await tester.pump();
await gesture.up(); await gesture.up();
await tester.pump(); await tester.pump();
...@@ -3672,8 +3668,6 @@ void main() { ...@@ -3672,8 +3668,6 @@ void main() {
final EditableTextState editableText = tester.state(find.byType(EditableText)); final EditableTextState editableText = tester.state(find.byType(EditableText));
expect(editableText.selectionOverlay.toolbarIsVisible, isFalse); expect(editableText.selectionOverlay.toolbarIsVisible, isFalse);
expect(editableText.selectionOverlay.handlesAreVisible, isFalse); expect(editableText.selectionOverlay.handlesAreVisible, isFalse);
await gesture.removePointer();
}, },
); );
...@@ -3695,6 +3689,7 @@ void main() { ...@@ -3695,6 +3689,7 @@ void main() {
pointer: 7, pointer: 7,
kind: PointerDeviceKind.mouse, kind: PointerDeviceKind.mouse,
); );
addTearDown(gesture.removePointer);
await tester.pump(const Duration(seconds: 2)); await tester.pump(const Duration(seconds: 2));
await gesture.up(); await gesture.up();
await tester.pump(); await tester.pump();
...@@ -3702,8 +3697,6 @@ void main() { ...@@ -3702,8 +3697,6 @@ void main() {
final EditableTextState editableText = tester.state(find.byType(EditableText)); final EditableTextState editableText = tester.state(find.byType(EditableText));
expect(editableText.selectionOverlay.toolbarIsVisible, isFalse); expect(editableText.selectionOverlay.toolbarIsVisible, isFalse);
expect(editableText.selectionOverlay.handlesAreVisible, isFalse); expect(editableText.selectionOverlay.handlesAreVisible, isFalse);
await gesture.removePointer();
}, },
); );
...@@ -3725,6 +3718,7 @@ void main() { ...@@ -3725,6 +3718,7 @@ void main() {
pointer: 7, pointer: 7,
kind: PointerDeviceKind.mouse, kind: PointerDeviceKind.mouse,
); );
addTearDown(gesture.removePointer);
await tester.pump(const Duration(milliseconds: 50)); await tester.pump(const Duration(milliseconds: 50));
await gesture.up(); await gesture.up();
await tester.pump(); await tester.pump();
...@@ -3736,8 +3730,6 @@ void main() { ...@@ -3736,8 +3730,6 @@ void main() {
final EditableTextState editableText = tester.state(find.byType(EditableText)); final EditableTextState editableText = tester.state(find.byType(EditableText));
expect(editableText.selectionOverlay.toolbarIsVisible, isFalse); expect(editableText.selectionOverlay.toolbarIsVisible, isFalse);
expect(editableText.selectionOverlay.handlesAreVisible, isFalse); expect(editableText.selectionOverlay.handlesAreVisible, isFalse);
await gesture.removePointer();
}, },
); );
} }
...@@ -161,6 +161,7 @@ void main() { ...@@ -161,6 +161,7 @@ void main() {
testWidgets('a very quick swipe is ignored', (WidgetTester tester) async { testWidgets('a very quick swipe is ignored', (WidgetTester tester) async {
await pumpGestureDetector(tester); await pumpGestureDetector(tester);
final TestGesture gesture = await tester.startGesture(const Offset(200, 200)); final TestGesture gesture = await tester.startGesture(const Offset(200, 200));
addTearDown(gesture.removePointer);
await tester.pump(const Duration(milliseconds: 20)); await tester.pump(const Duration(milliseconds: 20));
await gesture.moveBy(const Offset(100, 100)); await gesture.moveBy(const Offset(100, 100));
await tester.pump(); await tester.pump();
...@@ -182,6 +183,7 @@ void main() { ...@@ -182,6 +183,7 @@ void main() {
testWidgets('a slower swipe has a tap down and a canceled tap', (WidgetTester tester) async { testWidgets('a slower swipe has a tap down and a canceled tap', (WidgetTester tester) async {
await pumpGestureDetector(tester); await pumpGestureDetector(tester);
final TestGesture gesture = await tester.startGesture(const Offset(200, 200)); final TestGesture gesture = await tester.startGesture(const Offset(200, 200));
addTearDown(gesture.removePointer);
await tester.pump(const Duration(milliseconds: 120)); await tester.pump(const Duration(milliseconds: 120));
await gesture.moveBy(const Offset(100, 100)); await gesture.moveBy(const Offset(100, 100));
await tester.pump(); await tester.pump();
...@@ -319,8 +321,12 @@ void main() { ...@@ -319,8 +321,12 @@ void main() {
await pumpGestureDetector(tester); await pumpGestureDetector(tester);
const int pointerValue = 1; const int pointerValue = 1;
final TestGesture gesture = final TestGesture gesture = await tester.startGesture(
await tester.startGesture(const Offset(200.0, 200.0), pointer: pointerValue, kind: PointerDeviceKind.touch); const Offset(200.0, 200.0),
pointer: pointerValue,
kind: PointerDeviceKind.touch,
);
addTearDown(gesture.removePointer);
await tester.pump(const Duration(seconds: 2)); await tester.pump(const Duration(seconds: 2));
await gesture.up(); await gesture.up();
await tester.pumpAndSettle(); await tester.pumpAndSettle();
...@@ -334,8 +340,12 @@ void main() { ...@@ -334,8 +340,12 @@ void main() {
await pumpGestureDetector(tester); await pumpGestureDetector(tester);
const int pointerValue = 1; const int pointerValue = 1;
final TestGesture gesture = final TestGesture gesture = await tester.startGesture(
await tester.startGesture(const Offset(200.0, 200.0), pointer: pointerValue, kind: PointerDeviceKind.mouse); const Offset(200.0, 200.0),
pointer: pointerValue,
kind: PointerDeviceKind.mouse,
);
addTearDown(gesture.removePointer);
await tester.pump(const Duration(seconds: 2)); await tester.pump(const Duration(seconds: 2));
await gesture.up(); await gesture.up();
await tester.pumpAndSettle(); await tester.pumpAndSettle();
...@@ -343,16 +353,18 @@ void main() { ...@@ -343,16 +353,18 @@ void main() {
expect(tapCount, 1); expect(tapCount, 1);
expect(singleTapUpCount, 1); expect(singleTapUpCount, 1);
expect(singleLongTapStartCount, 0); expect(singleLongTapStartCount, 0);
await gesture.removePointer();
}); });
testWidgets('a touch drag is not recognized for text selection', (WidgetTester tester) async { testWidgets('a touch drag is not recognized for text selection', (WidgetTester tester) async {
await pumpGestureDetector(tester); await pumpGestureDetector(tester);
const int pointerValue = 1; const int pointerValue = 1;
final TestGesture gesture = final TestGesture gesture = await tester.startGesture(
await tester.startGesture(const Offset(200.0, 200.0), pointer: pointerValue, kind: PointerDeviceKind.touch); const Offset(200.0, 200.0),
pointer: pointerValue,
kind: PointerDeviceKind.touch,
);
addTearDown(gesture.removePointer);
await tester.pump(); await tester.pump();
await gesture.moveBy(const Offset(210.0, 200.0)); await gesture.moveBy(const Offset(210.0, 200.0));
await tester.pump(); await tester.pump();
...@@ -364,16 +376,18 @@ void main() { ...@@ -364,16 +376,18 @@ void main() {
expect(dragStartCount, 0); expect(dragStartCount, 0);
expect(dragUpdateCount, 0); expect(dragUpdateCount, 0);
expect(dragEndCount, 0); expect(dragEndCount, 0);
await gesture.removePointer();
}); });
testWidgets('a mouse drag is recognized for text selection', (WidgetTester tester) async { testWidgets('a mouse drag is recognized for text selection', (WidgetTester tester) async {
await pumpGestureDetector(tester); await pumpGestureDetector(tester);
const int pointerValue = 1; const int pointerValue = 1;
final TestGesture gesture = final TestGesture gesture = await tester.startGesture(
await tester.startGesture(const Offset(200.0, 200.0), pointer: pointerValue, kind: PointerDeviceKind.mouse); const Offset(200.0, 200.0),
pointer: pointerValue,
kind: PointerDeviceKind.mouse,
);
addTearDown(gesture.removePointer);
await tester.pump(); await tester.pump();
await gesture.moveBy(const Offset(210.0, 200.0)); await gesture.moveBy(const Offset(210.0, 200.0));
await tester.pump(); await tester.pump();
...@@ -385,16 +399,18 @@ void main() { ...@@ -385,16 +399,18 @@ void main() {
expect(dragStartCount, 1); expect(dragStartCount, 1);
expect(dragUpdateCount, 1); expect(dragUpdateCount, 1);
expect(dragEndCount, 1); expect(dragEndCount, 1);
await gesture.removePointer();
}); });
testWidgets('a slow mouse drag is still recognized for text selection', (WidgetTester tester) async { testWidgets('a slow mouse drag is still recognized for text selection', (WidgetTester tester) async {
await pumpGestureDetector(tester); await pumpGestureDetector(tester);
const int pointerValue = 1; const int pointerValue = 1;
final TestGesture gesture = final TestGesture gesture = await tester.startGesture(
await tester.startGesture(const Offset(200.0, 200.0), pointer: pointerValue, kind: PointerDeviceKind.mouse); const Offset(200.0, 200.0),
pointer: pointerValue,
kind: PointerDeviceKind.mouse,
);
addTearDown(gesture.removePointer);
await tester.pump(const Duration(seconds: 2)); await tester.pump(const Duration(seconds: 2));
await gesture.moveBy(const Offset(210.0, 200.0)); await gesture.moveBy(const Offset(210.0, 200.0));
await tester.pump(); await tester.pump();
...@@ -404,14 +420,16 @@ void main() { ...@@ -404,14 +420,16 @@ void main() {
expect(dragStartCount, 1); expect(dragStartCount, 1);
expect(dragUpdateCount, 1); expect(dragUpdateCount, 1);
expect(dragEndCount, 1); expect(dragEndCount, 1);
await gesture.removePointer();
}); });
testWidgets('test TextSelectionGestureDetectorBuilder long press', (WidgetTester tester) async { testWidgets('test TextSelectionGestureDetectorBuilder long press', (WidgetTester tester) async {
await pumpTextSelectionGestureDetectorBuilder(tester); await pumpTextSelectionGestureDetectorBuilder(tester);
final TestGesture gesture = final TestGesture gesture = await tester.startGesture(
await tester.startGesture(const Offset(200.0, 200.0), pointer: 0, kind: PointerDeviceKind.touch); const Offset(200.0, 200.0),
pointer: 0,
kind: PointerDeviceKind.touch,
);
addTearDown(gesture.removePointer);
await tester.pump(const Duration(seconds: 2)); await tester.pump(const Duration(seconds: 2));
await gesture.up(); await gesture.up();
await tester.pumpAndSettle(); await tester.pumpAndSettle();
...@@ -424,8 +442,12 @@ void main() { ...@@ -424,8 +442,12 @@ void main() {
testWidgets('test TextSelectionGestureDetectorBuilder tap', (WidgetTester tester) async { testWidgets('test TextSelectionGestureDetectorBuilder tap', (WidgetTester tester) async {
await pumpTextSelectionGestureDetectorBuilder(tester); await pumpTextSelectionGestureDetectorBuilder(tester);
final TestGesture gesture = final TestGesture gesture = await tester.startGesture(
await tester.startGesture(const Offset(200.0, 200.0), pointer: 0, kind: PointerDeviceKind.touch); const Offset(200.0, 200.0),
pointer: 0,
kind: PointerDeviceKind.touch,
);
addTearDown(gesture.removePointer);
await gesture.up(); await gesture.up();
await tester.pumpAndSettle(); await tester.pumpAndSettle();
...@@ -437,8 +459,12 @@ void main() { ...@@ -437,8 +459,12 @@ void main() {
testWidgets('test TextSelectionGestureDetectorBuilder double tap', (WidgetTester tester) async { testWidgets('test TextSelectionGestureDetectorBuilder double tap', (WidgetTester tester) async {
await pumpTextSelectionGestureDetectorBuilder(tester); await pumpTextSelectionGestureDetectorBuilder(tester);
final TestGesture gesture = final TestGesture gesture = await tester.startGesture(
await tester.startGesture(const Offset(200.0, 200.0), pointer: 0, kind: PointerDeviceKind.touch); const Offset(200.0, 200.0),
pointer: 0,
kind: PointerDeviceKind.touch,
);
addTearDown(gesture.removePointer);
await tester.pump(const Duration(milliseconds: 50)); await tester.pump(const Duration(milliseconds: 50));
await gesture.up(); await gesture.up();
await gesture.down(const Offset(200.0, 200.0)); await gesture.down(const Offset(200.0, 200.0));
...@@ -455,6 +481,7 @@ void main() { ...@@ -455,6 +481,7 @@ void main() {
testWidgets('test TextSelectionGestureDetectorBuilder forcePress enabled', (WidgetTester tester) async { testWidgets('test TextSelectionGestureDetectorBuilder forcePress enabled', (WidgetTester tester) async {
await pumpTextSelectionGestureDetectorBuilder(tester); await pumpTextSelectionGestureDetectorBuilder(tester);
final TestGesture gesture = await tester.createGesture(); final TestGesture gesture = await tester.createGesture();
addTearDown(gesture.removePointer);
await gesture.downWithCustomEvent( await gesture.downWithCustomEvent(
const Offset(200.0, 200.0), const Offset(200.0, 200.0),
const PointerDownEvent( const PointerDownEvent(
...@@ -484,8 +511,12 @@ void main() { ...@@ -484,8 +511,12 @@ void main() {
testWidgets('test TextSelectionGestureDetectorBuilder selection disabled', (WidgetTester tester) async { testWidgets('test TextSelectionGestureDetectorBuilder selection disabled', (WidgetTester tester) async {
await pumpTextSelectionGestureDetectorBuilder(tester, selectionEnabled: false); await pumpTextSelectionGestureDetectorBuilder(tester, selectionEnabled: false);
final TestGesture gesture = final TestGesture gesture = await tester.startGesture(
await tester.startGesture(const Offset(200.0, 200.0), pointer: 0, kind: PointerDeviceKind.touch); const Offset(200.0, 200.0),
pointer: 0,
kind: PointerDeviceKind.touch,
);
addTearDown(gesture.removePointer);
await tester.pump(const Duration(seconds: 2)); await tester.pump(const Duration(seconds: 2));
await gesture.up(); await gesture.up();
await tester.pumpAndSettle(); await tester.pumpAndSettle();
...@@ -499,6 +530,7 @@ void main() { ...@@ -499,6 +530,7 @@ void main() {
testWidgets('test TextSelectionGestureDetectorBuilder forcePress disabled', (WidgetTester tester) async { testWidgets('test TextSelectionGestureDetectorBuilder forcePress disabled', (WidgetTester tester) async {
await pumpTextSelectionGestureDetectorBuilder(tester, forcePressEnabled: false); await pumpTextSelectionGestureDetectorBuilder(tester, forcePressEnabled: false);
final TestGesture gesture = await tester.createGesture(); final TestGesture gesture = await tester.createGesture();
addTearDown(gesture.removePointer);
await gesture.downWithCustomEvent( await gesture.downWithCustomEvent(
const Offset(200.0, 200.0), const Offset(200.0, 200.0),
const PointerDownEvent( const PointerDownEvent(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment