summaryrefslogtreecommitdiff
path: root/src/tests/ecore/ecore_test_ecore.c
diff options
context:
space:
mode:
authorMike Blumenkrantz <zmike@osg.samsung.com>2018-04-09 13:37:02 +0200
committerStefan Schmidt <stefan@osg.samsung.com>2018-04-10 11:28:01 +0200
commit1bd52cc1167fc6ce83a845b0d6393e3a9ae60b90 (patch)
tree22de6dd39bddd445b60186a26233b922d7e55515 /src/tests/ecore/ecore_test_ecore.c
parent88a6a3c76908d10d83c0f24e04ef2614fa4e94c2 (diff)
tests: split ecore poller tests into separate file
Summary: ref T6850 Depends on D5900 Reviewers: stefan_schmidt Subscribers: cedric Maniphest Tasks: T6850 Differential Revision: https://phab.enlightenment.org/D5901
Diffstat (limited to 'src/tests/ecore/ecore_test_ecore.c')
-rw-r--r--src/tests/ecore/ecore_test_ecore.c144
1 files changed, 0 insertions, 144 deletions
diff --git a/src/tests/ecore/ecore_test_ecore.c b/src/tests/ecore/ecore_test_ecore.c
index 0314eebc6e..8159e22fb4 100644
--- a/src/tests/ecore/ecore_test_ecore.c
+++ b/src/tests/ecore/ecore_test_ecore.c
@@ -10,9 +10,6 @@
10 10
11#include "ecore_suite.h" 11#include "ecore_suite.h"
12 12
13#define FP_ERR (0.0000001)
14#define CHECK_FP(a, b) ((a - b) < FP_ERR)
15
16#define ECORE_EVENT_CUSTOM_1 1 13#define ECORE_EVENT_CUSTOM_1 1
17#define ECORE_EVENT_CUSTOM_2 2 14#define ECORE_EVENT_CUSTOM_2 2
18 15
@@ -471,143 +468,6 @@ EFL_START_TEST(ecore_test_ecore_app)
471} 468}
472EFL_END_TEST 469EFL_END_TEST
473 470
474Eina_Bool _poller_cb(void *data)
475{
476 int *val = data;
477 (*val)++;
478 return ECORE_CALLBACK_RENEW;
479}
480
481EFL_START_TEST(ecore_test_ecore_main_loop_poller)
482{
483 Ecore_Poller *poll1_ptr = NULL;
484 int poll1_interval = 1;
485 int poll1_counter = 0;
486
487 Ecore_Poller *poll2_ptr = NULL;
488 int poll2_interval = 2;
489 int poll2_counter = 0;
490
491 Ecore_Poller *poll3_ptr = NULL;
492 int poll3_interval = 4;
493 int poll3_counter = 0;
494
495 Eina_Bool did = EINA_FALSE;
496
497 /* Check ECORE_POLLER_CORE poll interval */
498 double interval = 0.05;
499 ecore_poller_poll_interval_set(ECORE_POLLER_CORE, interval);
500 fail_unless(CHECK_FP(ecore_poller_poll_interval_get(ECORE_POLLER_CORE), interval));
501
502 /* Create three pollers with different poller interval */
503 poll1_ptr = ecore_poller_add(ECORE_POLLER_CORE, poll1_interval, _poller_cb, &poll1_counter);
504 poll2_ptr = ecore_poller_add(ECORE_POLLER_CORE, poll2_interval, _poller_cb, &poll2_counter);
505 poll3_ptr = ecore_poller_add(ECORE_POLLER_CORE, poll3_interval, _poller_cb, &poll3_counter);
506
507 /* Add one time processed quit poller */
508 ecore_poller_add(ECORE_POLLER_CORE, 8, _quit_cb, &did);
509
510 /* Enter main loop and wait 8 intervals for quit */
511 ecore_main_loop_begin();
512
513 /* Check each poller poll interval */
514 fail_if(ecore_poller_poller_interval_get(poll1_ptr) != poll1_interval);
515 fail_if(ecore_poller_poller_interval_get(poll2_ptr) != poll2_interval);
516 fail_if(ecore_poller_poller_interval_get(poll3_ptr) != poll3_interval);
517
518 /* Check each poller call counter */
519 ck_assert_int_eq(8, poll1_counter);
520 ck_assert_int_eq(4, poll2_counter);
521 ck_assert_int_eq(2, poll3_counter);
522
523 /* Destroy renewable pollers */
524 ecore_poller_del(poll3_ptr);
525 ecore_poller_del(poll2_ptr);
526 ecore_poller_del(poll1_ptr);
527
528 fail_if(did == EINA_FALSE);
529
530}
531EFL_END_TEST
532
533Eina_Bool _poller_handler(void *data)
534{
535 int *val = data;
536 (*val)++;
537 return ECORE_CALLBACK_RENEW;
538}
539
540static Eina_Bool
541_poller_loop_add(void *data EINA_UNUSED)
542{
543 ecore_poller_add(ECORE_POLLER_CORE, 1, _quit_cb, NULL);
544 return ECORE_CALLBACK_RENEW;
545}
546
547static Eina_Bool
548_poller_loop_fail(void *data EINA_UNUSED)
549{
550 ecore_main_loop_quit();
551 ck_abort();
552 return ECORE_CALLBACK_RENEW;
553}
554
555static Eina_Bool
556_poller_loop_del(void *data)
557{
558 static int count = 0;
559
560 if (count++ == 0)
561 ecore_poller_del(data);
562 else
563 ecore_main_loop_quit();
564 return ECORE_CALLBACK_RENEW;
565}
566
567static Eina_Bool
568_poller_loop_modify(void *data)
569{
570 ecore_poller_poller_interval_set(data, 1);
571 return EINA_FALSE;
572}
573
574EFL_START_TEST(ecore_test_ecore_main_loop_poller_add)
575{
576 /* Create renewable main poller */
577 Ecore_Poller *poll_ptr = ecore_poller_add(ECORE_POLLER_CORE, 1, _poller_loop_add, NULL);
578
579 /* Enter main loop and wait for quit*/
580 ecore_main_loop_begin();
581
582 /* Destroy renewable main poller */
583 ecore_poller_del(poll_ptr);
584}
585EFL_END_TEST
586
587
588EFL_START_TEST(ecore_test_ecore_main_loop_poller_del)
589{
590 /* Create renewable main poller */
591 Ecore_Poller *poller = ecore_poller_add(ECORE_POLLER_CORE, 2, _poller_loop_fail, NULL);
592 ecore_poller_add(ECORE_POLLER_CORE, 1, _poller_loop_del, poller);
593
594 /* Enter main loop and wait for quit*/
595 ecore_main_loop_begin();
596}
597EFL_END_TEST
598
599EFL_START_TEST(ecore_test_ecore_main_loop_poller_modify)
600{
601 /* Create renewable main poller */
602 Ecore_Poller *poller = ecore_poller_add(ECORE_POLLER_CORE, 4, _quit_cb, NULL);
603 ecore_poller_add(ECORE_POLLER_CORE, 1, _poller_loop_modify, poller);
604 ecore_poller_add(ECORE_POLLER_CORE, 4, _poller_loop_fail, NULL);
605
606 /* Enter main loop and wait for quit*/
607 ecore_main_loop_begin();
608}
609EFL_END_TEST
610
611void ecore_test_ecore(TCase *tc) 471void ecore_test_ecore(TCase *tc)
612{ 472{
613 tcase_add_test(tc, ecore_test_ecore_init); 473 tcase_add_test(tc, ecore_test_ecore_init);
@@ -621,8 +481,4 @@ void ecore_test_ecore(TCase *tc)
621 tcase_add_test(tc, ecore_test_ecore_main_loop_event_recursive); 481 tcase_add_test(tc, ecore_test_ecore_main_loop_event_recursive);
622#endif 482#endif
623 tcase_add_test(tc, ecore_test_ecore_app); 483 tcase_add_test(tc, ecore_test_ecore_app);
624 tcase_add_test(tc, ecore_test_ecore_main_loop_poller);
625 tcase_add_test(tc, ecore_test_ecore_main_loop_poller_add);
626 tcase_add_test(tc, ecore_test_ecore_main_loop_poller_del);
627 tcase_add_test(tc, ecore_test_ecore_main_loop_poller_modify);
628} 484}