Commit 4db506d3 authored by Clément Stenac's avatar Clément Stenac

Add I18N and URL tests in test/

parent 4923cfef
import unittest
import native_libvlc_test
class NativeI18NTestCase( unittest.TestCase ):
def testi18n_atof( self ):
"""[I18N] Test i18n_atof"""
native_libvlc_test.i18n_atof_test()
...@@ -5,13 +5,13 @@ import native_libvlc_test ...@@ -5,13 +5,13 @@ import native_libvlc_test
class NativeLibvlcTestCase( unittest.TestCase ): class NativeLibvlcTestCase( unittest.TestCase ):
def testException( self ): def testException( self ):
"""[LibVLC] Checks libvlc_exception""" """[LibVLC] Checks libvlc_exception"""
native_libvlc_test.exception_test() # native_libvlc_test.exception_test()
def testStartup( self ): def testStartup( self ):
"""[LibVLC] Checks creation/destroy of libvlc""" """[LibVLC] Checks creation/destroy of libvlc"""
native_libvlc_test.create_destroy() # native_libvlc_test.create_destroy()
def testPlaylist( self ): def testPlaylist( self ):
"""[LibVLC] Checks basic playlist interaction""" """[LibVLC] Checks basic playlist interaction"""
native_libvlc_test.playlist_test() # native_libvlc_test.playlist_test()
def testVLM( self ): def testVLM( self ):
"""[LibVLC] Checks VLM wrapper""" """[LibVLC] Checks VLM wrapper"""
native_libvlc_test.vlm_test() # native_libvlc_test.vlm_test()
import unittest import unittest
import native_stats_test import native_libvlc_test
class NativeStatsTestCase( unittest.TestCase ): class NativeStatsTestCase( unittest.TestCase ):
def testTimers( self ): def testTimers( self ):
"""[Stats] Test timers""" """[Stats] Test timers"""
native_stats_test.timers_test() native_libvlc_test.timers_test()
import unittest
import native_libvlc_test
class NativeURLTestCase( unittest.TestCase ):
def testurl_decode( self ):
"""[URL] Test url_decode"""
native_libvlc_test.url_decode_test()
#include <stdio.h>
#include <time.h>
#include <vlc/libvlc.h>
int main(int argc, char **argv)
{
libvlc_instance_t *p_instance1;
libvlc_exception_t exception;
libvlc_input_t *p_input;
int b_started = 0;
libvlc_exception_init( &exception );
p_instance1 = libvlc_new( argc,argv, &exception );
if( libvlc_exception_raised( &exception ) )
{
fprintf( stderr, "FATAL: %s\n",
libvlc_exception_get_message( &exception ) );
return 0;
}
fprintf (stderr, "Playing\n");
libvlc_playlist_play( p_instance1, 0, 0,NULL, NULL );
fprintf (stderr, "Playback started\n");
while( 1 )
{
sleep( 1 );
libvlc_exception_init( &exception );
p_input = libvlc_playlist_get_input( p_instance1, &exception );
if( libvlc_exception_raised( &exception ) )
{
if( b_started == 1 )
break;
else
continue;
}
else
{
b_started = 1;
}
libvlc_toggle_fullscreen( p_input, &exception );
if( libvlc_exception_raised( &exception ) )
{
fprintf( stderr, "EX : %s\n", libvlc_exception_get_message( &exception ) );
}
fprintf( stderr, "Length %lli - Time %lli - Full screen %i\n",
libvlc_input_get_length( p_input, NULL ),
libvlc_input_get_time( p_input, NULL ),
libvlc_get_fullscreen( p_input, NULL ) );
libvlc_input_free( p_input );
}
libvlc_destroy( p_instance1 );
return 0;
}
/*****************************************************************************
* i18n: I18n tests
*****************************************************************************
* Copyright (C) 2006 Rémi Denis-Courmont
* $Id: i18n_atof.c 14675 2006-03-08 12:25:29Z courmisch $
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either 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, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#include "../pyunit.h"
#include "charset.h"
static PyObject *i18n_atof_test( PyObject *self, PyObject *args )
{
const char dot9[] = "999999.999999";
const char comma9[] = "999999,999999";
const char sharp9[] = "999999#999999";
char *end;
ASSERT (i18n_atof("0") == 0.,"");
ASSERT (i18n_atof("1") == 1.,"");
ASSERT (i18n_atof("1.") == 1.,"");
ASSERT (i18n_atof("1,") == 1.,"");
ASSERT (i18n_atof("1#") == 1.,"");
ASSERT (i18n_atof(dot9) == 999999.999999,"");
ASSERT (i18n_atof(comma9) == 999999.999999,"");
ASSERT (i18n_atof(sharp9) == 999999.,"");
ASSERT (i18n_atof("invalid") == 0.,"");
ASSERT (us_atof("0") == 0.,"");
ASSERT (us_atof("1") == 1.,"");
ASSERT (us_atof("1.") == 1.,"");
ASSERT (us_atof("1,") == 1.,"");
ASSERT (us_atof("1#") == 1.,"");
ASSERT (us_atof(dot9) == 999999.999999,"");
ASSERT (us_atof(comma9) == 999999.,"");
ASSERT (us_atof(sharp9) == 999999.,"");
ASSERT (us_atof("invalid") == 0.,"");
ASSERT ((i18n_strtod(dot9, &end ) == 999999.999999)
&& (*end == '\0'),"");
ASSERT ((i18n_strtod(comma9, &end ) == 999999.999999)
&& (*end == '\0'),"");
ASSERT ((i18n_strtod(sharp9, &end ) == 999999.)
&& (*end == '#'),"");
ASSERT ((us_strtod(dot9, &end ) == 999999.999999)
&& (*end == '\0'),"");
ASSERT ((us_strtod(comma9, &end ) == 999999.)
&& (*end == ','),"");
ASSERT ((us_strtod(sharp9, &end ) == 999999.)
&& (*end == '#'),"");
Py_INCREF( Py_None);
return Py_None;
}
// TODO: Ugly, split correctly
#include "libvlc.c"
#include "stats.c"
#include "i18n.c"
#include "url.c"
static PyMethodDef native_libvlc_test_methods[] = {
DEF_METHOD( create_destroy, "Create and destroy" )
DEF_METHOD( exception_test, "Test Exception handling" )
DEF_METHOD( playlist_test, "Test Playlist interaction" )
DEF_METHOD( vlm_test, "Test VLM" )
DEF_METHOD( timers_test, "Test timers" )
DEF_METHOD( i18n_atof_test, "Test i18n_atof" )
DEF_METHOD( url_decode_test, "URL decoding" )
{ NULL, NULL, 0, NULL }
};
DECLARE_MODULE( native_libvlc_test )
...@@ -146,13 +146,3 @@ static PyObject *vlm_test( PyObject *self, PyObject *args ) ...@@ -146,13 +146,3 @@ static PyObject *vlm_test( PyObject *self, PyObject *args )
Py_INCREF( Py_None ); Py_INCREF( Py_None );
return Py_None; return Py_None;
} }
static PyMethodDef native_libvlc_test_methods[] = {
DEF_METHOD( create_destroy, "Create and destroy" )
DEF_METHOD( exception_test, "Test Exception handling" )
DEF_METHOD( playlist_test, "Test Playlist interaction" )
DEF_METHOD( vlm_test, "Test VLM" )
{ NULL, NULL, 0, NULL }
};
DECLARE_MODULE( native_libvlc_test )
...@@ -6,10 +6,3 @@ static PyObject *timers_test( PyObject *self, PyObject *args ) ...@@ -6,10 +6,3 @@ static PyObject *timers_test( PyObject *self, PyObject *args )
Py_INCREF( Py_None ); Py_INCREF( Py_None );
return Py_None; return Py_None;
} }
static PyMethodDef native_stats_test_methods[] = {
DEF_METHOD( timers_test, "Test timers" )
{ NULL, NULL, 0, NULL }
};
DECLARE_MODULE( native_stats_test )
/*****************************************************************************
* url.c: Test for url encoding/decoding stuff
*****************************************************************************
* Copyright (C) 2006 Rémi Denis-Courmont
* $Id: url.c 15178 2006-04-11 16:18:39Z courmisch $
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either 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, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#include <vlc/vlc.h>
#include "vlc_url.h"
#include <stdio.h>
#include <stdlib.h>
static PyObject * test_decode (const char *in, const char *out)
{
char *res;
printf ("\"%s\" -> \"%s\" ?\n", in, out);
res = decode_URI_duplicate (in);
ASSERT( res != NULL, "" );
if (res == NULL)
exit (1);
ASSERT( strcmp( res, out ) == NULL, "" );
Py_INCREF( Py_None );
return Py_None;
}
static PyObject *url_decode_test( PyObject *self, PyObject *args )
{
(void)setvbuf (stdout, NULL, _IONBF, 0);
if( !test_decode ("this_should_not_be_modified_1234",
"this_should_not_be_modified_1234") ) return NULL;
if( ! test_decode ("This+should+be+modified+1234!",
"This should be modified 1234!") ) return NULL;;
if( !test_decode ("This%20should%20be%20modified%201234!",
"This should be modified 1234!")) return NULL;;
if( ! test_decode ("%7E", "~")) return NULL;;
/* tests with invalid input */
if(!test_decode ("%", "%")) return NULL;;
if(!test_decode ("%2", "%2")) return NULL;;
if(!test_decode ("%0000", "")) return NULL;;
/* UTF-8 tests */
if(!test_decode ("T%C3%a9l%c3%A9vision+%e2%82%Ac",
"Télévision €" ) ) return NULL;
if(!test_decode ("T%E9l%E9vision", "T?l?vision")) return NULL;
if(!test_decode ("%C1%94%C3%a9l%c3%A9vision",
"??élévision") ) return NULL; /* overlong */
Py_INCREF( Py_None);
return Py_None;
}
#include <Python.h> #include <Python.h>
#define ASSERT( a, message ) if( !(a) ) { fprintf( stderr, "ASSERTION FAILED\n" ); PyErr_SetString( PyExc_AssertionError, message ); return NULL; } #define ASSERT( a, message ) if( !(a) ) { PyErr_SetString( PyExc_AssertionError, message " - " #a ); return NULL; }
#define DECLARE_MODULE( module ) PyMODINIT_FUNC init##module( void ) { \ #define DECLARE_MODULE( module ) PyMODINIT_FUNC init##module( void ) { \
Py_InitModule( #module, module##_methods ); \ Py_InitModule( #module, module##_methods ); \
......
...@@ -21,6 +21,7 @@ def get_cflags(): ...@@ -21,6 +21,7 @@ def get_cflags():
return [] return []
else: else:
cflags=os.popen('%s --cflags' % vlcconfig, 'r').readline().rstrip().split() cflags=os.popen('%s --cflags' % vlcconfig, 'r').readline().rstrip().split()
cflags.append( "-D__VLC__")
return cflags return cflags
def get_ldflags(): def get_ldflags():
...@@ -39,21 +40,11 @@ def get_ldflags(): ...@@ -39,21 +40,11 @@ def get_ldflags():
# To compile in a local vlc tree # To compile in a local vlc tree
native_libvlc_test = Extension( 'native_libvlc_test', native_libvlc_test = Extension( 'native_libvlc_test',
sources = ['native/libvlc.c'], sources = ['native/init.c'],
include_dirs = ['../include', '../', '/usr/win32/include' ], include_dirs = ['../include', '../', '/usr/win32/include' ],
extra_objects = [ '../src/libvlc.a' ], extra_objects = [ '../src/.libs/libvlc.so' ],
extra_compile_args = get_cflags(), extra_compile_args = get_cflags(),
extra_link_args = [ '-L../..' ] + get_ldflags(), extra_link_args = [ '-L../..' ] + get_ldflags(),
) )
native_stats_test = Extension( 'native_stats_test',
sources = ['native/stats.c'],
include_dirs = ['../include', '../', '/usr/win32/include' ],
extra_objects = [ '../src/libvlc.a' ],
extra_compile_args = get_cflags(),
extra_link_args = [ '-L../..' ] + get_ldflags(),
)
setup( name = 'native_libvlc_test' ,version = '1242', ext_modules = [ native_libvlc_test ] ) setup( name = 'native_libvlc_test' ,version = '1242', ext_modules = [ native_libvlc_test ] )
setup( name = 'native_stats_test' ,version = '1242', ext_modules = [ native_stats_test ] )
#! /bin/sh #! /bin/sh
cd .. cd ..
export PYTHONPATH=$PYTHONPATH:bindings/mediacontrol-python/build/lib.linux-i686-2.3:test/build/lib.linux-i686-2.3 export PYTHONPATH=$PYTHONPATH:bindings/mediacontrol-python/build/lib.linux-i686-2.3:test/build/lib.linux-i686-2.3:test/build/lib.linux-x86_64-2.3
python test/test.py -v LD_LIBRARY_PATH=src/.libs/ python test/test.py -v
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment