1.1 --- a/gmyth/tests/gmyth_test_program_info.c Tue May 08 16:05:47 2007 +0100
1.2 +++ b/gmyth/tests/gmyth_test_program_info.c Thu Jun 14 18:19:52 2007 +0100
1.3 @@ -11,7 +11,7 @@
1.4 #define URI_DEFAULT "myth://192.168.3.165:6543/livetv?channel=9"
1.5
1.6 static gboolean
1.7 -test_program_info_setup ( gchar *uri )
1.8 +test_program_info_setup(gchar * uri)
1.9 {
1.10 GMythLiveTV *livetv = NULL;
1.11 GMythStringList *str_list = NULL;
1.12 @@ -20,104 +20,113 @@
1.13 gchar *channel_name = NULL;
1.14 gboolean ret = TRUE;
1.15 gboolean live_tv = FALSE;
1.16 -
1.17 - if ( NULL == uri )
1.18 - uri = g_strdup( URI_DEFAULT );
1.19
1.20 - GMythURI *gmyth_uri = gmyth_uri_new_with_value( uri );
1.21 + if (NULL == uri)
1.22 + uri = g_strdup(URI_DEFAULT);
1.23
1.24 - GMythBackendInfo* backend_info = gmyth_backend_info_new_with_uri (uri);
1.25 - live_tv = gmyth_uri_is_livetv( gmyth_uri );
1.26 - if ( live_tv ) {
1.27 - livetv = gmyth_livetv_new (backend_info);
1.28 -
1.29 - gchar* ch = gmyth_uri_get_channel_name( gmyth_uri );
1.30 - if ( ch != NULL )
1.31 - channel_name = ch;
1.32 -
1.33 - if (channel_name != NULL) {
1.34 - if (gmyth_livetv_channel_name_setup (livetv, channel_name) == FALSE) {
1.35 - g_debug("LiveTV setup felt down on error.");
1.36 - ret = FALSE;
1.37 - goto init_failed;
1.38 - }
1.39 - } else {
1.40 - if (gmyth_livetv_setup (livetv) == FALSE) {
1.41 - g_debug("LiveTV setup felt down on error");
1.42 - ret = FALSE;
1.43 - goto init_failed;
1.44 - }
1.45 - }
1.46 - }
1.47 + GMythURI *gmyth_uri = gmyth_uri_new_with_value(uri);
1.48
1.49 - g_debug( "uri = %s", uri);
1.50 + GMythBackendInfo *backend_info = gmyth_backend_info_new_with_uri(uri);
1.51 + live_tv = gmyth_uri_is_livetv(gmyth_uri);
1.52 + if (live_tv)
1.53 + {
1.54 + livetv = gmyth_livetv_new(backend_info);
1.55
1.56 - if ( ret == FALSE ) {
1.57 - g_debug("MythTV ProgramInfo request failed when setting up socket connection!");
1.58 - goto init_failed;
1.59 - }
1.60 + gchar *ch = gmyth_uri_get_channel_name(gmyth_uri);
1.61 + if (ch != NULL)
1.62 + channel_name = ch;
1.63
1.64 - g_return_val_if_fail( livetv->proginfo != NULL, FALSE );
1.65 + if (channel_name != NULL)
1.66 + {
1.67 + if (gmyth_livetv_channel_name_setup(livetv, channel_name) == FALSE)
1.68 + {
1.69 + g_debug("LiveTV setup felt down on error.");
1.70 + ret = FALSE;
1.71 + goto init_failed;
1.72 + }
1.73 + }
1.74 + else
1.75 + {
1.76 + if (gmyth_livetv_setup(livetv) == FALSE)
1.77 + {
1.78 + g_debug("LiveTV setup felt down on error");
1.79 + ret = FALSE;
1.80 + goto init_failed;
1.81 + }
1.82 + }
1.83 + }
1.84
1.85 - g_debug( "Printing ProgramInfo... [%s]", gmyth_program_info_to_string( livetv->proginfo ) );
1.86 + g_debug("uri = %s", uri);
1.87
1.88 - str_list = gmyth_program_info_to_string_list( livetv->proginfo, str_list );
1.89 + if (ret == FALSE)
1.90 + {
1.91 + g_debug
1.92 + ("MythTV ProgramInfo request failed when setting up socket connection!");
1.93 + goto init_failed;
1.94 + }
1.95
1.96 - g_return_val_if_fail( str_list != NULL && gmyth_string_list_length( str_list ) > 0, FALSE );
1.97 + g_return_val_if_fail(livetv->proginfo != NULL, FALSE);
1.98
1.99 - program_info = gmyth_program_info_from_string_list( str_list );
1.100 + g_debug("Printing ProgramInfo... [%s]",
1.101 + gmyth_program_info_to_string(livetv->proginfo));
1.102
1.103 - /* assert it IS the same program info */
1.104 - g_return_val_if_fail( gmyth_program_info_is_equals( program_info, livetv->proginfo ), FALSE );
1.105 + str_list = gmyth_program_info_to_string_list(livetv->proginfo, str_list);
1.106
1.107 - program_info->title = g_string_assign( program_info->title, "Another RaNdOm Title..." );
1.108 + g_return_val_if_fail(str_list != NULL
1.109 + && gmyth_string_list_length(str_list) > 0, FALSE);
1.110 +
1.111 + program_info = gmyth_program_info_from_string_list(str_list);
1.112 +
1.113 + /* assert it IS the same program info */
1.114 + g_return_val_if_fail(gmyth_program_info_is_equals
1.115 + (program_info, livetv->proginfo), FALSE);
1.116 +
1.117 + program_info->title =
1.118 + g_string_assign(program_info->title, "Another RaNdOm Title...");
1.119
1.120 /* assert it is not the same program info anymore */
1.121 - g_return_val_if_fail( !gmyth_program_info_is_equals( program_info, livetv->proginfo ), FALSE );
1.122 + g_return_val_if_fail(!gmyth_program_info_is_equals
1.123 + (program_info, livetv->proginfo), FALSE);
1.124
1.125 init_failed:
1.126 - if ( str_list != NULL )
1.127 - g_object_unref( str_list );
1.128 + if (str_list != NULL)
1.129 + g_object_unref(str_list);
1.130
1.131 - if ( program_info != NULL )
1.132 - g_object_unref( program_info );
1.133 + if (program_info != NULL)
1.134 + g_object_unref(program_info);
1.135
1.136 - if ( livetv != NULL )
1.137 - g_object_unref(livetv);
1.138 -
1.139 - if ( gmyth_uri != NULL )
1.140 - g_object_unref( gmyth_uri );
1.141 + if (livetv != NULL)
1.142 + g_object_unref(livetv);
1.143
1.144 - return ret;
1.145 -
1.146 + if (gmyth_uri != NULL)
1.147 + g_object_unref(gmyth_uri);
1.148 +
1.149 + return ret;
1.150 +
1.151 }
1.152
1.153 gint
1.154 -main (gint args, const gchar **argv)
1.155 +main(gint args, const gchar ** argv)
1.156 {
1.157 - gboolean ret;
1.158 + gboolean ret;
1.159
1.160 - g_type_init ();
1.161 -
1.162 - g_thread_init (NULL);
1.163 + g_type_init();
1.164
1.165 - fprintf(stdout, SYNC_STRING);
1.166 - fflush(NULL);
1.167 - getchar();
1.168 -
1.169 - if ( args > 1 )
1.170 - ret = test_program_info_setup ( argv[1] );
1.171 - else
1.172 - ret = test_program_info_setup( NULL );
1.173 -
1.174 - if ( !ret )
1.175 - g_debug ("Error when getting program info from the LiveTV instance!");
1.176 - else
1.177 - g_debug ("LiveTV setup test script finished with success.");
1.178 + g_thread_init(NULL);
1.179
1.180 - return(0);
1.181 + fprintf(stdout, SYNC_STRING);
1.182 + fflush(NULL);
1.183 + getchar();
1.184 +
1.185 + if (args > 1)
1.186 + ret = test_program_info_setup(argv[1]);
1.187 + else
1.188 + ret = test_program_info_setup(NULL);
1.189 +
1.190 + if (!ret)
1.191 + g_debug("Error when getting program info from the LiveTV instance!");
1.192 + else
1.193 + g_debug("LiveTV setup test script finished with success.");
1.194 +
1.195 + return (0);
1.196 }
1.197 -
1.198 -
1.199 -
1.200 -