]> git.sesse.net Git - vlc/commitdiff
media_list_player test: attempt at fixing test
authorRafaël Carré <rafael.carre@gmail.com>
Mon, 18 Jan 2010 08:06:49 +0000 (09:06 +0100)
committerRafaël Carré <rafael.carre@gmail.com>
Mon, 18 Jan 2010 08:09:11 +0000 (09:09 +0100)
Replace arbitrary sleep delays by active waiting of state change
Add state change wait where needed (after play()/next()/previous())

test/libvlc/media_list_player.c

index 3f625f6afe627df20ea5a857493614e5f3bfdb7f..870875f6d360ab74d13f61e7c95186aa712e2060 100644 (file)
@@ -198,29 +198,35 @@ static void test_media_list_player_previous(const char** argv, int argc)
     libvlc_media_list_player_play_item (mlp, md, &ex);
     catch ();
 
-    libvlc_media_release (md);
+    while (!libvlc_media_list_player_is_playing (mlp, &ex))
+        catch() ;
 
-    msleep(100000);
+    libvlc_media_release (md);
 
     libvlc_media_list_player_previous (mlp, &ex);
     catch ();
 
+    while (!libvlc_media_list_player_is_playing (mlp, &ex))
+        catch() ;
+
     libvlc_media_list_player_pause (mlp, &ex);
     catch();
 
-    msleep(100000);
-
     libvlc_media_list_player_previous (mlp, &ex);
     catch ();
 
+    while (!libvlc_media_list_player_is_playing (mlp, &ex))
+        catch() ;
+
     libvlc_media_list_player_stop (mlp, &ex);
     catch ();
 
-    msleep(100000);
-
     libvlc_media_list_player_previous (mlp, &ex);
     catch ();
 
+    while (!libvlc_media_list_player_is_playing (mlp, &ex))
+        catch() ;
+
     libvlc_media_list_player_stop (mlp, &ex);
     catch ();
 
@@ -270,27 +276,33 @@ static void test_media_list_player_next(const char** argv, int argc)
 
     libvlc_media_release (md);
 
-    msleep(100000);
+    while (!libvlc_media_list_player_is_playing (mlp, &ex))
+        catch() ;
 
     libvlc_media_list_player_next (mlp, &ex);
     catch ();
 
+    while (!libvlc_media_list_player_is_playing (mlp, &ex))
+        catch() ;
+
     libvlc_media_list_player_pause (mlp, &ex);
     catch();
 
-    msleep(100000);
-
     libvlc_media_list_player_next (mlp, &ex);
     catch ();
 
+    while (!libvlc_media_list_player_is_playing (mlp, &ex))
+        catch() ;
+
     libvlc_media_list_player_stop (mlp, &ex);
     catch ();
 
-    msleep(100000);
-
     libvlc_media_list_player_next (mlp, &ex);
     catch ();
 
+    while (!libvlc_media_list_player_is_playing (mlp, &ex))
+        catch() ;
+
     libvlc_media_list_player_stop (mlp, &ex);
     catch ();
 
@@ -332,6 +344,9 @@ static void test_media_list_player_pause_stop(const char** argv, int argc)
     libvlc_media_list_player_play_item( mlp, md, &ex );
     catch ();
 
+    while (!libvlc_media_list_player_is_playing (mlp, &ex))
+        catch() ;
+
     libvlc_media_list_player_pause (mlp, &ex);
     catch();
 
@@ -381,6 +396,9 @@ static void test_media_list_player_play_item_at_index(const char** argv, int arg
     libvlc_media_list_player_play_item_at_index( mlp, 0, &ex );
     catch ();
 
+    while (!libvlc_media_list_player_is_playing (mlp, &ex))
+        catch() ;
+
     libvlc_media_list_player_stop (mlp, &ex);
     catch ();
 
@@ -513,6 +531,9 @@ static void test_media_list_player_playback_options (const char** argv, int argc
     libvlc_media_list_player_play_item (mlp, md, &ex);
     catch ();
 
+    while (!libvlc_media_list_player_is_playing (mlp, &ex))
+        catch() ;
+
     libvlc_media_release (md);
     catch ();
     libvlc_media_release (md2);
@@ -524,8 +545,6 @@ static void test_media_list_player_playback_options (const char** argv, int argc
     libvlc_media_release (md5);
     catch ();
 
-    msleep(500000);
-
     libvlc_media_list_player_stop (mlp, &ex);
     catch ();
 
@@ -537,7 +556,8 @@ static void test_media_list_player_playback_options (const char** argv, int argc
     libvlc_media_list_player_play_item (mlp, md, &ex);
     catch ();
 
-    msleep(500000);
+    while (!libvlc_media_list_player_is_playing (mlp, &ex))
+        catch() ;
 
     libvlc_media_list_player_stop (mlp, &ex);
     catch ();
@@ -550,7 +570,8 @@ static void test_media_list_player_playback_options (const char** argv, int argc
     libvlc_media_list_player_play_item (mlp, md, &ex);
     catch ();
 
-    msleep(500000);
+    while (!libvlc_media_list_player_is_playing (mlp, &ex))
+        catch() ;
 
     libvlc_media_list_player_stop (mlp, &ex);
     catch ();