]> git.sesse.net Git - vlc/commitdiff
libvlc-control smoke test. Feel free to extend
authorRémi Denis-Courmont <rem@videolan.org>
Sat, 20 Oct 2007 10:41:53 +0000 (10:41 +0000)
committerRémi Denis-Courmont <rem@videolan.org>
Sat, 20 Oct 2007 10:41:53 +0000 (10:41 +0000)
src/Makefile.am
src/control/testapi.c [new file with mode: 0644]

index 2f83036f19f5aefec80e4b497f489084861c77fb..58ca6f737c409342101c322a2290aa459f3faaed 100644 (file)
@@ -351,7 +351,7 @@ misc/revision.c:
 ###############################################################################
 # Unit/regression test
 ###############################################################################
-check_PROGRAMS = test_i18n_atof test_url test_utf8
+check_PROGRAMS = test_i18n_atof test_url test_utf8 test_control
 TESTS = $(check_PROGRAMS)
 
 CFLAGS_tests = `$(VLC_CONFIG) --cflags libvlc`
@@ -367,6 +367,10 @@ test_utf8_SOURCES = test/utf8.c
 test_utf8_LDADD = libvlc.la
 test_utf8_CFLAGS = $(CFLAGS_tests)
 
+test_control_SOURCES = control/testapi.c
+test_control_LDADD = libvlc-control.la
+test_control_CFLAGS = $(CFLAGS_tests)
+
 FORCE:
        @echo "Generated source cannot be phony. Go away." >&2
        @exit 1
diff --git a/src/control/testapi.c b/src/control/testapi.c
new file mode 100644 (file)
index 0000000..1dbe03b
--- /dev/null
@@ -0,0 +1,84 @@
+/*
+ * testapi.c - libvlc-control smoke test
+ *
+ * $Id$
+ */
+
+/**********************************************************************
+ *  Copyright (C) 2007 Rémi Denis-Courmont.                           *
+ *  This program is free software; you can redistribute and/or modify *
+ *  it under the terms of the GNU General Public License as published *
+ *  by the Free Software Foundation; version 2 of the license, or (at *
+ *  your option) any later version.                                   *
+ *                                                                    *
+ *  This program is distributed in the hope that it will be useful,   *
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of    *
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.              *
+ *  See the GNU General Public License for more details.              *
+ *                                                                    *
+ *  You should have received a copy of the GNU General Public License *
+ *  along with this program; if not, you can get it from:             *
+ *  http://www.gnu.org/copyleft/gpl.html                              *
+ **********************************************************************/
+
+#include <vlc/mediacontrol.h>
+#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);
+
+    //mediacontrol_exit (mc2);
+
+    /* 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);
+
+    mediacontrol_exception_init (&ex);
+    mediacontrol_stop (mc, NULL, &ex);
+    mediacontrol_exception_cleanup (&ex);
+
+    /* Playlist tests */
+    mediacontrol_exception_init (&ex);
+    mediacontrol_playlist_clear (mc, &ex);
+    assert (!ex.code);
+    mediacontrol_exception_cleanup (&ex);
+
+    mediacontrol_exception_init (&ex);
+    mediacontrol_playlist_add_item (mc, "/dev/null", &ex);
+    mediacontrol_exception_cleanup (&ex);
+
+    mediacontrol_exception_init (&ex);
+    mediacontrol_playlist_clear (mc, &ex);
+    assert (!ex.code);
+    mediacontrol_exception_cleanup (&ex);
+
+    mediacontrol_exit (mc);
+    return 0;
+}