Skip to content

Commit

Permalink
test: player state, improved position & duration (#1257, #1298) (#1284)
Browse files Browse the repository at this point in the history
* test: player state tests (#1257)

* test: more reliable duration checks

* test: test for duration on live stream

* test: improve durationRangeMatcher

* test(example): allow cleartext traffic / AllowsArbitraryLoads on darwin

* test: test onPosition on every platform

* tests: overwrite setState for streams tab

* fix(linux): install gstreamer1.0-plugins-bad for m3u8 tests

* test(windows): disable playlist source (m3u8) on windows
  • Loading branch information
Gustl22 authored Oct 5, 2022
1 parent a4474dc commit 5dcc382
Show file tree
Hide file tree
Showing 12 changed files with 379 additions and 230 deletions.
258 changes: 129 additions & 129 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: build
on:
workflow_dispatch: {}
workflow_dispatch: { }
push:
branches:
- main
Expand Down Expand Up @@ -34,160 +34,160 @@ jobs:
timeout-minutes: 30
if: github.event.pull_request.draft == false
steps:
- uses: actions/checkout@v3

- uses: nanasess/setup-chromedriver@v1
- uses: actions/checkout@v3

- uses: subosito/flutter-action@v2
with:
channel: stable
- uses: bluefireteam/melos-action@main
- uses: nanasess/setup-chromedriver@v1

- name: Example app - Build Web app
working-directory: ./packages/audioplayers/example
run: |
flutter build web
- uses: subosito/flutter-action@v2
with:
channel: stable
- uses: bluefireteam/melos-action@main

- name: Run Flutter integration tests
working-directory: ./packages/audioplayers/example
run: |
export DISPLAY=:99
chromedriver --port=4444 &
sudo Xvfb -ac :99 -screen 0 1280x1024x24 > /dev/null 2>&1 & # optional
- name: Example app - Build Web app
working-directory: ./packages/audioplayers/example
run: |
flutter build web
flutter drive \
--driver=test_driver/integration_test.dart \
--target=integration_test/app_test.dart \
-d web-server --web-browser-flag="--autoplay-policy=no-user-gesture-required"
- name: Run Flutter integration tests
working-directory: ./packages/audioplayers/example
run: |
export DISPLAY=:99
chromedriver --port=4444 &
sudo Xvfb -ac :99 -screen 0 1280x1024x24 > /dev/null 2>&1 & # optional
flutter drive \
--driver=test_driver/integration_test.dart \
--target=integration_test/app_test.dart \
-d web-server --web-browser-flag="--autoplay-policy=no-user-gesture-required"
android:
runs-on: macOS-latest
timeout-minutes: 60
if: github.event.pull_request.draft == false
steps:
- uses: actions/checkout@v3

- name: Setup Java
uses: actions/setup-java@v2
with:
distribution: 'temurin'
java-version: '17'

- name: Setup Android SDK
uses: android-actions/setup-android@v2

- uses: subosito/flutter-action@v2
with:
channel: stable
- uses: bluefireteam/melos-action@main

- name: Example App - Build Android APK
working-directory: ./packages/audioplayers/example
run: |
flutter build apk --release
- name: Run Android unit tests
working-directory: ./packages/audioplayers/example/android
run: |
./gradlew test
- name: Download Android emulator image
run: |
export ANDROID_TOOLS="$ANDROID_HOME/cmdline-tools/latest/bin"
echo "y" | $ANDROID_TOOLS/sdkmanager --install "system-images;android-30;aosp_atd;x86"
echo "no" | $ANDROID_TOOLS/avdmanager create avd --force --name emu --device "Nexus 5X" -k 'system-images;android-30;aosp_atd;x86'
$ANDROID_HOME/emulator/emulator -list-avds
- name: Start Android emulator
timeout-minutes: 10
run: |
export ANDROID_TOOLS="$ANDROID_HOME/cmdline-tools/latest/bin"
echo "Starting emulator"
$ANDROID_TOOLS/sdkmanager "platform-tools" "platforms;android-30"
nohup $ANDROID_HOME/emulator/emulator -avd emu -no-audio -no-snapshot -no-window &
$ANDROID_HOME/platform-tools/adb wait-for-device shell 'while [[ -z $(getprop sys.boot_completed | tr -d '\r') ]]; do sleep 1; done; input keyevent 82'
$ANDROID_HOME/platform-tools/adb devices
echo "Emulator started"
- name: Run Flutter integration tests
working-directory: ./packages/audioplayers/example
run: "flutter test integration_test"
- uses: actions/checkout@v3

- name: Setup Java
uses: actions/setup-java@v2
with:
distribution: 'temurin'
java-version: '17'

- name: Setup Android SDK
uses: android-actions/setup-android@v2

- uses: subosito/flutter-action@v2
with:
channel: stable
- uses: bluefireteam/melos-action@main

- name: Example App - Build Android APK
working-directory: ./packages/audioplayers/example
run: |
flutter build apk --release
- name: Run Android unit tests
working-directory: ./packages/audioplayers/example/android
run: |
./gradlew test
- name: Download Android emulator image
run: |
export ANDROID_TOOLS="$ANDROID_HOME/cmdline-tools/latest/bin"
echo "y" | $ANDROID_TOOLS/sdkmanager --install "system-images;android-30;aosp_atd;x86"
echo "no" | $ANDROID_TOOLS/avdmanager create avd --force --name emu --device "Nexus 5X" -k 'system-images;android-30;aosp_atd;x86'
$ANDROID_HOME/emulator/emulator -list-avds
- name: Start Android emulator
timeout-minutes: 10
run: |
export ANDROID_TOOLS="$ANDROID_HOME/cmdline-tools/latest/bin"
echo "Starting emulator"
$ANDROID_TOOLS/sdkmanager "platform-tools" "platforms;android-30"
nohup $ANDROID_HOME/emulator/emulator -avd emu -no-audio -no-snapshot -no-window &
$ANDROID_HOME/platform-tools/adb wait-for-device shell 'while [[ -z $(getprop sys.boot_completed | tr -d '\r') ]]; do sleep 1; done; input keyevent 82'
$ANDROID_HOME/platform-tools/adb devices
echo "Emulator started"
- name: Run Flutter integration tests
working-directory: ./packages/audioplayers/example
run: "flutter test integration_test"

ios:
runs-on: macOS-latest
timeout-minutes: 60
if: github.event.pull_request.draft == false
steps:
- uses: actions/checkout@v3
- uses: subosito/flutter-action@v2
with:
channel: stable
- uses: bluefireteam/melos-action@main

- name: List all simulators
run: "xcrun simctl list devices"
- name: Start simulator
run: |
UDID=$(xcrun simctl list devices | grep "iPhone" | sed -n 1p | awk -F '\\)? \\(' '{ print $2 }')
echo "Using simulator $UDID"
xcrun simctl boot "${UDID:?No Simulator with this name iPhone found}"
- name: Example app - Build iOS
working-directory: ./packages/audioplayers/example
run: |
flutter build ios --release --no-codesign
- name: Run Flutter integration tests
working-directory: ./packages/audioplayers/example
run: "flutter test integration_test"
- uses: actions/checkout@v3
- uses: subosito/flutter-action@v2
with:
channel: stable
- uses: bluefireteam/melos-action@main

- name: List all simulators
run: "xcrun simctl list devices"
- name: Start simulator
run: |
UDID=$(xcrun simctl list devices | grep "iPhone" | sed -n 1p | awk -F '\\)? \\(' '{ print $2 }')
echo "Using simulator $UDID"
xcrun simctl boot "${UDID:?No Simulator with this name iPhone found}"
- name: Example app - Build iOS
working-directory: ./packages/audioplayers/example
run: |
flutter build ios --release --no-codesign
- name: Run Flutter integration tests
working-directory: ./packages/audioplayers/example
run: "flutter test integration_test"

macos:
runs-on: macOS-latest
timeout-minutes: 30
if: github.event.pull_request.draft == false
steps:
- uses: actions/checkout@v3
- uses: subosito/flutter-action@v2
with:
channel: stable
- uses: bluefireteam/melos-action@main

- name: setup-cocoapods
uses: maxim-lobanov/setup-cocoapods@v1
with:
podfile-path: ./packages/audioplayers/example/macos/Podfile.lock
- name: Example app - Build macOS
working-directory: ./packages/audioplayers/example
run: |
flutter config --enable-macos-desktop
flutter build macos --release
- name: Run Flutter integration tests
working-directory: ./packages/audioplayers/example
run: "flutter test -d macos integration_test"
- uses: actions/checkout@v3
- uses: subosito/flutter-action@v2
with:
channel: stable
- uses: bluefireteam/melos-action@main

- name: setup-cocoapods
uses: maxim-lobanov/setup-cocoapods@v1
with:
podfile-path: ./packages/audioplayers/example/macos/Podfile.lock
- name: Example app - Build macOS
working-directory: ./packages/audioplayers/example
run: |
flutter config --enable-macos-desktop
flutter build macos --release
- name: Run Flutter integration tests
working-directory: ./packages/audioplayers/example
run: "flutter test -d macos integration_test"

windows:
runs-on: windows-latest
timeout-minutes: 30
if: github.event.pull_request.draft == false
steps:
- uses: actions/checkout@v3
- uses: subosito/flutter-action@v2
with:
channel: stable
- uses: bluefireteam/melos-action@main
- name: Example app - Build Windows app
working-directory: ./packages/audioplayers/example
run: |
flutter build windows --release
- name: Start audio server
run: net start audiosrv
- name: Install virtual audio device
shell: powershell
run: |
Invoke-WebRequest https://github.com/duncanthrax/scream/releases/download/3.9/Scream3.9.zip -OutFile Scream3.9.zip
Expand-Archive -Path Scream3.9.zip -DestinationPath Scream
Import-Certificate -FilePath Scream\Install\driver\x64\Scream.cat -CertStoreLocation Cert:\LocalMachine\TrustedPublisher
Scream\Install\helpers\devcon-x64.exe install Scream\Install\driver\x64\Scream.inf *Scream
- name: Run Flutter integration tests
working-directory: ./packages/audioplayers/example
run: "flutter test -d windows integration_test"
- uses: actions/checkout@v3
- uses: subosito/flutter-action@v2
with:
channel: stable
- uses: bluefireteam/melos-action@main
- name: Example app - Build Windows app
working-directory: ./packages/audioplayers/example
run: |
flutter build windows --release
- name: Start audio server
run: net start audiosrv
- name: Install virtual audio device
shell: powershell
run: |
Invoke-WebRequest https://github.com/duncanthrax/scream/releases/download/3.9/Scream3.9.zip -OutFile Scream3.9.zip
Expand-Archive -Path Scream3.9.zip -DestinationPath Scream
Import-Certificate -FilePath Scream\Install\driver\x64\Scream.cat -CertStoreLocation Cert:\LocalMachine\TrustedPublisher
Scream\Install\helpers\devcon-x64.exe install Scream\Install\driver\x64\Scream.inf *Scream
- name: Run Flutter integration tests
working-directory: ./packages/audioplayers/example
run: "flutter test -d windows integration_test"

linux:
runs-on: ubuntu-latest
Expand All @@ -200,11 +200,11 @@ jobs:
channel: stable
- uses: bluefireteam/melos-action@main
- name: Install Flutter requirements for Linux
run: |
run: |
sudo apt-get update
sudo apt-get install clang cmake ninja-build pkg-config libgtk-3-dev liblzma-dev
- name: Install GStreamer
run: sudo apt-get install libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev gstreamer1.0-plugins-good
run: sudo apt-get install libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev gstreamer1.0-plugins-good gstreamer1.0-plugins-bad
- name: Example app - Build Linux app
working-directory: ./packages/audioplayers/example
run: |
Expand Down
4 changes: 2 additions & 2 deletions feature_parity_table.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ Note: LLM means Low Latency Mode.
<tr><td>byte array</td><td>SDK >=23</td><td>not yet</td><td>not yet</td><td>not yet</td><td>not yet</td><td>not yet</td></tr>
<tr><td colspan="7"><strong>Audio Config</strong></td></tr>
<tr><td>set url</td><td>yes</td><td>yes</td><td>yes</td><td>yes</td><td>yes</td><td>yes</td></tr>
<tr><td>audio cache (pre-load)</td><td>yes</td><td>yes</td><td>yes</td><td>yes</td><td>yes</td><td>yes (?)</td></tr>
<tr><td>audio cache (pre-load)</td><td>yes</td><td>yes</td><td>yes</td><td>yes</td><td>yes</td><td>yes</td></tr>
<tr><td>low latency mode</td><td>SDK >=21</td><td>no</td><td>no</td><td>no</td><td>no</td><td>no</td></tr>
<tr><td colspan="7"><strong>Audio Control Commands</strong></td></tr>
<tr><td>resume / pause / stop</td><td>yes</td><td>yes</td><td>yes</td><td>yes</td><td>yes</td><td>yes</td></tr>
Expand All @@ -63,7 +63,7 @@ Note: LLM means Low Latency Mode.
<tr><td colspan="7"><strong>Streams</strong></td></tr>
<tr><td>duration event</td><td>yes</td><td>yes</td><td>yes</td><td>yes</td><td>yes</td><td>yes</td></tr>
<tr><td>position event</td><td>yes</td><td>yes</td><td>yes</td><td>yes</td><td>yes</td><td>yes</td></tr>
<tr><td>state event</td><td>yes</td><td>yes</td><td>yes</td><td>yes</td><td>yes</td><td>yes (?)</td></tr>
<tr><td>state event</td><td>yes</td><td>yes</td><td>yes</td><td>yes</td><td>yes</td><td>yes</td></tr>
<tr><td>completion event</td><td>yes</td><td>yes</td><td>yes</td><td>yes</td><td>yes</td><td>yes</td></tr>
<tr><td>error event</td><td>yes</td><td>yes</td><td>yes</td><td>not yet</td><td>yes</td><td>yes</td></tr>
</tbody>
Expand Down
4 changes: 2 additions & 2 deletions packages/audioplayers/example/integration_test/app_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,13 @@ void main() {
SourceTestData(
sourceKey: 'url-remote-m3u8',
duration: Duration.zero,
isStream: true,
isLiveStream: true,
),
if (features.hasUrlSource)
SourceTestData(
sourceKey: 'url-remote-mpga',
duration: Duration.zero,
isStream: true,
isLiveStream: true,
),
if (features.hasAssetSource)
SourceTestData(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ class PlatformFeatures {

static const windowsPlatformFeatures = PlatformFeatures(
hasBytesSource: false,
hasPlaylistSourceType: false,
hasLowLatency: false,
hasDuckAudio: false,
hasRespectSilence: false,
Expand All @@ -73,15 +74,15 @@ class PlatformFeatures {

final bool hasPlaylistSourceType;

final bool hasLowLatency; // Not yet tested
final bool hasReleaseModeRelease; // Not yet tested
final bool hasReleaseModeLoop; // Not yet tested
final bool hasVolume; // Not yet tested
final bool hasBalance; // Not yet tested
final bool hasSeek; // Not yet tested
final bool hasMp3Duration; // Not yet tested
final bool hasLowLatency;
final bool hasReleaseModeRelease;
final bool hasReleaseModeLoop;
final bool hasVolume;
final bool hasBalance;
final bool hasSeek;
final bool hasMp3Duration;

final bool hasPlaybackRate; // Not yet tested
final bool hasPlaybackRate;
final bool hasDuckAudio; // Not yet tested
final bool hasRespectSilence; // Not yet tested
final bool hasStayAwake; // Not yet tested
Expand All @@ -90,7 +91,7 @@ class PlatformFeatures {

final bool hasDurationEvent;
final bool hasPositionEvent;
final bool hasCompletionEvent; // Not yet tested
final bool hasPlayerStateEvent;
final bool hasErrorEvent; // Not yet tested

const PlatformFeatures({
Expand All @@ -113,7 +114,7 @@ class PlatformFeatures {
this.hasPlayingRoute = true,
this.hasDurationEvent = true,
this.hasPositionEvent = true,
this.hasCompletionEvent = true,
this.hasPlayerStateEvent = true,
this.hasErrorEvent = true,
});

Expand Down
Loading

0 comments on commit 5dcc382

Please sign in to comment.