aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorEric Rowe <erowe@google.com>2017-03-20 17:12:33 -0700
committerEric Rowe <erowe@google.com>2017-03-20 20:01:07 -0700
commita7e57e416667909ee81ab28b6b406364e8d812e4 (patch)
tree25201b30bb018603d4730a3dccbd75eee7fa11c7 /src
parentf2fa419c69a2c36440e73c1ef2e51b7d9c783201 (diff)
downloadcontrib-a7e57e416667909ee81ab28b6b406364e8d812e4.tar.gz
Use less SnapshotInputStreamSource
Replace `new SnapshotInputStreamSource(new FileInputStream(s))` with `new FileInputStream(s)`. Replace `new SnapshotInputStreamSource(new ByteArrayInputStream(s))` with `new ByteArrayInputStreamSource(s)` Bug: 36397380 Test: Build and run TF unit tests. Change-Id: If9ac9908539f6d1b1ede26fd2b0e759a2f92e845
Diffstat (limited to 'src')
-rw-r--r--src/com/android/media/tests/AudioLoopbackTest.java61
-rw-r--r--src/com/android/media/tests/Camera2StressTest.java16
-rw-r--r--src/com/android/media/tests/CameraLatencyTest.java16
-rw-r--r--src/com/android/media/tests/CameraStressTest.java20
-rw-r--r--src/com/android/media/tests/CameraTestBase.java30
-rw-r--r--src/com/android/media/tests/MediaMemoryTest.java19
-rw-r--r--src/com/android/media/tests/MediaPlayerStressTest.java10
-rw-r--r--src/com/android/media/tests/MediaStressTest.java11
-rw-r--r--src/com/android/media/tests/VideoEditingMemoryTest.java49
-rw-r--r--src/com/android/media/tests/VideoEditingPerformanceTest.java11
-rw-r--r--src/com/android/media/tests/VideoMultimeterTest.java15
11 files changed, 124 insertions, 134 deletions
diff --git a/src/com/android/media/tests/AudioLoopbackTest.java b/src/com/android/media/tests/AudioLoopbackTest.java
index 1e4859b..ce737fd 100644
--- a/src/com/android/media/tests/AudioLoopbackTest.java
+++ b/src/com/android/media/tests/AudioLoopbackTest.java
@@ -22,16 +22,15 @@ import com.android.tradefed.config.Option;
import com.android.tradefed.device.DeviceNotAvailableException;
import com.android.tradefed.device.ITestDevice;
import com.android.tradefed.log.LogUtil.CLog;
+import com.android.tradefed.result.FileInputStreamSource;
import com.android.tradefed.result.ITestInvocationListener;
import com.android.tradefed.result.LogDataType;
-import com.android.tradefed.result.SnapshotInputStreamSource;
import com.android.tradefed.testtype.IDeviceTest;
import com.android.tradefed.testtype.IRemoteTest;
import com.android.tradefed.util.RunUtil;
import java.io.BufferedReader;
import java.io.File;
-import java.io.FileInputStream;
import java.io.FileReader;
import java.io.IOException;
import java.util.Collections;
@@ -102,7 +101,7 @@ public class AudioLoopbackTest implements IDeviceTest, IRemoteTest {
+ " --ei AudioLevel %s --ei TestType %s --ei BufferTestDuration %s";
private static Map<String, String> createMetricsKeyMap() {
- Map<String, String> result = new HashMap<String, String>();
+ Map<String, String> result = new HashMap<>();
result.put("LatencyMs", "latency_ms");
result.put("LatencyConfidence", "latency_confidence");
result.put("Recorder Benchmark", "recorder_benchmark");
@@ -146,7 +145,7 @@ public class AudioLoopbackTest implements IDeviceTest, IRemoteTest {
listener.testStarted(testId);
long testStartTime = System.currentTimeMillis();
- Map<String, String> metrics = new HashMap<String, String>();
+ Map<String, String> metrics = new HashMap<>();
// start measurement and wait for result file
CollectingOutputReceiver receiver = new CollectingOutputReceiver();
@@ -188,36 +187,48 @@ public class AudioLoopbackTest implements IDeviceTest, IRemoteTest {
return;
}
metrics = loopbackResult;
- listener.testLog(mKeyPrefix + "result", LogDataType.TEXT,
- new SnapshotInputStreamSource(new FileInputStream(loopbackReport)));
+ listener.testLog(
+ mKeyPrefix + "result",
+ LogDataType.TEXT,
+ new FileInputStreamSource(loopbackReport));
File loopbackGraphFile = device.pullFile(OUTPUT_PNG_PATH);
- listener.testLog(mKeyPrefix + "graph", LogDataType.PNG,
- new SnapshotInputStreamSource(new FileInputStream(loopbackGraphFile)));
+ listener.testLog(
+ mKeyPrefix + "graph",
+ LogDataType.PNG,
+ new FileInputStreamSource(loopbackGraphFile));
File loopbackWaveFile = device.pullFile(OUTPUT_WAV_PATH);
- listener.testLog(mKeyPrefix + "wave", LogDataType.UNKNOWN,
- new SnapshotInputStreamSource(new FileInputStream(loopbackWaveFile)));
+ listener.testLog(
+ mKeyPrefix + "wave",
+ LogDataType.UNKNOWN,
+ new FileInputStreamSource(loopbackWaveFile));
if (mTestType.equals(TESTTYPE_BUFFER)) {
File loopbackPlayerBuffer = device.pullFile(OUTPUT_PLAYER_BUFFER_PATH);
- listener.testLog(mKeyPrefix + "player_buffer", LogDataType.TEXT,
- new SnapshotInputStreamSource(
- new FileInputStream(loopbackPlayerBuffer)));
+ listener.testLog(
+ mKeyPrefix + "player_buffer",
+ LogDataType.TEXT,
+ new FileInputStreamSource(loopbackPlayerBuffer));
File loopbackPlayerBufferPng = device.pullFile(OUTPUT_PLAYER_BUFFER_PNG_PATH);
- listener.testLog(mKeyPrefix + "player_buffer_histogram", LogDataType.PNG,
- new SnapshotInputStreamSource(new FileInputStream(loopbackPlayerBufferPng)));
+ listener.testLog(
+ mKeyPrefix + "player_buffer_histogram",
+ LogDataType.PNG,
+ new FileInputStreamSource(loopbackPlayerBufferPng));
File loopbackRecorderBuffer = device.pullFile(OUTPUT_RECORDER_BUFFER_PATH);
- listener.testLog(mKeyPrefix + "recorder_buffer", LogDataType.TEXT,
- new SnapshotInputStreamSource(new FileInputStream(
- loopbackRecorderBuffer)));
+ listener.testLog(
+ mKeyPrefix + "recorder_buffer",
+ LogDataType.TEXT,
+ new FileInputStreamSource(loopbackRecorderBuffer));
File loopbackRecorderBufferPng = device.pullFile(OUTPUT_RECORDER_BUFFER_PNG_PATH);
- listener.testLog(mKeyPrefix + "recorder_buffer_histogram", LogDataType.PNG,
- new SnapshotInputStreamSource(new FileInputStream(
- loopbackRecorderBufferPng)));
+ listener.testLog(
+ mKeyPrefix + "recorder_buffer_histogram",
+ LogDataType.PNG,
+ new FileInputStreamSource(loopbackRecorderBufferPng));
File loopbackGlitch = device.pullFile(OUTPUT_GLITCH_PATH);
- listener.testLog(mKeyPrefix + "glitches_millis", LogDataType.TEXT,
- new SnapshotInputStreamSource(new FileInputStream(
- loopbackGlitch)));
+ listener.testLog(
+ mKeyPrefix + "glitches_millis",
+ LogDataType.TEXT,
+ new FileInputStreamSource(loopbackGlitch));
}
} catch (IOException ioe) {
CLog.e(ioe.getMessage());
@@ -254,7 +265,7 @@ public class AudioLoopbackTest implements IDeviceTest, IRemoteTest {
* @throws IOException
*/
private Map<String, String> parseResult(File result) throws IOException {
- Map<String, String> resultMap = new HashMap<String, String>();
+ Map<String, String> resultMap = new HashMap<>();
BufferedReader br = new BufferedReader(new FileReader(result));
try {
String line = br.readLine();
diff --git a/src/com/android/media/tests/Camera2StressTest.java b/src/com/android/media/tests/Camera2StressTest.java
index fec5b02..3c3e539 100644
--- a/src/com/android/media/tests/Camera2StressTest.java
+++ b/src/com/android/media/tests/Camera2StressTest.java
@@ -21,14 +21,13 @@ import com.android.tradefed.config.OptionClass;
import com.android.tradefed.device.DeviceNotAvailableException;
import com.android.tradefed.device.IFileEntry;
import com.android.tradefed.log.LogUtil.CLog;
+import com.android.tradefed.result.FileInputStreamSource;
import com.android.tradefed.result.ITestInvocationListener;
import com.android.tradefed.result.LogDataType;
-import com.android.tradefed.result.SnapshotInputStreamSource;
import com.android.tradefed.util.FileUtil;
import java.io.BufferedReader;
import java.io.File;
-import java.io.FileInputStream;
import java.io.FileReader;
import java.io.IOException;
import java.util.HashMap;
@@ -102,10 +101,11 @@ public class Camera2StressTest extends CameraTestBase {
}
private void postScreenshotOnFailure(TestIdentifier test) {
+ File tmpDir = null;
try {
IFileEntry screenshotDir = getDevice().getFileEntry(FAILURE_SCREENSHOT_DIR);
if (screenshotDir != null && screenshotDir.isDirectory()) {
- File tmpDir = FileUtil.createTempDir("screenshot");
+ tmpDir = FileUtil.createTempDir("screenshot");
for (IFileEntry remoteFile : screenshotDir.getChildren(false)) {
if (remoteFile.isDirectory()) {
continue;
@@ -120,14 +120,18 @@ public class Camera2StressTest extends CameraTestBase {
CLog.w("Could not pull screenshot: %s", remoteFile.getFullPath());
continue;
}
- testLog("screenshot_" + screenshot.getName(), LogDataType.PNG,
- new SnapshotInputStreamSource(new FileInputStream(screenshot)));
+ testLog(
+ "screenshot_" + screenshot.getName(),
+ LogDataType.PNG,
+ new FileInputStreamSource(screenshot));
}
}
} catch (DeviceNotAvailableException e) {
CLog.e(e);
} catch (IOException e) {
CLog.e(e);
+ } finally {
+ FileUtil.recursiveDelete(tmpDir);
}
}
@@ -142,7 +146,7 @@ public class Camera2StressTest extends CameraTestBase {
}
BufferedReader reader = new BufferedReader(new FileReader(outputFile));
String line;
- Map<String, String> resultMap = new HashMap<String, String>();
+ Map<String, String> resultMap = new HashMap<>();
// Parse results from log file that contain the key-value pairs.
// eg. "numAttempts=10|iteration=9"
diff --git a/src/com/android/media/tests/CameraLatencyTest.java b/src/com/android/media/tests/CameraLatencyTest.java
index 56f003b..f44fd59 100644
--- a/src/com/android/media/tests/CameraLatencyTest.java
+++ b/src/com/android/media/tests/CameraLatencyTest.java
@@ -24,10 +24,10 @@ import com.android.tradefed.device.DeviceNotAvailableException;
import com.android.tradefed.device.ITestDevice;
import com.android.tradefed.log.LogUtil.CLog;
import com.android.tradefed.result.CollectingTestListener;
+import com.android.tradefed.result.FileInputStreamSource;
import com.android.tradefed.result.ITestInvocationListener;
import com.android.tradefed.result.InputStreamSource;
import com.android.tradefed.result.LogDataType;
-import com.android.tradefed.result.SnapshotInputStreamSource;
import com.android.tradefed.testtype.IDeviceTest;
import com.android.tradefed.testtype.IRemoteTest;
import com.android.tradefed.util.FileUtil;
@@ -70,10 +70,10 @@ public class CameraLatencyTest implements IDeviceTest, IRemoteTest {
/**
* Stores the test cases that we should consider running.
- * <p/>
- * This currently consists of "startup" and "latency"
+ *
+ * <p>This currently consists of "startup" and "latency"
*/
- private List<TestInfo> mTestCases = new ArrayList<TestInfo>();
+ private List<TestInfo> mTestCases = new ArrayList<>();
// Options for the running the gCam test
@Option(name = "gCam", description = "Run gCam startup test")
@@ -87,7 +87,7 @@ public class CameraLatencyTest implements IDeviceTest, IRemoteTest {
public String mTestName = null;
public String mClassName = null;
public String mTestMetricsName = null;
- public RegexTrie<String> mPatternMap = new RegexTrie<String>();
+ public RegexTrie<String> mPatternMap = new RegexTrie<>();
@Override
public String toString() {
@@ -207,7 +207,7 @@ public class CameraLatencyTest implements IDeviceTest, IRemoteTest {
// Upload a verbatim copy of the output file
CLog.d("Sending %d byte file %s into the logosphere!", outputFile.length(), outputFile);
- outputSource = new SnapshotInputStreamSource(new FileInputStream(outputFile));
+ outputSource = new FileInputStreamSource(outputFile);
listener.testLog(String.format("output-%s.txt", test.mTestName), LogDataType.TEXT,
outputSource);
@@ -227,7 +227,7 @@ public class CameraLatencyTest implements IDeviceTest, IRemoteTest {
*/
private void parseOutputFile(TestInfo test, InputStream dataStream,
ITestInvocationListener listener) {
- Map<String, String> runMetrics = new HashMap<String, String>();
+ Map<String, String> runMetrics = new HashMap<>();
// try to parse it
String contents;
@@ -244,7 +244,7 @@ public class CameraLatencyTest implements IDeviceTest, IRemoteTest {
String line;
while (lineIter.hasNext()) {
line = lineIter.next();
- List<List<String>> capture = new ArrayList<List<String>>(1);
+ List<List<String>> capture = new ArrayList<>(1);
String key = test.mPatternMap.retrieve(capture, line);
if (key != null) {
CLog.d("Got %s key '%s' and captures '%s'", test.mTestName, key,
diff --git a/src/com/android/media/tests/CameraStressTest.java b/src/com/android/media/tests/CameraStressTest.java
index ca92544..def3f39 100644
--- a/src/com/android/media/tests/CameraStressTest.java
+++ b/src/com/android/media/tests/CameraStressTest.java
@@ -24,10 +24,10 @@ import com.android.tradefed.config.Option;
import com.android.tradefed.device.DeviceNotAvailableException;
import com.android.tradefed.device.ITestDevice;
import com.android.tradefed.result.CollectingTestListener;
+import com.android.tradefed.result.FileInputStreamSource;
import com.android.tradefed.result.ITestInvocationListener;
import com.android.tradefed.result.InputStreamSource;
import com.android.tradefed.result.LogDataType;
-import com.android.tradefed.result.SnapshotInputStreamSource;
import com.android.tradefed.testtype.IDeviceTest;
import com.android.tradefed.testtype.IRemoteTest;
import com.android.tradefed.util.FileUtil;
@@ -74,10 +74,10 @@ public class CameraStressTest implements IDeviceTest, IRemoteTest {
/**
* Stores the test cases that we should consider running.
- * <p/>
- * This currently consists of "startup" and "latency"
+ *
+ * <p>This currently consists of "startup" and "latency"
*/
- private List<TestInfo> mTestCases = new ArrayList<TestInfo>();
+ private List<TestInfo> mTestCases = new ArrayList<>();
// Options for the running the gCam test
@Option(name = "gCam", description = "Run gCam back image capture test")
@@ -90,8 +90,8 @@ public class CameraStressTest implements IDeviceTest, IRemoteTest {
public String mTestName = null;
public String mClassName = null;
public String mTestMetricsName = null;
- public Map<String, String> mInstrumentationArgs = new HashMap<String, String>();
- public RegexTrie<String> mPatternMap = new RegexTrie<String>();
+ public Map<String, String> mInstrumentationArgs = new HashMap<>();
+ public RegexTrie<String> mPatternMap = new RegexTrie<>();
@Override
public String toString() {
@@ -106,7 +106,7 @@ public class CameraStressTest implements IDeviceTest, IRemoteTest {
* Exposed for unit meta-testing
*/
static RegexTrie<String> getPatternMap() {
- RegexTrie<String> patMap = new RegexTrie<String>();
+ RegexTrie<String> patMap = new RegexTrie<>();
patMap.put("SwitchPreview", "^Camera Switch Mode:");
// For versions of the on-device test that don't differentiate between front and back camera
@@ -243,7 +243,7 @@ public class CameraStressTest implements IDeviceTest, IRemoteTest {
// Upload a verbatim copy of the output file
Log.d(LOG_TAG, String.format("Sending %d byte file %s into the logosphere!",
outputFile.length(), outputFile));
- outputSource = new SnapshotInputStreamSource(new FileInputStream(outputFile));
+ outputSource = new FileInputStreamSource(outputFile);
listener.testLog(String.format("output-%s.txt", test.mTestName), LogDataType.TEXT,
outputSource);
@@ -262,7 +262,7 @@ public class CameraStressTest implements IDeviceTest, IRemoteTest {
*/
private void parseOutputFile(TestInfo test, InputStream dataStream,
ITestInvocationListener listener) {
- Map<String, String> runMetrics = new HashMap<String, String>();
+ Map<String, String> runMetrics = new HashMap<>();
String contents;
try {
@@ -282,7 +282,7 @@ public class CameraStressTest implements IDeviceTest, IRemoteTest {
String line;
while (lineIter.hasNext()) {
line = lineIter.next();
- List<List<String>> capture = new ArrayList<List<String>>(1);
+ List<List<String>> capture = new ArrayList<>(1);
String pattern = test.mPatternMap.retrieve(capture, line);
if (pattern != null) {
if ("loopCount".equals(pattern)) {
diff --git a/src/com/android/media/tests/CameraTestBase.java b/src/com/android/media/tests/CameraTestBase.java
index f8928b7..94fe3ce 100644
--- a/src/com/android/media/tests/CameraTestBase.java
+++ b/src/com/android/media/tests/CameraTestBase.java
@@ -26,10 +26,10 @@ import com.android.tradefed.device.ITestDevice;
import com.android.tradefed.log.LogUtil.CLog;
import com.android.tradefed.result.ByteArrayInputStreamSource;
import com.android.tradefed.result.CollectingTestListener;
+import com.android.tradefed.result.FileInputStreamSource;
import com.android.tradefed.result.ITestInvocationListener;
import com.android.tradefed.result.InputStreamSource;
import com.android.tradefed.result.LogDataType;
-import com.android.tradefed.result.SnapshotInputStreamSource;
import com.android.tradefed.testtype.IDeviceTest;
import com.android.tradefed.testtype.IRemoteTest;
import com.android.tradefed.testtype.InstrumentationTest;
@@ -43,8 +43,6 @@ import org.junit.Assert;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
import java.io.FileWriter;
import java.io.IOException;
import java.io.StringReader;
@@ -79,7 +77,7 @@ public class CameraTestBase implements IDeviceTest, IRemoteTest, IConfigurationR
private String mTestClass = null;
@Option(name = "test-methods", description = "Test method to run. May be repeated.")
- private Collection<String> mTestMethods = new ArrayList<String>();
+ private Collection<String> mTestMethods = new ArrayList<>();
@Option(name = "test-runner", description = "Test runner for test instrumentation.")
private String mTestRunner = "android.test.InstrumentationTestRunner";
@@ -101,9 +99,11 @@ public class CameraTestBase implements IDeviceTest, IRemoteTest, IConfigurationR
"take a logcat snapshot on every test failure.")
private boolean mLogcatOnFailure = false;
- @Option(name = "instrumentation-arg",
- description = "Additional instrumentation arguments to provide.")
- private Map<String, String> mInstrArgMap = new HashMap<String, String>();
+ @Option(
+ name = "instrumentation-arg",
+ description = "Additional instrumentation arguments to provide."
+ )
+ private Map<String, String> mInstrArgMap = new HashMap<>();
@Option(name = "dump-meminfo", description =
"take a dumpsys meminfo at a given interval time.")
@@ -233,8 +233,8 @@ public class CameraTestBase implements IDeviceTest, IRemoteTest, IConfigurationR
protected abstract class AbstractCollectingListener extends CollectingTestListener {
private ITestInvocationListener mListener = null;
- private Map<String, String> mMetrics = new HashMap<String, String>();
- private Map<String, String> mFatalErrors = new HashMap<String, String>();
+ private Map<String, String> mMetrics = new HashMap<>();
+ private Map<String, String> mFatalErrors = new HashMap<>();
private static final String INCOMPLETE_TEST_ERR_MSG_PREFIX =
"Test failed to run to completion. Reason: 'Instrumentation run failed";
@@ -356,13 +356,9 @@ public class CameraTestBase implements IDeviceTest, IRemoteTest, IConfigurationR
// Grab a snapshot of meminfo file and post it to dashboard.
try {
outputFile = mMeminfoTimer.getOutputFile();
- outputSource = new SnapshotInputStreamSource(new FileInputStream(outputFile));
+ outputSource = new FileInputStreamSource(outputFile, true /* delete */);
String logName = String.format("meminfo_%s", test.getTestName());
mListener.testLog(logName, LogDataType.TEXT, outputSource);
- outputFile.delete();
- } catch (FileNotFoundException e) {
- CLog.e("Failed to read meminfo log %s:", outputFile);
- CLog.e(e);
} finally {
StreamUtil.cancel(outputSource);
}
@@ -371,13 +367,9 @@ public class CameraTestBase implements IDeviceTest, IRemoteTest, IConfigurationR
mThreadTrackerTimer.stop();
try {
outputFile = mThreadTrackerTimer.getOutputFile();
- outputSource = new SnapshotInputStreamSource(new FileInputStream(outputFile));
+ outputSource = new FileInputStreamSource(outputFile, true /* delete */);
String logName = String.format("ps_%s", test.getTestName());
mListener.testLog(logName, LogDataType.TEXT, outputSource);
- outputFile.delete();
- } catch (FileNotFoundException e) {
- CLog.e("Failed to read thread count log %s", outputFile);
- CLog.e(e);
} finally {
StreamUtil.cancel(outputSource);
}
diff --git a/src/com/android/media/tests/MediaMemoryTest.java b/src/com/android/media/tests/MediaMemoryTest.java
index fcc615e..bb09488 100644
--- a/src/com/android/media/tests/MediaMemoryTest.java
+++ b/src/com/android/media/tests/MediaMemoryTest.java
@@ -27,10 +27,10 @@ import com.android.tradefed.result.BugreportCollector;
import com.android.tradefed.result.BugreportCollector.Freq;
import com.android.tradefed.result.BugreportCollector.Noun;
import com.android.tradefed.result.BugreportCollector.Relation;
+import com.android.tradefed.result.FileInputStreamSource;
import com.android.tradefed.result.ITestInvocationListener;
import com.android.tradefed.result.InputStreamSource;
import com.android.tradefed.result.LogDataType;
-import com.android.tradefed.result.SnapshotInputStreamSource;
import com.android.tradefed.testtype.IDeviceTest;
import com.android.tradefed.testtype.IRemoteTest;
import com.android.tradefed.util.FileUtil;
@@ -78,7 +78,7 @@ public class MediaMemoryTest implements IDeviceTest, IRemoteTest {
//Max test timeout - 4 hrs
private static final int MAX_TEST_TIMEOUT = 4 * 60 * 60 * 1000;
- public Map<String, String> mPatternMap = new HashMap<String, String>();
+ public Map<String, String> mPatternMap = new HashMap<>();
private static final Pattern TOTAL_MEM_DIFF_PATTERN =
Pattern.compile("^The total diff = (\\d+)");
@@ -89,7 +89,7 @@ public class MediaMemoryTest implements IDeviceTest, IRemoteTest {
private boolean mGetProcMem = false;
@Option(name = "testName", description = "Test name to run. May be repeated.")
- private Collection<String> mTests = new LinkedList<String>();
+ private Collection<String> mTests = new LinkedList<>();
public MediaMemoryTest() {
mPatternMap.put("testCameraPreviewMemoryUsage", "CameraPreview");
@@ -165,13 +165,8 @@ public class MediaMemoryTest implements IDeviceTest, IRemoteTest {
if (outputFile == null) {
continue;
}
- outputSource = new SnapshotInputStreamSource(
- new FileInputStream(outputFile));
- listener.testLog(heapFile, LogDataType.TEXT,
- outputSource);
- } catch (IOException e) {
- CLog.e("IOException while reading or parsing output file: %s",
- e.getMessage());
+ outputSource = new FileInputStreamSource(outputFile);
+ listener.testLog(heapFile, LogDataType.TEXT, outputSource);
} finally {
FileUtil.deleteFile(outputFile);
StreamUtil.cancel(outputSource);
@@ -203,7 +198,7 @@ public class MediaMemoryTest implements IDeviceTest, IRemoteTest {
// Upload a verbatim copy of the output file
CLog.d("Sending %d byte file %s into the logosphere!",
outputFile.length(), outputFile);
- outputSource = new SnapshotInputStreamSource(new FileInputStream(outputFile));
+ outputSource = new FileInputStreamSource(outputFile);
listener.testLog(outputPath, LogDataType.TEXT, outputSource);
// Parse the output file to upload aggregated metrics
@@ -224,7 +219,7 @@ public class MediaMemoryTest implements IDeviceTest, IRemoteTest {
private void parseOutputFile(InputStream dataStream,
ITestInvocationListener listener) {
- Map<String, String> runMetrics = new HashMap<String, String>();
+ Map<String, String> runMetrics = new HashMap<>();
// try to parse it
String contents;
diff --git a/src/com/android/media/tests/MediaPlayerStressTest.java b/src/com/android/media/tests/MediaPlayerStressTest.java
index 8c761d5..8efab3e 100644
--- a/src/com/android/media/tests/MediaPlayerStressTest.java
+++ b/src/com/android/media/tests/MediaPlayerStressTest.java
@@ -28,10 +28,10 @@ import com.android.tradefed.result.BugreportCollector;
import com.android.tradefed.result.BugreportCollector.Freq;
import com.android.tradefed.result.BugreportCollector.Noun;
import com.android.tradefed.result.BugreportCollector.Relation;
+import com.android.tradefed.result.FileInputStreamSource;
import com.android.tradefed.result.ITestInvocationListener;
import com.android.tradefed.result.InputStreamSource;
import com.android.tradefed.result.LogDataType;
-import com.android.tradefed.result.SnapshotInputStreamSource;
import com.android.tradefed.testtype.IDeviceTest;
import com.android.tradefed.testtype.IRemoteTest;
import com.android.tradefed.util.FileUtil;
@@ -79,7 +79,7 @@ public class MediaPlayerStressTest implements IDeviceTest, IRemoteTest {
private static final String TEST_PACKAGE_NAME = "com.android.mediaframeworktest";
private static final String TEST_RUNNER_NAME = ".MediaPlayerStressTestRunner";
- public RegexTrie<String> mPatternMap = new RegexTrie<String>();
+ public RegexTrie<String> mPatternMap = new RegexTrie<>();
public MediaPlayerStressTest() {
mPatternMap.put("PlaybackPass", "^Total Complete: (\\d+)");
@@ -137,7 +137,7 @@ public class MediaPlayerStressTest implements IDeviceTest, IRemoteTest {
// Upload a verbatim copy of the output file
Log.d(LOG_TAG, String.format("Sending %d byte file %s into the logosphere!",
outputFile.length(), outputFile));
- outputSource = new SnapshotInputStreamSource(new FileInputStream(outputFile));
+ outputSource = new FileInputStreamSource(outputFile);
listener.testLog(mOutputPath, LogDataType.TEXT, outputSource);
// Parse the output file to upload aggregated metrics
parseOutputFile(new FileInputStream(outputFile), listener);
@@ -155,7 +155,7 @@ public class MediaPlayerStressTest implements IDeviceTest, IRemoteTest {
*/
private void parseOutputFile(InputStream dataStream,
ITestInvocationListener listener) {
- Map<String, String> runMetrics = new HashMap<String, String>();
+ Map<String, String> runMetrics = new HashMap<>();
// try to parse it
String contents;
@@ -172,7 +172,7 @@ public class MediaPlayerStressTest implements IDeviceTest, IRemoteTest {
String line;
while (lineIter.hasNext()) {
line = lineIter.next();
- List<List<String>> capture = new ArrayList<List<String>>(1);
+ List<List<String>> capture = new ArrayList<>(1);
String key = mPatternMap.retrieve(capture, line);
if (key != null) {
Log.d(LOG_TAG, String.format("Got '%s' and captures '%s'",
diff --git a/src/com/android/media/tests/MediaStressTest.java b/src/com/android/media/tests/MediaStressTest.java
index fdcaea0..189dd60 100644
--- a/src/com/android/media/tests/MediaStressTest.java
+++ b/src/com/android/media/tests/MediaStressTest.java
@@ -22,10 +22,10 @@ import com.android.ddmlib.testrunner.RemoteAndroidTestRunner;
import com.android.tradefed.device.DeviceNotAvailableException;
import com.android.tradefed.device.ITestDevice;
import com.android.tradefed.log.LogUtil.CLog;
+import com.android.tradefed.result.FileInputStreamSource;
import com.android.tradefed.result.ITestInvocationListener;
import com.android.tradefed.result.InputStreamSource;
import com.android.tradefed.result.LogDataType;
-import com.android.tradefed.result.SnapshotInputStreamSource;
import com.android.tradefed.testtype.IDeviceTest;
import com.android.tradefed.testtype.IRemoteTest;
import com.android.tradefed.util.FileUtil;
@@ -113,12 +113,9 @@ public class MediaStressTest implements IDeviceTest, IRemoteTest {
}
CLog.d("Sending %d byte file %s into the logosphere!", outputFile.length(), outputFile);
- outputSource = new SnapshotInputStreamSource(new FileInputStream(outputFile));
+ outputSource = new FileInputStreamSource(outputFile);
listener.testLog(OUTPUT_PATH, LogDataType.TEXT, outputSource);
parseOutputFile(outputFile, listener);
- } catch (IOException e) {
- CLog.e("IOException while reading or parsing output file");
- CLog.e(e);
} finally {
FileUtil.deleteFile(outputFile);
StreamUtil.cancel(outputSource);
@@ -129,8 +126,8 @@ public class MediaStressTest implements IDeviceTest, IRemoteTest {
* Parse the relevant metrics from the Instrumentation test output file
*/
private void parseOutputFile(File outputFile, ITestInvocationListener listener) {
- Map<String, String> runMetrics = new HashMap<String, String>();
- Map<String, String> stanzaKeyMap = new HashMap<String, String>();
+ Map<String, String> runMetrics = new HashMap<>();
+ Map<String, String> stanzaKeyMap = new HashMap<>();
stanzaKeyMap.put("testStressRecordVideoAndPlayback1080P", "VideoRecordPlayback1080P");
stanzaKeyMap.put("testStressRecordVideoAndPlayback720P", "VideoRecordPlayback720P");
stanzaKeyMap.put("testStressRecordVideoAndPlayback480P", "VideoRecordPlayback480P");
diff --git a/src/com/android/media/tests/VideoEditingMemoryTest.java b/src/com/android/media/tests/VideoEditingMemoryTest.java
index 67e486e..bb58df2 100644
--- a/src/com/android/media/tests/VideoEditingMemoryTest.java
+++ b/src/com/android/media/tests/VideoEditingMemoryTest.java
@@ -27,10 +27,10 @@ import com.android.tradefed.result.BugreportCollector;
import com.android.tradefed.result.BugreportCollector.Freq;
import com.android.tradefed.result.BugreportCollector.Noun;
import com.android.tradefed.result.BugreportCollector.Relation;
+import com.android.tradefed.result.FileInputStreamSource;
import com.android.tradefed.result.ITestInvocationListener;
import com.android.tradefed.result.InputStreamSource;
import com.android.tradefed.result.LogDataType;
-import com.android.tradefed.result.SnapshotInputStreamSource;
import com.android.tradefed.testtype.IDeviceTest;
import com.android.tradefed.testtype.IRemoteTest;
import com.android.tradefed.util.FileUtil;
@@ -84,8 +84,8 @@ public class VideoEditingMemoryTest implements IDeviceTest, IRemoteTest {
public static final Pattern TOTAL_MEM_DIFF_PATTERN =
Pattern.compile("(.+?)\\s.*diff.*\\s(-?\\d+)");
- public Map<String, String> mRunMetrics = new HashMap<String, String>();
- public Map<String, String> mKeyMap = new HashMap<String, String>();
+ public Map<String, String> mRunMetrics = new HashMap<>();
+ public Map<String, String> mKeyMap = new HashMap<>();
@Option(name = "getHeapDump", description = "Collect the heap")
private boolean mGetHeapDump = false;
@@ -156,13 +156,8 @@ public class VideoEditingMemoryTest implements IDeviceTest, IRemoteTest {
if (outputFile == null) {
continue;
}
- outputSource = new SnapshotInputStreamSource(
- new FileInputStream(outputFile));
- listener.testLog(heapOutputFile, LogDataType.TEXT,
- outputSource);
- } catch (IOException e) {
- Log.e(LOG_TAG, String.format(
- "IOException while reading or parsing output file: %s", e));
+ outputSource = new FileInputStreamSource(outputFile);
+ listener.testLog(heapOutputFile, LogDataType.TEXT, outputSource);
} finally {
FileUtil.deleteFile(outputFile);
StreamUtil.cancel(outputSource);
@@ -179,12 +174,12 @@ public class VideoEditingMemoryTest implements IDeviceTest, IRemoteTest {
File outputFile = null;
InputStreamSource outputSource = null;
- try {
- if (mGetHeapDump) {
- // Upload all the heap dump files.
- uploadHeapDumpFiles(listener);
- }
- for(String resultFile : mKeyMap.keySet()) {
+ if (mGetHeapDump) {
+ // Upload all the heap dump files.
+ uploadHeapDumpFiles(listener);
+ }
+ for (String resultFile : mKeyMap.keySet()) {
+ try {
outputFile = mTestDevice.pullFileFromExternal(resultFile);
if (outputFile == null) {
@@ -195,21 +190,19 @@ public class VideoEditingMemoryTest implements IDeviceTest, IRemoteTest {
Log.d(LOG_TAG, String.format(
"Sending %d byte file %s into the logosphere!",
outputFile.length(), outputFile));
- outputSource = new SnapshotInputStreamSource(
- new FileInputStream(outputFile));
- listener.testLog(resultFile, LogDataType.TEXT,
- outputSource);
+ outputSource = new FileInputStreamSource(outputFile);
+ listener.testLog(resultFile, LogDataType.TEXT, outputSource);
// Parse the output file to upload aggregated metrics
- parseOutputFile(new FileInputStream(outputFile), listener,
- resultFile);
+ parseOutputFile(new FileInputStream(outputFile), listener, resultFile);
+ } catch (IOException e) {
+ Log.e(
+ LOG_TAG,
+ String.format("IOException while reading or parsing output file: %s", e));
+ } finally {
+ FileUtil.deleteFile(outputFile);
+ StreamUtil.cancel(outputSource);
}
- } catch (IOException e) {
- Log.e(LOG_TAG, String.format(
- "IOException while reading or parsing output file: %s", e));
- } finally {
- FileUtil.deleteFile(outputFile);
- StreamUtil.cancel(outputSource);
}
}
diff --git a/src/com/android/media/tests/VideoEditingPerformanceTest.java b/src/com/android/media/tests/VideoEditingPerformanceTest.java
index b2b1ec6..046403e 100644
--- a/src/com/android/media/tests/VideoEditingPerformanceTest.java
+++ b/src/com/android/media/tests/VideoEditingPerformanceTest.java
@@ -26,10 +26,10 @@ import com.android.tradefed.result.BugreportCollector;
import com.android.tradefed.result.BugreportCollector.Freq;
import com.android.tradefed.result.BugreportCollector.Noun;
import com.android.tradefed.result.BugreportCollector.Relation;
+import com.android.tradefed.result.FileInputStreamSource;
import com.android.tradefed.result.ITestInvocationListener;
import com.android.tradefed.result.InputStreamSource;
import com.android.tradefed.result.LogDataType;
-import com.android.tradefed.result.SnapshotInputStreamSource;
import com.android.tradefed.testtype.IDeviceTest;
import com.android.tradefed.testtype.IRemoteTest;
import com.android.tradefed.util.FileUtil;
@@ -75,7 +75,7 @@ public class VideoEditingPerformanceTest implements IDeviceTest, IRemoteTest {
private static final String OUTPUT_PATH = "VideoEditorPerformance.txt";
- private final RegexTrie<String> mPatternMap = new RegexTrie<String>();
+ private final RegexTrie<String> mPatternMap = new RegexTrie<>();
public VideoEditingPerformanceTest() {
mPatternMap.put("ImageItemCreate",
@@ -179,8 +179,7 @@ public class VideoEditingPerformanceTest implements IDeviceTest, IRemoteTest {
Log.d(LOG_TAG, String.format(
"Sending %d byte file %s into the logosphere!",
outputFile.length(), outputFile));
- outputSource = new SnapshotInputStreamSource(new FileInputStream(
- outputFile));
+ outputSource = new FileInputStreamSource(outputFile);
listener.testLog(OUTPUT_PATH, LogDataType.TEXT, outputSource);
// Parse the output file to upload aggregated metrics
@@ -200,7 +199,7 @@ public class VideoEditingPerformanceTest implements IDeviceTest, IRemoteTest {
private void parseOutputFile(InputStream dataStream,
ITestInvocationListener listener) {
- Map<String, String> runMetrics = new HashMap<String, String>();
+ Map<String, String> runMetrics = new HashMap<>();
// try to parse it
String contents;
@@ -217,7 +216,7 @@ public class VideoEditingPerformanceTest implements IDeviceTest, IRemoteTest {
String line;
while (lineIter.hasNext()) {
line = lineIter.next();
- List<List<String>> capture = new ArrayList<List<String>>(1);
+ List<List<String>> capture = new ArrayList<>(1);
String key = mPatternMap.retrieve(capture, line);
if (key != null) {
Log.d(LOG_TAG, String.format("Got '%s' and captures '%s'", key,
diff --git a/src/com/android/media/tests/VideoMultimeterTest.java b/src/com/android/media/tests/VideoMultimeterTest.java
index 9e2ab78..c287bed 100644
--- a/src/com/android/media/tests/VideoMultimeterTest.java
+++ b/src/com/android/media/tests/VideoMultimeterTest.java
@@ -23,16 +23,17 @@ import com.android.tradefed.device.CollectingOutputReceiver;
import com.android.tradefed.device.DeviceNotAvailableException;
import com.android.tradefed.device.ITestDevice;
import com.android.tradefed.log.LogUtil.CLog;
+import com.android.tradefed.result.ByteArrayInputStreamSource;
import com.android.tradefed.result.ITestInvocationListener;
import com.android.tradefed.result.LogDataType;
-import com.android.tradefed.result.SnapshotInputStreamSource;
import com.android.tradefed.testtype.IDeviceTest;
import com.android.tradefed.testtype.IRemoteTest;
import com.android.tradefed.util.CommandResult;
import com.android.tradefed.util.IRunUtil;
import com.android.tradefed.util.RunUtil;
-import java.io.ByteArrayInputStream;
+import org.junit.Assert;
+
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
@@ -43,8 +44,6 @@ import java.util.concurrent.TimeUnit;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
-import org.junit.Assert;
-
/**
* A harness that test video playback and reports result.
*/
@@ -284,8 +283,8 @@ public class VideoMultimeterTest implements IDeviceTest, IRemoteTest {
// get all results from multimeter and write to output file
cr = getRunUtil().runTimedCmd(GETDATA_TIMEOUT_MS, mMeterUtilPath, CMD_GET_ALL_DATA);
String allData = cr.getStdout();
- listener.testLog(keyprefix, LogDataType.TEXT, new SnapshotInputStreamSource(
- new ByteArrayInputStream(allData.getBytes())));
+ listener.testLog(
+ keyprefix, LogDataType.TEXT, new ByteArrayInputStreamSource(allData.getBytes()));
// parse results
return parseResult(metrics, nrOfDataPoints, allData, keyprefix, fps, lipsync);
@@ -331,7 +330,7 @@ public class VideoMultimeterTest implements IDeviceTest, IRemoteTest {
listener.testStarted(testId);
long testStartTime = System.currentTimeMillis();
- Map<String, String> metrics = new HashMap<String, String>();
+ Map<String, String> metrics = new HashMap<>();
if (setupTestEnv()) {
runMultimeterTest(listener, metrics);
@@ -428,7 +427,7 @@ public class VideoMultimeterTest implements IDeviceTest, IRemoteTest {
// format: "OK (time); (frame duration); (marker color); (total dropped frames); (lipsync)"
p = Pattern.compile(LIPSYNC_DATA_PATTERN);
if (lipsync) {
- ArrayList<Integer> lipsyncVals = new ArrayList<Integer>();
+ ArrayList<Integer> lipsyncVals = new ArrayList<>();
StringBuilder lipsyncValsStr = new StringBuilder("[");
long lipsyncSum = 0;
for (int i = 0; i < lines.length; i++) {