Loading android/app/src/com/android/bluetooth/newavrcp/MediaPlayerWrapper.java +6 −3 Original line number Diff line number Diff line Loading @@ -27,6 +27,7 @@ import android.support.annotation.VisibleForTesting; import android.util.Log; import java.util.List; import java.util.Objects; /* * A class to synchronize Media Controller Callbacks and only pass through Loading Loading @@ -423,17 +424,19 @@ class MediaPlayerWrapper { return; } if (!queue.equals(getQueue())) { if (!Objects.equals(queue, getQueue())) { e("The callback queue isn't the current queue"); } if (queue.equals(mCurrentData.queue)) { List<Metadata> current_queue = Util.toMetadataList(queue); if (current_queue.equals(mCurrentData.queue)) { Log.w(TAG, "onQueueChanged(): " + mPackageName + " tried to update with no new data"); return; } if (DEBUG) { for (int i = 0; i < queue.size(); i++) { for (int i = 0; i < current_queue.size(); i++) { Log.d(TAG, " └ QueueItem(" + i + "): " + queue.get(i)); } } Loading android/app/tests/unit/src/com/android/bluetooth/newavrcp/MediaPlayerWrapperTest.java +25 −1 Original line number Diff line number Diff line Loading @@ -282,7 +282,7 @@ public class MediaPlayerWrapperTest { verify(mMockController).registerCallback(mControllerCbs.capture(), any()); MediaController.Callback controllerCallbacks = mControllerCbs.getValue(); // Update Metdata returned by controller // Update Metadata returned by controller mTestMetadata.putString(MediaMetadata.METADATA_KEY_TITLE, "New Title"); doReturn(mTestMetadata.build()).when(mMockController).getMetadata(); Loading Loading @@ -311,6 +311,30 @@ public class MediaPlayerWrapperTest { verify(mFailHandler, never()).onTerribleFailure(any(), any(), anyBoolean()); } @Test public void testNullQueue() { // Create the wrapper object and register the looper with the timeout handler TestLooperManager looperManager = new TestLooperManager(mThread.getLooper()); MediaPlayerWrapper wrapper = MediaPlayerWrapper.wrap(mMockController, mThread.getLooper()); wrapper.registerCallback(mTestCbs); // Return null when getting the queue doReturn(null).when(mMockController).getQueue(); // Grab the callbacks the wrapper registered with the controller verify(mMockController).registerCallback(mControllerCbs.capture(), any()); MediaController.Callback controllerCallbacks = mControllerCbs.getValue(); // Call the callback controllerCallbacks.onQueueChanged(null); // Assert that both metadata and playback state are there. verify(mTestCbs, times(1)).mediaUpdatedCallback(mMediaUpdateData.capture()); MediaData data = mMediaUpdateData.getValue(); Assert.assertEquals("Returned Queue isn't null", data.queue.size(), 0); } /* * This test checks to see if the now playing queue data is cached. */ Loading Loading
android/app/src/com/android/bluetooth/newavrcp/MediaPlayerWrapper.java +6 −3 Original line number Diff line number Diff line Loading @@ -27,6 +27,7 @@ import android.support.annotation.VisibleForTesting; import android.util.Log; import java.util.List; import java.util.Objects; /* * A class to synchronize Media Controller Callbacks and only pass through Loading Loading @@ -423,17 +424,19 @@ class MediaPlayerWrapper { return; } if (!queue.equals(getQueue())) { if (!Objects.equals(queue, getQueue())) { e("The callback queue isn't the current queue"); } if (queue.equals(mCurrentData.queue)) { List<Metadata> current_queue = Util.toMetadataList(queue); if (current_queue.equals(mCurrentData.queue)) { Log.w(TAG, "onQueueChanged(): " + mPackageName + " tried to update with no new data"); return; } if (DEBUG) { for (int i = 0; i < queue.size(); i++) { for (int i = 0; i < current_queue.size(); i++) { Log.d(TAG, " └ QueueItem(" + i + "): " + queue.get(i)); } } Loading
android/app/tests/unit/src/com/android/bluetooth/newavrcp/MediaPlayerWrapperTest.java +25 −1 Original line number Diff line number Diff line Loading @@ -282,7 +282,7 @@ public class MediaPlayerWrapperTest { verify(mMockController).registerCallback(mControllerCbs.capture(), any()); MediaController.Callback controllerCallbacks = mControllerCbs.getValue(); // Update Metdata returned by controller // Update Metadata returned by controller mTestMetadata.putString(MediaMetadata.METADATA_KEY_TITLE, "New Title"); doReturn(mTestMetadata.build()).when(mMockController).getMetadata(); Loading Loading @@ -311,6 +311,30 @@ public class MediaPlayerWrapperTest { verify(mFailHandler, never()).onTerribleFailure(any(), any(), anyBoolean()); } @Test public void testNullQueue() { // Create the wrapper object and register the looper with the timeout handler TestLooperManager looperManager = new TestLooperManager(mThread.getLooper()); MediaPlayerWrapper wrapper = MediaPlayerWrapper.wrap(mMockController, mThread.getLooper()); wrapper.registerCallback(mTestCbs); // Return null when getting the queue doReturn(null).when(mMockController).getQueue(); // Grab the callbacks the wrapper registered with the controller verify(mMockController).registerCallback(mControllerCbs.capture(), any()); MediaController.Callback controllerCallbacks = mControllerCbs.getValue(); // Call the callback controllerCallbacks.onQueueChanged(null); // Assert that both metadata and playback state are there. verify(mTestCbs, times(1)).mediaUpdatedCallback(mMediaUpdateData.capture()); MediaData data = mMediaUpdateData.getValue(); Assert.assertEquals("Returned Queue isn't null", data.queue.size(), 0); } /* * This test checks to see if the now playing queue data is cached. */ Loading