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

Commit 5b314e42 authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge "Return cached data for the Now Playing Queue"

parents a7ed6330 38e067b4
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.