summaryrefslogtreecommitdiff
path: root/src/tests/ecore/ecore_test_promise.c
diff options
context:
space:
mode:
authorCedric Bail <cedric@osg.samsung.com>2016-07-27 14:28:19 -0700
committerCedric BAIL <cedric@osg.samsung.com>2016-09-08 14:58:06 -0700
commit5edb42d3715366fb0b141763da43bdaaec19dc8f (patch)
tree8b4780d68238b38f9e885cae8b69fbf3b396e173 /src/tests/ecore/ecore_test_promise.c
parent0789156c86fb51cadbf173bbb230a4d2ddef9612 (diff)
ecore: add test for efl_future_race.
Diffstat (limited to 'src/tests/ecore/ecore_test_promise.c')
-rw-r--r--src/tests/ecore/ecore_test_promise.c50
1 files changed, 50 insertions, 0 deletions
diff --git a/src/tests/ecore/ecore_test_promise.c b/src/tests/ecore/ecore_test_promise.c
index e998d99..131e5af 100644
--- a/src/tests/ecore/ecore_test_promise.c
+++ b/src/tests/ecore/ecore_test_promise.c
@@ -1048,6 +1048,55 @@ START_TEST(efl_test_promise_all)
1048} 1048}
1049END_TEST 1049END_TEST
1050 1050
1051static void
1052_then_race(void *data, const Efl_Event *ev)
1053{
1054 Future_Ok *fo = data;
1055 Efl_Future_Event_Success *s = ev->info;
1056 Efl_Future_Race_Success *rs = s->value;
1057
1058 fail_if(rs->index != 1);
1059 fail_if(rs->value != &value[0]);
1060
1061 fo->then = EINA_TRUE;
1062}
1063
1064START_TEST(efl_test_promise_race)
1065{
1066 Efl_Promise *p1, *p2, *p3;
1067 Efl_Future *race = NULL, *f1;
1068 Future_Ok donea = { EINA_FALSE, EINA_FALSE, EINA_FALSE };
1069 Future_Ok donep1 = { EINA_FALSE, EINA_FALSE, EINA_FALSE };
1070
1071 ecore_init();
1072
1073 p1 = efl_add(EFL_PROMISE_CLASS, ecore_main_loop_get());
1074 p2 = efl_add(EFL_PROMISE_CLASS, ecore_main_loop_get());
1075 p3 = efl_add(EFL_PROMISE_CLASS, ecore_main_loop_get());
1076 fail_if(!p1 || !p2 || !p3);
1077
1078 f1 = efl_ref(efl_promise_future_get(p1));
1079 fail_if(!efl_future_then(f1, _then, _cancel, _progress, &donep1));
1080 efl_future_use(&race, efl_future_race(f1, efl_promise_future_get(p2), efl_promise_future_get(p3)));
1081 efl_unref(f1);
1082
1083 fail_if(!efl_future_then(race, _then_race, _cancel, _progress, &donea));
1084 fail_if(!race);
1085
1086 efl_promise_value_set(p2, &value[0], NULL);
1087 fail_if(donep1.then || !donep1.cancel || donep1.progress);
1088 fail_if(!donea.then || donea.cancel || donea.progress);
1089
1090 fail_if(race);
1091
1092 efl_del(p1);
1093 efl_del(p2);
1094 efl_del(p3);
1095
1096 ecore_shutdown();
1097}
1098END_TEST
1099
1051void ecore_test_ecore_promise(TCase *tc) 1100void ecore_test_ecore_promise(TCase *tc)
1052{ 1101{
1053 tcase_add_test(tc, ecore_test_promise); 1102 tcase_add_test(tc, ecore_test_promise);
@@ -1076,4 +1125,5 @@ void ecore_test_ecore_promise(TCase *tc)
1076 tcase_add_test(tc, efl_test_promise_future_optional_success); 1125 tcase_add_test(tc, efl_test_promise_future_optional_success);
1077 tcase_add_test(tc, efl_test_promise_future_optional_cancel); 1126 tcase_add_test(tc, efl_test_promise_future_optional_cancel);
1078 tcase_add_test(tc, efl_test_promise_all); 1127 tcase_add_test(tc, efl_test_promise_all);
1128 tcase_add_test(tc, efl_test_promise_race);
1079} 1129}