1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/gmyth/tests/compile_test_recorder Thu Jan 18 20:48:09 2007 +0000
1.3 @@ -0,0 +1,1 @@
1.4 +gcc -o gmyth_test_recorder gmyth_test_recorder.c `pkg-config --cflags --libs gmyth-0.1`
2.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
2.2 +++ b/gmyth/tests/gmyth_test_epg.c Thu Jan 18 20:48:09 2007 +0000
2.3 @@ -0,0 +1,60 @@
2.4 +
2.5 +#include "gmyth_backendinfo.h"
2.6 +#include "gmyth_epg.h"
2.7 +
2.8 +static gboolean
2.9 +test_epg_connection (GMythBackendInfo *backend_info)
2.10 +{
2.11 + GMythEPG *epg = gmyth_epg_new ();
2.12 + gboolean res = FALSE;
2.13 +
2.14 + res = gmyth_epg_connect (epg, backend_info);
2.15 +
2.16 + gmyth_epg_disconnect (epg);
2.17 + g_object_unref (epg);
2.18 +
2.19 + return res;
2.20 +}
2.21 +
2.22 +
2.23 +static gboolean
2.24 +test_epg_get_channels (GMythBackendInfo *backend_info)
2.25 +{
2.26 + GMythEPG *epg = gmyth_epg_new ();
2.27 + GList *clist;
2.28 + gint i, length;
2.29 +
2.30 + if (!gmyth_epg_connect (epg, backend_info)) {
2.31 + return FALSE;
2.32 + }
2.33 +
2.34 + length = gmyth_epg_get_channel_list (epg, &clist);
2.35 + g_print ("==== %d channels found in the EPG ====\n", length);
2.36 + for (i=0; i<length; i++) {
2.37 + GMythChannelInfo *channel_info = (GMythChannelInfo*) g_list_nth_data (clist, i);
2.38 +
2.39 + gmyth_channel_info_print(channel_info);
2.40 + }
2.41 +
2.42 + g_list_free (clist);
2.43 + gmyth_epg_disconnect (epg);
2.44 + g_object_unref (epg);
2.45 +}
2.46 +
2.47 +int
2.48 +main (int args, const char **argv)
2.49 +{
2.50 + const char* uri = argv[1];
2.51 +
2.52 + GMythBackendInfo *backend_info;
2.53 + g_type_init ();
2.54 + g_thread_init (NULL);
2.55 +
2.56 + backend_info = gmyth_backend_info_new_with_uri (argv[1]);
2.57 +
2.58 + test_epg_connection (backend_info);
2.59 + test_epg_get_channels (backend_info);
2.60 +
2.61 + return 0;
2.62 +}
2.63 +
3.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
3.2 +++ b/gmyth/tests/gmyth_test_recorder.c Thu Jan 18 20:48:09 2007 +0000
3.3 @@ -0,0 +1,118 @@
3.4 +#include <glib-object.h>
3.5 +
3.6 +#include "gmyth_backendinfo.h"
3.7 +#include "gmyth_remote_util.h"
3.8 +#include "gmyth_query.h"
3.9 +#include "gmyth_epg.h"
3.10 +#include "gmyth_common.h"
3.11 +
3.12 +
3.13 +static gboolean
3.14 +test_recorder_availability (GMythBackendInfo *backend_info)
3.15 +{
3.16 + GMythRecorder* recorder;
3.17 + GMythSocket *socket = gmyth_socket_new ();
3.18 +
3.19 + if (gmyth_socket_connect_with_timeout (socket,
3.20 + gmyth_backend_info_get_hostname (backend_info),
3.21 + gmyth_backend_info_get_port (backend_info), 4) == FALSE) {
3.22 + g_debug ("Test recorder failed: Connection failed");
3.23 + return FALSE;
3.24 + }
3.25 +
3.26 + recorder = remote_request_next_free_recorder (socket, -1);
3.27 + if (recorder == NULL) {
3.28 + g_debug ("Recorder not available\n");
3.29 + return FALSE;
3.30 + }
3.31 +
3.32 + g_debug ("Recorder found (num): %d", recorder->recorder_num);
3.33 +
3.34 + return TRUE;
3.35 +}
3.36 +
3.37 +static gboolean
3.38 +test_recorder_setup (GMythBackendInfo *backend_info)
3.39 +{
3.40 + GMythQuery *query = gmyth_query_new ();
3.41 +
3.42 + if (gmyth_query_connect_with_timeout (query, backend_info, 3) == TRUE) {
3.43 + g_debug ("Mysql connection success");
3.44 + return TRUE;
3.45 + } else {
3.46 + g_debug ("Mysql connection failed");
3.47 + return FALSE;
3.48 + }
3.49 +
3.50 +}
3.51 +
3.52 +static gboolean
3.53 +test_recorder_check_channels (GMythBackendInfo *backend_info)
3.54 +{
3.55 + GMythRecorder* recorder;
3.56 + GMythSocket *socket = gmyth_socket_new ();
3.57 + GMythEPG *epg = gmyth_epg_new ();
3.58 + GList *clist;
3.59 + gint i, length;
3.60 +
3.61 + // Gets the free recorder
3.62 + if (gmyth_socket_connect_with_timeout (socket,
3.63 + gmyth_backend_info_get_hostname (backend_info),
3.64 + gmyth_backend_info_get_port (backend_info), 4) == FALSE) {
3.65 + g_debug ("Test recorder failed: Connection failed");
3.66 + return FALSE;
3.67 + }
3.68 +
3.69 + recorder = remote_request_next_free_recorder (socket, -1);
3.70 + if (recorder == NULL) {
3.71 + g_debug ("[%s] Recorder not available", __FUNCTION__);
3.72 + return FALSE;
3.73 + }
3.74 +
3.75 + // Connects the recorder socket
3.76 + gmyth_recorder_setup (recorder);
3.77 +
3.78 + // Gets the list of channels
3.79 + if (!gmyth_epg_connect (epg, backend_info)) {
3.80 + g_debug ("%s: Not connected\n", __FUNCTION__);
3.81 + return FALSE;
3.82 + }
3.83 +
3.84 + length = gmyth_epg_get_channel_list (epg, &clist);
3.85 + gmyth_epg_disconnect (epg);
3.86 + g_object_unref (epg);
3.87 +
3.88 + g_print ("==== Verifying the %d channels found in the EPG ====\n", length);
3.89 + for (i=0; i<length; i++) {
3.90 + GMythChannelInfo *channel_info = (GMythChannelInfo*) g_list_nth_data (clist, i);
3.91 + gboolean res;
3.92 +
3.93 + // Checks the channels
3.94 + res = gmyth_recorder_check_channel (recorder, channel_info->channel_ID);
3.95 + g_debug ("Channel %d %s", channel_info->channel_ID, res ? "Found" : "Not found");
3.96 + }
3.97 +
3.98 + g_list_free (clist);
3.99 +
3.100 +}
3.101 +
3.102 +
3.103 +int
3.104 +main (int args, const char **argv)
3.105 +{
3.106 + const char* uri = argv[1];
3.107 +
3.108 + GMythBackendInfo *backend_info;
3.109 + g_type_init ();
3.110 + g_thread_init (NULL);
3.111 +
3.112 + backend_info = gmyth_backend_info_new_with_uri (argv[1]);
3.113 +
3.114 + test_recorder_availability (backend_info);
3.115 + test_recorder_check_channels (backend_info);
3.116 +}
3.117 +
3.118 +
3.119 +
3.120 +
3.121 +