diff options
author | Daniel Willmann <d.willmann@samsung.com> | 2013-04-19 15:30:26 +0100 |
---|---|---|
committer | Daniel Willmann <d.willmann@samsung.com> | 2013-04-19 15:43:20 +0100 |
commit | af8fed32c652d554952d76f5935c552f69fbd9b1 (patch) | |
tree | 9ee98649d9e84565a18c37566aff940bc91f292b /src/tests/ecore/ecore_test_ecore_audio.c | |
parent | 3b5f002f179a0a1bc44d74a8e63eaf48f9a7b335 (diff) |
ecore_audio test: Better test coverage for inputs
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.c | 147 |
1 files changed, 128 insertions, 19 deletions
diff --git a/src/tests/ecore/ecore_test_ecore_audio.c b/src/tests/ecore/ecore_test_ecore_audio.c index 38d44c8..60f9ede 100644 --- a/src/tests/ecore/ecore_test_ecore_audio.c +++ b/src/tests/ecore/ecore_test_ecore_audio.c | |||
@@ -332,6 +332,9 @@ START_TEST(ecore_test_ecore_audio_obj_tone) | |||
332 | eo_do(in, ecore_audio_obj_in_length_get(&len)); | 332 | eo_do(in, ecore_audio_obj_in_length_get(&len)); |
333 | fail_if(len != 2.5); | 333 | fail_if(len != 2.5); |
334 | 334 | ||
335 | eo_do(in, ecore_audio_obj_in_remaining_get(&len)); | ||
336 | fail_if(len != 2.5); | ||
337 | |||
335 | eo_do(in, eo_base_data_get(ECORE_AUDIO_ATTR_TONE_FREQ, (void **)&freq)); | 338 | eo_do(in, eo_base_data_get(ECORE_AUDIO_ATTR_TONE_FREQ, (void **)&freq)); |
336 | fail_if(freq != 1000); | 339 | fail_if(freq != 1000); |
337 | 340 | ||
@@ -341,6 +344,24 @@ START_TEST(ecore_test_ecore_audio_obj_tone) | |||
341 | eo_do(in, eo_base_data_get(ECORE_AUDIO_ATTR_TONE_FREQ, (void **)&freq)); | 344 | eo_do(in, eo_base_data_get(ECORE_AUDIO_ATTR_TONE_FREQ, (void **)&freq)); |
342 | fail_if(freq != 2000); | 345 | fail_if(freq != 2000); |
343 | 346 | ||
347 | eo_do(in, ecore_audio_obj_in_seek(1.0, SEEK_SET, &len)); | ||
348 | fail_if(len != 1.0); | ||
349 | |||
350 | eo_do(in, ecore_audio_obj_in_remaining_get(&len)); | ||
351 | fail_if(len != 1.5); | ||
352 | |||
353 | eo_do(in, ecore_audio_obj_in_seek(1.0, SEEK_CUR, &len)); | ||
354 | fail_if(len != 2.0); | ||
355 | |||
356 | eo_do(in, ecore_audio_obj_in_remaining_get(&len)); | ||
357 | fail_if(len != 0.5); | ||
358 | |||
359 | eo_do(in, ecore_audio_obj_in_seek(-1.0, SEEK_END, &len)); | ||
360 | fail_if(len != 1.5); | ||
361 | |||
362 | eo_do(in, ecore_audio_obj_in_remaining_get(&len)); | ||
363 | fail_if(len != 1.0); | ||
364 | |||
344 | out = eo_add(ECORE_AUDIO_OBJ_OUT_SNDFILE_CLASS, NULL); | 365 | out = eo_add(ECORE_AUDIO_OBJ_OUT_SNDFILE_CLASS, NULL); |
345 | fail_if(!out); | 366 | fail_if(!out); |
346 | 367 | ||
@@ -443,42 +464,129 @@ START_TEST(ecore_test_ecore_audio_obj_in_out) | |||
443 | } | 464 | } |
444 | END_TEST | 465 | END_TEST |
445 | 466 | ||
467 | START_TEST(ecore_test_ecore_audio_obj_in) | ||
468 | { | ||
469 | int i; | ||
470 | double speed, length; | ||
471 | int samplerate, channels; | ||
472 | Eina_Bool looped; | ||
473 | |||
474 | ssize_t read; | ||
475 | uint8_t buf[10]; | ||
476 | |||
477 | Eo *in = eo_add(ECORE_AUDIO_OBJ_IN_CLASS, NULL); | ||
478 | |||
479 | fail_if(!in); | ||
480 | |||
481 | fail_if(!eo_do(in, ecore_audio_obj_in_speed_get(&speed))); | ||
482 | fail_if(speed != 1.0); | ||
483 | |||
484 | fail_if(!eo_do(in, ecore_audio_obj_in_speed_set(2.5))); | ||
485 | |||
486 | fail_if(!eo_do(in, ecore_audio_obj_in_speed_get(&speed))); | ||
487 | fail_if(speed != 2.5); | ||
488 | |||
489 | fail_if(!eo_do(in, ecore_audio_obj_in_speed_set(0))); | ||
490 | |||
491 | fail_if(!eo_do(in, ecore_audio_obj_in_speed_get(&speed))); | ||
492 | fail_if(speed != 0.2); | ||
493 | |||
494 | fail_if(!eo_do(in, ecore_audio_obj_in_speed_set(10))); | ||
495 | |||
496 | fail_if(!eo_do(in, ecore_audio_obj_in_speed_get(&speed))); | ||
497 | fail_if(speed != 5.0); | ||
498 | |||
499 | fail_if(!eo_do(in, ecore_audio_obj_in_samplerate_get(&samplerate))); | ||
500 | fail_if(samplerate != 0); | ||
501 | |||
502 | fail_if(!eo_do(in, ecore_audio_obj_in_samplerate_set(1234))); | ||
503 | |||
504 | fail_if(!eo_do(in, ecore_audio_obj_in_samplerate_get(&samplerate))); | ||
505 | fail_if(samplerate != 1234); | ||
506 | |||
507 | fail_if(!eo_do(in, ecore_audio_obj_in_channels_get(&channels))); | ||
508 | fail_if(channels != 0); | ||
509 | |||
510 | fail_if(!eo_do(in, ecore_audio_obj_in_channels_set(2))); | ||
511 | |||
512 | fail_if(!eo_do(in, ecore_audio_obj_in_channels_get(&channels))); | ||
513 | fail_if(channels != 2); | ||
514 | |||
515 | fail_if(!eo_do(in, ecore_audio_obj_in_looped_get(&looped))); | ||
516 | fail_if(looped); | ||
517 | |||
518 | fail_if(!eo_do(in, ecore_audio_obj_in_looped_set(EINA_TRUE))); | ||
519 | |||
520 | fail_if(!eo_do(in, ecore_audio_obj_in_looped_get(&looped))); | ||
521 | fail_if(!looped); | ||
522 | |||
523 | fail_if(!eo_do(in, ecore_audio_obj_in_length_get(&length))); | ||
524 | fail_if(length != 0); | ||
525 | |||
526 | fail_if(eo_do(in, ecore_audio_obj_in_length_set(10.0))); | ||
527 | |||
528 | fail_if(!eo_do(in, ecore_audio_obj_in_remaining_get(&length))); | ||
529 | fail_if(length != -1); | ||
530 | |||
531 | memset(buf, 0xaa, 10); | ||
532 | fail_if(!eo_do(in, ecore_audio_obj_in_read(buf, 10, &read))); | ||
533 | fail_if(read != 0); | ||
534 | |||
535 | for (i=0; i<10; i++) { | ||
536 | fail_if(buf[i] != 0xaa); | ||
537 | } | ||
538 | |||
539 | eo_del(in); | ||
540 | } | ||
541 | END_TEST | ||
542 | |||
446 | START_TEST(ecore_test_ecore_audio_obj) | 543 | START_TEST(ecore_test_ecore_audio_obj) |
447 | { | 544 | { |
545 | int i; | ||
448 | const char *name; | 546 | const char *name; |
449 | Eina_Bool paused; | 547 | Eina_Bool paused; |
450 | double volume; | 548 | double volume; |
549 | Eo *objs[2], *obj; | ||
451 | 550 | ||
452 | Eo *in = eo_add(ECORE_AUDIO_OBJ_IN_CLASS, NULL); | 551 | objs[0] = eo_add(ECORE_AUDIO_OBJ_IN_CLASS, NULL); |
552 | fail_if(!objs[0]); | ||
453 | 553 | ||
454 | fail_if(!in); | 554 | objs[1] = eo_add(ECORE_AUDIO_OBJ_OUT_CLASS, NULL); |
555 | fail_if(!objs[1]); | ||
455 | 556 | ||
456 | fail_if(!eo_do(in, ecore_audio_obj_name_get(&name))); | 557 | for (i=0; i<2; i++) { |
558 | obj = objs[i]; | ||
457 | 559 | ||
458 | fail_if(name); | 560 | fail_if(!obj); |
459 | 561 | ||
460 | fail_if(!eo_do(in, ecore_audio_obj_name_set("In1"))); | 562 | fail_if(!eo_do(obj, ecore_audio_obj_name_get(&name))); |
461 | fail_if(!eo_do(in, ecore_audio_obj_name_get(&name))); | ||
462 | 563 | ||
463 | ck_assert_str_eq(name, "In1"); | 564 | fail_if(name); |
464 | 565 | ||
465 | fail_if(!eo_do(in, ecore_audio_obj_name_get(NULL))); | 566 | fail_if(!eo_do(obj, ecore_audio_obj_name_set("In1"))); |
567 | fail_if(!eo_do(obj, ecore_audio_obj_name_get(&name))); | ||
466 | 568 | ||
467 | fail_if(!eo_do(in, ecore_audio_obj_paused_get(&paused))); | 569 | ck_assert_str_eq(name, "In1"); |
468 | fail_if(paused); | ||
469 | 570 | ||
470 | fail_if(!eo_do(in, ecore_audio_obj_paused_set(EINA_TRUE))); | 571 | fail_if(!eo_do(obj, ecore_audio_obj_name_get(NULL))); |
471 | fail_if(!eo_do(in, ecore_audio_obj_paused_get(&paused))); | ||
472 | fail_if(!paused); | ||
473 | 572 | ||
474 | fail_if(!eo_do(in, ecore_audio_obj_volume_get(&volume))); | 573 | fail_if(!eo_do(obj, ecore_audio_obj_paused_get(&paused))); |
475 | fail_if(volume != 1.0); | 574 | fail_if(paused); |
476 | 575 | ||
477 | fail_if(!eo_do(in, ecore_audio_obj_volume_set(0.5))); | 576 | fail_if(!eo_do(obj, ecore_audio_obj_paused_set(EINA_TRUE))); |
478 | fail_if(!eo_do(in, ecore_audio_obj_volume_get(&volume))); | 577 | fail_if(!eo_do(obj, ecore_audio_obj_paused_get(&paused))); |
479 | fail_if(volume != 0.5); | 578 | fail_if(!paused); |
579 | |||
580 | fail_if(!eo_do(obj, ecore_audio_obj_volume_get(&volume))); | ||
581 | fail_if(volume != 1.0); | ||
582 | |||
583 | fail_if(!eo_do(obj, ecore_audio_obj_volume_set(0.5))); | ||
584 | fail_if(!eo_do(obj, ecore_audio_obj_volume_get(&volume))); | ||
585 | fail_if(volume != 0.5); | ||
586 | |||
587 | eo_del(obj); | ||
588 | } | ||
480 | 589 | ||
481 | eo_del(in); | ||
482 | } | 590 | } |
483 | END_TEST | 591 | END_TEST |
484 | 592 | ||
@@ -524,6 +632,7 @@ ecore_test_ecore_audio(TCase *tc) | |||
524 | tcase_add_test(tc, ecore_test_ecore_audio_init); | 632 | tcase_add_test(tc, ecore_test_ecore_audio_init); |
525 | 633 | ||
526 | tcase_add_test(tc, ecore_test_ecore_audio_obj); | 634 | tcase_add_test(tc, ecore_test_ecore_audio_obj); |
635 | tcase_add_test(tc, ecore_test_ecore_audio_obj_in); | ||
527 | tcase_add_test(tc, ecore_test_ecore_audio_obj_in_out); | 636 | tcase_add_test(tc, ecore_test_ecore_audio_obj_in_out); |
528 | tcase_add_test(tc, ecore_test_ecore_audio_obj_sndfile); | 637 | tcase_add_test(tc, ecore_test_ecore_audio_obj_sndfile); |
529 | tcase_add_test(tc, ecore_test_ecore_audio_obj_tone); | 638 | tcase_add_test(tc, ecore_test_ecore_audio_obj_tone); |