media/libraries/test_session_current
ibaker 06f5324665 Deflake MediaSessionServiceTest.addSessions_removedWhenReleased
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
2023-09-07 08:00:25 -07:00
..
2021-10-27 09:12:46 +01:00

Session test module

Tests cross-process use of the session module. To run the tests:

  1. Prepare a device (either an emulator or a real device) to run the tests on.
  2. Run ./gradlew :test-session-current:cAT