File tree Expand file tree Collapse file tree 5 files changed +35
-31
lines changed
experimental/federated_plugin
federated_plugin_platform_interface/test Expand file tree Collapse file tree 5 files changed +35
-31
lines changed Original file line number Diff line number Diff line change @@ -10,15 +10,17 @@ import 'package:flutter_test/flutter_test.dart';
10
10
void main () {
11
11
group ('federated plugin demo tests' , () {
12
12
const batteryLevel = 45 ;
13
- setUpAll (() {
14
- const MethodChannel ('battery' ).setMockMethodCallHandler ((call) async {
15
- if (call.method == 'getBatteryLevel' ) {
16
- return batteryLevel;
17
- }
18
- });
19
- });
20
13
21
14
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
+ );
22
24
await tester.pumpWidget (const MyApp ());
23
25
24
26
// Tap button to retrieve current battery level from platform.
Original file line number Diff line number Diff line change @@ -11,13 +11,17 @@ void main() {
11
11
12
12
group ('Federated Plugin Test' , () {
13
13
const batteryLevel = 34 ;
14
- const MethodChannel ('battery' ).setMockMethodCallHandler ((call) async {
15
- if (call.method == 'getBatteryLevel' ) {
16
- return batteryLevel;
17
- }
18
- });
19
14
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
+ );
21
25
final result = await getBatteryLevel ();
22
26
expect (result, batteryLevel);
23
27
});
Original file line number Diff line number Diff line change @@ -11,13 +11,17 @@ void main() {
11
11
12
12
group ('MethodChannel test' , () {
13
13
const batteryLevel = 89 ;
14
- const MethodChannel ('battery' ).setMockMethodCallHandler ((call) async {
15
- if (call.method == 'getBatteryLevel' ) {
16
- return batteryLevel;
17
- }
18
- });
19
14
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
+ );
21
25
final locationMethodChannel = BatteryMethodChannel ();
22
26
final result = await locationMethodChannel.getBatteryLevel ();
23
27
expect (result, batteryLevel);
Original file line number Diff line number Diff line change @@ -26,13 +26,10 @@ declare -ar PROJECT_NAMES=(
26
26
" desktop_photo_search/material"
27
27
" experimental/context_menus"
28
28
" 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"
33
31
" 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"
36
33
" experimental/federated_plugin/federated_plugin_web"
37
34
" experimental/federated_plugin/federated_plugin_windows"
38
35
" experimental/linting_tool"
Original file line number Diff line number Diff line change @@ -27,13 +27,10 @@ declare -ar PROJECT_NAMES=(
27
27
# TODO(DomesticMouse): The function can't be unconditionally invoked because it can be 'null'.
28
28
# "experimental/context_menus"
29
29
" 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"
34
32
" 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"
37
34
" experimental/federated_plugin/federated_plugin_web"
38
35
" experimental/federated_plugin/federated_plugin_windows"
39
36
" experimental/linting_tool"
You can’t perform that action at this time.
0 commit comments