Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5efd5c70 authored by Ajay Panicker's avatar Ajay Panicker Committed by android-build-merger
Browse files

Merge "Return cached data for the Now Playing Queue"

am: 5b314e42

Change-Id: I611ee4f926e09c331f28da252e7ad157dfad1cae
parents ccc5a07d 5b314e42
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -133,7 +133,7 @@ class MediaPlayerWrapper {
    }

    List<Metadata> getCurrentQueue() {
        return Util.toMetadataList(getQueue());
        return mCurrentData.queue;
    }

    // We don't return the cached info here in order to always provide the freshest data.
+22 −0
Original line number Diff line number Diff line
@@ -311,6 +311,28 @@ public class MediaPlayerWrapperTest {
        verify(mFailHandler, never()).onTerribleFailure(any(), any(), anyBoolean());
    }

    /*
     * This test checks to see if the now playing queue data is cached.
     */
    @Test
    public void testQueueCached() {
        // 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);

        // Call getCurrentQueue() multiple times.
        for (int i = 0; i < 3; i++) {
            Assert.assertEquals(wrapper.getCurrentQueue(),
                    Util.toMetadataList(getQueueFromDescriptions(mTestQueue)));
        }

        // Verify that getQueue() was only called twice. Once on creation and once during
        // registration
        verify(mMockController, times(2)).getQueue();
    }

    /*
     * This test sends repeated Playback State updates that only have a short
     * position update change to see if they get debounced.