]> git.sesse.net Git - vlc/blobdiff - src/control/testapi.c
Switch API smoke test to libvlc API
[vlc] / src / control / testapi.c
index 80cc0e28d8d97db8f4edc45db9f9e6e3a5cf313e..96887baab39762cb5f163a026e981c6872bbdfca 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * testapi.c - libvlc-control smoke test
+ * testapi.c - libvlc smoke test
  *
  * $Id$
  */
  *  http://www.gnu.org/copyleft/gpl.html                              *
  **********************************************************************/
 
-#include <vlc/mediacontrol.h>
+#include <vlc/libvlc.h>
 
 #undef NDEBUG
 #include <assert.h>
 
-int main (int argc, char *argv[])
-{
-    mediacontrol_Exception ex;
-    mediacontrol_Instance *mc, *mc2;
-    libvlc_instance_t *vlc;
-
-    mediacontrol_exception_init (&ex);
-    mc = mediacontrol_new (argc, argv, &ex);
-    assert (mc);
-    assert (!ex.code);
-    mediacontrol_exception_cleanup (&ex);
-
-    /* Duplication test */
-    vlc = mediacontrol_get_libvlc_instance (mc);
-    assert (vlc);
-    assert (!ex.code);
-
-    mediacontrol_exception_init (&ex);
-    mc2 = mediacontrol_new_from_instance (vlc, &ex);
-    assert (mc2);
-    assert (!ex.code);
-    mediacontrol_exception_cleanup (&ex);
+#include <stdio.h>
+#include <stdlib.h>
 
-    //mediacontrol_exit (mc2);
+static libvlc_exception_t ex;
 
-    /* Input tests */
-    mediacontrol_exception_init (&ex);
-    mediacontrol_resume (mc, NULL, &ex);
-    assert (ex.code); /* should fail: we have no input */
-    mediacontrol_exception_cleanup (&ex);
-
-    mediacontrol_exception_init (&ex);
-    mediacontrol_pause (mc, NULL, &ex);
-    assert (ex.code); /* should fail: we have no input */
-    mediacontrol_exception_cleanup (&ex);
+static void catch (void)
+{
+    if (libvlc_exception_raised (&ex))
+    {
+         fprintf (stderr, "Exception: %s\n",
+                  libvlc_exception_get_message (&ex));
+         abort ();
+    }
 
-    mediacontrol_exception_init (&ex);
-    mediacontrol_stop (mc, NULL, &ex);
-    mediacontrol_exception_cleanup (&ex);
+    assert (libvlc_exception_get_message (&ex) == NULL);
+    libvlc_exception_clear (&ex);
+}
 
-    /* Playlist tests */
-    mediacontrol_exception_init (&ex);
-    mediacontrol_playlist_clear (mc, &ex);
-    assert (!ex.code);
-    mediacontrol_exception_cleanup (&ex);
+int main (int argc, char *argv[])
+{
+    libvlc_instance_t *vlc;
+    const char *args[argc + 3];
 
-    mediacontrol_exception_init (&ex);
-    mediacontrol_playlist_add_item (mc, "/dev/null", &ex);
-    mediacontrol_exception_cleanup (&ex);
+    args[0] = "-I";
+    args[1] = "dummy";
+    args[2] = "-vvv";
+    args[3] = "--plugin-path=..";
+    for (int i = 1; i < argc; i++)
+        args[i + 3] = argv[i];
 
-    mediacontrol_exception_init (&ex);
-    mediacontrol_playlist_clear (mc, &ex);
-    assert (!ex.code);
-    mediacontrol_exception_cleanup (&ex);
+    libvlc_exception_init (&ex);
+    vlc = libvlc_new (sizeof (args) / sizeof (args[0]), args, &ex);
+    catch ();
 
-    mediacontrol_exit (mc);
+    libvlc_destroy (vlc, &ex);
+    catch ();
     return 0;
 }