diff --git a/experimental/federated_plugin/federated_plugin/example/test/widget_test.dart b/experimental/federated_plugin/federated_plugin/example/test/widget_test.dart index e0f5b568f..597a07b8e 100644 --- a/experimental/federated_plugin/federated_plugin/example/test/widget_test.dart +++ b/experimental/federated_plugin/federated_plugin/example/test/widget_test.dart @@ -10,15 +10,17 @@ import 'package:flutter_test/flutter_test.dart'; void main() { group('federated plugin demo tests', () { const batteryLevel = 45; - setUpAll(() { - const MethodChannel('battery').setMockMethodCallHandler((call) async { - if (call.method == 'getBatteryLevel') { - return batteryLevel; - } - }); - }); testWidgets('get current battery level from platform', (tester) async { + tester.binding.defaultBinaryMessenger.setMockMethodCallHandler( + const MethodChannel('battery'), + (call) async { + if (call.method == 'getBatteryLevel') { + return batteryLevel; + } + return 0; + }, + ); await tester.pumpWidget(const MyApp()); // Tap button to retrieve current battery level from platform. diff --git a/experimental/federated_plugin/federated_plugin/test/federated_plugin_test.dart b/experimental/federated_plugin/federated_plugin/test/federated_plugin_test.dart index eba62999b..833fda455 100644 --- a/experimental/federated_plugin/federated_plugin/test/federated_plugin_test.dart +++ b/experimental/federated_plugin/federated_plugin/test/federated_plugin_test.dart @@ -11,13 +11,17 @@ void main() { group('Federated Plugin Test', () { const batteryLevel = 34; - const MethodChannel('battery').setMockMethodCallHandler((call) async { - if (call.method == 'getBatteryLevel') { - return batteryLevel; - } - }); - test('getBatteryLevel method test', () async { + testWidgets('getBatteryLevel method test', (tester) async { + tester.binding.defaultBinaryMessenger.setMockMethodCallHandler( + const MethodChannel('battery'), + (call) async { + if (call.method == 'getBatteryLevel') { + return batteryLevel; + } + return 0; + }, + ); final result = await getBatteryLevel(); expect(result, batteryLevel); }); diff --git a/experimental/federated_plugin/federated_plugin_platform_interface/test/federated_plugin_platform_interface_test.dart b/experimental/federated_plugin/federated_plugin_platform_interface/test/federated_plugin_platform_interface_test.dart index 5b0f561ea..3c302abc7 100644 --- a/experimental/federated_plugin/federated_plugin_platform_interface/test/federated_plugin_platform_interface_test.dart +++ b/experimental/federated_plugin/federated_plugin_platform_interface/test/federated_plugin_platform_interface_test.dart @@ -11,13 +11,17 @@ void main() { group('MethodChannel test', () { const batteryLevel = 89; - const MethodChannel('battery').setMockMethodCallHandler((call) async { - if (call.method == 'getBatteryLevel') { - return batteryLevel; - } - }); - test('getBatteryLevel method test', () async { + testWidgets('getBatteryLevel method test', (tester) async { + tester.binding.defaultBinaryMessenger.setMockMethodCallHandler( + const MethodChannel('battery'), + (call) async { + if (call.method == 'getBatteryLevel') { + return batteryLevel; + } + return 0; + }, + ); final locationMethodChannel = BatteryMethodChannel(); final result = await locationMethodChannel.getBatteryLevel(); expect(result, batteryLevel); diff --git a/tool/flutter_ci_script_beta.sh b/tool/flutter_ci_script_beta.sh index 3661f2ed3..3540f835f 100755 --- a/tool/flutter_ci_script_beta.sh +++ b/tool/flutter_ci_script_beta.sh @@ -26,13 +26,10 @@ declare -ar PROJECT_NAMES=( "desktop_photo_search/material" "experimental/context_menus" "experimental/element_embedding_demo" - # TODO(DomesticMouse): 'setMockMethodCallHandler' is deprecated and shouldn't be used. - # "experimental/federated_plugin/federated_plugin" - # TODO(DomesticMouse): 'setMockMethodCallHandler' is deprecated and shouldn't be used. - # "experimental/federated_plugin/federated_plugin/example" + "experimental/federated_plugin/federated_plugin" + "experimental/federated_plugin/federated_plugin/example" "experimental/federated_plugin/federated_plugin_macos" - # TODO(DomesticMouse): 'setMockMethodCallHandler' is deprecated and shouldn't be used. - # "experimental/federated_plugin/federated_plugin_platform_interface" + "experimental/federated_plugin/federated_plugin_platform_interface" "experimental/federated_plugin/federated_plugin_web" "experimental/federated_plugin/federated_plugin_windows" "experimental/linting_tool" diff --git a/tool/flutter_ci_script_master.sh b/tool/flutter_ci_script_master.sh index 3457446a9..6bc1a051f 100755 --- a/tool/flutter_ci_script_master.sh +++ b/tool/flutter_ci_script_master.sh @@ -27,13 +27,10 @@ declare -ar PROJECT_NAMES=( # TODO(DomesticMouse): The function can't be unconditionally invoked because it can be 'null'. # "experimental/context_menus" "experimental/element_embedding_demo" - # TODO(DomesticMouse): 'setMockMethodCallHandler' is deprecated and shouldn't be used. - # "experimental/federated_plugin/federated_plugin" - # TODO(DomesticMouse): 'setMockMethodCallHandler' is deprecated and shouldn't be used. - # "experimental/federated_plugin/federated_plugin/example" + "experimental/federated_plugin/federated_plugin" + "experimental/federated_plugin/federated_plugin/example" "experimental/federated_plugin/federated_plugin_macos" - # TODO(DomesticMouse): 'setMockMethodCallHandler' is deprecated and shouldn't be used. - # "experimental/federated_plugin/federated_plugin_platform_interface" + "experimental/federated_plugin/federated_plugin_platform_interface" "experimental/federated_plugin/federated_plugin_web" "experimental/federated_plugin/federated_plugin_windows" "experimental/linting_tool"