am 8d73367a: Merge "Test for bug 13652927" into jb-dev

* commit '8d73367a15559f78becff8007369ea741f53f67c':
  Test for bug 13652927
diff --git a/tests/tests/media/res/raw/bug13652927.ogg b/tests/tests/media/res/raw/bug13652927.ogg
new file mode 100644
index 0000000..065d9e5
--- /dev/null
+++ b/tests/tests/media/res/raw/bug13652927.ogg
Binary files differ
diff --git a/tests/tests/media/src/android/media/cts/MediaPlayerTest.java b/tests/tests/media/src/android/media/cts/MediaPlayerTest.java
index 11d2907..5a22226 100644
--- a/tests/tests/media/src/android/media/cts/MediaPlayerTest.java
+++ b/tests/tests/media/src/android/media/cts/MediaPlayerTest.java
@@ -22,14 +22,18 @@
 import android.content.res.AssetFileDescriptor;
 import android.media.AudioManager;
 import android.media.MediaPlayer;
+import android.media.MediaPlayer.OnErrorListener;
 import android.media.MediaRecorder;
 import android.media.audiofx.AudioEffect;
 import android.media.audiofx.Visualizer;
 import android.media.cts.MediaPlayerTestBase.Monitor;
 import android.net.Uri;
 import android.os.Environment;
+import android.os.IBinder;
 import android.os.PowerManager;
+import android.os.ServiceManager;
 import android.os.SystemClock;
+import android.util.Log;
 
 import java.io.File;
 import java.util.UUID;
@@ -67,6 +71,35 @@
             mOutFile.delete();
         }
     }
+
+    // Bug 13652927
+    public void testVorbisCrash() throws Exception {
+        MediaPlayer mp = mMediaPlayer;
+        MediaPlayer mp2 = mMediaPlayer2;
+        AssetFileDescriptor afd2 = mResources.openRawResourceFd(R.raw.testmp3_2);
+        mp2.setDataSource(afd2.getFileDescriptor(), afd2.getStartOffset(), afd2.getLength());
+        afd2.close();
+        mp2.prepare();
+        mp2.setLooping(true);
+        mp2.start();
+
+        for (int i = 0; i < 20; i++) {
+            try {
+                AssetFileDescriptor afd = mResources.openRawResourceFd(R.raw.bug13652927);
+                mp.setDataSource(afd.getFileDescriptor(), afd.getStartOffset(), afd.getLength());
+                afd.close();
+                mp.prepare();
+                fail("shouldn't be here");
+            } catch (Exception e) {
+                // expected to fail
+                Log.i("@@@", "failed: " + e);
+            }
+            Thread.sleep(500);
+            assertTrue("media server died", mp2.isPlaying());
+            mp.reset();
+        }
+    }
+
     public void testPlayNullSource() throws Exception {
         try {
             mMediaPlayer.setDataSource((String) null);