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

git version control git at videolan.org
Thu May 21 08:35:04 CEST 2009


vlc | branch: master | Pierre d'Herbemont <pdherbemont at free.fr> | Wed May 20 23:34:03 2009 -0700| [f5a9539f55495ab279eda9938b9db8ed9963a1ba] | committer: Pierre d'Herbemont 

test: Add a test for media_player_next().

Doesn't work because variables callback can't be removed from their own callbacks.
Some work will be required here.

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

 test/libvlc/media_list_player.c |   81 +++++++++++++++++++++++++++++++++++++++
 1 files changed, 81 insertions(+), 0 deletions(-)

diff --git a/test/libvlc/media_list_player.c b/test/libvlc/media_list_player.c
index 5ae0c27..fbc67bf 100644
--- a/test/libvlc/media_list_player.c
+++ b/test/libvlc/media_list_player.c
@@ -23,6 +23,84 @@
 
 #include "test.h"
 
+static void media_list_add_file_path(libvlc_instance_t *vlc, libvlc_media_list_t *ml, const char * file_path)
+{
+    libvlc_media_t *md = libvlc_media_new (vlc, file_path, &ex);
+    catch ();
+
+    libvlc_media_list_add_media (ml, md, &ex);
+    catch ();
+
+    libvlc_media_release (md);
+}
+
+static void test_media_list_player_next(const char** argv, int argc)
+{
+    libvlc_instance_t *vlc;
+    libvlc_media_t *md;
+    libvlc_media_list_t *ml;
+    libvlc_media_list_player_t *mlp;
+    
+    const char * file = test_default_sample;
+    
+    log ("Testing media player next()\n");
+    
+    libvlc_exception_init (&ex);
+    vlc = libvlc_new (argc, argv, &ex);
+    catch ();
+    
+    md = libvlc_media_new (vlc, file, &ex);
+    catch ();
+    
+    ml = libvlc_media_list_new (vlc, &ex);
+    catch ();
+    
+    mlp = libvlc_media_list_player_new (vlc, &ex);
+    catch ();
+
+    libvlc_media_list_add_media (ml, md, &ex);
+    catch ();
+
+    // Add three media
+    media_list_add_file_path (vlc, ml, file);
+    media_list_add_file_path (vlc, ml, file);
+    media_list_add_file_path (vlc, ml, file);
+
+    libvlc_media_list_player_set_media_list (mlp, ml, &ex);
+    
+    libvlc_media_list_player_play_item (mlp, md, &ex);
+    catch ();
+
+    libvlc_media_release (md);
+
+    usleep(500000);
+    
+    libvlc_media_list_player_next (mlp, &ex);
+    catch ();
+
+    libvlc_media_list_player_pause (mlp, &ex);
+    catch();
+
+    usleep(500000);
+    
+    libvlc_media_list_player_next (mlp, &ex);
+    catch ();
+    
+    libvlc_media_list_player_stop (mlp, &ex);
+    catch ();
+
+    usleep(500000);
+    
+    libvlc_media_list_player_next (mlp, &ex);
+    catch ();
+        
+    libvlc_media_list_player_release (mlp);
+    catch ();
+    
+    libvlc_release (vlc);
+    catch ();
+}
+
 static void test_media_list_player_pause_stop(const char** argv, int argc)
 {
     libvlc_instance_t *vlc;
@@ -120,5 +198,8 @@ int main (void)
 
     test_media_list_player_pause_stop (test_defaults_args, test_defaults_nargs);
     test_media_list_player_play_item_at_index (test_defaults_args, test_defaults_nargs);
+    if(0) // Core hangs here, because it doesn't support callback removal from callbacks (variable)
+        test_media_list_player_next (test_defaults_args, test_defaults_nargs);
+
     return 0;
 }




More information about the vlc-devel mailing list