[svn r689] Added new test case to TV Chain; put back the testing scripts configuration file. trunk
authorrosfran
Thu May 17 15:43:02 2007 +0100 (2007-05-17)
branchtrunk
changeset 6834a784466828d
parent 682 367d791aeb57
child 684 cabd7221c449
[svn r689] Added new test case to TV Chain; put back the testing scripts configuration file.
gmyth/tests/Makefile.am
gmyth/tests/gmyth_test_tvchain.c
gmyth/tests/test_scripts.cfg
gmyth/tests/test_tvchain.py
     1.1 --- a/gmyth/tests/Makefile.am	Thu May 17 14:07:27 2007 +0100
     1.2 +++ b/gmyth/tests/Makefile.am	Thu May 17 15:43:02 2007 +0100
     1.3 @@ -30,7 +30,8 @@
     1.4  	gmyth_test_file_download \
     1.5  	gmyth_test_program_info \
     1.6  	gmyth_test_monitor_handler \
     1.7 -	gmyth_test_stringlist
     1.8 +	gmyth_test_stringlist \
     1.9 +	gmyth_test_tvchain
    1.10  
    1.11  TESTS = \
    1.12  	relink.py \
    1.13 @@ -49,7 +50,8 @@
    1.14  	test_livetv_stress.py \
    1.15  	test_program_info.py \
    1.16  	test_monitor_handler.py \
    1.17 -	test_stringlist.py
    1.18 +	test_stringlist.py \
    1.19 +	test_tvchain.py
    1.20  
    1.21  if HAVE_GENHTML
    1.22  TESTS += \
    1.23 @@ -97,12 +99,15 @@
    1.24  gmyth_test_program_info_SOURCES = \
    1.25  	gmyth_test_program_info.c
    1.26  
    1.27 -gmyth_test_monitor_handlerSOURCES = \
    1.28 +gmyth_test_monitor_handler_SOURCES = \
    1.29  	gmyth_test_monitor_handler.c
    1.30  
    1.31  gmyth_test_stringlist_SOURCES = \
    1.32  	gmyth_test_stringlist.c
    1.33  
    1.34 +gmyth_test_tvchain_SOURCES = \
    1.35 +	gmyth_test_tvchain.c
    1.36 +
    1.37  CLEANFILES = $(BUILT_SOURCES)
    1.38  
    1.39  if HAVE_GCOV
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/gmyth/tests/gmyth_test_tvchain.c	Thu May 17 15:43:02 2007 +0100
     2.3 @@ -0,0 +1,142 @@
     2.4 +#include <glib-object.h>
     2.5 +
     2.6 +#include "common.h"
     2.7 +
     2.8 +#include <gmyth/gmyth_uri.h>
     2.9 +#include <gmyth/gmyth_backendinfo.h>
    2.10 +#include <gmyth/gmyth_livetv.h>
    2.11 +#include <gmyth/gmyth_file.h>
    2.12 +#include <gmyth/gmyth_file_transfer.h>
    2.13 +#include <gmyth/gmyth_file_local.h>
    2.14 +#include <gmyth/gmyth_common.h>
    2.15 +
    2.16 +#define URI_DEFAULT	"myth://192.168.3.165:6543/livetv?channel=9"
    2.17 +
    2.18 +static gboolean
    2.19 +test_tvchain_setup ( gchar *uri )
    2.20 +{
    2.21 +  GMythTVChain *tvchain = NULL;
    2.22 +  gchar *channel = NULL;
    2.23 +  gboolean ret = TRUE;
    2.24 +  
    2.25 +  if ( NULL == uri )
    2.26 +    uri = g_strdup( URI_DEFAULT );
    2.27 +
    2.28 +  GMythURI *gmyth_uri = gmyth_uri_new_with_value( uri );
    2.29 +
    2.30 +  GMythBackendInfo* backend_info = gmyth_backend_info_new_with_uri (uri);
    2.31 +  
    2.32 +  channel = gmyth_uri_get_channel_name( gmyth_uri );
    2.33 +
    2.34 +  /* Creates livetv chain handler */
    2.35 +  tvchain = gmyth_tvchain_new ();
    2.36 +  gmyth_tvchain_initialize (tvchain, backend_info);
    2.37 +
    2.38 +  if (tvchain == NULL || tvchain->tvchain_id == NULL)
    2.39 +  {
    2.40 +    ret = FALSE;
    2.41 +    goto init_failed;
    2.42 +  }
    2.43 +
    2.44 +  ret = ( gmyth_tvchain_get_id (tvchain) != NULL );
    2.45 +  if (!ret)
    2.46 +  {
    2.47 +    g_debug ("[%s] TV Chain ID is NULL.\n", __FUNCTION__);
    2.48 +    goto init_failed;
    2.49 +  }
    2.50 +
    2.51 +  gmyth_backend_info_set_username (tvchain->backend_info,
    2.52 +		  "mythtv");
    2.53 +  gmyth_backend_info_set_password (tvchain->backend_info,
    2.54 +		  "mythtv");
    2.55 +  gmyth_backend_info_set_db_name (tvchain->backend_info,
    2.56 +		  "mythconverg");
    2.57 +  GList *prog_list =
    2.58 +	  gmyth_tvchain_get_program_info_from_channel (tvchain,
    2.59 +			  channel);
    2.60 +  GMythProgramInfo *ch_prog = NULL;
    2.61 +  if (prog_list != NULL && g_list_length (prog_list) > 0)
    2.62 +  {
    2.63 +	  ch_prog = (GMythProgramInfo *) g_list_nth_data (prog_list, 0);
    2.64 +	  g_debug ("Channel program info (from a list with size = %d)!",
    2.65 +			  g_list_length (prog_list));
    2.66 +	  gmyth_program_info_print (ch_prog);
    2.67 +  }
    2.68 +
    2.69 +  g_debug ("Program Info: %s\n",
    2.70 +		  gmyth_program_info_to_string (ch_prog));
    2.71 +  
    2.72 +  /* Reload all TV chain from Mysql database. */
    2.73 +  gmyth_tvchain_reload_all (tvchain);
    2.74 +
    2.75 +  if (tvchain == NULL)
    2.76 +  {
    2.77 +	  ret = FALSE;
    2.78 +	  goto init_failed;
    2.79 +  }
    2.80 +
    2.81 +  /* Get program info from database using chanid and starttime */
    2.82 +  ch_prog = gmyth_tvchain_get_program_at (tvchain, 0);
    2.83 +  if (NULL == ch_prog)
    2.84 +  {
    2.85 +	  g_debug ("TVChain not successfully started.\n");
    2.86 +	  ret = FALSE;
    2.87 +	  goto init_failed;
    2.88 +  }
    2.89 +  else
    2.90 +  {
    2.91 +	  ret = TRUE;
    2.92 +	  g_debug
    2.93 +		  ("GMythTVChain: All requests to backend to start TV were OK. [%s]\n",
    2.94 +		   ch_prog->pathname->str);
    2.95 +  }
    2.96 +
    2.97 +
    2.98 +init_failed:
    2.99 +    if ( tvchain != NULL )
   2.100 +        g_object_unref(tvchain);
   2.101 + 
   2.102 +    if ( gmyth_uri != NULL )
   2.103 +        g_object_unref( gmyth_uri );
   2.104 +
   2.105 +    if ( ch_prog != NULL )
   2.106 +       g_object_unref( ch_prog );
   2.107 +
   2.108 +    if ( prog_list != NULL )
   2.109 +       g_list_free( prog_list );
   2.110 +
   2.111 +    if ( backend_info != NULL )
   2.112 +       g_object_unref( backend_info );
   2.113 +
   2.114 +    return ret;
   2.115 +    
   2.116 +}
   2.117 +
   2.118 +gint
   2.119 +main (gint args, const gchar **argv)
   2.120 +{
   2.121 +    gboolean ret;
   2.122 +
   2.123 +    g_type_init ();
   2.124 +    g_thread_init (NULL);
   2.125 +
   2.126 +    fprintf(stdout, SYNC_STRING);
   2.127 +    fflush(NULL);
   2.128 +    getchar();
   2.129 +    
   2.130 +    if ( args > 1 )
   2.131 +	ret = test_tvchain_setup ( argv[1] );
   2.132 +    else
   2.133 +    	ret = test_tvchain_setup ( NULL );
   2.134 +    
   2.135 +    if ( !ret )
   2.136 +        g_debug ("Error when running TV Chain setup test script!");
   2.137 +    else
   2.138 +        g_debug ("TV Chain setup test script finished with success.");
   2.139 +
   2.140 +    return(0);
   2.141 +}
   2.142 +
   2.143 +
   2.144 +
   2.145 +
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/gmyth/tests/test_scripts.cfg	Thu May 17 15:43:02 2007 +0100
     3.3 @@ -0,0 +1,10 @@
     3.4 +[GMyth Test Scripts Config]
     3.5 +host = 192.168.3.110
     3.6 +port = 6543
     3.7 +filename = 1004_20070510161500.nuv
     3.8 +user = mythtv
     3.9 +password = mythtv
    3.10 +database = mythconverg
    3.11 +filename = 1004_20070510161500.nuv
    3.12 +channel = 1
    3.13 +
     4.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.2 +++ b/gmyth/tests/test_tvchain.py	Thu May 17 15:43:02 2007 +0100
     4.3 @@ -0,0 +1,14 @@
     4.4 +#!/usr/bin/python
     4.5 +
     4.6 +#doc: test gmyth_epg_* methods
     4.7 +
     4.8 +from testing_tools import start, finish
     4.9 +import sys
    4.10 +from utils import TestConfigFile
    4.11 +
    4.12 +cfg_file = TestConfigFile('test_scripts.cfg')
    4.13 +
    4.14 +p = start('gmyth_test_tvchain', ["myth://%s:%s@%s:%s/?%s" % ( cfg_file.get_db_user(), cfg_file.get_db_passwd(), \
    4.15 +	cfg_file.get_host(), cfg_file.get_port(), cfg_file.get_db_name() )], 2)
    4.16 +
    4.17 +sys.exit(finish(p))