]> git.sesse.net Git - vlc/commitdiff
test: Get rid of the sleep() that crept in our test code.
authorPierre d'Herbemont <pdherbemont@videolan.org>
Fri, 11 Apr 2008 17:11:52 +0000 (19:11 +0200)
committerPierre d'Herbemont <pdherbemont@videolan.org>
Fri, 11 Apr 2008 17:11:52 +0000 (19:11 +0200)
test/libvlc/media_list_player.c
test/libvlc/media_player.c

index 5f228de0d9a01beb3eb77e35b706030012d6a6cb..948e7b25e91f501cffebcac6be1351b03b4c9330 100644 (file)
@@ -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);
index a09a0192be6f932fb4493b7f42118dabf082e16b..54f98cdeaae891ad730e7fd05ce16543cdfb1b05 100644 (file)
@@ -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 );