# HG changeset patch # User rosfran # Date 1179412982 -3600 # Node ID 4a784466828dd9f4a66658fcc908c71c9e61f1ab # Parent 367d791aeb574ad2631cd8fadacd4f0d018e0922 [svn r689] Added new test case to TV Chain; put back the testing scripts configuration file. diff -r 367d791aeb57 -r 4a784466828d gmyth/tests/Makefile.am --- a/gmyth/tests/Makefile.am Thu May 17 14:07:27 2007 +0100 +++ b/gmyth/tests/Makefile.am Thu May 17 15:43:02 2007 +0100 @@ -30,7 +30,8 @@ gmyth_test_file_download \ gmyth_test_program_info \ gmyth_test_monitor_handler \ - gmyth_test_stringlist + gmyth_test_stringlist \ + gmyth_test_tvchain TESTS = \ relink.py \ @@ -49,7 +50,8 @@ test_livetv_stress.py \ test_program_info.py \ test_monitor_handler.py \ - test_stringlist.py + test_stringlist.py \ + test_tvchain.py if HAVE_GENHTML TESTS += \ @@ -97,12 +99,15 @@ gmyth_test_program_info_SOURCES = \ gmyth_test_program_info.c -gmyth_test_monitor_handlerSOURCES = \ +gmyth_test_monitor_handler_SOURCES = \ gmyth_test_monitor_handler.c gmyth_test_stringlist_SOURCES = \ gmyth_test_stringlist.c +gmyth_test_tvchain_SOURCES = \ + gmyth_test_tvchain.c + CLEANFILES = $(BUILT_SOURCES) if HAVE_GCOV diff -r 367d791aeb57 -r 4a784466828d gmyth/tests/gmyth_test_tvchain.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gmyth/tests/gmyth_test_tvchain.c Thu May 17 15:43:02 2007 +0100 @@ -0,0 +1,142 @@ +#include + +#include "common.h" + +#include +#include +#include +#include +#include +#include +#include + +#define URI_DEFAULT "myth://192.168.3.165:6543/livetv?channel=9" + +static gboolean +test_tvchain_setup ( gchar *uri ) +{ + GMythTVChain *tvchain = NULL; + gchar *channel = NULL; + gboolean ret = TRUE; + + if ( NULL == uri ) + uri = g_strdup( URI_DEFAULT ); + + GMythURI *gmyth_uri = gmyth_uri_new_with_value( uri ); + + GMythBackendInfo* backend_info = gmyth_backend_info_new_with_uri (uri); + + channel = gmyth_uri_get_channel_name( gmyth_uri ); + + /* Creates livetv chain handler */ + tvchain = gmyth_tvchain_new (); + gmyth_tvchain_initialize (tvchain, backend_info); + + if (tvchain == NULL || tvchain->tvchain_id == NULL) + { + ret = FALSE; + goto init_failed; + } + + ret = ( gmyth_tvchain_get_id (tvchain) != NULL ); + if (!ret) + { + g_debug ("[%s] TV Chain ID is NULL.\n", __FUNCTION__); + goto init_failed; + } + + gmyth_backend_info_set_username (tvchain->backend_info, + "mythtv"); + gmyth_backend_info_set_password (tvchain->backend_info, + "mythtv"); + gmyth_backend_info_set_db_name (tvchain->backend_info, + "mythconverg"); + GList *prog_list = + gmyth_tvchain_get_program_info_from_channel (tvchain, + channel); + GMythProgramInfo *ch_prog = NULL; + if (prog_list != NULL && g_list_length (prog_list) > 0) + { + ch_prog = (GMythProgramInfo *) g_list_nth_data (prog_list, 0); + g_debug ("Channel program info (from a list with size = %d)!", + g_list_length (prog_list)); + gmyth_program_info_print (ch_prog); + } + + g_debug ("Program Info: %s\n", + gmyth_program_info_to_string (ch_prog)); + + /* Reload all TV chain from Mysql database. */ + gmyth_tvchain_reload_all (tvchain); + + if (tvchain == NULL) + { + ret = FALSE; + goto init_failed; + } + + /* Get program info from database using chanid and starttime */ + ch_prog = gmyth_tvchain_get_program_at (tvchain, 0); + if (NULL == ch_prog) + { + g_debug ("TVChain not successfully started.\n"); + ret = FALSE; + goto init_failed; + } + else + { + ret = TRUE; + g_debug + ("GMythTVChain: All requests to backend to start TV were OK. [%s]\n", + ch_prog->pathname->str); + } + + +init_failed: + if ( tvchain != NULL ) + g_object_unref(tvchain); + + if ( gmyth_uri != NULL ) + g_object_unref( gmyth_uri ); + + if ( ch_prog != NULL ) + g_object_unref( ch_prog ); + + if ( prog_list != NULL ) + g_list_free( prog_list ); + + if ( backend_info != NULL ) + g_object_unref( backend_info ); + + return ret; + +} + +gint +main (gint args, const gchar **argv) +{ + gboolean ret; + + g_type_init (); + g_thread_init (NULL); + + fprintf(stdout, SYNC_STRING); + fflush(NULL); + getchar(); + + if ( args > 1 ) + ret = test_tvchain_setup ( argv[1] ); + else + ret = test_tvchain_setup ( NULL ); + + if ( !ret ) + g_debug ("Error when running TV Chain setup test script!"); + else + g_debug ("TV Chain setup test script finished with success."); + + return(0); +} + + + + diff -r 367d791aeb57 -r 4a784466828d gmyth/tests/test_scripts.cfg --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gmyth/tests/test_scripts.cfg Thu May 17 15:43:02 2007 +0100 @@ -0,0 +1,10 @@ +[GMyth Test Scripts Config] +host = 192.168.3.110 +port = 6543 +filename = 1004_20070510161500.nuv +user = mythtv +password = mythtv +database = mythconverg +filename = 1004_20070510161500.nuv +channel = 1 + diff -r 367d791aeb57 -r 4a784466828d gmyth/tests/test_tvchain.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gmyth/tests/test_tvchain.py Thu May 17 15:43:02 2007 +0100 @@ -0,0 +1,14 @@ +#!/usr/bin/python + +#doc: test gmyth_epg_* methods + +from testing_tools import start, finish +import sys +from utils import TestConfigFile + +cfg_file = TestConfigFile('test_scripts.cfg') + +p = start('gmyth_test_tvchain', ["myth://%s:%s@%s:%s/?%s" % ( cfg_file.get_db_user(), cfg_file.get_db_passwd(), \ + cfg_file.get_host(), cfg_file.get_port(), cfg_file.get_db_name() )], 2) + +sys.exit(finish(p))