Skip to content

Commit 1db9c93

Browse files
committed
Add failing test
1 parent 4c339e4 commit 1db9c93

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

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

Lines changed: 16 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;
@@ -794,6 +795,21 @@ public void onEvents(Player player, Player.Events events) {
794795
serviceController.destroy();
795796
}
796797

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

0 commit comments

Comments
 (0)