Skip to content

Commit 7adc1d7

Browse files
committed
Fix: Adapt test to new audioplayer version
1 parent 413083b commit 7adc1d7

File tree

1 file changed

+31
-18
lines changed

1 file changed

+31
-18
lines changed

test/utils/test_mock_channel_handlers.dart

Lines changed: 31 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -50,24 +50,37 @@ void setupMockPrinting() {
5050
}
5151

5252
void setupMockAudioplayers() {
53-
TestWidgetsFlutterBinding.ensureInitialized();
53+
final binding = TestWidgetsFlutterBinding.ensureInitialized();
5454

55-
const channel = MethodChannel('xyz.luan/audioplayers');
56-
TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger
57-
.setMockMethodCallHandler(channel, (MethodCall methodCall) async {
58-
if (methodCall.method == 'create') {
59-
return true;
60-
}
61-
return null;
62-
});
55+
binding.defaultBinaryMessenger.setMockMethodCallHandler(
56+
MethodChannel('xyz.luan/audioplayers'),
57+
(MethodCall methodCall) async {
58+
if (methodCall.method == 'create') return true;
59+
return null;
60+
},
61+
);
6362

64-
const playerChannel =
65-
MethodChannel('xyz.luan/audioplayers/events/pencilSoundEffect');
66-
TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger
67-
.setMockMethodCallHandler(playerChannel, (MethodCall methodCall) async {
68-
if (methodCall.method == 'listen') {
69-
return true;
70-
}
71-
return null;
72-
});
63+
binding.defaultBinaryMessenger.setMockMethodCallHandler(
64+
MethodChannel('xyz.luan/audioplayers.global'),
65+
(MethodCall methodCall) async {
66+
if (methodCall.method == 'init') return true;
67+
return null;
68+
},
69+
);
70+
71+
binding.defaultBinaryMessenger.setMockMethodCallHandler(
72+
MethodChannel('xyz.luan/audioplayers.global/events'),
73+
(MethodCall methodCall) async {
74+
if (methodCall.method == 'listen') return true;
75+
return null;
76+
},
77+
);
78+
79+
binding.defaultBinaryMessenger.setMockMethodCallHandler(
80+
MethodChannel('xyz.luan/audioplayers/events/pencilSoundEffect'),
81+
(MethodCall methodCall) async {
82+
if (methodCall.method == 'listen') return true;
83+
return null;
84+
},
85+
);
7386
}

0 commit comments

Comments
 (0)