summaryrefslogtreecommitdiff
path: root/src/tests/ecore/ecore_test_promise.c
diff options
context:
space:
mode:
authorMike Blumenkrantz <zmike@osg.samsung.com>2018-04-09 13:37:03 +0200
committerStefan Schmidt <stefan@osg.samsung.com>2018-04-10 11:28:01 +0200
commit5e806ee41ff3c3384fa63644e0dddce6105aa756 (patch)
tree0f3b814846bf2f46921730aa104eff465a168a7e /src/tests/ecore/ecore_test_promise.c
parentb4da776b3b6b0e44c153b159ef8b23554555084b (diff)
tests: move ecore promise tests into efl_app_suite
Summary: ref T6815 Depends on D5902 Reviewers: stefan_schmidt Subscribers: cedric Maniphest Tasks: T6815 Differential Revision: https://phab.enlightenment.org/D5903
Diffstat (limited to 'src/tests/ecore/ecore_test_promise.c')
-rw-r--r--src/tests/ecore/ecore_test_promise.c1364
1 files changed, 0 insertions, 1364 deletions
diff --git a/src/tests/ecore/ecore_test_promise.c b/src/tests/ecore/ecore_test_promise.c
deleted file mode 100644
index 1dfa4a6877..0000000000
--- a/src/tests/ecore/ecore_test_promise.c
+++ /dev/null
@@ -1,1364 +0,0 @@
1#ifdef HAVE_CONFIG_H
2# include <config.h>
3#endif
4
5#include <Ecore.h>
6#include <Eina.h>
7#include <stdlib.h>
8#include <errno.h>
9#include <time.h>
10#include <stdarg.h>
11#include <Eo.h>
12#include "ecore_suite.h"
13
14#define CHAIN_SIZE (3)
15#define DEFAULT_ERROR (EFBIG)
16#define DEFAULT_MSG ("Future resolve is working!")
17#define DEFAULT_INT_VALUE (5466)
18#define DEFAULT_INT_VALUE_AS_STRING ("5466")
19#define DEFAULT_TIMEOUT (0.1)
20
21#define VALUE_TYPE_CHECK(_v, _type) \
22 do { \
23 ck_assert_ptr_eq(_v.type, _type); \
24} while(0)
25
26#define ERROR_CHECK(_v, _errno) \
27 do { \
28 Eina_Error _err; \
29 VALUE_TYPE_CHECK(_v, EINA_VALUE_TYPE_ERROR); \
30 fail_if(!eina_value_get(&_v, &_err)); \
31 ck_assert_int_eq(_err, _errno); \
32 } while (0)
33
34typedef struct _PromiseCtx {
35 Eina_Promise *p;
36 Ecore_Timer *t;
37 Eina_Bool fail;
38 Eina_Value *value;
39} PromiseCtx;
40
41typedef struct _Easy_Ctx {
42 Eina_Bool success_called;
43 Eina_Bool error_called;
44 Eina_Bool free_called;
45 Eina_Bool stop_loop;
46} Easy_Ctx;
47
48typedef struct _Race_Ctx {
49 Eina_Value value;
50 unsigned int success_idx;
51 unsigned int failed;
52 unsigned int success;
53} Race_Ctx;
54
55typedef struct _Race_Future_Ctx {
56 Race_Ctx *race_ctx;
57 unsigned int idx;
58 int value;
59} Race_Future_Ctx;
60
61#ifdef EINA_SAFETY_CHECKS
62
63#define LOG_CTX_MULTIPLE_FUNC_CTX_SET(_ctx, ...) \
64 do { \
65 _ctx.level = EINA_LOG_LEVEL_ERR; \
66 _ctx.did = EINA_FALSE; \
67 _ctx.just_fmt = EINA_FALSE; \
68 _ctx.func_ctx_idx = 0; \
69 _ctx.func_ctx = (struct Func_Ctx []){ __VA_ARGS__, {NULL, NULL}}; \
70 } while(0)
71
72#define LOG_CTX_SET(_ctx, _fnc, _msg) LOG_CTX_MULTIPLE_FUNC_CTX_SET(_ctx, {_fnc, _msg})
73
74typedef struct _Log_Ctx {
75 struct Func_Ctx {
76 const char *fnc;
77 const char *msg;
78 } *func_ctx;
79 int level;
80 int func_ctx_idx;
81 Eina_Bool did;
82 Eina_Bool just_fmt;
83} Log_Ctx;
84
85static void
86_eina_test_safety_print_cb(const Eina_Log_Domain *d,
87 Eina_Log_Level level,
88 const char *file,
89 const char *fnc, int line,
90 const char *fmt,
91 void *data,
92 va_list args)
93{
94 Log_Ctx *ctx = data;
95 va_list cp_args;
96 const char *str;
97
98 va_copy(cp_args, args);
99 str = va_arg(cp_args, const char *);
100 va_end(cp_args);
101
102 ck_assert_ptr_ne(ctx->func_ctx[ctx->func_ctx_idx].msg, NULL);
103 ck_assert_int_eq(level, ctx->level);
104 if (ctx->just_fmt)
105 ck_assert_str_eq(fmt, ctx->func_ctx[ctx->func_ctx_idx].msg);
106 else
107 {
108 ck_assert_str_eq(fmt, "%s");
109 ck_assert_str_eq(ctx->func_ctx[ctx->func_ctx_idx].msg, str);
110 }
111 ck_assert_str_eq(ctx->func_ctx[ctx->func_ctx_idx].fnc, fnc);
112 ctx->did = EINA_TRUE;
113 ctx->func_ctx_idx++;
114
115 (void)d;
116 (void)file;
117 (void)line;
118}
119#endif
120
121static void
122_cancel(void *data, const Eina_Promise *dead_ptr EINA_UNUSED)
123{
124 PromiseCtx *ctx = data;
125 if (ctx->t) ecore_timer_del(ctx->t);
126 ctx->t = NULL;
127 eina_value_free(ctx->value);
128 free(ctx);
129}
130
131static void
132_promise_cancel_test(void *data, const Eina_Promise *dead_ptr EINA_UNUSED)
133{
134 Eina_Bool *cancel_called = data;
135 *cancel_called = EINA_TRUE;
136}
137
138static Eina_Bool
139_simple_timeout(void *data)
140{
141 PromiseCtx *ctx = data;
142
143 if (ctx->fail) eina_promise_reject(ctx->p, DEFAULT_ERROR);
144 else
145 {
146 Eina_Value v;
147
148 fail_if(!eina_value_copy(ctx->value, &v));
149 eina_promise_resolve(ctx->p, v);
150 eina_value_free(ctx->value);
151 }
152 free(ctx);
153 return EINA_FALSE;
154}
155
156static Eina_Future_Scheduler *
157_future_scheduler_get(void)
158{
159 return efl_loop_future_scheduler_get(efl_main_loop_get());
160}
161
162static PromiseCtx *
163_promise_ctx_new(void)
164{
165 PromiseCtx *ctx;
166 ctx = calloc(1, sizeof(PromiseCtx));
167 fail_if(!ctx);
168 ctx->p = eina_promise_new(_future_scheduler_get(), _cancel, ctx);
169 fail_if(!ctx->p);
170 return ctx;
171}
172
173static Eina_Future *
174_future_get(PromiseCtx *ctx, double timeout)
175{
176 Eina_Future *f;
177
178 f = eina_future_new(ctx->p);
179 fail_if(!f);
180 ctx->t = ecore_timer_add(timeout, _simple_timeout, ctx);
181 fail_if(!ctx->t);
182 return f;
183}
184
185static Eina_Future *
186_fail_future_get(void)
187{
188 PromiseCtx *ctx = _promise_ctx_new();
189 ctx->fail = EINA_TRUE;
190 return _future_get(ctx, DEFAULT_TIMEOUT);
191}
192
193static Eina_Future *
194_int_future_with_value_and_timeout(int value, double timeout)
195{
196 PromiseCtx *ctx = _promise_ctx_new();
197 ctx->value = eina_value_util_int_new(value);
198 fail_if(!ctx->value);
199 return _future_get(ctx, timeout);
200}
201
202static Eina_Future *
203_int_future_get(void)
204{
205 return _int_future_with_value_and_timeout(DEFAULT_INT_VALUE, DEFAULT_TIMEOUT);
206}
207
208static Eina_Future *
209_str_future_get(void)
210{
211 PromiseCtx *ctx = _promise_ctx_new();
212 ctx->value = eina_value_util_string_new(DEFAULT_MSG);
213 fail_if(!ctx->value);
214 return _future_get(ctx, DEFAULT_TIMEOUT);
215}
216
217static Eina_Value
218_simple_err(void *data EINA_UNUSED, const Eina_Value v, const Eina_Future *dead_future EINA_UNUSED)
219{
220 ERROR_CHECK(v, DEFAULT_ERROR);
221 ecore_main_loop_quit();
222 return v;
223}
224
225static Eina_Value
226_simple_ok(void *data EINA_UNUSED, const Eina_Value v, const Eina_Future *dead_future EINA_UNUSED)
227{
228 const char *msg;
229
230 VALUE_TYPE_CHECK(v, EINA_VALUE_TYPE_STRING);
231 fail_if(!eina_value_get(&v, &msg));
232 ck_assert_str_eq(DEFAULT_MSG, msg);
233 ecore_main_loop_quit();
234 return v;
235}
236
237static Eina_Value
238_chain_stop(void *data, const Eina_Value v, const Eina_Future *dead_future EINA_UNUSED)
239{
240 int *i = data;
241 fail_if(*i != CHAIN_SIZE);
242 ecore_main_loop_quit();
243 return v;
244}
245
246static Eina_Value
247_chain_no_error(void *data, const Eina_Value v, const Eina_Future *dead_future EINA_UNUSED)
248{
249 Eina_Value new_v;
250 static int count = DEFAULT_INT_VALUE;
251 int current_i;
252 int *i = data;
253
254 VALUE_TYPE_CHECK(v, EINA_VALUE_TYPE_INT);
255 fail_if(!eina_value_get(&v, &current_i));
256 fail_if(current_i != count++);
257 fail_if(!eina_value_setup(&new_v, EINA_VALUE_TYPE_INT));
258 fail_if(!eina_value_set(&new_v, count));
259 (*i)++;
260 return new_v;
261}
262
263static Eina_Value
264_chain_error(void *data, const Eina_Value v, const Eina_Future *dead_future EINA_UNUSED)
265{
266 int *i = data;
267
268 ERROR_CHECK(v, DEFAULT_ERROR);
269 (*i)++;
270 return v;
271}
272
273static Eina_Value
274_cancel_cb(void *data, const Eina_Value v, const Eina_Future *dead_future EINA_UNUSED)
275{
276 Eina_Value new_v;
277 int *cancel_count = data;
278
279 fail_if(!eina_value_setup(&new_v, EINA_VALUE_TYPE_INT));
280 ERROR_CHECK(v, ECANCELED);
281 (*cancel_count)++;
282 /* Although this function returns an INT Eina_Value, the next
283 _cancel_cb must receive a EINA_VALYE_TYPE_ERROR as ECANCELED */
284 return new_v;
285}
286
287static Eina_Value
288_inner_resolve(void *data, const Eina_Value v, const Eina_Future *dead_future EINA_UNUSED)
289{
290 Eina_Value new_v;
291 fail_if(!eina_value_setup(&new_v, EINA_VALUE_TYPE_STRING));
292 fail_if(!eina_value_set(&new_v, DEFAULT_MSG));
293 eina_promise_resolve(data, new_v);
294 return v;
295}
296
297static Eina_Value
298_inner_fail(void *data, const Eina_Value v, const Eina_Future *dead_future EINA_UNUSED)
299{
300 eina_promise_reject(data, DEFAULT_ERROR);
301 return v;
302}
303
304static void
305_inner_promise_cancel(void *data EINA_UNUSED, const Eina_Promise *dead_ptr EINA_UNUSED)
306{
307 //This must never happen...
308 fail_if(EINA_FALSE);
309}
310
311static Eina_Value
312_future_promise_create(void *data, const Eina_Value v EINA_UNUSED, const Eina_Future *dead_future EINA_UNUSED)
313{
314 Eina_Promise *p;
315
316 p = eina_promise_new(_future_scheduler_get(), _inner_promise_cancel, NULL);
317 fail_if(!p);
318 eina_future_then(_str_future_get(),
319 data ? _inner_fail : _inner_resolve,
320 p);
321 return eina_promise_as_value(p);
322}
323
324static Eina_Value
325_inner_future_last(void *data, const Eina_Value v, const Eina_Future *dead_future EINA_UNUSED)
326{
327 if (data)
328 ERROR_CHECK(v, DEFAULT_ERROR);
329 else
330 {
331 const char *msg;
332 VALUE_TYPE_CHECK(v, EINA_VALUE_TYPE_STRING);
333 fail_if(!eina_value_get(&v, &msg));
334 ck_assert_str_eq(DEFAULT_MSG, msg);
335 }
336 ecore_main_loop_quit();
337 return v;
338}
339
340static Eina_Value
341_convert_check(void *data EINA_UNUSED, const Eina_Value v, const Eina_Future *dead_future EINA_UNUSED)
342{
343 const char *number;
344 VALUE_TYPE_CHECK(v, EINA_VALUE_TYPE_STRING);
345 fail_if(!eina_value_get(&v, &number));
346 ck_assert_str_eq(DEFAULT_INT_VALUE_AS_STRING, number);
347 ecore_main_loop_quit();
348 return v;
349}
350
351static Eina_Value
352_easy_success(void *data, const Eina_Value v)
353{
354 Easy_Ctx *ctx = data;
355 const char *msg;
356
357 ctx->success_called = EINA_TRUE;
358 VALUE_TYPE_CHECK(v, EINA_VALUE_TYPE_STRING);
359 fail_if(!eina_value_get(&v, &msg));
360 ck_assert_str_eq(DEFAULT_MSG, msg);
361 return v;
362}
363
364static Eina_Value
365_easy_error(void *data, const Eina_Error err)
366{
367 Eina_Value v;
368 Easy_Ctx *ctx = data;
369 fail_if(err != EINVAL);
370 fail_if(!eina_value_setup(&v, EINA_VALUE_TYPE_ERROR));
371 fail_if(!eina_value_set(&v, err));
372 ctx->error_called = EINA_TRUE;
373 return v;
374}
375
376static void
377_easy_free(void *data, const Eina_Future *dead_future EINA_UNUSED)
378{
379 Easy_Ctx *ctx = data;
380 ctx->free_called = EINA_TRUE;
381 if (ctx->stop_loop) ecore_main_loop_quit();
382}
383
384static Eina_Value
385_all_cb(void *data, const Eina_Value array, const Eina_Future *dead EINA_UNUSED)
386{
387 unsigned int len, i, *expected_len = data;
388
389 VALUE_TYPE_CHECK(array, EINA_VALUE_TYPE_ARRAY);
390 len = eina_value_array_count(&array);
391 fail_if(len != *expected_len);
392
393 for (i = 0; i < len; i++)
394 {
395 Eina_Value v;
396
397 fail_if(!eina_value_array_get(&array, i, &v));
398 if (i % 2 == 0)
399 {
400 const char *msg;
401 VALUE_TYPE_CHECK(v, EINA_VALUE_TYPE_STRING);
402 fail_if(!eina_value_get(&v, &msg));
403 ck_assert_str_eq(DEFAULT_MSG, msg);
404 }
405 else
406 {
407 int ivalue = 0;
408 VALUE_TYPE_CHECK(v, EINA_VALUE_TYPE_INT);
409 fail_if(!eina_value_get(&v, &ivalue));
410 fail_if(ivalue != DEFAULT_INT_VALUE);
411 }
412 eina_value_flush(&v);
413 }
414 ecore_main_loop_quit();
415 return array;
416}
417
418static Eina_Value
419_future_all_count(void *data, const Eina_Value v, const Eina_Future *dead EINA_UNUSED)
420{
421 unsigned int *futures_called = data;
422 (*futures_called)++;
423 return v;
424}
425
426static Eina_Value
427_race_cb(void *data, const Eina_Value v, const Eina_Future *dead EINA_UNUSED)
428{
429 Race_Future_Ctx *future_ctx = data;
430 Race_Ctx *ctx = future_ctx->race_ctx;
431
432 if (v.type == EINA_VALUE_TYPE_ERROR)
433 {
434 Eina_Error err;
435 eina_value_get(&v, &err);
436 fail_if(err != ECANCELED);
437 ctx->failed++;
438 }
439 else if (v.type == EINA_VALUE_TYPE_INT)
440 {
441 int i;
442 fail_if(!eina_value_get(&v, &i));
443 fail_if(future_ctx->value != i);
444 ctx->success++;
445 ctx->success_idx = future_ctx->idx;
446 fail_if(!eina_value_copy(&v, &ctx->value));
447 }
448 else fail_if(EINA_TRUE); //This is not supposed to happen!
449 free(future_ctx);
450 return v;
451}
452
453static Eina_Value
454_race_end_cb(void *data, const Eina_Value v, const Eina_Future *dead EINA_UNUSED)
455{
456 Race_Ctx *ctx = data;
457 unsigned int idx;
458 Eina_Value_Struct *st;
459 Eina_Value r;
460
461 VALUE_TYPE_CHECK(v, EINA_VALUE_TYPE_STRUCT);
462
463 st = eina_value_memory_get(&v);
464 fail_if(!st);
465 fail_if(st->desc != EINA_PROMISE_RACE_STRUCT_DESC);
466 fail_if(!eina_value_struct_get(&v, "index", &idx));
467 fail_if(idx != ctx->success_idx);
468 fail_if(!eina_value_struct_get(&v, "value", &r));
469 fail_if(eina_value_compare(&r, &ctx->value));
470 eina_value_flush(&r);
471 ecore_main_loop_quit();
472 return v;
473}
474
475static Eina_Value
476_promise_empty_done(void *data, const Eina_Value value, const Eina_Future *dead_future EINA_UNUSED)
477{
478 Eina_Bool *pdone = data;
479
480 if (!value.type) *pdone = EINA_TRUE;
481
482 ecore_main_loop_quit();
483
484 return value;
485}
486
487EFL_START_TEST(efl_test_timeout)
488{
489 Eina_Future *f;
490 Eina_Bool done = EINA_FALSE;
491
492 fail_if(!ecore_init());
493 f = eina_future_then(efl_loop_timeout(efl_main_loop_get(), 0.0001),
494 _promise_empty_done, &done);
495 fail_if(!f);
496 ecore_main_loop_begin();
497 ecore_shutdown();
498
499 fail_unless(done);
500}
501EFL_END_TEST
502
503EFL_START_TEST(efl_test_job)
504{
505 Eina_Future *f;
506 Eina_Bool done = EINA_FALSE;
507
508 fail_if(!ecore_init());
509 f = eina_future_then(efl_loop_job(efl_main_loop_get()),
510 _promise_empty_done, &done);
511 fail_if(!f);
512 ecore_main_loop_begin();
513 ecore_shutdown();
514
515 fail_unless(done);
516}
517EFL_END_TEST
518
519EFL_START_TEST(efl_test_idle)
520{
521 Eina_Future *f;
522 Eina_Bool done = EINA_FALSE;
523
524 fail_if(!ecore_init());
525 f = eina_future_then(efl_loop_idle(efl_main_loop_get()),
526 _promise_empty_done, &done);
527 fail_if(!f);
528 ecore_main_loop_begin();
529 ecore_shutdown();
530
531 fail_unless(done);
532}
533EFL_END_TEST
534
535
536EFL_START_TEST(efl_test_promise_future_success)
537{
538 Eina_Future *f;
539 fail_if(!ecore_init());
540 f = eina_future_then(_str_future_get(),
541 _simple_ok, NULL);
542 fail_if(!f);
543 ecore_main_loop_begin();
544 ecore_shutdown();
545}
546EFL_END_TEST
547
548EFL_START_TEST(efl_test_promise_future_failure)
549{
550 Eina_Future *f;
551 fail_if(!ecore_init());
552 f = eina_future_then(_fail_future_get(),
553 _simple_err, NULL);
554 fail_if(!f);
555 ecore_main_loop_begin();
556 ecore_shutdown();
557}
558EFL_END_TEST
559
560EFL_START_TEST(efl_test_promise_future_chain_no_error)
561{
562 Eina_Future *f;
563 static int i = 0;
564
565 fail_if(!ecore_init());
566 f = eina_future_chain(_int_future_get(),
567 {.cb = _chain_no_error, .data = &i},
568 {.cb = _chain_no_error, .data = &i},
569 {.cb = _chain_no_error, .data = &i},
570 {.cb = _chain_stop, .data = &i});
571 fail_if(!f);
572 ecore_main_loop_begin();
573 ecore_shutdown();
574}
575EFL_END_TEST
576
577EFL_START_TEST(efl_test_promise_future_chain_error)
578{
579 Eina_Future *f;
580 static int i = 0;
581
582 fail_if(!ecore_init());
583 f = eina_future_chain(_fail_future_get(),
584 {.cb = _chain_error, .data = &i},
585 {.cb = _chain_error, .data = &i},
586 {.cb = _chain_error, .data = &i},
587 {.cb = _chain_stop, .data = &i});
588 fail_if(!f);
589 ecore_main_loop_begin();
590 ecore_shutdown();
591}
592EFL_END_TEST
593
594EFL_START_TEST(efl_test_promise_future_cancel)
595{
596 fail_if(!ecore_init());
597 int i;
598
599 for (i = 0; i < 3; i++)
600 {
601 Eina_Promise *p;
602 Eina_Future *first, *last, *middle;
603 int cancel_count = 0;
604 Eina_Bool cancel_called = EINA_FALSE;
605
606 p = eina_promise_new(_future_scheduler_get(), _promise_cancel_test, &cancel_called);
607 fail_if(!p);
608 first = eina_future_new(p);
609 fail_if(!first);
610 if (i == 2)
611 {
612 Eina_Future *f;
613 last = NULL;
614 f = eina_future_then(first, _cancel_cb, &cancel_count);
615 fail_if(!f);
616 middle = eina_future_then(f, _cancel_cb, &cancel_count);
617 fail_if(!middle);
618 f = eina_future_then(middle, _cancel_cb, &cancel_count);
619 fail_if(!f);
620 }
621 else
622 {
623 middle = NULL;
624 last = eina_future_chain(first,
625 {.cb = _cancel_cb, .data = &cancel_count},
626 {.cb = _cancel_cb, .data = &cancel_count},
627 {.cb = _cancel_cb, .data = &cancel_count});
628 fail_if(!last);
629 }
630 if (i == 0)
631 eina_future_cancel(last);
632 else if (i == 1)
633 eina_future_cancel(first);
634 else
635 eina_future_cancel(middle);
636 fail_if(cancel_count != CHAIN_SIZE);
637 fail_if(!cancel_called);
638 }
639 ecore_shutdown();
640}
641EFL_END_TEST
642
643EFL_START_TEST(efl_test_promise_future_inner_promise)
644{
645 Eina_Future *f;
646
647 fail_if(!ecore_init());
648 f = eina_future_chain(_str_future_get(),
649 {.cb = _future_promise_create, .data = NULL},
650 {.cb = _inner_future_last, .data = NULL});
651 fail_if(!f);
652 ecore_main_loop_begin();
653 ecore_shutdown();
654}
655EFL_END_TEST
656
657EFL_START_TEST(efl_test_promise_future_inner_promise_fail)
658{
659 Eina_Future *f;
660 void *data =(void *) 0x01;
661
662 fail_if(!ecore_init());
663 f = eina_future_chain(_str_future_get(),
664 {.cb = _future_promise_create, .data = data},
665 {.cb = _inner_future_last, .data = data});
666 fail_if(!f);
667 ecore_main_loop_begin();
668 ecore_shutdown();
669}
670EFL_END_TEST
671
672EFL_START_TEST(efl_test_promise_future_implicit_cancel)
673{
674 Eina_Promise *p;
675 Eina_Future *f;
676 int cancel_count = 0;
677 Eina_Bool cancel_called = EINA_FALSE;
678 Eina_Value v = EINA_VALUE_EMPTY;
679
680 fail_if(!ecore_init());
681
682 p = eina_promise_new(_future_scheduler_get(), _promise_cancel_test, &cancel_called);
683 fail_if(!p);
684 f = eina_future_new(p);
685 fail_if(!f);
686 f = eina_future_chain(f,
687 {.cb = _cancel_cb, .data = &cancel_count},
688 {.cb = _cancel_cb, .data = &cancel_count},
689 {.cb = _cancel_cb, .data = &cancel_count});
690 fail_if(!f);
691 eina_promise_resolve(p, v);
692 /*
693 The promise was resolved, but the mainloop is not running.
694 Since ecore_shutdown() will be called all the futures must be cancelled
695 */
696 ecore_shutdown();
697 //All the futures were cancelled at this point
698 fail_if(cancel_count != CHAIN_SIZE);
699 //Cancel should not be called, since we called eina_promise_resolve()
700 fail_if(cancel_called);
701}
702EFL_END_TEST
703
704EFL_START_TEST(efl_test_promise_future_convert)
705{
706 Eina_Future *f;
707
708 fail_if(!ecore_init());
709 f = eina_future_chain(_int_future_get(),
710 eina_future_cb_convert_to(EINA_VALUE_TYPE_STRING),
711 { .cb = _convert_check, .data = NULL });
712 fail_if(!f);
713 ecore_main_loop_begin();
714 ecore_shutdown();
715
716}
717EFL_END_TEST
718
719EFL_START_TEST(efl_test_promise_future_easy)
720{
721 Eina_Future *f;
722 Easy_Ctx easy1 = { 0 };
723 Easy_Ctx easy2 = { 0 };
724 Easy_Ctx easy3 = { 0 };
725
726 easy3.stop_loop = EINA_TRUE;
727 fail_if(!ecore_init());
728 f = eina_future_then_from_desc(_str_future_get(),
729 eina_future_cb_easy(_easy_success,
730 _easy_error,
731 _easy_free,
732 EINA_VALUE_TYPE_STRING,
733 &easy1));
734 fail_if(!f);
735 f = eina_future_then_easy(f, _easy_success, _easy_error,
736 _easy_free, NULL, &easy2);
737 fail_if(!f);
738 f = eina_future_chain_easy(f, {_easy_success, _easy_error,
739 _easy_free, EINA_VALUE_TYPE_INT, &easy3});
740 fail_if(!f);
741 ecore_main_loop_begin();
742 ecore_shutdown();
743 fail_if(!(easy1.success_called && !easy1.error_called && easy1.free_called));
744 fail_if(!(easy2.success_called && !easy2.error_called && easy2.free_called));
745 fail_if(!(!easy3.success_called && easy3.error_called && easy3.free_called));
746}
747EFL_END_TEST
748
749EFL_START_TEST(efl_test_promise_future_all)
750{
751 Eina_Future *futures[11];
752 unsigned int i, futures_called = 0, len = EINA_C_ARRAY_LENGTH(futures);
753
754 fail_if(!ecore_init());
755 for (i = 0; i < len - 1; i++)
756 {
757 Eina_Future *f;
758 if (i % 2 == 0)
759 f = _str_future_get();
760 else
761 f = _int_future_get();
762 fail_if(!f);
763 futures[i] = eina_future_then(f, _future_all_count, &futures_called);
764 fail_if(!futures[i]);
765 }
766
767 futures[--len] = EINA_FUTURE_SENTINEL;
768 fail_if(!eina_future_then(eina_future_all_array(futures), _all_cb, &len));
769 ecore_main_loop_begin();
770 ecore_shutdown();
771 fail_if(futures_called != len);
772}
773EFL_END_TEST
774
775EFL_START_TEST(efl_test_promise_future_race)
776{
777 Race_Ctx ctx = { 0 };
778 Eina_Future *futures[11];
779 unsigned int i, len = EINA_C_ARRAY_LENGTH(futures);
780 double timeouts[10] = {
781 2.0, 1.0, 0.5, 0.1, 4.5, 2.3, 5.6, 1.0, 0.5, 0.3
782 };
783
784 srand(time(NULL));
785 fail_if(!ecore_init());
786 for (i = 0; i < len - 1; i++)
787 {
788 Race_Future_Ctx *future_ctx = calloc(1, sizeof(Race_Future_Ctx));
789 fail_if(!future_ctx);
790 future_ctx->race_ctx = &ctx;
791 future_ctx->idx = i;
792 future_ctx->value = rand() % RAND_MAX;
793 futures[i] = eina_future_then(_int_future_with_value_and_timeout(future_ctx->value, timeouts[i]),
794 _race_cb, future_ctx);
795 fail_if(!futures[i]);
796 }
797
798 futures[--len] = EINA_FUTURE_SENTINEL;
799 fail_if(!eina_future_then(eina_future_race_array(futures),
800 _race_end_cb, &ctx));
801 ecore_main_loop_begin();
802 eina_value_flush(&ctx.value);
803 ecore_shutdown();
804 fail_if(ctx.success != 1);
805 fail_if(ctx.failed != (len - 1));
806}
807EFL_END_TEST
808
809static Eina_Value
810_eo_future1_ok(Eo *eo EINA_UNUSED, const Eina_Value v)
811{
812 const char *number;
813
814 VALUE_TYPE_CHECK(v, EINA_VALUE_TYPE_STRING);
815 fail_if(!eina_value_get(&v, &number));
816 ck_assert_str_eq(DEFAULT_INT_VALUE_AS_STRING, number);
817 return v;
818}
819
820static Eina_Value
821_eo_future1_err(Eo *eo EINA_UNUSED, Eina_Error err EINA_UNUSED)
822{
823 //Should not happen
824 fail_if(EINA_TRUE);
825}
826
827static Eina_Value
828_eo_future2_ok(Eo *eo EINA_UNUSED, const Eina_Value v)
829{
830 //Should not happen
831 fail_if(EINA_TRUE);
832 return v;
833}
834
835static Eina_Value
836_eo_future2_err(Eo *eo EINA_UNUSED, Eina_Error err)
837{
838 Eina_Value v;
839
840 fail_if(err != EINVAL);
841 fail_if(!eina_value_setup(&v, EINA_VALUE_TYPE_INT));
842 fail_if(!eina_value_set(&v, DEFAULT_INT_VALUE));
843 return v;
844}
845
846static void
847_eo_future_free(Eo *eo, const Eina_Future *dead EINA_UNUSED)
848{
849 int *free_called = efl_key_data_get(eo, "free_called");
850 (*free_called)++;
851}
852
853static Eina_Value
854_eo_chain_stop(void *data EINA_UNUSED, const Eina_Value v, const Eina_Future *dead_future EINA_UNUSED)
855{
856 int ivalue = 0;
857 VALUE_TYPE_CHECK(v, EINA_VALUE_TYPE_INT);
858 fail_if(!eina_value_get(&v, &ivalue));
859 ck_assert_int_eq(ivalue, DEFAULT_INT_VALUE);
860 ecore_main_loop_quit();
861 return v;
862}
863
864EFL_START_TEST(efl_test_promise_eo)
865{
866 Eina_Future *f;
867 Eo *obj;
868 int free_called = 0;
869
870 fail_if(!efl_object_init());
871 fail_if(!ecore_init());
872
873 //Use a random object..
874 obj = efl_add(EFL_IO_BUFFER_CLASS, efl_main_loop_get());
875 fail_if(!obj);
876 efl_key_data_set(obj, "free_called", &free_called);
877 f = eina_future_chain(_int_future_get(),
878 eina_future_cb_convert_to(EINA_VALUE_TYPE_STRING),
879 efl_future_cb(obj, _eo_future1_ok, _eo_future1_err, _eo_future_free, EINA_VALUE_TYPE_STRING),
880 efl_future_cb(obj, _eo_future2_ok, _eo_future2_err, _eo_future_free, EINA_VALUE_TYPE_INT),
881 { .cb = _eo_chain_stop });
882 fail_if(!f);
883 ecore_main_loop_begin();
884 efl_unref(obj);
885 ecore_shutdown();
886 efl_object_shutdown();
887 ck_assert_int_eq(free_called, 2);
888}
889EFL_END_TEST
890
891static Eina_Value
892_eo_future_link_success(Eo *eo EINA_UNUSED, const Eina_Value v)
893{
894 //This should never happen
895 fail_if(EINA_TRUE);
896 return v;
897}
898
899static Eina_Value
900_eo_future_link_err(Eo *eo, Eina_Error err)
901{
902 int *err_called = efl_key_data_get(eo, "err_called");
903 Eina_Value v;
904
905 fail_if(!err_called);
906 ck_assert_int_eq(err, ECANCELED);
907 fail_if(!eina_value_setup(&v, EINA_VALUE_TYPE_ERROR));
908 fail_if(!eina_value_set(&v, err));
909 (*err_called)++;
910 return v;
911}
912
913static Eina_Value
914_eo_link_chain_end(void *data EINA_UNUSED, const Eina_Value v, const Eina_Future *dead EINA_UNUSED)
915{
916 int *err_called = data;
917 VALUE_TYPE_CHECK(v, EINA_VALUE_TYPE_ERROR);
918 ERROR_CHECK(v, ECANCELED);
919 (*err_called)++;
920 return v;
921}
922
923EFL_START_TEST(efl_test_promise_eo_link)
924{
925 Eina_Future *f;
926 Eo *obj;
927 int err_called = 0;
928
929 fail_if(!efl_object_init());
930 fail_if(!ecore_init());
931
932 //Use a random object..
933 obj = efl_add(EFL_IO_BUFFER_CLASS, efl_main_loop_get());
934 fail_if(!obj);
935
936 efl_key_data_set(obj, "err_called", &err_called);
937 fail_if(!efl_key_data_get(obj, "err_called"));
938 f = efl_future_chain(obj, _int_future_get(),
939 {.success = _eo_future_link_success, .error = _eo_future_link_err},
940 {.success = _eo_future_link_success, .error = _eo_future_link_err},
941 {.success = _eo_future_link_success, .error = _eo_future_link_err},
942 {.success = _eo_future_link_success, .error = _eo_future_link_err},
943 {.success = _eo_future_link_success, .error = _eo_future_link_err});
944 fail_if(!f);
945 f = eina_future_then(f, _eo_link_chain_end, &err_called);
946 fail_if(!f);
947 /*
948 Since the mainloop is not running and the object is deleted the whole chain must be cancelled.
949 */
950 efl_unref(obj);
951 ecore_shutdown();
952 efl_object_shutdown();
953 ck_assert_int_eq(err_called, 6);
954}
955EFL_END_TEST
956
957static Eina_Value
958_err_ignored(void *data EINA_UNUSED, const Eina_Value v, const Eina_Future *f EINA_UNUSED)
959{
960 //Must be NULL since the error must be ignored.
961 VALUE_TYPE_CHECK(v, NULL);
962 ecore_main_loop_quit();
963 return v;
964}
965
966EFL_START_TEST(efl_test_promise_future_ignore_error)
967{
968 Eina_Future *f;
969
970 fail_if(!ecore_init());
971 f = _fail_future_get();
972 fail_if(!f);
973 eina_future_chain(f, eina_future_cb_ignore_error(DEFAULT_ERROR),
974 {.cb = _err_ignored});
975 ecore_main_loop_begin();
976 ecore_shutdown();
977}
978EFL_END_TEST
979
980#define PROMISE_LOG_DOMAIN_STR ("promise_test_domain")
981
982typedef struct _Promise_Log_Ctx {
983 Eina_Future_Cb_Log_Desc dbg;
984 Eina_Future_Cb_Log_Desc crit;
985 Eina_Future_Cb_Log_Desc warn;
986 Eina_Future_Cb_Log_Desc info;
987 Eina_Future_Cb_Log_Desc err;
988 Eina_Bool dbg_log_ok;
989 Eina_Bool crit_log_ok;
990 Eina_Bool warn_log_ok;
991 Eina_Bool info_log_ok;
992 Eina_Bool err_log_ok;
993} Promise_Log_Ctx;
994
995static Eina_Value
996_log_quit(void *data EINA_UNUSED, const Eina_Value v, const Eina_Future *dead EINA_UNUSED)
997{
998 int ivalue;
999
1000 VALUE_TYPE_CHECK(v, EINA_VALUE_TYPE_INT);
1001 fail_if(!eina_value_get(&v, &ivalue));
1002 fail_if(ivalue != DEFAULT_INT_VALUE);
1003 ecore_main_loop_quit();
1004 return v;
1005}
1006
1007static void
1008_log_test(const Eina_Log_Domain *d,
1009 Eina_Log_Level level,
1010 const char *file, const char *fnc, int line,
1011 const char *fmt, void *data, va_list args)
1012{
1013 Promise_Log_Ctx *ctx = data;
1014 Eina_Bool *log_ok;
1015 Eina_Future_Cb_Log_Desc *desc;
1016 va_list cpy;
1017 const char *prefix, *suffix, *value;
1018
1019 if (strcmp(d->name, PROMISE_LOG_DOMAIN_STR))
1020 return;
1021
1022 switch (level)
1023 {
1024 case EINA_LOG_LEVEL_DBG:
1025 log_ok = &ctx->dbg_log_ok;
1026 desc = &ctx->dbg;
1027 break;
1028 case EINA_LOG_LEVEL_CRITICAL:
1029 log_ok = &ctx->crit_log_ok;
1030 desc = &ctx->crit;
1031 break;
1032 case EINA_LOG_LEVEL_WARN:
1033 log_ok = &ctx->warn_log_ok;
1034 desc = &ctx->warn;
1035 break;
1036 case EINA_LOG_LEVEL_INFO:
1037 log_ok = &ctx->info_log_ok;
1038 desc = &ctx->info;
1039 break;
1040 default:
1041 log_ok = &ctx->err_log_ok;
1042 desc = &ctx->err;
1043 }
1044
1045 ck_assert_str_eq(fnc, desc->func);
1046 ck_assert_str_eq(file, desc->file);
1047 ck_assert_str_eq(fmt, "%s%s%s");
1048 ck_assert_int_eq(desc->line, line);
1049 //FIXME: REmove this check
1050 ck_assert_int_eq(desc->level, level);
1051 va_copy(cpy, args);
1052 prefix = va_arg(cpy, const char *);
1053 value = va_arg(cpy, const char *);
1054 suffix = va_arg(cpy, const char *);
1055 ck_assert_str_eq(prefix, desc->prefix ? desc->prefix : "");
1056 ck_assert_str_eq(suffix, desc->suffix ? desc->suffix : "");
1057 ck_assert_str_eq(value, DEFAULT_INT_VALUE_AS_STRING);
1058 va_end(cpy);
1059 *log_ok = EINA_TRUE;
1060}
1061
1062EFL_START_TEST(efl_test_promise_log)
1063{
1064 Promise_Log_Ctx ctx = { 0 };
1065 Eina_Future *f;
1066 int domain;
1067
1068 fail_if(!ecore_init());
1069
1070 domain = eina_log_domain_register(PROMISE_LOG_DOMAIN_STR, EINA_COLOR_CYAN);
1071 fail_if(domain < 0);
1072 eina_log_domain_level_set(PROMISE_LOG_DOMAIN_STR, EINA_LOG_LEVEL_DBG);
1073 ctx.dbg = (Eina_Future_Cb_Log_Desc){"dbg prefix:", " dbg suffix", __FILE__,
1074 __FUNCTION__, EINA_LOG_LEVEL_DBG,
1075 domain, __LINE__};
1076 ctx.crit = (Eina_Future_Cb_Log_Desc){NULL, NULL, __FILE__,
1077 __FUNCTION__, EINA_LOG_LEVEL_CRITICAL,
1078 domain, __LINE__};
1079 ctx.warn = (Eina_Future_Cb_Log_Desc){"warn prefix:", NULL, __FILE__,
1080 __FUNCTION__, EINA_LOG_LEVEL_WARN,
1081 domain, __LINE__};
1082 ctx.err = (Eina_Future_Cb_Log_Desc){NULL, " err suffix", __FILE__,
1083 __FUNCTION__, EINA_LOG_LEVEL_ERR,
1084 domain, __LINE__};
1085 ctx.info = (Eina_Future_Cb_Log_Desc){"info prefix:", " info suffix",
1086 __FILE__, __FUNCTION__, EINA_LOG_LEVEL_INFO,
1087 domain, __LINE__};
1088 eina_log_print_cb_set(_log_test, &ctx);
1089 f = eina_future_chain(_int_future_get(),
1090 eina_future_cb_log_from_desc(ctx.dbg),
1091 eina_future_cb_log_from_desc(ctx.crit),
1092 eina_future_cb_log_from_desc(ctx.warn),
1093 eina_future_cb_log_from_desc(ctx.err),
1094 eina_future_cb_log_from_desc(ctx.info),
1095 { _log_quit });
1096 fail_if(!f);
1097 ecore_main_loop_begin();
1098 eina_log_domain_unregister(domain);
1099 ecore_shutdown();
1100 fail_if(!ctx.dbg_log_ok);
1101 fail_if(!ctx.crit_log_ok);
1102 fail_if(!ctx.warn_log_ok);
1103 fail_if(!ctx.err_log_ok);
1104 fail_if(!ctx.info_log_ok);
1105}
1106EFL_END_TEST
1107
1108#ifdef EINA_SAFETY_CHECKS
1109
1110static void
1111_dummy_cancel(void *data EINA_UNUSED, const Eina_Promise *dead EINA_UNUSED)
1112{
1113}
1114
1115EFL_START_TEST(efl_test_promise_null)
1116{
1117 Log_Ctx ctx = { 0 };
1118 Eina_Promise *p;
1119
1120 fail_if(!ecore_init());
1121
1122 eina_log_print_cb_set(_eina_test_safety_print_cb, &ctx);
1123 LOG_CTX_SET(ctx, "eina_promise_new", "safety check failed: scheduler == NULL");
1124 p = eina_promise_new(NULL, _dummy_cancel, NULL);
1125 ck_assert_ptr_eq(p, NULL);
1126 fail_unless(ctx.did);
1127
1128 LOG_CTX_SET(ctx, "eina_promise_new", "safety check failed: cancel_cb == NULL");
1129 p = eina_promise_new(_future_scheduler_get(), NULL, NULL);
1130 ck_assert_ptr_eq(p, NULL);
1131 fail_unless(ctx.did);
1132
1133 ecore_shutdown();
1134}
1135EFL_END_TEST
1136
1137EFL_START_TEST(efl_test_promise_reject_resolve_null)
1138{
1139 Log_Ctx ctx = { 0 };
1140 Eina_Value v;
1141
1142 fail_if(!ecore_init());
1143
1144 LOG_CTX_SET(ctx, "eina_promise_resolve", "safety check failed: (p) == NULL");
1145 eina_log_print_cb_set(_eina_test_safety_print_cb, &ctx);
1146 eina_value_setup(&v, EINA_VALUE_TYPE_INT);
1147 VALUE_TYPE_CHECK(v, EINA_VALUE_TYPE_INT);
1148 eina_promise_resolve(NULL, v);
1149 fail_unless(ctx.did);
1150
1151 LOG_CTX_SET(ctx, "eina_promise_reject", "safety check failed: (p) == NULL");
1152 eina_promise_reject(NULL, DEFAULT_ERROR);
1153 fail_unless(ctx.did);
1154 ecore_shutdown();
1155}
1156EFL_END_TEST
1157
1158static Eina_Value
1159_future_null_cb(void *data, const Eina_Value v, const Eina_Future *dead)
1160{
1161 int err;
1162 int *cb_called = data;
1163
1164 ck_assert_ptr_eq(dead, NULL);
1165 VALUE_TYPE_CHECK(v, EINA_VALUE_TYPE_ERROR);
1166 fail_if(!eina_value_get(&v, &err));
1167 ck_assert_int_eq(err, EINVAL);
1168 (*cb_called)++;
1169 return v;
1170}
1171
1172static Eina_Value
1173_future_easy_null_success(void *data EINA_UNUSED, const Eina_Value v)
1174{
1175 //Should not happen
1176 fail_if(EINA_TRUE);
1177 return v;
1178}
1179
1180static Eina_Value
1181_future_easy_null_err(void *data, Eina_Error err)
1182{
1183 int *cb_called = data;
1184 ck_assert_int_eq(err, EINVAL);
1185 (*cb_called)++;
1186 return eina_value_error_init(err);
1187}
1188
1189static void
1190_future_easy_null_free(void *data, const Eina_Future *dead)
1191{
1192 int *cb_called = data;
1193 ck_assert_ptr_eq(dead, NULL);
1194 (*cb_called)++;
1195}
1196
1197EFL_START_TEST(efl_test_future_null)
1198{
1199 Eina_Future *f;
1200 Log_Ctx ctx = { 0 };
1201 int cb_called = 0;
1202 int easy_cb_calls = 0;
1203
1204 fail_if(!ecore_init());
1205
1206 LOG_CTX_SET(ctx, "eina_future_then_from_desc", "safety check failed: (prev) == NULL");
1207 eina_log_print_cb_set(_eina_test_safety_print_cb, &ctx);
1208 f = eina_future_then(NULL, _future_null_cb, &cb_called);
1209 ck_assert_ptr_eq(f, NULL);
1210
1211 ck_assert_int_eq(cb_called, 1);
1212
1213 cb_called = 0;
1214 LOG_CTX_SET(ctx, "eina_future_chain_array", "safety check failed: (prev) == NULL");
1215 f = eina_future_chain(NULL,
1216 eina_future_cb_easy(_future_easy_null_success,
1217 _future_easy_null_err,
1218 _future_easy_null_free,
1219 NULL, &easy_cb_calls),
1220 {_future_null_cb, &cb_called},
1221 {_future_null_cb, &cb_called},
1222 {_future_null_cb, &cb_called},
1223 {_future_null_cb, &cb_called},
1224 {_future_null_cb, &cb_called});
1225 ck_assert_ptr_eq(f, NULL);
1226 ck_assert_int_eq(cb_called, 5);
1227 ck_assert_int_eq(easy_cb_calls, 2);
1228
1229 easy_cb_calls = 0;
1230 LOG_CTX_SET(ctx, "eina_future_chain_easy_array", "safety check failed: (prev) == NULL");
1231 f = eina_future_chain_easy(NULL,
1232 {_future_easy_null_success,
1233 _future_easy_null_err,
1234 _future_easy_null_free,
1235 NULL, &easy_cb_calls});
1236 ck_assert_ptr_eq(f, NULL);
1237 ck_assert_int_eq(easy_cb_calls, 2);
1238 ecore_shutdown();
1239}
1240EFL_END_TEST
1241
1242static Eina_Value
1243_future_race_all_null_cb(void *data, const Eina_Value v, const Eina_Future *dead EINA_UNUSED)
1244{
1245 int err;
1246 int *cb_called = data;
1247
1248 VALUE_TYPE_CHECK(v, EINA_VALUE_TYPE_ERROR);
1249 fail_if(!eina_value_get(&v, &err));
1250 ck_assert_int_eq(err, ENOMEM);
1251 (*cb_called)++;
1252 return v;
1253}
1254
1255EFL_START_TEST(efl_test_future_all_null)
1256{
1257 Log_Ctx ctx = { 0 };
1258 unsigned i, len;
1259 int cb_called = 0;
1260 Eina_Future *futures[11] = { 0 }, *f;
1261
1262 fail_if(!ecore_init());
1263
1264 eina_log_print_cb_set(_eina_test_safety_print_cb, &ctx);
1265
1266 len = EINA_C_ARRAY_LENGTH(futures);
1267 len--;
1268 for (i = 0; i < len; i++)
1269 {
1270 futures[i] = eina_future_then(_int_future_get(),
1271 _future_race_all_null_cb, &cb_called);
1272 fail_if(!futures[i]);
1273 }
1274
1275 LOG_CTX_MULTIPLE_FUNC_CTX_SET(ctx,
1276 {"promise_proxy_of_future_array_create", "safety check failed: array[i] == NULL"},
1277 {"eina_promise_all_array", "safety check failed: r is false"});
1278 //The last future is NULL, which may cause the cancel.
1279 f = eina_future_all_array(futures);
1280 ck_assert_ptr_eq(f, NULL);
1281 ecore_shutdown();
1282 ck_assert_int_eq(cb_called, len);
1283}
1284EFL_END_TEST
1285
1286EFL_START_TEST(efl_test_future_race_null)
1287{
1288 Log_Ctx ctx = { 0 };
1289 unsigned i, len;
1290 int cb_called = 0;
1291 Eina_Future *futures[11] = { 0 }, *f;
1292
1293 fail_if(!ecore_init());
1294
1295 eina_log_print_cb_set(_eina_test_safety_print_cb, &ctx);
1296
1297 len = EINA_C_ARRAY_LENGTH(futures);
1298 len--;
1299 for (i = 0; i < len; i++)
1300 {
1301 futures[i] = eina_future_then(_int_future_get(),
1302 _future_race_all_null_cb, &cb_called);
1303 fail_if(!futures[i]);
1304 }
1305
1306 LOG_CTX_MULTIPLE_FUNC_CTX_SET(ctx,
1307 {"promise_proxy_of_future_array_create", "safety check failed: array[i] == NULL"},
1308 {"eina_promise_race_array", "safety check failed: r is false"});
1309 //The last future is NULL, which may cause the cancel.
1310 f = eina_future_race_array(futures);
1311 ck_assert_ptr_eq(f, NULL);
1312 ecore_shutdown();
1313 ck_assert_int_eq(cb_called, len);
1314}
1315EFL_END_TEST
1316
1317#endif
1318
1319static void
1320promise_init(void)
1321{
1322 /* enable ecore init count manipulation for these tests */
1323 ecore_shutdown();
1324}
1325
1326static void
1327promise_shutdown(void)
1328{
1329 /* enable ecore init count manipulation for these tests */
1330 ecore_init();
1331}
1332
1333void ecore_test_ecore_promise(TCase *tc)
1334{
1335 tcase_add_checked_fixture(tc, promise_init, promise_shutdown);
1336 tcase_add_test(tc, efl_test_timeout);
1337 tcase_add_test(tc, efl_test_job);
1338 tcase_add_test(tc, efl_test_idle);
1339 tcase_add_test(tc, efl_test_promise_future_success);
1340 tcase_add_test(tc, efl_test_promise_future_failure);
1341 tcase_add_test(tc, efl_test_promise_future_chain_no_error);
1342 tcase_add_test(tc, efl_test_promise_future_chain_error);
1343 tcase_add_test(tc, efl_test_promise_future_cancel);
1344 tcase_add_test(tc, efl_test_promise_future_implicit_cancel);
1345 tcase_add_test(tc, efl_test_promise_future_inner_promise);
1346 tcase_add_test(tc, efl_test_promise_future_inner_promise_fail);
1347 tcase_add_test(tc, efl_test_promise_future_convert);
1348 tcase_add_test(tc, efl_test_promise_future_easy);
1349 tcase_add_test(tc, efl_test_promise_future_all);
1350 tcase_add_test(tc, efl_test_promise_future_race);
1351 tcase_add_test(tc, efl_test_promise_future_ignore_error);
1352 tcase_add_test(tc, efl_test_promise_log);
1353 //FIXME: We should move this to EO tests, however they depend on Ecore...
1354 tcase_add_test(tc, efl_test_promise_eo);
1355 tcase_add_test(tc, efl_test_promise_eo_link);
1356
1357#ifdef EINA_SAFETY_CHECKS
1358 tcase_add_test(tc, efl_test_promise_null);
1359 tcase_add_test(tc, efl_test_promise_reject_resolve_null);
1360 tcase_add_test(tc, efl_test_future_null);
1361 tcase_add_test(tc, efl_test_future_all_null);
1362 tcase_add_test(tc, efl_test_future_race_null);
1363#endif
1364}