Merge "Remove the unnecssary intent call." into jb-dev

This commit is contained in:
Yu Shan Emily Lau
2012-07-10 16:47:09 -07:00
committed by Android (Google) Code Review

View File

@@ -24,6 +24,7 @@ import android.content.Intent;
import android.hardware.Camera; import android.hardware.Camera;
import android.media.MediaPlayer; import android.media.MediaPlayer;
import android.media.MediaRecorder; import android.media.MediaRecorder;
import android.os.Environment;
import android.test.ActivityInstrumentationTestCase2; import android.test.ActivityInstrumentationTestCase2;
import android.test.suitebuilder.annotation.LargeTest; import android.test.suitebuilder.annotation.LargeTest;
import android.util.Log; import android.util.Log;
@@ -66,6 +67,9 @@ public class MediaPlayerStressTest extends ActivityInstrumentationTestCase2<Medi
private int mTotalNotSeekable = 0; private int mTotalNotSeekable = 0;
private int mTotalMetaDataUpdate = 0; private int mTotalMetaDataUpdate = 0;
//Test result output file
private static final String PLAYBACK_RESULT = "PlaybackTestResult.txt";
private void writeTestOutput(String filename, Writer output) throws Exception{ private void writeTestOutput(String filename, Writer output) throws Exception{
output.write("File Name: " + filename); output.write("File Name: " + filename);
output.write(" Complete: " + CodecTest.onCompleteSuccess); output.write(" Complete: " + CodecTest.onCompleteSuccess);
@@ -109,27 +113,19 @@ public class MediaPlayerStressTest extends ActivityInstrumentationTestCase2<Medi
@LargeTest @LargeTest
public void testVideoPlayback() throws Exception { public void testVideoPlayback() throws Exception {
String fileWithError = "Filename:\n"; String fileWithError = "Filename:\n";
File playbackOutput = new File("/sdcard/PlaybackTestResult.txt"); File playbackOutput = new File(Environment.getExternalStorageDirectory(), PLAYBACK_RESULT);
Writer output = new BufferedWriter(new FileWriter(playbackOutput, true)); Writer output = new BufferedWriter(new FileWriter(playbackOutput, true));
boolean testResult = true; boolean testResult = true;
// load directory files // load directory files
boolean onCompleteSuccess = false; boolean onCompleteSuccess = false;
File dir = new File(MediaNames.MEDIA_SAMPLE_POOL); File dir = new File(MediaNames.MEDIA_SAMPLE_POOL);
Instrumentation inst = getInstrumentation();
Intent intent = new Intent();
intent.setClass(getInstrumentation().getTargetContext(), MediaFrameworkTest.class);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
String[] children = dir.list(); String[] children = dir.list();
if (children == null) { if (children == null) {
Log.v("MediaPlayerApiTest:testMediaSamples", "dir is empty"); Log.v("MediaPlayerApiTest:testMediaSamples", "dir is empty");
return; return;
} else { } else {
for (int i = 0; i < children.length; i++) { for (int i = 0; i < children.length; i++) {
Activity act = inst.startActivitySync(intent);
//Get filename of directory //Get filename of directory
String filename = children[i]; String filename = children[i];
onCompleteSuccess = onCompleteSuccess =
@@ -141,8 +137,6 @@ public class MediaPlayerStressTest extends ActivityInstrumentationTestCase2<Medi
testResult = false; testResult = false;
} }
Thread.sleep(3000); Thread.sleep(3000);
//Call onCreat to recreate the surface
act.finish();
//Write test result to an output file //Write test result to an output file
writeTestOutput(filename,output); writeTestOutput(filename,output);
//Get the summary //Get the summary