From 0d402242c57783b05989c6c729483d54fa05c567 Mon Sep 17 00:00:00 2001 From: Adam Barth Date: Mon, 3 Apr 2017 22:50:30 -0700 Subject: [PATCH] Test that MaterialApp can be inside a FocusScope (#9141) The underlying issue was fixed by the new focus system. Fixes #1523 --- packages/flutter/test/material/app_test.dart | 40 +++++++++++++------- 1 file changed, 27 insertions(+), 13 deletions(-) diff --git a/packages/flutter/test/material/app_test.dart b/packages/flutter/test/material/app_test.dart index 8758c07499..96d9610449 100644 --- a/packages/flutter/test/material/app_test.dart +++ b/packages/flutter/test/material/app_test.dart @@ -30,9 +30,9 @@ void main() { await tester.pumpWidget( new MaterialApp( home: new MaterialApp( - home: new Text('Home sweet home') - ) - ) + home: new Text('Home sweet home'), + ), + ), ); expect(find.text('Home sweet home'), findsOneWidget); @@ -51,11 +51,25 @@ void main() { 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 { await tester.pumpWidget( new MaterialApp( - home: new StateMarker() - ) + home: new StateMarker(), + ), ); final StateMarkerState state1 = tester.state(find.byType(StateMarker)); @@ -64,8 +78,8 @@ void main() { await tester.pumpWidget( new MaterialApp( debugShowMaterialGrid: true, - home: new StateMarker() - ) + home: new StateMarker(), + ), ); final StateMarkerState state2 = tester.state(find.byType(StateMarker)); @@ -82,8 +96,8 @@ void main() { return new Material( child: new RaisedButton( child: new Text('X'), - onPressed: () { Navigator.of(context).pushNamed('/next'); } - ) + onPressed: () { Navigator.of(context).pushNamed('/next'); }, + ), ); } ), @@ -93,11 +107,11 @@ void main() { builder: (BuildContext context) { ++buildCounter; return new Container(); - } + }, ); - } - } - ) + }, + }, + ), ); expect(buildCounter, 0);