From cc8381508611330f2e5d6971fe4d6637a3e68bfd Mon Sep 17 00:00:00 2001 From: =?utf8?q?R=C3=A9mi=20Denis-Courmont?= Date: Sat, 20 Oct 2007 10:41:53 +0000 Subject: [PATCH] libvlc-control smoke test. Feel free to extend --- src/Makefile.am | 6 +++- src/control/testapi.c | 84 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 89 insertions(+), 1 deletion(-) create mode 100644 src/control/testapi.c diff --git a/src/Makefile.am b/src/Makefile.am index 2f83036f19..58ca6f737c 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -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 index 0000000000..1dbe03b735 --- /dev/null +++ b/src/control/testapi.c @@ -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 +#include + +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; +} -- 2.39.2