summaryrefslogtreecommitdiff
path: root/src/tests/ecore/ecore_test_ecore_audio.c
diff options
context:
space:
mode:
authorDaniel Willmann <d.willmann@samsung.com>2013-04-29 19:47:49 +0100
committerDaniel Willmann <d.willmann@samsung.com>2013-04-29 19:57:16 +0100
commit72e65872d51c7222c3f99835a51963ab22ac06b5 (patch)
tree59bbfc0c411b2d3be689350e9414cc484e5c2ba6 /src/tests/ecore/ecore_test_ecore_audio.c
parent014c6176b3a3fa9bb9665949348121d008569a52 (diff)
ecore_audio: Add test to check correct cleanup when removing input
Signed-off-by: Daniel Willmann <d.willmann@samsung.com>
Diffstat (limited to 'src/tests/ecore/ecore_test_ecore_audio.c')
-rw-r--r--src/tests/ecore/ecore_test_ecore_audio.c113
1 files changed, 47 insertions, 66 deletions
diff --git a/src/tests/ecore/ecore_test_ecore_audio.c b/src/tests/ecore/ecore_test_ecore_audio.c
index b661e57..c4955c4 100644
--- a/src/tests/ecore/ecore_test_ecore_audio.c
+++ b/src/tests/ecore/ecore_test_ecore_audio.c
@@ -14,71 +14,6 @@
14#include <Ecore_Audio.h> 14#include <Ecore_Audio.h>
15 15
16#if 0 16#if 0
17Eina_Bool
18seek(void *data)
19{
20 double offs;
21 fail_if(ecore_audio_input_seek(in, 0, SEEK_SET) != 0);
22 fail_if(ecore_audio_input_seek(in, 1, SEEK_CUR) != 1);
23 offs = ecore_audio_input_seek(in, -1, SEEK_END);
24 fail_if((offs > 1.001) || (offs < 0.999));
25
26 fail_if(ecore_audio_input_seek(in, SEEK_CUR, 10) != -1);
27 fail_if(ecore_audio_input_seek(in, 5, 0) != -1);
28
29 fail_if(ecore_audio_input_seek(in, 0, SEEK_SET) != 0);
30}
31
32Eina_Bool
33input_del(void *data)
34{
35 printf("Deleting input\n");
36
37 ecore_audio_input_del(in);
38
39 return EINA_FALSE;
40}
41
42Eina_Bool
43output_add(void *data)
44{
45 out = ecore_audio_output_add(ECORE_AUDIO_TYPE_SNDFILE);
46 fail_if(!out);
47 ecore_audio_output_sndfile_filename_set(out, SOUNDS_DIR"tmp.ogg");
48
49 printf("Adding input\n");
50 ecore_audio_output_input_add(out, in);
51
52 return EINA_FALSE;
53}
54
55Eina_Bool
56_quit(void *data)
57{
58 printf("Deleting output\n");
59 ecore_audio_output_del(out);
60
61 printf("Quitting\n");
62 ecore_main_loop_quit();
63}
64
65START_TEST(ecore_test_ecore_audio_cleanup)
66{
67 in = ecore_audio_input_add(ECORE_AUDIO_TYPE_TONE);
68 fail_if(!in);
69 ecore_audio_input_tone_frequency_set(in, 1000);
70 ecore_audio_input_tone_duration_set(in, 2);
71
72 ecore_timer_add(1, output_add, NULL);
73 ecore_timer_add(2, seek, NULL);
74 ecore_timer_add(3.3, input_del, NULL);
75 ecore_timer_add(4, _quit, NULL);
76
77 ecore_main_loop_begin();
78
79 ecore_file_remove(SOUNDS_DIR"tmp.ogg");
80}
81END_TEST
82 17
83 18
84Eina_Bool 19Eina_Bool
@@ -363,6 +298,52 @@ START_TEST(ecore_test_ecore_audio_obj_pulse)
363END_TEST 298END_TEST
364#endif 299#endif
365 300
301static Eina_Bool _quit(void *data EINA_UNUSED)
302{
303 ecore_main_loop_quit();
304
305 return EINA_FALSE;
306}
307
308static Eina_Bool
309_idle_del(void *data)
310{
311 Eo *in = data;
312 eo_del(in);
313 ecore_idler_add(_quit, NULL);
314
315 return EINA_FALSE;
316}
317
318START_TEST(ecore_test_ecore_audio_cleanup)
319{
320 Eo *in, *out;
321 int freq = 1000;
322 Eina_Bool ret;
323
324 in = eo_add(ECORE_AUDIO_OBJ_IN_TONE_CLASS, NULL);
325 fail_if(!in);
326 eo_do(in, eo_base_data_set(ECORE_AUDIO_ATTR_TONE_FREQ, &freq, NULL));
327 eo_do(in, ecore_audio_obj_in_length_set(2));
328
329 out = eo_add(ECORE_AUDIO_OBJ_OUT_SNDFILE_CLASS, NULL);
330 fail_if(!out);
331 eo_do(out, ecore_audio_obj_format_set(ECORE_AUDIO_FORMAT_OGG, &ret));
332 fail_if(!ret);
333 eo_do(out, ecore_audio_obj_source_set(TESTS_BUILD_DIR"/tmp.ogg", &ret));
334 fail_if(!ret);
335
336 eo_do(out, ecore_audio_obj_out_input_attach(in, &ret));
337 fail_if(!ret);
338
339 ecore_idler_add(_idle_del, in);
340
341 ecore_main_loop_begin();
342
343 ecore_file_remove(TESTS_BUILD_DIR"/tmp.ogg");
344}
345END_TEST
346
366START_TEST(ecore_test_ecore_audio_obj_tone) 347START_TEST(ecore_test_ecore_audio_obj_tone)
367{ 348{
368 Eo *in, *out; 349 Eo *in, *out;
@@ -866,6 +847,7 @@ ecore_test_ecore_audio(TCase *tc)
866 847
867#ifdef HAVE_SNDFILE 848#ifdef HAVE_SNDFILE
868 tcase_add_test(tc, ecore_test_ecore_audio_obj_sndfile); 849 tcase_add_test(tc, ecore_test_ecore_audio_obj_sndfile);
850 tcase_add_test(tc, ecore_test_ecore_audio_cleanup);
869#endif 851#endif
870#ifdef HAVE_PULSE 852#ifdef HAVE_PULSE
871 tcase_add_test(tc, ecore_test_ecore_audio_obj_pulse); 853 tcase_add_test(tc, ecore_test_ecore_audio_obj_pulse);
@@ -875,7 +857,6 @@ ecore_test_ecore_audio(TCase *tc)
875 tcase_add_test(tc, ecore_test_ecore_audio_default); 857 tcase_add_test(tc, ecore_test_ecore_audio_default);
876 tcase_add_test(tc, ecore_test_ecore_audio_sndfile_vio); 858 tcase_add_test(tc, ecore_test_ecore_audio_sndfile_vio);
877 tcase_add_test(tc, ecore_test_ecore_audio_custom); 859 tcase_add_test(tc, ecore_test_ecore_audio_custom);
878 tcase_add_test(tc, ecore_test_ecore_audio_cleanup);
879*/ 860*/
880} 861}
881 862