From a79edb72333ceda76c73166acef139c8668ee829 Mon Sep 17 00:00:00 2001 From: Yu Shan Emily Lau Date: Wed, 4 Apr 2012 21:17:04 -0700 Subject: Insert the 2 seconds before test start to workaround the race conditon for requesting the surface. Change-Id: Ic8ba358400492860b0d38fc71468ea4bb4d3d7bd --- .../mediaplayback/MediaPlayerApiTest.java | 35 ++++++++++++---------- 1 file changed, 19 insertions(+), 16 deletions(-) (limited to 'media/tests') diff --git a/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/functional/mediaplayback/MediaPlayerApiTest.java b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/functional/mediaplayback/MediaPlayerApiTest.java index c501d3f..7be2707 100644 --- a/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/functional/mediaplayback/MediaPlayerApiTest.java +++ b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/functional/mediaplayback/MediaPlayerApiTest.java @@ -22,7 +22,7 @@ import com.android.mediaframeworktest.MediaProfileReader; import com.android.mediaframeworktest.functional.CodecTest; import android.content.Context; -import android.test.ActivityInstrumentationTestCase; +import android.test.ActivityInstrumentationTestCase2; import android.util.Log; import android.test.suitebuilder.annotation.LargeTest; import android.test.suitebuilder.annotation.MediumTest; @@ -33,25 +33,28 @@ import java.io.File; /** * Junit / Instrumentation test case for the media player api */ -public class MediaPlayerApiTest extends ActivityInstrumentationTestCase { - private boolean duratoinWithinTolerence = false; - private String TAG = "MediaPlayerApiTest"; - private boolean isWMAEnable = false; - private boolean isWMVEnable = false; +public class MediaPlayerApiTest extends ActivityInstrumentationTestCase2 { + private boolean duratoinWithinTolerence = false; + private String TAG = "MediaPlayerApiTest"; + private boolean isWMAEnable = false; + private boolean isWMVEnable = false; - Context mContext; + Context mContext; - public MediaPlayerApiTest() { - super("com.android.mediaframeworktest", MediaFrameworkTest.class); - isWMAEnable = MediaProfileReader.getWMAEnable(); - isWMVEnable = MediaProfileReader.getWMVEnable(); - } + public MediaPlayerApiTest() { + super("com.android.mediaframeworktest", MediaFrameworkTest.class); + isWMAEnable = MediaProfileReader.getWMAEnable(); + isWMVEnable = MediaProfileReader.getWMVEnable(); + } protected void setUp() throws Exception { - super.setUp(); - - } - + //Insert a 2 second before launching the test activity. This is + //the workaround for the race condition of requesting the updated surface. + Thread.sleep(2000); + getActivity(); + super.setUp(); + } + public boolean verifyDuration(int duration, int expectedDuration){ if ((duration > expectedDuration * 1.1) || (duration < expectedDuration * 0.9)) return false; -- cgit v1.1