2 * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
18 #include <media/radio.h>
23 POSITIVE_TC_IDX = 0x01,
27 //keeping ret and radio global, since using startup function for all
31 static void startup(void);
32 static void cleanup(void);
34 void (*tet_startup)(void) = startup;
35 void (*tet_cleanup)(void) = cleanup;
37 static void utc_media_radio_create_p(void);
38 static void utc_media_radio_create_n(void);
39 static void utc_media_radio_destroy_p(void);
40 static void utc_media_radio_destroy_n(void);
41 static void utc_media_radio_get_state_p(void);
42 static void utc_media_radio_get_state_n(void);
43 static void utc_media_radio_start_p(void);
44 static void utc_media_radio_start_n(void);
45 static void utc_media_radio_stop_p(void);
46 static void utc_media_radio_stop_n(void);
47 static void utc_media_radio_seek_up_p(void);
48 static void utc_media_radio_seek_up_n(void);
49 static void utc_media_radio_seek_down_p(void);
50 static void utc_media_radio_seek_down_n(void);
51 static void utc_media_radio_set_frequency_p(void);
52 static void utc_media_radio_set_frequency_n(void);
53 static void utc_media_radio_get_frequency_p(void);
54 static void utc_media_radio_get_frequency_n(void);
55 static void utc_media_radio_scan_start_p(void);
56 static void utc_media_radio_scan_start_n(void);
57 static void utc_media_radio_scan_stop_p(void);
58 static void utc_media_radio_scan_stop_n(void);
59 static void utc_media_radio_set_mute_p(void);
60 static void utc_media_radio_set_mute_n(void);
61 static void utc_media_radio_is_muted_p(void);
62 static void utc_media_radio_is_muted_n(void);
63 static void utc_media_radio_set_scan_completed_callback_p(void);
64 static void utc_media_radio_set_scan_completed_callback_n(void);
65 static void utc_media_radio_unset_scan_completed_callback_p(void);
66 static void utc_media_radio_unset_scan_completed_callback_n(void);
67 static void utc_media_radio_set_interrupted_callback_p(void);
68 static void utc_media_radio_set_interrupted_callback_n(void);
69 static void utc_media_radio_unset_interrupted_callback_p(void);
70 static void utc_media_radio_unset_interrupted_callback_n(void);
72 struct tet_testlist tet_testlist[] = {
73 { utc_media_radio_create_p , POSITIVE_TC_IDX },
74 { utc_media_radio_create_n , NEGATIVE_TC_IDX },
75 { utc_media_radio_destroy_p , POSITIVE_TC_IDX },
76 { utc_media_radio_destroy_n , NEGATIVE_TC_IDX },
77 { utc_media_radio_get_state_p , POSITIVE_TC_IDX },
78 { utc_media_radio_get_state_n , NEGATIVE_TC_IDX },
79 { utc_media_radio_start_p , POSITIVE_TC_IDX },
80 { utc_media_radio_start_n , NEGATIVE_TC_IDX },
81 { utc_media_radio_stop_p , POSITIVE_TC_IDX },
82 { utc_media_radio_stop_n , NEGATIVE_TC_IDX },
83 { utc_media_radio_seek_up_p , POSITIVE_TC_IDX },
84 { utc_media_radio_seek_up_n , NEGATIVE_TC_IDX },
85 { utc_media_radio_seek_down_p , POSITIVE_TC_IDX },
86 { utc_media_radio_seek_down_n , NEGATIVE_TC_IDX },
87 { utc_media_radio_set_frequency_p , POSITIVE_TC_IDX },
88 { utc_media_radio_set_frequency_n , NEGATIVE_TC_IDX },
89 { utc_media_radio_get_frequency_p , POSITIVE_TC_IDX },
90 { utc_media_radio_get_frequency_n , NEGATIVE_TC_IDX },
91 { utc_media_radio_scan_start_p , POSITIVE_TC_IDX },
92 { utc_media_radio_scan_start_n , NEGATIVE_TC_IDX },
93 { utc_media_radio_scan_stop_p , POSITIVE_TC_IDX },
94 { utc_media_radio_scan_stop_n , NEGATIVE_TC_IDX },
95 { utc_media_radio_set_mute_p , POSITIVE_TC_IDX },
96 { utc_media_radio_set_mute_n , NEGATIVE_TC_IDX },
97 { utc_media_radio_is_muted_p , POSITIVE_TC_IDX },
98 { utc_media_radio_is_muted_n, NEGATIVE_TC_IDX },
99 { utc_media_radio_set_scan_completed_callback_p , POSITIVE_TC_IDX },
100 { utc_media_radio_set_scan_completed_callback_n , NEGATIVE_TC_IDX },
101 { utc_media_radio_unset_scan_completed_callback_p , POSITIVE_TC_IDX },
102 { utc_media_radio_unset_scan_completed_callback_n , NEGATIVE_TC_IDX },
103 { utc_media_radio_set_interrupted_callback_p , POSITIVE_TC_IDX },
104 { utc_media_radio_set_interrupted_callback_n , NEGATIVE_TC_IDX },
105 { utc_media_radio_unset_interrupted_callback_p , POSITIVE_TC_IDX },
106 { utc_media_radio_unset_interrupted_callback_n , NEGATIVE_TC_IDX },
110 static GMainLoop *g_mainloop = NULL;
111 static GThread *event_thread;
113 gpointer GmainThread(gpointer data){
114 g_mainloop = g_main_loop_new (NULL, 0);
115 g_main_loop_run (g_mainloop);
120 static void radio_completed_cb(int frequency, void *data)
122 dts_message("RadiorEvent", "Radio scan info : %d!!!", frequency);
125 static void radio_interrupt_cb(radio_interrupted_code_e code, void *data)
127 dts_message("RadiorEvent", "Radio Interrupted!!!");
130 static void startup(void)
132 if( !g_thread_supported() )
138 event_thread = g_thread_create(GmainThread, NULL, 1, &gerr);
140 if ((sRet = radio_create(&radio)) != RADIO_ERROR_NONE)
142 dts_fail("startup failed");
146 static void cleanup(void)
148 if ((sRet = radio_destroy(radio)) != RADIO_ERROR_NONE)
150 dts_fail("cleanup failed");
152 g_main_loop_quit (g_mainloop);
153 g_thread_join(event_thread);
156 static void utc_media_radio_create_p(void)
158 char* api_name = "utc_media_radio_create_p";
160 int ret = radio_create(&radio2);
161 if (ret != RADIO_ERROR_NONE)
163 dts_message(api_name, "Call log: %d", ret);
168 radio_destroy(radio2);
173 static void utc_media_radio_create_n(void)
175 char* api_name = "utc_media_radio_create_n";
176 int ret = radio_create(NULL);
177 if (ret == RADIO_ERROR_NONE)
179 dts_message(api_name, "Call log: %d", ret);
188 static void utc_media_radio_destroy_p(void)
190 char* api_name = "utc_media_radio_destroy_p";
192 radio_create(&radio2);
194 ret = radio_destroy(radio2);
195 if (ret != RADIO_ERROR_NONE)
197 dts_message(api_name, "Call log: %d", ret);
206 static void utc_media_radio_destroy_n(void)
208 char* api_name = "utc_media_radio_destroy_n";
209 int ret = radio_destroy(NULL);
210 if (ret == RADIO_ERROR_NONE)
212 dts_message(api_name, "Call log: %d", ret);
221 static void utc_media_radio_get_state_p(void)
223 char* api_name = "utc_media_radio_get_state_p";
226 if (sRet == RADIO_ERROR_NONE)
228 if ((ret = radio_get_state(radio, &state)) == RADIO_ERROR_NONE)
233 dts_message(api_name, "Call log: %d %d", sRet, ret);
237 static void utc_media_radio_get_state_n(void)
239 char* api_name = "utc_media_radio_get_state_n";
242 if (sRet == RADIO_ERROR_NONE)
244 if ((ret = radio_get_state(NULL, &state)) == RADIO_ERROR_INVALID_PARAMETER)
249 dts_message(api_name, "Call log: %d %d", sRet, ret);
253 static void utc_media_radio_start_p(void)
255 char* api_name = "utc_media_radio_start_p";
258 if (sRet == RADIO_ERROR_NONE)
260 if ((ret = radio_start(radio)) == RADIO_ERROR_NONE)
266 dts_message(api_name, "Call log: %d %d", sRet, ret);
270 static void utc_media_radio_start_n(void)
272 char* api_name = "utc_media_radio_start_n";
274 if (sRet == RADIO_ERROR_NONE)
276 if ((ret = radio_start(NULL)) == RADIO_ERROR_INVALID_PARAMETER)
281 dts_message(api_name, "Call log: %d %d", sRet, ret);
285 static void utc_media_radio_stop_p(void)
287 char* api_name = "utc_media_radio_stop_p";
290 if (sRet == RADIO_ERROR_NONE)
292 if ((ret = radio_start(radio)) == RADIO_ERROR_NONE)
294 if((ret = radio_stop(radio)) == RADIO_ERROR_NONE)
300 dts_message(api_name, "Call log: %d %d", sRet, ret);
304 static void utc_media_radio_stop_n(void)
306 char* api_name = "utc_media_radio_stop_n";
308 if (sRet == RADIO_ERROR_NONE)
310 if ((ret = radio_stop(NULL)) == RADIO_ERROR_INVALID_PARAMETER)
315 dts_message(api_name, "Call log: %d %d", sRet, ret);
319 static void utc_media_radio_seek_up_p(void)
321 char* api_name = "utc_media_radio_seek_up_p";
324 if (sRet == RADIO_ERROR_NONE)
326 if ((ret = radio_start(radio)) == RADIO_ERROR_NONE)
328 if((ret = radio_seek_up(radio,NULL,NULL)) == RADIO_ERROR_NONE)
335 dts_message(api_name, "Call log: %d %d", sRet, ret);
339 static void utc_media_radio_seek_up_n(void)
341 char* api_name = "utc_media_radio_seek_up_n";
343 if (sRet == RADIO_ERROR_NONE)
345 if ((ret = radio_seek_up(radio,NULL,NULL)) == RADIO_ERROR_INVALID_STATE)
350 dts_message(api_name, "Call log: %d %d", sRet, ret);
354 static void utc_media_radio_seek_down_p(void)
356 char* api_name = "utc_media_radio_seek_down_p";
359 if (sRet == RADIO_ERROR_NONE)
361 if ((ret = radio_start(radio)) == RADIO_ERROR_NONE)
363 if((ret = radio_seek_down(radio,NULL,NULL)) == RADIO_ERROR_NONE)
370 dts_message(api_name, "Call log: %d %d", sRet, ret);
374 static void utc_media_radio_seek_down_n(void)
376 char* api_name = "utc_media_radio_seek_down_n";
378 if (sRet == RADIO_ERROR_NONE)
380 if ((ret = radio_seek_down(radio,NULL,NULL)) == RADIO_ERROR_INVALID_STATE)
385 dts_message(api_name, "Call log: %d %d", sRet, ret);
389 static void utc_media_radio_set_frequency_p(void)
391 char* api_name = "utc_media_radio_set_frequency_p";
393 if (sRet == RADIO_ERROR_NONE)
395 if ((ret = radio_start(radio)) == RADIO_ERROR_NONE)
397 if((ret = radio_set_frequency(radio, 91900)) == RADIO_ERROR_NONE)
404 dts_message(api_name, "Call log: %d %d", sRet, ret);
408 static void utc_media_radio_set_frequency_n(void)
410 char* api_name = "utc_media_radio_set_frequency_n";
412 if (sRet == RADIO_ERROR_NONE)
414 if((ret = radio_set_frequency(radio, 100)) == RADIO_ERROR_INVALID_PARAMETER)
419 dts_message(api_name, "Call log: %d %d", sRet, ret);
423 static void utc_media_radio_get_frequency_p(void)
425 char* api_name = "utc_media_radio_get_frequency_p";
427 if (sRet == RADIO_ERROR_NONE)
429 if ((ret = radio_start(radio)) == RADIO_ERROR_NONE)
432 if((ret = radio_get_frequency(radio, &frequency)) == RADIO_ERROR_NONE)
439 dts_message(api_name, "Call log: %d %d", sRet, ret);
443 static void utc_media_radio_get_frequency_n(void)
445 char* api_name = "utc_media_radio_get_frequency_n";
447 if (sRet == RADIO_ERROR_NONE)
449 if((ret = radio_get_frequency(NULL, NULL)) == RADIO_ERROR_INVALID_PARAMETER)
454 dts_message(api_name, "Call log: %d %d", sRet, ret);
458 static void utc_media_radio_scan_start_p(void)
460 char* api_name = "utc_media_radio_scan_start_p";
462 if (sRet == RADIO_ERROR_NONE)
464 if ((ret = radio_scan_start(radio,NULL,NULL)) == RADIO_ERROR_NONE)
466 radio_scan_stop(radio,NULL,NULL);
470 dts_message(api_name, "Call log: %d %d", sRet, ret);
474 static void utc_media_radio_scan_start_n(void)
476 char* api_name = "utc_media_radio_scan_start_n";
478 if (sRet == RADIO_ERROR_NONE)
480 if ((ret = radio_scan_start(NULL,NULL,NULL)) == RADIO_ERROR_INVALID_PARAMETER)
485 dts_message(api_name, "Call log: %d %d", sRet, ret);
489 static void utc_media_radio_scan_stop_p(void)
491 char* api_name = "utc_media_radio_scan_stop_p";
494 if (sRet == RADIO_ERROR_NONE)
496 if ((ret = radio_scan_start(radio,NULL,NULL)) == RADIO_ERROR_NONE)
498 if((ret = radio_scan_stop(radio,NULL,NULL)) == RADIO_ERROR_NONE)
504 dts_message(api_name, "Call log: %d %d", sRet, ret);
508 static void utc_media_radio_scan_stop_n(void)
510 char* api_name = "utc_media_radio_scan_stop_n";
512 if (sRet == RADIO_ERROR_NONE)
514 if ((ret = radio_scan_stop(NULL,NULL,NULL)) == RADIO_ERROR_INVALID_PARAMETER)
519 dts_message(api_name, "Call log: %d %d", sRet, ret);
523 static void utc_media_radio_set_mute_p(void)
525 char* api_name = "utc_media_radio_set_mute_p";
528 if (sRet == RADIO_ERROR_NONE)
530 if ((ret = radio_set_mute(radio, mute)) == RADIO_ERROR_NONE)
535 dts_message(api_name, "Call log: %d %d", sRet, ret);
539 static void utc_media_radio_set_mute_n(void)
541 char* api_name = "utc_media_radio_set_mute_n";
543 if (sRet == RADIO_ERROR_NONE)
545 if ((ret = radio_set_mute(NULL,TRUE)) == RADIO_ERROR_INVALID_PARAMETER)
550 dts_message(api_name, "Call log: %d %d", sRet, ret);
554 static void utc_media_radio_is_muted_p(void)
556 char* api_name = "utc_media_radio_is_muted_p";
559 if (sRet == RADIO_ERROR_NONE)
561 if ((ret = radio_is_muted(radio,&mute)) == RADIO_ERROR_NONE)
566 dts_message(api_name, "Call log: %d %d", sRet, ret);
570 static void utc_media_radio_is_muted_n(void)
572 char* api_name = "utc_media_radio_is_muted_n";
574 if (sRet == RADIO_ERROR_NONE)
576 if ((ret = radio_is_muted(NULL,NULL)) == RADIO_ERROR_INVALID_PARAMETER)
581 dts_message(api_name, "Call log: %d %d", sRet, ret);
585 static void utc_media_radio_set_scan_completed_callback_p(void)
587 char* api_name = "utc_media_radio_set_scan_completed_callback_p";
589 if (sRet == RADIO_ERROR_NONE)
591 if ((ret = radio_set_scan_completed_cb(radio, radio_completed_cb, NULL)) == RADIO_ERROR_NONE)
596 dts_message(api_name, "Call log: %d %d", sRet, ret);
600 static void utc_media_radio_set_scan_completed_callback_n(void)
602 char* api_name = "utc_media_radio_set_scan_completed_callback_n";
604 if (sRet == RADIO_ERROR_NONE)
606 if ((ret = radio_set_scan_completed_cb(radio, NULL, NULL)) == RADIO_ERROR_INVALID_PARAMETER)
611 dts_message(api_name, "Call log: %d %d", sRet, ret);
615 static void utc_media_radio_unset_scan_completed_callback_p(void)
617 char* api_name = "utc_media_radio_unset_scan_completed_callback_p";
619 if (sRet == RADIO_ERROR_NONE)
621 if ((ret = radio_unset_scan_completed_cb(radio)) == RADIO_ERROR_NONE)
626 dts_message(api_name, "Call log: %d %d", sRet, ret);
630 static void utc_media_radio_unset_scan_completed_callback_n(void)
632 char* api_name = "utc_media_radio_unset_scan_completed_callback_n";
634 if (sRet == RADIO_ERROR_NONE)
636 if ((ret = radio_unset_scan_completed_cb(NULL)) == RADIO_ERROR_INVALID_PARAMETER)
641 dts_message(api_name, "Call log: %d %d", sRet, ret);
645 static void utc_media_radio_set_interrupted_callback_p(void)
647 char* api_name = "utc_media_radio_set_interrupted_callback_p";
649 if (sRet == RADIO_ERROR_NONE)
651 if ((ret = radio_set_interrupted_cb(radio, radio_interrupt_cb, NULL)) == RADIO_ERROR_NONE)
656 dts_message(api_name, "Call log: %d %d", sRet, ret);
660 static void utc_media_radio_set_interrupted_callback_n(void)
662 char* api_name = "utc_media_radio_set_interrupted_callback_n";
664 if (sRet == RADIO_ERROR_NONE)
666 if ((ret = radio_set_interrupted_cb(radio, NULL, NULL)) == RADIO_ERROR_INVALID_PARAMETER)
671 dts_message(api_name, "Call log: %d %d", sRet, ret);
675 static void utc_media_radio_unset_interrupted_callback_p(void)
677 char* api_name = "utc_media_radio_unset_interrupted_callback_p";
679 if (sRet == RADIO_ERROR_NONE)
681 if ((ret = radio_unset_interrupted_cb(radio)) == RADIO_ERROR_NONE)
686 dts_message(api_name, "Call log: %d %d", sRet, ret);
690 static void utc_media_radio_unset_interrupted_callback_n(void)
692 char* api_name = "utc_media_radio_unset_interrupted_callback_n";
694 if (sRet == RADIO_ERROR_NONE)
696 if ((ret = radio_unset_interrupted_cb(NULL)) == RADIO_ERROR_INVALID_PARAMETER)
701 dts_message(api_name, "Call log: %d %d", sRet, ret);