summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Blumenkrantz <zmike@osg.samsung.com>2018-04-09 13:36:55 +0200
committerStefan Schmidt <stefan@osg.samsung.com>2018-04-10 11:28:01 +0200
commita995a0c0fecf240d67a588a557dbaeefe06b9c3f (patch)
treedc62a8c6bb1483b232da1f588bcea786a5f43fdd
parent853e2c43cab2f2a5e3211705def20f868e297bc2 (diff)
tests: split ecore_test_ecore_main_loop_poller_add_del into separate tests
Summary: unit tests should verify only small pieces of functionality to ensure that they are testing what they claim to be testing fix T6852 Depends on D5882 Reviewers: stefan_schmidt Subscribers: cedric Maniphest Tasks: T6852 Differential Revision: https://phab.enlightenment.org/D5883
-rw-r--r--src/tests/ecore/ecore_test_ecore.c88
1 files changed, 54 insertions, 34 deletions
diff --git a/src/tests/ecore/ecore_test_ecore.c b/src/tests/ecore/ecore_test_ecore.c
index a09b09452c..d38861a3e3 100644
--- a/src/tests/ecore/ecore_test_ecore.c
+++ b/src/tests/ecore/ecore_test_ecore.c
@@ -20,7 +20,7 @@ static Eina_Bool
20_quit_cb(void *data) 20_quit_cb(void *data)
21{ 21{
22 Eina_Bool *val = data; 22 Eina_Bool *val = data;
23 *val = EINA_TRUE; 23 if (val) *val = EINA_TRUE;
24 ecore_main_loop_quit(); 24 ecore_main_loop_quit();
25 return EINA_FALSE; 25 return EINA_FALSE;
26} 26}
@@ -717,56 +717,74 @@ Eina_Bool _poller_handler(void *data)
717 return ECORE_CALLBACK_RENEW; 717 return ECORE_CALLBACK_RENEW;
718} 718}
719 719
720Eina_Bool _poller_loop(void *data) 720static Eina_Bool
721_poller_loop_add(void *data EINA_UNUSED)
722{
723 ecore_poller_add(ECORE_POLLER_CORE, 1, _quit_cb, NULL);
724 return ECORE_CALLBACK_RENEW;
725}
726
727static Eina_Bool
728_poller_loop_fail(void *data EINA_UNUSED)
721{ 729{
722 int *res = data; 730 ecore_main_loop_quit();
731 ck_abort();
732 return ECORE_CALLBACK_RENEW;
733}
723 734
724 static Ecore_Poller *poll_ptr = NULL; 735static Eina_Bool
736_poller_loop_del(void *data)
737{
725 static int count = 0; 738 static int count = 0;
726 739
727 switch (count) 740 if (count++ == 0)
728 { 741 ecore_poller_del(data);
729 case 2: 742 else
730 poll_ptr = ecore_poller_add(ECORE_POLLER_CORE, 2, _poller_handler, res); 743 ecore_main_loop_quit();
731 break;
732 case 6:
733 ecore_poller_poller_interval_set(poll_ptr, 1);
734 break;
735 case 10:
736 ecore_poller_del(poll_ptr);
737 break;
738 default:
739 // do nothing
740 break;
741 }
742 count++;
743 return ECORE_CALLBACK_RENEW; 744 return ECORE_CALLBACK_RENEW;
744} 745}
745 746
746EFL_START_TEST(ecore_test_ecore_main_loop_poller_add_del) 747static Eina_Bool
748_poller_loop_modify(void *data)
747{ 749{
748 int count_res = 0; 750 ecore_poller_poller_interval_set(data, 1);
749 751 return EINA_FALSE;
750 Eina_Bool did = EINA_FALSE; 752}
751 753
754EFL_START_TEST(ecore_test_ecore_main_loop_poller_add)
755{
752 /* Create renewable main poller */ 756 /* Create renewable main poller */
753 Ecore_Poller *poll_ptr = ecore_poller_add(ECORE_POLLER_CORE, 1, _poller_loop, &count_res); 757 Ecore_Poller *poll_ptr = ecore_poller_add(ECORE_POLLER_CORE, 1, _poller_loop_add, NULL);
754
755 /* One time processed poller */
756 ecore_poller_add(ECORE_POLLER_CORE, 16, _quit_cb, &did);
757 758
758 /* Enter main loop and wait for quit*/ 759 /* Enter main loop and wait for quit*/
759 ecore_main_loop_begin(); 760 ecore_main_loop_begin();
760 761
761 fprintf(stderr, "count_res: %i\n", count_res);
762 /* Validation call counter */
763 fail_if(6 != count_res);
764
765 /* Destroy renewable main poller */ 762 /* Destroy renewable main poller */
766 ecore_poller_del(poll_ptr); 763 ecore_poller_del(poll_ptr);
764}
765EFL_END_TEST
767 766
768 fail_if(did == EINA_FALSE);
769 767
768EFL_START_TEST(ecore_test_ecore_main_loop_poller_del)
769{
770 /* Create renewable main poller */
771 Ecore_Poller *poller = ecore_poller_add(ECORE_POLLER_CORE, 2, _poller_loop_fail, NULL);
772 ecore_poller_add(ECORE_POLLER_CORE, 1, _poller_loop_del, poller);
773
774 /* Enter main loop and wait for quit*/
775 ecore_main_loop_begin();
776}
777EFL_END_TEST
778
779EFL_START_TEST(ecore_test_ecore_main_loop_poller_modify)
780{
781 /* Create renewable main poller */
782 Ecore_Poller *poller = ecore_poller_add(ECORE_POLLER_CORE, 4, _quit_cb, NULL);
783 ecore_poller_add(ECORE_POLLER_CORE, 1, _poller_loop_modify, poller);
784 ecore_poller_add(ECORE_POLLER_CORE, 4, _poller_loop_fail, NULL);
785
786 /* Enter main loop and wait for quit*/
787 ecore_main_loop_begin();
770} 788}
771EFL_END_TEST 789EFL_END_TEST
772 790
@@ -789,7 +807,9 @@ void ecore_test_ecore(TCase *tc)
789#endif 807#endif
790 tcase_add_test(tc, ecore_test_ecore_app); 808 tcase_add_test(tc, ecore_test_ecore_app);
791 tcase_add_test(tc, ecore_test_ecore_main_loop_poller); 809 tcase_add_test(tc, ecore_test_ecore_main_loop_poller);
792 tcase_add_test(tc, ecore_test_ecore_main_loop_poller_add_del); 810 tcase_add_test(tc, ecore_test_ecore_main_loop_poller_add);
811 tcase_add_test(tc, ecore_test_ecore_main_loop_poller_del);
812 tcase_add_test(tc, ecore_test_ecore_main_loop_poller_modify);
793 tcase_add_test(tc, ecore_test_efl_loop_fd); 813 tcase_add_test(tc, ecore_test_efl_loop_fd);
794 tcase_add_test(tc, ecore_test_efl_loop_fd_lifecycle); 814 tcase_add_test(tc, ecore_test_efl_loop_fd_lifecycle);
795} 815}