gmyth/tests/gmyth_test_tvchain.c
branchtrunk
changeset 750 312d6bc514f3
parent 683 4a784466828d
child 754 cb885ee44618
     1.1 --- a/gmyth/tests/gmyth_test_tvchain.c	Thu May 17 15:43:02 2007 +0100
     1.2 +++ b/gmyth/tests/gmyth_test_tvchain.c	Thu Jun 14 18:19:52 2007 +0100
     1.3 @@ -13,130 +13,121 @@
     1.4  #define URI_DEFAULT	"myth://192.168.3.165:6543/livetv?channel=9"
     1.5  
     1.6  static gboolean
     1.7 -test_tvchain_setup ( gchar *uri )
     1.8 +test_tvchain_setup(gchar * uri)
     1.9  {
    1.10    GMythTVChain *tvchain = NULL;
    1.11    gchar *channel = NULL;
    1.12    gboolean ret = TRUE;
    1.13 -  
    1.14 -  if ( NULL == uri )
    1.15 -    uri = g_strdup( URI_DEFAULT );
    1.16  
    1.17 -  GMythURI *gmyth_uri = gmyth_uri_new_with_value( uri );
    1.18 +  if (NULL == uri)
    1.19 +	uri = g_strdup(URI_DEFAULT);
    1.20  
    1.21 -  GMythBackendInfo* backend_info = gmyth_backend_info_new_with_uri (uri);
    1.22 -  
    1.23 -  channel = gmyth_uri_get_channel_name( gmyth_uri );
    1.24 +  GMythURI *gmyth_uri = gmyth_uri_new_with_value(uri);
    1.25 +
    1.26 +  GMythBackendInfo *backend_info = gmyth_backend_info_new_with_uri(uri);
    1.27 +
    1.28 +  channel = gmyth_uri_get_channel_name(gmyth_uri);
    1.29  
    1.30    /* Creates livetv chain handler */
    1.31 -  tvchain = gmyth_tvchain_new ();
    1.32 -  gmyth_tvchain_initialize (tvchain, backend_info);
    1.33 +  tvchain = gmyth_tvchain_new();
    1.34 +  gmyth_tvchain_initialize(tvchain, backend_info);
    1.35  
    1.36    if (tvchain == NULL || tvchain->tvchain_id == NULL)
    1.37 -  {
    1.38 -    ret = FALSE;
    1.39 -    goto init_failed;
    1.40 -  }
    1.41 +	{
    1.42 +	  ret = FALSE;
    1.43 +	  goto init_failed;
    1.44 +	}
    1.45  
    1.46 -  ret = ( gmyth_tvchain_get_id (tvchain) != NULL );
    1.47 +  ret = (gmyth_tvchain_get_id(tvchain) != NULL);
    1.48    if (!ret)
    1.49 -  {
    1.50 -    g_debug ("[%s] TV Chain ID is NULL.\n", __FUNCTION__);
    1.51 -    goto init_failed;
    1.52 -  }
    1.53 +	{
    1.54 +	  g_debug("[%s] TV Chain ID is NULL.\n", __FUNCTION__);
    1.55 +	  goto init_failed;
    1.56 +	}
    1.57  
    1.58 -  gmyth_backend_info_set_username (tvchain->backend_info,
    1.59 -		  "mythtv");
    1.60 -  gmyth_backend_info_set_password (tvchain->backend_info,
    1.61 -		  "mythtv");
    1.62 -  gmyth_backend_info_set_db_name (tvchain->backend_info,
    1.63 -		  "mythconverg");
    1.64 -  GList *prog_list =
    1.65 -	  gmyth_tvchain_get_program_info_from_channel (tvchain,
    1.66 -			  channel);
    1.67 +  gmyth_backend_info_set_username(tvchain->backend_info, "mythtv");
    1.68 +  gmyth_backend_info_set_password(tvchain->backend_info, "mythtv");
    1.69 +  gmyth_backend_info_set_db_name(tvchain->backend_info, "mythconverg");
    1.70 +  GList *prog_list = gmyth_tvchain_get_program_info_from_channel(tvchain,
    1.71 +																 channel);
    1.72    GMythProgramInfo *ch_prog = NULL;
    1.73 -  if (prog_list != NULL && g_list_length (prog_list) > 0)
    1.74 -  {
    1.75 -	  ch_prog = (GMythProgramInfo *) g_list_nth_data (prog_list, 0);
    1.76 -	  g_debug ("Channel program info (from a list with size = %d)!",
    1.77 -			  g_list_length (prog_list));
    1.78 -	  gmyth_program_info_print (ch_prog);
    1.79 -  }
    1.80 +  if (prog_list != NULL && g_list_length(prog_list) > 0)
    1.81 +	{
    1.82 +	  ch_prog = (GMythProgramInfo *) g_list_nth_data(prog_list, 0);
    1.83 +	  g_debug("Channel program info (from a list with size = %d)!",
    1.84 +			  g_list_length(prog_list));
    1.85 +	  gmyth_program_info_print(ch_prog);
    1.86 +	}
    1.87  
    1.88 -  g_debug ("Program Info: %s\n",
    1.89 -		  gmyth_program_info_to_string (ch_prog));
    1.90 -  
    1.91 +  g_debug("Program Info: %s\n", gmyth_program_info_to_string(ch_prog));
    1.92 +
    1.93    /* Reload all TV chain from Mysql database. */
    1.94 -  gmyth_tvchain_reload_all (tvchain);
    1.95 +  gmyth_tvchain_reload_all(tvchain);
    1.96  
    1.97    if (tvchain == NULL)
    1.98 -  {
    1.99 +	{
   1.100  	  ret = FALSE;
   1.101  	  goto init_failed;
   1.102 -  }
   1.103 +	}
   1.104  
   1.105    /* Get program info from database using chanid and starttime */
   1.106 -  ch_prog = gmyth_tvchain_get_program_at (tvchain, 0);
   1.107 +  ch_prog = gmyth_tvchain_get_program_at(tvchain, 0);
   1.108    if (NULL == ch_prog)
   1.109 -  {
   1.110 -	  g_debug ("TVChain not successfully started.\n");
   1.111 +	{
   1.112 +	  g_debug("TVChain not successfully started.\n");
   1.113  	  ret = FALSE;
   1.114  	  goto init_failed;
   1.115 -  }
   1.116 +	}
   1.117    else
   1.118 -  {
   1.119 +	{
   1.120  	  ret = TRUE;
   1.121  	  g_debug
   1.122 -		  ("GMythTVChain: All requests to backend to start TV were OK. [%s]\n",
   1.123 -		   ch_prog->pathname->str);
   1.124 -  }
   1.125 +		("GMythTVChain: All requests to backend to start TV were OK. [%s]\n",
   1.126 +		 ch_prog->pathname->str);
   1.127 +	}
   1.128  
   1.129  
   1.130  init_failed:
   1.131 -    if ( tvchain != NULL )
   1.132 -        g_object_unref(tvchain);
   1.133 - 
   1.134 -    if ( gmyth_uri != NULL )
   1.135 -        g_object_unref( gmyth_uri );
   1.136 +  if (tvchain != NULL)
   1.137 +	g_object_unref(tvchain);
   1.138  
   1.139 -    if ( ch_prog != NULL )
   1.140 -       g_object_unref( ch_prog );
   1.141 +  if (gmyth_uri != NULL)
   1.142 +	g_object_unref(gmyth_uri);
   1.143  
   1.144 -    if ( prog_list != NULL )
   1.145 -       g_list_free( prog_list );
   1.146 +  if (ch_prog != NULL)
   1.147 +	g_object_unref(ch_prog);
   1.148  
   1.149 -    if ( backend_info != NULL )
   1.150 -       g_object_unref( backend_info );
   1.151 +  if (prog_list != NULL)
   1.152 +	g_list_free(prog_list);
   1.153  
   1.154 -    return ret;
   1.155 -    
   1.156 +  if (backend_info != NULL)
   1.157 +	g_object_unref(backend_info);
   1.158 +
   1.159 +  return ret;
   1.160 +
   1.161  }
   1.162  
   1.163  gint
   1.164 -main (gint args, const gchar **argv)
   1.165 +main(gint args, const gchar ** argv)
   1.166  {
   1.167 -    gboolean ret;
   1.168 +  gboolean ret;
   1.169  
   1.170 -    g_type_init ();
   1.171 -    g_thread_init (NULL);
   1.172 +  g_type_init();
   1.173 +  g_thread_init(NULL);
   1.174  
   1.175 -    fprintf(stdout, SYNC_STRING);
   1.176 -    fflush(NULL);
   1.177 -    getchar();
   1.178 -    
   1.179 -    if ( args > 1 )
   1.180 -	ret = test_tvchain_setup ( argv[1] );
   1.181 -    else
   1.182 -    	ret = test_tvchain_setup ( NULL );
   1.183 -    
   1.184 -    if ( !ret )
   1.185 -        g_debug ("Error when running TV Chain setup test script!");
   1.186 -    else
   1.187 -        g_debug ("TV Chain setup test script finished with success.");
   1.188 +  fprintf(stdout, SYNC_STRING);
   1.189 +  fflush(NULL);
   1.190 +  getchar();
   1.191  
   1.192 -    return(0);
   1.193 +  if (args > 1)
   1.194 +	ret = test_tvchain_setup(argv[1]);
   1.195 +  else
   1.196 +	ret = test_tvchain_setup(NULL);
   1.197 +
   1.198 +  if (!ret)
   1.199 +	g_debug("Error when running TV Chain setup test script!");
   1.200 +  else
   1.201 +	g_debug("TV Chain setup test script finished with success.");
   1.202 +
   1.203 +  return (0);
   1.204  }
   1.205 -
   1.206 -
   1.207 -
   1.208 -