Commit c46347b6 authored by Adam Barth's avatar Adam Barth Committed by GitHub

Add RTL support to Stack (#11973)

Notice that the default alignment for Stack needs to know the
directionality.
parent 1792766a
......@@ -112,6 +112,7 @@ void main() {
// The bottom later is our RenderDots object, and on top of that we show the
// text.
final RenderStack stack = new RenderStack(
textDirection: TextDirection.ltr,
children: <RenderBox>[
new RenderDots(),
paragraph,
......
......@@ -297,16 +297,19 @@ class RenderStack extends RenderBox
/// top left corners.
RenderStack({
List<RenderBox> children,
FractionalOffset alignment: FractionalOffset.topLeft,
FractionalOffsetGeometry alignment: FractionalOffsetDirectional.topStart,
@required TextDirection textDirection,
StackFit fit: StackFit.loose,
Overflow overflow: Overflow.clip
Overflow overflow: Overflow.clip,
}) : assert(alignment != null),
assert(fit != null),
assert(overflow != null),
_alignment = alignment,
_textDirection = textDirection,
_fit = fit,
_overflow = overflow {
addAll(children);
_applyUpdate();
}
bool _hasVisualOverflow = false;
......@@ -317,19 +320,40 @@ class RenderStack extends RenderBox
child.parentData = new StackParentData();
}
// The resolved absolute insets.
FractionalOffset _resolvedAlignment;
void _applyUpdate() {
final FractionalOffset resolvedAlignment = alignment.resolve(textDirection);
if (_resolvedAlignment != resolvedAlignment) {
_resolvedAlignment = resolvedAlignment;
markNeedsLayout();
}
}
/// How to align the non-positioned children in the stack.
///
/// The non-positioned children are placed relative to each other such that
/// the points determined by [alignment] are co-located. For example, if the
/// [alignment] is [FractionalOffset.topLeft], then the top left corner of
/// each non-positioned child will be located at the same global coordinate.
FractionalOffset get alignment => _alignment;
FractionalOffset _alignment;
set alignment(FractionalOffset value) {
FractionalOffsetGeometry get alignment => _alignment;
FractionalOffsetGeometry _alignment;
set alignment(FractionalOffsetGeometry value) {
assert(value != null);
if (_alignment != value) {
_alignment = value;
markNeedsLayout();
_applyUpdate();
}
}
/// The text direction with which to resolve [alignment].
TextDirection get textDirection => _textDirection;
TextDirection _textDirection;
set textDirection(TextDirection value) {
if (_textDirection != value) {
_textDirection = value;
_applyUpdate();
}
}
......@@ -455,7 +479,7 @@ class RenderStack extends RenderBox
final StackParentData childParentData = child.parentData;
if (!childParentData.isPositioned) {
childParentData.offset = alignment.alongOffset(size - child.size);
childParentData.offset = _resolvedAlignment.alongOffset(size - child.size);
} else {
BoxConstraints childConstraints = const BoxConstraints();
......@@ -526,7 +550,8 @@ class RenderStack extends RenderBox
@override
void debugFillProperties(DiagnosticPropertiesBuilder description) {
super.debugFillProperties(description);
description.add(new DiagnosticsProperty<FractionalOffset>('alignment', alignment));
description.add(new DiagnosticsProperty<FractionalOffsetGeometry>('alignment', alignment));
description.add(new EnumProperty<TextDirection>('textDirection', textDirection));
description.add(new EnumProperty<StackFit>('fit', fit));
description.add(new EnumProperty<Overflow>('overflow', overflow));
}
......@@ -543,11 +568,13 @@ class RenderIndexedStack extends RenderStack {
/// If the [index] parameter is null, nothing is displayed.
RenderIndexedStack({
List<RenderBox> children,
FractionalOffset alignment: FractionalOffset.topLeft,
int index: 0
FractionalOffsetGeometry alignment: FractionalOffsetDirectional.topStart,
@required TextDirection textDirection,
int index: 0,
}) : _index = index, super(
children: children,
alignment: alignment
alignment: alignment,
textDirection: textDirection,
);
@override
......
......@@ -2193,7 +2193,8 @@ class Stack extends MultiChildRenderObjectWidget {
/// top left corners.
Stack({
Key key,
this.alignment: FractionalOffset.topLeft,
this.alignment: FractionalOffsetDirectional.topStart,
this.textDirection,
this.fit: StackFit.loose,
this.overflow: Overflow.clip,
List<Widget> children: const <Widget>[],
......@@ -2205,7 +2206,12 @@ class Stack extends MultiChildRenderObjectWidget {
/// the points determined by [alignment] are co-located. For example, if the
/// [alignment] is [FractionalOffset.topLeft], then the top left corner of
/// each non-positioned child will be located at the same global coordinate.
final FractionalOffset alignment;
final FractionalOffsetGeometry alignment;
/// The text direction with which to resolve [alignment].
///
/// Defaults to the ambient [Directionality].
final TextDirection textDirection;
/// How to size the non-positioned children in the stack.
///
......@@ -2224,6 +2230,7 @@ class Stack extends MultiChildRenderObjectWidget {
RenderStack createRenderObject(BuildContext context) {
return new RenderStack(
alignment: alignment,
textDirection: textDirection ?? Directionality.of(context),
fit: fit,
overflow: overflow,
);
......@@ -2233,6 +2240,7 @@ class Stack extends MultiChildRenderObjectWidget {
void updateRenderObject(BuildContext context, RenderStack renderObject) {
renderObject
..alignment = alignment
..textDirection = textDirection ?? Directionality.of(context)
..fit = fit
..overflow = overflow;
}
......@@ -2240,7 +2248,8 @@ class Stack extends MultiChildRenderObjectWidget {
@override
void debugFillProperties(DiagnosticPropertiesBuilder description) {
super.debugFillProperties(description);
description.add(new DiagnosticsProperty<FractionalOffset>('alignment', alignment));
description.add(new DiagnosticsProperty<FractionalOffsetGeometry>('alignment', alignment));
description.add(new EnumProperty<TextDirection>('textDirection', textDirection, defaultValue: null));
description.add(new EnumProperty<StackFit>('fit', fit));
description.add(new EnumProperty<Overflow>('overflow', overflow));
}
......@@ -2260,23 +2269,31 @@ class IndexedStack extends Stack {
/// The [index] argument must not be null.
IndexedStack({
Key key,
FractionalOffset alignment: FractionalOffset.topLeft,
FractionalOffsetGeometry alignment: FractionalOffsetDirectional.topStart,
TextDirection textDirection,
StackFit sizing: StackFit.loose,
this.index: 0,
List<Widget> children: const <Widget>[],
}) : super(key: key, alignment: alignment, fit: sizing, children: children);
}) : super(key: key, alignment: alignment, textDirection: textDirection, fit: sizing, children: children);
/// The index of the child to show.
final int index;
@override
RenderIndexedStack createRenderObject(BuildContext context) => new RenderIndexedStack(index: index, alignment: alignment);
RenderIndexedStack createRenderObject(BuildContext context) {
return new RenderIndexedStack(
index: index,
alignment: alignment,
textDirection: textDirection ?? Directionality.of(context),
);
}
@override
void updateRenderObject(BuildContext context, RenderIndexedStack renderObject) {
renderObject
..index = index
..alignment = alignment;
..alignment = alignment
..textDirection = textDirection ?? Directionality.of(context);
}
}
......
......@@ -115,18 +115,21 @@ void main() {
}
Widget build() {
return new Navigator(
initialRoute: '/',
onGenerateRoute: (RouteSettings settings) {
return new MaterialPageRoute<Null>(
settings: settings,
builder: (BuildContext context) {
return new Material(
child: buildFrame(value: 'one', onChanged: didChangeValue),
);
},
);
}
return new Directionality(
textDirection: TextDirection.ltr,
child: new Navigator(
initialRoute: '/',
onGenerateRoute: (RouteSettings settings) {
return new MaterialPageRoute<Null>(
settings: settings,
builder: (BuildContext context) {
return new Material(
child: buildFrame(value: 'one', onChanged: didChangeValue),
);
},
);
},
),
);
}
......
......@@ -26,7 +26,10 @@ void main() {
),
);
final RenderBox stack = new RenderStack(children: <RenderBox>[red, green]);
final RenderBox stack = new RenderStack(
textDirection: TextDirection.ltr,
children: <RenderBox>[red, green],
);
final StackParentData greenParentData = green.parentData;
greenParentData
..top = 0.0
......@@ -59,8 +62,9 @@ void main() {
additionalConstraints: new BoxConstraints.tight(const Size(100.0, 100.0))
);
final RenderBox stack = new RenderIndexedStack(
children: <RenderBox>[child1, child2, child3],
index: 1,
textDirection: TextDirection.ltr,
children: <RenderBox>[child1, child2, child3],
);
final List<RenderObject> vistedChildren = <RenderObject>[];
......
......@@ -10,18 +10,21 @@ import 'package:flutter/widgets.dart';
void main() {
testWidgets('AnimatedCrossFade test', (WidgetTester tester) async {
await tester.pumpWidget(
const Center(
child: const AnimatedCrossFade(
firstChild: const SizedBox(
width: 100.0,
height: 100.0,
),
secondChild: const SizedBox(
width: 200.0,
height: 200.0,
const Directionality(
textDirection: TextDirection.ltr,
child: const Center(
child: const AnimatedCrossFade(
firstChild: const SizedBox(
width: 100.0,
height: 100.0,
),
secondChild: const SizedBox(
width: 200.0,
height: 200.0,
),
duration: const Duration(milliseconds: 200),
crossFadeState: CrossFadeState.showFirst,
),
duration: const Duration(milliseconds: 200),
crossFadeState: CrossFadeState.showFirst,
),
),
);
......@@ -32,18 +35,21 @@ void main() {
expect(box.size.height, equals(100.0));
await tester.pumpWidget(
const Center(
child: const AnimatedCrossFade(
firstChild: const SizedBox(
width: 100.0,
height: 100.0,
),
secondChild: const SizedBox(
width: 200.0,
height: 200.0,
const Directionality(
textDirection: TextDirection.ltr,
child: const Center(
child: const AnimatedCrossFade(
firstChild: const SizedBox(
width: 100.0,
height: 100.0,
),
secondChild: const SizedBox(
width: 200.0,
height: 200.0,
),
duration: const Duration(milliseconds: 200),
crossFadeState: CrossFadeState.showSecond,
),
duration: const Duration(milliseconds: 200),
crossFadeState: CrossFadeState.showSecond,
),
),
);
......@@ -58,18 +64,21 @@ void main() {
testWidgets('AnimatedCrossFade test showSecond', (WidgetTester tester) async {
await tester.pumpWidget(
const Center(
child: const AnimatedCrossFade(
firstChild: const SizedBox(
width: 100.0,
height: 100.0,
),
secondChild: const SizedBox(
width: 200.0,
height: 200.0,
const Directionality(
textDirection: TextDirection.ltr,
child: const Center(
child: const AnimatedCrossFade(
firstChild: const SizedBox(
width: 100.0,
height: 100.0,
),
secondChild: const SizedBox(
width: 200.0,
height: 200.0,
),
duration: const Duration(milliseconds: 200),
crossFadeState: CrossFadeState.showSecond,
),
duration: const Duration(milliseconds: 200),
crossFadeState: CrossFadeState.showSecond,
),
),
);
......@@ -85,41 +94,47 @@ void main() {
final Key secondKey = new UniqueKey();
await tester.pumpWidget(
new Center(
child: new AnimatedCrossFade(
alignment: FractionalOffset.bottomRight,
firstChild: new SizedBox(
key: firstKey,
width: 100.0,
height: 100.0,
),
secondChild: new SizedBox(
key: secondKey,
width: 200.0,
height: 200.0,
new Directionality(
textDirection: TextDirection.ltr,
child: new Center(
child: new AnimatedCrossFade(
alignment: FractionalOffset.bottomRight,
firstChild: new SizedBox(
key: firstKey,
width: 100.0,
height: 100.0,
),
secondChild: new SizedBox(
key: secondKey,
width: 200.0,
height: 200.0,
),
duration: const Duration(milliseconds: 200),
crossFadeState: CrossFadeState.showFirst,
),
duration: const Duration(milliseconds: 200),
crossFadeState: CrossFadeState.showFirst,
),
),
);
await tester.pumpWidget(
new Center(
child: new AnimatedCrossFade(
alignment: FractionalOffset.bottomRight,
firstChild: new SizedBox(
key: firstKey,
width: 100.0,
height: 100.0,
),
secondChild: new SizedBox(
key: secondKey,
width: 200.0,
height: 200.0,
new Directionality(
textDirection: TextDirection.ltr,
child: new Center(
child: new AnimatedCrossFade(
alignment: FractionalOffset.bottomRight,
firstChild: new SizedBox(
key: firstKey,
width: 100.0,
height: 100.0,
),
secondChild: new SizedBox(
key: secondKey,
width: 200.0,
height: 200.0,
),
duration: const Duration(milliseconds: 200),
crossFadeState: CrossFadeState.showSecond,
),
duration: const Duration(milliseconds: 200),
crossFadeState: CrossFadeState.showSecond,
),
),
);
......@@ -249,11 +264,14 @@ void main() {
});
Widget crossFadeWithWatcher({bool towardsSecond: false}) {
return new AnimatedCrossFade(
firstChild: const _TickerWatchingWidget(),
secondChild: new Container(),
crossFadeState: towardsSecond ? CrossFadeState.showSecond : CrossFadeState.showFirst,
duration: const Duration(milliseconds: 50),
return new Directionality(
textDirection: TextDirection.ltr,
child: new AnimatedCrossFade(
firstChild: const _TickerWatchingWidget(),
secondChild: new Container(),
crossFadeState: towardsSecond ? CrossFadeState.showSecond : CrossFadeState.showFirst,
duration: const Duration(milliseconds: 50),
),
);
}
......@@ -301,30 +319,45 @@ void main() {
});
testWidgets('AnimatedCrossFade.layoutBuilder', (WidgetTester tester) async {
await tester.pumpWidget(const AnimatedCrossFade(
firstChild: const Text('AAA', textDirection: TextDirection.ltr),
secondChild: const Text('BBB', textDirection: TextDirection.ltr),
crossFadeState: CrossFadeState.showFirst,
duration: const Duration(milliseconds: 50),
));
await tester.pumpWidget(
const Directionality(
textDirection: TextDirection.ltr,
child: const AnimatedCrossFade(
firstChild: const Text('AAA', textDirection: TextDirection.ltr),
secondChild: const Text('BBB', textDirection: TextDirection.ltr),
crossFadeState: CrossFadeState.showFirst,
duration: const Duration(milliseconds: 50),
),
),
);
expect(find.text('AAA'), findsOneWidget);
expect(find.text('BBB'), findsOneWidget);
await tester.pumpWidget(new AnimatedCrossFade(
firstChild: const Text('AAA', textDirection: TextDirection.ltr),
secondChild: const Text('BBB', textDirection: TextDirection.ltr),
crossFadeState: CrossFadeState.showFirst,
duration: const Duration(milliseconds: 50),
layoutBuilder: (Widget a, Key aKey, Widget b, Key bKey) => a,
));
await tester.pumpWidget(
new Directionality(
textDirection: TextDirection.ltr,
child: new AnimatedCrossFade(
firstChild: const Text('AAA', textDirection: TextDirection.ltr),
secondChild: const Text('BBB', textDirection: TextDirection.ltr),
crossFadeState: CrossFadeState.showFirst,
duration: const Duration(milliseconds: 50),
layoutBuilder: (Widget a, Key aKey, Widget b, Key bKey) => a,
),
),
);
expect(find.text('AAA'), findsOneWidget);
expect(find.text('BBB'), findsNothing);
await tester.pumpWidget(new AnimatedCrossFade(
firstChild: const Text('AAA', textDirection: TextDirection.ltr),
secondChild: const Text('BBB', textDirection: TextDirection.ltr),
crossFadeState: CrossFadeState.showSecond,
duration: const Duration(milliseconds: 50),
layoutBuilder: (Widget a, Key aKey, Widget b, Key bKey) => a,
));
await tester.pumpWidget(
new Directionality(
textDirection: TextDirection.ltr,
child: new AnimatedCrossFade(
firstChild: const Text('AAA', textDirection: TextDirection.ltr),
secondChild: const Text('BBB', textDirection: TextDirection.ltr),
crossFadeState: CrossFadeState.showSecond,
duration: const Duration(milliseconds: 50),
layoutBuilder: (Widget a, Key aKey, Widget b, Key bKey) => a,
),
),
);
expect(find.text('BBB'), findsOneWidget);
expect(find.text('AAA'), findsNothing);
});
......
......@@ -27,6 +27,7 @@ void main() {
await tester.pumpWidget(
new Stack(
textDirection: TextDirection.ltr,
children: <Widget>[
new AnimatedPositioned(
child: new Container(key: key),
......@@ -50,6 +51,7 @@ void main() {
await tester.pumpWidget(
new Stack(
textDirection: TextDirection.ltr,
children: <Widget>[
new AnimatedPositioned(
child: new Container(key: key),
......@@ -110,6 +112,7 @@ void main() {
await tester.pumpWidget(
new Stack(
textDirection: TextDirection.ltr,
children: <Widget>[
new AnimatedPositioned(
child: new Container(key: key),
......@@ -133,6 +136,7 @@ void main() {
await tester.pumpWidget(
new Stack(
textDirection: TextDirection.ltr,
children: <Widget>[
new AnimatedPositioned(
child: new Container(key: key),
......@@ -156,6 +160,7 @@ void main() {
await tester.pumpWidget(
new Stack(
textDirection: TextDirection.ltr,
children: <Widget>[
new AnimatedPositioned(
child: new Container(key: key),
......@@ -190,6 +195,7 @@ void main() {
await tester.pumpWidget(
new Stack(
textDirection: TextDirection.ltr,
children: <Widget>[
new AnimatedPositioned(
child: new Container(key: key),
......@@ -213,6 +219,7 @@ void main() {
await tester.pumpWidget(
new Stack(
textDirection: TextDirection.ltr,
children: <Widget>[
new AnimatedPositioned(
child: new Container(key: key),
......
......@@ -26,12 +26,17 @@ class TestRoute<T> extends PageRoute<T> {
}
Future<Null> pumpApp(WidgetTester tester) async {
await tester.pumpWidget(new WidgetsApp(
color: const Color(0xFF333333),
onGenerateRoute: (RouteSettings settings) {
return new TestRoute<Null>(settings: settings, child: new Container());
},
));
await tester.pumpWidget(
new Directionality(
textDirection: TextDirection.ltr,
child: new WidgetsApp(
color: const Color(0xFF333333),
onGenerateRoute: (RouteSettings settings) {
return new TestRoute<Null>(settings: settings, child: new Container());
},
),
),
);
}
void main() {
......
......@@ -11,25 +11,28 @@ void main() {
final LayerLink link = new LayerLink();
final GlobalKey key = new GlobalKey();
await tester.pumpWidget(
new Stack(
children: <Widget>[
new Positioned(
left: 123.0,
top: 456.0,
child: new CompositedTransformTarget(
link: link,
child: new Container(height: 10.0, width: 10.0),
new Directionality(
textDirection: TextDirection.ltr,
child: new Stack(
children: <Widget>[
new Positioned(
left: 123.0,
top: 456.0,
child: new CompositedTransformTarget(
link: link,
child: new Container(height: 10.0, width: 10.0),
),
),
),
new Positioned(
left: 787.0,
top: 343.0,
child: new CompositedTransformFollower(
link: link,
child: new Container(key: key, height: 10.0, width: 10.0),
new Positioned(
left: 787.0,
top: 343.0,
child: new CompositedTransformFollower(
link: link,
child: new Container(key: key, height: 10.0, width: 10.0),
),
),
),
],
],
),
),
);
final RenderBox box = key.currentContext.findRenderObject();
......@@ -41,31 +44,34 @@ void main() {
final GlobalKey key1 = new GlobalKey();
final GlobalKey key2 = new GlobalKey();
await tester.pumpWidget(
new Stack(
children: <Widget>[
new Positioned(
top: 123.0,
left: 456.0,
child: new Transform.rotate(
angle: 1.0, // radians
child: new CompositedTransformTarget(
link: link,
child: new Container(key: key1, height: 10.0, width: 10.0),
new Directionality(
textDirection: TextDirection.ltr,
child: new Stack(
children: <Widget>[
new Positioned(
top: 123.0,
left: 456.0,
child: new Transform.rotate(
angle: 1.0, // radians
child: new CompositedTransformTarget(
link: link,
child: new Container(key: key1, height: 10.0, width: 10.0),
),
),
),
),
new Positioned(
top: 787.0,
left: 343.0,
child: new Transform.rotate(
angle: -0.3, // radians
child: new CompositedTransformFollower(
link: link,
child: new Container(key: key2, height: 10.0, width: 10.0),
new Positioned(
top: 787.0,
left: 343.0,
child: new Transform.rotate(
angle: -0.3, // radians
child: new CompositedTransformFollower(
link: link,
child: new Container(key: key2, height: 10.0, width: 10.0),
),
),
),
),
],
],
),
),
);
final RenderBox box1 = key1.currentContext.findRenderObject();
......@@ -81,43 +87,46 @@ void main() {
final GlobalKey key1 = new GlobalKey();
final GlobalKey key2 = new GlobalKey();
await tester.pumpWidget(
new Stack(
children: <Widget>[
new Positioned(
top: 123.0,
left: 456.0,
child: new Transform.rotate(
angle: 1.0, // radians
child: new CompositedTransformTarget(
link: link,
child: new Container(key: key1, height: 10.0, width: 10.0),
new Directionality(
textDirection: TextDirection.ltr,
child: new Stack(
children: <Widget>[
new Positioned(
top: 123.0,
left: 456.0,
child: new Transform.rotate(
angle: 1.0, // radians
child: new CompositedTransformTarget(
link: link,
child: new Container(key: key1, height: 10.0, width: 10.0),
),
),
),
),
new Positioned(
top: 787.0,
left: 343.0,
child: new Transform.rotate(
angle: -0.3, // radians
child: new Padding(
padding: const EdgeInsets.all(20.0),
child: new CompositedTransformFollower(
link: new LayerLink(),
child: new Transform(
transform: new Matrix4.skew(0.9, 1.1),
child: new Padding(
padding: const EdgeInsets.all(20.0),
child: new CompositedTransformFollower(
link: link,
child: new Container(key: key2, height: 10.0, width: 10.0),
new Positioned(
top: 787.0,
left: 343.0,
child: new Transform.rotate(
angle: -0.3, // radians
child: new Padding(
padding: const EdgeInsets.all(20.0),
child: new CompositedTransformFollower(
link: new LayerLink(),
child: new Transform(
transform: new Matrix4.skew(0.9, 1.1),
child: new Padding(
padding: const EdgeInsets.all(20.0),
child: new CompositedTransformFollower(
link: link,
child: new Container(key: key2, height: 10.0, width: 10.0),
),
),
),
),
),
),
),
),
],
],
),
),
);
final RenderBox box1 = key1.currentContext.findRenderObject();
......@@ -135,26 +144,29 @@ void main() {
final GlobalKey key3 = new GlobalKey();
bool _tapped = false;
await tester.pumpWidget(
new Stack(
children: <Widget>[
new Positioned(
left: 123.0,
top: 456.0,
child: new CompositedTransformTarget(
link: link,
child: new Container(key: key1, height: 10.0, width: 10.0),
new Directionality(
textDirection: TextDirection.ltr,
child: new Stack(
children: <Widget>[
new Positioned(
left: 123.0,
top: 456.0,
child: new CompositedTransformTarget(
link: link,
child: new Container(key: key1, height: 10.0, width: 10.0),
),
),
),
new CompositedTransformFollower(
link: link,
child: new GestureDetector(
key: key2,
behavior: HitTestBehavior.opaque,
onTap: () { _tapped = true; },
child: new Container(key: key3, height: 10.0, width: 10.0),
new CompositedTransformFollower(
link: link,
child: new GestureDetector(
key: key2,
behavior: HitTestBehavior.opaque,
onTap: () { _tapped = true; },
child: new Container(key: key3, height: 10.0, width: 10.0),
),
),
),
],
],
),
),
);
final RenderBox box2 = key2.currentContext.findRenderObject();
......
......@@ -13,6 +13,7 @@ void main() {
await tester.pumpWidget(
new Stack(
textDirection: TextDirection.ltr,
children: <Widget>[
new Positioned(
top: 100.0,
......@@ -20,8 +21,8 @@ void main() {
child: new SizedBox(
key: keyA,
width: 10.0,
height: 10.0
)
height: 10.0,
),
),
new Positioned(
left: 100.0,
......@@ -29,11 +30,11 @@ void main() {
child: new SizedBox(
key: keyB,
width: 20.0,
height: 10.0
)
height: 10.0,
),
),
]
)
],
),
);
final RenderBox boxA = tester.renderObject(find.byKey(keyA));
......
......@@ -10,32 +10,35 @@ void main() {
testWidgets('Can hit test flex children of stacks', (WidgetTester tester) async {
bool didReceiveTap = false;
await tester.pumpWidget(
new Container(
color: const Color(0xFF00FF00),
child: new Stack(
children: <Widget>[
new Positioned(
top: 10.0,
left: 10.0,
child: new Column(
children: <Widget>[
new GestureDetector(
onTap: () {
didReceiveTap = true;
},
child: new Container(
color: const Color(0xFF0000FF),
width: 100.0,
height: 100.0,
child: const Center(
child: const Text('X', textDirection: TextDirection.ltr),
new Directionality(
textDirection: TextDirection.ltr,
child: new Container(
color: const Color(0xFF00FF00),
child: new Stack(
children: <Widget>[
new Positioned(
top: 10.0,
left: 10.0,
child: new Column(
children: <Widget>[
new GestureDetector(
onTap: () {
didReceiveTap = true;
},
child: new Container(
color: const Color(0xFF0000FF),
width: 100.0,
height: 100.0,
child: const Center(
child: const Text('X', textDirection: TextDirection.ltr),
),
),
),
),
],
],
),
),
),
],
],
),
),
),
);
......
......@@ -47,6 +47,7 @@ void main() {
testWidgets('GlobalKey duplication 1 - double appearance', (WidgetTester tester) async {
final Key key = new GlobalKey(debugLabel: 'problematic');
await tester.pumpWidget(new Stack(
textDirection: TextDirection.ltr,
children: <Widget>[
new Container(
key: const ValueKey<int>(1),
......@@ -65,6 +66,7 @@ void main() {
final Key key = new GlobalKey(debugLabel: 'problematic');
await tester.pumpWidget(new Stack(
textDirection: TextDirection.ltr,
children: <Widget>[
new Container(
key: const ValueKey<int>(1),
......@@ -79,6 +81,7 @@ void main() {
));
await tester.pumpWidget(new Stack(
textDirection: TextDirection.ltr,
children: <Widget>[
new Container(
key: const ValueKey<int>(1),
......@@ -97,11 +100,13 @@ void main() {
testWidgets('GlobalKey duplication 3 - splitting and changing type', (WidgetTester tester) async {
final Key key = new GlobalKey(debugLabel: 'problematic');
await tester.pumpWidget(new Stack(
textDirection: TextDirection.ltr,
children: <Widget>[
new Container(key: key),
],
));
await tester.pumpWidget(new Stack(
textDirection: TextDirection.ltr,
children: <Widget>[
new SizedBox(key: key),
new Placeholder(key: key),
......@@ -113,11 +118,13 @@ void main() {
testWidgets('GlobalKey duplication 4 - splitting and half changing type', (WidgetTester tester) async {
final Key key = new GlobalKey(debugLabel: 'problematic');
await tester.pumpWidget(new Stack(
textDirection: TextDirection.ltr,
children: <Widget>[
new Container(key: key),
],
));
await tester.pumpWidget(new Stack(
textDirection: TextDirection.ltr,
children: <Widget>[
new Container(key: key),
new Placeholder(key: key),
......@@ -129,11 +136,13 @@ void main() {
testWidgets('GlobalKey duplication 5 - splitting and half changing type', (WidgetTester tester) async {
final Key key = new GlobalKey(debugLabel: 'problematic');
await tester.pumpWidget(new Stack(
textDirection: TextDirection.ltr,
children: <Widget>[
new Container(key: key),
],
));
await tester.pumpWidget(new Stack(
textDirection: TextDirection.ltr,
children: <Widget>[
new Placeholder(key: key),
new Container(key: key),
......@@ -145,11 +154,13 @@ void main() {
testWidgets('GlobalKey duplication 6 - splitting and not changing type', (WidgetTester tester) async {
final Key key = new GlobalKey(debugLabel: 'problematic');
await tester.pumpWidget(new Stack(
textDirection: TextDirection.ltr,
children: <Widget>[
new Container(key: key),
],
));
await tester.pumpWidget(new Stack(
textDirection: TextDirection.ltr,
children: <Widget>[
new Container(key: key),
new Container(key: key),
......@@ -161,12 +172,14 @@ void main() {
testWidgets('GlobalKey duplication 7 - appearing later', (WidgetTester tester) async {
final Key key = new GlobalKey(debugLabel: 'problematic');
await tester.pumpWidget(new Stack(
textDirection: TextDirection.ltr,
children: <Widget>[
new Container(key: const ValueKey<int>(1), child: new Container(key: key)),
new Container(key: const ValueKey<int>(2)),
],
));
await tester.pumpWidget(new Stack(
textDirection: TextDirection.ltr,
children: <Widget>[
new Container(key: const ValueKey<int>(1), child: new Container(key: key)),
new Container(key: const ValueKey<int>(2), child: new Container(key: key)),
......@@ -178,12 +191,14 @@ void main() {
testWidgets('GlobalKey duplication 8 - appearing earlier', (WidgetTester tester) async {
final Key key = new GlobalKey(debugLabel: 'problematic');
await tester.pumpWidget(new Stack(
textDirection: TextDirection.ltr,
children: <Widget>[
new Container(key: const ValueKey<int>(1)),
new Container(key: const ValueKey<int>(2), child: new Container(key: key)),
],
));
await tester.pumpWidget(new Stack(
textDirection: TextDirection.ltr,
children: <Widget>[
new Container(key: const ValueKey<int>(1), child: new Container(key: key)),
new Container(key: const ValueKey<int>(2), child: new Container(key: key)),
......@@ -195,6 +210,7 @@ void main() {
testWidgets('GlobalKey duplication 9 - moving and appearing later', (WidgetTester tester) async {
final Key key = new GlobalKey(debugLabel: 'problematic');
await tester.pumpWidget(new Stack(
textDirection: TextDirection.ltr,
children: <Widget>[
new Container(key: const ValueKey<int>(0), child: new Container(key: key)),
new Container(key: const ValueKey<int>(1)),
......@@ -202,6 +218,7 @@ void main() {
],
));
await tester.pumpWidget(new Stack(
textDirection: TextDirection.ltr,
children: <Widget>[
new Container(key: const ValueKey<int>(0)),
new Container(key: const ValueKey<int>(1), child: new Container(key: key)),
......@@ -214,6 +231,7 @@ void main() {
testWidgets('GlobalKey duplication 10 - moving and appearing earlier', (WidgetTester tester) async {
final Key key = new GlobalKey(debugLabel: 'problematic');
await tester.pumpWidget(new Stack(
textDirection: TextDirection.ltr,
children: <Widget>[
new Container(key: const ValueKey<int>(1)),
new Container(key: const ValueKey<int>(2)),
......@@ -221,6 +239,7 @@ void main() {
],
));
await tester.pumpWidget(new Stack(
textDirection: TextDirection.ltr,
children: <Widget>[
new Container(key: const ValueKey<int>(1), child: new Container(key: key)),
new Container(key: const ValueKey<int>(2), child: new Container(key: key)),
......@@ -233,6 +252,7 @@ void main() {
testWidgets('GlobalKey duplication 11 - double sibling appearance', (WidgetTester tester) async {
final Key key = new GlobalKey(debugLabel: 'problematic');
await tester.pumpWidget(new Stack(
textDirection: TextDirection.ltr,
children: <Widget>[
new Container(key: key),
new Container(key: key),
......@@ -246,6 +266,7 @@ void main() {
final Key key2 = new GlobalKey(debugLabel: 'problematic'); // intentionally the same label
final Key key3 = new GlobalKey(debugLabel: 'also problematic');
await tester.pumpWidget(new Stack(
textDirection: TextDirection.ltr,
children: <Widget>[
new Container(key: key1),
new Container(key: key1),
......@@ -284,6 +305,7 @@ void main() {
final Key key2 = new GlobalKey(debugLabel: 'problematic'); // intentionally the same label
final Key key3 = new GlobalKey(debugLabel: 'also problematic');
await tester.pumpWidget(new Stack(
textDirection: TextDirection.ltr,
children: <Widget>[
new Container(key: key1),
new Container(key: key2),
......@@ -291,6 +313,7 @@ void main() {
]),
);
await tester.pumpWidget(new Stack(
textDirection: TextDirection.ltr,
children: <Widget>[
new Container(key: key1),
new Container(key: key1),
......@@ -327,6 +350,7 @@ void main() {
testWidgets('GlobalKey duplication 14 - moving during build - before', (WidgetTester tester) async {
final Key key = new GlobalKey(debugLabel: 'problematic');
await tester.pumpWidget(new Stack(
textDirection: TextDirection.ltr,
children: <Widget>[
new Container(key: key),
new Container(key: const ValueKey<int>(0)),
......@@ -334,6 +358,7 @@ void main() {
],
));
await tester.pumpWidget(new Stack(
textDirection: TextDirection.ltr,
children: <Widget>[
new Container(key: const ValueKey<int>(0)),
new Container(key: const ValueKey<int>(1), child: new Container(key: key)),
......@@ -344,6 +369,7 @@ void main() {
testWidgets('GlobalKey duplication 15 - duplicating during build - before', (WidgetTester tester) async {
final Key key = new GlobalKey(debugLabel: 'problematic');
await tester.pumpWidget(new Stack(
textDirection: TextDirection.ltr,
children: <Widget>[
new Container(key: key),
new Container(key: const ValueKey<int>(0)),
......@@ -351,6 +377,7 @@ void main() {
],
));
await tester.pumpWidget(new Stack(
textDirection: TextDirection.ltr,
children: <Widget>[
new Container(key: key),
new Container(key: const ValueKey<int>(0)),
......@@ -363,6 +390,7 @@ void main() {
testWidgets('GlobalKey duplication 16 - moving during build - after', (WidgetTester tester) async {
final Key key = new GlobalKey(debugLabel: 'problematic');
await tester.pumpWidget(new Stack(
textDirection: TextDirection.ltr,
children: <Widget>[
new Container(key: const ValueKey<int>(0)),
new Container(key: const ValueKey<int>(1)),
......@@ -370,6 +398,7 @@ void main() {
],
));
await tester.pumpWidget(new Stack(
textDirection: TextDirection.ltr,
children: <Widget>[
new Container(key: const ValueKey<int>(0)),
new Container(key: const ValueKey<int>(1), child: new Container(key: key)),
......@@ -380,6 +409,7 @@ void main() {
testWidgets('GlobalKey duplication 17 - duplicating during build - after', (WidgetTester tester) async {
final Key key = new GlobalKey(debugLabel: 'problematic');
await tester.pumpWidget(new Stack(
textDirection: TextDirection.ltr,
children: <Widget>[
new Container(key: const ValueKey<int>(0)),
new Container(key: const ValueKey<int>(1)),
......@@ -393,6 +423,7 @@ void main() {
count += 1;
};
await tester.pumpWidget(new Stack(
textDirection: TextDirection.ltr,
children: <Widget>[
new Container(key: const ValueKey<int>(0)),
new Container(key: const ValueKey<int>(1), child: new Container(key: key)),
......
......@@ -25,7 +25,7 @@ void main() {
},
child: new Container(
color: const Color(0xFF00FF00),
)
),
);
await tester.pumpWidget(widget);
......@@ -70,7 +70,7 @@ void main() {
onHorizontalDragEnd: (DragEndDetails details) { fail('gesture should not match'); },
child: new Container(
color: const Color(0xFF00FF00),
)
),
);
await tester.pumpWidget(widget);
......@@ -106,8 +106,8 @@ void main() {
},
child: new Container(
color: const Color(0xFF00FF00),
)
)
),
),
);
expect(didStartPan, isFalse);
......@@ -128,30 +128,33 @@ void main() {
Future<Null> pumpWidgetTree(HitTestBehavior behavior) {
return tester.pumpWidget(
new Stack(
children: <Widget>[
new Listener(
onPointerDown: (_) {
didReceivePointerDown = true;
},
child: new Container(
new Directionality(
textDirection: TextDirection.ltr,
child: new Stack(
children: <Widget>[
new Listener(
onPointerDown: (_) {
didReceivePointerDown = true;
},
child: new Container(
width: 100.0,
height: 100.0,
color: const Color(0xFF00FF00),
),
),
new Container(
width: 100.0,
height: 100.0,
color: const Color(0xFF00FF00),
)
),
new Container(
width: 100.0,
height: 100.0,
child: new GestureDetector(
onTap: () {
didTap = true;
},
behavior: behavior
)
)
]
)
child: new GestureDetector(
onTap: () {
didTap = true;
},
behavior: behavior,
),
),
],
),
),
);
}
......@@ -193,8 +196,8 @@ void main() {
onTap: () {
didTap = true;
},
)
)
),
),
);
expect(didTap, isFalse);
await tester.tapAt(const Offset(10.0, 10.0));
......@@ -210,8 +213,8 @@ void main() {
didTap = true;
},
child: new Container(),
)
)
),
),
);
expect(didTap, isFalse);
await tester.tapAt(const Offset(10.0, 10.0));
......@@ -222,24 +225,24 @@ void main() {
final GestureTapCallback inputCallback = () {};
await tester.pumpWidget(
new Center(
child: new GestureDetector(
onTap: inputCallback,
child: new Container(),
)
)
new Center(
child: new GestureDetector(
onTap: inputCallback,
child: new Container(),
),
),
);
final RenderSemanticsGestureHandler renderObj1 = tester.renderObject(find.byType(GestureDetector));
final GestureTapCallback actualCallback1 = renderObj1.onTap;
await tester.pumpWidget(
new Center(
child: new GestureDetector(
onTap: inputCallback,
child: new Container(),
)
)
new Center(
child: new GestureDetector(
onTap: inputCallback,
child: new Container(),
),
),
);
final RenderSemanticsGestureHandler renderObj2 = tester.renderObject(find.byType(GestureDetector));
......
......@@ -30,6 +30,7 @@ void main() {
testWidgets('ModalBarrier prevents interactions with widgets behind it', (WidgetTester tester) async {
final Widget subject = new Stack(
textDirection: TextDirection.ltr,
children: <Widget>[
tapTarget,
const ModalBarrier(dismissible: false),
......@@ -45,6 +46,7 @@ void main() {
testWidgets('ModalBarrier does not prevent interactions with widgets in front of it', (WidgetTester tester) async {
final Widget subject = new Stack(
textDirection: TextDirection.ltr,
children: <Widget>[
const ModalBarrier(dismissible: false),
tapTarget,
......
......@@ -52,16 +52,17 @@ void main() {
await tester.pumpWidget(
new Stack(
textDirection: TextDirection.ltr,
children: <Widget>[
new DecoratedBox(decoration: kBoxDecorationA),
new Positioned(
top: 10.0,
left: 10.0,
child: new DecoratedBox(decoration: kBoxDecorationB)
child: new DecoratedBox(decoration: kBoxDecorationB),
),
new DecoratedBox(decoration: kBoxDecorationC),
]
)
],
),
);
checkTree(tester, <TestParentData>[
......@@ -72,20 +73,21 @@ void main() {
await tester.pumpWidget(
new Stack(
textDirection: TextDirection.ltr,
children: <Widget>[
new Positioned(
bottom: 5.0,
right: 7.0,
child: new DecoratedBox(decoration: kBoxDecorationA)
child: new DecoratedBox(decoration: kBoxDecorationA),
),
new Positioned(
top: 10.0,
left: 10.0,
child: new DecoratedBox(decoration: kBoxDecorationB)
child: new DecoratedBox(decoration: kBoxDecorationB),
),
new DecoratedBox(decoration: kBoxDecorationC),
]
)
],
),
);
checkTree(tester, <TestParentData>[
......@@ -100,20 +102,21 @@ void main() {
await tester.pumpWidget(
new Stack(
textDirection: TextDirection.ltr,
children: <Widget>[
new Positioned(
bottom: 5.0,
right: 7.0,
child: kDecoratedBoxA
child: kDecoratedBoxA,
),
new Positioned(
top: 10.0,
left: 10.0,
child: kDecoratedBoxB
child: kDecoratedBoxB,
),
kDecoratedBoxC,
]
)
],
),
);
checkTree(tester, <TestParentData>[
......@@ -124,20 +127,21 @@ void main() {
await tester.pumpWidget(
new Stack(
textDirection: TextDirection.ltr,
children: <Widget>[
new Positioned(
bottom: 6.0,
right: 8.0,
child: kDecoratedBoxA
child: kDecoratedBoxA,
),
new Positioned(
left: 10.0,
right: 10.0,
child: kDecoratedBoxB
child: kDecoratedBoxB,
),
kDecoratedBoxC,
]
)
],
),
);
checkTree(tester, <TestParentData>[
......@@ -148,16 +152,17 @@ void main() {
await tester.pumpWidget(
new Stack(
textDirection: TextDirection.ltr,
children: <Widget>[
kDecoratedBoxA,
new Positioned(
left: 11.0,
right: 12.0,
child: new Container(child: kDecoratedBoxB)
child: new Container(child: kDecoratedBoxB),
),
kDecoratedBoxC,
]
)
],
),
);
checkTree(tester, <TestParentData>[
......@@ -168,20 +173,21 @@ void main() {
await tester.pumpWidget(
new Stack(
textDirection: TextDirection.ltr,
children: <Widget>[
kDecoratedBoxA,
new Positioned(
right: 10.0,
child: new Container(child: kDecoratedBoxB)
child: new Container(child: kDecoratedBoxB),
),
new Container(
child: new Positioned(
top: 8.0,
child: kDecoratedBoxC
)
)
]
)
child: kDecoratedBoxC,
),
),
],
),
);
checkTree(tester, <TestParentData>[
......@@ -192,13 +198,14 @@ void main() {
await tester.pumpWidget(
new Stack(
textDirection: TextDirection.ltr,
children: <Widget>[
new Positioned(
right: 10.0,
child: new FlipWidget(left: kDecoratedBoxA, right: kDecoratedBoxB)
child: new FlipWidget(left: kDecoratedBoxA, right: kDecoratedBoxB),
),
]
)
],
),
);
checkTree(tester, <TestParentData>[
......@@ -214,13 +221,14 @@ void main() {
await tester.pumpWidget(
new Stack(
textDirection: TextDirection.ltr,
children: <Widget>[
new Positioned(
top: 7.0,
child: new FlipWidget(left: kDecoratedBoxA, right: kDecoratedBoxB)
child: new FlipWidget(left: kDecoratedBoxA, right: kDecoratedBoxB),
),
]
)
],
),
);
checkTree(tester, <TestParentData>[
......@@ -235,7 +243,7 @@ void main() {
]);
await tester.pumpWidget(
new Stack()
new Stack(textDirection: TextDirection.ltr)
);
checkTree(tester, <TestParentData>[]);
......@@ -244,6 +252,7 @@ void main() {
testWidgets('ParentDataWidget conflicting data', (WidgetTester tester) async {
await tester.pumpWidget(
new Stack(
textDirection: TextDirection.ltr,
children: <Widget>[
new Positioned(
top: 5.0,
......@@ -251,15 +260,15 @@ void main() {
child: new Positioned(
top: 6.0,
left: 7.0,
child: new DecoratedBox(decoration: kBoxDecorationB)
)
)
]
)
child: new DecoratedBox(decoration: kBoxDecorationB),
),
),
],
),
);
expect(tester.takeException(), isFlutterError);
await tester.pumpWidget(new Stack());
await tester.pumpWidget(new Stack(textDirection: TextDirection.ltr));
checkTree(tester, <TestParentData>[]);
......@@ -270,16 +279,16 @@ void main() {
new Positioned(
top: 6.0,
left: 7.0,
child: new DecoratedBox(decoration: kBoxDecorationB)
)
]
)
)
child: new DecoratedBox(decoration: kBoxDecorationB),
),
],
),
),
);
expect(tester.takeException(), isFlutterError);
await tester.pumpWidget(
new Stack()
new Stack(textDirection: TextDirection.ltr)
);
checkTree(tester, <TestParentData>[]);
......@@ -290,14 +299,15 @@ void main() {
await tester.pumpWidget(
new Stack(
textDirection: TextDirection.ltr,
children: <Widget>[
new Positioned(
top: 10.0,
left: 10.0,
child: new DecoratedBox(key: key, decoration: kBoxDecorationA)
)
]
)
child: new DecoratedBox(key: key, decoration: kBoxDecorationA),
),
],
),
);
checkTree(tester, <TestParentData>[
......@@ -306,17 +316,18 @@ void main() {
await tester.pumpWidget(
new Stack(
textDirection: TextDirection.ltr,
children: <Widget>[
new Positioned(
top: 10.0,
left: 10.0,
child: new DecoratedBox(
decoration: kBoxDecorationB,
child: new DecoratedBox(key: key, decoration: kBoxDecorationA)
)
)
]
)
child: new DecoratedBox(key: key, decoration: kBoxDecorationA),
),
),
],
),
);
checkTree(tester, <TestParentData>[
......@@ -325,14 +336,15 @@ void main() {
await tester.pumpWidget(
new Stack(
textDirection: TextDirection.ltr,
children: <Widget>[
new Positioned(
top: 10.0,
left: 10.0,
child: new DecoratedBox(key: key, decoration: kBoxDecorationA)
)
]
)
child: new DecoratedBox(key: key, decoration: kBoxDecorationA),
),
],
),
);
checkTree(tester, <TestParentData>[
......@@ -344,6 +356,7 @@ void main() {
await tester.pumpWidget(new Row(
children: <Widget>[
new Stack(
textDirection: TextDirection.ltr,
children: <Widget>[
new Expanded(
child: new Container()
......
......@@ -13,11 +13,11 @@ void main() {
expect(tester.renderObject<RenderBox>(find.byType(Placeholder)).size, const Size(800.0, 600.0));
await tester.pumpWidget(const Center(child: const Placeholder()));
expect(tester.renderObject<RenderBox>(find.byType(Placeholder)).size, const Size(800.0, 600.0));
await tester.pumpWidget(new Stack(children: <Widget>[const Positioned(top: 0.0, bottom: 0.0, child: const Placeholder())]));
await tester.pumpWidget(new Stack(textDirection: TextDirection.ltr, children: <Widget>[const Positioned(top: 0.0, bottom: 0.0, child: const Placeholder())]));
expect(tester.renderObject<RenderBox>(find.byType(Placeholder)).size, const Size(400.0, 600.0));
await tester.pumpWidget(new Stack(children: <Widget>[const Positioned(left: 0.0, right: 0.0, child: const Placeholder())]));
await tester.pumpWidget(new Stack(textDirection: TextDirection.ltr, children: <Widget>[const Positioned(left: 0.0, right: 0.0, child: const Placeholder())]));
expect(tester.renderObject<RenderBox>(find.byType(Placeholder)).size, const Size(800.0, 400.0));
await tester.pumpWidget(new Stack(children: <Widget>[const Positioned(top: 0.0, child: const Placeholder(fallbackWidth: 200.0, fallbackHeight: 300.0))]));
await tester.pumpWidget(new Stack(textDirection: TextDirection.ltr, children: <Widget>[const Positioned(top: 0.0, child: const Placeholder(fallbackWidth: 200.0, fallbackHeight: 300.0))]));
expect(tester.renderObject<RenderBox>(find.byType(Placeholder)).size, const Size(200.0, 300.0));
});
......
......@@ -60,11 +60,11 @@ void main() {
final RelativeRectTween rect = new RelativeRectTween(
begin: new RelativeRect.fromRect(
new Rect.fromLTRB(10.0, 20.0, 20.0, 30.0),
new Rect.fromLTRB(0.0, 10.0, 100.0, 110.0)
new Rect.fromLTRB(0.0, 10.0, 100.0, 110.0),
),
end: new RelativeRect.fromRect(
new Rect.fromLTRB(80.0, 90.0, 90.0, 100.0),
new Rect.fromLTRB(0.0, 10.0, 100.0, 110.0)
new Rect.fromLTRB(0.0, 10.0, 100.0, 110.0),
)
);
final AnimationController controller = new AnimationController(
......@@ -83,22 +83,25 @@ void main() {
}
await tester.pumpWidget(
new Center(
child: new Container(
height: 100.0,
width: 100.0,
child: new Stack(
children: <Widget>[
new PositionedTransition(
rect: rect.animate(controller),
child: new Container(
key: key
)
)
]
)
)
)
new Directionality(
textDirection: TextDirection.ltr,
child: new Center(
child: new Container(
height: 100.0,
width: 100.0,
child: new Stack(
children: <Widget>[
new PositionedTransition(
rect: rect.animate(controller),
child: new Container(
key: key,
),
),
],
),
),
),
),
); // t=0
recordMetrics();
final Completer<Null> completer = new Completer<Null>();
......
......@@ -38,7 +38,8 @@ class OrderSwitcherState extends State<OrderSwitcher> {
children.add(widget.a);
}
return new Stack(
children: children
textDirection: TextDirection.ltr,
children: children,
);
}
}
......
......@@ -56,6 +56,7 @@ void main() {
final StateMarker grandchild = const StateMarker();
await tester.pumpWidget(
new Stack(
textDirection: TextDirection.ltr,
children: <Widget>[
new Container(
child: new StateMarker(key: left)
......@@ -82,6 +83,7 @@ void main() {
final StateMarker newGrandchild = const StateMarker();
await tester.pumpWidget(
new Stack(
textDirection: TextDirection.ltr,
children: <Widget>[
new Container(
child: new StateMarker(
......@@ -129,6 +131,7 @@ void main() {
final StateMarker grandchild = const StateMarker();
await tester.pumpWidget(
new Stack(
textDirection: TextDirection.ltr,
children: <Widget>[
new StateMarker(key: left),
new StateMarker(
......@@ -151,6 +154,7 @@ void main() {
final StateMarker newGrandchild = const StateMarker();
await tester.pumpWidget(
new Stack(
textDirection: TextDirection.ltr,
children: <Widget>[
new StateMarker(
key: right,
......@@ -224,6 +228,7 @@ void main() {
final GlobalKey key = new GlobalKey();
await tester.pumpWidget(new Stack(
textDirection: TextDirection.ltr,
children: <Widget>[
new StateMarker(key: key),
new Container(width: 100.0, height: 100.0),
......@@ -234,6 +239,7 @@ void main() {
keyState.marker = "marked";
await tester.pumpWidget(new Stack(
textDirection: TextDirection.ltr,
children: <Widget>[
new Container(width: 100.0, height: 100.0),
new StateMarker(key: key),
......@@ -244,6 +250,7 @@ void main() {
expect(keyState.marker, equals("marked"));
await tester.pumpWidget(new Stack(
textDirection: TextDirection.ltr,
children: <Widget>[
new StateMarker(key: key),
new Container(width: 100.0, height: 100.0),
......@@ -258,6 +265,7 @@ void main() {
final GlobalKey key = new GlobalKey();
await tester.pumpWidget(new Stack(
textDirection: TextDirection.ltr,
children: <Widget>[
new Container(width: 100.0, height: 100.0),
new StateMarker(key: key),
......@@ -269,6 +277,7 @@ void main() {
keyState.marker = "marked";
await tester.pumpWidget(new Stack(
textDirection: TextDirection.ltr,
children: <Widget>[
new Container(width: 100.0, height: 100.0, child: new StateMarker(key: key)),
new Container(width: 100.0, height: 100.0),
......@@ -279,6 +288,7 @@ void main() {
expect(keyState.marker, equals("marked"));
await tester.pumpWidget(new Stack(
textDirection: TextDirection.ltr,
children: <Widget>[
new Container(width: 100.0, height: 100.0),
new StateMarker(key: key),
......@@ -290,6 +300,7 @@ void main() {
expect(keyState.marker, equals("marked"));
await tester.pumpWidget(new Stack(
textDirection: TextDirection.ltr,
children: <Widget>[
new Container(width: 100.0, height: 100.0),
new Container(width: 100.0, height: 100.0, child: new StateMarker(key: key)),
......@@ -300,6 +311,7 @@ void main() {
expect(keyState.marker, equals("marked"));
await tester.pumpWidget(new Stack(
textDirection: TextDirection.ltr,
children: <Widget>[
new Container(width: 100.0, height: 100.0),
new StateMarker(key: key),
......
......@@ -109,10 +109,15 @@ void main() {
testWidgets('Route management - push, replace, pop', (WidgetTester tester) async {
final GlobalKey<NavigatorState> navigatorKey = new GlobalKey<NavigatorState>();
await tester.pumpWidget(new Navigator(
key: navigatorKey,
onGenerateRoute: (_) => new TestRoute('initial')
));
await tester.pumpWidget(
new Directionality(
textDirection: TextDirection.ltr,
child: new Navigator(
key: navigatorKey,
onGenerateRoute: (_) => new TestRoute('initial'),
),
),
);
final NavigatorState host = navigatorKey.currentState;
await runNavigatorTest(
tester,
......@@ -187,10 +192,15 @@ void main() {
testWidgets('Route management - push, remove, pop', (WidgetTester tester) async {
final GlobalKey<NavigatorState> navigatorKey = new GlobalKey<NavigatorState>();
await tester.pumpWidget(new Navigator(
key: navigatorKey,
onGenerateRoute: (_) => new TestRoute('first')
));
await tester.pumpWidget(
new Directionality(
textDirection: TextDirection.ltr,
child: new Navigator(
key: navigatorKey,
onGenerateRoute: (_) => new TestRoute('first')
),
),
);
final NavigatorState host = navigatorKey.currentState;
await runNavigatorTest(
tester,
......@@ -293,10 +303,15 @@ void main() {
testWidgets('Route management - push, replace, popUntil', (WidgetTester tester) async {
final GlobalKey<NavigatorState> navigatorKey = new GlobalKey<NavigatorState>();
await tester.pumpWidget(new Navigator(
key: navigatorKey,
onGenerateRoute: (_) => new TestRoute('A')
));
await tester.pumpWidget(
new Directionality(
textDirection: TextDirection.ltr,
child: new Navigator(
key: navigatorKey,
onGenerateRoute: (_) => new TestRoute('A')
),
),
);
final NavigatorState host = navigatorKey.currentState;
await runNavigatorTest(
tester,
......@@ -370,10 +385,15 @@ void main() {
onRemove: () { routeA.log('onRemove 1'); }
));
final GlobalKey<NavigatorState> navigatorKey = new GlobalKey<NavigatorState>();
await tester.pumpWidget(new Navigator(
key: navigatorKey,
onGenerateRoute: (_) => routeA
));
await tester.pumpWidget(
new Directionality(
textDirection: TextDirection.ltr,
child: new Navigator(
key: navigatorKey,
onGenerateRoute: (_) => routeA
),
),
);
final NavigatorState host = navigatorKey.currentState;
await runNavigatorTest(
tester,
......
......@@ -14,6 +14,7 @@ void main() {
await tester.pumpWidget(
new Stack(
textDirection: TextDirection.ltr,
fit: StackFit.expand,
children: <Widget>[
const Semantics(
......
......@@ -21,6 +21,7 @@ void main() {
child: new Semantics(
container: true,
child: new Stack(
textDirection: TextDirection.ltr,
children: <Widget>[
const Semantics(
checked: true,
......@@ -52,6 +53,7 @@ void main() {
child: new Semantics(
container: true,
child: new Stack(
textDirection: TextDirection.ltr,
children: <Widget>[
const Semantics(
label: 'label',
......
......@@ -15,6 +15,7 @@ void main() {
final SemanticsTester semantics = new SemanticsTester(tester);
await tester.pumpWidget(new Stack(
textDirection: TextDirection.ltr,
children: <Widget>[
new Semantics(
label: 'layer#1',
......@@ -33,6 +34,7 @@ void main() {
expect(semantics, isNot(includesNodeWith(label: 'layer#1')));
await tester.pumpWidget(new Stack(
textDirection: TextDirection.ltr,
children: <Widget>[
new Semantics(
label: 'layer#1',
......
......@@ -12,22 +12,8 @@ void main() {
// This is a smoketest to verify that adding a debugger doesn't crash.
await tester.pumpWidget(
new Stack(
children: <Widget>[
const Semantics(),
const Semantics(
container: true,
),
const Semantics(
label: 'label',
textDirection: TextDirection.ltr,
),
],
),
);
await tester.pumpWidget(
new SemanticsDebugger(
new Directionality(
textDirection: TextDirection.ltr,
child: new Stack(
children: <Widget>[
const Semantics(),
......@@ -43,6 +29,26 @@ void main() {
),
);
await tester.pumpWidget(
new Directionality(
textDirection: TextDirection.ltr,
child: new SemanticsDebugger(
child: new Stack(
children: <Widget>[
const Semantics(),
const Semantics(
container: true,
),
const Semantics(
label: 'label',
textDirection: TextDirection.ltr,
),
],
),
),
),
);
expect(true, isTrue); // expect that we reach here without crashing
});
......@@ -51,71 +57,80 @@ void main() {
final GlobalKey key = new GlobalKey();
await tester.pumpWidget(
new SemanticsDebugger(
child: new Stack(
children: <Widget>[
const Semantics(label: 'label1', textDirection: TextDirection.ltr),
new Positioned(
key: key,
left: 0.0,
top: 0.0,
width: 100.0,
height: 100.0,
child: const Semantics(label: 'label2', textDirection: TextDirection.ltr),
),
],
),
),
);
await tester.pumpWidget(
new SemanticsDebugger(
child: new Stack(
children: <Widget>[
const Semantics(label: 'label1', textDirection: TextDirection.ltr),
new Semantics(
container: true,
child: new Stack(
children: <Widget>[
new Positioned(
key: key,
left: 0.0,
top: 0.0,
width: 100.0,
height: 100.0,
child: const Semantics(label: 'label2', textDirection: TextDirection.ltr),
),
const Semantics(label: 'label3', textDirection: TextDirection.ltr),
],
new Directionality(
textDirection: TextDirection.ltr,
child: new SemanticsDebugger(
child: new Stack(
children: <Widget>[
const Semantics(label: 'label1', textDirection: TextDirection.ltr),
new Positioned(
key: key,
left: 0.0,
top: 0.0,
width: 100.0,
height: 100.0,
child: const Semantics(label: 'label2', textDirection: TextDirection.ltr),
),
),
],
],
),
),
),
);
await tester.pumpWidget(
new SemanticsDebugger(
child: new Stack(
children: <Widget>[
const Semantics(label: 'label1', textDirection: TextDirection.ltr),
new Semantics(
container: true,
child: new Stack(
children: <Widget>[
new Positioned(
new Directionality(
textDirection: TextDirection.ltr,
child: new SemanticsDebugger(
child: new Stack(
children: <Widget>[
const Semantics(label: 'label1', textDirection: TextDirection.ltr),
new Semantics(
container: true,
child: new Stack(
children: <Widget>[
new Positioned(
key: key,
left: 0.0,
top: 0.0,
width: 100.0,
height: 100.0,
child: const Semantics(label: 'label2', textDirection: TextDirection.ltr)),
const Semantics(label: 'label3', textDirection: TextDirection.ltr),
const Semantics(label: 'label4', textDirection: TextDirection.ltr),
],
child: const Semantics(label: 'label2', textDirection: TextDirection.ltr),
),
const Semantics(label: 'label3', textDirection: TextDirection.ltr),
],
),
),
),
],
],
),
),
),
);
await tester.pumpWidget(
new Directionality(
textDirection: TextDirection.ltr,
child: new SemanticsDebugger(
child: new Stack(
children: <Widget>[
const Semantics(label: 'label1', textDirection: TextDirection.ltr),
new Semantics(
container: true,
child: new Stack(
children: <Widget>[
new Positioned(
key: key,
left: 0.0,
top: 0.0,
width: 100.0,
height: 100.0,
child: const Semantics(label: 'label2', textDirection: TextDirection.ltr)),
const Semantics(label: 'label3', textDirection: TextDirection.ltr),
const Semantics(label: 'label4', textDirection: TextDirection.ltr),
],
),
),
],
),
),
),
);
......@@ -250,13 +265,16 @@ void main() {
bool didLongPress = false;
await tester.pumpWidget(
new SemanticsDebugger(
child: new GestureDetector(
onLongPress: () {
expect(didLongPress, isFalse);
didLongPress = true;
},
child: const Text('target', textDirection: TextDirection.ltr),
new Directionality(
textDirection: TextDirection.ltr,
child: new SemanticsDebugger(
child: new GestureDetector(
onLongPress: () {
expect(didLongPress, isFalse);
didLongPress = true;
},
child: const Text('target', textDirection: TextDirection.ltr),
),
),
),
);
......@@ -269,16 +287,19 @@ void main() {
double value = 0.75;
await tester.pumpWidget(
new SemanticsDebugger(
child: new Directionality(
textDirection: TextDirection.ltr,
child: new Material(
child: new Center(
child: new Slider(
value: value,
onChanged: (double newValue) {
value = newValue;
},
new Directionality(
textDirection: TextDirection.ltr,
child: new SemanticsDebugger(
child: new Directionality(
textDirection: TextDirection.ltr,
child: new Material(
child: new Center(
child: new Slider(
value: value,
onChanged: (double newValue) {
value = newValue;
},
),
),
),
),
......
......@@ -13,38 +13,41 @@ void main() {
testWidgets('Transform origin', (WidgetTester tester) async {
bool didReceiveTap = false;
await tester.pumpWidget(
new Stack(
children: <Widget>[
new Positioned(
top: 100.0,
left: 100.0,
child: new Container(
width: 100.0,
height: 100.0,
color: const Color(0xFF0000FF),
new Directionality(
textDirection: TextDirection.ltr,
child: new Stack(
children: <Widget>[
new Positioned(
top: 100.0,
left: 100.0,
child: new Container(
width: 100.0,
height: 100.0,
color: const Color(0xFF0000FF),
),
),
),
new Positioned(
top: 100.0,
left: 100.0,
child: new Container(
width: 100.0,
height: 100.0,
child: new Transform(
transform: new Matrix4.diagonal3Values(0.5, 0.5, 1.0),
origin: const Offset(100.0, 50.0),
child: new GestureDetector(
onTap: () {
didReceiveTap = true;
},
child: new Container(
color: const Color(0xFF00FFFF),
new Positioned(
top: 100.0,
left: 100.0,
child: new Container(
width: 100.0,
height: 100.0,
child: new Transform(
transform: new Matrix4.diagonal3Values(0.5, 0.5, 1.0),
origin: const Offset(100.0, 50.0),
child: new GestureDetector(
onTap: () {
didReceiveTap = true;
},
child: new Container(
color: const Color(0xFF00FFFF),
),
),
),
),
),
),
],
],
),
),
);
......@@ -58,38 +61,41 @@ void main() {
testWidgets('Transform alignment', (WidgetTester tester) async {
bool didReceiveTap = false;
await tester.pumpWidget(
new Stack(
children: <Widget>[
new Positioned(
top: 100.0,
left: 100.0,
child: new Container(
width: 100.0,
height: 100.0,
color: const Color(0xFF0000FF),
new Directionality(
textDirection: TextDirection.ltr,
child: new Stack(
children: <Widget>[
new Positioned(
top: 100.0,
left: 100.0,
child: new Container(
width: 100.0,
height: 100.0,
color: const Color(0xFF0000FF),
),
),
),
new Positioned(
top: 100.0,
left: 100.0,
child: new Container(
width: 100.0,
height: 100.0,
child: new Transform(
transform: new Matrix4.diagonal3Values(0.5, 0.5, 1.0),
alignment: const FractionalOffset(1.0, 0.5),
child: new GestureDetector(
onTap: () {
didReceiveTap = true;
},
child: new Container(
color: const Color(0xFF00FFFF),
new Positioned(
top: 100.0,
left: 100.0,
child: new Container(
width: 100.0,
height: 100.0,
child: new Transform(
transform: new Matrix4.diagonal3Values(0.5, 0.5, 1.0),
alignment: const FractionalOffset(1.0, 0.5),
child: new GestureDetector(
onTap: () {
didReceiveTap = true;
},
child: new Container(
color: const Color(0xFF00FFFF),
),
),
),
),
),
),
],
],
),
),
);
......@@ -102,40 +108,45 @@ void main() {
testWidgets('Transform offset + alignment', (WidgetTester tester) async {
bool didReceiveTap = false;
await tester.pumpWidget(new Stack(
children: <Widget>[
new Positioned(
top: 100.0,
left: 100.0,
child: new Container(
width: 100.0,
height: 100.0,
color: const Color(0xFF0000FF),
),
),
new Positioned(
top: 100.0,
left: 100.0,
child: new Container(
width: 100.0,
height: 100.0,
child: new Transform(
transform: new Matrix4.diagonal3Values(0.5, 0.5, 1.0),
origin: const Offset(100.0, 0.0),
alignment: const FractionalOffset(0.0, 0.5),
child: new GestureDetector(
onTap: () {
didReceiveTap = true;
},
child: new Container(
color: const Color(0xFF00FFFF),
await tester.pumpWidget(
new Directionality(
textDirection: TextDirection.ltr,
child: new Stack(
children: <Widget>[
new Positioned(
top: 100.0,
left: 100.0,
child: new Container(
width: 100.0,
height: 100.0,
color: const Color(0xFF0000FF),
),
),
new Positioned(
top: 100.0,
left: 100.0,
child: new Container(
width: 100.0,
height: 100.0,
child: new Transform(
transform: new Matrix4.diagonal3Values(0.5, 0.5, 1.0),
origin: const Offset(100.0, 0.0),
alignment: const FractionalOffset(0.0, 0.5),
child: new GestureDetector(
onTap: () {
didReceiveTap = true;
},
child: new Container(
color: const Color(0xFF00FFFF),
),
),
),
),
),
),
],
),
],
));
),
);
expect(didReceiveTap, isFalse);
await tester.tapAt(const Offset(110.0, 110.0));
......
......@@ -11,18 +11,8 @@ void main() {
testWidgets('WidgetInspector smoke test', (WidgetTester tester) async {
// This is a smoke test to verify that adding the inspector doesn't crash.
await tester.pumpWidget(
new Stack(
children: <Widget>[
const Text('a', textDirection: TextDirection.ltr),
const Text('b', textDirection: TextDirection.ltr),
const Text('c', textDirection: TextDirection.ltr),
],
),
);
await tester.pumpWidget(
new WidgetInspector(
selectButtonBuilder: null,
new Directionality(
textDirection: TextDirection.ltr,
child: new Stack(
children: <Widget>[
const Text('a', textDirection: TextDirection.ltr),
......@@ -33,6 +23,22 @@ void main() {
),
);
await tester.pumpWidget(
new Directionality(
textDirection: TextDirection.ltr,
child: new WidgetInspector(
selectButtonBuilder: null,
child: new Stack(
children: <Widget>[
const Text('a', textDirection: TextDirection.ltr),
const Text('b', textDirection: TextDirection.ltr),
const Text('c', textDirection: TextDirection.ltr),
],
),
),
),
);
expect(true, isTrue); // Expect that we reach here without crashing.
});
......@@ -172,14 +178,17 @@ void main() {
bool didLongPress = false;
await tester.pumpWidget(
new WidgetInspector(
selectButtonBuilder: null,
child: new GestureDetector(
onLongPress: () {
expect(didLongPress, isFalse);
didLongPress = true;
},
child: const Text('target', textDirection: TextDirection.ltr),
new Directionality(
textDirection: TextDirection.ltr,
child: new WidgetInspector(
selectButtonBuilder: null,
child: new GestureDetector(
onLongPress: () {
expect(didLongPress, isFalse);
didLongPress = true;
},
child: const Text('target', textDirection: TextDirection.ltr),
),
),
),
);
......@@ -208,27 +217,30 @@ void main() {
);
}
await tester.pumpWidget(
new WidgetInspector(
key: inspectorKey,
selectButtonBuilder: null,
child: new Overlay(
initialEntries: <OverlayEntry>[
new OverlayEntry(
opaque: false,
maintainState: true,
builder: (BuildContext _) => createSubtree(width: 94.0),
),
new OverlayEntry(
opaque: true,
maintainState: true,
builder: (BuildContext _) => createSubtree(width: 95.0),
),
new OverlayEntry(
opaque: false,
maintainState: true,
builder: (BuildContext _) => createSubtree(width: 96.0, key: clickTarget),
),
],
new Directionality(
textDirection: TextDirection.ltr,
child: new WidgetInspector(
key: inspectorKey,
selectButtonBuilder: null,
child: new Overlay(
initialEntries: <OverlayEntry>[
new OverlayEntry(
opaque: false,
maintainState: true,
builder: (BuildContext _) => createSubtree(width: 94.0),
),
new OverlayEntry(
opaque: true,
maintainState: true,
builder: (BuildContext _) => createSubtree(width: 95.0),
),
new OverlayEntry(
opaque: false,
maintainState: true,
builder: (BuildContext _) => createSubtree(width: 96.0, key: clickTarget),
),
],
),
),
),
);
......
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