1
mirror of https://code.videolan.org/videolan/vlc synced 2024-10-03 01:31:53 +02:00

Switch API smoke test to libvlc API

This commit is contained in:
Rémi Denis-Courmont 2007-10-21 08:09:02 +00:00
parent 4a2ded0bad
commit 508d87e61d
3 changed files with 35 additions and 54 deletions

View File

@ -107,7 +107,8 @@ libvlc_exception_get_message( const libvlc_exception_t *p_exception );
* \param argv command-line-type arguments
* \param exception an initialized exception pointer
*/
VLC_PUBLIC_API libvlc_instance_t * libvlc_new( int , char **, libvlc_exception_t *);
VLC_PUBLIC_API libvlc_instance_t *
libvlc_new( int , const char *const *, libvlc_exception_t *);
/**
* Returns a libvlc instance identifier for legacy APIs. Use of this

View File

@ -79,7 +79,7 @@ void libvlc_exception_raise( libvlc_exception_t *p_exception,
p_exception->b_raised = 1;
}
libvlc_instance_t * libvlc_new( int argc, char **argv,
libvlc_instance_t * libvlc_new( int argc, const char *const *argv,
libvlc_exception_t *p_e )
{
libvlc_instance_t *p_new;

View File

@ -1,5 +1,5 @@
/*
* testapi.c - libvlc-control smoke test
* testapi.c - libvlc smoke test
*
* $Id$
*/
@ -21,66 +21,46 @@
* http://www.gnu.org/copyleft/gpl.html *
**********************************************************************/
#include <vlc/mediacontrol.h>
#include <vlc/libvlc.h>
#undef NDEBUG
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
static libvlc_exception_t ex;
static void catch (void)
{
if (libvlc_exception_raised (&ex))
{
fprintf (stderr, "Exception: %s\n",
libvlc_exception_get_message (&ex));
abort ();
}
assert (libvlc_exception_get_message (&ex) == NULL);
libvlc_exception_clear (&ex);
}
int main (int argc, char *argv[])
{
mediacontrol_Exception ex;
mediacontrol_Instance *mc, *mc2;
libvlc_instance_t *vlc;
const char *args[argc + 3];
mediacontrol_exception_init (&ex);
mc = mediacontrol_new (argc, argv, &ex);
assert (mc);
assert (!ex.code);
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];
/* Duplication test */
vlc = mediacontrol_get_libvlc_instance (mc);
assert (vlc);
assert (!ex.code);
libvlc_exception_init (&ex);
vlc = libvlc_new (sizeof (args) / sizeof (args[0]), args, &ex);
catch ();
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);
libvlc_destroy (vlc, &ex);
catch ();
return 0;
}