[vlc-devel] commit: test: Get rid of the sleep() that crept in our test code. (Pierre d 'Herbemont )

git version control git at videolan.org
Fri Apr 11 19:11:37 CEST 2008


vlc | branch: master | Pierre d'Herbemont <pdherbemont at videolan.org> | Fri Apr 11 19:11:52 2008 +0200| [6d6185f24f8c3ebade4e22babcd027606a6d3b69]

test: Get rid of the sleep() that crept in our test code.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=6d6185f24f8c3ebade4e22babcd027606a6d3b69
---

 test/libvlc/media_list_player.c |    1 -
 test/libvlc/media_player.c      |   26 ++++++++++++++++++--------
 2 files changed, 18 insertions(+), 9 deletions(-)

diff --git a/test/libvlc/media_list_player.c b/test/libvlc/media_list_player.c
index 5f228de..948e7b2 100644
--- a/test/libvlc/media_list_player.c
+++ b/test/libvlc/media_list_player.c
@@ -52,7 +52,6 @@ static void test_media_list_player_pause_stop(const char** argv, int argc)
     libvlc_media_list_player_set_media_list( mlp, ml, &ex );
 
     libvlc_media_list_player_play_item( mlp, md, &ex );
-    sleep(1); // play is asynchronous
     catch ();
 
     libvlc_media_list_player_pause (mlp, &ex);
diff --git a/test/libvlc/media_player.c b/test/libvlc/media_player.c
index a09a019..54f98cd 100644
--- a/test/libvlc/media_player.c
+++ b/test/libvlc/media_player.c
@@ -47,11 +47,16 @@ static void test_media_player_play_stop(const char** argv, int argc)
     libvlc_media_player_play (mi, &ex);
     catch ();
 
-    /* FIXME: Do something clever */
-    sleep(1);
+    /* Wait a correct state */
+    libvlc_state_t state;
+    do {
+        state = libvlc_media_player_get_state (mi, &ex);
+        catch ();
+    } while( state != libvlc_Playing &&
+             state != libvlc_Error &&
+             state != libvlc_MediaPlayerEndReached );
 
-    assert( libvlc_media_player_get_state (mi, &ex) != libvlc_Error );
-    catch ();
+    assert( state == libvlc_Playing || state == libvlc_MediaPlayerEndReached );
 
     libvlc_media_player_stop (mi, &ex);
     catch ();
@@ -87,11 +92,16 @@ static void test_media_player_pause_stop(const char** argv, int argc)
     libvlc_media_player_play (mi, &ex);
     catch ();
 
-    /* FIXME: Do something clever */
-    sleep(1);
+    /* Wait a correct state */
+    libvlc_state_t state;
+    do {
+        state = libvlc_media_player_get_state (mi, &ex);
+        catch ();
+    } while( state != libvlc_Playing &&
+             state != libvlc_Error &&
+             state != libvlc_MediaPlayerEndReached );
 
-    assert( libvlc_media_player_get_state (mi, &ex) == libvlc_Playing );
-    catch ();
+    assert( state == libvlc_Playing || state == libvlc_MediaPlayerEndReached );
 
     libvlc_media_player_pause (mi, &ex);
     assert( libvlc_media_player_get_state (mi, &ex) == libvlc_Paused );




More information about the vlc-devel mailing list