tv-service  0.1.0
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
tv_service_add_delete_favorite_channel_auto_test.c

This is an example of how to use TV Service's interface to add and delete favorite channel.

Author
Jiang Minmin min86.nosp@m..jia.nosp@m.ng@sa.nosp@m.msun.nosp@m.g.com
/* Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <glib-object.h>
#include <stdlib.h>
#include <stdio.h>
#include <glib.h>
#include <string.h>
#include "tv_service_logger.h"
gint tv_service_delete_favorite_channel_test()
{
gint rc = 0;
GList *tvs_list = NULL;
TvServiceChannel *p_tvs_data = NULL;
TvServiceChannel check_data;
printf ("#tv_service_delete_favorite_channel start#\n");
if(rc != TVS_ERROR_OK){
printf("tv_service_get_channel_list error %d\n",rc);
return rc;
}
p_tvs_data = (TvServiceChannel*)g_list_nth_data(tvs_list,0);
if(p_tvs_data == NULL){
printf("p_tvs_data is null\n");
return -1;
}
printf("service id is %d\n",p_tvs_data->service_id);
if(p_tvs_data->favorite == 1){
tv_service_get_channel(p_tvs_data->service_id,&check_data);
if(check_data.favorite != 0){
printf("tv_service_delete_favorite_channel is error %d\n",rc);
return rc;
}
else{
printf("tv_service_delete_favorite_channel is ok\n");
}
}
else{
tv_service_get_channel(p_tvs_data->service_id,&check_data);
if(check_data.favorite != 1){
printf("tv_service_add_favorite_channel is error %d\n",rc);
return rc;
}
else{
tv_service_get_channel(p_tvs_data->service_id,&check_data);
if(check_data.favorite != 0){
printf("tv_service_delete_favorite_channel is error %d\n",rc);
return rc;
}
else{
printf("tv_service_delete_favorite_channel is ok\n");
}
}
}
printf ("#tv_service_delete_favorite_channel end#\n");
return rc;
}
gint tv_service_add_favorite_channel_test()
{
gint rc = 0;
GList *tvs_list = NULL;
TvServiceChannel *p_tvs_data = NULL;
TvServiceChannel check_data;
printf ("#tv_service_add_favorite_channel_start#\n");
if(rc != TVS_ERROR_OK){
printf("tv_service_get_channel_list error %d\n",rc);
}
p_tvs_data = (TvServiceChannel*)g_list_nth_data(tvs_list,0);
if(p_tvs_data == NULL){
printf("p_tvs_data is null\n");
return -1;
}
printf("service id is %d\n",p_tvs_data->service_id);
if(p_tvs_data->favorite == 0){
tv_service_get_channel(p_tvs_data->service_id,&check_data);
if(check_data.favorite != 1){
printf("tv_service_add_favorite_channel is error %d\n",rc);
return rc;
}
else{
printf("tv_service_add_favorite_channel is ok\n");
}
}
else{
tv_service_get_channel(p_tvs_data->service_id,&check_data);
if(check_data.favorite != 0){
printf("tv_service_delete_favorite_channel is error %d\n",rc);
return rc;
}
else{
tv_service_get_channel(p_tvs_data->service_id,&check_data);
if(check_data.favorite != 1){
printf("tv_service_add_favorite_channel is error %d\n",rc);
return rc;
}
else{
printf("tv_service_add_favorite_channel is ok\n");
}
}
}
printf ("#tv_service_add_favorite_channel_end#\n");
return rc;
}
int main(int argc, char *argv[])
{
gint rc = 0;
if(rc != TVS_ERROR_OK)
{
printf("tv_service_channel_info_create error %d\n",rc);
return rc;
}
rc = tv_service_add_favorite_channel_test();
rc = tv_service_delete_favorite_channel_test();
return 0;
}