Commit f2fd57cd by mishragaurav Committed by Oliver Woodman

Adding dummy device report log.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=110768506
parent 33a2b2d0
...@@ -112,11 +112,12 @@ public abstract class ExoHostedTest implements HostedTest, ExoPlayer.Listener { ...@@ -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 { ...@@ -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() {
......
...@@ -74,12 +74,12 @@ public final class HostActivity extends Activity implements SurfaceHolder.Callba ...@@ -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 ...@@ -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 "
......
/*
* 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());
}
}
}
}
/*
* 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);
}
}
}
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