Skip to content

Commit b703f1f

Browse files
Fixup experimental/federated_plugin (#1776)
Replaces #1749 FYI @negotoyolo ## Pre-launch Checklist - [x] I read the [Flutter Style Guide] _recently_, and have followed its advice. - [x] I signed the [CLA]. - [x] I read the [Contributors Guide]. - [x] I updated/added relevant documentation (doc comments with `///`). - [x] All existing and new tests are passing. If you need help, consider asking for advice on the #hackers-devrel channel on [Discord]. <!-- Links --> [Flutter Style Guide]: https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo [CLA]: https://cla.developers.google.com/ [Discord]: https://github.com/flutter/flutter/wiki/Chat [Contributors Guide]: https://github.com/flutter/samples/blob/main/CONTRIBUTING.md
1 parent ebcf72c commit b703f1f

File tree

5 files changed

+35
-31
lines changed

5 files changed

+35
-31
lines changed

experimental/federated_plugin/federated_plugin/example/test/widget_test.dart

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,17 @@ import 'package:flutter_test/flutter_test.dart';
1010
void main() {
1111
group('federated plugin demo tests', () {
1212
const batteryLevel = 45;
13-
setUpAll(() {
14-
const MethodChannel('battery').setMockMethodCallHandler((call) async {
15-
if (call.method == 'getBatteryLevel') {
16-
return batteryLevel;
17-
}
18-
});
19-
});
2013

2114
testWidgets('get current battery level from platform', (tester) async {
15+
tester.binding.defaultBinaryMessenger.setMockMethodCallHandler(
16+
const MethodChannel('battery'),
17+
(call) async {
18+
if (call.method == 'getBatteryLevel') {
19+
return batteryLevel;
20+
}
21+
return 0;
22+
},
23+
);
2224
await tester.pumpWidget(const MyApp());
2325

2426
// Tap button to retrieve current battery level from platform.

experimental/federated_plugin/federated_plugin/test/federated_plugin_test.dart

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,17 @@ void main() {
1111

1212
group('Federated Plugin Test', () {
1313
const batteryLevel = 34;
14-
const MethodChannel('battery').setMockMethodCallHandler((call) async {
15-
if (call.method == 'getBatteryLevel') {
16-
return batteryLevel;
17-
}
18-
});
1914

20-
test('getBatteryLevel method test', () async {
15+
testWidgets('getBatteryLevel method test', (tester) async {
16+
tester.binding.defaultBinaryMessenger.setMockMethodCallHandler(
17+
const MethodChannel('battery'),
18+
(call) async {
19+
if (call.method == 'getBatteryLevel') {
20+
return batteryLevel;
21+
}
22+
return 0;
23+
},
24+
);
2125
final result = await getBatteryLevel();
2226
expect(result, batteryLevel);
2327
});

experimental/federated_plugin/federated_plugin_platform_interface/test/federated_plugin_platform_interface_test.dart

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,17 @@ void main() {
1111

1212
group('MethodChannel test', () {
1313
const batteryLevel = 89;
14-
const MethodChannel('battery').setMockMethodCallHandler((call) async {
15-
if (call.method == 'getBatteryLevel') {
16-
return batteryLevel;
17-
}
18-
});
1914

20-
test('getBatteryLevel method test', () async {
15+
testWidgets('getBatteryLevel method test', (tester) async {
16+
tester.binding.defaultBinaryMessenger.setMockMethodCallHandler(
17+
const MethodChannel('battery'),
18+
(call) async {
19+
if (call.method == 'getBatteryLevel') {
20+
return batteryLevel;
21+
}
22+
return 0;
23+
},
24+
);
2125
final locationMethodChannel = BatteryMethodChannel();
2226
final result = await locationMethodChannel.getBatteryLevel();
2327
expect(result, batteryLevel);

tool/flutter_ci_script_beta.sh

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,10 @@ declare -ar PROJECT_NAMES=(
2626
"desktop_photo_search/material"
2727
"experimental/context_menus"
2828
"experimental/element_embedding_demo"
29-
# TODO(DomesticMouse): 'setMockMethodCallHandler' is deprecated and shouldn't be used.
30-
# "experimental/federated_plugin/federated_plugin"
31-
# TODO(DomesticMouse): 'setMockMethodCallHandler' is deprecated and shouldn't be used.
32-
# "experimental/federated_plugin/federated_plugin/example"
29+
"experimental/federated_plugin/federated_plugin"
30+
"experimental/federated_plugin/federated_plugin/example"
3331
"experimental/federated_plugin/federated_plugin_macos"
34-
# TODO(DomesticMouse): 'setMockMethodCallHandler' is deprecated and shouldn't be used.
35-
# "experimental/federated_plugin/federated_plugin_platform_interface"
32+
"experimental/federated_plugin/federated_plugin_platform_interface"
3633
"experimental/federated_plugin/federated_plugin_web"
3734
"experimental/federated_plugin/federated_plugin_windows"
3835
"experimental/linting_tool"

tool/flutter_ci_script_master.sh

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,10 @@ declare -ar PROJECT_NAMES=(
2727
# TODO(DomesticMouse): The function can't be unconditionally invoked because it can be 'null'.
2828
# "experimental/context_menus"
2929
"experimental/element_embedding_demo"
30-
# TODO(DomesticMouse): 'setMockMethodCallHandler' is deprecated and shouldn't be used.
31-
# "experimental/federated_plugin/federated_plugin"
32-
# TODO(DomesticMouse): 'setMockMethodCallHandler' is deprecated and shouldn't be used.
33-
# "experimental/federated_plugin/federated_plugin/example"
30+
"experimental/federated_plugin/federated_plugin"
31+
"experimental/federated_plugin/federated_plugin/example"
3432
"experimental/federated_plugin/federated_plugin_macos"
35-
# TODO(DomesticMouse): 'setMockMethodCallHandler' is deprecated and shouldn't be used.
36-
# "experimental/federated_plugin/federated_plugin_platform_interface"
33+
"experimental/federated_plugin/federated_plugin_platform_interface"
3734
"experimental/federated_plugin/federated_plugin_web"
3835
"experimental/federated_plugin/federated_plugin_windows"
3936
"experimental/linting_tool"

0 commit comments

Comments
 (0)