Add tests for setQueue and setQueueTitle in MediaSession

We were assuming these weren't null in code when they can be. This adds
a test for it to make sure they can be set to null.

bug:17593962
Change-Id: I4d1bc8cdf7c3284430e93755e878ca759fb363c1
diff --git a/tests/tests/media/src/android/media/cts/MediaSessionTest.java b/tests/tests/media/src/android/media/cts/MediaSessionTest.java
index 7409ff5..df68392 100644
--- a/tests/tests/media/src/android/media/cts/MediaSessionTest.java
+++ b/tests/tests/media/src/android/media/cts/MediaSessionTest.java
@@ -20,6 +20,7 @@
 import android.content.Intent;
 import android.media.AudioAttributes;
 import android.media.AudioManager;
+import android.media.MediaDescription;
 import android.media.MediaMetadata;
 import android.media.Rating;
 import android.media.VolumeProvider;
@@ -30,6 +31,7 @@
 import android.os.Bundle;
 import android.test.AndroidTestCase;
 
+import java.util.ArrayList;
 import java.util.Set;
 
 public class MediaSessionTest extends AndroidTestCase {
@@ -121,7 +123,24 @@
         assertNotNull(tags);
         assertTrue(tags.contains(val));
 
-        // TODO test Queue APIs after fixing b/17205016
+        // test setQueue and setQueueTitle
+        ArrayList<MediaSession.QueueItem> queue = new ArrayList<MediaSession.QueueItem>();
+        MediaSession.QueueItem item = new MediaSession.QueueItem(new MediaDescription.Builder()
+                .setMediaId(val).setTitle("title").build(), 11);
+        queue.add(item);
+        session.setQueue(queue);
+        session.setQueueTitle(val);
+
+        assertEquals(val, controller.getQueueTitle());
+        assertEquals(1, controller.getQueue().size());
+        assertEquals(11, controller.getQueue().get(0).getQueueId());
+        assertEquals(val, controller.getQueue().get(0).getDescription().getMediaId());
+
+        session.setQueue(null);
+        session.setQueueTitle(null);
+
+        assertNull(controller.getQueueTitle());
+        assertNull(controller.getQueue());
 
         // test setSessionActivity
         Intent intent = new Intent("cts.MEDIA_SESSION_ACTION");