From ca6e8f51e5245720caf3557031cfc7cf2983fc4b Mon Sep 17 00:00:00 2001 From: Alexander Dischberg Date: Thu, 14 Dec 2023 02:12:02 +0800 Subject: [PATCH] test: fix static analysis --- app_widget/README.md | 40 +++++++++++++----------- app_widget/test/app_widget_ios_test.dart | 5 +-- app_widget/test/app_widget_test.dart | 25 ++++++++------- 3 files changed, 37 insertions(+), 33 deletions(-) diff --git a/app_widget/README.md b/app_widget/README.md index c138018..07dafda 100644 --- a/app_widget/README.md +++ b/app_widget/README.md @@ -465,25 +465,27 @@ void main() { const MethodChannel channel = MethodChannel(AppWidgetPlatform.channel); final List log = []; - - channel.setMockMethodCallHandler((methodCall) async { - log.add(methodCall); - switch (methodCall.method) { - case 'configureWidget': - return true; - case 'cancelConfigureWidget': - return true; - case 'getWidgetIds': - return [42]; - case 'reloadWidgets': - return true; - case 'updateWidget': - return true; - case 'widgetExist': - return true; - default: - } - }); + + + TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger + .setMockMethodCallHandler(channel, (methodCall) async { + log.add(methodCall); + switch (methodCall.method) { + case 'getPlatformVersion': + return '42'; + case 'configureWidget': + return true; + case 'cancelConfigureWidget': + return true; + case 'getWidgetIds': + return []; + case 'reloadWidgets': + return true; + case 'widgetExist': + return true; + default: + return null; + } }); setUp(() { diff --git a/app_widget/test/app_widget_ios_test.dart b/app_widget/test/app_widget_ios_test.dart index 57eb95f..2b8446b 100644 --- a/app_widget/test/app_widget_ios_test.dart +++ b/app_widget/test/app_widget_ios_test.dart @@ -11,8 +11,8 @@ void main() { final List log = []; setUpAll(() { - // ignore: always_specify_types - channel.setMockMethodCallHandler((methodCall) async { + TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger + .setMockMethodCallHandler(channel, (methodCall) async { log.add(methodCall); switch (methodCall.method) { case 'getPlatformVersion': @@ -28,6 +28,7 @@ void main() { case 'widgetExist': return true; default: + return null; } }); }); diff --git a/app_widget/test/app_widget_test.dart b/app_widget/test/app_widget_test.dart index 5338117..1da1cfd 100644 --- a/app_widget/test/app_widget_test.dart +++ b/app_widget/test/app_widget_test.dart @@ -13,8 +13,8 @@ void main() { final List log = []; setUpAll(() { - // ignore: always_specify_types - channel.setMockMethodCallHandler((methodCall) async { + TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger + .setMockMethodCallHandler(channel, (methodCall) async { log.add(methodCall); switch (methodCall.method) { case 'getPlatformVersion': @@ -32,6 +32,7 @@ void main() { case 'widgetExist': return true; default: + return false; } }); }); @@ -71,7 +72,7 @@ void main() { 'payload': '{"itemId": 1, "stringUid": "uid"}', 'url': 'https://google.come', }, - ) + ), ]); }); @@ -102,7 +103,7 @@ void main() { 'payload': '{"itemId": 1, "stringUid": "uid"}', 'url': 'https://google.come', }, - ) + ), ]); }); @@ -132,7 +133,7 @@ void main() { 'payload': '{"itemId": 1, "stringUid": "uid"}', 'url': 'https://google.come', }, - ) + ), ]); }); @@ -163,7 +164,7 @@ void main() { 'payload': '{"itemId": 1, "stringUid": "uid"}', 'url': 'https://google.come', }, - ) + ), ]); }); @@ -179,7 +180,7 @@ void main() { isMethodCall( 'cancelConfigureWidget', arguments: null, - ) + ), ]); }); @@ -200,7 +201,7 @@ void main() { 'androidProviderName': 'TestProvider', 'androidPackageName': 'appname', }, - ) + ), ]); }); @@ -222,7 +223,7 @@ void main() { 'androidProviderName': 'TestProvider', 'androidPackageName': 'appname2', }, - ) + ), ]); }); @@ -243,7 +244,7 @@ void main() { 'androidProviderName': 'TestProvider', 'androidPackageName': 'appname', }, - ) + ), ]); }); @@ -265,7 +266,7 @@ void main() { 'androidProviderName': 'TestProvider', 'androidPackageName': 'appname2', }, - ) + ), ]); }); @@ -283,7 +284,7 @@ void main() { arguments: { 'widgetId': 12, }, - ) + ), ]); }); });