3 * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
5 * Contact: JongHyuk Choi <jhchoi.choi@samsung.com>, YoungHwan An <younghwan_.an@samsung.com>
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
21 /* testsuite for radio api */
27 #include "radio_test_type.h"
30 #define DEFAULT_TEST_FREQ 107700
31 #define MENU_ITEM_MAX 19
32 #define _MAX_INPUT_STRING_ 100
36 int __test_radio_init(void);
37 int __test_radio_listen_gorealra(void);
38 int __test_repeat_init_release(void);
39 int __test_repeat_start_stop(void);
40 int __test_repeat_seek(void);
41 int __test_repeat_whole(void);
42 int __test_manual_api_calling(void);
43 int __test_radio_hw_debug(void);
47 static void __print_menu(void);
48 static void __run_test(int key);
50 int radio_rt_api_test(void);
51 static int __menu(void);
52 static void __call_api( int choosen );
53 void __radio_seek_completed_cb(int frequency, void *user_data);
54 void __radio_scan_updated_cb(int freq, void *user_data);
55 void __radio_scan_stop_cb(void *user_data);
56 void __radio_set_scan_completed_cb(void *user_param);
57 void __radio_set_interrupted_cb(radio_interrupted_code_e code, void *user_param);
62 test_item_t g_tests[100] =
64 /* menu string : short string to be displayed to menu
65 description : detailed description
66 test function : a pointer to a actual test function
67 0 : to be filled with return value of test function
71 "check radio init function",
78 "let's listen to the gorealra!",
79 __test_radio_listen_gorealra,
84 "repeat_init_release",
85 "repeat init and release and check if it working and memory usage increment",
86 __test_repeat_init_release,
92 "repeat start and stop and check if it working and memory usage increment",
93 __test_repeat_start_stop,
99 "repeat seek and check if it working and memory usage increment",
106 "repeat whole radio sequence and check if it working and memory usage increment",
112 "manual api calling test",
113 "mapping each api to each test manu. just like other testsuite. try to reproduce the bugs with it.",
114 __test_manual_api_calling,
120 /* NOTE : do not remove this last item */
121 {"end", "", NULL, 0},
124 int g_num_of_tests = 0;
125 static radio_h g_my_radio = 0;
127 int main(int argc, char **argv)
137 if ( key >= '0' && key <= '9')
139 __run_test( key - '0' );
141 }while ( key == '\n' );
142 if(key == 'Q' || key == 'q')
146 printf("radio test client finished\n");
151 void __print_menu(void)
155 printf("\n\nFMRadio testing menu\n");
156 printf("------------------------------------------\n");
158 for ( i = 0; g_tests[i].func; i++ )
160 printf( "[%d] %s\n", i, g_tests[i].menu_string );
162 printf("[q] quit\n");
166 printf("Choose one : ");
169 void __run_test(int key)
174 printf("#tests : %d key : %d\n", g_num_of_tests, key);
175 if ( key >= g_num_of_tests || key < 0 )
177 printf("unassigned key has pressed : %d\n", key);
181 /* display description*/
182 printf( "excuting test : %s\n", g_tests[key].menu_string );
183 printf( "description : %s\n", g_tests[key].description );
185 /* calling test function*/
186 ret = g_tests[key].func();
188 g_tests[key].result = ret;
192 printf( "TEST FAILED. ret code : %d\n", g_tests[key].result);
196 printf( "TEST SUCCEDED. ret code : %d\n", g_tests[key].result);
202 int __test_radio_init(void)
204 printf("%s\n", __FUNCTION__);
206 int ret = RADIO_ERROR_NONE;
209 RADIO_TEST__( radio_create(&radio); )
210 RADIO_TEST__( radio_destroy(radio); )
214 int __test_radio_listen_gorealra(void)
216 printf("%s\n", __FUNCTION__);
218 int ret = RADIO_ERROR_NONE;
221 RADIO_TEST__( radio_create(&radio); )
222 RADIO_TEST__( radio_set_frequency( radio, DEFAULT_TEST_FREQ ); )
223 RADIO_TEST__( radio_start(radio); )
225 RADIO_TEST__( radio_stop(radio); )
226 RADIO_TEST__( radio_destroy(radio); )
230 int __test_repeat_init_release(void)
232 printf("%s\n", __FUNCTION__);
234 int ret = RADIO_ERROR_NONE;
240 RADIO_TEST__( radio_create(&radio); )
241 RADIO_TEST__( radio_destroy(radio); )
245 printf("%s : repeat count : %d\n", __FUNCTION__, cnt);
251 int __test_repeat_start_stop(void)
253 printf("%s\n", __FUNCTION__);
254 int ret = RADIO_ERROR_NONE;
258 RADIO_TEST__( radio_create(&radio); )
259 RADIO_TEST__( radio_set_frequency( radio, DEFAULT_TEST_FREQ ); )
263 RADIO_TEST__( radio_start(radio); )
265 RADIO_TEST__( radio_stop(radio); )
269 printf("%s : repeat count : %d\n", __FUNCTION__, cnt);
275 int __test_repeat_seek(void)
277 printf("__test_repeat_seek\n");
281 int __test_repeat_whole(void)
283 printf("__test_repeat_whole\n");
287 int __test_manual_api_calling(void)
296 int radio_rt_api_test(void)
310 __call_api( choosen );
313 printf("radio test client finished\n");
322 printf("---------------------------------------------------------\n");
323 printf("radio rt api test. try now!\n");
324 printf("---------------------------------------------------------\n");
325 printf("[1] radio_create\n");
326 printf("[2] radio_destroy\n");
327 printf("[3] radio_get_state\n");
328 printf("[4] radio_start\n");
329 printf("[5] radio_stop\n");
330 printf("[6] radio_seek_up\n");
331 printf("[7] radio_seek_down\n");
332 printf("[8] radio_set_frequency(ex.107700)\n");
333 printf("[9] radio_get_frequency\n");
334 printf("[10] radio_signal_strength\n");
335 printf("[11] radio_scan_start\n");
336 printf("[12] radio_scan_stop\n");
337 printf("[13] radio_set_mute\n");
338 printf("[14] radio_is_muted\n");
339 printf("[15] radio_set_scan_completed_cb\n");
340 printf("[16] radio_unset_scan_completed_cb\n");
341 printf("[17] radio_set_interrupted_cb\n");
342 printf("[18] radio_unset_interrupted_cb\n");
344 printf("[0] quit\n");
345 printf("---------------------------------------------------------\n");
346 printf("choose one : ");
348 if ( scanf("%d", &menu_item) == 0)
350 char temp[_MAX_INPUT_STRING_];
351 if (scanf("%s", temp) ==0)
353 printf("Error while flushing the input buffer - but lets continue\n");
359 if ( menu_item > MENU_ITEM_MAX )
365 void __call_api( int choosen )
367 int ret = RADIO_ERROR_NONE;
373 RADIO_TEST__( radio_create( &g_my_radio ); )
379 RADIO_TEST__( radio_destroy( g_my_radio ); )
387 RADIO_TEST__( radio_get_state(g_my_radio, &state); )
389 printf("state : %d\n", state);
395 RADIO_TEST__( radio_start(g_my_radio); )
401 RADIO_TEST__( radio_stop(g_my_radio); )
407 RADIO_TEST__( radio_seek_up(g_my_radio, __radio_seek_completed_cb, NULL); )
414 RADIO_TEST__( radio_seek_down(g_my_radio, __radio_seek_completed_cb, NULL); )
421 printf("input freq : ");
422 if (scanf("%d", &freq) == 0)
425 RADIO_TEST__( radio_set_frequency(g_my_radio, freq); )
432 RADIO_TEST__( radio_get_frequency(g_my_radio, &freq ); )
434 printf("freq : %d\n", freq);
440 int signal_strength = 0;
441 RADIO_TEST__( radio_get_signal_strength(g_my_radio, &signal_strength); )
442 printf("signal strength is : %d \n", signal_strength);
448 RADIO_TEST__( radio_scan_start(g_my_radio, &__radio_scan_updated_cb, NULL); )
454 RADIO_TEST__( radio_scan_stop(g_my_radio, &__radio_scan_stop_cb, NULL); )
461 printf("select one(0:UNMUTE/1:MUTE) : ");
462 if ( scanf("%d", &muted) == 0)
464 RADIO_TEST__( radio_set_mute(g_my_radio, muted); )
471 RADIO_TEST__( radio_is_muted(g_my_radio, &muted); )
472 printf("muted : %d \n", muted);
479 RADIO_TEST__( radio_set_scan_completed_cb(g_my_radio, &__radio_set_scan_completed_cb, NULL); )
485 RADIO_TEST__( radio_unset_scan_completed_cb(g_my_radio); )
491 RADIO_TEST__( radio_set_interrupted_cb(g_my_radio, &__radio_set_interrupted_cb, NULL ); )
497 RADIO_TEST__( radio_unset_interrupted_cb(g_my_radio); )
507 void __radio_seek_completed_cb(int frequency, void *user_data)
509 printf("__radio_seek_completed_cb freq is %d\n" , frequency);
511 void __radio_scan_updated_cb(int frequency, void *user_param)
513 printf("__radio_scan_updated_cb freq is %d\n" , frequency);
516 void __radio_scan_stop_cb(void *user_param)
518 printf("__radio_scan_stop_cb\n");
521 void __radio_set_scan_completed_cb(void *user_param)
523 printf("__radio_scan_completed_cb\n");
526 void __radio_set_interrupted_cb(radio_interrupted_code_e code, void *user_param)
528 printf("__radio_set_interrupted_cb\n");