mirror of
https://github.com/androidx/media.git
synced 2025-04-30 06:46:50 +08:00

While investigating a different test failure on a pending change I noticed that sometimes the "testAddSessions_removedWhenClose" session was being released before it could be fully connected - and this results in a failure like: ``` expected not to contain: androidx.media3.session.MediaSession@50a9ef1 but was : [androidx.media3.session.MediaSession@50a9ef1, androidx.media3.session.MediaSession@3a6bac] at androidx.media3.session.MediaSessionServiceTest.addSessions_removedWhenReleased(MediaSessionServiceTest.java:376) ``` It also shows up in the logs like: ``` MediaController future failed (so we couldn't release it) ... Caused by: java.lang.SecurityException: Session rejected the connection request. ``` Adding some debug logging revealed that the `session.release` call posted to the test thread was happening before the call to `MediaSessionStub.connect` on the main thread (this is triggered deep in prod media3 session logic). PiperOrigin-RevId: 563431265
Session test module
Tests cross-process use of the session module. To run the tests:
- Prepare a device (either an emulator or a real device) to run the tests on.
- Run
./gradlew :test-session-current:cAT