Unverified Commit 3821c35d authored by Jonah Williams's avatar Jonah Williams Committed by GitHub

Ensure that textDirection is always passed to ShapeBorder.getOuterPath (#21532)

parent 9a290c17
...@@ -39,6 +39,7 @@ class InkHighlight extends InteractiveInkFeature { ...@@ -39,6 +39,7 @@ class InkHighlight extends InteractiveInkFeature {
@required MaterialInkController controller, @required MaterialInkController controller,
@required RenderBox referenceBox, @required RenderBox referenceBox,
@required Color color, @required Color color,
@required TextDirection textDirection,
BoxShape shape = BoxShape.rectangle, BoxShape shape = BoxShape.rectangle,
BorderRadius borderRadius, BorderRadius borderRadius,
ShapeBorder customBorder, ShapeBorder customBorder,
...@@ -46,9 +47,11 @@ class InkHighlight extends InteractiveInkFeature { ...@@ -46,9 +47,11 @@ class InkHighlight extends InteractiveInkFeature {
VoidCallback onRemoved, VoidCallback onRemoved,
}) : assert(color != null), }) : assert(color != null),
assert(shape != null), assert(shape != null),
assert(textDirection != null),
_shape = shape, _shape = shape,
_borderRadius = borderRadius ?? BorderRadius.zero, _borderRadius = borderRadius ?? BorderRadius.zero,
_customBorder = customBorder, _customBorder = customBorder,
_textDirection = textDirection,
_rectCallback = rectCallback, _rectCallback = rectCallback,
super(controller: controller, referenceBox: referenceBox, color: color, onRemoved: onRemoved) { super(controller: controller, referenceBox: referenceBox, color: color, onRemoved: onRemoved) {
_alphaController = new AnimationController(duration: _kHighlightFadeDuration, vsync: controller.vsync) _alphaController = new AnimationController(duration: _kHighlightFadeDuration, vsync: controller.vsync)
...@@ -67,6 +70,7 @@ class InkHighlight extends InteractiveInkFeature { ...@@ -67,6 +70,7 @@ class InkHighlight extends InteractiveInkFeature {
final BorderRadius _borderRadius; final BorderRadius _borderRadius;
final ShapeBorder _customBorder; final ShapeBorder _customBorder;
final RectCallback _rectCallback; final RectCallback _rectCallback;
final TextDirection _textDirection;
Animation<int> _alpha; Animation<int> _alpha;
AnimationController _alphaController; AnimationController _alphaController;
...@@ -102,7 +106,7 @@ class InkHighlight extends InteractiveInkFeature { ...@@ -102,7 +106,7 @@ class InkHighlight extends InteractiveInkFeature {
assert(_shape != null); assert(_shape != null);
canvas.save(); canvas.save();
if (_customBorder != null) { if (_customBorder != null) {
canvas.clipPath(_customBorder.getOuterPath(rect)); canvas.clipPath(_customBorder.getOuterPath(rect, textDirection: _textDirection));
} }
switch (_shape) { switch (_shape) {
case BoxShape.circle: case BoxShape.circle:
......
...@@ -45,6 +45,7 @@ class _InkRippleFactory extends InteractiveInkFeatureFactory { ...@@ -45,6 +45,7 @@ class _InkRippleFactory extends InteractiveInkFeatureFactory {
@required RenderBox referenceBox, @required RenderBox referenceBox,
@required Offset position, @required Offset position,
@required Color color, @required Color color,
@required TextDirection textDirection,
bool containedInkWell = false, bool containedInkWell = false,
RectCallback rectCallback, RectCallback rectCallback,
BorderRadius borderRadius, BorderRadius borderRadius,
...@@ -63,6 +64,7 @@ class _InkRippleFactory extends InteractiveInkFeatureFactory { ...@@ -63,6 +64,7 @@ class _InkRippleFactory extends InteractiveInkFeatureFactory {
customBorder: customBorder, customBorder: customBorder,
radius: radius, radius: radius,
onRemoved: onRemoved, onRemoved: onRemoved,
textDirection: textDirection,
); );
} }
} }
...@@ -114,6 +116,7 @@ class InkRipple extends InteractiveInkFeature { ...@@ -114,6 +116,7 @@ class InkRipple extends InteractiveInkFeature {
@required RenderBox referenceBox, @required RenderBox referenceBox,
@required Offset position, @required Offset position,
@required Color color, @required Color color,
@required TextDirection textDirection,
bool containedInkWell = false, bool containedInkWell = false,
RectCallback rectCallback, RectCallback rectCallback,
BorderRadius borderRadius, BorderRadius borderRadius,
...@@ -122,9 +125,11 @@ class InkRipple extends InteractiveInkFeature { ...@@ -122,9 +125,11 @@ class InkRipple extends InteractiveInkFeature {
VoidCallback onRemoved, VoidCallback onRemoved,
}) : assert(color != null), }) : assert(color != null),
assert(position != null), assert(position != null),
assert(textDirection != null),
_position = position, _position = position,
_borderRadius = borderRadius ?? BorderRadius.zero, _borderRadius = borderRadius ?? BorderRadius.zero,
_customBorder = customBorder, _customBorder = customBorder,
_textDirection = textDirection,
_targetRadius = radius ?? _getTargetRadius(referenceBox, containedInkWell, rectCallback, position), _targetRadius = radius ?? _getTargetRadius(referenceBox, containedInkWell, rectCallback, position),
_clipCallback = _getClipCallback(referenceBox, containedInkWell, rectCallback), _clipCallback = _getClipCallback(referenceBox, containedInkWell, rectCallback),
super(controller: controller, referenceBox: referenceBox, color: color, onRemoved: onRemoved) super(controller: controller, referenceBox: referenceBox, color: color, onRemoved: onRemoved)
...@@ -179,6 +184,7 @@ class InkRipple extends InteractiveInkFeature { ...@@ -179,6 +184,7 @@ class InkRipple extends InteractiveInkFeature {
final ShapeBorder _customBorder; final ShapeBorder _customBorder;
final double _targetRadius; final double _targetRadius;
final RectCallback _clipCallback; final RectCallback _clipCallback;
final TextDirection _textDirection;
Animation<double> _radius; Animation<double> _radius;
AnimationController _radiusController; AnimationController _radiusController;
...@@ -245,7 +251,7 @@ class InkRipple extends InteractiveInkFeature { ...@@ -245,7 +251,7 @@ class InkRipple extends InteractiveInkFeature {
if (_clipCallback != null) { if (_clipCallback != null) {
final Rect rect = _clipCallback(); final Rect rect = _clipCallback();
if (_customBorder != null) { if (_customBorder != null) {
canvas.clipPath(_customBorder.getOuterPath(rect)); canvas.clipPath(_customBorder.getOuterPath(rect, textDirection: _textDirection));
} else if (_borderRadius != BorderRadius.zero) { } else if (_borderRadius != BorderRadius.zero) {
canvas.clipRRect(new RRect.fromRectAndCorners( canvas.clipRRect(new RRect.fromRectAndCorners(
rect, rect,
......
...@@ -51,6 +51,7 @@ class _InkSplashFactory extends InteractiveInkFeatureFactory { ...@@ -51,6 +51,7 @@ class _InkSplashFactory extends InteractiveInkFeatureFactory {
@required RenderBox referenceBox, @required RenderBox referenceBox,
@required Offset position, @required Offset position,
@required Color color, @required Color color,
@required TextDirection textDirection,
bool containedInkWell = false, bool containedInkWell = false,
RectCallback rectCallback, RectCallback rectCallback,
BorderRadius borderRadius, BorderRadius borderRadius,
...@@ -69,6 +70,7 @@ class _InkSplashFactory extends InteractiveInkFeatureFactory { ...@@ -69,6 +70,7 @@ class _InkSplashFactory extends InteractiveInkFeatureFactory {
customBorder: customBorder, customBorder: customBorder,
radius: radius, radius: radius,
onRemoved: onRemoved, onRemoved: onRemoved,
textDirection: textDirection,
); );
} }
} }
...@@ -116,6 +118,7 @@ class InkSplash extends InteractiveInkFeature { ...@@ -116,6 +118,7 @@ class InkSplash extends InteractiveInkFeature {
InkSplash({ InkSplash({
@required MaterialInkController controller, @required MaterialInkController controller,
@required RenderBox referenceBox, @required RenderBox referenceBox,
@required TextDirection textDirection,
Offset position, Offset position,
Color color, Color color,
bool containedInkWell = false, bool containedInkWell = false,
...@@ -124,12 +127,14 @@ class InkSplash extends InteractiveInkFeature { ...@@ -124,12 +127,14 @@ class InkSplash extends InteractiveInkFeature {
ShapeBorder customBorder, ShapeBorder customBorder,
double radius, double radius,
VoidCallback onRemoved, VoidCallback onRemoved,
}) : _position = position, }) : assert(textDirection != null),
_position = position,
_borderRadius = borderRadius ?? BorderRadius.zero, _borderRadius = borderRadius ?? BorderRadius.zero,
_customBorder = customBorder, _customBorder = customBorder,
_targetRadius = radius ?? _getTargetRadius(referenceBox, containedInkWell, rectCallback, position), _targetRadius = radius ?? _getTargetRadius(referenceBox, containedInkWell, rectCallback, position),
_clipCallback = _getClipCallback(referenceBox, containedInkWell, rectCallback), _clipCallback = _getClipCallback(referenceBox, containedInkWell, rectCallback),
_repositionToReferenceBox = !containedInkWell, _repositionToReferenceBox = !containedInkWell,
_textDirection = textDirection,
super(controller: controller, referenceBox: referenceBox, color: color, onRemoved: onRemoved) { super(controller: controller, referenceBox: referenceBox, color: color, onRemoved: onRemoved) {
assert(_borderRadius != null); assert(_borderRadius != null);
_radiusController = new AnimationController(duration: _kUnconfirmedSplashDuration, vsync: controller.vsync) _radiusController = new AnimationController(duration: _kUnconfirmedSplashDuration, vsync: controller.vsync)
...@@ -156,6 +161,7 @@ class InkSplash extends InteractiveInkFeature { ...@@ -156,6 +161,7 @@ class InkSplash extends InteractiveInkFeature {
final double _targetRadius; final double _targetRadius;
final RectCallback _clipCallback; final RectCallback _clipCallback;
final bool _repositionToReferenceBox; final bool _repositionToReferenceBox;
final TextDirection _textDirection;
Animation<double> _radius; Animation<double> _radius;
AnimationController _radiusController; AnimationController _radiusController;
...@@ -206,7 +212,7 @@ class InkSplash extends InteractiveInkFeature { ...@@ -206,7 +212,7 @@ class InkSplash extends InteractiveInkFeature {
if (_clipCallback != null) { if (_clipCallback != null) {
final Rect rect = _clipCallback(); final Rect rect = _clipCallback();
if (_customBorder != null) { if (_customBorder != null) {
canvas.clipPath(_customBorder.getOuterPath(rect)); canvas.clipPath(_customBorder.getOuterPath(rect, textDirection: _textDirection));
} else if (_borderRadius != BorderRadius.zero) { } else if (_borderRadius != BorderRadius.zero) {
canvas.clipRRect(new RRect.fromRectAndCorners( canvas.clipRRect(new RRect.fromRectAndCorners(
rect, rect,
......
...@@ -92,6 +92,7 @@ abstract class InteractiveInkFeatureFactory { ...@@ -92,6 +92,7 @@ abstract class InteractiveInkFeatureFactory {
@required RenderBox referenceBox, @required RenderBox referenceBox,
@required Offset position, @required Offset position,
@required Color color, @required Color color,
@required TextDirection textDirection,
bool containedInkWell = false, bool containedInkWell = false,
RectCallback rectCallback, RectCallback rectCallback,
BorderRadius borderRadius, BorderRadius borderRadius,
...@@ -372,6 +373,7 @@ class InkResponse extends StatefulWidget { ...@@ -372,6 +373,7 @@ class InkResponse extends StatefulWidget {
@mustCallSuper @mustCallSuper
bool debugCheckContext(BuildContext context) { bool debugCheckContext(BuildContext context) {
assert(debugCheckHasMaterial(context)); assert(debugCheckHasMaterial(context));
assert(debugCheckHasDirectionality(context));
return true; return true;
} }
...@@ -426,6 +428,7 @@ class _InkResponseState<T extends InkResponse> extends State<T> with AutomaticKe ...@@ -426,6 +428,7 @@ class _InkResponseState<T extends InkResponse> extends State<T> with AutomaticKe
customBorder: widget.customBorder, customBorder: widget.customBorder,
rectCallback: widget.getRectCallback(referenceBox), rectCallback: widget.getRectCallback(referenceBox),
onRemoved: _handleInkHighlightRemoval, onRemoved: _handleInkHighlightRemoval,
textDirection: Directionality.of(context),
); );
updateKeepAlive(); updateKeepAlive();
} else { } else {
...@@ -476,6 +479,7 @@ class _InkResponseState<T extends InkResponse> extends State<T> with AutomaticKe ...@@ -476,6 +479,7 @@ class _InkResponseState<T extends InkResponse> extends State<T> with AutomaticKe
borderRadius: borderRadius, borderRadius: borderRadius,
customBorder: customBorder, customBorder: customBorder,
onRemoved: onRemoved, onRemoved: onRemoved,
textDirection: Directionality.of(context),
); );
return splash; return splash;
......
...@@ -497,7 +497,7 @@ class _OutlineBorder extends ShapeBorder { ...@@ -497,7 +497,7 @@ class _OutlineBorder extends ShapeBorder {
case BorderStyle.none: case BorderStyle.none:
break; break;
case BorderStyle.solid: case BorderStyle.solid:
canvas.drawPath(shape.getOuterPath(rect), side.toPaint()); canvas.drawPath(shape.getOuterPath(rect, textDirection: textDirection), side.toPaint());
} }
} }
......
...@@ -473,6 +473,7 @@ class _TextFieldState extends State<TextField> with AutomaticKeepAliveClientMixi ...@@ -473,6 +473,7 @@ class _TextFieldState extends State<TextField> with AutomaticKeepAliveClientMixi
// TODO(hansmuller): splash clip borderRadius should match the input decorator's border. // TODO(hansmuller): splash clip borderRadius should match the input decorator's border.
borderRadius: BorderRadius.zero, borderRadius: BorderRadius.zero,
onRemoved: handleRemoved, onRemoved: handleRemoved,
textDirection: Directionality.of(context),
); );
return splash; return splash;
...@@ -539,6 +540,7 @@ class _TextFieldState extends State<TextField> with AutomaticKeepAliveClientMixi ...@@ -539,6 +540,7 @@ class _TextFieldState extends State<TextField> with AutomaticKeepAliveClientMixi
Widget build(BuildContext context) { Widget build(BuildContext context) {
super.build(context); // See AutomaticKeepAliveClientMixin. super.build(context); // See AutomaticKeepAliveClientMixin.
assert(debugCheckHasMaterial(context)); assert(debugCheckHasMaterial(context));
assert(debugCheckHasDirectionality(context));
final ThemeData themeData = Theme.of(context); final ThemeData themeData = Theme.of(context);
final TextStyle style = widget.style ?? themeData.textTheme.subhead; final TextStyle style = widget.style ?? themeData.textTheme.subhead;
final Brightness keyboardAppearance = widget.keyboardAppearance ?? themeData.primaryColorBrightness; final Brightness keyboardAppearance = widget.keyboardAppearance ?? themeData.primaryColorBrightness;
......
...@@ -15,7 +15,9 @@ void main() { ...@@ -15,7 +15,9 @@ void main() {
final BorderRadius borderRadius = new BorderRadius.circular(6.0); final BorderRadius borderRadius = new BorderRadius.circular(6.0);
await tester.pumpWidget( await tester.pumpWidget(
new Material( new Directionality(
textDirection: TextDirection.ltr,
child: new Material(
child: new Center( child: new Center(
child: new Container( child: new Container(
width: 200.0, width: 200.0,
...@@ -29,6 +31,7 @@ void main() { ...@@ -29,6 +31,7 @@ void main() {
), ),
), ),
), ),
),
); );
final Offset center = tester.getCenter(find.byType(InkWell)); final Offset center = tester.getCenter(find.byType(InkWell));
...@@ -61,7 +64,9 @@ void main() { ...@@ -61,7 +64,9 @@ void main() {
final BorderRadius borderRadius = new BorderRadius.circular(6.0); final BorderRadius borderRadius = new BorderRadius.circular(6.0);
await tester.pumpWidget( await tester.pumpWidget(
new Material( new Directionality(
textDirection: TextDirection.ltr,
child: new Material(
child: new Center( child: new Center(
child: new Container( child: new Container(
width: 100.0, width: 100.0,
...@@ -77,6 +82,7 @@ void main() { ...@@ -77,6 +82,7 @@ void main() {
), ),
), ),
), ),
),
); );
final Offset tapDownOffset = tester.getTopLeft(find.byType(InkWell)); final Offset tapDownOffset = tester.getTopLeft(find.byType(InkWell));
...@@ -138,7 +144,9 @@ void main() { ...@@ -138,7 +144,9 @@ void main() {
testWidgets('Does the Ink widget render anything', (WidgetTester tester) async { testWidgets('Does the Ink widget render anything', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
new Material( new Directionality(
textDirection: TextDirection.ltr,
child: new Material(
child: new Center( child: new Center(
child: new Ink( child: new Ink(
color: Colors.blue, color: Colors.blue,
...@@ -151,6 +159,7 @@ void main() { ...@@ -151,6 +159,7 @@ void main() {
), ),
), ),
), ),
),
); );
final Offset center = tester.getCenter(find.byType(InkWell)); final Offset center = tester.getCenter(find.byType(InkWell));
...@@ -167,7 +176,9 @@ void main() { ...@@ -167,7 +176,9 @@ void main() {
); );
await tester.pumpWidget( await tester.pumpWidget(
new Material( new Directionality(
textDirection: TextDirection.ltr,
child: new Material(
child: new Center( child: new Center(
child: new Ink( child: new Ink(
color: Colors.red, color: Colors.red,
...@@ -180,6 +191,7 @@ void main() { ...@@ -180,6 +191,7 @@ void main() {
), ),
), ),
), ),
),
); );
expect(Material.of(tester.element(find.byType(InkWell))), same(box)); expect(Material.of(tester.element(find.byType(InkWell))), same(box));
...@@ -192,7 +204,9 @@ void main() { ...@@ -192,7 +204,9 @@ void main() {
); );
await tester.pumpWidget( await tester.pumpWidget(
new Material( new Directionality(
textDirection: TextDirection.ltr,
child: new Material(
child: new Center( child: new Center(
child: new InkWell( // this is at a different depth in the tree so it's now a new InkWell child: new InkWell( // this is at a different depth in the tree so it's now a new InkWell
splashColor: Colors.green, splashColor: Colors.green,
...@@ -200,6 +214,7 @@ void main() { ...@@ -200,6 +214,7 @@ void main() {
), ),
), ),
), ),
),
); );
expect(Material.of(tester.element(find.byType(InkWell))), same(box)); expect(Material.of(tester.element(find.byType(InkWell))), same(box));
...@@ -213,7 +228,9 @@ void main() { ...@@ -213,7 +228,9 @@ void main() {
testWidgets('Cancel an InkRipple that was disposed when its animation ended', (WidgetTester tester) async { testWidgets('Cancel an InkRipple that was disposed when its animation ended', (WidgetTester tester) async {
// Regression test for https://github.com/flutter/flutter/issues/14391 // Regression test for https://github.com/flutter/flutter/issues/14391
await tester.pumpWidget( await tester.pumpWidget(
new Material( new Directionality(
textDirection: TextDirection.ltr,
child: new Material(
child: new Center( child: new Center(
child: new Container( child: new Container(
width: 100.0, width: 100.0,
...@@ -226,6 +243,7 @@ void main() { ...@@ -226,6 +243,7 @@ void main() {
), ),
), ),
), ),
),
); );
final Offset tapDownOffset = tester.getTopLeft(find.byType(InkWell)); final Offset tapDownOffset = tester.getTopLeft(find.byType(InkWell));
...@@ -246,7 +264,9 @@ void main() { ...@@ -246,7 +264,9 @@ void main() {
// Regression test for https://github.com/flutter/flutter/issues/14391 // Regression test for https://github.com/flutter/flutter/issues/14391
await tester.pumpWidget( await tester.pumpWidget(
new Material( new Directionality(
textDirection: TextDirection.ltr,
child: new Material(
child: new Center( child: new Center(
child: new Container( child: new Container(
width: 100.0, width: 100.0,
...@@ -261,6 +281,7 @@ void main() { ...@@ -261,6 +281,7 @@ void main() {
), ),
), ),
), ),
),
); );
final Offset tapDownOffset = tester.getTopLeft(find.byType(InkWell)); final Offset tapDownOffset = tester.getTopLeft(find.byType(InkWell));
......
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
void main() {
// Regression test for https://github.com/flutter/flutter/issues/21506.
testWidgets('InkSplash receives textDirection', (WidgetTester tester) async {
await tester.pumpWidget(new MaterialApp(
home: new Scaffold(
appBar: new AppBar(title: const Text('Button Border Test')),
body: new Center(
child: new RaisedButton(
child: const Text('Test'),
onPressed: () {},
shape: new Border.all(
color: Colors.blue,
),
),
),
)));
await tester.tap(find.text('Test'));
// start ink animation which asserts for a textDirection.
await tester.pumpAndSettle(const Duration(milliseconds: 30));
expect(tester.takeException(), isNull);
});
}
...@@ -14,7 +14,10 @@ void main() { ...@@ -14,7 +14,10 @@ void main() {
testWidgets('InkWell gestures control test', (WidgetTester tester) async { testWidgets('InkWell gestures control test', (WidgetTester tester) async {
final List<String> log = <String>[]; final List<String> log = <String>[];
await tester.pumpWidget(new Material( await tester.pumpWidget(
new Directionality(
textDirection: TextDirection.ltr,
child: new Material(
child: new Center( child: new Center(
child: new InkWell( child: new InkWell(
onTap: () { onTap: () {
...@@ -34,7 +37,9 @@ void main() { ...@@ -34,7 +37,9 @@ void main() {
}, },
), ),
), ),
)); )
)
);
await tester.tap(find.byType(InkWell), pointer: 1); await tester.tap(find.byType(InkWell), pointer: 1);
...@@ -72,9 +77,12 @@ void main() { ...@@ -72,9 +77,12 @@ void main() {
testWidgets('long-press and tap on disabled should not throw', (WidgetTester tester) async { testWidgets('long-press and tap on disabled should not throw', (WidgetTester tester) async {
await tester.pumpWidget(const Material( await tester.pumpWidget(const Material(
child: Directionality(
textDirection: TextDirection.ltr,
child: Center( child: Center(
child: InkWell(), child: InkWell(),
), ),
)
)); ));
await tester.tap(find.byType(InkWell), pointer: 1); await tester.tap(find.byType(InkWell), pointer: 1);
await tester.pump(const Duration(seconds: 1)); await tester.pump(const Duration(seconds: 1));
...@@ -95,12 +103,15 @@ void main() { ...@@ -95,12 +103,15 @@ void main() {
testWidgets('enabled (default)', (WidgetTester tester) async { testWidgets('enabled (default)', (WidgetTester tester) async {
await tester.pumpWidget(new Material( await tester.pumpWidget(new Material(
child: new Directionality(
textDirection: TextDirection.ltr,
child: new Center( child: new Center(
child: new InkWell( child: new InkWell(
onTap: () {}, onTap: () {},
onLongPress: () {}, onLongPress: () {},
), ),
), ),
),
)); ));
await tester.tap(find.byType(InkWell), pointer: 1); await tester.tap(find.byType(InkWell), pointer: 1);
await tester.pump(const Duration(seconds: 1)); await tester.pump(const Duration(seconds: 1));
...@@ -120,6 +131,8 @@ void main() { ...@@ -120,6 +131,8 @@ void main() {
testWidgets('disabled', (WidgetTester tester) async { testWidgets('disabled', (WidgetTester tester) async {
await tester.pumpWidget(new Material( await tester.pumpWidget(new Material(
child: new Directionality(
textDirection: TextDirection.ltr,
child: new Center( child: new Center(
child: new InkWell( child: new InkWell(
onTap: () {}, onTap: () {},
...@@ -127,6 +140,7 @@ void main() { ...@@ -127,6 +140,7 @@ void main() {
enableFeedback: false, enableFeedback: false,
), ),
), ),
)
)); ));
await tester.tap(find.byType(InkWell), pointer: 1); await tester.tap(find.byType(InkWell), pointer: 1);
await tester.pump(const Duration(seconds: 1)); await tester.pump(const Duration(seconds: 1));
......
...@@ -9,14 +9,19 @@ void main() { ...@@ -9,14 +9,19 @@ void main() {
testWidgets('materialTapTargetSize.padded expands hit test area', (WidgetTester tester) async { testWidgets('materialTapTargetSize.padded expands hit test area', (WidgetTester tester) async {
int pressed = 0; int pressed = 0;
await tester.pumpWidget(new RawMaterialButton( await tester.pumpWidget(
new Directionality(
textDirection: TextDirection.ltr,
child: new RawMaterialButton(
onPressed: () { onPressed: () {
pressed++; pressed++;
}, },
constraints: new BoxConstraints.tight(const Size(10.0, 10.0)), constraints: new BoxConstraints.tight(const Size(10.0, 10.0)),
materialTapTargetSize: MaterialTapTargetSize.padded, materialTapTargetSize: MaterialTapTargetSize.padded,
child: const Text('+', textDirection: TextDirection.ltr), child: const Text('+'),
)); ),
)
);
await tester.tapAt(const Offset(40.0, 400.0)); await tester.tapAt(const Offset(40.0, 400.0));
...@@ -26,12 +31,15 @@ void main() { ...@@ -26,12 +31,15 @@ void main() {
testWidgets('materialTapTargetSize.padded expands semantics area', (WidgetTester tester) async { testWidgets('materialTapTargetSize.padded expands semantics area', (WidgetTester tester) async {
final SemanticsTester semantics = new SemanticsTester(tester); final SemanticsTester semantics = new SemanticsTester(tester);
await tester.pumpWidget( await tester.pumpWidget(
new Center( new Directionality(
textDirection: TextDirection.ltr,
child: new Center(
child: new RawMaterialButton( child: new RawMaterialButton(
onPressed: () {}, onPressed: () {},
constraints: new BoxConstraints.tight(const Size(10.0, 10.0)), constraints: new BoxConstraints.tight(const Size(10.0, 10.0)),
materialTapTargetSize: MaterialTapTargetSize.padded, materialTapTargetSize: MaterialTapTargetSize.padded,
child: const Text('+', textDirection: TextDirection.ltr), child: const Text('+'),
),
), ),
), ),
); );
...@@ -66,7 +74,9 @@ void main() { ...@@ -66,7 +74,9 @@ void main() {
const Color fillColor = Color(0xFFEF5350); const Color fillColor = Color(0xFFEF5350);
await tester.pumpWidget( await tester.pumpWidget(
new Center( new Directionality(
textDirection: TextDirection.ltr,
child: new Center(
child: new RawMaterialButton( child: new RawMaterialButton(
materialTapTargetSize: MaterialTapTargetSize.padded, materialTapTargetSize: MaterialTapTargetSize.padded,
onPressed: () {}, onPressed: () {},
...@@ -76,6 +86,7 @@ void main() { ...@@ -76,6 +86,7 @@ void main() {
child: const SizedBox(), child: const SizedBox(),
), ),
), ),
),
); );
final Offset center = tester.getCenter(find.byType(InkWell)); final Offset center = tester.getCenter(find.byType(InkWell));
...@@ -95,7 +106,9 @@ void main() { ...@@ -95,7 +106,9 @@ void main() {
const Color fillColor = Color(0xFFEF5350); const Color fillColor = Color(0xFFEF5350);
await tester.pumpWidget( await tester.pumpWidget(
new Center( new Directionality(
textDirection: TextDirection.ltr,
child: new Center(
child: new RawMaterialButton( child: new RawMaterialButton(
materialTapTargetSize: MaterialTapTargetSize.padded, materialTapTargetSize: MaterialTapTargetSize.padded,
onPressed: () {}, onPressed: () {},
...@@ -105,6 +118,7 @@ void main() { ...@@ -105,6 +118,7 @@ void main() {
child: const SizedBox(), child: const SizedBox(),
), ),
), ),
),
); );
final Offset top = tester.getRect(find.byType(InkWell)).topCenter; final Offset top = tester.getRect(find.byType(InkWell)).topCenter;
......
...@@ -22,6 +22,7 @@ class TestInkSplash extends InkSplash { ...@@ -22,6 +22,7 @@ class TestInkSplash extends InkSplash {
ShapeBorder customBorder, ShapeBorder customBorder,
double radius, double radius,
VoidCallback onRemoved, VoidCallback onRemoved,
TextDirection textDirection
}) : super( }) : super(
controller: controller, controller: controller,
referenceBox: referenceBox, referenceBox: referenceBox,
...@@ -33,6 +34,7 @@ class TestInkSplash extends InkSplash { ...@@ -33,6 +34,7 @@ class TestInkSplash extends InkSplash {
customBorder: customBorder, customBorder: customBorder,
radius: radius, radius: radius,
onRemoved: onRemoved, onRemoved: onRemoved,
textDirection: textDirection,
); );
@override @override
...@@ -63,6 +65,7 @@ class TestInkSplashFactory extends InteractiveInkFeatureFactory { ...@@ -63,6 +65,7 @@ class TestInkSplashFactory extends InteractiveInkFeatureFactory {
ShapeBorder customBorder, ShapeBorder customBorder,
double radius, double radius,
VoidCallback onRemoved, VoidCallback onRemoved,
TextDirection textDirection,
}) { }) {
return new TestInkSplash( return new TestInkSplash(
controller: controller, controller: controller,
...@@ -75,6 +78,7 @@ class TestInkSplashFactory extends InteractiveInkFeatureFactory { ...@@ -75,6 +78,7 @@ class TestInkSplashFactory extends InteractiveInkFeatureFactory {
customBorder: customBorder, customBorder: customBorder,
radius: radius, radius: radius,
onRemoved: onRemoved, onRemoved: onRemoved,
textDirection: textDirection,
); );
} }
} }
......
...@@ -8,12 +8,15 @@ import 'package:flutter_test/flutter_test.dart'; ...@@ -8,12 +8,15 @@ import 'package:flutter_test/flutter_test.dart';
void main() { void main() {
testWidgets('runApp inside onPressed does not throw', (WidgetTester tester) async { testWidgets('runApp inside onPressed does not throw', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
new Material( new Directionality(
textDirection: TextDirection.ltr,
child: new Material(
child: new RaisedButton( child: new RaisedButton(
onPressed: () { onPressed: () {
runApp(const Center(child: Text('Done', textDirection: TextDirection.ltr))); runApp(const Center(child: Text('Done', textDirection: TextDirection.ltr,)));
}, },
child: const Text('GO', textDirection: TextDirection.ltr) child: const Text('GO')
)
) )
) )
); );
......
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