Commit 0d402242 authored by Adam Barth's avatar Adam Barth Committed by GitHub

Test that MaterialApp can be inside a FocusScope (#9141)

The underlying issue was fixed by the new focus system.

Fixes #1523
parent 830d163c
...@@ -30,9 +30,9 @@ void main() { ...@@ -30,9 +30,9 @@ void main() {
await tester.pumpWidget( await tester.pumpWidget(
new MaterialApp( new MaterialApp(
home: new MaterialApp( home: new MaterialApp(
home: new Text('Home sweet home') home: new Text('Home sweet home'),
) ),
) ),
); );
expect(find.text('Home sweet home'), findsOneWidget); expect(find.text('Home sweet home'), findsOneWidget);
...@@ -51,11 +51,25 @@ void main() { ...@@ -51,11 +51,25 @@ void main() {
expect(focusNode.hasFocus, isTrue); expect(focusNode.hasFocus, isTrue);
}); });
testWidgets('Can place app inside FocusScope', (WidgetTester tester) async {
final FocusScopeNode focusScopeNode = new FocusScopeNode();
await tester.pumpWidget(new FocusScope(
autofocus: true,
node: focusScopeNode,
child: new MaterialApp(
home: new Text('Home'),
),
));
expect(find.text('Home'), findsOneWidget);
});
testWidgets('Can show grid without losing sync', (WidgetTester tester) async { testWidgets('Can show grid without losing sync', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
new MaterialApp( new MaterialApp(
home: new StateMarker() home: new StateMarker(),
) ),
); );
final StateMarkerState state1 = tester.state(find.byType(StateMarker)); final StateMarkerState state1 = tester.state(find.byType(StateMarker));
...@@ -64,8 +78,8 @@ void main() { ...@@ -64,8 +78,8 @@ void main() {
await tester.pumpWidget( await tester.pumpWidget(
new MaterialApp( new MaterialApp(
debugShowMaterialGrid: true, debugShowMaterialGrid: true,
home: new StateMarker() home: new StateMarker(),
) ),
); );
final StateMarkerState state2 = tester.state(find.byType(StateMarker)); final StateMarkerState state2 = tester.state(find.byType(StateMarker));
...@@ -82,8 +96,8 @@ void main() { ...@@ -82,8 +96,8 @@ void main() {
return new Material( return new Material(
child: new RaisedButton( child: new RaisedButton(
child: new Text('X'), child: new Text('X'),
onPressed: () { Navigator.of(context).pushNamed('/next'); } onPressed: () { Navigator.of(context).pushNamed('/next'); },
) ),
); );
} }
), ),
...@@ -93,11 +107,11 @@ void main() { ...@@ -93,11 +107,11 @@ void main() {
builder: (BuildContext context) { builder: (BuildContext context) {
++buildCounter; ++buildCounter;
return new Container(); return new Container();
} },
); );
} },
} },
) ),
); );
expect(buildCounter, 0); expect(buildCounter, 0);
......
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