Commit 6d6185f2 authored by Pierre d'Herbemont's avatar Pierre d'Herbemont

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

parent 35dc9b31
...@@ -52,7 +52,6 @@ static void test_media_list_player_pause_stop(const char** argv, int argc) ...@@ -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_set_media_list( mlp, ml, &ex );
libvlc_media_list_player_play_item( mlp, md, &ex ); libvlc_media_list_player_play_item( mlp, md, &ex );
sleep(1); // play is asynchronous
catch (); catch ();
libvlc_media_list_player_pause (mlp, &ex); libvlc_media_list_player_pause (mlp, &ex);
......
...@@ -47,11 +47,16 @@ static void test_media_player_play_stop(const char** argv, int argc) ...@@ -47,11 +47,16 @@ static void test_media_player_play_stop(const char** argv, int argc)
libvlc_media_player_play (mi, &ex); libvlc_media_player_play (mi, &ex);
catch (); catch ();
/* FIXME: Do something clever */ /* Wait a correct state */
sleep(1); 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 ); assert( state == libvlc_Playing || state == libvlc_MediaPlayerEndReached );
catch ();
libvlc_media_player_stop (mi, &ex); libvlc_media_player_stop (mi, &ex);
catch (); catch ();
...@@ -87,11 +92,16 @@ static void test_media_player_pause_stop(const char** argv, int argc) ...@@ -87,11 +92,16 @@ static void test_media_player_pause_stop(const char** argv, int argc)
libvlc_media_player_play (mi, &ex); libvlc_media_player_play (mi, &ex);
catch (); catch ();
/* FIXME: Do something clever */ /* Wait a correct state */
sleep(1); 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 ); assert( state == libvlc_Playing || state == libvlc_MediaPlayerEndReached );
catch ();
libvlc_media_player_pause (mi, &ex); libvlc_media_player_pause (mi, &ex);
assert( libvlc_media_player_get_state (mi, &ex) == libvlc_Paused ); assert( libvlc_media_player_get_state (mi, &ex) == libvlc_Paused );
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment