Skip to content
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
58525a2
fix(linux): reuse channelId
Gustl22 Jun 28, 2023
7aca81f
ci: set other flutter version for linux
Gustl22 Jun 28, 2023
4d0c7a9
test(linux): remove tests for reusing event channel
Gustl22 Jun 28, 2023
4c6a25d
test(linux): remove additional pumps
Gustl22 Jun 28, 2023
a6e6b03
Revert "test(linux): remove additional pumps"
Gustl22 Jun 28, 2023
5f6ac19
test(linux): change issue for additional pumps
Gustl22 Jun 28, 2023
d42bd46
Merge branch 'main' into gustl22/1498-reuse-channel
Gustl22 Jun 29, 2023
c645f22
ci: use version 3.12.0-12.0.pre for Linux
Gustl22 Jul 4, 2023
1806a7f
revert
Gustl22 Jul 4, 2023
9d2d21e
revert
Gustl22 Jul 4, 2023
c653c01
print flutter version
Gustl22 Jul 5, 2023
49b6bdd
debug print
Gustl22 Jul 5, 2023
cd9d6fd
Merge branch 'main' into gustl22/1498-reuse-channel
Gustl22 Jul 18, 2023
5ef4159
remove last pump
Gustl22 Jul 18, 2023
7be0ee9
Revert "remove last pump"
Gustl22 Jul 18, 2023
5fc801f
Revert "debug print"
Gustl22 Jul 18, 2023
78b2711
Revert "print flutter version"
Gustl22 Jul 18, 2023
c8d0378
use beta version
Gustl22 Jul 18, 2023
00d97d5
add additional pump
Gustl22 Jul 18, 2023
ca137a7
Merge branch 'main' into gustl22/1498-reuse-channel
Gustl22 Jul 19, 2023
2746a01
add more pumps for linux
Gustl22 Jul 19, 2023
8b36dff
remove unused variable
Gustl22 Jul 19, 2023
bb93d3f
[WIP]: comment tests
Gustl22 Jul 19, 2023
b8c4fd8
[WIP] : debug variables
Gustl22 Jul 19, 2023
fd65737
[WIP] : add pumps
Gustl22 Jul 19, 2023
3c3b1fc
[WIP] : remove some pumps
Gustl22 Jul 19, 2023
e7c82f0
[WIP] : other pumps
Gustl22 Jul 19, 2023
3b13355
[WIP] : retest default
Gustl22 Jul 19, 2023
815ecbe
Revert "[WIP] : retest default"
Gustl22 Jul 19, 2023
e6e99a0
Revert "[WIP] : other pumps"
Gustl22 Jul 19, 2023
e96e5f5
Revert "[WIP] : remove some pumps"
Gustl22 Jul 19, 2023
3888137
Revert "[WIP] : add pumps"
Gustl22 Jul 19, 2023
5b2661e
Revert "[WIP] : debug variables"
Gustl22 Jul 19, 2023
7918767
remoe faulty pumps
Gustl22 Jul 19, 2023
b7b3bc4
pump elsewhere
Gustl22 Jul 19, 2023
7ebba34
enable app tests again
Gustl22 Jul 19, 2023
6634676
fix pump
Gustl22 Jul 19, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -268,8 +268,9 @@ jobs:
- uses: actions/checkout@v3
- uses: subosito/flutter-action@v2
with:
flutter-version: ${{ inputs.flutter_version }}
channel: 'stable'
# TODO: uncomment and change to `stable`, when flutter/flutter#129534 has been released.
#flutter-version: ${{ inputs.flutter_version }}
channel: 'master'
- uses: bluefireteam/melos-action@main
- name: Install Flutter requirements for Linux
run: |
Expand Down
112 changes: 26 additions & 86 deletions packages/audioplayers/example/integration_test/lib_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,6 @@ void main() {
final isAndroid = !kIsWeb && Platform.isAndroid;
final isLinux = !kIsWeb && Platform.isLinux;

// FIXME(gustl22): Cannot reuse event channel with same id on Linux (flutter/flutter#126209)
var linuxPlayerCount = 0;

final wavUrl1TestData = LibSourceTestData(
source: UrlSource(wavUrl1),
duration: const Duration(milliseconds: 451),
Expand Down Expand Up @@ -79,7 +76,7 @@ void main() {
// Start all players simultaneously
final iterator = List<int>.generate(audioTestDataList.length, (i) => i);
if (isLinux) {
// FIXME(gustl22): Linux needs additional pump (#1507)
// FIXME(gustl22): Linux needs additional pump (#1556)
await tester.pump();
}
await Future.wait<void>(
Expand All @@ -98,10 +95,7 @@ void main() {
}
await players[i].stop();
}
if (!isLinux) {
// FIXME(gustl22): Linux not disposing properly (#1507)
await Future.wait(players.map((p) => p.dispose()));
}
await Future.wait(players.map((p) => p.dispose()));
},
// FIXME: Causes media error on Android (see #1333, #1353)
// Unexpected platform error: MediaPlayer error with
Expand All @@ -116,7 +110,7 @@ void main() {
for (var i = 0; i < audioTestDataList.length; i++) {
final td = audioTestDataList[i];
if (isLinux) {
// FIXME(gustl22): Linux needs additional pump (#1507)
// FIXME(gustl22): Linux needs additional pump (#1556)
await tester.pump();
}
await player.play(td.source);
Expand All @@ -131,10 +125,7 @@ void main() {
}
await player.stop();
}
if (!isLinux) {
// FIXME(gustl22): Linux not disposing properly (#1507)
await player.dispose();
}
await player.dispose();
});
});

Expand All @@ -161,7 +152,7 @@ void main() {
await player.setAudioContext(audioContext);

if (isLinux) {
// FIXME(gustl22): Linux needs additional pump (#1507)
// FIXME(gustl22): Linux needs additional pump (#1556)
await tester.pump();
}
await player.play(td.source);
Expand All @@ -180,10 +171,7 @@ void main() {
await tester.pumpAndSettle();
await tester.pump(td.duration + const Duration(seconds: 8));
expect(player.state, PlayerState.completed);
if (!isLinux) {
// FIXME(gustl22): Linux not disposing properly (#1507)
await player.dispose();
}
await player.dispose();
},
skip: !features.hasForceSpeaker,
);
Expand Down Expand Up @@ -211,7 +199,7 @@ void main() {
await player.setAudioContext(audioContext);

if (isLinux) {
// FIXME(gustl22): Linux needs additional pump (#1507)
// FIXME(gustl22): Linux needs additional pump (#1556)
await tester.pump();
}
await player.setSource(td.source);
Expand All @@ -235,10 +223,7 @@ void main() {
expect(player.state, PlayerState.playing);
await player.stop();
expect(player.state, PlayerState.stopped);
if (!isLinux) {
// FIXME(gustl22): Linux not disposing properly (#1507)
await player.dispose();
}
await player.dispose();
},
skip: !features.hasForceSpeaker || !features.hasLowLatency,
);
Expand All @@ -248,7 +233,7 @@ void main() {
testWidgets('Emit platform log', (tester) async {
final logCompleter = Completer<String>();

final playerId = 'somePlayerId${isLinux ? linuxPlayerCount++ : ''}';
const playerId = 'somePlayerId';
final player = AudioPlayer(playerId: playerId);
final onLogSub = player.onLog.listen(
logCompleter.complete,
Expand Down Expand Up @@ -289,7 +274,7 @@ void main() {
try {
// Throws PlatformException via MethodChannel:
if (isLinux) {
// FIXME(gustl22): Linux needs additional pump (#1507)
// FIXME(gustl22): Linux needs additional pump (#1556)
await tester.pump();
}
await player.setSource(AssetSource(invalidAsset));
Expand All @@ -298,10 +283,7 @@ void main() {
} catch (e) {
expect(e, isInstanceOf<PlatformException>());
}
if (!isLinux) {
// FIXME(gustl22): Linux not disposing properly (#1507)
await player.dispose();
}
await player.dispose();
},
);

Expand All @@ -312,7 +294,7 @@ void main() {
try {
// Throws PlatformException via MethodChannel:
if (isLinux) {
// FIXME(gustl22): Linux needs additional pump (#1507)
// FIXME(gustl22): Linux needs additional pump (#1556)
await tester.pump();
}
await player.setSource(UrlSource('non_existent.txt'));
Expand All @@ -321,10 +303,7 @@ void main() {
} catch (e) {
expect(e, isInstanceOf<PlatformException>());
}
if (!isLinux) {
// FIXME(gustl22): Linux not disposing properly (#1507)
await player.dispose();
}
await player.dispose();
},
);
});
Expand All @@ -333,7 +312,7 @@ void main() {
testWidgets('#create and #dispose', (tester) async {
final platform = AudioplayersPlatformInterface.instance;

final playerId = 'somePlayerId${isLinux ? linuxPlayerCount++ : ''}';
const playerId = 'somePlayerId';
await platform.create(playerId);
await tester.pumpAndSettle();
await platform.dispose(playerId);
Expand All @@ -354,7 +333,7 @@ void main() {
testWidgets('#setSource #getPosition and #getDuration', (tester) async {
final platform = AudioplayersPlatformInterface.instance;

final playerId = 'somePlayerId${isLinux ? linuxPlayerCount++ : ''}';
const playerId = 'somePlayerId';
await platform.create(playerId);

final preparedCompleter = Completer<void>();
Expand All @@ -371,7 +350,7 @@ void main() {
onError: preparedCompleter.completeError,
);
if (isLinux) {
// FIXME(gustl22): Linux needs additional pump (#1507)
// FIXME(gustl22): Linux needs additional pump (#1556)
await tester.pump();
}
await platform.setSourceUrl(
Expand All @@ -387,16 +366,13 @@ void main() {
);

await onPreparedSub.cancel();
if (!isLinux) {
// FIXME(gustl22): Linux not disposing properly (#1507)
await platform.dispose(playerId);
}
await platform.dispose(playerId);
});

testWidgets('#seek with millisecond precision', (tester) async {
final platform = AudioplayersPlatformInterface.instance;

final playerId = 'somePlayerId${isLinux ? linuxPlayerCount++ : ''}';
const playerId = 'somePlayerId';
await platform.create(playerId);

final preparedCompleter = Completer<void>();
Expand All @@ -413,7 +389,7 @@ void main() {
onError: preparedCompleter.completeError,
);
if (isLinux) {
// FIXME(gustl22): Linux needs additional pump (#1507)
// FIXME(gustl22): Linux needs additional pump (#1556)
await tester.pump();
}
await platform.setSourceUrl(
Expand All @@ -437,16 +413,13 @@ void main() {
expect(await platform.getCurrentPosition(playerId), 21);

await onPreparedSub.cancel();
if (!isLinux) {
// FIXME(gustl22): Linux not disposing properly (#1507)
await platform.dispose(playerId);
}
await platform.dispose(playerId);
});

testWidgets('Set same source twice (#1520)', (tester) async {
final platform = AudioplayersPlatformInterface.instance;

final playerId = 'somePlayerId${isLinux ? linuxPlayerCount++ : ''}';
const playerId = 'somePlayerId';
await platform.create(playerId);

final eventStream = platform.getEventStream(playerId);
Expand All @@ -464,7 +437,7 @@ void main() {
onError: preparedCompleter.completeError,
);
if (isLinux) {
// FIXME(gustl22): Linux needs additional pump (#1507)
// FIXME(gustl22): Linux needs additional pump (#1556)
await tester.pump();
}
await platform.setSourceUrl(
Expand All @@ -474,63 +447,30 @@ void main() {
await preparedCompleter.future.timeout(const Duration(seconds: 30));
await onPreparedSub.cancel();
}
if (!isLinux) {
// FIXME(gustl22): Linux not disposing properly (#1507)
await platform.dispose(playerId);
}
await platform.dispose(playerId);
});
});

group('Platform event channel', () {
testWidgets('Listen and cancel twice', (tester) async {
final platform = AudioplayersPlatformInterface.instance;

final playerId = 'somePlayerId${isLinux ? linuxPlayerCount++ : ''}';
const playerId = 'somePlayerId';
await platform.create(playerId);

final eventStream = platform.getEventStream(playerId);
for (var i = 0; i < 2; i++) {
final eventSub = eventStream.listen(null);
await eventSub.cancel();
}
if (!isLinux) {
// FIXME(gustl22): Linux not disposing properly (#1507)
await platform.dispose(playerId);
}
await platform.dispose(playerId);
});

// TODO(gustl22): remove once https://github.com/flutter/flutter/issues/126209
// is fixed, as tests should cover the problem in flutter engine.
testWidgets(
'Reuse same platform event channel id',
(tester) async {
final platform = AudioplayersPlatformInterface.instance;

const playerId = 'somePlayerId';
await platform.create(playerId);

final eventStreamSub = platform.getEventStream(playerId).listen((_) {});

await eventStreamSub.cancel();
await platform.dispose(playerId);

// Recreate player with same player Id
await platform.create(playerId);

final eventStreamSub2 =
platform.getEventStream(playerId).listen((_) {});

await eventStreamSub2.cancel();
await platform.dispose(playerId);
},
skip: isLinux,
);

testWidgets('Emit platform error', (tester) async {
final errorCompleter = Completer<Object>();
final platform = AudioplayersPlatformInterface.instance;

final playerId = 'somePlayerId${isLinux ? linuxPlayerCount++ : ''}';
const playerId = 'somePlayerId';
await platform.create(playerId);

final eventStreamSub = platform
Expand Down