Adding dummy device report log.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=110768506
This commit is contained in:
mishragaurav 2015-12-22 06:59:47 -08:00 committed by Oliver Woodman
parent 33a2b2d0c5
commit f2fd57cde1
5 changed files with 182 additions and 39 deletions

View File

@ -39,6 +39,7 @@ import com.google.android.exoplayer.playbacktests.util.CodecCountersUtil;
import com.google.android.exoplayer.playbacktests.util.ExoHostedTest; import com.google.android.exoplayer.playbacktests.util.ExoHostedTest;
import com.google.android.exoplayer.playbacktests.util.HostActivity; import com.google.android.exoplayer.playbacktests.util.HostActivity;
import com.google.android.exoplayer.playbacktests.util.LogcatLogger; import com.google.android.exoplayer.playbacktests.util.LogcatLogger;
import com.google.android.exoplayer.playbacktests.util.MetricsLogger;
import com.google.android.exoplayer.playbacktests.util.TestUtil; import com.google.android.exoplayer.playbacktests.util.TestUtil;
import com.google.android.exoplayer.upstream.DataSource; import com.google.android.exoplayer.upstream.DataSource;
import com.google.android.exoplayer.upstream.DefaultAllocator; import com.google.android.exoplayer.upstream.DefaultAllocator;
@ -48,6 +49,7 @@ import com.google.android.exoplayer.util.Util;
import android.annotation.TargetApi; import android.annotation.TargetApi;
import android.media.MediaCodec; import android.media.MediaCodec;
import android.os.Bundle;
import android.os.Handler; import android.os.Handler;
import android.test.ActivityInstrumentationTestCase2; import android.test.ActivityInstrumentationTestCase2;
import android.util.Log; import android.util.Log;
@ -162,7 +164,8 @@ public final class DashTest extends ActivityInstrumentationTestCase2<HostActivit
// Pass. // Pass.
return; return;
} }
testDashPlayback(getActivity(), AAC_AUDIO_FRAME_COUNT, H264_VIDEO_FRAME_COUNT, String testName = "testH264Fixed";
testDashPlayback(getActivity(), testName, AAC_AUDIO_FRAME_COUNT, H264_VIDEO_FRAME_COUNT,
H264_MANIFEST, AAC_AUDIO_REPRESENTATION_ID, false, H264_CDD_FIXED); H264_MANIFEST, AAC_AUDIO_REPRESENTATION_ID, false, H264_CDD_FIXED);
} }
@ -171,7 +174,8 @@ public final class DashTest extends ActivityInstrumentationTestCase2<HostActivit
// Pass. // Pass.
return; return;
} }
testDashPlayback(getActivity(), AAC_AUDIO_FRAME_COUNT, H264_VIDEO_FRAME_COUNT, String testName = "testH264Adaptive";
testDashPlayback(getActivity(), testName, AAC_AUDIO_FRAME_COUNT, H264_VIDEO_FRAME_COUNT,
H264_MANIFEST, AAC_AUDIO_REPRESENTATION_ID, ALLOW_ADDITIONAL_VIDEO_FORMATS, H264_MANIFEST, AAC_AUDIO_REPRESENTATION_ID, ALLOW_ADDITIONAL_VIDEO_FORMATS,
H264_CDD_ADAPTIVE); H264_CDD_ADAPTIVE);
} }
@ -181,7 +185,8 @@ public final class DashTest extends ActivityInstrumentationTestCase2<HostActivit
// Pass. // Pass.
return; return;
} }
testDashPlayback(getActivity(), SEEKING_SCHEDULE, false, AAC_AUDIO_FRAME_COUNT, String testName = "testH264AdaptiveWithSeeking";
testDashPlayback(getActivity(), testName, SEEKING_SCHEDULE, false, AAC_AUDIO_FRAME_COUNT,
H264_VIDEO_FRAME_COUNT, H264_MANIFEST, AAC_AUDIO_REPRESENTATION_ID, H264_VIDEO_FRAME_COUNT, H264_MANIFEST, AAC_AUDIO_REPRESENTATION_ID,
ALLOW_ADDITIONAL_VIDEO_FORMATS, H264_CDD_ADAPTIVE); ALLOW_ADDITIONAL_VIDEO_FORMATS, H264_CDD_ADAPTIVE);
} }
@ -191,8 +196,9 @@ public final class DashTest extends ActivityInstrumentationTestCase2<HostActivit
// Pass. // Pass.
return; return;
} }
testDashPlayback(getActivity(), RENDERER_DISABLING_SCHEDULE, false, AAC_AUDIO_FRAME_COUNT, String testName = "testH264AdaptiveWithRendererDisabling";
H264_VIDEO_FRAME_COUNT, H264_MANIFEST, AAC_AUDIO_REPRESENTATION_ID, testDashPlayback(getActivity(), testName, RENDERER_DISABLING_SCHEDULE, false,
AAC_AUDIO_FRAME_COUNT, H264_VIDEO_FRAME_COUNT, H264_MANIFEST, AAC_AUDIO_REPRESENTATION_ID,
ALLOW_ADDITIONAL_VIDEO_FORMATS, H264_CDD_ADAPTIVE); ALLOW_ADDITIONAL_VIDEO_FORMATS, H264_CDD_ADAPTIVE);
} }
@ -203,8 +209,9 @@ public final class DashTest extends ActivityInstrumentationTestCase2<HostActivit
// Pass. // Pass.
return; return;
} }
testDashPlayback(getActivity(), VORBIS_AUDIO_FRAME_COUNT, VP9_VIDEO_FRAME_COUNT, VP9_MANIFEST, String testName = "testVp9Fixed360p";
VORBIS_AUDIO_REPRESENTATION_ID, false, VP9_CDD_FIXED); testDashPlayback(getActivity(), testName, VORBIS_AUDIO_FRAME_COUNT, VP9_VIDEO_FRAME_COUNT,
VP9_MANIFEST, VORBIS_AUDIO_REPRESENTATION_ID, false, VP9_CDD_FIXED);
} }
public void testVp9Adaptive() throws IOException { public void testVp9Adaptive() throws IOException {
@ -212,8 +219,10 @@ public final class DashTest extends ActivityInstrumentationTestCase2<HostActivit
// Pass. // Pass.
return; return;
} }
testDashPlayback(getActivity(), VORBIS_AUDIO_FRAME_COUNT, VP9_VIDEO_FRAME_COUNT, VP9_MANIFEST, String testName = "testVp9Adaptive";
VORBIS_AUDIO_REPRESENTATION_ID, ALLOW_ADDITIONAL_VIDEO_FORMATS, VP9_CDD_ADAPTIVE); testDashPlayback(getActivity(), testName, VORBIS_AUDIO_FRAME_COUNT, VP9_VIDEO_FRAME_COUNT,
VP9_MANIFEST, VORBIS_AUDIO_REPRESENTATION_ID, ALLOW_ADDITIONAL_VIDEO_FORMATS,
VP9_CDD_ADAPTIVE);
} }
public void testVp9AdaptiveWithSeeking() throws IOException { public void testVp9AdaptiveWithSeeking() throws IOException {
@ -221,7 +230,8 @@ public final class DashTest extends ActivityInstrumentationTestCase2<HostActivit
// Pass. // Pass.
return; return;
} }
testDashPlayback(getActivity(), SEEKING_SCHEDULE, false, VORBIS_AUDIO_FRAME_COUNT, String testName = "testVp9AdaptiveWithSeeking";
testDashPlayback(getActivity(), testName, SEEKING_SCHEDULE, false, VORBIS_AUDIO_FRAME_COUNT,
VP9_VIDEO_FRAME_COUNT, VP9_MANIFEST, VORBIS_AUDIO_REPRESENTATION_ID, VP9_VIDEO_FRAME_COUNT, VP9_MANIFEST, VORBIS_AUDIO_REPRESENTATION_ID,
ALLOW_ADDITIONAL_VIDEO_FORMATS, VP9_CDD_ADAPTIVE); ALLOW_ADDITIONAL_VIDEO_FORMATS, VP9_CDD_ADAPTIVE);
} }
@ -231,28 +241,32 @@ public final class DashTest extends ActivityInstrumentationTestCase2<HostActivit
// Pass. // Pass.
return; return;
} }
testDashPlayback(getActivity(), RENDERER_DISABLING_SCHEDULE, false, VORBIS_AUDIO_FRAME_COUNT, String testName = "testVp9AdaptiveWithRendererDisabling";
VP9_VIDEO_FRAME_COUNT, VP9_MANIFEST, VORBIS_AUDIO_REPRESENTATION_ID, testDashPlayback(getActivity(), testName, RENDERER_DISABLING_SCHEDULE, false,
ALLOW_ADDITIONAL_VIDEO_FORMATS, VP9_CDD_ADAPTIVE); VORBIS_AUDIO_FRAME_COUNT, VP9_VIDEO_FRAME_COUNT, VP9_MANIFEST,
VORBIS_AUDIO_REPRESENTATION_ID, ALLOW_ADDITIONAL_VIDEO_FORMATS, VP9_CDD_ADAPTIVE);
} }
// Internal. // Internal.
private static void testDashPlayback(HostActivity activity, int sourceAudioFrameCount, private void testDashPlayback(HostActivity activity, String testName,
int sourceVideoFrameCount, String manifestFileName, String audioFormat, int sourceAudioFrameCount, int sourceVideoFrameCount, String manifestFileName,
boolean includeAdditionalVideoFormats, String... videoFormats) throws IOException { String audioFormat, boolean includeAdditionalVideoFormats, String... videoFormats)
testDashPlayback(activity, null, true, sourceAudioFrameCount, sourceVideoFrameCount, throws IOException {
manifestFileName, audioFormat, includeAdditionalVideoFormats, videoFormats); testDashPlayback(activity, testName, null, true, sourceAudioFrameCount,
sourceVideoFrameCount, manifestFileName, audioFormat, includeAdditionalVideoFormats,
videoFormats);
} }
private static void testDashPlayback(HostActivity activity, ActionSchedule actionSchedule, private void testDashPlayback(HostActivity activity, String testName,
boolean fullPlaybackNoSeeking, int sourceAudioFrameCount, int sourceVideoFrameCount, ActionSchedule actionSchedule, boolean fullPlaybackNoSeeking, int sourceAudioFrameCount,
String manifestFileName, String audioFormat, boolean includeAdditionalVideoFormats, int sourceVideoFrameCount, String manifestFileName, String audioFormat,
String... videoFormats) throws IOException { boolean includeAdditionalVideoFormats, String... videoFormats) throws IOException {
MediaPresentationDescription mpd = TestUtil.loadManifest(activity, MediaPresentationDescription mpd = TestUtil.loadManifest(activity,
MANIFEST_URL_PREFIX + manifestFileName, new MediaPresentationDescriptionParser()); MANIFEST_URL_PREFIX + manifestFileName, new MediaPresentationDescriptionParser());
DashHostedTest test = new DashHostedTest(mpd, fullPlaybackNoSeeking, sourceAudioFrameCount, MetricsLogger metricsLogger = MetricsLogger.Factory.createDefault(getInstrumentation(), TAG);
sourceVideoFrameCount, audioFormat, includeAdditionalVideoFormats, DashHostedTest test = new DashHostedTest(testName, mpd, metricsLogger, fullPlaybackNoSeeking,
sourceAudioFrameCount, sourceVideoFrameCount, audioFormat, includeAdditionalVideoFormats,
videoFormats); videoFormats);
if (actionSchedule != null) { if (actionSchedule != null) {
test.setSchedule(actionSchedule); test.setSchedule(actionSchedule);
@ -276,19 +290,23 @@ public final class DashTest extends ActivityInstrumentationTestCase2<HostActivit
private static final int VIDEO_EVENT_ID = 0; private static final int VIDEO_EVENT_ID = 0;
private static final int AUDIO_EVENT_ID = 1; private static final int AUDIO_EVENT_ID = 1;
private final String testName;
private final MediaPresentationDescription mpd; private final MediaPresentationDescription mpd;
private final MetricsLogger metricsLogger;
private final boolean fullPlaybackNoSeeking; private final boolean fullPlaybackNoSeeking;
private final int sourceAudioFrameCount; private final int sourceAudioFrameCount;
private final int sourceVideoFrameCount; private final int sourceVideoFrameCount;
private String[] audioFormats; private final boolean includeAdditionalVideoFormats;
private boolean includeAdditionalVideoFormats; private final String[] audioFormats;
private String[] videoFormats; private final String[] videoFormats;
private CodecCounters videoCounters; private CodecCounters videoCounters;
private CodecCounters audioCounters; private CodecCounters audioCounters;
/** /**
* @param testName The name of the test.
* @param mpd The manifest. * @param mpd The manifest.
* @param metricsLogger Logger to log metrics from the test.
* @param fullPlaybackNoSeeking True if the test will play the entire source with no seeking. * @param fullPlaybackNoSeeking True if the test will play the entire source with no seeking.
* False otherwise. * False otherwise.
* @param sourceAudioFrameCount The number of audio frames in the source. * @param sourceAudioFrameCount The number of audio frames in the source.
@ -298,11 +316,14 @@ public final class DashTest extends ActivityInstrumentationTestCase2<HostActivit
* those listed in the videoFormats argument, if the device is capable of playing them. * those listed in the videoFormats argument, if the device is capable of playing them.
* @param videoFormats The video formats. * @param videoFormats The video formats.
*/ */
public DashHostedTest(MediaPresentationDescription mpd, boolean fullPlaybackNoSeeking, public DashHostedTest(String testName, MediaPresentationDescription mpd,
int sourceAudioFrameCount, int sourceVideoFrameCount, String audioFormat, MetricsLogger metricsLogger, boolean fullPlaybackNoSeeking, int sourceAudioFrameCount,
boolean includeAdditionalVideoFormats, String... videoFormats) { int sourceVideoFrameCount, String audioFormat, boolean includeAdditionalVideoFormats,
String... videoFormats) {
super(RENDERER_COUNT); super(RENDERER_COUNT);
this.testName = testName;
this.mpd = Assertions.checkNotNull(mpd); this.mpd = Assertions.checkNotNull(mpd);
this.metricsLogger = metricsLogger;
this.fullPlaybackNoSeeking = fullPlaybackNoSeeking; this.fullPlaybackNoSeeking = fullPlaybackNoSeeking;
this.sourceAudioFrameCount = sourceAudioFrameCount; this.sourceAudioFrameCount = sourceAudioFrameCount;
this.sourceVideoFrameCount = sourceVideoFrameCount; this.sourceVideoFrameCount = sourceVideoFrameCount;
@ -353,7 +374,7 @@ public final class DashTest extends ActivityInstrumentationTestCase2<HostActivit
} }
@Override @Override
protected void assertPassedInternal() { protected void assertPassed() {
if (fullPlaybackNoSeeking) { if (fullPlaybackNoSeeking) {
// Audio is not adaptive and we didn't seek (which can re-instantiate the audio decoder // Audio is not adaptive and we didn't seek (which can re-instantiate the audio decoder
// in ExoPlayer), so the decoder output format should have changed exactly once. The output // in ExoPlayer), so the decoder output format should have changed exactly once. The output
@ -399,6 +420,24 @@ public final class DashTest extends ActivityInstrumentationTestCase2<HostActivit
MAX_CONSECUTIVE_DROPPED_VIDEO_FRAMES); MAX_CONSECUTIVE_DROPPED_VIDEO_FRAMES);
} }
@Override
protected void logMetrics() {
// Create Bundle of metrics from the test.
Bundle metrics = new Bundle();
metrics.putString(MetricsLogger.KEY_TEST_NAME, testName);
metrics.putInt(MetricsLogger.KEY_FRAMES_DROPPED_COUNT,
videoCounters.droppedOutputBufferCount);
metrics.putInt(MetricsLogger.KEY_MAX_CONSECUTIVE_FRAMES_DROPPED_COUNT,
videoCounters.maxConsecutiveDroppedOutputBufferCount);
metrics.putInt(MetricsLogger.KEY_FRAMES_SKIPPED_COUNT,
videoCounters.skippedOutputBufferCount);
metrics.putInt(MetricsLogger.KEY_FRAMES_RENDERED_COUNT,
videoCounters.renderedOutputBufferCount);
// Send metrics for logging.
metricsLogger.logMetrics(metrics);
}
private static final class TrackSelector implements DashTrackSelector { private static final class TrackSelector implements DashTrackSelector {
private final int adaptationSetType; private final int adaptationSetType;

View File

@ -112,11 +112,12 @@ public abstract class ExoHostedTest implements HostedTest, ExoPlayer.Listener {
} }
@Override @Override
public final void assertPassed() { public final void onFinished() {
if (failOnPlayerError && playerError != null) { if (failOnPlayerError && playerError != null) {
throw new Error(playerError); throw new Error(playerError);
} }
assertPassedInternal(); logMetrics();
assertPassed();
} }
// ExoPlayer.Listener // ExoPlayer.Listener
@ -160,10 +161,14 @@ public abstract class ExoHostedTest implements HostedTest, ExoPlayer.Listener {
// Do nothing. Interested subclasses may override. // Do nothing. Interested subclasses may override.
} }
protected void assertPassedInternal() { protected void assertPassed() {
// Do nothing. Subclasses may override to add additional assertions. // Do nothing. Subclasses may override to add additional assertions.
} }
protected void logMetrics() {
// Do nothing. Subclasses may override to log metrics.
}
// Utility methods and actions for subclasses. // Utility methods and actions for subclasses.
protected final long getTotalPlayingTimeMs() { protected final long getTotalPlayingTimeMs() {

View File

@ -74,12 +74,12 @@ public final class HostActivity extends Activity implements SurfaceHolder.Callba
boolean isFinished(); boolean isFinished();
/** /**
* Asserts that the test passed. * Called after the test is finished and has been released. Implementations may use this method
* to assert that test criteria were met.
* <p> * <p>
* Called on the test thread once the test has reported that it's finished and after the test * Called on the test thread.
* has been released.
*/ */
void assertPassed(); void onFinished();
} }
@ -120,7 +120,7 @@ public final class HostActivity extends Activity implements SurfaceHolder.Callba
if (hostedTestReleasedCondition.block(timeoutMs)) { if (hostedTestReleasedCondition.block(timeoutMs)) {
if (hostedTestFinished) { if (hostedTestFinished) {
Log.d(TAG, "Test finished. Checking pass conditions."); Log.d(TAG, "Test finished. Checking pass conditions.");
hostedTest.assertPassed(); hostedTest.onFinished();
Log.d(TAG, "Pass conditions checked."); Log.d(TAG, "Pass conditions checked.");
} else { } else {
Log.e(TAG, "Test released before it finished. Activity may have been paused whilst test " Log.e(TAG, "Test released before it finished. Activity may have been paused whilst test "

View File

@ -0,0 +1,41 @@
/*
* Copyright (C) 2014 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.exoplayer.playbacktests.util;
import android.os.Bundle;
import android.util.Log;
/**
* Implementation of {@link MetricsLogger} that prints the metrics to logcat.
*/
public final class LogcatMetricsLogger implements MetricsLogger {
private final String tag;
public LogcatMetricsLogger(String tag) {
this.tag = tag;
}
@Override
public void logMetrics(Bundle metrics) {
if (metrics != null) {
for (String key : metrics.keySet()) {
Log.v(tag, key + ": " + metrics.get(key).toString());
}
}
}
}

View File

@ -0,0 +1,58 @@
/*
* Copyright (C) 2014 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.exoplayer.playbacktests.util;
import android.app.Instrumentation;
import android.os.Bundle;
/**
* Metric Logging interface for ExoPlayer playback tests.
*/
public interface MetricsLogger {
String KEY_FRAMES_DROPPED_COUNT = "Frames Dropped (Count)";
String KEY_FRAMES_RENDERED_COUNT = "Frames Rendered (Count)";
String KEY_FRAMES_SKIPPED_COUNT = "Frames Skipped (Count)";
String KEY_MAX_CONSECUTIVE_FRAMES_DROPPED_COUNT =
"Maximum Consecutive Frames Skipped";
String KEY_TEST_NAME = "Test Name";
/**
* Logs the metrics provided from a test.
*
* @param metrics The {@link Bundle} of metrics to be logged.
*/
void logMetrics(Bundle metrics);
/**
* A factory for instantiating MetricsLogger instances.
*/
final class Factory {
private Factory() {}
/**
* Obtains a new instance of MetricsLogger.
*
* @param instrumentation The test instrumentation.
* @param tag The tag to be used for logcat logs.
*/
public static MetricsLogger createDefault(Instrumentation instrumentation, String tag) {
return new LogcatMetricsLogger(tag);
}
}
}