Commit d5ac93f4 by eguven Committed by Oliver Woodman

Move playback tests to androidTest folder

This change makes Android Studio recognize tests as "android test" and run them on device by default.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=142008012
parent 31e2fa85
......@@ -11,14 +11,14 @@
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
apply plugin: 'com.android.application'
apply plugin: 'com.android.library'
android {
compileSdkVersion project.ext.compileSdkVersion
buildToolsVersion project.ext.buildToolsVersion
defaultConfig {
minSdkVersion 16
minSdkVersion 9
targetSdkVersion project.ext.targetSdkVersion
}
......
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2016 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.google.android.exoplayer2.playbacktests"
android:versionCode="2004"
android:versionName="2.0.4">
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.WAKE_LOCK"/>
<uses-sdk android:minSdkVersion="9" android:targetSdkVersion="24"/>
<application android:debuggable="true"
android:allowBackup="false"
tools:ignore="MissingApplicationIcon,HardcodedDebugMode">
<uses-library android:name="android.test.runner"/>
<activity android:name="com.google.android.exoplayer2.playbacktests.util.HostActivity"
android:configChanges="keyboardHidden|orientation|screenSize"
android:label="ExoPlayerTest"/>
</application>
<instrumentation
android:targetPackage="com.google.android.exoplayer2.playbacktests"
android:name="android.test.InstrumentationTestRunner"
tools:replace="android:targetPackage"/>
</manifest>
/*
* Copyright (C) 2016 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.google.android.exoplayer2.playbacktests;
import android.annotation.TargetApi;
import android.net.Uri;
import android.test.ActivityInstrumentationTestCase2;
import com.google.android.exoplayer2.ExoPlayer;
import com.google.android.exoplayer2.extractor.mp3.Mp3Extractor;
import com.google.android.exoplayer2.playbacktests.util.ActionSchedule;
import com.google.android.exoplayer2.playbacktests.util.ExoHostedTest;
import com.google.android.exoplayer2.playbacktests.util.HostActivity;
import com.google.android.exoplayer2.source.ExtractorMediaSource;
import com.google.android.exoplayer2.source.MediaSource;
import com.google.android.exoplayer2.upstream.DataSource;
import com.google.android.exoplayer2.upstream.DefaultDataSourceFactory;
import com.google.android.exoplayer2.upstream.TransferListener;
import com.google.android.exoplayer2.util.ClosedSource;
import com.google.android.exoplayer2.util.Util;
/**
* Tests MP3 playback using {@link ExoPlayer}.
*/
@ClosedSource(reason = "Not yet ready")
public final class Mp3PlaybackTest extends ActivityInstrumentationTestCase2<HostActivity> {
private static final String TAG = "Mp3PlaybackTest";
private static final String URL = "http://storage.googleapis.com/exoplayer-test-media-0/play.mp3";
private static final long TEST_TIMEOUT_MS = 2 * 60 * 1000;
public Mp3PlaybackTest() {
super(HostActivity.class);
}
public void testPlayback() {
if (Util.SDK_INT < 16) {
// Pass.
return;
}
Mp3HostedTest test = new Mp3HostedTest(URL, true);
getActivity().runTest(test, TEST_TIMEOUT_MS);
}
public void testPlaybackWithSeeking() {
if (Util.SDK_INT < 16) {
// Pass.
return;
}
Mp3HostedTest test = new Mp3HostedTest(URL, false);
ActionSchedule schedule = new ActionSchedule.Builder(TAG)
.delay(5000).seek(30000)
.delay(5000).seek(0)
.delay(5000).seek(30000)
.delay(5000).stop()
.build();
test.setSchedule(schedule);
getActivity().runTest(test, TEST_TIMEOUT_MS);
}
@TargetApi(16)
private static class Mp3HostedTest extends ExoHostedTest {
private final Uri uri;
public Mp3HostedTest(String uriString, boolean fullPlaybackNoSeeking) {
super("Mp3PlaybackTest", fullPlaybackNoSeeking);
uri = Uri.parse(uriString);
}
@Override
public MediaSource buildSource(HostActivity host, String userAgent,
TransferListener<? super DataSource> mediaTransferListener) {
DataSource.Factory dataSourceFactory = new DefaultDataSourceFactory(host, userAgent,
mediaTransferListener);
return new ExtractorMediaSource(uri, dataSourceFactory, Mp3Extractor.FACTORY, null, null);
}
}
}
/*
* Copyright (C) 2016 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.google.android.exoplayer2.playbacktests;
import android.annotation.TargetApi;
import android.net.Uri;
import android.test.ActivityInstrumentationTestCase2;
import com.google.android.exoplayer2.ExoPlayer;
import com.google.android.exoplayer2.decoder.DecoderCounters;
import com.google.android.exoplayer2.extractor.mp4.Mp4Extractor;
import com.google.android.exoplayer2.playbacktests.util.DecoderCountersUtil;
import com.google.android.exoplayer2.playbacktests.util.ExoHostedTest;
import com.google.android.exoplayer2.playbacktests.util.HostActivity;
import com.google.android.exoplayer2.source.ExtractorMediaSource;
import com.google.android.exoplayer2.source.MediaSource;
import com.google.android.exoplayer2.upstream.DataSource;
import com.google.android.exoplayer2.upstream.DefaultDataSourceFactory;
import com.google.android.exoplayer2.upstream.TransferListener;
import com.google.android.exoplayer2.util.ClosedSource;
import com.google.android.exoplayer2.util.Util;
/**
* Tests MP4 playback using {@link ExoPlayer}.
*/
@ClosedSource(reason = "Not yet ready")
public final class Mp4PlaybackTest extends ActivityInstrumentationTestCase2<HostActivity> {
private static final String SOURCE_URL = "http://redirector.c.youtube.com/videoplayback?id=604ed5"
+ "ce52eda7ee&itag=22&source=youtube&sparams=ip,ipbits,expire,source,id&ip=0.0.0.0&ipbits=0&"
+ "expire=19000000000&signature=513F28C7FDCBEC60A66C86C9A393556C99DC47FB.04C88036EEE12565A1ED"
+ "864A875A58F15D8B5300&key=ik0";
private static final String VIDEO_TAG = "Video";
private static final long TEST_TIMEOUT_MS = 15 * 60 * 1000;
private static final float MAX_DROPPED_VIDEO_FRAME_FRACTION = 0.01f;
private static final int EXPECTED_VIDEO_FRAME_COUNT = 14316;
public Mp4PlaybackTest() {
super(HostActivity.class);
}
public void testPlayback() {
if (Util.SDK_INT < 16) {
// Pass.
return;
}
Mp4HostedTest test = new Mp4HostedTest(SOURCE_URL, true);
getActivity().runTest(test, TEST_TIMEOUT_MS);
}
@TargetApi(16)
private static class Mp4HostedTest extends ExoHostedTest {
private final Uri uri;
public Mp4HostedTest(String uriString, boolean fullPlaybackNoSeeking) {
super("Mp4PlaybackTest", fullPlaybackNoSeeking);
uri = Uri.parse(uriString);
}
@Override
public MediaSource buildSource(HostActivity host, String userAgent,
TransferListener<? super DataSource> mediaTransferListener) {
DataSource.Factory dataSourceFactory = new DefaultDataSourceFactory(host, userAgent);
return new ExtractorMediaSource(uri, dataSourceFactory, Mp4Extractor.FACTORY, null, null);
}
@Override
public void assertPassed(DecoderCounters audioCounters, DecoderCounters videoCounters) {
assertEquals(1, videoCounters.decoderInitCount);
assertEquals(1, videoCounters.decoderReleaseCount);
DecoderCountersUtil.assertSkippedOutputBufferCount(VIDEO_TAG, videoCounters, 0);
// We allow one fewer output buffer due to the way that MediaCodecRenderer and the
// underlying decoders handle the end of stream. This should be tightened up in the future.
DecoderCountersUtil.assertTotalOutputBufferCount(VIDEO_TAG, videoCounters,
EXPECTED_VIDEO_FRAME_COUNT - 1, EXPECTED_VIDEO_FRAME_COUNT);
int droppedFrameLimit = (int) Math.ceil(MAX_DROPPED_VIDEO_FRAME_FRACTION
* DecoderCountersUtil.getTotalOutputBuffers(videoCounters));
DecoderCountersUtil.assertDroppedOutputBufferLimit(VIDEO_TAG, videoCounters,
droppedFrameLimit);
}
}
}
/*
* Copyright (C) 2016 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.google.android.exoplayer2.playbacktests.hls;
import android.annotation.TargetApi;
import android.net.Uri;
import android.test.ActivityInstrumentationTestCase2;
import com.google.android.exoplayer2.C;
import com.google.android.exoplayer2.ExoPlayer;
import com.google.android.exoplayer2.playbacktests.util.ExoHostedTest;
import com.google.android.exoplayer2.playbacktests.util.HostActivity;
import com.google.android.exoplayer2.source.MediaSource;
import com.google.android.exoplayer2.source.hls.HlsMediaSource;
import com.google.android.exoplayer2.upstream.DataSource;
import com.google.android.exoplayer2.upstream.DefaultDataSourceFactory;
import com.google.android.exoplayer2.upstream.TransferListener;
import com.google.android.exoplayer2.util.Assertions;
import com.google.android.exoplayer2.util.ClosedSource;
import com.google.android.exoplayer2.util.Util;
import java.io.IOException;
/**
* Tests HLS playbacks using {@link ExoPlayer}.
*/
@ClosedSource(reason = "Streams are internal")
public final class HlsTest extends ActivityInstrumentationTestCase2<HostActivity> {
private static final String TAG = "HlsTest";
private static final String BASE_URL = "https://storage.googleapis.com/"
+ "exoplayer-test-media-internal-63834241aced7884c2544af1a3452e01/hls/bipbop/";
private static final long TIMEOUT_MS = 3 * 60 * 1000;
public HlsTest() {
super(HostActivity.class);
}
/**
* Tests playback for two variants with all segments available.
*/
public void testAllSegmentsAvailable() throws IOException {
testPlaybackForPath("bipbop-all-200.m3u8");
}
/**
* Tests playback for a single variant with all segments available.
*/
public void testSingleGearAllSegmentsAvailable() throws IOException {
testPlaybackForPath("gear1/prog_index.m3u8");
}
/**
* Tests playback for two variants where the first has an unavailable playlist. Playback should
* succeed using the second variant.
*/
public void testGear1PlaylistMissing() throws IOException {
testPlaybackForPath("bipbop-gear1-playlist-404.m3u8");
}
/**
* Tests playback for two variants where the second has an unavailable playlist. Playback should
* succeed using the first variant.
*/
public void testGear2PlaylistMissing() throws IOException {
testPlaybackForPath("bipbop-gear2-playlist-404.m3u8");
}
/**
* Tests playback for two variants where the first has a missing first segment. Playback should
* succeed using the first segment from the second variant.
*/
public void testGear1Seg1Missing() throws IOException {
testPlaybackForPath("bipbop-gear1-seg1-404.m3u8");
}
/**
* Tests playback for two variants where the second has a missing first segment. Playback should
* succeed using the first segment from the first variant.
*/
public void testGear2Seg1Missing() throws IOException {
testPlaybackForPath("bipbop-gear2-seg1-404.m3u8");
}
/**
* Tests playback for two variants where the first has a missing second segment. Playback should
* succeed using the second segment from the second variant.
*/
public void testGear1Seg2Missing() throws IOException {
testPlaybackForPath("bipbop-gear1-seg2-404.m3u8");
}
/**
* Tests playback for two variants where the second has a missing second segment. Playback should
* succeed using the second segment from the first variant.
*/
public void testGear2Seg2Missing() throws IOException {
testPlaybackForPath("bipbop-gear2-seg2-404.m3u8");
}
/**
* Tests playback for two variants where the first has a missing sixth segment. Playback should
* succeed using the sixth segment from the second variant.
*/
public void testGear1Seg6Missing() throws IOException {
testPlaybackForPath("bipbop-gear1-seg6-404.m3u8");
}
/**
* Tests playback for two variants where the second has a missing sixth segment. Playback should
* succeed using the sixth segment from the first variant.
*/
public void testGear2Seg6Missing() throws IOException {
testPlaybackForPath("bipbop-gear2-seg6-404.m3u8");
}
/**
* Tests playback of a single variant with a missing sixth segment. Playback should fail, however
* should not do so until playback reaches the missing segment at 60 seconds.
*/
public void testSingleGearSeg6Missing() throws IOException {
testPlaybackForPath("gear1/prog_index-seg6-404.m3u8", 60000);
}
private void testPlaybackForPath(String path) throws IOException {
testPlaybackForPath(path, C.TIME_UNSET);
}
private void testPlaybackForPath(String path, long expectedFailureTimeMs) throws IOException {
if (Util.SDK_INT < 16) {
// Pass.
return;
}
HlsHostedTest test = new HlsHostedTest(Uri.parse(BASE_URL + path), expectedFailureTimeMs);
getActivity().runTest(test, TIMEOUT_MS);
}
@TargetApi(16)
private static class HlsHostedTest extends ExoHostedTest {
private final Uri playlistUri;
public HlsHostedTest(Uri playlistUri, long expectedFailureTimeMs) {
super(TAG, expectedFailureTimeMs == C.TIME_UNSET
? ExoHostedTest.EXPECTED_PLAYING_TIME_MEDIA_DURATION_MS : expectedFailureTimeMs,
expectedFailureTimeMs == C.TIME_UNSET);
this.playlistUri = Assertions.checkNotNull(playlistUri);
}
@Override
public MediaSource buildSource(HostActivity host, String userAgent,
TransferListener<? super DataSource> mediaTransferListener) {
DataSource.Factory dataSourceFactory = new DefaultDataSourceFactory(host, userAgent,
mediaTransferListener);
return new HlsMediaSource(playlistUri, dataSourceFactory, null, null);
}
}
}
......@@ -14,30 +14,4 @@
limitations under the License.
-->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.google.android.exoplayer2.playbacktests"
android:versionCode="2004"
android:versionName="2.0.4">
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.WAKE_LOCK"/>
<uses-sdk android:minSdkVersion="9" android:targetSdkVersion="24"/>
<application android:debuggable="true"
android:allowBackup="false"
tools:ignore="MissingApplicationIcon,HardcodedDebugMode">
<uses-library android:name="android.test.runner"/>
<activity android:name="com.google.android.exoplayer2.playbacktests.util.HostActivity"
android:configChanges="keyboardHidden|orientation|screenSize"
android:label="ExoPlayerTest"/>
</application>
<instrumentation
android:targetPackage="com.google.android.exoplayer2.playbacktests"
android:name="android.test.InstrumentationTestRunner"/>
</manifest>
<manifest package="com.google.android.exoplayer2.playbacktests"/>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment