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:39:54 +0100
committerDaniel Willmann <d.willmann@samsung.com>2013-04-29 19:57:16 +0100
commit014c6176b3a3fa9bb9665949348121d008569a52 (patch)
treed10afd28bd2a0d9551cce63514589a5ead782954 /src/tests/ecore/ecore_test_ecore_audio.c
parented011b10cc9ff87b19a7c17c43f4ce22c57c135a (diff)
ecore_audio: Test sndfile/tone format and source methods better
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.c76
1 files changed, 75 insertions, 1 deletions
diff --git a/src/tests/ecore/ecore_test_ecore_audio.c b/src/tests/ecore/ecore_test_ecore_audio.c
index 75c5bb0..b661e57 100644
--- a/src/tests/ecore/ecore_test_ecore_audio.c
+++ b/src/tests/ecore/ecore_test_ecore_audio.c
@@ -369,6 +369,7 @@ START_TEST(ecore_test_ecore_audio_obj_tone)
369 double len; 369 double len;
370 int channel, rate, freq; 370 int channel, rate, freq;
371 Eina_Bool ret; 371 Eina_Bool ret;
372 char *tmp;
372 373
373 in = eo_add(ECORE_AUDIO_OBJ_IN_TONE_CLASS, NULL); 374 in = eo_add(ECORE_AUDIO_OBJ_IN_TONE_CLASS, NULL);
374 fail_if(!in); 375 fail_if(!in);
@@ -400,6 +401,16 @@ START_TEST(ecore_test_ecore_audio_obj_tone)
400 eo_do(in, eo_base_data_get(ECORE_AUDIO_ATTR_TONE_FREQ, (void **)&freq)); 401 eo_do(in, eo_base_data_get(ECORE_AUDIO_ATTR_TONE_FREQ, (void **)&freq));
401 fail_if(freq != 2000); 402 fail_if(freq != 2000);
402 403
404 eo_do(in, eo_base_data_set("foo", "bar", NULL));
405 eo_do(in, eo_base_data_get("foo", (void **)&tmp));
406 ck_assert_str_eq(tmp, "bar");
407
408 eo_do(in, ecore_audio_obj_in_seek(5.0, SEEK_SET, &len));
409 fail_if(len != -1);
410
411 eo_do(in, ecore_audio_obj_in_seek(1.0, 42, &len));
412 fail_if(len != -1);
413
403 eo_do(in, ecore_audio_obj_in_seek(1.0, SEEK_SET, &len)); 414 eo_do(in, ecore_audio_obj_in_seek(1.0, SEEK_SET, &len));
404 fail_if(len != 1.0); 415 fail_if(len != 1.0);
405 416
@@ -445,18 +456,38 @@ END_TEST
445 456
446START_TEST(ecore_test_ecore_audio_obj_sndfile) 457START_TEST(ecore_test_ecore_audio_obj_sndfile)
447{ 458{
448 Eo *in; 459 Eo *in, *out;
449 double len, rem; 460 double len, rem;
450 int channel, rate; 461 int channel, rate;
451 Eina_Bool ret; 462 Eina_Bool ret;
463 Ecore_Audio_Format fmt;
464 const char *src;
452 465
453 in = eo_add(ECORE_AUDIO_OBJ_IN_SNDFILE_CLASS, NULL); 466 in = eo_add(ECORE_AUDIO_OBJ_IN_SNDFILE_CLASS, NULL);
454 fail_if(!in); 467 fail_if(!in);
455 468
469 eo_do(in, ecore_audio_obj_format_get(&fmt));
470 fail_if(fmt != ECORE_AUDIO_FORMAT_AUTO);
471
472 eo_do(in, ecore_audio_obj_format_set(ECORE_AUDIO_FORMAT_FLAC, &ret));
473 fail_if(!ret);
474
475 eo_do(in, ecore_audio_obj_format_get(&fmt));
476 fail_if(fmt != ECORE_AUDIO_FORMAT_FLAC);
477
478 eo_do(in, ecore_audio_obj_format_set(ECORE_AUDIO_FORMAT_AUTO, &ret));
479 fail_if(!ret);
480
456 eo_do(in, ecore_audio_obj_name_set("sms.ogg")); 481 eo_do(in, ecore_audio_obj_name_set("sms.ogg"));
457 eo_do(in, ecore_audio_obj_source_set(TESTS_SRC_DIR"/sms.ogg", &ret)); 482 eo_do(in, ecore_audio_obj_source_set(TESTS_SRC_DIR"/sms.ogg", &ret));
458 fail_if(!ret); 483 fail_if(!ret);
459 484
485 eo_do(in, ecore_audio_obj_source_get(&src));
486 ck_assert_str_eq(src, TESTS_SRC_DIR"/sms.ogg");
487
488 eo_do(in, ecore_audio_obj_format_get(&fmt));
489 fail_if(fmt != ECORE_AUDIO_FORMAT_OGG);
490
460 eo_do(in, ecore_audio_obj_in_channels_get(&channel)); 491 eo_do(in, ecore_audio_obj_in_channels_get(&channel));
461 fail_if(channel != 2); 492 fail_if(channel != 2);
462 eo_do(in, ecore_audio_obj_in_samplerate_get(&rate)); 493 eo_do(in, ecore_audio_obj_in_samplerate_get(&rate));
@@ -466,7 +497,50 @@ START_TEST(ecore_test_ecore_audio_obj_sndfile)
466 eo_do(in, ecore_audio_obj_in_remaining_get(&rem)); 497 eo_do(in, ecore_audio_obj_in_remaining_get(&rem));
467 fail_if(len != rem); 498 fail_if(len != rem);
468 499
500 eo_do(in, ecore_audio_obj_format_get(&fmt));
501 fail_if(fmt != ECORE_AUDIO_FORMAT_OGG);
502
503 eo_do(in, ecore_audio_obj_in_seek(0.5, SEEK_SET, &len));
504 fail_if(len != 0.5);
505
506 eo_do(in, ecore_audio_obj_in_seek(0.5, SEEK_CUR, &len));
507 fail_if(len != 1.0);
508
509 eo_do(in, ecore_audio_obj_in_seek(-1.0, SEEK_END, &len));
510 fail_if(fabs(rem - 1 - len) > 0.1);
511
512 out = eo_add(ECORE_AUDIO_OBJ_OUT_SNDFILE_CLASS, NULL);
513 fail_if(!out);
514
515 eo_do(out, ecore_audio_obj_name_set("tmp.wav"));
516 eo_do(out, ecore_audio_obj_format_set(ECORE_AUDIO_FORMAT_WAV, &ret));
517 fail_if(!ret);
518
519 eo_do(out, ecore_audio_obj_format_get(&fmt));
520 fail_if(fmt != ECORE_AUDIO_FORMAT_WAV);
521
522
523// eo_do(out, ecore_audio_obj_source_set("/tmp/file/does/not/exist/hopefully.wav", &ret));
524// fail_if(ret);
525
526 eo_do(out, ecore_audio_obj_source_set(TESTS_BUILD_DIR"/tmp.wav", &ret));
527 fail_if(!ret);
528
529 eo_do(out, ecore_audio_obj_source_get(&src));
530 ck_assert_str_eq(src, TESTS_BUILD_DIR"/tmp.wav");
531
532 eo_do(out, ecore_audio_obj_out_input_attach(in, &ret));
533 fail_if(!ret);
534
535 eo_do(in, eo_event_callback_add(ECORE_AUDIO_EV_IN_STOPPED, _finished_cb, NULL));
536
537 ecore_main_loop_begin();
538
469 eo_del(in); 539 eo_del(in);
540 eo_del(out);
541
542 //TODO: Compare and fail
543 ecore_file_remove(TESTS_BUILD_DIR"/tmp.wav");
470} 544}
471END_TEST 545END_TEST
472 546