Unverified Commit 0e76cb4c authored by Alexandre Ardhuin's avatar Alexandre Ardhuin Committed by GitHub

prefer_void_to_null in flutter_test (#22847)

* prefer_void_to_null in flutter_test

* fix CI
parent dba54316
...@@ -12,7 +12,7 @@ import '../widgets/semantics_tester.dart'; ...@@ -12,7 +12,7 @@ import '../widgets/semantics_tester.dart';
void main() { void main() {
Future<Null> _dragSlider(WidgetTester tester, Key sliderKey) { Future<void> _dragSlider(WidgetTester tester, Key sliderKey) {
final Offset topLeft = tester.getTopLeft(find.byKey(sliderKey)); final Offset topLeft = tester.getTopLeft(find.byKey(sliderKey));
const double unit = CupertinoThumbPainter.radius; const double unit = CupertinoThumbPainter.radius;
const double delta = 3.0 * unit; const double delta = 3.0 * unit;
......
...@@ -545,7 +545,7 @@ void main() { ...@@ -545,7 +545,7 @@ void main() {
testWidgets('Avatar drawer works as expected on RawChip', (WidgetTester tester) async { testWidgets('Avatar drawer works as expected on RawChip', (WidgetTester tester) async {
final GlobalKey labelKey = GlobalKey(); final GlobalKey labelKey = GlobalKey();
Future<Null> pushChip({Widget avatar}) async { Future<void> pushChip({Widget avatar}) async {
return tester.pumpWidget( return tester.pumpWidget(
_wrapForChip( _wrapForChip(
child: Wrap( child: Wrap(
...@@ -659,7 +659,7 @@ void main() { ...@@ -659,7 +659,7 @@ void main() {
final UniqueKey labelKey = UniqueKey(); final UniqueKey labelKey = UniqueKey();
final UniqueKey deleteButtonKey = UniqueKey(); final UniqueKey deleteButtonKey = UniqueKey();
bool wasDeleted = false; bool wasDeleted = false;
Future<Null> pushChip({bool deletable = false}) async { Future<void> pushChip({bool deletable = false}) async {
return tester.pumpWidget( return tester.pumpWidget(
_wrapForChip( _wrapForChip(
child: Wrap( child: Wrap(
...@@ -774,7 +774,7 @@ void main() { ...@@ -774,7 +774,7 @@ void main() {
testWidgets('Selection with avatar works as expected on RawChip', (WidgetTester tester) async { testWidgets('Selection with avatar works as expected on RawChip', (WidgetTester tester) async {
bool selected = false; bool selected = false;
final UniqueKey labelKey = UniqueKey(); final UniqueKey labelKey = UniqueKey();
Future<Null> pushChip({Widget avatar, bool selectable = false}) async { Future<void> pushChip({Widget avatar, bool selectable = false}) async {
return tester.pumpWidget( return tester.pumpWidget(
_wrapForChip( _wrapForChip(
child: Wrap( child: Wrap(
...@@ -857,7 +857,7 @@ void main() { ...@@ -857,7 +857,7 @@ void main() {
testWidgets('Selection without avatar works as expected on RawChip', (WidgetTester tester) async { testWidgets('Selection without avatar works as expected on RawChip', (WidgetTester tester) async {
bool selected = false; bool selected = false;
final UniqueKey labelKey = UniqueKey(); final UniqueKey labelKey = UniqueKey();
Future<Null> pushChip({bool selectable = false}) async { Future<void> pushChip({bool selectable = false}) async {
return tester.pumpWidget( return tester.pumpWidget(
_wrapForChip( _wrapForChip(
child: Wrap( child: Wrap(
...@@ -933,7 +933,7 @@ void main() { ...@@ -933,7 +933,7 @@ void main() {
testWidgets('Activation works as expected on RawChip', (WidgetTester tester) async { testWidgets('Activation works as expected on RawChip', (WidgetTester tester) async {
bool selected = false; bool selected = false;
final UniqueKey labelKey = UniqueKey(); final UniqueKey labelKey = UniqueKey();
Future<Null> pushChip({Widget avatar, bool selectable = false}) async { Future<void> pushChip({Widget avatar, bool selectable = false}) async {
return tester.pumpWidget( return tester.pumpWidget(
_wrapForChip( _wrapForChip(
child: Wrap( child: Wrap(
......
...@@ -353,7 +353,7 @@ void main() { ...@@ -353,7 +353,7 @@ void main() {
group('Nested viewports (same orientation) showOnScreen', () { group('Nested viewports (same orientation) showOnScreen', () {
List<Widget> children; List<Widget> children;
Future<Null> buildNestedScroller({WidgetTester tester, ScrollController inner, ScrollController outer}) { Future<void> buildNestedScroller({WidgetTester tester, ScrollController inner, ScrollController outer}) {
return tester.pumpWidget( return tester.pumpWidget(
Directionality( Directionality(
textDirection: TextDirection.ltr, textDirection: TextDirection.ltr,
......
...@@ -346,7 +346,7 @@ void main() { ...@@ -346,7 +346,7 @@ void main() {
}); });
testWidgets('AnimatedSwitcher updates widgets without animating if they are isomorphic.', (WidgetTester tester) async { testWidgets('AnimatedSwitcher updates widgets without animating if they are isomorphic.', (WidgetTester tester) async {
Future<Null> pumpChild(Widget child) async { Future<void> pumpChild(Widget child) async {
return tester.pumpWidget( return tester.pumpWidget(
Directionality( Directionality(
textDirection: TextDirection.rtl, textDirection: TextDirection.rtl,
......
...@@ -1444,7 +1444,7 @@ void main() { ...@@ -1444,7 +1444,7 @@ void main() {
}); });
group('a11y copy/cut/paste', () { group('a11y copy/cut/paste', () {
Future<Null> _buildApp( Future<void> _buildApp(
MockTextSelectionControls controls, WidgetTester tester) { MockTextSelectionControls controls, WidgetTester tester) {
return tester.pumpWidget(MaterialApp( return tester.pumpWidget(MaterialApp(
home: EditableText( home: EditableText(
......
...@@ -126,7 +126,7 @@ void main() { ...@@ -126,7 +126,7 @@ void main() {
bool didReceivePointerDown; bool didReceivePointerDown;
bool didTap; bool didTap;
Future<Null> pumpWidgetTree(HitTestBehavior behavior) { Future<void> pumpWidgetTree(HitTestBehavior behavior) {
return tester.pumpWidget( return tester.pumpWidget(
Directionality( Directionality(
textDirection: TextDirection.ltr, textDirection: TextDirection.ltr,
......
...@@ -156,7 +156,7 @@ TestImage getTestImage(WidgetTester tester, Key key) { ...@@ -156,7 +156,7 @@ TestImage getTestImage(WidgetTester tester, Key key) {
return tester.renderObject<RenderImage>(find.byKey(key)).image; return tester.renderObject<RenderImage>(find.byKey(key)).image;
} }
Future<Null> pumpTreeToLayout(WidgetTester tester, Widget widget) { Future<void> pumpTreeToLayout(WidgetTester tester, Widget widget) {
const Duration pumpDuration = Duration(milliseconds: 0); const Duration pumpDuration = Duration(milliseconds: 0);
const EnginePhase pumpPhase = EnginePhase.layout; const EnginePhase pumpPhase = EnginePhase.layout;
return tester.pumpWidget(widget, pumpDuration, pumpPhase); return tester.pumpWidget(widget, pumpDuration, pumpPhase);
......
...@@ -697,7 +697,7 @@ void main() { ...@@ -697,7 +697,7 @@ void main() {
group('Nested SingleChildScrollView (same orientation) showOnScreen', () { group('Nested SingleChildScrollView (same orientation) showOnScreen', () {
List<Widget> children; List<Widget> children;
Future<Null> buildNestedScroller({WidgetTester tester, ScrollController inner, ScrollController outer}) { Future<void> buildNestedScroller({WidgetTester tester, ScrollController inner, ScrollController outer}) {
return tester.pumpWidget( return tester.pumpWidget(
Directionality( Directionality(
textDirection: TextDirection.ltr, textDirection: TextDirection.ltr,
......
...@@ -24,7 +24,7 @@ class _GenerationTextState extends State<GenerationText> { ...@@ -24,7 +24,7 @@ class _GenerationTextState extends State<GenerationText> {
// Creates a SliverList with `keys.length` children and each child having a key from `keys` and a text of `key:generation`. // Creates a SliverList with `keys.length` children and each child having a key from `keys` and a text of `key:generation`.
// The generation is increased with every call to this method. // The generation is increased with every call to this method.
Future<Null> test(WidgetTester tester, double offset, List<int> keys) { Future<void> test(WidgetTester tester, double offset, List<int> keys) {
globalGeneration += 1; globalGeneration += 1;
return tester.pumpWidget( return tester.pumpWidget(
Directionality( Directionality(
......
...@@ -8,7 +8,7 @@ import 'package:flutter/widgets.dart'; ...@@ -8,7 +8,7 @@ import 'package:flutter/widgets.dart';
import '../rendering/mock_canvas.dart'; import '../rendering/mock_canvas.dart';
Future<Null> test(WidgetTester tester, double offset) { Future<void> test(WidgetTester tester, double offset) {
return tester.pumpWidget( return tester.pumpWidget(
Directionality( Directionality(
textDirection: TextDirection.ltr, textDirection: TextDirection.ltr,
......
...@@ -6,7 +6,7 @@ import 'package:flutter_test/flutter_test.dart'; ...@@ -6,7 +6,7 @@ import 'package:flutter_test/flutter_test.dart';
import 'package:flutter/rendering.dart'; import 'package:flutter/rendering.dart';
import 'package:flutter/widgets.dart'; import 'package:flutter/widgets.dart';
Future<Null> test(WidgetTester tester, double offset, EdgeInsetsGeometry padding, AxisDirection axisDirection, TextDirection textDirection) { Future<void> test(WidgetTester tester, double offset, EdgeInsetsGeometry padding, AxisDirection axisDirection, TextDirection textDirection) {
return tester.pumpWidget( return tester.pumpWidget(
Directionality( Directionality(
textDirection: textDirection, textDirection: textDirection,
......
...@@ -6,7 +6,7 @@ import 'package:flutter_test/flutter_test.dart'; ...@@ -6,7 +6,7 @@ import 'package:flutter_test/flutter_test.dart';
import 'package:flutter/widgets.dart'; import 'package:flutter/widgets.dart';
import 'package:flutter/rendering.dart'; import 'package:flutter/rendering.dart';
Future<Null> test(WidgetTester tester, double offset, { double anchor = 0.0 }) { Future<void> test(WidgetTester tester, double offset, { double anchor = 0.0 }) {
return tester.pumpWidget( return tester.pumpWidget(
Directionality( Directionality(
textDirection: TextDirection.ltr, textDirection: TextDirection.ltr,
......
...@@ -197,7 +197,7 @@ abstract class TestWidgetsFlutterBinding extends BindingBase ...@@ -197,7 +197,7 @@ abstract class TestWidgetsFlutterBinding extends BindingBase
/// ///
/// See also [LiveTestWidgetsFlutterBindingFramePolicy], which affects how /// See also [LiveTestWidgetsFlutterBindingFramePolicy], which affects how
/// this method works when the test is run with `flutter run`. /// this method works when the test is run with `flutter run`.
Future<Null> pump([ Duration duration, EnginePhase newPhase = EnginePhase.sendSemanticsUpdate ]); Future<void> pump([ Duration duration, EnginePhase newPhase = EnginePhase.sendSemanticsUpdate ]);
/// Runs a `callback` that performs real asynchronous work. /// Runs a `callback` that performs real asynchronous work.
/// ///
...@@ -227,12 +227,11 @@ abstract class TestWidgetsFlutterBinding extends BindingBase ...@@ -227,12 +227,11 @@ abstract class TestWidgetsFlutterBinding extends BindingBase
/// Artificially calls dispatchLocaleChanged on the Widget binding, /// Artificially calls dispatchLocaleChanged on the Widget binding,
/// then flushes microtasks. /// then flushes microtasks.
Future<Null> setLocale(String languageCode, String countryCode) { Future<void> setLocale(String languageCode, String countryCode) {
return TestAsyncUtils.guard<Null>(() async { return TestAsyncUtils.guard<void>(() async {
assert(inTest); assert(inTest);
final Locale locale = Locale(languageCode, countryCode); final Locale locale = Locale(languageCode, countryCode);
dispatchLocaleChanged(locale); dispatchLocaleChanged(locale);
return null;
}); });
} }
...@@ -242,14 +241,13 @@ abstract class TestWidgetsFlutterBinding extends BindingBase ...@@ -242,14 +241,13 @@ abstract class TestWidgetsFlutterBinding extends BindingBase
/// then flushes microtasks. /// then flushes microtasks.
/// ///
/// Set to null to use the default surface size. /// Set to null to use the default surface size.
Future<Null> setSurfaceSize(Size size) { Future<void> setSurfaceSize(Size size) {
return TestAsyncUtils.guard<Null>(() async { return TestAsyncUtils.guard<void>(() async {
assert(inTest); assert(inTest);
if (_surfaceSize == size) if (_surfaceSize == size)
return null; return;
_surfaceSize = size; _surfaceSize = size;
handleMetricsChanged(); handleMetricsChanged();
return null;
}); });
} }
...@@ -272,11 +270,11 @@ abstract class TestWidgetsFlutterBinding extends BindingBase ...@@ -272,11 +270,11 @@ abstract class TestWidgetsFlutterBinding extends BindingBase
/// May result in an infinite loop or run out of memory if microtasks continue /// May result in an infinite loop or run out of memory if microtasks continue
/// to recursively schedule new microtasks. Will not run any timers scheduled /// to recursively schedule new microtasks. Will not run any timers scheduled
/// after this method was invoked, even if they are zero-time timers. /// after this method was invoked, even if they are zero-time timers.
Future<Null> idle() { Future<void> idle() {
return TestAsyncUtils.guard<Null>(() { return TestAsyncUtils.guard<void>(() {
final Completer<Null> completer = Completer<Null>(); final Completer<void> completer = Completer<void>();
Timer.run(() { Timer.run(() {
completer.complete(null); completer.complete();
}); });
return completer.future; return completer.future;
}); });
...@@ -386,7 +384,7 @@ abstract class TestWidgetsFlutterBinding extends BindingBase ...@@ -386,7 +384,7 @@ abstract class TestWidgetsFlutterBinding extends BindingBase
/// The `description` is used by the [LiveTestWidgetsFlutterBinding] to /// The `description` is used by the [LiveTestWidgetsFlutterBinding] to
/// show a label on the screen during the test. The description comes from /// show a label on the screen during the test. The description comes from
/// the value passed to [testWidgets]. It must not be null. /// the value passed to [testWidgets]. It must not be null.
Future<Null> runTest(Future<Null> testBody(), VoidCallback invariantTester, { String description = '' }); Future<void> runTest(Future<void> testBody(), VoidCallback invariantTester, { String description = '' });
/// This is called during test execution before and after the body has been /// This is called during test execution before and after the body has been
/// executed. /// executed.
...@@ -399,7 +397,7 @@ abstract class TestWidgetsFlutterBinding extends BindingBase ...@@ -399,7 +397,7 @@ abstract class TestWidgetsFlutterBinding extends BindingBase
Zone _parentZone; Zone _parentZone;
VoidCallback _createTestCompletionHandler(String testDescription, Completer<Null> completer) { VoidCallback _createTestCompletionHandler(String testDescription, Completer<void> completer) {
return () { return () {
// This can get called twice, in the case of a Future without listeners failing, and then // This can get called twice, in the case of a Future without listeners failing, and then
// our main future completing. // our main future completing.
...@@ -410,7 +408,7 @@ abstract class TestWidgetsFlutterBinding extends BindingBase ...@@ -410,7 +408,7 @@ abstract class TestWidgetsFlutterBinding extends BindingBase
_pendingExceptionDetails = null; _pendingExceptionDetails = null;
} }
if (!completer.isCompleted) if (!completer.isCompleted)
completer.complete(null); completer.complete();
}; };
} }
...@@ -426,8 +424,8 @@ abstract class TestWidgetsFlutterBinding extends BindingBase ...@@ -426,8 +424,8 @@ abstract class TestWidgetsFlutterBinding extends BindingBase
// The LiveTestWidgetsFlutterBinding overrides this to report the exception to the console. // The LiveTestWidgetsFlutterBinding overrides this to report the exception to the console.
} }
Future<Null> _runTest(Future<Null> testBody(), VoidCallback invariantTester, String description, { Future<void> _runTest(Future<void> testBody(), VoidCallback invariantTester, String description, {
Future<Null> timeout, Future<void> timeout,
}) { }) {
assert(description != null); assert(description != null);
assert(inTest); assert(inTest);
...@@ -452,7 +450,7 @@ abstract class TestWidgetsFlutterBinding extends BindingBase ...@@ -452,7 +450,7 @@ abstract class TestWidgetsFlutterBinding extends BindingBase
_pendingExceptionDetails = details; _pendingExceptionDetails = details;
} }
}; };
final Completer<Null> testCompleter = Completer<Null>(); final Completer<void> testCompleter = Completer<void>();
final VoidCallback testCompletionHandler = _createTestCompletionHandler(description, testCompleter); final VoidCallback testCompletionHandler = _createTestCompletionHandler(description, testCompleter);
void handleUncaughtError(dynamic exception, StackTrace stack) { void handleUncaughtError(dynamic exception, StackTrace stack) {
if (testCompleter.isCompleted) { if (testCompleter.isCompleted) {
...@@ -537,13 +535,13 @@ abstract class TestWidgetsFlutterBinding extends BindingBase ...@@ -537,13 +535,13 @@ abstract class TestWidgetsFlutterBinding extends BindingBase
); );
_parentZone = Zone.current; _parentZone = Zone.current;
final Zone testZone = _parentZone.fork(specification: errorHandlingZoneSpecification); final Zone testZone = _parentZone.fork(specification: errorHandlingZoneSpecification);
testZone.runBinary<Future<Null>, Future<Null> Function(), VoidCallback>(_runTestBody, testBody, invariantTester) testZone.runBinary<Future<void>, Future<void> Function(), VoidCallback>(_runTestBody, testBody, invariantTester)
.whenComplete(testCompletionHandler); .whenComplete(testCompletionHandler);
timeout?.catchError(handleUncaughtError); timeout?.catchError(handleUncaughtError);
return testCompleter.future; return testCompleter.future;
} }
Future<Null> _runTestBody(Future<Null> testBody(), VoidCallback invariantTester) async { Future<void> _runTestBody(Future<void> testBody(), VoidCallback invariantTester) async {
assert(inTest); assert(inTest);
runApp(Container(key: UniqueKey(), child: _preTestMessage)); // Reset the tree to a known state. runApp(Container(key: UniqueKey(), child: _preTestMessage)); // Reset the tree to a known state.
...@@ -688,8 +686,8 @@ class AutomatedTestWidgetsFlutterBinding extends TestWidgetsFlutterBinding { ...@@ -688,8 +686,8 @@ class AutomatedTestWidgetsFlutterBinding extends TestWidgetsFlutterBinding {
int get microtaskCount => _currentFakeAsync.microtaskCount; int get microtaskCount => _currentFakeAsync.microtaskCount;
@override @override
Future<Null> pump([ Duration duration, EnginePhase newPhase = EnginePhase.sendSemanticsUpdate ]) { Future<void> pump([ Duration duration, EnginePhase newPhase = EnginePhase.sendSemanticsUpdate ]) {
return TestAsyncUtils.guard<Null>(() { return TestAsyncUtils.guard<void>(() {
assert(inTest); assert(inTest);
assert(_clock != null); assert(_clock != null);
if (duration != null) if (duration != null)
...@@ -705,7 +703,7 @@ class AutomatedTestWidgetsFlutterBinding extends TestWidgetsFlutterBinding { ...@@ -705,7 +703,7 @@ class AutomatedTestWidgetsFlutterBinding extends TestWidgetsFlutterBinding {
handleDrawFrame(); handleDrawFrame();
} }
_currentFakeAsync.flushMicrotasks(); _currentFakeAsync.flushMicrotasks();
return Future<Null>.value(); return Future<void>.value();
}); });
} }
...@@ -774,8 +772,8 @@ class AutomatedTestWidgetsFlutterBinding extends TestWidgetsFlutterBinding { ...@@ -774,8 +772,8 @@ class AutomatedTestWidgetsFlutterBinding extends TestWidgetsFlutterBinding {
} }
@override @override
Future<Null> idle() { Future<void> idle() {
final Future<Null> result = super.idle(); final Future<void> result = super.idle();
_currentFakeAsync.elapse(const Duration()); _currentFakeAsync.elapse(const Duration());
return result; return result;
} }
...@@ -816,7 +814,7 @@ class AutomatedTestWidgetsFlutterBinding extends TestWidgetsFlutterBinding { ...@@ -816,7 +814,7 @@ class AutomatedTestWidgetsFlutterBinding extends TestWidgetsFlutterBinding {
Duration _timeout; Duration _timeout;
Stopwatch _timeoutStopwatch; Stopwatch _timeoutStopwatch;
Timer _timeoutTimer; Timer _timeoutTimer;
Completer<Null> _timeoutCompleter; Completer<void> _timeoutCompleter;
void _checkTimeout(Timer timer) { void _checkTimeout(Timer timer) {
assert(_timeoutTimer == timer); assert(_timeoutTimer == timer);
...@@ -860,7 +858,7 @@ class AutomatedTestWidgetsFlutterBinding extends TestWidgetsFlutterBinding { ...@@ -860,7 +858,7 @@ class AutomatedTestWidgetsFlutterBinding extends TestWidgetsFlutterBinding {
} }
@override @override
Future<Null> runTest(Future<Null> testBody(), VoidCallback invariantTester, { Future<void> runTest(Future<void> testBody(), VoidCallback invariantTester, {
String description = '', String description = '',
Duration timeout = const Duration(seconds: 2), Duration timeout = const Duration(seconds: 2),
}) { }) {
...@@ -872,12 +870,12 @@ class AutomatedTestWidgetsFlutterBinding extends TestWidgetsFlutterBinding { ...@@ -872,12 +870,12 @@ class AutomatedTestWidgetsFlutterBinding extends TestWidgetsFlutterBinding {
_timeout = timeout; _timeout = timeout;
_timeoutStopwatch = Stopwatch()..start(); _timeoutStopwatch = Stopwatch()..start();
_timeoutTimer = Timer.periodic(const Duration(seconds: 1), _checkTimeout); _timeoutTimer = Timer.periodic(const Duration(seconds: 1), _checkTimeout);
_timeoutCompleter = Completer<Null>(); _timeoutCompleter = Completer<void>();
final FakeAsync fakeAsync = FakeAsync(); final FakeAsync fakeAsync = FakeAsync();
_currentFakeAsync = fakeAsync; // reset in postTest _currentFakeAsync = fakeAsync; // reset in postTest
_clock = fakeAsync.getClock(DateTime.utc(2015, 1, 1)); _clock = fakeAsync.getClock(DateTime.utc(2015, 1, 1));
Future<Null> testBodyResult; Future<void> testBodyResult;
fakeAsync.run((FakeAsync localFakeAsync) { fakeAsync.run((FakeAsync localFakeAsync) {
assert(fakeAsync == _currentFakeAsync); assert(fakeAsync == _currentFakeAsync);
assert(fakeAsync == localFakeAsync); assert(fakeAsync == localFakeAsync);
...@@ -885,14 +883,14 @@ class AutomatedTestWidgetsFlutterBinding extends TestWidgetsFlutterBinding { ...@@ -885,14 +883,14 @@ class AutomatedTestWidgetsFlutterBinding extends TestWidgetsFlutterBinding {
assert(inTest); assert(inTest);
}); });
return Future<Null>.microtask(() async { return Future<void>.microtask(() async {
// testBodyResult is a Future that was created in the Zone of the // testBodyResult is a Future that was created in the Zone of the
// fakeAsync. This means that if we await it here, it will register a // fakeAsync. This means that if we await it here, it will register a
// microtask to handle the future _in the fake async zone_. We avoid this // microtask to handle the future _in the fake async zone_. We avoid this
// by calling '.then' in the current zone. While flushing the microtasks // by calling '.then' in the current zone. While flushing the microtasks
// of the fake-zone below, the new future will be completed and can then // of the fake-zone below, the new future will be completed and can then
// be used without fakeAsync. // be used without fakeAsync.
final Future<Null> resultFuture = testBodyResult.then<Null>((_) { final Future<void> resultFuture = testBodyResult.then<void>((_) {
// Do nothing. // Do nothing.
}); });
...@@ -1038,7 +1036,7 @@ class LiveTestWidgetsFlutterBinding extends TestWidgetsFlutterBinding { ...@@ -1038,7 +1036,7 @@ class LiveTestWidgetsFlutterBinding extends TestWidgetsFlutterBinding {
@override @override
test_package.Timeout get defaultTestTimeout => test_package.Timeout.none; test_package.Timeout get defaultTestTimeout => test_package.Timeout.none;
Completer<Null> _pendingFrame; Completer<void> _pendingFrame;
bool _expectingFrame = false; bool _expectingFrame = false;
bool _viewNeedsPaint = false; bool _viewNeedsPaint = false;
bool _runningAsyncTasks = false; bool _runningAsyncTasks = false;
...@@ -1192,12 +1190,12 @@ class LiveTestWidgetsFlutterBinding extends TestWidgetsFlutterBinding { ...@@ -1192,12 +1190,12 @@ class LiveTestWidgetsFlutterBinding extends TestWidgetsFlutterBinding {
} }
@override @override
Future<Null> pump([ Duration duration, EnginePhase newPhase = EnginePhase.sendSemanticsUpdate ]) { Future<void> pump([ Duration duration, EnginePhase newPhase = EnginePhase.sendSemanticsUpdate ]) {
assert(newPhase == EnginePhase.sendSemanticsUpdate); assert(newPhase == EnginePhase.sendSemanticsUpdate);
assert(inTest); assert(inTest);
assert(!_expectingFrame); assert(!_expectingFrame);
assert(_pendingFrame == null); assert(_pendingFrame == null);
return TestAsyncUtils.guard<Null>(() { return TestAsyncUtils.guard<void>(() {
if (duration != null) { if (duration != null) {
Timer(duration, () { Timer(duration, () {
_expectingFrame = true; _expectingFrame = true;
...@@ -1207,7 +1205,7 @@ class LiveTestWidgetsFlutterBinding extends TestWidgetsFlutterBinding { ...@@ -1207,7 +1205,7 @@ class LiveTestWidgetsFlutterBinding extends TestWidgetsFlutterBinding {
_expectingFrame = true; _expectingFrame = true;
scheduleFrame(); scheduleFrame();
} }
_pendingFrame = Completer<Null>(); _pendingFrame = Completer<void>();
return _pendingFrame.future; return _pendingFrame.future;
}); });
} }
...@@ -1244,7 +1242,7 @@ class LiveTestWidgetsFlutterBinding extends TestWidgetsFlutterBinding { ...@@ -1244,7 +1242,7 @@ class LiveTestWidgetsFlutterBinding extends TestWidgetsFlutterBinding {
} }
@override @override
Future<Null> runTest(Future<Null> testBody(), VoidCallback invariantTester, { String description = '' }) async { Future<void> runTest(Future<void> testBody(), VoidCallback invariantTester, { String description = '' }) async {
assert(description != null); assert(description != null);
assert(!inTest); assert(!inTest);
_inTest = true; _inTest = true;
...@@ -1587,8 +1585,8 @@ class _MockHttpRequest extends HttpClientRequest { ...@@ -1587,8 +1585,8 @@ class _MockHttpRequest extends HttpClientRequest {
void addError(Object error, [StackTrace stackTrace]) {} void addError(Object error, [StackTrace stackTrace]) {}
@override @override
Future<Null> addStream(Stream<List<int>> stream) { Future<void> addStream(Stream<List<int>> stream) {
return Future<Null>.value(null); return Future<void>.value();
} }
@override @override
...@@ -1606,8 +1604,8 @@ class _MockHttpRequest extends HttpClientRequest { ...@@ -1606,8 +1604,8 @@ class _MockHttpRequest extends HttpClientRequest {
Future<HttpClientResponse> get done => null; Future<HttpClientResponse> get done => null;
@override @override
Future<Null> flush() { Future<void> flush() {
return Future<Null>.value(null); return Future<void>.value();
} }
@override @override
......
...@@ -256,16 +256,15 @@ abstract class WidgetController { ...@@ -256,16 +256,15 @@ abstract class WidgetController {
/// ///
/// If the center of the widget is not exposed, this might send events to /// If the center of the widget is not exposed, this might send events to
/// another object. /// another object.
Future<Null> tap(Finder finder, { int pointer }) { Future<void> tap(Finder finder, { int pointer }) {
return tapAt(getCenter(finder), pointer: pointer); return tapAt(getCenter(finder), pointer: pointer);
} }
/// Dispatch a pointer down / pointer up sequence at the given location. /// Dispatch a pointer down / pointer up sequence at the given location.
Future<Null> tapAt(Offset location, { int pointer }) { Future<void> tapAt(Offset location, { int pointer }) {
return TestAsyncUtils.guard<Null>(() async { return TestAsyncUtils.guard<void>(() async {
final TestGesture gesture = await startGesture(location, pointer: pointer); final TestGesture gesture = await startGesture(location, pointer: pointer);
await gesture.up(); await gesture.up();
return null;
}); });
} }
...@@ -286,18 +285,17 @@ abstract class WidgetController { ...@@ -286,18 +285,17 @@ abstract class WidgetController {
/// ///
/// If the center of the widget is not exposed, this might send events to /// If the center of the widget is not exposed, this might send events to
/// another object. /// another object.
Future<Null> longPress(Finder finder, { int pointer }) { Future<void> longPress(Finder finder, { int pointer }) {
return longPressAt(getCenter(finder), pointer: pointer); return longPressAt(getCenter(finder), pointer: pointer);
} }
/// Dispatch a pointer down / pointer up sequence at the given location with /// Dispatch a pointer down / pointer up sequence at the given location with
/// a delay of [kLongPressTimeout] + [kPressTimeout] between the two events. /// a delay of [kLongPressTimeout] + [kPressTimeout] between the two events.
Future<Null> longPressAt(Offset location, { int pointer }) { Future<void> longPressAt(Offset location, { int pointer }) {
return TestAsyncUtils.guard<Null>(() async { return TestAsyncUtils.guard<void>(() async {
final TestGesture gesture = await startGesture(location, pointer: pointer); final TestGesture gesture = await startGesture(location, pointer: pointer);
await pump(kLongPressTimeout + kPressTimeout); await pump(kLongPressTimeout + kPressTimeout);
await gesture.up(); await gesture.up();
return null;
}); });
} }
...@@ -321,7 +319,7 @@ abstract class WidgetController { ...@@ -321,7 +319,7 @@ abstract class WidgetController {
/// opposite direction of the fling (e.g. dragging 200 pixels to the right, /// opposite direction of the fling (e.g. dragging 200 pixels to the right,
/// then fling to the left over 200 pixels, ending at the exact point that the /// then fling to the left over 200 pixels, ending at the exact point that the
/// drag started). /// drag started).
Future<Null> fling(Finder finder, Offset offset, double speed, { Future<void> fling(Finder finder, Offset offset, double speed, {
int pointer, int pointer,
Duration frameInterval = const Duration(milliseconds: 16), Duration frameInterval = const Duration(milliseconds: 16),
Offset initialOffset = Offset.zero, Offset initialOffset = Offset.zero,
...@@ -363,7 +361,7 @@ abstract class WidgetController { ...@@ -363,7 +361,7 @@ abstract class WidgetController {
/// opposite direction of the fling (e.g. dragging 200 pixels to the right, /// opposite direction of the fling (e.g. dragging 200 pixels to the right,
/// then fling to the left over 200 pixels, ending at the exact point that the /// then fling to the left over 200 pixels, ending at the exact point that the
/// drag started). /// drag started).
Future<Null> flingFrom(Offset startLocation, Offset offset, double speed, { Future<void> flingFrom(Offset startLocation, Offset offset, double speed, {
int pointer, int pointer,
Duration frameInterval = const Duration(milliseconds: 16), Duration frameInterval = const Duration(milliseconds: 16),
Offset initialOffset = Offset.zero, Offset initialOffset = Offset.zero,
...@@ -371,7 +369,7 @@ abstract class WidgetController { ...@@ -371,7 +369,7 @@ abstract class WidgetController {
}) { }) {
assert(offset.distance > 0.0); assert(offset.distance > 0.0);
assert(speed > 0.0); // speed is pixels/second assert(speed > 0.0); // speed is pixels/second
return TestAsyncUtils.guard<Null>(() async { return TestAsyncUtils.guard<void>(() async {
final TestPointer testPointer = TestPointer(pointer ?? _getNextPointer()); final TestPointer testPointer = TestPointer(pointer ?? _getNextPointer());
final HitTestResult result = hitTestOnBinding(startLocation); final HitTestResult result = hitTestOnBinding(startLocation);
const int kMoveCount = 50; // Needs to be >= kHistorySize, see _LeastSquaresVelocityTrackerStrategy const int kMoveCount = 50; // Needs to be >= kHistorySize, see _LeastSquaresVelocityTrackerStrategy
...@@ -394,7 +392,6 @@ abstract class WidgetController { ...@@ -394,7 +392,6 @@ abstract class WidgetController {
} }
} }
await sendEventToBinding(testPointer.up(timeStamp: Duration(milliseconds: timeStamp.round())), result); await sendEventToBinding(testPointer.up(timeStamp: Duration(milliseconds: timeStamp.round())), result);
return null;
}); });
} }
...@@ -407,7 +404,7 @@ abstract class WidgetController { ...@@ -407,7 +404,7 @@ abstract class WidgetController {
/// ///
/// See also [SchedulerBinding.endOfFrame], which returns a future that could /// See also [SchedulerBinding.endOfFrame], which returns a future that could
/// be appropriate to return in the implementation of this method. /// be appropriate to return in the implementation of this method.
Future<Null> pump(Duration duration); Future<void> pump(Duration duration);
/// Attempts to drag the given widget by the given offset, by /// Attempts to drag the given widget by the given offset, by
/// starting a drag in the middle of the widget. /// starting a drag in the middle of the widget.
...@@ -417,7 +414,7 @@ abstract class WidgetController { ...@@ -417,7 +414,7 @@ abstract class WidgetController {
/// ///
/// If you want the drag to end with a speed so that the gesture recognition /// If you want the drag to end with a speed so that the gesture recognition
/// system identifies the gesture as a fling, consider using [fling] instead. /// system identifies the gesture as a fling, consider using [fling] instead.
Future<Null> drag(Finder finder, Offset offset, { int pointer }) { Future<void> drag(Finder finder, Offset offset, { int pointer }) {
return dragFrom(getCenter(finder), offset, pointer: pointer); return dragFrom(getCenter(finder), offset, pointer: pointer);
} }
...@@ -427,13 +424,12 @@ abstract class WidgetController { ...@@ -427,13 +424,12 @@ abstract class WidgetController {
/// If you want the drag to end with a speed so that the gesture recognition /// If you want the drag to end with a speed so that the gesture recognition
/// system identifies the gesture as a fling, consider using [flingFrom] /// system identifies the gesture as a fling, consider using [flingFrom]
/// instead. /// instead.
Future<Null> dragFrom(Offset startLocation, Offset offset, { int pointer }) { Future<void> dragFrom(Offset startLocation, Offset offset, { int pointer }) {
return TestAsyncUtils.guard<Null>(() async { return TestAsyncUtils.guard<void>(() async {
final TestGesture gesture = await startGesture(startLocation, pointer: pointer); final TestGesture gesture = await startGesture(startLocation, pointer: pointer);
assert(gesture != null); assert(gesture != null);
await gesture.moveBy(offset); await gesture.moveBy(offset);
await gesture.up(); await gesture.up();
return null;
}); });
} }
...@@ -468,10 +464,9 @@ abstract class WidgetController { ...@@ -468,10 +464,9 @@ abstract class WidgetController {
} }
/// Forwards the given pointer event to the binding. /// Forwards the given pointer event to the binding.
Future<Null> sendEventToBinding(PointerEvent event, HitTestResult result) { Future<void> sendEventToBinding(PointerEvent event, HitTestResult result) {
return TestAsyncUtils.guard<Null>(() async { return TestAsyncUtils.guard<void>(() async {
binding.dispatchEvent(event, result); binding.dispatchEvent(event, result);
return null;
}); });
} }
...@@ -538,7 +533,7 @@ class LiveWidgetController extends WidgetController { ...@@ -538,7 +533,7 @@ class LiveWidgetController extends WidgetController {
LiveWidgetController(WidgetsBinding binding) : super(binding); LiveWidgetController(WidgetsBinding binding) : super(binding);
@override @override
Future<Null> pump(Duration duration) async { Future<void> pump(Duration duration) async {
if (duration != null) if (duration != null)
await Future<void>.delayed(duration); await Future<void>.delayed(duration);
binding.scheduleFrame(); binding.scheduleFrame();
......
...@@ -1506,7 +1506,7 @@ class _RendersOnPhysicalModel extends _MatchRenderObject<RenderPhysicalShape, Re ...@@ -1506,7 +1506,7 @@ class _RendersOnPhysicalModel extends _MatchRenderObject<RenderPhysicalShape, Re
} }
} }
class _RendersOnPhysicalShape extends _MatchRenderObject<RenderPhysicalShape, Null> { class _RendersOnPhysicalShape extends _MatchRenderObject<RenderPhysicalShape, RenderPhysicalModel> {
const _RendersOnPhysicalShape({ const _RendersOnPhysicalShape({
this.shape, this.shape,
this.elevation, this.elevation,
...@@ -1607,7 +1607,7 @@ class _ClipsWithBoundingRRect extends _MatchRenderObject<RenderClipPath, RenderC ...@@ -1607,7 +1607,7 @@ class _ClipsWithBoundingRRect extends _MatchRenderObject<RenderClipPath, RenderC
description.add('clips with bounding rounded rectangle with borderRadius: $borderRadius'); description.add('clips with bounding rounded rectangle with borderRadius: $borderRadius');
} }
class _ClipsWithShapeBorder extends _MatchRenderObject<RenderClipPath, Null> { class _ClipsWithShapeBorder extends _MatchRenderObject<RenderClipPath, RenderClipRRect> {
const _ClipsWithShapeBorder({@required this.shape}); const _ClipsWithShapeBorder({@required this.shape});
final ShapeBorder shape; final ShapeBorder shape;
......
...@@ -113,7 +113,7 @@ class TestPointer { ...@@ -113,7 +113,7 @@ class TestPointer {
/// Signature for a callback that can dispatch events and returns a future that /// Signature for a callback that can dispatch events and returns a future that
/// completes when the event dispatch is complete. /// completes when the event dispatch is complete.
typedef EventDispatcher = Future<Null> Function(PointerEvent event, HitTestResult result); typedef EventDispatcher = Future<void> Function(PointerEvent event, HitTestResult result);
/// Signature for callbacks that perform hit-testing at a given location. /// Signature for callbacks that perform hit-testing at a given location.
typedef HitTester = HitTestResult Function(Offset location); typedef HitTester = HitTestResult Function(Offset location);
...@@ -142,7 +142,7 @@ class TestGesture { ...@@ -142,7 +142,7 @@ class TestGesture {
assert(hitTester != null); assert(hitTester != null);
assert(dispatcher != null); assert(dispatcher != null);
TestGesture result; TestGesture result;
return TestAsyncUtils.guard<Null>(() async { return TestAsyncUtils.guard<void>(() async {
// dispatch down event // dispatch down event
final HitTestResult hitTestResult = hitTester(downLocation); final HitTestResult hitTestResult = hitTester(downLocation);
final TestPointer testPointer = TestPointer(pointer); final TestPointer testPointer = TestPointer(pointer);
...@@ -150,8 +150,7 @@ class TestGesture { ...@@ -150,8 +150,7 @@ class TestGesture {
// create a TestGesture // create a TestGesture
result = TestGesture._(dispatcher, hitTestResult, testPointer); result = TestGesture._(dispatcher, hitTestResult, testPointer);
return null; }).then<TestGesture>((void value) {
}).then<TestGesture>((Null value) {
return result; return result;
}, onError: (dynamic error, StackTrace stack) { }, onError: (dynamic error, StackTrace stack) {
return Future<TestGesture>.error(error, stack); return Future<TestGesture>.error(error, stack);
...@@ -163,14 +162,14 @@ class TestGesture { ...@@ -163,14 +162,14 @@ class TestGesture {
final TestPointer _pointer; final TestPointer _pointer;
/// Send a move event moving the pointer by the given offset. /// Send a move event moving the pointer by the given offset.
Future<Null> moveBy(Offset offset, { Duration timeStamp = Duration.zero }) { Future<void> moveBy(Offset offset, { Duration timeStamp = Duration.zero }) {
assert(_pointer._isDown); assert(_pointer._isDown);
return moveTo(_pointer.location + offset, timeStamp: timeStamp); return moveTo(_pointer.location + offset, timeStamp: timeStamp);
} }
/// Send a move event moving the pointer to the given location. /// Send a move event moving the pointer to the given location.
Future<Null> moveTo(Offset location, { Duration timeStamp = Duration.zero }) { Future<void> moveTo(Offset location, { Duration timeStamp = Duration.zero }) {
return TestAsyncUtils.guard<Null>(() { return TestAsyncUtils.guard<void>(() {
assert(_pointer._isDown); assert(_pointer._isDown);
return _dispatcher(_pointer.move(location, timeStamp: timeStamp), _result); return _dispatcher(_pointer.move(location, timeStamp: timeStamp), _result);
}); });
...@@ -179,12 +178,11 @@ class TestGesture { ...@@ -179,12 +178,11 @@ class TestGesture {
/// End the gesture by releasing the pointer. /// End the gesture by releasing the pointer.
/// ///
/// The object is no longer usable after this method has been called. /// The object is no longer usable after this method has been called.
Future<Null> up() { Future<void> up() {
return TestAsyncUtils.guard<Null>(() async { return TestAsyncUtils.guard<void>(() async {
assert(_pointer._isDown); assert(_pointer._isDown);
await _dispatcher(_pointer.up(), _result); await _dispatcher(_pointer.up(), _result);
assert(!_pointer._isDown); assert(!_pointer._isDown);
return null;
}); });
} }
...@@ -193,12 +191,11 @@ class TestGesture { ...@@ -193,12 +191,11 @@ class TestGesture {
/// for instance). /// for instance).
/// ///
/// The object is no longer usable after this method has been called. /// The object is no longer usable after this method has been called.
Future<Null> cancel() { Future<void> cancel() {
return TestAsyncUtils.guard<Null>(() async { return TestAsyncUtils.guard<void>(() async {
assert(_pointer._isDown); assert(_pointer._isDown);
await _dispatcher(_pointer.cancel(), _result); await _dispatcher(_pointer.cancel(), _result);
assert(!_pointer._isDown); assert(!_pointer._isDown);
return null;
}); });
} }
} }
...@@ -127,7 +127,7 @@ class TestTextInput { ...@@ -127,7 +127,7 @@ class TestTextInput {
/// Simulates the user pressing one of the [TextInputAction] buttons. /// Simulates the user pressing one of the [TextInputAction] buttons.
/// Does not check that the [TextInputAction] performed is an acceptable one /// Does not check that the [TextInputAction] performed is an acceptable one
/// based on the `inputAction` [setClientArgs]. /// based on the `inputAction` [setClientArgs].
Future<Null> receiveAction(TextInputAction action) async { Future<void> receiveAction(TextInputAction action) async {
return TestAsyncUtils.guard(() { return TestAsyncUtils.guard(() {
// Not using the `expect` function because in the case of a FlutterDriver // Not using the `expect` function because in the case of a FlutterDriver
// test this code does not run in a package:test test zone. // test this code does not run in a package:test test zone.
...@@ -135,7 +135,7 @@ class TestTextInput { ...@@ -135,7 +135,7 @@ class TestTextInput {
throw TestFailure('Tried to use TestTextInput with no keyboard attached. You must use WidgetTester.showKeyboard() first.'); throw TestFailure('Tried to use TestTextInput with no keyboard attached. You must use WidgetTester.showKeyboard() first.');
} }
final Completer<Null> completer = Completer<Null>(); final Completer<void> completer = Completer<void>();
BinaryMessages.handlePlatformMessage( BinaryMessages.handlePlatformMessage(
SystemChannels.textInput.name, SystemChannels.textInput.name,
......
...@@ -30,7 +30,7 @@ export 'package:test/test.dart' hide ...@@ -30,7 +30,7 @@ export 'package:test/test.dart' hide
isInstanceOf; // we have our own wrapper in matchers.dart isInstanceOf; // we have our own wrapper in matchers.dart
/// Signature for callback to [testWidgets] and [benchmarkWidgets]. /// Signature for callback to [testWidgets] and [benchmarkWidgets].
typedef WidgetTesterCallback = Future<Null> Function(WidgetTester widgetTester); typedef WidgetTesterCallback = Future<void> Function(WidgetTester widgetTester);
/// Runs the [callback] inside the Flutter test environment. /// Runs the [callback] inside the Flutter test environment.
/// ///
...@@ -114,7 +114,7 @@ void testWidgets(String description, WidgetTesterCallback callback, { ...@@ -114,7 +114,7 @@ void testWidgets(String description, WidgetTesterCallback callback, {
/// }); /// });
/// exit(0); /// exit(0);
/// } /// }
Future<Null> benchmarkWidgets(WidgetTesterCallback callback) { Future<void> benchmarkWidgets(WidgetTesterCallback callback) {
assert(() { assert(() {
print('┏╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍┓'); print('┏╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍┓');
print('┇ ⚠ THIS BENCHMARK IS BEING RUN WITH ASSERTS ENABLED ⚠ ┇'); print('┇ ⚠ THIS BENCHMARK IS BEING RUN WITH ASSERTS ENABLED ⚠ ┇');
...@@ -136,7 +136,7 @@ Future<Null> benchmarkWidgets(WidgetTesterCallback callback) { ...@@ -136,7 +136,7 @@ Future<Null> benchmarkWidgets(WidgetTesterCallback callback) {
return binding.runTest( return binding.runTest(
() => callback(tester), () => callback(tester),
tester._endOfTestVerifications, tester._endOfTestVerifications,
) ?? Future<Null>.value(); ) ?? Future<void>.value();
} }
/// Assert that `actual` matches `matcher`. /// Assert that `actual` matches `matcher`.
...@@ -217,11 +217,11 @@ class WidgetTester extends WidgetController implements HitTestDispatcher, Ticker ...@@ -217,11 +217,11 @@ class WidgetTester extends WidgetController implements HitTestDispatcher, Ticker
/// ///
/// See also [LiveTestWidgetsFlutterBindingFramePolicy], which affects how /// See also [LiveTestWidgetsFlutterBindingFramePolicy], which affects how
/// this method works when the test is run with `flutter run`. /// this method works when the test is run with `flutter run`.
Future<Null> pumpWidget(Widget widget, [ Future<void> pumpWidget(Widget widget, [
Duration duration, Duration duration,
EnginePhase phase = EnginePhase.sendSemanticsUpdate, EnginePhase phase = EnginePhase.sendSemanticsUpdate,
]) { ]) {
return TestAsyncUtils.guard<Null>(() { return TestAsyncUtils.guard<void>(() {
binding.attachRootWidget(widget); binding.attachRootWidget(widget);
binding.scheduleFrame(); binding.scheduleFrame();
return binding.pump(duration, phase); return binding.pump(duration, phase);
...@@ -240,11 +240,11 @@ class WidgetTester extends WidgetController implements HitTestDispatcher, Ticker ...@@ -240,11 +240,11 @@ class WidgetTester extends WidgetController implements HitTestDispatcher, Ticker
/// See also [LiveTestWidgetsFlutterBindingFramePolicy], which affects how /// See also [LiveTestWidgetsFlutterBindingFramePolicy], which affects how
/// this method works when the test is run with `flutter run`. /// this method works when the test is run with `flutter run`.
@override @override
Future<Null> pump([ Future<void> pump([
Duration duration, Duration duration,
EnginePhase phase = EnginePhase.sendSemanticsUpdate, EnginePhase phase = EnginePhase.sendSemanticsUpdate,
]) { ]) {
return TestAsyncUtils.guard<Null>(() => binding.pump(duration, phase)); return TestAsyncUtils.guard<void>(() => binding.pump(duration, phase));
} }
/// Repeatedly calls [pump] with the given `duration` until there are no /// Repeatedly calls [pump] with the given `duration` until there are no
...@@ -292,7 +292,7 @@ class WidgetTester extends WidgetController implements HitTestDispatcher, Ticker ...@@ -292,7 +292,7 @@ class WidgetTester extends WidgetController implements HitTestDispatcher, Ticker
return true; return true;
}()); }());
int count = 0; int count = 0;
return TestAsyncUtils.guard<Null>(() async { return TestAsyncUtils.guard<void>(() async {
final DateTime endTime = binding.clock.fromNowBy(timeout); final DateTime endTime = binding.clock.fromNowBy(timeout);
do { do {
if (binding.clock.now().isAfter(endTime)) if (binding.clock.now().isAfter(endTime))
...@@ -300,7 +300,7 @@ class WidgetTester extends WidgetController implements HitTestDispatcher, Ticker ...@@ -300,7 +300,7 @@ class WidgetTester extends WidgetController implements HitTestDispatcher, Ticker
await binding.pump(duration, phase); await binding.pump(duration, phase);
count += 1; count += 1;
} while (binding.hasScheduledFrame); } while (binding.hasScheduledFrame);
}).then<int>((Null _) => count); }).then<int>((void _) => count);
} }
/// Runs a [callback] that performs real asynchronous work. /// Runs a [callback] that performs real asynchronous work.
...@@ -350,10 +350,9 @@ class WidgetTester extends WidgetController implements HitTestDispatcher, Ticker ...@@ -350,10 +350,9 @@ class WidgetTester extends WidgetController implements HitTestDispatcher, Ticker
} }
@override @override
Future<Null> sendEventToBinding(PointerEvent event, HitTestResult result) { Future<void> sendEventToBinding(PointerEvent event, HitTestResult result) {
return TestAsyncUtils.guard<Null>(() async { return TestAsyncUtils.guard<void>(() async {
binding.dispatchEvent(event, result, source: TestBindingEventSource.test); binding.dispatchEvent(event, result, source: TestBindingEventSource.test);
return null;
}); });
} }
...@@ -484,8 +483,8 @@ class WidgetTester extends WidgetController implements HitTestDispatcher, Ticker ...@@ -484,8 +483,8 @@ class WidgetTester extends WidgetController implements HitTestDispatcher, Ticker
/// ///
/// Does not run timers. May result in an infinite loop or run out of memory /// Does not run timers. May result in an infinite loop or run out of memory
/// if microtasks continue to recursively schedule new microtasks. /// if microtasks continue to recursively schedule new microtasks.
Future<Null> idle() { Future<void> idle() {
return TestAsyncUtils.guard<Null>(() => binding.idle()); return TestAsyncUtils.guard<void>(() => binding.idle());
} }
Set<Ticker> _tickers; Set<Ticker> _tickers;
...@@ -569,8 +568,8 @@ class WidgetTester extends WidgetController implements HitTestDispatcher, Ticker ...@@ -569,8 +568,8 @@ class WidgetTester extends WidgetController implements HitTestDispatcher, Ticker
/// ///
/// Tests that just need to add text to widgets like [TextField] /// Tests that just need to add text to widgets like [TextField]
/// or [TextFormField] only need to call [enterText]. /// or [TextFormField] only need to call [enterText].
Future<Null> showKeyboard(Finder finder) async { Future<void> showKeyboard(Finder finder) async {
return TestAsyncUtils.guard<Null>(() async { return TestAsyncUtils.guard<void>(() async {
final EditableTextState editable = state<EditableTextState>( final EditableTextState editable = state<EditableTextState>(
find.descendant( find.descendant(
of: finder, of: finder,
...@@ -592,8 +591,8 @@ class WidgetTester extends WidgetController implements HitTestDispatcher, Ticker ...@@ -592,8 +591,8 @@ class WidgetTester extends WidgetController implements HitTestDispatcher, Ticker
/// ///
/// To just give [finder] the focus without entering any text, /// To just give [finder] the focus without entering any text,
/// see [showKeyboard]. /// see [showKeyboard].
Future<Null> enterText(Finder finder, String text) async { Future<void> enterText(Finder finder, String text) async {
return TestAsyncUtils.guard<Null>(() async { return TestAsyncUtils.guard<void>(() async {
await showKeyboard(finder); await showKeyboard(finder);
testTextInput.enterText(text); testTextInput.enterText(text);
await idle(); await idle();
......
...@@ -13,22 +13,22 @@ import 'package:test/test.dart' as real_test show expect; ...@@ -13,22 +13,22 @@ import 'package:test/test.dart' as real_test show expect;
// of this test is to see how we handle leaking APIs. // of this test is to see how we handle leaking APIs.
class TestAPI { class TestAPI {
Future<Null> testGuard1() { Future<Object> testGuard1() {
return TestAsyncUtils.guard(() async { return null; }); return TestAsyncUtils.guard<Object>(() async { return null; });
} }
Future<Null> testGuard2() { Future<Object> testGuard2() {
return TestAsyncUtils.guard(() async { return null; }); return TestAsyncUtils.guard<Object>(() async { return null; });
} }
} }
class TestAPISubclass extends TestAPI { class TestAPISubclass extends TestAPI {
Future<Null> testGuard3() { Future<Object> testGuard3() {
return TestAsyncUtils.guard(() async { return null; }); return TestAsyncUtils.guard<Object>(() async { return null; });
} }
} }
Future<Null> _guardedThrower() { Future<Object> _guardedThrower() {
return TestAsyncUtils.guard(() async { return TestAsyncUtils.guard<Object>(() async {
throw 'Hello'; throw 'Hello';
}); });
} }
...@@ -36,7 +36,7 @@ Future<Null> _guardedThrower() { ...@@ -36,7 +36,7 @@ Future<Null> _guardedThrower() {
void main() { void main() {
test('TestAsyncUtils - one class', () async { test('TestAsyncUtils - one class', () async {
final TestAPI testAPI = TestAPI(); final TestAPI testAPI = TestAPI();
Future<Null> f1, f2; Future<Object> f1, f2;
f1 = testAPI.testGuard1(); f1 = testAPI.testGuard1();
try { try {
f2 = testAPI.testGuard2(); f2 = testAPI.testGuard2();
...@@ -57,7 +57,7 @@ void main() { ...@@ -57,7 +57,7 @@ void main() {
test('TestAsyncUtils - two classes, all callers in superclass', () async { test('TestAsyncUtils - two classes, all callers in superclass', () async {
final TestAPI testAPI = TestAPISubclass(); final TestAPI testAPI = TestAPISubclass();
Future<Null> f1, f2; Future<Object> f1, f2;
f1 = testAPI.testGuard1(); f1 = testAPI.testGuard1();
try { try {
f2 = testAPI.testGuard2(); f2 = testAPI.testGuard2();
...@@ -78,7 +78,7 @@ void main() { ...@@ -78,7 +78,7 @@ void main() {
test('TestAsyncUtils - two classes, mixed callers', () async { test('TestAsyncUtils - two classes, mixed callers', () async {
final TestAPISubclass testAPI = TestAPISubclass(); final TestAPISubclass testAPI = TestAPISubclass();
Future<Null> f1, f2; Future<Object> f1, f2;
f1 = testAPI.testGuard1(); f1 = testAPI.testGuard1();
try { try {
f2 = testAPI.testGuard3(); f2 = testAPI.testGuard3();
...@@ -99,7 +99,7 @@ void main() { ...@@ -99,7 +99,7 @@ void main() {
test('TestAsyncUtils - expect() catches pending async work', () async { test('TestAsyncUtils - expect() catches pending async work', () async {
final TestAPI testAPI = TestAPISubclass(); final TestAPI testAPI = TestAPISubclass();
Future<Null> f1; Future<Object> f1;
f1 = testAPI.testGuard1(); f1 = testAPI.testGuard1();
try { try {
flutter_test.expect(0, 0); flutter_test.expect(0, 0);
...@@ -119,7 +119,7 @@ void main() { ...@@ -119,7 +119,7 @@ void main() {
}); });
testWidgets('TestAsyncUtils - expect() catches pending async work', (WidgetTester tester) async { testWidgets('TestAsyncUtils - expect() catches pending async work', (WidgetTester tester) async {
Future<Null> f1, f2; Future<Object> f1, f2;
try { try {
f1 = tester.pump(); f1 = tester.pump();
f2 = tester.pump(); f2 = tester.pump();
...@@ -139,7 +139,7 @@ void main() { ...@@ -139,7 +139,7 @@ void main() {
}); });
testWidgets('TestAsyncUtils - expect() catches pending async work', (WidgetTester tester) async { testWidgets('TestAsyncUtils - expect() catches pending async work', (WidgetTester tester) async {
Future<Null> f1; Future<Object> f1;
try { try {
f1 = tester.pump(); f1 = tester.pump();
TestAsyncUtils.verifyAllScopesClosed(); TestAsyncUtils.verifyAllScopesClosed();
...@@ -155,7 +155,7 @@ void main() { ...@@ -155,7 +155,7 @@ void main() {
}); });
testWidgets('TestAsyncUtils - expect() catches pending async work', (WidgetTester tester) async { testWidgets('TestAsyncUtils - expect() catches pending async work', (WidgetTester tester) async {
Future<Null> f1; Future<Object> f1;
try { try {
f1 = tester.pump(); f1 = tester.pump();
TestAsyncUtils.verifyAllScopesClosed(); TestAsyncUtils.verifyAllScopesClosed();
......
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