// Copyright 2016 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_test/flutter_test.dart';
import 'package:flutter/widgets.dart';
class TestUniqueWidget extends UniqueWidget<TestUniqueWidgetState> {
const TestUniqueWidget({ GlobalKey<TestUniqueWidgetState> key }) : super(key: key);
@override
TestUniqueWidgetState createState() => new TestUniqueWidgetState();
}
class TestUniqueWidgetState extends State<TestUniqueWidget> {
@override
Widget build(BuildContext context) => new Container();
}
void main() {
testWidgets('Unique widget control test', (WidgetTester tester) async {
final TestUniqueWidget widget = new TestUniqueWidget(key: new GlobalKey<TestUniqueWidgetState>());
await tester.pumpWidget(widget);
final TestUniqueWidgetState state = widget.currentState;
expect(state, isNotNull);
await tester.pumpWidget(new Container(child: widget));
expect(widget.currentState, equals(state));
});
}
-
Vyacheslav Egorov authored
* Use explicit types for onClick handler in diagnostics_test. This test formats it to string and expects exact match. Before this change onClick had type () => dynamic in Dart 1 and () => Null in Dart 2. * Fix strong mode issues in packages/flutter/test/material/dropdown_test.dart Pass explicit type argument to renderObjectList(...) in expressions like List<RenderBox> l = tester.renderObjectList(...).toList(); Dart 2 mode inference is not strong enough to infer RenderBox as a type argument fto renderObjectList and passes RenderObject instead, which later leads to runtime check failures (because List<RenderObject> is not List<RenderBox>). * Fix strong mode issues in packages/flutter/test/material/theme_test.dart. Pass type argument explicity to widgetList. Dart 2 type inference can't infer it by itself. * Fix strong mode issue packages/flutter/test/widgets/unique_widget_test.dart Pass correct type argument to GlobalKey. * Fix type annotation in packages/flutter/test/material/app_test.dart. pushNamed returns Future<Object> not Future<String>.