Unverified Commit f013b25b authored by Greg Spencer's avatar Greg Spencer Committed by GitHub

Add TargetPlatform.macOS tests to the widgets library. (#48997)

parent 3dbe90e1
...@@ -105,7 +105,7 @@ void main() { ...@@ -105,7 +105,7 @@ void main() {
expect(find.text('Item 1'), findsOneWidget); expect(find.text('Item 1'), findsOneWidget);
expect(find.text('Item 21'), findsOneWidget); expect(find.text('Item 21'), findsOneWidget);
expect(find.text('Item 31'), findsOneWidget); expect(find.text('Item 31'), findsOneWidget);
}, skip: isBrowser); }, skip: isBrowser, variant: TargetPlatformVariant.all());
testWidgets('Can be dragged down when not full height', (WidgetTester tester) async { testWidgets('Can be dragged down when not full height', (WidgetTester tester) async {
await tester.pumpWidget(_boilerplate(null)); await tester.pumpWidget(_boilerplate(null));
...@@ -118,7 +118,7 @@ void main() { ...@@ -118,7 +118,7 @@ void main() {
expect(find.text('Item 1'), findsOneWidget); expect(find.text('Item 1'), findsOneWidget);
expect(find.text('Item 21'), findsNothing); expect(find.text('Item 21'), findsNothing);
expect(find.text('Item 36'), findsNothing); expect(find.text('Item 36'), findsNothing);
}, skip: isBrowser); }, skip: isBrowser, variant: TargetPlatformVariant.all());
testWidgets('Can be dragged down when list is shorter than full height', (WidgetTester tester) async { testWidgets('Can be dragged down when list is shorter than full height', (WidgetTester tester) async {
await tester.pumpWidget(_boilerplate(null, itemCount: 30, initialChildSize: .25)); await tester.pumpWidget(_boilerplate(null, itemCount: 30, initialChildSize: .25));
...@@ -135,7 +135,7 @@ void main() { ...@@ -135,7 +135,7 @@ void main() {
await tester.pumpAndSettle(); await tester.pumpAndSettle();
expect(find.text('Item 1').hitTestable(), findsOneWidget); expect(find.text('Item 1').hitTestable(), findsOneWidget);
expect(find.text('Item 29').hitTestable(), findsNothing); expect(find.text('Item 29').hitTestable(), findsNothing);
}, skip: isBrowser); }, skip: isBrowser, variant: TargetPlatformVariant.all());
testWidgets('Can be dragged up and cover its container and scroll in single motion, and then dragged back down', (WidgetTester tester) async { testWidgets('Can be dragged up and cover its container and scroll in single motion, and then dragged back down', (WidgetTester tester) async {
int taps = 0; int taps = 0;
...@@ -164,7 +164,7 @@ void main() { ...@@ -164,7 +164,7 @@ void main() {
expect(find.text('Item 1'), findsOneWidget); expect(find.text('Item 1'), findsOneWidget);
expect(find.text('Item 18'), findsOneWidget); expect(find.text('Item 18'), findsOneWidget);
expect(find.text('Item 36'), findsNothing); expect(find.text('Item 36'), findsNothing);
}, skip: isBrowser); }, skip: isBrowser, variant: TargetPlatformVariant.all());
testWidgets('Can be flung up gently', (WidgetTester tester) async { testWidgets('Can be flung up gently', (WidgetTester tester) async {
int taps = 0; int taps = 0;
...@@ -187,7 +187,7 @@ void main() { ...@@ -187,7 +187,7 @@ void main() {
expect(find.text('Item 21'), findsOneWidget); expect(find.text('Item 21'), findsOneWidget);
expect(find.text('Item 36'), findsOneWidget); expect(find.text('Item 36'), findsOneWidget);
expect(find.text('Item 70'), findsNothing); expect(find.text('Item 70'), findsNothing);
}, skip: isBrowser); }, skip: isBrowser, variant: TargetPlatformVariant.all());
testWidgets('Can be flung up', (WidgetTester tester) async { testWidgets('Can be flung up', (WidgetTester tester) async {
int taps = 0; int taps = 0;
...@@ -208,7 +208,7 @@ void main() { ...@@ -208,7 +208,7 @@ void main() {
expect(find.text('Item 1'), findsNothing); expect(find.text('Item 1'), findsNothing);
expect(find.text('Item 21'), findsNothing); expect(find.text('Item 21'), findsNothing);
expect(find.text('Item 70'), findsOneWidget); expect(find.text('Item 70'), findsOneWidget);
}, skip: isBrowser); }, skip: isBrowser, variant: TargetPlatformVariant.all());
testWidgets('Can be flung down when not full height', (WidgetTester tester) async { testWidgets('Can be flung down when not full height', (WidgetTester tester) async {
await tester.pumpWidget(_boilerplate(null)); await tester.pumpWidget(_boilerplate(null));
...@@ -221,7 +221,7 @@ void main() { ...@@ -221,7 +221,7 @@ void main() {
expect(find.text('Item 1'), findsOneWidget); expect(find.text('Item 1'), findsOneWidget);
expect(find.text('Item 21'), findsNothing); expect(find.text('Item 21'), findsNothing);
expect(find.text('Item 36'), findsNothing); expect(find.text('Item 36'), findsNothing);
}, skip: isBrowser); }, skip: isBrowser, variant: TargetPlatformVariant.all());
testWidgets('Can be flung up and then back down', (WidgetTester tester) async { testWidgets('Can be flung up and then back down', (WidgetTester tester) async {
int taps = 0; int taps = 0;
...@@ -260,7 +260,7 @@ void main() { ...@@ -260,7 +260,7 @@ void main() {
expect(find.text('Item 1'), findsOneWidget); expect(find.text('Item 1'), findsOneWidget);
expect(find.text('Item 21'), findsNothing); expect(find.text('Item 21'), findsNothing);
expect(find.text('Item 70'), findsNothing); expect(find.text('Item 70'), findsNothing);
}, skip: isBrowser); }, skip: isBrowser, variant: TargetPlatformVariant.all());
debugDefaultTargetPlatformOverride = null; debugDefaultTargetPlatformOverride = null;
}); });
......
...@@ -304,9 +304,7 @@ void main() { ...@@ -304,9 +304,7 @@ void main() {
expect(buttonPressed, equals(true)); expect(buttonPressed, equals(true));
}); });
testWidgets('Dismissible ModalBarrier includes button in semantic tree on iOS', (WidgetTester tester) async { testWidgets('Dismissible ModalBarrier includes button in semantic tree', (WidgetTester tester) async {
debugDefaultTargetPlatformOverride = TargetPlatform.iOS;
final SemanticsTester semantics = SemanticsTester(tester); final SemanticsTester semantics = SemanticsTester(tester);
final GlobalKey<ScaffoldState> scaffoldKey = GlobalKey<ScaffoldState>(); final GlobalKey<ScaffoldState> scaffoldKey = GlobalKey<ScaffoldState>();
...@@ -331,9 +329,7 @@ void main() { ...@@ -331,9 +329,7 @@ void main() {
expect(semantics, includesNodeWith(label: 'Dismiss')); expect(semantics, includesNodeWith(label: 'Dismiss'));
semantics.dispose(); semantics.dispose();
}, variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.iOS, TargetPlatform.macOS }));
debugDefaultTargetPlatformOverride = null;
});
testWidgets('Dismissible ModalBarrier is hidden on Android (back button is used to dismiss)', (WidgetTester tester) async { testWidgets('Dismissible ModalBarrier is hidden on Android (back button is used to dismiss)', (WidgetTester tester) async {
final SemanticsTester semantics = SemanticsTester(tester); final SemanticsTester semantics = SemanticsTester(tester);
...@@ -361,7 +357,7 @@ void main() { ...@@ -361,7 +357,7 @@ void main() {
expect(semantics, isNot(includesNodeWith(label: 'Dismiss'))); expect(semantics, isNot(includesNodeWith(label: 'Dismiss')));
semantics.dispose(); semantics.dispose();
}); }, variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.android }));
testWidgets('Drawer contains route semantics flags', (WidgetTester tester) async { testWidgets('Drawer contains route semantics flags', (WidgetTester tester) async {
final SemanticsTester semantics = SemanticsTester(tester); final SemanticsTester semantics = SemanticsTester(tester);
......
...@@ -145,10 +145,9 @@ void main() { ...@@ -145,10 +145,9 @@ void main() {
); );
}); });
testWidgets('Cursor animates on iOS', (WidgetTester tester) async { testWidgets('Cursor animates', (WidgetTester tester) async {
final Widget widget = MaterialApp( const Widget widget = MaterialApp(
theme: ThemeData(platform: TargetPlatform.iOS), home: Material(
home: const Material(
child: TextField( child: TextField(
maxLines: 3, maxLines: 3,
), ),
...@@ -200,7 +199,7 @@ void main() { ...@@ -200,7 +199,7 @@ void main() {
// Cursor starts coming back. // Cursor starts coming back.
expect(renderEditable.cursorColor.alpha, 79); expect(renderEditable.cursorColor.alpha, 79);
expect(renderEditable, paints..rrect(color: const Color(0x4f2196f3))); expect(renderEditable, paints..rrect(color: const Color(0x4f2196f3)));
}); }, variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.iOS, TargetPlatform.macOS }));
testWidgets('Cursor does not animate on Android', (WidgetTester tester) async { testWidgets('Cursor does not animate on Android', (WidgetTester tester) async {
const Widget widget = MaterialApp( const Widget widget = MaterialApp(
...@@ -241,11 +240,10 @@ void main() { ...@@ -241,11 +240,10 @@ void main() {
expect(renderEditable, paintsExactlyCountTimes(#drawRect, 0)); expect(renderEditable, paintsExactlyCountTimes(#drawRect, 0));
}); });
testWidgets('Cursor does not animates on iOS when debugDeterministicCursor is set', (WidgetTester tester) async { testWidgets('Cursor does not animates when debugDeterministicCursor is set', (WidgetTester tester) async {
EditableText.debugDeterministicCursor = true; EditableText.debugDeterministicCursor = true;
final Widget widget = MaterialApp( const Widget widget = MaterialApp(
theme: ThemeData(platform: TargetPlatform.iOS), home: Material(
home: const Material(
child: TextField( child: TextField(
maxLines: 3, maxLines: 3,
), ),
...@@ -277,7 +275,7 @@ void main() { ...@@ -277,7 +275,7 @@ void main() {
expect(renderEditable, paints..rrect(color: const Color(0xff2196f3))); expect(renderEditable, paints..rrect(color: const Color(0xff2196f3)));
EditableText.debugDeterministicCursor = false; EditableText.debugDeterministicCursor = false;
}); }, variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.iOS, TargetPlatform.macOS }));
testWidgets('Cursor does not animate on Android when debugDeterministicCursor is set', (WidgetTester tester) async { testWidgets('Cursor does not animate on Android when debugDeterministicCursor is set', (WidgetTester tester) async {
EditableText.debugDeterministicCursor = true; EditableText.debugDeterministicCursor = true;
...@@ -346,10 +344,9 @@ void main() { ...@@ -346,10 +344,9 @@ void main() {
expect(renderEditable, paintsExactlyCountTimes(#drawRect, 0)); expect(renderEditable, paintsExactlyCountTimes(#drawRect, 0));
}); });
testWidgets('Cursor radius is 2.0 on iOS', (WidgetTester tester) async { testWidgets('Cursor radius is 2.0', (WidgetTester tester) async {
final Widget widget = MaterialApp( const Widget widget = MaterialApp(
theme: ThemeData(platform: TargetPlatform.iOS), home: Material(
home: const Material(
child: TextField( child: TextField(
maxLines: 3, maxLines: 3,
), ),
...@@ -361,7 +358,7 @@ void main() { ...@@ -361,7 +358,7 @@ void main() {
final RenderEditable renderEditable = editableTextState.renderEditable; final RenderEditable renderEditable = editableTextState.renderEditable;
expect(renderEditable.cursorRadius, const Radius.circular(2.0)); expect(renderEditable.cursorRadius, const Radius.circular(2.0));
}); }, variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.iOS, TargetPlatform.macOS }));
testWidgets('Cursor gets placed correctly after going out of bounds', (WidgetTester tester) async { testWidgets('Cursor gets placed correctly after going out of bounds', (WidgetTester tester) async {
const String text = 'hello world this is fun and cool and awesome!'; const String text = 'hello world this is fun and cool and awesome!';
...@@ -645,9 +642,7 @@ void main() { ...@@ -645,9 +642,7 @@ void main() {
expect(controller.selection.baseOffset, text.length); expect(controller.selection.baseOffset, text.length);
}, skip: isBrowser); }, skip: isBrowser);
testWidgets('Floating cursor is painted on iOS', (WidgetTester tester) async { testWidgets('Floating cursor is painted', (WidgetTester tester) async {
debugDefaultTargetPlatformOverride = TargetPlatform.iOS;
final TextEditingController controller = TextEditingController(); final TextEditingController controller = TextEditingController();
const TextStyle textStyle = TextStyle(); const TextStyle textStyle = TextStyle();
const String text = 'hello world this is fun and cool and awesome!'; const String text = 'hello world this is fun and cool and awesome!';
...@@ -656,7 +651,6 @@ void main() { ...@@ -656,7 +651,6 @@ void main() {
await tester.pumpWidget( await tester.pumpWidget(
MaterialApp( MaterialApp(
theme: ThemeData(platform: TargetPlatform.iOS),
home: Padding( home: Padding(
padding: const EdgeInsets.only(top: 0.25), padding: const EdgeInsets.only(top: 0.25),
child: Material( child: Material(
...@@ -731,16 +725,13 @@ void main() { ...@@ -731,16 +725,13 @@ void main() {
editableTextState.updateFloatingCursor(RawFloatingCursorPoint(state: FloatingCursorDragState.End)); editableTextState.updateFloatingCursor(RawFloatingCursorPoint(state: FloatingCursorDragState.End));
await tester.pumpAndSettle(); await tester.pumpAndSettle();
debugDefaultTargetPlatformOverride = null; debugDefaultTargetPlatformOverride = null;
}, skip: isBrowser); }, skip: isBrowser, variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.iOS, TargetPlatform.macOS }));
testWidgets('cursor layout iOS', (WidgetTester tester) async { testWidgets('cursor layout', (WidgetTester tester) async {
final GlobalKey<EditableTextState> editableTextKey = GlobalKey<EditableTextState>(); final GlobalKey<EditableTextState> editableTextKey = GlobalKey<EditableTextState>();
debugDefaultTargetPlatformOverride = TargetPlatform.iOS;
String changedValue; String changedValue;
final Widget widget = MaterialApp( final Widget widget = MaterialApp(
theme: ThemeData(platform: TargetPlatform.iOS),
home: RepaintBoundary( home: RepaintBoundary(
key: const ValueKey<int>(1), key: const ValueKey<int>(1),
child: Column( child: Column(
...@@ -751,7 +742,7 @@ void main() { ...@@ -751,7 +742,7 @@ void main() {
key: editableTextKey, key: editableTextKey,
controller: TextEditingController(), controller: TextEditingController(),
focusNode: FocusNode(), focusNode: FocusNode(),
style: Typography(platform: TargetPlatform.iOS).black.subhead, style: Typography(platform: debugDefaultTargetPlatformOverride).black.subhead,
cursorColor: Colors.blue, cursorColor: Colors.blue,
selectionControls: materialTextSelectionControls, selectionControls: materialTextSelectionControls,
keyboardType: TextInputType.text, keyboardType: TextInputType.text,
...@@ -793,6 +784,5 @@ void main() { ...@@ -793,6 +784,5 @@ void main() {
find.byKey(const ValueKey<int>(1)), find.byKey(const ValueKey<int>(1)),
matchesGoldenFile('editable_text_test.2.png'), matchesGoldenFile('editable_text_test.2.png'),
); );
debugDefaultTargetPlatformOverride = null; }, variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.iOS, TargetPlatform.macOS }));
});
} }
...@@ -3757,9 +3757,7 @@ void main() { ...@@ -3757,9 +3757,7 @@ void main() {
}); });
// Regression test for https://github.com/flutter/flutter/issues/31287 // Regression test for https://github.com/flutter/flutter/issues/31287
testWidgets('iOS text selection handle visibility', (WidgetTester tester) async { testWidgets('text selection handle visibility', (WidgetTester tester) async {
debugDefaultTargetPlatformOverride = TargetPlatform.iOS;
// Text with two separate words to select. // Text with two separate words to select.
const String testText = 'XXXXX XXXXX'; const String testText = 'XXXXX XXXXX';
final TextEditingController controller = TextEditingController(text: testText); final TextEditingController controller = TextEditingController(text: testText);
...@@ -3774,7 +3772,7 @@ void main() { ...@@ -3774,7 +3772,7 @@ void main() {
showSelectionHandles: true, showSelectionHandles: true,
controller: controller, controller: controller,
focusNode: FocusNode(), focusNode: FocusNode(),
style: Typography(platform: TargetPlatform.iOS).black.subhead, style: Typography(platform: debugDefaultTargetPlatformOverride).black.subhead,
cursorColor: Colors.blue, cursorColor: Colors.blue,
backgroundCursorColor: Colors.grey, backgroundCursorColor: Colors.grey,
selectionControls: cupertinoTextSelectionControls, selectionControls: cupertinoTextSelectionControls,
...@@ -3924,9 +3922,7 @@ void main() { ...@@ -3924,9 +3922,7 @@ void main() {
// at all. Again, both handles should be invisible. // at all. Again, both handles should be invisible.
scrollable.controller.jumpTo(0); scrollable.controller.jumpTo(0);
await verifyVisibility(HandlePositionInViewport.rightEdge, false, HandlePositionInViewport.rightEdge, false); await verifyVisibility(HandlePositionInViewport.rightEdge, false, HandlePositionInViewport.rightEdge, false);
}, skip: isBrowser, variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.iOS, TargetPlatform.macOS }));
debugDefaultTargetPlatformOverride = null;
}, skip: isBrowser);
testWidgets('scrolling doesn\'t bounce', (WidgetTester tester) async { testWidgets('scrolling doesn\'t bounce', (WidgetTester tester) async {
// 3 lines of text, where the last line overflows and requires scrolling. // 3 lines of text, where the last line overflows and requires scrolling.
......
...@@ -1614,9 +1614,6 @@ Future<void> main() async { ...@@ -1614,9 +1614,6 @@ Future<void> main() async {
testWidgets('Heroes do not transition on back gestures by default', (WidgetTester tester) async { testWidgets('Heroes do not transition on back gestures by default', (WidgetTester tester) async {
await tester.pumpWidget(MaterialApp( await tester.pumpWidget(MaterialApp(
theme: ThemeData(
platform: TargetPlatform.iOS,
),
routes: routes, routes: routes,
)); ));
...@@ -1652,14 +1649,11 @@ Future<void> main() async { ...@@ -1652,14 +1649,11 @@ Future<void> main() async {
expect(find.byKey(firstKey), isInCard); expect(find.byKey(firstKey), isInCard);
expect(find.byKey(secondKey), isOnstage); expect(find.byKey(secondKey), isOnstage);
expect(find.byKey(secondKey), isInCard); expect(find.byKey(secondKey), isInCard);
}); }, variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.iOS, TargetPlatform.macOS }));
testWidgets('Heroes can transition on gesture in one frame', (WidgetTester tester) async { testWidgets('Heroes can transition on gesture in one frame', (WidgetTester tester) async {
transitionFromUserGestures = true; transitionFromUserGestures = true;
await tester.pumpWidget(MaterialApp( await tester.pumpWidget(MaterialApp(
theme: ThemeData(
platform: TargetPlatform.iOS,
),
routes: routes, routes: routes,
)); ));
...@@ -1698,14 +1692,11 @@ Future<void> main() async { ...@@ -1698,14 +1692,11 @@ Future<void> main() async {
expect(find.byKey(firstKey), isOnstage); expect(find.byKey(firstKey), isOnstage);
expect(find.byKey(firstKey), isInCard); expect(find.byKey(firstKey), isInCard);
expect(find.byKey(secondKey), findsNothing); expect(find.byKey(secondKey), findsNothing);
}); }, variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.iOS, TargetPlatform.macOS }));
testWidgets('Heroes animate should hide destination hero and display original hero in case of dismissed', (WidgetTester tester) async { testWidgets('Heroes animate should hide destination hero and display original hero in case of dismissed', (WidgetTester tester) async {
transitionFromUserGestures = true; transitionFromUserGestures = true;
await tester.pumpWidget(MaterialApp( await tester.pumpWidget(MaterialApp(
theme: ThemeData(
platform: TargetPlatform.iOS,
),
routes: routes, routes: routes,
)); ));
...@@ -1737,7 +1728,7 @@ Future<void> main() async { ...@@ -1737,7 +1728,7 @@ Future<void> main() async {
expect(find.byKey(firstKey), findsNothing); expect(find.byKey(firstKey), findsNothing);
expect(find.byKey(secondKey), isOnstage); expect(find.byKey(secondKey), isOnstage);
expect(find.byKey(secondKey), isInCard); expect(find.byKey(secondKey), isInCard);
}); }, variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.iOS, TargetPlatform.macOS }));
testWidgets('Handles transitions when a non-default initial route is set', (WidgetTester tester) async { testWidgets('Handles transitions when a non-default initial route is set', (WidgetTester tester) async {
await tester.pumpWidget(MaterialApp( await tester.pumpWidget(MaterialApp(
...@@ -2298,9 +2289,6 @@ Future<void> main() async { ...@@ -2298,9 +2289,6 @@ Future<void> main() async {
testWidgets('Remove user gesture driven flights when the gesture is invalid', (WidgetTester tester) async { testWidgets('Remove user gesture driven flights when the gesture is invalid', (WidgetTester tester) async {
transitionFromUserGestures = true; transitionFromUserGestures = true;
await tester.pumpWidget(MaterialApp( await tester.pumpWidget(MaterialApp(
theme: ThemeData(
platform: TargetPlatform.iOS,
),
routes: routes, routes: routes,
)); ));
...@@ -2324,7 +2312,7 @@ Future<void> main() async { ...@@ -2324,7 +2312,7 @@ Future<void> main() async {
// The simple route should still be on top. // The simple route should still be on top.
expect(find.byKey(simpleKey), findsOneWidget); expect(find.byKey(simpleKey), findsOneWidget);
expect(tester.takeException(), isNull); expect(tester.takeException(), isNull);
}); }, variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.iOS, TargetPlatform.macOS }));
// Regression test for https://github.com/flutter/flutter/issues/40239. // Regression test for https://github.com/flutter/flutter/issues/40239.
testWidgets( testWidgets(
......
...@@ -1203,8 +1203,6 @@ void main() { ...@@ -1203,8 +1203,6 @@ void main() {
}); });
testWidgets('high fling velocities lands exactly on items', (WidgetTester tester) async { testWidgets('high fling velocities lands exactly on items', (WidgetTester tester) async {
debugDefaultTargetPlatformOverride = TargetPlatform.iOS;
final FixedExtentScrollController controller = FixedExtentScrollController(initialItem: 40); final FixedExtentScrollController controller = FixedExtentScrollController(initialItem: 40);
final List<double> scrolledPositions = <double>[]; final List<double> scrolledPositions = <double>[];
...@@ -1252,9 +1250,7 @@ void main() { ...@@ -1252,9 +1250,7 @@ void main() {
expect(controller.selectedItem, 49); expect(controller.selectedItem, 49);
// More importantly, lands tightly on 49. // More importantly, lands tightly on 49.
expect(scrolledPositions.last, moreOrLessEquals(49 * 100.0, epsilon: 0.3)); expect(scrolledPositions.last, moreOrLessEquals(49 * 100.0, epsilon: 0.3));
}, variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.iOS, TargetPlatform.macOS }));
debugDefaultTargetPlatformOverride = null;
});
}); });
testWidgets('ListWheelScrollView getOffsetToReveal', (WidgetTester tester) async { testWidgets('ListWheelScrollView getOffsetToReveal', (WidgetTester tester) async {
......
...@@ -340,8 +340,6 @@ void main() { ...@@ -340,8 +340,6 @@ void main() {
}); });
testWidgets('Dismissible ModalBarrier includes button in semantic tree on iOS', (WidgetTester tester) async { testWidgets('Dismissible ModalBarrier includes button in semantic tree on iOS', (WidgetTester tester) async {
debugDefaultTargetPlatformOverride = TargetPlatform.iOS;
final SemanticsTester semantics = SemanticsTester(tester); final SemanticsTester semantics = SemanticsTester(tester);
await tester.pumpWidget(const Directionality( await tester.pumpWidget(const Directionality(
textDirection: TextDirection.ltr, textDirection: TextDirection.ltr,
...@@ -364,8 +362,7 @@ void main() { ...@@ -364,8 +362,7 @@ void main() {
expect(semantics, hasSemantics(expectedSemantics, ignoreId: true)); expect(semantics, hasSemantics(expectedSemantics, ignoreId: true));
semantics.dispose(); semantics.dispose();
debugDefaultTargetPlatformOverride = null; }, variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.iOS, TargetPlatform.macOS }));
});
testWidgets('Dismissible ModalBarrier is hidden on Android (back button is used to dismiss)', (WidgetTester tester) async { testWidgets('Dismissible ModalBarrier is hidden on Android (back button is used to dismiss)', (WidgetTester tester) async {
final SemanticsTester semantics = SemanticsTester(tester); final SemanticsTester semantics = SemanticsTester(tester);
......
...@@ -113,7 +113,6 @@ Widget buildTest({ ScrollController controller, String title = 'TTTTTTTT' }) { ...@@ -113,7 +113,6 @@ Widget buildTest({ ScrollController controller, String title = 'TTTTTTTT' }) {
void main() { void main() {
testWidgets('NestedScrollView overscroll and release and hold', (WidgetTester tester) async { testWidgets('NestedScrollView overscroll and release and hold', (WidgetTester tester) async {
debugDefaultTargetPlatformOverride = TargetPlatform.iOS;
await tester.pumpWidget(buildTest()); await tester.pumpWidget(buildTest());
expect(find.text('aaa2'), findsOneWidget); expect(find.text('aaa2'), findsOneWidget);
await tester.pump(const Duration(milliseconds: 250)); await tester.pump(const Duration(milliseconds: 250));
...@@ -128,10 +127,8 @@ void main() { ...@@ -128,10 +127,8 @@ void main() {
// TODO(ianh): Once we improve how we handle scrolling down from overscroll, // TODO(ianh): Once we improve how we handle scrolling down from overscroll,
// the following expectation should switch to 200.0. // the following expectation should switch to 200.0.
expect(tester.renderObject<RenderBox>(find.byType(AppBar)).size.height, 120.0); expect(tester.renderObject<RenderBox>(find.byType(AppBar)).size.height, 120.0);
debugDefaultTargetPlatformOverride = null; }, variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.iOS, TargetPlatform.macOS }));
});
testWidgets('NestedScrollView overscroll and release and hold', (WidgetTester tester) async { testWidgets('NestedScrollView overscroll and release and hold', (WidgetTester tester) async {
debugDefaultTargetPlatformOverride = TargetPlatform.iOS;
await tester.pumpWidget(buildTest()); await tester.pumpWidget(buildTest());
expect(find.text('aaa2'), findsOneWidget); expect(find.text('aaa2'), findsOneWidget);
await tester.pump(const Duration(milliseconds: 250)); await tester.pump(const Duration(milliseconds: 250));
...@@ -149,10 +146,8 @@ void main() { ...@@ -149,10 +146,8 @@ void main() {
await tester.pump(const Duration(milliseconds: 10)); await tester.pump(const Duration(milliseconds: 10));
expect(find.text('aaa2'), findsNothing); expect(find.text('aaa2'), findsNothing);
await tester.pump(const Duration(milliseconds: 1000)); await tester.pump(const Duration(milliseconds: 1000));
debugDefaultTargetPlatformOverride = null; }, variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.iOS, TargetPlatform.macOS }));
});
testWidgets('NestedScrollView overscroll and release', (WidgetTester tester) async { testWidgets('NestedScrollView overscroll and release', (WidgetTester tester) async {
debugDefaultTargetPlatformOverride = TargetPlatform.iOS;
await tester.pumpWidget(buildTest()); await tester.pumpWidget(buildTest());
expect(find.text('aaa2'), findsOneWidget); expect(find.text('aaa2'), findsOneWidget);
await tester.pump(const Duration(milliseconds: 500)); await tester.pump(const Duration(milliseconds: 500));
...@@ -164,8 +159,10 @@ void main() { ...@@ -164,8 +159,10 @@ void main() {
await gesture1.up(); await gesture1.up();
await tester.pumpAndSettle(); await tester.pumpAndSettle();
expect(find.text('aaa2'), findsOneWidget); expect(find.text('aaa2'), findsOneWidget);
debugDefaultTargetPlatformOverride = null; },
}, skip: true); // https://github.com/flutter/flutter/issues/9040 skip: true, // https://github.com/flutter/flutter/issues/9040
variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.iOS, TargetPlatform.macOS }));
testWidgets('NestedScrollView', (WidgetTester tester) async { testWidgets('NestedScrollView', (WidgetTester tester) async {
await tester.pumpWidget(buildTest()); await tester.pumpWidget(buildTest());
expect(find.text('aaa2'), findsOneWidget); expect(find.text('aaa2'), findsOneWidget);
...@@ -610,12 +607,11 @@ void main() { ...@@ -610,12 +607,11 @@ void main() {
debugDisableShadows = true; debugDisableShadows = true;
}); });
testWidgets('NestedScrollView and iOS bouncing', (WidgetTester tester) async { testWidgets('NestedScrollView and bouncing', (WidgetTester tester) async {
// This verifies that overscroll bouncing works correctly on iOS. For // This verifies that overscroll bouncing works correctly on iOS. For
// example, this checks that if you pull to overscroll, friction is applied; // example, this checks that if you pull to overscroll, friction is applied;
// it also makes sure that if you scroll back the other way, the scroll // it also makes sure that if you scroll back the other way, the scroll
// positions of the inner and outer list don't have a discontinuity. // positions of the inner and outer list don't have a discontinuity.
debugDefaultTargetPlatformOverride = TargetPlatform.iOS;
const Key key1 = ValueKey<int>(1); const Key key1 = ValueKey<int>(1);
const Key key2 = ValueKey<int>(2); const Key key2 = ValueKey<int>(2);
await tester.pumpWidget( await tester.pumpWidget(
...@@ -674,8 +670,7 @@ void main() { ...@@ -674,8 +670,7 @@ void main() {
await tester.pump(); await tester.pump();
expect(tester.getRect(find.byKey(key1)), const Rect.fromLTWH(0.0, 0.0, 800.0, 100.0)); expect(tester.getRect(find.byKey(key1)), const Rect.fromLTWH(0.0, 0.0, 800.0, 100.0));
await gesture.up(); await gesture.up();
debugDefaultTargetPlatformOverride = null; }, variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.iOS, TargetPlatform.macOS }));
});
} }
class TestHeader extends SliverPersistentHeaderDelegate { class TestHeader extends SliverPersistentHeaderDelegate {
......
...@@ -157,10 +157,7 @@ void main() { ...@@ -157,10 +157,7 @@ void main() {
), ),
}; };
await tester.pumpWidget(MaterialApp( await tester.pumpWidget(MaterialApp(routes: routes));
routes: routes,
theme: ThemeData(platform: TargetPlatform.iOS),
));
Navigator.pushNamed(containerKey1.currentContext, '/settings'); Navigator.pushNamed(containerKey1.currentContext, '/settings');
...@@ -199,7 +196,7 @@ void main() { ...@@ -199,7 +196,7 @@ void main() {
settingsOffset = tester.getTopLeft(find.text('Settings')); settingsOffset = tester.getTopLeft(find.text('Settings'));
expect(settingsOffset.dx, greaterThan(100.0)); expect(settingsOffset.dx, greaterThan(100.0));
expect(settingsOffset.dy, 100.0); expect(settingsOffset.dy, 100.0);
}); }, variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.iOS, TargetPlatform.macOS }));
testWidgets('Check back gesture doesn\'t start during transitions', (WidgetTester tester) async { testWidgets('Check back gesture doesn\'t start during transitions', (WidgetTester tester) async {
final GlobalKey containerKey1 = GlobalKey(); final GlobalKey containerKey1 = GlobalKey();
...@@ -209,10 +206,7 @@ void main() { ...@@ -209,10 +206,7 @@ void main() {
'/settings': (_) => Scaffold(key: containerKey2, body: const Text('Settings')), '/settings': (_) => Scaffold(key: containerKey2, body: const Text('Settings')),
}; };
await tester.pumpWidget(MaterialApp( await tester.pumpWidget(MaterialApp(routes: routes));
routes: routes,
theme: ThemeData(platform: TargetPlatform.iOS),
));
Navigator.pushNamed(containerKey1.currentContext, '/settings'); Navigator.pushNamed(containerKey1.currentContext, '/settings');
...@@ -245,7 +239,7 @@ void main() { ...@@ -245,7 +239,7 @@ void main() {
expect(find.text('Home'), isOnstage); expect(find.text('Home'), isOnstage);
expect(find.text('Settings'), findsNothing); expect(find.text('Settings'), findsNothing);
}); }, variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.iOS, TargetPlatform.macOS }));
// Tests bug https://github.com/flutter/flutter/issues/6451 // Tests bug https://github.com/flutter/flutter/issues/6451
testWidgets('Check back gesture with a persistent bottom sheet showing', (WidgetTester tester) async { testWidgets('Check back gesture with a persistent bottom sheet showing', (WidgetTester tester) async {
...@@ -256,10 +250,7 @@ void main() { ...@@ -256,10 +250,7 @@ void main() {
'/sheet': (_) => PersistentBottomSheetTest(key: containerKey2), '/sheet': (_) => PersistentBottomSheetTest(key: containerKey2),
}; };
await tester.pumpWidget(MaterialApp( await tester.pumpWidget(MaterialApp(routes: routes));
routes: routes,
theme: ThemeData(platform: TargetPlatform.iOS),
));
Navigator.pushNamed(containerKey1.currentContext, '/sheet'); Navigator.pushNamed(containerKey1.currentContext, '/sheet');
...@@ -302,7 +293,7 @@ void main() { ...@@ -302,7 +293,7 @@ void main() {
// Sheet did not call setState (since the gesture did nothing). // Sheet did not call setState (since the gesture did nothing).
expect(sheet.setStateCalled, isFalse); expect(sheet.setStateCalled, isFalse);
}); }, variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.iOS, TargetPlatform.macOS }));
testWidgets('Test completed future', (WidgetTester tester) async { testWidgets('Test completed future', (WidgetTester tester) async {
final Map<String, WidgetBuilder> routes = <String, WidgetBuilder>{ final Map<String, WidgetBuilder> routes = <String, WidgetBuilder>{
......
...@@ -83,7 +83,6 @@ void main() { ...@@ -83,7 +83,6 @@ void main() {
testWidgets('PageView does not squish when overscrolled', (WidgetTester tester) async { testWidgets('PageView does not squish when overscrolled', (WidgetTester tester) async {
await tester.pumpWidget(MaterialApp( await tester.pumpWidget(MaterialApp(
theme: ThemeData(platform: TargetPlatform.iOS),
home: PageView( home: PageView(
children: List<Widget>.generate(10, (int i) { children: List<Widget>.generate(10, (int i) {
return Container( return Container(
...@@ -113,7 +112,7 @@ void main() { ...@@ -113,7 +112,7 @@ void main() {
expect(leftOf(0), lessThan(0.0)); expect(leftOf(0), lessThan(0.0));
expect(sizeOf(0), equals(const Size(800.0, 600.0))); expect(sizeOf(0), equals(const Size(800.0, 600.0)));
}); }, variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.iOS, TargetPlatform.macOS }));
testWidgets('PageController control test', (WidgetTester tester) async { testWidgets('PageController control test', (WidgetTester tester) async {
final PageController controller = PageController(initialPage: 4); final PageController controller = PageController(initialPage: 4);
......
...@@ -28,10 +28,9 @@ void main() { ...@@ -28,10 +28,9 @@ void main() {
await tester.pump(const Duration(hours: 5)); await tester.pump(const Duration(hours: 5));
}); });
testWidgets('Disposing a (nested) Scrollable while holding in overscroll (iOS) does not crash', (WidgetTester tester) async { testWidgets('Disposing a (nested) Scrollable while holding in overscroll does not crash', (WidgetTester tester) async {
// Regression test for https://github.com/flutter/flutter/issues/27707. // Regression test for https://github.com/flutter/flutter/issues/27707.
debugDefaultTargetPlatformOverride = TargetPlatform.iOS;
final ScrollController controller = ScrollController(); final ScrollController controller = ScrollController();
final Key outterContainer = GlobalKey(); final Key outterContainer = GlobalKey();
...@@ -88,7 +87,5 @@ void main() { ...@@ -88,7 +87,5 @@ void main() {
); );
await tester.pumpAndSettle(); await tester.pumpAndSettle();
expect(controller.hasClients, isFalse); expect(controller.hasClients, isFalse);
}, variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.iOS, TargetPlatform.macOS }));
debugDefaultTargetPlatformOverride = null;
});
} }
...@@ -43,7 +43,7 @@ void main() { ...@@ -43,7 +43,7 @@ void main() {
await tester.pump(); // trigger fling await tester.pump(); // trigger fling
expect(getCurrentOffset(), dragOffset); expect(getCurrentOffset(), dragOffset);
await tester.pump(const Duration(seconds: 5)); await tester.pump(const Duration(seconds: 5));
final double result1 = getCurrentOffset(); final double androidResult = getCurrentOffset();
await pumpTest(tester, TargetPlatform.iOS); await pumpTest(tester, TargetPlatform.iOS);
await tester.fling(find.byType(ListView), const Offset(0.0, -dragOffset), 1000.0); await tester.fling(find.byType(ListView), const Offset(0.0, -dragOffset), 1000.0);
...@@ -52,9 +52,19 @@ void main() { ...@@ -52,9 +52,19 @@ void main() {
await tester.pump(); // trigger fling await tester.pump(); // trigger fling
expect(getCurrentOffset(), moreOrLessEquals(210.71026666666666)); expect(getCurrentOffset(), moreOrLessEquals(210.71026666666666));
await tester.pump(const Duration(seconds: 5)); await tester.pump(const Duration(seconds: 5));
final double result2 = getCurrentOffset(); final double iOSResult = getCurrentOffset();
expect(result1, lessThan(result2)); // iOS (result2) is slipperier than Android (result1) await pumpTest(tester, TargetPlatform.macOS);
await tester.fling(find.byType(ListView), const Offset(0.0, -dragOffset), 1000.0);
// Scroll starts ease into the scroll on iOS.
expect(getCurrentOffset(), moreOrLessEquals(210.71026666666666));
await tester.pump(); // trigger fling
expect(getCurrentOffset(), moreOrLessEquals(210.71026666666666));
await tester.pump(const Duration(seconds: 5));
final double macOSResult = getCurrentOffset();
expect(androidResult, lessThan(iOSResult)); // iOS is slipperier than Android
expect(androidResult, lessThan(macOSResult)); // macOS is slipperier than Android
}); });
testWidgets('fling and tap to stop', (WidgetTester tester) async { testWidgets('fling and tap to stop', (WidgetTester tester) async {
......
...@@ -97,7 +97,7 @@ void main() { ...@@ -97,7 +97,7 @@ void main() {
await tester.pump(); // trigger fling await tester.pump(); // trigger fling
expect(getScrollOffset(tester), dragOffset); expect(getScrollOffset(tester), dragOffset);
await tester.pump(const Duration(seconds: 5)); await tester.pump(const Duration(seconds: 5));
final double result1 = getScrollOffset(tester); final double androidResult = getScrollOffset(tester);
resetScrollOffset(tester); resetScrollOffset(tester);
...@@ -108,13 +108,25 @@ void main() { ...@@ -108,13 +108,25 @@ void main() {
await tester.pump(); // trigger fling await tester.pump(); // trigger fling
expect(getScrollOffset(tester), moreOrLessEquals(197.16666666666669)); expect(getScrollOffset(tester), moreOrLessEquals(197.16666666666669));
await tester.pump(const Duration(seconds: 5)); await tester.pump(const Duration(seconds: 5));
final double result2 = getScrollOffset(tester); final double iOSResult = getScrollOffset(tester);
expect(result1, lessThan(result2)); // iOS (result2) is slipperier than Android (result1) resetScrollOffset(tester);
await pumpTest(tester, TargetPlatform.macOS);
await tester.fling(find.byType(Viewport), const Offset(0.0, -dragOffset), 1000.0);
// Scroll starts ease into the scroll on iOS.
expect(getScrollOffset(tester), moreOrLessEquals(197.16666666666669));
await tester.pump(); // trigger fling
expect(getScrollOffset(tester), moreOrLessEquals(197.16666666666669));
await tester.pump(const Duration(seconds: 5));
final double macOSResult = getScrollOffset(tester);
expect(androidResult, lessThan(iOSResult)); // iOS is slipperier than Android
expect(androidResult, lessThan(macOSResult)); // macOS is slipperier than Android
}); });
testWidgets('Holding scroll', (WidgetTester tester) async { testWidgets('Holding scroll', (WidgetTester tester) async {
await pumpTest(tester, TargetPlatform.iOS); await pumpTest(tester, debugDefaultTargetPlatformOverride);
await tester.drag(find.byType(Viewport), const Offset(0.0, 200.0), touchSlopY: 0.0); await tester.drag(find.byType(Viewport), const Offset(0.0, 200.0), touchSlopY: 0.0);
expect(getScrollOffset(tester), -200.0); expect(getScrollOffset(tester), -200.0);
await tester.pump(); // trigger ballistic await tester.pump(); // trigger ballistic
...@@ -130,10 +142,10 @@ void main() { ...@@ -130,10 +142,10 @@ void main() {
// Once the hold is let go, it should still snap back to origin. // Once the hold is let go, it should still snap back to origin.
expect(await tester.pumpAndSettle(const Duration(minutes: 1)), 2); expect(await tester.pumpAndSettle(const Duration(minutes: 1)), 2);
expect(getScrollOffset(tester), 0.0); expect(getScrollOffset(tester), 0.0);
}); }, variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.iOS, TargetPlatform.macOS }));
testWidgets('Repeated flings builds momentum on iOS', (WidgetTester tester) async { testWidgets('Repeated flings builds momentum', (WidgetTester tester) async {
await pumpTest(tester, TargetPlatform.iOS); await pumpTest(tester, debugDefaultTargetPlatformOverride);
await tester.fling(find.byType(Viewport), const Offset(0.0, -dragOffset), 1000.0); await tester.fling(find.byType(Viewport), const Offset(0.0, -dragOffset), 1000.0);
await tester.pump(); // trigger fling await tester.pump(); // trigger fling
await tester.pump(const Duration(milliseconds: 10)); await tester.pump(const Duration(milliseconds: 10));
...@@ -143,9 +155,9 @@ void main() { ...@@ -143,9 +155,9 @@ void main() {
// On iOS, the velocity will be larger than the velocity of the last fling by a // On iOS, the velocity will be larger than the velocity of the last fling by a
// non-trivial amount. // non-trivial amount.
expect(getScrollVelocity(tester), greaterThan(1100.0)); expect(getScrollVelocity(tester), greaterThan(1100.0));
}, variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.iOS, TargetPlatform.macOS }));
resetScrollOffset(tester); testWidgets('Repeated flings do not build momentum on Android', (WidgetTester tester) async {
await pumpTest(tester, TargetPlatform.android); await pumpTest(tester, TargetPlatform.android);
await tester.fling(find.byType(Viewport), const Offset(0.0, -dragOffset), 1000.0); await tester.fling(find.byType(Viewport), const Offset(0.0, -dragOffset), 1000.0);
await tester.pump(); // trigger fling await tester.pump(); // trigger fling
...@@ -158,8 +170,8 @@ void main() { ...@@ -158,8 +170,8 @@ void main() {
expect(getScrollVelocity(tester), moreOrLessEquals(1000.0)); expect(getScrollVelocity(tester), moreOrLessEquals(1000.0));
}); });
testWidgets('No iOS momentum build with flings in opposite directions', (WidgetTester tester) async { testWidgets('No iOS/macOS momentum build with flings in opposite directions', (WidgetTester tester) async {
await pumpTest(tester, TargetPlatform.iOS); await pumpTest(tester, debugDefaultTargetPlatformOverride);
await tester.fling(find.byType(Viewport), const Offset(0.0, -dragOffset), 1000.0); await tester.fling(find.byType(Viewport), const Offset(0.0, -dragOffset), 1000.0);
await tester.pump(); // trigger fling await tester.pump(); // trigger fling
await tester.pump(const Duration(milliseconds: 10)); await tester.pump(const Duration(milliseconds: 10));
...@@ -170,10 +182,10 @@ void main() { ...@@ -170,10 +182,10 @@ void main() {
// opposite direction. // opposite direction.
expect(getScrollVelocity(tester), greaterThan(-1000.0)); expect(getScrollVelocity(tester), greaterThan(-1000.0));
expect(getScrollVelocity(tester), lessThan(0.0)); expect(getScrollVelocity(tester), lessThan(0.0));
}); }, variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.iOS, TargetPlatform.macOS }));
testWidgets('No iOS momentum kept on hold gestures', (WidgetTester tester) async { testWidgets('No iOS/macOS momentum kept on hold gestures', (WidgetTester tester) async {
await pumpTest(tester, TargetPlatform.iOS); await pumpTest(tester, debugDefaultTargetPlatformOverride);
await tester.fling(find.byType(Viewport), const Offset(0.0, -dragOffset), 1000.0); await tester.fling(find.byType(Viewport), const Offset(0.0, -dragOffset), 1000.0);
await tester.pump(); // trigger fling await tester.pump(); // trigger fling
await tester.pump(const Duration(milliseconds: 10)); await tester.pump(const Duration(milliseconds: 10));
...@@ -183,7 +195,7 @@ void main() { ...@@ -183,7 +195,7 @@ void main() {
await gesture.up(); await gesture.up();
// After a hold longer than 2 frames, previous velocity is lost. // After a hold longer than 2 frames, previous velocity is lost.
expect(getScrollVelocity(tester), 0.0); expect(getScrollVelocity(tester), 0.0);
}); }, variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.iOS, TargetPlatform.macOS }));
testWidgets('Drags creeping unaffected on Android', (WidgetTester tester) async { testWidgets('Drags creeping unaffected on Android', (WidgetTester tester) async {
await pumpTest(tester, TargetPlatform.android); await pumpTest(tester, TargetPlatform.android);
...@@ -196,8 +208,8 @@ void main() { ...@@ -196,8 +208,8 @@ void main() {
expect(getScrollOffset(tester), 1.5); expect(getScrollOffset(tester), 1.5);
}); });
testWidgets('Drags creeping must break threshold on iOS', (WidgetTester tester) async { testWidgets('Drags creeping must break threshold on iOS/macOS', (WidgetTester tester) async {
await pumpTest(tester, TargetPlatform.iOS); await pumpTest(tester, debugDefaultTargetPlatformOverride);
final TestGesture gesture = await tester.startGesture(tester.getCenter(find.byType(Viewport))); final TestGesture gesture = await tester.startGesture(tester.getCenter(find.byType(Viewport)));
await gesture.moveBy(const Offset(0.0, -0.5)); await gesture.moveBy(const Offset(0.0, -0.5));
expect(getScrollOffset(tester), 0.0); expect(getScrollOffset(tester), 0.0);
...@@ -214,18 +226,18 @@ void main() { ...@@ -214,18 +226,18 @@ void main() {
await gesture.moveBy(const Offset(0.0, -0.5), timeStamp: const Duration(milliseconds: 50)); await gesture.moveBy(const Offset(0.0, -0.5), timeStamp: const Duration(milliseconds: 50));
// -0.5 over threshold transferred. // -0.5 over threshold transferred.
expect(getScrollOffset(tester), 0.5); expect(getScrollOffset(tester), 0.5);
}); }, variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.iOS, TargetPlatform.macOS }));
testWidgets('Big drag over threshold magnitude preserved on iOS', (WidgetTester tester) async { testWidgets('Big drag over threshold magnitude preserved on iOS/macOS', (WidgetTester tester) async {
await pumpTest(tester, TargetPlatform.iOS); await pumpTest(tester, debugDefaultTargetPlatformOverride);
final TestGesture gesture = await tester.startGesture(tester.getCenter(find.byType(Viewport))); final TestGesture gesture = await tester.startGesture(tester.getCenter(find.byType(Viewport)));
await gesture.moveBy(const Offset(0.0, -30.0)); await gesture.moveBy(const Offset(0.0, -30.0));
// No offset lost from threshold. // No offset lost from threshold.
expect(getScrollOffset(tester), 30.0); expect(getScrollOffset(tester), 30.0);
}); }, variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.iOS, TargetPlatform.macOS }));
testWidgets('Slow threshold breaks are attenuated on iOS', (WidgetTester tester) async { testWidgets('Slow threshold breaks are attenuated on iOS/macOS', (WidgetTester tester) async {
await pumpTest(tester, TargetPlatform.iOS); await pumpTest(tester, debugDefaultTargetPlatformOverride);
final TestGesture gesture = await tester.startGesture(tester.getCenter(find.byType(Viewport))); final TestGesture gesture = await tester.startGesture(tester.getCenter(find.byType(Viewport)));
// This is a typical 'hesitant' iOS scroll start. // This is a typical 'hesitant' iOS scroll start.
await gesture.moveBy(const Offset(0.0, -10.0)); await gesture.moveBy(const Offset(0.0, -10.0));
...@@ -233,10 +245,10 @@ void main() { ...@@ -233,10 +245,10 @@ void main() {
await gesture.moveBy(const Offset(0.0, -10.0), timeStamp: const Duration(milliseconds: 20)); await gesture.moveBy(const Offset(0.0, -10.0), timeStamp: const Duration(milliseconds: 20));
// Subsequent motions unaffected. // Subsequent motions unaffected.
expect(getScrollOffset(tester), moreOrLessEquals(11.16666666666666673)); expect(getScrollOffset(tester), moreOrLessEquals(11.16666666666666673));
}); }, variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.iOS, TargetPlatform.macOS }));
testWidgets('Small continuing motion preserved on iOS', (WidgetTester tester) async { testWidgets('Small continuing motion preserved on iOS/macOS', (WidgetTester tester) async {
await pumpTest(tester, TargetPlatform.iOS); await pumpTest(tester, debugDefaultTargetPlatformOverride);
final TestGesture gesture = await tester.startGesture(tester.getCenter(find.byType(Viewport))); final TestGesture gesture = await tester.startGesture(tester.getCenter(find.byType(Viewport)));
await gesture.moveBy(const Offset(0.0, -30.0)); // Break threshold. await gesture.moveBy(const Offset(0.0, -30.0)); // Break threshold.
expect(getScrollOffset(tester), 30.0); expect(getScrollOffset(tester), 30.0);
...@@ -246,10 +258,10 @@ void main() { ...@@ -246,10 +258,10 @@ void main() {
expect(getScrollOffset(tester), 31.0); expect(getScrollOffset(tester), 31.0);
await gesture.moveBy(const Offset(0.0, -0.5), timeStamp: const Duration(milliseconds: 60)); await gesture.moveBy(const Offset(0.0, -0.5), timeStamp: const Duration(milliseconds: 60));
expect(getScrollOffset(tester), 31.5); expect(getScrollOffset(tester), 31.5);
}); }, variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.iOS, TargetPlatform.macOS }));
testWidgets('Motion stop resets threshold on iOS', (WidgetTester tester) async { testWidgets('Motion stop resets threshold on iOS/macOS', (WidgetTester tester) async {
await pumpTest(tester, TargetPlatform.iOS); await pumpTest(tester, debugDefaultTargetPlatformOverride);
final TestGesture gesture = await tester.startGesture(tester.getCenter(find.byType(Viewport))); final TestGesture gesture = await tester.startGesture(tester.getCenter(find.byType(Viewport)));
await gesture.moveBy(const Offset(0.0, -30.0)); // Break threshold. await gesture.moveBy(const Offset(0.0, -30.0)); // Break threshold.
expect(getScrollOffset(tester), 30.0); expect(getScrollOffset(tester), 30.0);
...@@ -269,9 +281,9 @@ void main() { ...@@ -269,9 +281,9 @@ void main() {
expect(getScrollOffset(tester), 31.5); expect(getScrollOffset(tester), 31.5);
await gesture.moveBy(const Offset(0.0, -1.0), timeStamp: const Duration(milliseconds: 180)); await gesture.moveBy(const Offset(0.0, -1.0), timeStamp: const Duration(milliseconds: 180));
expect(getScrollOffset(tester), 32.5); expect(getScrollOffset(tester), 32.5);
}); }, variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.iOS, TargetPlatform.macOS }));
testWidgets('Scroll pointer signals are handled', (WidgetTester tester) async { testWidgets('Scroll pointer signals are handled on Fuchsia', (WidgetTester tester) async {
await pumpTest(tester, TargetPlatform.fuchsia); await pumpTest(tester, TargetPlatform.fuchsia);
final Offset scrollEventLocation = tester.getCenter(find.byType(Viewport)); final Offset scrollEventLocation = tester.getCenter(find.byType(Viewport));
final TestPointer testPointer = TestPointer(1, ui.PointerDeviceKind.mouse); final TestPointer testPointer = TestPointer(1, ui.PointerDeviceKind.mouse);
......
...@@ -2321,12 +2321,11 @@ void main() { ...@@ -2321,12 +2321,11 @@ void main() {
}); });
testWidgets( testWidgets(
'tap moves cursor to the edge of the word it tapped on (iOS)', 'tap moves cursor to the edge of the word it tapped',
(WidgetTester tester) async { (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
MaterialApp( const MaterialApp(
theme: ThemeData(platform: TargetPlatform.iOS), home: Material(
home: const Material(
child: Center( child: Center(
child: SelectableText('Atwater Peel Sherbrooke Bonaventure'), child: SelectableText('Atwater Peel Sherbrooke Bonaventure'),
), ),
...@@ -2349,8 +2348,7 @@ void main() { ...@@ -2349,8 +2348,7 @@ void main() {
// But don't trigger the toolbar. // But don't trigger the toolbar.
expect(find.byType(CupertinoButton), findsNothing); expect(find.byType(CupertinoButton), findsNothing);
}, }, variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.iOS, TargetPlatform.macOS }));
);
testWidgets( testWidgets(
'tap moves cursor to the position tapped (Android)', 'tap moves cursor to the position tapped (Android)',
...@@ -2385,12 +2383,11 @@ void main() { ...@@ -2385,12 +2383,11 @@ void main() {
); );
testWidgets( testWidgets(
'two slow taps do not trigger a word selection (iOS)', 'two slow taps do not trigger a word selection',
(WidgetTester tester) async { (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
MaterialApp( const MaterialApp(
theme: ThemeData(platform: TargetPlatform.iOS), home: Material(
home: const Material(
child: Center( child: Center(
child: SelectableText('Atwater Peel Sherbrooke Bonaventure'), child: SelectableText('Atwater Peel Sherbrooke Bonaventure'),
), ),
...@@ -2416,16 +2413,14 @@ void main() { ...@@ -2416,16 +2413,14 @@ void main() {
// No toolbar. // No toolbar.
expect(find.byType(CupertinoButton), findsNothing); expect(find.byType(CupertinoButton), findsNothing);
}, }, variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.iOS, TargetPlatform.macOS }));
);
testWidgets( testWidgets(
'double tap selects word and first tap of double tap moves cursor (iOS)', 'double tap selects word and first tap of double tap moves cursor',
(WidgetTester tester) async { (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
MaterialApp( const MaterialApp(
theme: ThemeData(platform: TargetPlatform.iOS), home: Material(
home: const Material(
child: Center( child: Center(
child: SelectableText('Atwater Peel Sherbrooke Bonaventure'), child: SelectableText('Atwater Peel Sherbrooke Bonaventure'),
), ),
...@@ -2462,8 +2457,7 @@ void main() { ...@@ -2462,8 +2457,7 @@ void main() {
// Selected text shows 1 toolbar buttons. // Selected text shows 1 toolbar buttons.
expect(find.byType(CupertinoButton), findsNWidgets(1)); expect(find.byType(CupertinoButton), findsNWidgets(1));
}, }, variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.iOS, TargetPlatform.macOS }));
);
testWidgets( testWidgets(
'double tap selects word and first tap of double tap moves cursor and shows toolbar (Android)', 'double tap selects word and first tap of double tap moves cursor and shows toolbar (Android)',
...@@ -2560,12 +2554,11 @@ void main() { ...@@ -2560,12 +2554,11 @@ void main() {
); );
testWidgets( testWidgets(
'double tap hold selects word (iOS)', 'double tap hold selects word',
(WidgetTester tester) async { (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
MaterialApp( const MaterialApp(
theme: ThemeData(platform: TargetPlatform.iOS), home: Material(
home: const Material(
child: Center( child: Center(
child: SelectableText('Atwater Peel Sherbrooke Bonaventure'), child: SelectableText('Atwater Peel Sherbrooke Bonaventure'),
), ),
...@@ -2603,16 +2596,14 @@ void main() { ...@@ -2603,16 +2596,14 @@ void main() {
); );
// The toolbar is still showing. // The toolbar is still showing.
expect(find.byType(CupertinoButton), findsNWidgets(1)); expect(find.byType(CupertinoButton), findsNWidgets(1));
}, }, variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.iOS, TargetPlatform.macOS }));
);
testWidgets( testWidgets(
'tap after a double tap select is not affected (iOS)', 'tap after a double tap select is not affected (iOS)',
(WidgetTester tester) async { (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
MaterialApp( const MaterialApp(
theme: ThemeData(platform: TargetPlatform.iOS), home: Material(
home: const Material(
child: Center( child: Center(
child: SelectableText('Atwater Peel Sherbrooke Bonaventure'), child: SelectableText('Atwater Peel Sherbrooke Bonaventure'),
), ),
...@@ -2650,16 +2641,14 @@ void main() { ...@@ -2650,16 +2641,14 @@ void main() {
// No toolbar. // No toolbar.
expect(find.byType(CupertinoButton), findsNothing); expect(find.byType(CupertinoButton), findsNothing);
}, }, variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.iOS, TargetPlatform.macOS }));
);
testWidgets( testWidgets(
'long press moves cursor to the exact long press position and shows toolbar (iOS)', 'long press moves cursor to the exact long press position and shows toolbar',
(WidgetTester tester) async { (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
MaterialApp( const MaterialApp(
theme: ThemeData(platform: TargetPlatform.iOS), home: Material(
home: const Material(
child: Center( child: Center(
child: SelectableText('Atwater Peel Sherbrooke Bonaventure'), child: SelectableText('Atwater Peel Sherbrooke Bonaventure'),
), ),
...@@ -2683,8 +2672,7 @@ void main() { ...@@ -2683,8 +2672,7 @@ void main() {
// Collapsed toolbar shows 2 buttons. // Collapsed toolbar shows 2 buttons.
expect(find.byType(CupertinoButton), findsNWidgets(1)); expect(find.byType(CupertinoButton), findsNWidgets(1));
}, }, variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.iOS, TargetPlatform.macOS }));
);
testWidgets( testWidgets(
'long press selects word and shows toolbar (Android)', 'long press selects word and shows toolbar (Android)',
...@@ -2719,12 +2707,11 @@ void main() { ...@@ -2719,12 +2707,11 @@ void main() {
); );
testWidgets( testWidgets(
'long press tap cannot initiate a double tap (iOS)', 'long press tap cannot initiate a double tap',
(WidgetTester tester) async { (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
MaterialApp( const MaterialApp(
theme: ThemeData(platform: TargetPlatform.iOS), home: Material(
home: const Material(
child: Center( child: Center(
child: SelectableText('Atwater Peel Sherbrooke Bonaventure'), child: SelectableText('Atwater Peel Sherbrooke Bonaventure'),
), ),
...@@ -2751,16 +2738,14 @@ void main() { ...@@ -2751,16 +2738,14 @@ void main() {
); );
expect(find.byType(CupertinoButton), findsNothing); expect(find.byType(CupertinoButton), findsNothing);
}, }, variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.iOS, TargetPlatform.macOS }));
);
testWidgets( testWidgets(
'long press drag moves the cursor under the drag and shows toolbar on lift (iOS)', 'long press drag moves the cursor under the drag and shows toolbar on lift (iOS)',
(WidgetTester tester) async { (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
MaterialApp( const MaterialApp(
theme: ThemeData(platform: TargetPlatform.iOS), home: Material(
home: const Material(
child: Center( child: Center(
child: SelectableText('Atwater Peel Sherbrooke Bonaventure'), child: SelectableText('Atwater Peel Sherbrooke Bonaventure'),
), ),
...@@ -2817,14 +2802,12 @@ void main() { ...@@ -2817,14 +2802,12 @@ void main() {
); );
// The toolbar now shows up. // The toolbar now shows up.
expect(find.byType(CupertinoButton), findsNWidgets(1)); expect(find.byType(CupertinoButton), findsNWidgets(1));
}, }, variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.iOS, TargetPlatform.macOS }));
);
testWidgets('long press drag can edge scroll (iOS)', (WidgetTester tester) async { testWidgets('long press drag can edge scroll', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
MaterialApp( const MaterialApp(
theme: ThemeData(platform: TargetPlatform.iOS), home: Material(
home: const Material(
child: Center( child: Center(
child: SelectableText( child: SelectableText(
'Atwater Peel Sherbrooke Bonaventure Angrignon Peel Côte-des-Neiges', 'Atwater Peel Sherbrooke Bonaventure Angrignon Peel Côte-des-Neiges',
...@@ -2908,15 +2891,14 @@ void main() { ...@@ -2908,15 +2891,14 @@ void main() {
expect(firstCharEndpoint.length, 1); expect(firstCharEndpoint.length, 1);
// The first character is now offscreen to the left. // The first character is now offscreen to the left.
expect(firstCharEndpoint[0].point.dx, moreOrLessEquals(-125, epsilon: 1)); expect(firstCharEndpoint[0].point.dx, moreOrLessEquals(-125, epsilon: 1));
}); }, variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.iOS, TargetPlatform.macOS }));
testWidgets( testWidgets(
'long tap after a double tap select is not affected (iOS)', 'long tap after a double tap select is not affected',
(WidgetTester tester) async { (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
MaterialApp( const MaterialApp(
theme: ThemeData(platform: TargetPlatform.iOS), home: Material(
home: const Material(
child: Center( child: Center(
child: SelectableText('Atwater Peel Sherbrooke Bonaventure'), child: SelectableText('Atwater Peel Sherbrooke Bonaventure'),
), ),
...@@ -2951,16 +2933,14 @@ void main() { ...@@ -2951,16 +2933,14 @@ void main() {
// Long press toolbar. // Long press toolbar.
expect(find.byType(CupertinoButton), findsNWidgets(1)); expect(find.byType(CupertinoButton), findsNWidgets(1));
}, }, variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.iOS, TargetPlatform.macOS }));
);
//convert //convert
testWidgets( testWidgets(
'double tap after a long tap is not affected (iOS)', 'double tap after a long tap is not affected',
(WidgetTester tester) async { (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
MaterialApp( const MaterialApp(
theme: ThemeData(platform: TargetPlatform.iOS), home: Material(
home: const Material(
child: Center( child: Center(
child: SelectableText('Atwater Peel Sherbrooke Bonaventure'), child: SelectableText('Atwater Peel Sherbrooke Bonaventure'),
), ),
...@@ -2993,16 +2973,14 @@ void main() { ...@@ -2993,16 +2973,14 @@ void main() {
const TextSelection(baseOffset: 8, extentOffset: 12), const TextSelection(baseOffset: 8, extentOffset: 12),
); );
expect(find.byType(CupertinoButton), findsNWidgets(1)); expect(find.byType(CupertinoButton), findsNWidgets(1));
}, }, variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.iOS, TargetPlatform.macOS }));
);
testWidgets( testWidgets(
'double tap chains work (iOS)', 'double tap chains work',
(WidgetTester tester) async { (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
MaterialApp( const MaterialApp(
theme: ThemeData(platform: TargetPlatform.iOS), home: Material(
home: const Material(
child: Center( child: Center(
child: SelectableText('Atwater Peel Sherbrooke Bonaventure'), child: SelectableText('Atwater Peel Sherbrooke Bonaventure'),
), ),
...@@ -3060,8 +3038,7 @@ void main() { ...@@ -3060,8 +3038,7 @@ void main() {
const TextSelection(baseOffset: 8, extentOffset: 12), const TextSelection(baseOffset: 8, extentOffset: 12),
); );
expect(find.byType(CupertinoButton), findsNWidgets(1)); expect(find.byType(CupertinoButton), findsNWidgets(1));
}, }, variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.iOS, TargetPlatform.macOS }));
);
testWidgets('force press does not select a word on (android)', (WidgetTester tester) async { testWidgets('force press does not select a word on (android)', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
...@@ -3099,11 +3076,10 @@ void main() { ...@@ -3099,11 +3076,10 @@ void main() {
expect(find.byType(FlatButton), findsNothing); expect(find.byType(FlatButton), findsNothing);
}); });
testWidgets('force press selects word (iOS)', (WidgetTester tester) async { testWidgets('force press selects word', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
MaterialApp( const MaterialApp(
theme: ThemeData(platform: TargetPlatform.iOS), home: Material(
home: const Material(
child: SelectableText('Atwater Peel Sherbrooke Bonaventure'), child: SelectableText('Atwater Peel Sherbrooke Bonaventure'),
), ),
), ),
...@@ -3139,13 +3115,12 @@ void main() { ...@@ -3139,13 +3115,12 @@ void main() {
await gesture.up(); await gesture.up();
await tester.pump(); await tester.pump();
expect(find.byType(CupertinoButton), findsNWidgets(1)); expect(find.byType(CupertinoButton), findsNWidgets(1));
}); }, variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.iOS, TargetPlatform.macOS }));
testWidgets('tap on non-force-press-supported devices work (iOS)', (WidgetTester tester) async { testWidgets('tap on non-force-press-supported devices work', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
MaterialApp( const MaterialApp(
theme: ThemeData(platform: TargetPlatform.iOS), home: Material(
home: const Material(
child: SelectableText('Atwater Peel Sherbrooke Bonaventure'), child: SelectableText('Atwater Peel Sherbrooke Bonaventure'),
), ),
), ),
...@@ -3184,7 +3159,11 @@ void main() { ...@@ -3184,7 +3159,11 @@ void main() {
await tester.pump(); await tester.pump();
// Single taps shouldn't trigger the toolbar. // Single taps shouldn't trigger the toolbar.
expect(find.byType(CupertinoButton), findsNothing); expect(find.byType(CupertinoButton), findsNothing);
});
// TODO(gspencergoog): Add in TargetPlatform.macOS in the line below when we
// figure out what global state is leaking.
// https://github.com/flutter/flutter/issues/43445
}, variant: TargetPlatformVariant.only(TargetPlatform.iOS));
testWidgets('default SelectableText debugFillProperties', (WidgetTester tester) async { testWidgets('default SelectableText debugFillProperties', (WidgetTester tester) async {
final DiagnosticPropertiesBuilder builder = DiagnosticPropertiesBuilder(); final DiagnosticPropertiesBuilder builder = DiagnosticPropertiesBuilder();
...@@ -3566,8 +3545,7 @@ void main() { ...@@ -3566,8 +3545,7 @@ void main() {
expect(right.opacity.value, equals(1.0)); expect(right.opacity.value, equals(1.0));
}); });
testWidgets('iOS selection handles are rendered and not faded away', (WidgetTester tester) async { testWidgets('selection handles are rendered and not faded away', (WidgetTester tester) async {
debugDefaultTargetPlatformOverride = TargetPlatform.iOS;
const String testText = 'lorem ipsum'; const String testText = 'lorem ipsum';
await tester.pumpWidget( await tester.pumpWidget(
...@@ -3593,9 +3571,7 @@ void main() { ...@@ -3593,9 +3571,7 @@ void main() {
expect(left.opacity.value, equals(1.0)); expect(left.opacity.value, equals(1.0));
expect(right.opacity.value, equals(1.0)); expect(right.opacity.value, equals(1.0));
}, variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.iOS, TargetPlatform.macOS }));
debugDefaultTargetPlatformOverride = null;
});
testWidgets('Long press shows handles and toolbar', (WidgetTester tester) async { testWidgets('Long press shows handles and toolbar', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
......
...@@ -283,7 +283,6 @@ void main() { ...@@ -283,7 +283,6 @@ void main() {
}); });
testWidgets('alignment with a flexible works', (WidgetTester tester) async { testWidgets('alignment with a flexible works', (WidgetTester tester) async {
debugDefaultTargetPlatformOverride = TargetPlatform.iOS;
final GlobalKey key = GlobalKey(); final GlobalKey key = GlobalKey();
final List<Widget> slivers = <Widget>[ final List<Widget> slivers = <Widget>[
sliverBox, sliverBox,
...@@ -347,13 +346,10 @@ void main() { ...@@ -347,13 +346,10 @@ void main() {
); );
expect(tester.getBottomLeft(button).dy, lessThan(600.0)); expect(tester.getBottomLeft(button).dy, lessThan(600.0));
expect(tester.getCenter(button).dx, equals(400.0)); expect(tester.getCenter(button).dx, equals(400.0));
}, variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.iOS, TargetPlatform.macOS }));
debugDefaultTargetPlatformOverride = null;
});
group('fillOverscroll: true, relevant platforms', () { group('fillOverscroll: true, relevant platforms', () {
testWidgets('child without size is sized by extent and overscroll', (WidgetTester tester) async { testWidgets('child without size is sized by extent and overscroll', (WidgetTester tester) async {
debugDefaultTargetPlatformOverride = TargetPlatform.iOS;
final List<Widget> slivers = <Widget>[ final List<Widget> slivers = <Widget>[
sliverBox, sliverBox,
SliverFillRemaining( SliverFillRemaining(
...@@ -378,12 +374,9 @@ void main() { ...@@ -378,12 +374,9 @@ void main() {
await tester.pumpAndSettle(); await tester.pumpAndSettle();
final RenderBox box3 = tester.renderObject<RenderBox>(find.byType(Container).last); final RenderBox box3 = tester.renderObject<RenderBox>(find.byType(Container).last);
expect(box3.size.height, equals(450)); expect(box3.size.height, equals(450));
}, variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.iOS, TargetPlatform.macOS }));
debugDefaultTargetPlatformOverride = null;
});
testWidgets('child with smaller size is overridden and sized by extent and overscroll', (WidgetTester tester) async { testWidgets('child with smaller size is overridden and sized by extent and overscroll', (WidgetTester tester) async {
debugDefaultTargetPlatformOverride = TargetPlatform.iOS;
final GlobalKey key = GlobalKey(); final GlobalKey key = GlobalKey();
final List<Widget> slivers = <Widget>[ final List<Widget> slivers = <Widget>[
sliverBox, sliverBox,
...@@ -428,12 +421,9 @@ void main() { ...@@ -428,12 +421,9 @@ void main() {
tester.renderObject<RenderBox>(find.byKey(key)).size.height, tester.renderObject<RenderBox>(find.byKey(key)).size.height,
equals(450), equals(450),
); );
}, variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.iOS, TargetPlatform.macOS }));
debugDefaultTargetPlatformOverride = null;
});
testWidgets('extent is overridden by child size and overscroll if precedingScrollExtent > viewportMainAxisExtent', (WidgetTester tester) async { testWidgets('extent is overridden by child size and overscroll if precedingScrollExtent > viewportMainAxisExtent', (WidgetTester tester) async {
debugDefaultTargetPlatformOverride = TargetPlatform.iOS;
final GlobalKey key = GlobalKey(); final GlobalKey key = GlobalKey();
final ScrollController controller = ScrollController(); final ScrollController controller = ScrollController();
final List<Widget> slivers = <Widget>[ final List<Widget> slivers = <Widget>[
...@@ -473,12 +463,10 @@ void main() { ...@@ -473,12 +463,10 @@ void main() {
tester.renderObject<RenderBox>(find.byKey(key)).size.height, tester.renderObject<RenderBox>(find.byKey(key)).size.height,
equals(148.0), equals(148.0),
); );
// Check that the button alignment is true to expectations // Check that the button alignment is true to expectations
final Finder button = find.byType(RaisedButton); final Finder button = find.byType(RaisedButton);
expect(tester.getBottomLeft(button).dy, equals(550.0)); expect(tester.getBottomLeft(button).dy, equals(550.0));
expect(tester.getCenter(button).dx, equals(400.0)); expect(tester.getCenter(button).dx, equals(400.0));
debugDefaultTargetPlatformOverride = null;
// Drag for overscroll // Drag for overscroll
await tester.drag(find.byType(Scrollable), const Offset(0.0, -50.0)); await tester.drag(find.byType(Scrollable), const Offset(0.0, -50.0));
...@@ -498,12 +486,9 @@ void main() { ...@@ -498,12 +486,9 @@ void main() {
tester.renderObject<RenderBox>(find.byKey(key)).size.height, tester.renderObject<RenderBox>(find.byKey(key)).size.height,
equals(148.0), equals(148.0),
); );
}, variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.iOS, TargetPlatform.macOS }));
debugDefaultTargetPlatformOverride = null;
});
testWidgets('fillOverscroll works when child has no size and precedingScrollExtent > viewportMainAxisExtent', (WidgetTester tester) async { testWidgets('fillOverscroll works when child has no size and precedingScrollExtent > viewportMainAxisExtent', (WidgetTester tester) async {
debugDefaultTargetPlatformOverride = TargetPlatform.iOS;
final GlobalKey key = GlobalKey(); final GlobalKey key = GlobalKey();
final ScrollController controller = ScrollController(); final ScrollController controller = ScrollController();
final List<Widget> slivers = <Widget>[ final List<Widget> slivers = <Widget>[
...@@ -557,12 +542,9 @@ void main() { ...@@ -557,12 +542,9 @@ void main() {
tester.widgetList<DecoratedBox>(find.byType(DecoratedBox)).last.decoration, tester.widgetList<DecoratedBox>(find.byType(DecoratedBox)).last.decoration,
amberBox, amberBox,
); );
}, variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.iOS, TargetPlatform.macOS }));
debugDefaultTargetPlatformOverride = null;
});
testWidgets('alignment with a flexible works with fillOverscroll', (WidgetTester tester) async { testWidgets('alignment with a flexible works with fillOverscroll', (WidgetTester tester) async {
debugDefaultTargetPlatformOverride = TargetPlatform.iOS;
final GlobalKey key = GlobalKey(); final GlobalKey key = GlobalKey();
final List<Widget> slivers = <Widget>[ final List<Widget> slivers = <Widget>[
sliverBox, sliverBox,
...@@ -648,9 +630,7 @@ void main() { ...@@ -648,9 +630,7 @@ void main() {
); );
expect(tester.getBottomLeft(button).dy, equals(600.0)); expect(tester.getBottomLeft(button).dy, equals(600.0));
expect(tester.getCenter(button).dx, equals(400.0)); expect(tester.getCenter(button).dx, equals(400.0));
}, variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.iOS, TargetPlatform.macOS }));
debugDefaultTargetPlatformOverride = null;
});
}); });
group('fillOverscroll: true, is ignored on irrevelant platforms', () { group('fillOverscroll: true, is ignored on irrevelant platforms', () {
......
...@@ -7,7 +7,6 @@ import 'package:flutter/gestures.dart' show PointerDeviceKind; ...@@ -7,7 +7,6 @@ import 'package:flutter/gestures.dart' show PointerDeviceKind;
import 'package:flutter/widgets.dart'; import 'package:flutter/widgets.dart';
import 'package:flutter/rendering.dart'; import 'package:flutter/rendering.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/foundation.dart' show debugDefaultTargetPlatformOverride;
void main() { void main() {
int tapCount; int tapCount;
...@@ -552,7 +551,6 @@ void main() { ...@@ -552,7 +551,6 @@ void main() {
// Regression test for https://github.com/flutter/flutter/issues/37032. // Regression test for https://github.com/flutter/flutter/issues/37032.
testWidgets("selection handle's GestureDetector should not cover the entire screen", (WidgetTester tester) async { testWidgets("selection handle's GestureDetector should not cover the entire screen", (WidgetTester tester) async {
debugDefaultTargetPlatformOverride = TargetPlatform.iOS;
final TextEditingController controller = TextEditingController(text: 'a'); final TextEditingController controller = TextEditingController(text: 'a');
await tester.pumpWidget( await tester.pumpWidget(
...@@ -583,9 +581,7 @@ void main() { ...@@ -583,9 +581,7 @@ void main() {
expect(hitRect.size.width, lessThan(textFieldRect.size.width)); expect(hitRect.size.width, lessThan(textFieldRect.size.width));
expect(hitRect.size.height, lessThan(textFieldRect.size.height)); expect(hitRect.size.height, lessThan(textFieldRect.size.height));
}, variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.iOS, TargetPlatform.macOS }));
debugDefaultTargetPlatformOverride = null;
});
} }
class FakeTextSelectionGestureDetectorBuilderDelegate implements TextSelectionGestureDetectorBuilderDelegate { class FakeTextSelectionGestureDetectorBuilderDelegate implements TextSelectionGestureDetectorBuilderDelegate {
......
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