summaryrefslogtreecommitdiff
path: root/src/tests/ecore/ecore_test_promise.c
diff options
context:
space:
mode:
authorCedric Bail <cedric@osg.samsung.com>2016-07-26 12:08:48 -0700
committerCedric BAIL <cedric@osg.samsung.com>2016-09-08 14:58:05 -0700
commit61957ace36ea0473777155584e29c1588e0290b3 (patch)
treec6747aff934aaa227303051ae4923393c94b0d75 /src/tests/ecore/ecore_test_promise.c
parent84958dc6ca42114068a1aa4b185fdab5f640ae34 (diff)
ecore: add tests for efl_future_all.
Diffstat (limited to 'src/tests/ecore/ecore_test_promise.c')
-rw-r--r--src/tests/ecore/ecore_test_promise.c61
1 files changed, 61 insertions, 0 deletions
diff --git a/src/tests/ecore/ecore_test_promise.c b/src/tests/ecore/ecore_test_promise.c
index d813aca..e998d99 100644
--- a/src/tests/ecore/ecore_test_promise.c
+++ b/src/tests/ecore/ecore_test_promise.c
@@ -988,6 +988,66 @@ START_TEST(efl_test_promise_future_optional_cancel)
988} 988}
989END_TEST 989END_TEST
990 990
991static int value[] = { 42, 7, 3 };
992
993static void
994_then_all(void *data, const Efl_Event *ev)
995{
996 Future_Ok *fo = data;
997 Efl_Future_Event_Success *s = ev->info;
998 Eina_Accessor *ac = s->value;
999 int *i;
1000
1001 fail_if(!eina_accessor_data_get(ac, 0, (void**) &i));
1002 fail_if(i != &value[0]);
1003 fail_if(!eina_accessor_data_get(ac, 1, (void**) &i));
1004 fail_if(i != &value[1]);
1005 fail_if(!eina_accessor_data_get(ac, 2, (void**) &i));
1006 fail_if(i != &value[2]);
1007
1008 fo->then = EINA_TRUE;
1009}
1010
1011START_TEST(efl_test_promise_all)
1012{
1013 Efl_Promise *p1, *p2, *p3;
1014 Efl_Future *all = NULL, *f1;
1015 Future_Ok donea = { EINA_FALSE, EINA_FALSE, EINA_FALSE };
1016 Future_Ok donep1 = { EINA_FALSE, EINA_FALSE, EINA_FALSE };
1017
1018 ecore_init();
1019
1020 p1 = efl_add(EFL_PROMISE_CLASS, ecore_main_loop_get());
1021 p2 = efl_add(EFL_PROMISE_CLASS, ecore_main_loop_get());
1022 p3 = efl_add(EFL_PROMISE_CLASS, ecore_main_loop_get());
1023 fail_if(!p1 || !p2 || !p3);
1024
1025 f1 = efl_ref(efl_promise_future_get(p1));
1026 fail_if(!efl_future_then(f1, _then, _cancel, _progress, &donep1));
1027 efl_future_use(&all, efl_future_all(f1, efl_promise_future_get(p2), efl_promise_future_get(p3)));
1028 efl_unref(f1);
1029
1030 fail_if(!efl_future_then(all, _then_all, _cancel, _progress, &donea));
1031 fail_if(!all);
1032
1033 efl_promise_value_set(p1, &value[0], NULL);
1034 fail_if(!donep1.then || donep1.cancel || donep1.progress);
1035 fail_if(donea.then || donea.cancel || donea.progress);
1036
1037 efl_promise_value_set(p2, &value[1], NULL);
1038 efl_promise_value_set(p3, &value[2], NULL);
1039
1040 fail_if(!donea.then || donea.cancel || donea.progress);
1041 fail_if(all);
1042
1043 efl_del(p1);
1044 efl_del(p2);
1045 efl_del(p3);
1046
1047 ecore_shutdown();
1048}
1049END_TEST
1050
991void ecore_test_ecore_promise(TCase *tc) 1051void ecore_test_ecore_promise(TCase *tc)
992{ 1052{
993 tcase_add_test(tc, ecore_test_promise); 1053 tcase_add_test(tc, ecore_test_promise);
@@ -1015,4 +1075,5 @@ void ecore_test_ecore_promise(TCase *tc)
1015 tcase_add_test(tc, efl_test_promise_before_future_multi_cancel); 1075 tcase_add_test(tc, efl_test_promise_before_future_multi_cancel);
1016 tcase_add_test(tc, efl_test_promise_future_optional_success); 1076 tcase_add_test(tc, efl_test_promise_future_optional_success);
1017 tcase_add_test(tc, efl_test_promise_future_optional_cancel); 1077 tcase_add_test(tc, efl_test_promise_future_optional_cancel);
1078 tcase_add_test(tc, efl_test_promise_all);
1018} 1079}