mirror of
https://github.com/androidx/media.git
synced 2025-04-30 06:46:50 +08:00
Remove test that just times out
One of the tests in MediaBrowserListenerTest caused the remote browser service to crash and then just timed out. As this asserts nothing useful besides checking that the timeout method is working, we can remove the test. Crashing the remote browser service had the side effect of letting subsequent tests in the same class fail because the previous session was never released and was still present in the static MediaSession SESSION_ID_TO_SESSION_MAP instance, which prevented the creation of new sessions with the same id. This is only an issue in test runs because a real process would also lose its static variables when it crashes. PiperOrigin-RevId: 476905337
This commit is contained in:
parent
acd9e581c4
commit
d2887d5237
@ -30,7 +30,6 @@ public class MediaBrowserConstants {
|
||||
public static final String MEDIA_ID_GET_BROWSABLE_ITEM = "media_id_get_browsable_item";
|
||||
public static final String MEDIA_ID_GET_PLAYABLE_ITEM = "media_id_get_playable_item";
|
||||
public static final String MEDIA_ID_GET_ITEM_WITH_METADATA = "media_id_get_item_with_metadata";
|
||||
public static final String MEDIA_ID_GET_NULL_ITEM = "media_id_get_null_item";
|
||||
|
||||
public static final String PARENT_ID = "parent_id";
|
||||
public static final String PARENT_ID_LONG_LIST = "parent_id_long_list";
|
||||
|
@ -45,7 +45,6 @@ import androidx.test.ext.junit.runners.AndroidJUnit4;
|
||||
import androidx.test.filters.LargeTest;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.TimeoutException;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
import org.junit.Before;
|
||||
@ -144,30 +143,6 @@ public class MediaBrowserListenerTest extends MediaControllerListenerTest {
|
||||
assertThat(result.value).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getItem_nullResult() throws Exception {
|
||||
String mediaId = MediaBrowserConstants.MEDIA_ID_GET_NULL_ITEM;
|
||||
|
||||
// Exception will be thrown in the service side, and the process will be crashed.
|
||||
// In that case one of following will happen
|
||||
// Case 1) Process is crashed. Pending ListenableFuture will get error
|
||||
// Case 2) Due to the frequent crashes with other tests, process may not crash immediately
|
||||
// because the Android shows dialog 'xxx keeps stopping' and defer sending
|
||||
// SIG_KILL until the user's explicit action.
|
||||
try {
|
||||
MediaBrowser browser = createBrowser();
|
||||
LibraryResult<MediaItem> result =
|
||||
threadTestRule
|
||||
.getHandler()
|
||||
.postAndSync(() -> browser.getItem(mediaId))
|
||||
.get(TIMEOUT_MS, MILLISECONDS);
|
||||
// Case 1.
|
||||
assertThat(result.resultCode).isNotEqualTo(RESULT_SUCCESS);
|
||||
} catch (TimeoutException e) {
|
||||
// Case 2.
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getChildren() throws Exception {
|
||||
String parentId = MediaBrowserConstants.PARENT_ID;
|
||||
|
@ -27,7 +27,6 @@ import static androidx.media3.test.session.common.MediaBrowserConstants.GET_CHIL
|
||||
import static androidx.media3.test.session.common.MediaBrowserConstants.LONG_LIST_COUNT;
|
||||
import static androidx.media3.test.session.common.MediaBrowserConstants.MEDIA_ID_GET_BROWSABLE_ITEM;
|
||||
import static androidx.media3.test.session.common.MediaBrowserConstants.MEDIA_ID_GET_ITEM_WITH_METADATA;
|
||||
import static androidx.media3.test.session.common.MediaBrowserConstants.MEDIA_ID_GET_NULL_ITEM;
|
||||
import static androidx.media3.test.session.common.MediaBrowserConstants.MEDIA_ID_GET_PLAYABLE_ITEM;
|
||||
import static androidx.media3.test.session.common.MediaBrowserConstants.NOTIFY_CHILDREN_CHANGED_EXTRAS;
|
||||
import static androidx.media3.test.session.common.MediaBrowserConstants.NOTIFY_CHILDREN_CHANGED_ITEM_COUNT;
|
||||
@ -208,11 +207,6 @@ public class MockMediaLibraryService extends MediaLibraryService {
|
||||
case MEDIA_ID_GET_ITEM_WITH_METADATA:
|
||||
return Futures.immediateFuture(
|
||||
LibraryResult.ofItem(createMediaItemWithMetadata(mediaId), /* params= */ null));
|
||||
case MEDIA_ID_GET_NULL_ITEM:
|
||||
// Passing item=null here is expected to throw NPE, this is testing a misbehaving app
|
||||
// that ignores the nullness annotations.
|
||||
return Futures.immediateFuture(
|
||||
LibraryResult.ofItem(/* item= */ null, /* params= */ null));
|
||||
default: // fall out
|
||||
}
|
||||
return Futures.immediateFuture(LibraryResult.ofError(LibraryResult.RESULT_ERROR_BAD_VALUE));
|
||||
|
Loading…
x
Reference in New Issue
Block a user