[vlc-devel] commit: libvlc: Add a test for media_player_set_media(). (Pierre d' Herbemont )

git version control git at videolan.org
Thu Feb 18 15:49:47 CET 2010


vlc | branch: master | Pierre d'Herbemont <pdherbemont at free.fr> | Thu Feb 18 15:49:25 2010 +0100| [82c5d9de7635a9be6235a9273ed66d300c7950ed] | committer: Pierre d'Herbemont 

libvlc: Add a test for media_player_set_media().

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

 test/libvlc/media_player.c |   39 ++++++++++++++++++++++++++++++++++++++-
 1 files changed, 38 insertions(+), 1 deletions(-)

diff --git a/test/libvlc/media_player.c b/test/libvlc/media_player.c
index 8df6b10..a843b65 100644
--- a/test/libvlc/media_player.c
+++ b/test/libvlc/media_player.c
@@ -23,6 +23,42 @@
 
 #include "test.h"
 
+static void test_media_player_set_media(const char** argv, int argc)
+{
+    const char * file = test_default_sample;
+
+    log ("Testing set_media\n");
+
+    libvlc_instance_t *vlc = libvlc_new (argc, argv);
+    assert (vlc != NULL);
+
+    libvlc_media_t *md = libvlc_media_new (vlc, file);
+    assert (md != NULL);
+
+    libvlc_media_player_t *mp = libvlc_media_player_new (vlc);
+    assert (mp != NULL);
+
+    libvlc_media_player_set_media (mp, md);
+
+    libvlc_media_release (md);
+
+    libvlc_media_player_play (mp);
+
+    /* Wait a correct state */
+    libvlc_state_t state;
+    do {
+        state = libvlc_media_player_get_state (mp);
+    } while(state != libvlc_Playing &&
+            state != libvlc_Error &&
+            state != libvlc_Ended );
+
+    assert(state == libvlc_Playing || state == libvlc_Ended);
+
+    libvlc_media_player_stop (mp);
+    libvlc_media_player_release (mp);
+    libvlc_release (vlc);
+}
+
 static void test_media_player_play_stop(const char** argv, int argc)
 {
     libvlc_instance_t *vlc;
@@ -110,7 +146,7 @@ static void test_media_player_pause_stop(const char** argv, int argc)
 
     assert( state == libvlc_Paused || state == libvlc_Ended );
 #endif
-    
+
     libvlc_media_player_stop (mi);
     libvlc_media_player_release (mi);
     libvlc_release (vlc);
@@ -121,6 +157,7 @@ int main (void)
 {
     test_init();
 
+    test_media_player_set_media (test_defaults_args, test_defaults_nargs);
     test_media_player_play_stop (test_defaults_args, test_defaults_nargs);
     test_media_player_pause_stop (test_defaults_args, test_defaults_nargs);
 




More information about the vlc-devel mailing list