Skip to content

Commit 73a463b

Browse files
committed
Add failing test
1 parent 130889f commit 73a463b

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

libraries/session/src/test/java/androidx/media3/session/MediaSessionServiceTest.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import static androidx.media3.test.utils.robolectric.RobolectricUtil.runMainLooperUntil;
1919
import static com.google.common.truth.Truth.assertThat;
2020
import static java.util.concurrent.TimeUnit.MILLISECONDS;
21+
import static org.junit.Assert.assertThrows;
2122

2223
import android.app.NotificationManager;
2324
import android.content.Context;
@@ -792,6 +793,20 @@ public void onEvents(Player player, Player.Events events) {
792793
serviceController.destroy();
793794
}
794795

796+
@Test
797+
public void onStartCommand_playbackResumption_emptyResultWillThrow() {
798+
Intent playIntent = new Intent(Intent.ACTION_MEDIA_BUTTON);
799+
playIntent.putExtra(
800+
Intent.EXTRA_KEY_EVENT, new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_MEDIA_PLAY));
801+
ServiceController<TestServiceWithPlaybackResumption> serviceController =
802+
Robolectric.buildService(TestServiceWithPlaybackResumption.class, playIntent);
803+
TestServiceWithPlaybackResumption service = serviceController.create().get();
804+
service.setMediaItems(ImmutableList.of());
805+
assertThrows(IllegalArgumentException.class,
806+
() -> serviceController.startCommand(/* flags= */ 0, /* startId= */ 0));
807+
serviceController.destroy();
808+
}
809+
795810
@Test
796811
public void onStartCommand_customCommands_deliveredByMediaNotificationController()
797812
throws InterruptedException {

0 commit comments

Comments
 (0)