-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
## Improvements * fix: Player should always request redundant_streams (#19) * feat: Set player software name as `mux-player-android` (#21) Co-authored-by: Emily Dixon <[email protected]> Co-authored-by: Tomislav Kordic <[email protected]> Co-authored-by: GitHub <[email protected]>
- Loading branch information
1 parent
e86b60d
commit d1593fd
Showing
310 changed files
with
4,793 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
name: Test with Sauce Labs | ||
|
||
on: | ||
push: | ||
|
||
env: | ||
SAUCE_USERNAME: ${{secrets.SAUCE_USERNAME}} | ||
SAUCE_ACCESS_KEY: ${{secrets.SAUCE_ACCESS_KEY}} | ||
|
||
#concurrency: | ||
# group: sauce-labs | ||
# cancel-in-progress: true | ||
|
||
jobs: | ||
build: | ||
name: Build Test APKs | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Set up JDK 17 | ||
uses: actions/setup-java@v3 | ||
with: | ||
java-version: '17' | ||
distribution: 'temurin' | ||
- name: Build automated tests | ||
uses: gradle/[email protected] | ||
with: | ||
arguments: automatedtests:assembleDebug :automatedtests:assembleDebugAndroidTest | ||
- name: Upload Test APKs | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: automated-test-apks | ||
path: | | ||
automatedtests/build/outputs/apk/androidTest/debug/automatedtests-debug-androidTest.apk | ||
automatedtests/build/outputs/apk/debug/automatedtests-debug.apk | ||
test: | ||
name: Run Sauce Labs Tests | ||
runs-on: ubuntu-latest | ||
needs: build | ||
|
||
strategy: | ||
max-parallel: 2 | ||
|
||
env: | ||
app_artifact: automatedtests\/build\/outputs\/apk\/debug\/automatedtests-debug.apk | ||
test_artifact: automatedtests\/build\/outputs\/apk\/androidTest\/debug\/automatedtests-debug-androidTest.apk | ||
app_apk: debug\/automatedtests-debug.apk | ||
test_apk: androidTest\/debug\/automatedtests-debug-androidTest.apk | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Download Test APKS | ||
uses: actions/download-artifact@v3 | ||
with: | ||
name: automated-test-apks | ||
- name: Build sauce config file | ||
run: | | ||
sed -E \ | ||
-e 's/BUILD_LABEL/debug/g' \ | ||
-e 's/APP_APK/${{ env.app_apk }}/g' \ | ||
-e 's/TEST_APK/${{ env.test_apk }}/g' \ | ||
.sauce/template.yml > .sauce/conf.yml | ||
- name: Dump Generated Sauce Conf | ||
run: cat .sauce/conf.yml | ||
- name: Run Saucelabs Test | ||
uses: saucelabs/saucectl-run-action@v3 | ||
env: | ||
GITHUB_TOKEN: ${{ github.token }} | ||
with: | ||
sauce-username: ${{ secrets.SAUCE_USERNAME }} | ||
sauce-access-key: ${{ secrets.SAUCE_ACCESS_KEY }} | ||
config-file: .sauce/conf.yml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
apiVersion: v1alpha | ||
kind: espresso | ||
sauce: | ||
region: us-west-1 | ||
concurrency: 1 | ||
retries: 3 | ||
|
||
metadata: | ||
#name: Runs from GHA | ||
tags: | ||
- saucectrl-runner | ||
build: Release BUILD_LABEL | ||
espresso: | ||
app: APP_APK | ||
testApp: TEST_APK | ||
suites: | ||
- name: 'BUILD_LABEL automation' | ||
devices: | ||
- name: Google Pixel.* | ||
|
||
#artifacts: | ||
# download: | ||
# when: always | ||
# match: | ||
# - junit.xml | ||
# - device.log | ||
# directory: ./data/artifacts/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
/build | ||
/buildout | ||
/automated_test_results |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
apply plugin: 'com.android.application' | ||
|
||
|
||
android { | ||
namespace = "com.mux.player.media3" | ||
compileSdkVersion 34 | ||
|
||
defaultConfig { | ||
applicationId "com.mux.player.media3" | ||
minSdkVersion 21 | ||
// Target SDK 31 causes manifest merger errors. One of our dependencies is not setting | ||
// `android:exported` for an Activity. Error logs have no more useful information | ||
targetSdkVersion 33 //project.ext.targetSdkVersion | ||
versionCode 1 | ||
versionName "1.0" | ||
multiDexEnabled true | ||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" | ||
|
||
buildConfigField("boolean", "SHOULD_REPORT_INSTRUMENTATION_TEST_EVENTS_TO_SERVER", "true") | ||
buildConfigField("String", "INSTRUMENTATION_TEST_ENVIRONMENT_KEY", "\"YOUR_KEY_HERE\"") | ||
} | ||
|
||
buildFeatures { | ||
buildConfig true | ||
} | ||
|
||
buildTypes { | ||
debug { | ||
minifyEnabled false | ||
} | ||
} | ||
|
||
|
||
testOptions { | ||
// Changes the directory where Gradle saves test reports. By default, Gradle saves test reports | ||
// in the path_to_your_project/module_name/build/outputs/reports/ directory. | ||
// '$rootDir' sets the path relative to the root directory of the current project. | ||
reportDir "./automated_test_results/reports" | ||
// Changes the directory where Gradle saves test results. By default, Gradle saves test results | ||
// in the path_to_your_project/module_name/build/outputs/test-results/ directory. | ||
// '$rootDir' sets the path relative to the root directory of the current project. | ||
resultsDir "./automated_test_results/results" | ||
} | ||
|
||
sourceSets { | ||
androidTest { | ||
// Important, can't get asset file in instrumentation test without this | ||
assets.srcDirs += 'src/main/assets' | ||
} | ||
} | ||
|
||
compileOptions { | ||
sourceCompatibility = JavaVersion.VERSION_1_8 | ||
targetCompatibility = JavaVersion.VERSION_1_8 | ||
} | ||
} | ||
|
||
dependencies { | ||
implementation fileTree(dir: "libs", include: ["*.jar"]) | ||
implementation 'androidx.appcompat:appcompat:1.4.0' | ||
implementation 'com.google.android.material:material:1.9.0' | ||
implementation 'androidx.constraintlayout:constraintlayout:2.0.3' | ||
implementation 'androidx.navigation:navigation-fragment:2.5.3' | ||
implementation 'androidx.navigation:navigation-ui:2.5.3' | ||
|
||
androidTestImplementation 'androidx.test:runner:1.5.2' | ||
androidTestImplementation 'androidx.test:rules:1.3.0' | ||
// Optional -- Hamcrest library | ||
androidTestImplementation 'org.hamcrest:hamcrest-library:1.3' | ||
// Optional -- UI testing with Espresso | ||
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1' | ||
// Optional -- UI testing with UI Automator | ||
androidTestImplementation 'androidx.test.uiautomator:uiautomator:2.2.0' | ||
androidTestImplementation 'androidx.test.ext:junit:1.1.2' | ||
|
||
api("com.mux.stats.sdk.muxstats:data-media3:${project.ext.get("muxDataVersion")}") | ||
|
||
api 'org.checkerframework:checker-qual:3.33.0' | ||
// Automated tests should always test the local module and not the maven dependency. | ||
implementation project(":library") | ||
} |
11 changes: 11 additions & 0 deletions
11
automatedtests/src/androidTest/java/com/mux/player/media3/MuxStatsHelper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package com.mux.player.media3; | ||
|
||
import com.mux.player.MuxPlayer; | ||
|
||
public class MuxStatsHelper { | ||
|
||
public static void allowHeaderToBeSentToBackend(MuxPlayer muxStats, String headerName) { | ||
// TODO: implement this | ||
// muxStats.allowHeaderToBeSentToBackend(headerName); | ||
} | ||
} |
94 changes: 94 additions & 0 deletions
94
.../src/androidTest/java/com/mux/player/media3/automatedtests/AdaptiveBitStreamTestBase.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
package com.mux.player.media3.automatedtests; | ||
|
||
import static androidx.media3.common.C.TRACK_TYPE_VIDEO; | ||
import static org.junit.Assert.fail; | ||
|
||
import androidx.media3.common.Format; | ||
import androidx.media3.common.TrackGroup; | ||
import androidx.media3.exoplayer.source.TrackGroupArray; | ||
import androidx.media3.exoplayer.trackselection.DefaultTrackSelector; | ||
import androidx.media3.exoplayer.trackselection.MappingTrackSelector; | ||
import com.mux.stats.sdk.core.events.playback.RenditionChangeEvent; | ||
import com.mux.stats.sdk.core.model.VideoData; | ||
import java.util.ArrayList; | ||
import org.json.JSONException; | ||
import org.json.JSONObject; | ||
import org.junit.Ignore; | ||
import org.junit.Test; | ||
|
||
public class AdaptiveBitStreamTestBase extends TestBase { | ||
|
||
@Test | ||
@Ignore("Dummy Test that prevents the 'no runnable methods' failure") | ||
public void dummyTestThatPasses() { | ||
// This test is needed because extending TestBase fools junit into thinking this class has | ||
// @Test-annotated tests instead of just utility code | ||
} | ||
|
||
TrackGroupArray getVideoTrackGroupArray() { | ||
DefaultTrackSelector selector = testActivity.getTrackSelector(); | ||
MappingTrackSelector.MappedTrackInfo mappedTrackInfo = selector.getCurrentMappedTrackInfo(); | ||
for (int rendererTrackIndex = 0; rendererTrackIndex < mappedTrackInfo.getRendererCount(); | ||
rendererTrackIndex++) { | ||
int trackType = mappedTrackInfo.getRendererType(rendererTrackIndex); | ||
if (trackType == TRACK_TYPE_VIDEO) { | ||
return mappedTrackInfo | ||
.getTrackGroups(rendererTrackIndex); | ||
} | ||
|
||
} | ||
return null; | ||
} | ||
|
||
ArrayList<Format> getAvailableVideoRendition() { | ||
ArrayList<Format> result = new ArrayList<>(); | ||
TrackGroupArray videoTrackGroupArray = getVideoTrackGroupArray(); | ||
for (int trackIndex = 0; trackIndex < videoTrackGroupArray.length; trackIndex++) { | ||
TrackGroup trackGroup = videoTrackGroupArray.get(trackIndex); | ||
for (int formatIndex = 0; formatIndex < trackGroup.length; formatIndex++) { | ||
result.add(trackGroup.getFormat(formatIndex)); | ||
} | ||
} | ||
return result; | ||
} | ||
|
||
int getSelectedRenditionIndex() throws JSONException { | ||
int renditionChangeIndex = networkRequest.getIndexForFirstEvent(RenditionChangeEvent.TYPE); | ||
if (renditionChangeIndex == -1) { | ||
return -1; | ||
} | ||
JSONObject jo = networkRequest.getEventForIndex(renditionChangeIndex); | ||
if (jo == null || !jo.has(VideoData.VIDEO_SOURCE_WIDTH) || !jo | ||
.has(VideoData.VIDEO_SOURCE_HEIGHT)) { | ||
return -1; | ||
} | ||
int videoWidth = jo.getInt(VideoData.VIDEO_SOURCE_WIDTH); | ||
int videoHeight = jo.getInt(VideoData.VIDEO_SOURCE_HEIGHT); | ||
|
||
ArrayList<Format> availableFormats = getAvailableVideoRendition(); | ||
int index = 0; | ||
for (Format fmt : availableFormats) { | ||
if (Math.abs(fmt.width - videoWidth) < 10 && | ||
Math.abs(fmt.height - videoHeight) < 10) { | ||
return index; | ||
} | ||
index++; | ||
} | ||
String availableFormatsStr = ""; | ||
for (Format fmt : availableFormats) { | ||
availableFormatsStr += "(" + fmt.width + "x" + fmt.height + ") "; | ||
} | ||
fail("Reported source resolution: " + videoWidth + "x" + videoHeight + | ||
" do not match any of available formats: " + availableFormatsStr); | ||
return -1; | ||
} | ||
|
||
void switchRenditionToIndex(int index) { | ||
Format fmt = getAvailableVideoRendition().get(index); | ||
DefaultTrackSelector selector = testActivity.getTrackSelector(); | ||
selector.setParameters(selector.buildUponParameters() | ||
.setMaxVideoSize(fmt.width, fmt.height) | ||
.setForceHighestSupportedBitrate(true) | ||
); | ||
} | ||
} |
Oops, something went wrong.