Augment CTS test for MediaPlayer.setSurface

This change makes the test cover the case where a Surface that has
already been released is passed to MediaPlayer.setSurface.

Bug: 5396571
Change-Id: I34dbae755b4aa17664c20f2e6a34c0603e061adf
diff --git a/tests/src/android/media/cts/VideoSurfaceView.java b/tests/src/android/media/cts/VideoSurfaceView.java
index 75811cc..0f23a2d 100644
--- a/tests/src/android/media/cts/VideoSurfaceView.java
+++ b/tests/src/android/media/cts/VideoSurfaceView.java
@@ -68,6 +68,18 @@
         Thread.sleep(SLEEP_TIME * 5);
         mMediaPlayer.setSurface(null);
 
+        Thread.sleep(SLEEP_TIME * 1);
+        SurfaceTexture surfaceTexture = new SurfaceTexture(0);
+        Surface surface = new Surface(surfaceTexture);
+        surface.release();
+        try {
+            mMediaPlayer.setSurface(surface);
+            throw new RuntimeException("setSurface with released Surface object didn't throw " +
+                    "IllegalArgumentException");
+        } catch (IllegalArgumentException e) {
+            // Expected
+        }
+
         while (mMediaPlayer.isPlaying()) {
             Thread.sleep(SLEEP_TIME);
         }