[vlc-devel] [PATCHv3 15/17] test: lib: media_player: pause can now be always tested

Thomas Guillem thomas at gllm.fr
Wed Jun 10 14:57:54 CEST 2020


Since the mock:// duration is 5seconds.
---
 test/libvlc/media_player.c | 15 ++++++---------
 1 file changed, 6 insertions(+), 9 deletions(-)

diff --git a/test/libvlc/media_player.c b/test/libvlc/media_player.c
index 5a7cb3e2169..a3b2d3e82f4 100644
--- a/test/libvlc/media_player.c
+++ b/test/libvlc/media_player.c
@@ -59,20 +59,17 @@ static void pause_and_wait(libvlc_media_player_t *mp)
     int res;
     res = libvlc_event_attach(em, libvlc_MediaPlayerPaused, on_event, &sem);
     assert(!res);
-    res = libvlc_event_attach(em, libvlc_MediaPlayerEndReached, on_event, &sem);
-    assert(!res);
+
+    assert(libvlc_media_player_get_state(mp) == libvlc_Playing);
 
     libvlc_media_player_set_pause(mp, true);
 
-    /* the end may have been already reached before attaching the event */
-    if (libvlc_media_player_get_state(mp) == libvlc_Playing)
-    {
-        test_log("Waiting for pause\n");
-        vlc_sem_wait(&sem);
-    }
+    test_log("Waiting for pause\n");
+    vlc_sem_wait(&sem);
+
+    assert(libvlc_media_player_get_state(mp) == libvlc_Paused);
 
     libvlc_event_detach(em, libvlc_MediaPlayerPaused, on_event, &sem);
-    libvlc_event_detach(em, libvlc_MediaPlayerEndReached, on_event, &sem);
 }
 
 /* Test a bunch of A/V properties. This most does nothing since the current
-- 
2.20.1



More information about the vlc-devel mailing list