提交 2510e316 编写于 作者: A Adam Barth

Merge pull request #1538 from abarth/fix_snackbar

SnackBar throws exception on creation
......@@ -245,6 +245,10 @@ abstract class Route {
}
abstract class PerformanceRoute extends Route {
PerformanceRoute() {
_performance = createPerformance();
}
PerformanceView get performance => _performance?.view;
Performance _performance;
......@@ -261,7 +265,6 @@ abstract class PerformanceRoute extends Route {
Widget build(NavigatorState navigator, PerformanceView nextRoutePerformance);
void didPush(NavigatorState navigator) {
_performance = createPerformance();
super.didPush(navigator);
_performance?.forward();
}
......
import 'package:sky/widgets.dart';
import 'package:test/test.dart';
import 'widget_tester.dart';
void main() {
test('SnackBar control test', () {
testWidgets((WidgetTester tester) {
String helloSnackBar = 'Hello SnackBar';
GlobalKey<PlaceholderState> placeholderKey = new GlobalKey<PlaceholderState>();
Key tapTarget = new Key('tap-target');
tester.pumpWidget(new App(
routes: {
'/': (RouteArguments args) {
return new GestureDetector(
onTap: () {
showSnackBar(
navigator: args.navigator,
placeholderKey: placeholderKey,
content: new Text(helloSnackBar)
);
},
child: new Center(
key: tapTarget,
child: new Placeholder(key: placeholderKey)
)
);
}
}
));
tester.tap(tester.findElementByKey(tapTarget));
expect(tester.findText(helloSnackBar), isNull);
tester.pump();
expect(tester.findText(helloSnackBar), isNotNull);
});
});
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册