4 * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
6 * Contact: JongHyuk Choi <jhchoi.choi@samsung.com>, YoungHwan An <younghwan_.an@samsung.com>
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
22 /* testsuite for mm-radio library */
28 #include "radio_test_type.h"
31 #define DEFAULT_TEST_FREQ 107700
32 #define MENU_ITEM_MAX 19
33 #define _MAX_INPUT_STRING_ 100
37 int __test_radio_init(void);
38 int __test_radio_listen_gorealra(void);
39 int __test_repeat_init_release(void);
40 int __test_repeat_start_stop(void);
41 int __test_repeat_seek(void);
42 int __test_repeat_whole(void);
43 int __test_manual_api_calling(void);
44 int __test_radio_hw_debug(void);
48 static void __print_menu(void);
49 static void __run_test(int key);
51 int mm_radio_rt_api_test(void);
52 static int __menu(void);
53 static void __call_api( int choosen );
54 void __radio_seek_completed_cb(int frequency, void *user_data);
55 void __radio_scan_updated_cb(int freq, void *user_data);
56 void __radio_scan_stop_cb(void *user_data);
57 void __radio_set_scan_completed_cb(void *user_param);
58 void __radio_set_interrupted_cb(radio_interrupted_code_e code, void *user_param);
63 test_item_t g_tests[100] =
65 /* menu string : short string to be displayed to menu
66 description : detailed description
67 test function : a pointer to a actual test function
68 0 : to be filled with return value of test function
72 "check radio init function",
79 "let's listen to the gorealra!",
80 __test_radio_listen_gorealra,
85 "repeat_init_release",
86 "repeat init and release and check if it working and memory usage increment",
87 __test_repeat_init_release,
93 "repeat start and stop and check if it working and memory usage increment",
94 __test_repeat_start_stop,
100 "repeat seek and check if it working and memory usage increment",
107 "repeat whole radio sequence and check if it working and memory usage increment",
113 "manual api calling test",
114 "mapping each api to each test manu. just like other testsuite. try to reproduce the bugs with it.",
115 __test_manual_api_calling,
121 /* NOTE : do not remove this last item */
122 {"end", "", NULL, 0},
125 int g_num_of_tests = 0;
126 static radio_h g_my_radio = 0;
128 int main(int argc, char **argv)
138 if ( key >= '0' && key <= '9')
140 __run_test( key - '0' );
142 }while ( key == '\n' );
143 if(key == 'Q' || key == 'q')
147 printf("radio test client finished\n");
152 void __print_menu(void)
156 printf("\n\nFMRadio testing menu\n");
157 printf("------------------------------------------\n");
159 for ( i = 0; g_tests[i].func; i++ )
161 printf( "[%d] %s\n", i, g_tests[i].menu_string );
163 printf("[q] quit\n");
167 printf("Choose one : ");
170 void __run_test(int key)
175 printf("#tests : %d key : %d\n", g_num_of_tests, key);
176 if ( key >= g_num_of_tests || key < 0 )
178 printf("unassigned key has pressed : %d\n", key);
182 /* display description*/
183 printf( "excuting test : %s\n", g_tests[key].menu_string );
184 printf( "description : %s\n", g_tests[key].description );
186 /* calling test function*/
187 ret = g_tests[key].func();
189 g_tests[key].result = ret;
193 printf( "TEST FAILED. ret code : %d\n", g_tests[key].result);
197 printf( "TEST SUCCEDED. ret code : %d\n", g_tests[key].result);
203 int __test_radio_init(void)
205 printf("%s\n", __FUNCTION__);
207 int ret = RADIO_ERROR_NONE;
210 RADIO_TEST__( radio_create(&radio); )
211 RADIO_TEST__( radio_destroy(radio); )
215 int __test_radio_listen_gorealra(void)
217 printf("%s\n", __FUNCTION__);
219 int ret = RADIO_ERROR_NONE;
222 RADIO_TEST__( radio_create(&radio); )
223 RADIO_TEST__( radio_set_frequency( radio, DEFAULT_TEST_FREQ ); )
224 RADIO_TEST__( radio_start(radio); )
226 RADIO_TEST__( radio_stop(radio); )
227 RADIO_TEST__( radio_destroy(radio); )
231 int __test_repeat_init_release(void)
233 printf("%s\n", __FUNCTION__);
235 int ret = RADIO_ERROR_NONE;
241 RADIO_TEST__( radio_create(&radio); )
242 RADIO_TEST__( radio_destroy(radio); )
246 printf("%s : repeat count : %d\n", __FUNCTION__, cnt);
252 int __test_repeat_start_stop(void)
254 printf("%s\n", __FUNCTION__);
255 int ret = RADIO_ERROR_NONE;
259 RADIO_TEST__( radio_create(&radio); )
260 RADIO_TEST__( radio_set_frequency( radio, DEFAULT_TEST_FREQ ); )
264 RADIO_TEST__( radio_start(radio); )
266 RADIO_TEST__( radio_stop(radio); )
270 printf("%s : repeat count : %d\n", __FUNCTION__, cnt);
276 int __test_repeat_seek(void)
278 printf("__test_repeat_seek\n");
282 int __test_repeat_whole(void)
284 printf("__test_repeat_whole\n");
288 int __test_manual_api_calling(void)
291 mm_radio_rt_api_test();
297 int mm_radio_rt_api_test(void)
311 __call_api( choosen );
314 printf("radio test client finished\n");
323 printf("---------------------------------------------------------\n");
324 printf("mm-radio rt api test. try now!\n");
325 printf("---------------------------------------------------------\n");
326 printf("[1] radio_create\n");
327 printf("[2] radio_destroy\n");
328 printf("[3] radio_get_state\n");
329 printf("[4] radio_start\n");
330 printf("[5] radio_stop\n");
331 printf("[6] radio_seek_up\n");
332 printf("[7] radio_seek_down\n");
333 printf("[8] radio_set_frequency(ex.107700)\n");
334 printf("[9] radio_get_frequency\n");
335 printf("[10] radio_signal_strength\n");
336 printf("[11] radio_scan_start\n");
337 printf("[12] radio_scan_stop\n");
338 printf("[13] radio_set_mute\n");
339 printf("[14] radio_is_muted\n");
340 printf("[15] radio_set_scan_completed_cb\n");
341 printf("[16] radio_unset_scan_completed_cb\n");
342 printf("[17] radio_set_interrupted_cb\n");
343 printf("[18] radio_unset_interrupted_cb\n");
345 printf("[0] quit\n");
346 printf("---------------------------------------------------------\n");
347 printf("choose one : ");
349 if ( scanf("%d", &menu_item) == 0)
351 char temp[_MAX_INPUT_STRING_];
352 if (scanf("%s", temp) ==0)
354 printf("Error while flushing the input buffer - but lets continue\n");
360 if ( menu_item > MENU_ITEM_MAX )
366 void __call_api( int choosen )
368 int ret = RADIO_ERROR_NONE;
374 RADIO_TEST__( radio_create( &g_my_radio ); )
380 RADIO_TEST__( radio_destroy( g_my_radio ); )
388 RADIO_TEST__( radio_get_state(g_my_radio, &state); )
390 printf("state : %d\n", state);
396 RADIO_TEST__( radio_start(g_my_radio); )
402 RADIO_TEST__( radio_stop(g_my_radio); )
408 RADIO_TEST__( radio_seek_up(g_my_radio, __radio_seek_completed_cb, NULL); )
415 RADIO_TEST__( radio_seek_down(g_my_radio, __radio_seek_completed_cb, NULL); )
422 printf("input freq : ");
423 if (scanf("%d", &freq) == 0)
426 RADIO_TEST__( radio_set_frequency(g_my_radio, freq); )
433 RADIO_TEST__( radio_get_frequency(g_my_radio, &freq ); )
435 printf("freq : %d\n", freq);
441 int signal_strength = 0;
442 RADIO_TEST__( radio_get_signal_strength(g_my_radio, &signal_strength); )
443 printf("signal strength is : %d \n", signal_strength);
449 RADIO_TEST__( radio_scan_start(g_my_radio, &__radio_scan_updated_cb, NULL); )
455 RADIO_TEST__( radio_scan_stop(g_my_radio, &__radio_scan_stop_cb, NULL); )
462 printf("select one(0:UNMUTE/1:MUTE) : ");
463 if ( scanf("%d", &muted) == 0)
465 RADIO_TEST__( radio_set_mute(g_my_radio, muted); )
472 RADIO_TEST__( radio_is_muted(g_my_radio, &muted); )
473 printf("muted : %d \n", muted);
480 RADIO_TEST__( radio_set_scan_completed_cb(g_my_radio, &__radio_set_scan_completed_cb, NULL); )
486 RADIO_TEST__( radio_unset_scan_completed_cb(g_my_radio); )
492 RADIO_TEST__( radio_set_interrupted_cb(g_my_radio, &__radio_set_interrupted_cb, NULL ); )
498 RADIO_TEST__( radio_unset_interrupted_cb(g_my_radio); )
508 void __radio_seek_completed_cb(int frequency, void *user_data)
510 printf("__radio_seek_completed_cb freq is %d\n" , frequency);
512 void __radio_scan_updated_cb(int frequency, void *user_param)
514 printf("__radio_scan_updated_cb freq is %d\n" , frequency);
517 void __radio_scan_stop_cb(void *user_param)
519 printf("__radio_scan_stop_cb\n");
522 void __radio_set_scan_completed_cb(void *user_param)
524 printf("__radio_scan_completed_cb\n");
527 void __radio_set_interrupted_cb(radio_interrupted_code_e code, void *user_param)
529 printf("__radio_set_interrupted_cb\n");