ExoPlayer icon indicating copy to clipboard operation
ExoPlayer copied to clipboard

Espresso with exoplayer

Open NayaneshGupte opened this issue 7 years ago • 4 comments

[REQUIRED] Searched documentation and issues

Sample app of exoplayer doesn't have espresso testing use cases.

[REQUIRED] Question

I have been looking for a way to set up espresso in the same screen where the exoplayer is also integrated but not able to find a way to do it. Is there any IdlingResource and rule to for espresso with exoplayer ?

A full bug report captured from the device

Not a bug

Link to test content

Sample app can be updated to demonstrate Espresso testing with exoplayer

NayaneshGupte avatar Aug 29 '19 09:08 NayaneshGupte

The ExoPlayer library does not provide dedicated support for Espresso.

I'm not too much into the details of Espresso but as far as I understand it should be possible to implement an IdlingResource which is for instance waiting for a given event passed to Player.EventLogger and then call onTransitionToIdle. For example if you want to play a video and when the state Player.STATE_ENDED is passed to onPlayerStateChanged, then you call onTransitionToIdle so the test can continue and assert some UI state.

marcbaechinger avatar Aug 29 '19 09:08 marcbaechinger

@marcbaechinger so does that mean performing test while player is in READY (Playing) state , espresso test can not continue ?

NayaneshGupte avatar Aug 29 '19 09:08 NayaneshGupte

Being not an Espresso expert, I assume the espresso test runs on a thread which is similar to the main thread in the app. As ExoPlayer has it's own playback thread, the player will not block that main thread when doing playback. In fact I believe you need to make sure that your test does not end and hence stop ExoPlayer while the player is doing playback.

As far as I understand this is exactly why you want such an IdleResource implementation. It will tell your test to wait until a certain event happens on which your code then calls onTransitionToIdle. After that call your test continues. Without this IdelResource your test would finish regardless of the state of the player.

marcbaechinger avatar Aug 30 '19 14:08 marcbaechinger

closing due to inactivity.

marcbaechinger avatar Sep 25 '19 09:09 marcbaechinger