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

Commit 667bcd05 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Return cached data for the Now Playing Queue" into pi-dev

parents c51c0bee 75c7717c
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.