Unverified Commit 04bc6123 authored by Jonah Williams's avatar Jonah Williams Committed by GitHub

[null-safety] update to several framework test cases/APIs for null assertions (#62946)

parent 7d1842bf
...@@ -2053,7 +2053,7 @@ class PercentProperty extends DoubleProperty { ...@@ -2053,7 +2053,7 @@ class PercentProperty extends DoubleProperty {
/// The [showName] and [level] arguments must not be null. /// The [showName] and [level] arguments must not be null.
PercentProperty( PercentProperty(
String name, String name,
double fraction, { double? fraction, {
String? ifNull, String? ifNull,
bool showName = true, bool showName = true,
String? tooltip, String? tooltip,
......
...@@ -2,7 +2,6 @@ ...@@ -2,7 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
import 'dart:developer'; import 'dart:developer';
import 'dart:ui' show hashValues; import 'dart:ui' show hashValues;
......
...@@ -49,7 +49,7 @@ abstract class BinaryMessenger { ...@@ -49,7 +49,7 @@ abstract class BinaryMessenger {
/// ///
/// This method is useful for tests or test harnesses that want to assert the /// This method is useful for tests or test harnesses that want to assert the
/// handler for the specified channel has not been altered by a previous test. /// handler for the specified channel has not been altered by a previous test.
bool checkMessageHandler(String channel, MessageHandler handler); bool checkMessageHandler(String channel, MessageHandler? handler);
/// Set a mock callback for intercepting messages from the [send] method on /// Set a mock callback for intercepting messages from the [send] method on
/// this class, on the given channel, without decoding them. /// this class, on the given channel, without decoding them.
...@@ -70,7 +70,7 @@ abstract class BinaryMessenger { ...@@ -70,7 +70,7 @@ abstract class BinaryMessenger {
/// This method is useful for tests or test harnesses that want to assert the /// This method is useful for tests or test harnesses that want to assert the
/// mock handler for the specified channel has not been altered by a previous /// mock handler for the specified channel has not been altered by a previous
/// test. /// test.
bool checkMockMessageHandler(String channel, MessageHandler handler); bool checkMockMessageHandler(String channel, MessageHandler? handler);
} }
/// The default instance of [BinaryMessenger]. /// The default instance of [BinaryMessenger].
......
...@@ -216,8 +216,8 @@ mixin ServicesBinding on BindingBase, SchedulerBinding { ...@@ -216,8 +216,8 @@ mixin ServicesBinding on BindingBase, SchedulerBinding {
/// To use a different [RestorationManager] subclasses can override /// To use a different [RestorationManager] subclasses can override
/// [createRestorationManager], which is called to create the instance /// [createRestorationManager], which is called to create the instance
/// returned by this getter. /// returned by this getter.
RestorationManager get restorationManager => _restorationManager; RestorationManager get restorationManager => _restorationManager!;
late RestorationManager _restorationManager; RestorationManager? _restorationManager;
/// Creates the [RestorationManager] instance available via /// Creates the [RestorationManager] instance available via
/// [restorationManager]. /// [restorationManager].
...@@ -319,7 +319,7 @@ class _DefaultBinaryMessenger extends BinaryMessenger { ...@@ -319,7 +319,7 @@ class _DefaultBinaryMessenger extends BinaryMessenger {
} }
@override @override
bool checkMessageHandler(String channel, MessageHandler handler) => _handlers[channel] == handler; bool checkMessageHandler(String channel, MessageHandler? handler) => _handlers[channel] == handler;
@override @override
void setMockMessageHandler(String channel, MessageHandler? handler) { void setMockMessageHandler(String channel, MessageHandler? handler) {
...@@ -330,5 +330,5 @@ class _DefaultBinaryMessenger extends BinaryMessenger { ...@@ -330,5 +330,5 @@ class _DefaultBinaryMessenger extends BinaryMessenger {
} }
@override @override
bool checkMockMessageHandler(String channel, MessageHandler handler) => _mockHandlers[channel] == handler; bool checkMockMessageHandler(String channel, MessageHandler? handler) => _mockHandlers[channel] == handler;
} }
...@@ -2,7 +2,6 @@ ...@@ -2,7 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
import 'dart:async'; import 'dart:async';
import 'dart:typed_data'; import 'dart:typed_data';
......
...@@ -210,8 +210,8 @@ void main() { ...@@ -210,8 +210,8 @@ void main() {
test('Cannot use a disposed ChangeNotifier', () { test('Cannot use a disposed ChangeNotifier', () {
final TestNotifier source = TestNotifier(); final TestNotifier source = TestNotifier();
source.dispose(); source.dispose();
expect(() { source.addListener(null); }, throwsFlutterError); expect(() { source.addListener(() { }); }, throwsFlutterError);
expect(() { source.removeListener(null); }, throwsFlutterError); expect(() { source.removeListener(() { }); }, throwsFlutterError);
expect(() { source.dispose(); }, throwsFlutterError); expect(() { source.dispose(); }, throwsFlutterError);
expect(() { source.notify(); }, throwsFlutterError); expect(() { source.notify(); }, throwsFlutterError);
}); });
......
...@@ -136,7 +136,9 @@ void main() { ...@@ -136,7 +136,9 @@ void main() {
final File file = fs.file('/empty.png')..createSync(recursive: true); final File file = fs.file('/empty.png')..createSync(recursive: true);
final FileImage provider = FileImage(file); final FileImage provider = FileImage(file);
expect(provider.load(provider, null), isA<MultiFrameImageStreamCompleter>()); expect(provider.load(provider, (Uint8List bytes, {int cacheWidth, int cacheHeight, bool allowUpscaling}) async {
return Future<Codec>.value(FakeCodec());
}), isA<MultiFrameImageStreamCompleter>());
expect(await error.future, isStateError); expect(await error.future, isStateError);
}); });
......
...@@ -96,7 +96,7 @@ void main() { ...@@ -96,7 +96,7 @@ void main() {
Ticker ticker; Ticker ticker;
void testFunction() { void testFunction() {
ticker = Ticker(null); ticker = Ticker((Duration _) { });
} }
testFunction(); testFunction();
......
...@@ -194,7 +194,7 @@ void main() { ...@@ -194,7 +194,7 @@ void main() {
testWidgets('scheduleFrameCallback error control test', (WidgetTester tester) async { testWidgets('scheduleFrameCallback error control test', (WidgetTester tester) async {
FlutterError error; FlutterError error;
try { try {
tester.binding.scheduleFrameCallback(null, rescheduling: true); tester.binding.scheduleFrameCallback((Duration _) { }, rescheduling: true);
} on FlutterError catch (e) { } on FlutterError catch (e) {
error = e; error = e;
} }
......
...@@ -797,12 +797,12 @@ void main() { ...@@ -797,12 +797,12 @@ void main() {
expect(listeners.length, 2); expect(listeners.length, 2);
// Make sure the first listener can be called re-entrantly // Make sure the first listener can be called re-entrantly
listeners[1].onImage(null, null); listeners[1].onImage(null, false);
listeners[1].onImage(null, null); listeners[1].onImage(null, false);
// Make sure the second listener can be called re-entrantly. // Make sure the second listener can be called re-entrantly.
listeners[0].onImage(null, null); listeners[0].onImage(null, false);
listeners[0].onImage(null, null); listeners[0].onImage(null, false);
}); });
testWidgets('Precache completes with onError on error', (WidgetTester tester) async { testWidgets('Precache completes with onError on error', (WidgetTester tester) async {
......
...@@ -190,7 +190,7 @@ class TestWindow implements Window { ...@@ -190,7 +190,7 @@ class TestWindow implements Window {
@override @override
String get initialLifecycleState => _initialLifecycleStateTestValue; String get initialLifecycleState => _initialLifecycleStateTestValue;
String _initialLifecycleStateTestValue; String _initialLifecycleStateTestValue = '';
/// Sets a faked initialLifecycleState for testing. /// Sets a faked initialLifecycleState for testing.
set initialLifecycleStateTestValue(String state) { set initialLifecycleStateTestValue(String state) {
_initialLifecycleStateTestValue = state; _initialLifecycleStateTestValue = state;
......
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