Unverified Commit 87f88734 authored by Sam Rawlins's avatar Sam Rawlins Committed by GitHub

Add explicit null returns in flutter/test (#94834)

parent da6e5297
......@@ -226,6 +226,7 @@ void main() {
tester.binding.defaultBinaryMessenger.setMockMethodCallHandler(SystemChannels.platform, (MethodCall methodCall) async {
systemCalls.add(methodCall);
return null;
});
await tester.pumpWidget(
......@@ -279,6 +280,7 @@ void main() {
tester.binding.defaultBinaryMessenger.setMockMethodCallHandler(SystemChannels.platform, (MethodCall methodCall) async {
systemCalls.add(methodCall);
return null;
});
await tester.pumpWidget(
......
......@@ -177,6 +177,7 @@ void main() {
tester.binding.defaultBinaryMessenger.setMockMethodCallHandler(SystemChannels.platform, (MethodCall methodCall) async {
platformCallLog.add(methodCall);
return null;
});
await tester.pumpWidget(
......
......@@ -137,6 +137,7 @@ void main() {
if (methodCall.method == 'HapticFeedback.vibrate') {
hapticFeedbackCalls += 1;
}
return null;
});
// Long press on the scrollbar thumb and expect a vibration after it resizes.
......@@ -777,6 +778,7 @@ void main() {
if (methodCall.method == 'HapticFeedback.vibrate') {
hapticFeedbackCalls += 1;
}
return null;
});
// Long press on the scrollbar thumb and expect a vibration after it resizes.
......
......@@ -53,6 +53,7 @@ void main() {
tester.binding.defaultBinaryMessenger.setMockMethodCallHandler(SystemChannels.platform, (MethodCall methodCall) async {
log.add(methodCall);
return null;
});
await tester.pumpWidget(
......@@ -93,6 +94,7 @@ void main() {
tester.binding.defaultBinaryMessenger.setMockMethodCallHandler(SystemChannels.platform, (MethodCall methodCall) async {
log.add(methodCall);
return null;
});
await tester.pumpWidget(
......@@ -160,6 +162,7 @@ void main() {
tester.binding.defaultBinaryMessenger.setMockMethodCallHandler(SystemChannels.platform, (MethodCall methodCall) async {
log.add(methodCall);
return null;
});
await tester.pumpWidget(
......@@ -198,6 +201,7 @@ void main() {
final List<MethodCall> log = <MethodCall>[];
tester.binding.defaultBinaryMessenger.setMockMethodCallHandler(SystemChannels.platform, (MethodCall methodCall) async {
log.add(methodCall);
return null;
});
await tester.pumpWidget(
......
......@@ -3248,6 +3248,7 @@ void main() {
final List<MethodCall> log = <MethodCall>[];
tester.binding.defaultBinaryMessenger.setMockMethodCallHandler(SystemChannels.textInput, (MethodCall methodCall) async {
log.add(methodCall);
return null;
});
await tester.pumpWidget(
......@@ -3271,6 +3272,7 @@ void main() {
final List<MethodCall> log = <MethodCall>[];
tester.binding.defaultBinaryMessenger.setMockMethodCallHandler(SystemChannels.textInput, (MethodCall methodCall) async {
log.add(methodCall);
return null;
});
await tester.pumpWidget(
......@@ -4359,6 +4361,7 @@ void main() {
actions: <Type, Action<Intent>>{
ScrollIntent: CallbackAction<ScrollIntent>(onInvoke: (Intent intent) {
scrollInvoked = true;
return null;
}),
},
child: ListView(
......
......@@ -9841,6 +9841,7 @@ void main() {
actions: <Type, Action<Intent>>{
ScrollIntent: CallbackAction<ScrollIntent>(onInvoke: (Intent intent) {
scrollInvoked = true;
return null;
}),
},
child: Material(
......
......@@ -18,6 +18,7 @@ void main() {
const MethodChannel firstFrameChannel = MethodChannel('flutter/service_worker');
binding.defaultBinaryMessenger.setMockMethodCallHandler(firstFrameChannel, (MethodCall methodCall) async {
completer.complete();
return null;
});
binding.handleBeginFrame(Duration.zero);
......
......@@ -57,8 +57,10 @@ void main() {
setUp(() {
_binding.postFrameCallbacks.clear();
_binding.defaultBinaryMessenger.setMockMethodCallHandler(SystemChannels.mouseCursor, (MethodCall call) async {
if (_methodCallHandler != null)
if (_methodCallHandler != null) {
return _methodCallHandler!(call);
}
return null;
});
});
......
......@@ -41,6 +41,7 @@ void main() {
(ByteData? message) async {
expect(message, bar);
countInbound += 1;
return null;
},
);
expect(countInbound, equals(0));
......
......@@ -13,6 +13,7 @@ void main() {
TestDefaultBinaryMessengerBinding.instance!.defaultBinaryMessenger.setMockMethodCallHandler(SystemChannels.deferredComponent, (MethodCall methodCall) async {
log.add(methodCall);
return null;
});
await DeferredComponent.installDeferredComponent(componentName: 'testComponentName');
......@@ -29,6 +30,7 @@ void main() {
TestDefaultBinaryMessengerBinding.instance!.defaultBinaryMessenger.setMockMethodCallHandler(SystemChannels.deferredComponent, (MethodCall methodCall) async {
log.add(methodCall);
return null;
});
await DeferredComponent.uninstallDeferredComponent(componentName: 'testComponentName');
......
......@@ -13,6 +13,7 @@ void main() {
TestDefaultBinaryMessengerBinding.instance!.defaultBinaryMessenger.setMockMethodCallHandler(SystemChannels.platform, (MethodCall methodCall) async {
log.add(methodCall);
return null;
});
await HapticFeedback.vibrate();
......@@ -27,6 +28,7 @@ void main() {
TestDefaultBinaryMessengerBinding.instance!.defaultBinaryMessenger.setMockMethodCallHandler(SystemChannels.platform, (MethodCall methodCall) async {
log.add(methodCall);
return null;
});
await hapticFunction();
......
......@@ -66,6 +66,7 @@ void main() {
final List<MethodCall> callsToEngine = <MethodCall>[];
tester.binding.defaultBinaryMessenger.setMockMethodCallHandler(SystemChannels.restoration, (MethodCall call) async {
callsToEngine.add(call);
return null;
});
final RestorationManager manager = RestorationManager();
......
......@@ -14,6 +14,7 @@ void main() {
TestDefaultBinaryMessengerBinding.instance!.defaultBinaryMessenger.setMockMethodCallHandler(SystemChannels.platform, (MethodCall methodCall) async {
log.add(methodCall);
return null;
});
// The first call is a cache miss and will queue a microtask
......@@ -71,6 +72,7 @@ void main() {
TestDefaultBinaryMessengerBinding.instance!.defaultBinaryMessenger.setMockMethodCallHandler(SystemChannels.platform, (MethodCall methodCall) async {
log.add(methodCall);
return null;
});
await SystemChrome.setPreferredOrientations(<DeviceOrientation>[
......@@ -89,6 +91,7 @@ void main() {
TestDefaultBinaryMessengerBinding.instance!.defaultBinaryMessenger.setMockMethodCallHandler(SystemChannels.platform, (MethodCall methodCall) async {
log.add(methodCall);
return null;
});
await SystemChrome.setApplicationSwitcherDescription(
......@@ -107,6 +110,7 @@ void main() {
TestDefaultBinaryMessengerBinding.instance!.defaultBinaryMessenger.setMockMessageHandler('flutter/platform', (ByteData? message) async {
log.add(message);
return null;
});
await SystemChrome.setApplicationSwitcherDescription(
......@@ -121,6 +125,7 @@ void main() {
TestDefaultBinaryMessengerBinding.instance!.defaultBinaryMessenger.setMockMethodCallHandler(SystemChannels.platform, (MethodCall methodCall) async {
log.add(methodCall);
return null;
});
await SystemChrome.setEnabledSystemUIOverlays(<SystemUiOverlay>[SystemUiOverlay.top]);
......@@ -137,6 +142,7 @@ void main() {
TestDefaultBinaryMessengerBinding.instance!.defaultBinaryMessenger.setMockMethodCallHandler(SystemChannels.platform, (MethodCall methodCall) async {
log.add(methodCall);
return null;
});
await SystemChrome.setEnabledSystemUIMode(SystemUiMode.leanBack);
......@@ -165,6 +171,7 @@ void main() {
TestDefaultBinaryMessengerBinding.instance!.defaultBinaryMessenger.setMockMethodCallHandler(SystemChannels.platform, (MethodCall methodCall) async {
log.add(methodCall);
return null;
});
await SystemChrome.setEnabledSystemUIMode(SystemUiMode.manual, overlays: <SystemUiOverlay>[SystemUiOverlay.top]);
......@@ -181,6 +188,7 @@ void main() {
TestDefaultBinaryMessengerBinding.instance!.defaultBinaryMessenger.setMockMethodCallHandler(SystemChannels.platform, (MethodCall methodCall) async {
log.add(methodCall);
return null;
});
await SystemChrome.setSystemUIChangeCallback(null);
......
......@@ -20,6 +20,7 @@ void main() {
test('System navigator control test - platform messages', () async {
TestDefaultBinaryMessengerBinding.instance!.defaultBinaryMessenger.setMockMethodCallHandler(SystemChannels.platform, (MethodCall methodCall) async {
log.add(methodCall);
return null;
});
await verify(() => SystemNavigator.pop(), <Object>[
......@@ -32,6 +33,7 @@ void main() {
test('System navigator control test - navigation messages', () async {
TestDefaultBinaryMessengerBinding.instance!.defaultBinaryMessenger.setMockMethodCallHandler(SystemChannels.navigation, (MethodCall methodCall) async {
log.add(methodCall);
return null;
});
await verify(() => SystemNavigator.selectSingleEntryHistory(), <Object>[
......
......@@ -14,6 +14,7 @@ void main() {
TestDefaultBinaryMessengerBinding.instance!.defaultBinaryMessenger.setMockMethodCallHandler(SystemChannels.platform, (MethodCall methodCall) async {
log.add(methodCall);
return null;
});
await SystemSound.play(SystemSoundType.click);
......
......@@ -3116,6 +3116,7 @@ Future<void> _testLongPressDraggableHapticFeedback({ required WidgetTester teste
if (methodCall.method == 'HapticFeedback.vibrate') {
hapticFeedbackCalls++;
}
return null;
});
await tester.pumpWidget(MaterialApp(
......
......@@ -2207,6 +2207,7 @@ void main() {
final List<MethodCall> log = <MethodCall>[];
tester.binding.defaultBinaryMessenger.setMockMethodCallHandler(SystemChannels.textInput, (MethodCall methodCall) async {
log.add(methodCall);
return null;
});
await tester.showKeyboard(find.byType(EditableText));
......@@ -3502,6 +3503,7 @@ void main() {
final List<MethodCall> log = <MethodCall>[];
tester.binding.defaultBinaryMessenger.setMockMethodCallHandler(SystemChannels.textInput, (MethodCall methodCall) async {
log.add(methodCall);
return null;
});
final TextEditingController controller = TextEditingController();
......@@ -3531,6 +3533,7 @@ void main() {
final List<MethodCall> log = <MethodCall>[];
tester.binding.defaultBinaryMessenger.setMockMethodCallHandler(SystemChannels.textInput, (MethodCall methodCall) async {
log.add(methodCall);
return null;
});
final TextEditingController controller = TextEditingController();
......@@ -3566,6 +3569,7 @@ void main() {
final List<MethodCall> log = <MethodCall>[];
tester.binding.defaultBinaryMessenger.setMockMethodCallHandler(SystemChannels.textInput, (MethodCall methodCall) async {
log.add(methodCall);
return null;
});
final TextEditingController controller1 = TextEditingController();
......@@ -3651,6 +3655,7 @@ void main() {
final List<MethodCall> log = <MethodCall>[];
tester.binding.defaultBinaryMessenger.setMockMethodCallHandler(SystemChannels.textInput, (MethodCall methodCall) async {
log.add(methodCall);
return null;
});
const Offset offset = Offset(10.0, 20.0);
......@@ -3693,6 +3698,7 @@ void main() {
final List<MethodCall> log = <MethodCall>[];
tester.binding.defaultBinaryMessenger.setMockMethodCallHandler(SystemChannels.textInput, (MethodCall methodCall) async {
log.add(methodCall);
return null;
});
final TextEditingController controller = TextEditingController();
......@@ -3780,6 +3786,7 @@ void main() {
final List<MethodCall> log = <MethodCall>[];
tester.binding.defaultBinaryMessenger.setMockMethodCallHandler(SystemChannels.textInput, (MethodCall methodCall) async {
log.add(methodCall);
return null;
});
setState(() {
currentTextStyle = textStyle2;
......@@ -4007,6 +4014,7 @@ void main() {
final List<MethodCall> log = <MethodCall>[];
tester.binding.defaultBinaryMessenger.setMockMethodCallHandler(SystemChannels.textInput, (MethodCall methodCall) async {
log.add(methodCall);
return null;
});
final TextEditingController controller = TextEditingController();
......@@ -6706,6 +6714,7 @@ void main() {
final List<MethodCall> log = <MethodCall>[];
tester.binding.defaultBinaryMessenger.setMockMethodCallHandler(SystemChannels.textInput, (MethodCall methodCall) async {
log.add(methodCall);
return null;
});
final TextInputFormatter formatter = TextInputFormatter.withFunction((TextEditingValue oldValue, TextEditingValue newValue) {
if (newValue.text == 'I will be modified by the formatter.') {
......@@ -6834,6 +6843,7 @@ void main() {
final List<MethodCall> log = <MethodCall>[];
tester.binding.defaultBinaryMessenger.setMockMethodCallHandler(SystemChannels.textInput, (MethodCall methodCall) async {
log.add(methodCall);
return null;
});
final TextInputFormatter formatter = TextInputFormatter.withFunction((TextEditingValue oldValue, TextEditingValue newValue) {
return const TextEditingValue(text: 'Flutter is the best!');
......@@ -6913,6 +6923,7 @@ void main() {
final List<MethodCall> log = <MethodCall>[];
tester.binding.defaultBinaryMessenger.setMockMethodCallHandler(SystemChannels.textInput, (MethodCall methodCall) async {
log.add(methodCall);
return null;
});
final TextEditingController controller = TextEditingController();
......@@ -7034,6 +7045,7 @@ void main() {
final List<MethodCall> log = <MethodCall>[];
tester.binding.defaultBinaryMessenger.setMockMethodCallHandler(SystemChannels.textInput, (MethodCall methodCall) async {
log.add(methodCall);
return null;
});
final TextEditingController controller = TextEditingController();
......@@ -8635,7 +8647,7 @@ void main() {
);
bool myIntentWasCalled = false;
final CallbackAction<ExtendSelectionByCharacterIntent> overrideAction = CallbackAction<ExtendSelectionByCharacterIntent>(
onInvoke: (ExtendSelectionByCharacterIntent intent) { myIntentWasCalled = true; },
onInvoke: (ExtendSelectionByCharacterIntent intent) { myIntentWasCalled = true; return null; },
);
await tester.pumpWidget(MaterialApp(
home: Align(
......@@ -8690,7 +8702,7 @@ void main() {
child: Actions(
actions: <Type, Action<Intent>>{
ExtendSelectionByCharacterIntent: CallbackAction<ExtendSelectionByCharacterIntent>(
onInvoke: (ExtendSelectionByCharacterIntent intent) { myIntentWasCalled = true; },
onInvoke: (ExtendSelectionByCharacterIntent intent) { myIntentWasCalled = true; return null; },
),
},
child: EditableText(
......
......@@ -160,8 +160,10 @@ void main() {
final List<String> playedSystemSounds = <String>[];
try {
tester.binding.defaultBinaryMessenger.setMockMethodCallHandler(SystemChannels.platform, (MethodCall methodCall) async {
if (methodCall.method == 'SystemSound.play')
if (methodCall.method == 'SystemSound.play') {
playedSystemSounds.add(methodCall.arguments as String);
}
return null;
});
final Widget subject = Stack(
......
......@@ -1621,6 +1621,7 @@ void main() {
addTearDown(gesture.removePointer);
tester.binding.defaultBinaryMessenger.setMockMethodCallHandler(SystemChannels.mouseCursor, (_) async {
logCursors.add('cursor');
return null;
});
final GlobalKey key = GlobalKey();
......
......@@ -57,6 +57,7 @@ void main() {
tester.binding.defaultBinaryMessenger.setMockMethodCallHandler(SystemChannels.navigation, (MethodCall methodCall) async {
log.add(methodCall);
return null;
});
await tester.pumpWidget(MaterialApp(
......@@ -115,6 +116,7 @@ void main() {
final List<MethodCall> log = <MethodCall>[];
tester.binding.defaultBinaryMessenger.setMockMethodCallHandler(SystemChannels.navigation, (MethodCall methodCall) async {
log.add(methodCall);
return null;
});
await tester.pumpWidget(Directionality(
......@@ -165,6 +167,7 @@ void main() {
tester.binding.defaultBinaryMessenger.setMockMethodCallHandler(SystemChannels.navigation, (MethodCall methodCall) async {
log.add(methodCall);
return null;
});
await tester.pumpWidget(MaterialApp(
......@@ -223,6 +226,7 @@ void main() {
final List<MethodCall> log = <MethodCall>[];
tester.binding.defaultBinaryMessenger.setMockMethodCallHandler(SystemChannels.navigation, (MethodCall methodCall) async {
log.add(methodCall);
return null;
});
await tester.pumpWidget(MaterialApp(
......@@ -266,6 +270,7 @@ void main() {
final List<MethodCall> log = <MethodCall>[];
tester.binding.defaultBinaryMessenger.setMockMethodCallHandler(SystemChannels.navigation, (MethodCall methodCall) async {
log.add(methodCall);
return null;
});
final PlatformRouteInformationProvider provider = PlatformRouteInformationProvider(
......
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