Transferring to a cast device should not close the output switcher

-Close panel only when on pause and stop
-Transfer device would set the play state to "STATE_NONE"
-Add test case

Bug: 152632226
Test: make -j42 RunSettingsRoboTests
Change-Id: Ibf6ce1454b1d5bf3facc07abec15b8735029f2cf
This commit is contained in:
Tim Peng
2020-04-07 11:54:26 +08:00
committed by tim peng
parent c0c522d999
commit 6fb4059944
2 changed files with 18 additions and 1 deletions

View File

@@ -259,7 +259,9 @@ public class MediaOutputPanel implements PanelContent, LocalMediaManager.DeviceC
@Override @Override
public void onPlaybackStateChanged(PlaybackState state) { public void onPlaybackStateChanged(PlaybackState state) {
if (mCallback != null && state.getState() != PlaybackState.STATE_PLAYING) { final int playState = state.getState();
if (mCallback != null && (playState == PlaybackState.STATE_STOPPED
|| playState == PlaybackState.STATE_PAUSED)) {
mCallback.forceClose(); mCallback.forceClose();
} }
} }

View File

@@ -295,4 +295,19 @@ public class MediaOutputPanelTest {
verify(mCallback).forceClose(); verify(mCallback).forceClose();
} }
@Test
public void onPlaybackStateChanged_stateFromPlayingToPaused_verifyCallForceClose() {
mPanel.onStart();
verify(mMediaController).registerCallback(mControllerCbs.capture());
final MediaController.Callback controllerCallbacks = mControllerCbs.getValue();
when(mPlaybackState.getState()).thenReturn(PlaybackState.STATE_PLAYING);
controllerCallbacks.onPlaybackStateChanged(mPlaybackState);
verify(mCallback, never()).forceClose();
when(mPlaybackState.getState()).thenReturn(PlaybackState.STATE_PAUSED);
controllerCallbacks.onPlaybackStateChanged(mPlaybackState);
verify(mCallback).forceClose();
}
} }