summaryrefslogtreecommitdiff
path: root/src/tests/ecore/ecore_test_promise.c
diff options
context:
space:
mode:
authorCedric BAIL <cedric@osg.samsung.com>2016-12-16 13:11:29 -0800
committerCedric BAIL <cedric@osg.samsung.com>2016-12-16 14:10:58 -0800
commitb7635be57d80299d674b0754eda40c966c2580bd (patch)
tree24759dade8e90aabf41090384e5ca12b036bef90 /src/tests/ecore/ecore_test_promise.c
parentc1811de61f7edbc27955f13938bff49ed7e06970 (diff)
ecore: add tests for new promise delayed behavior.
Diffstat (limited to 'src/tests/ecore/ecore_test_promise.c')
-rw-r--r--src/tests/ecore/ecore_test_promise.c140
1 files changed, 140 insertions, 0 deletions
diff --git a/src/tests/ecore/ecore_test_promise.c b/src/tests/ecore/ecore_test_promise.c
index fada926..2040095 100644
--- a/src/tests/ecore/ecore_test_promise.c
+++ b/src/tests/ecore/ecore_test_promise.c
@@ -442,6 +442,49 @@ START_TEST(efl_test_promise_future_multi_success)
442} 442}
443END_TEST 443END_TEST
444 444
445START_TEST(efl_test_promise_future_multi_success_noref)
446{
447 Efl_Promise *p;
448 Efl_Future *f;
449 Future_Ok fo1 = { EINA_FALSE, EINA_FALSE, EINA_FALSE };
450 Future_Ok fo2 = { EINA_FALSE, EINA_FALSE, EINA_FALSE };
451 Eina_Bool deadf = EINA_FALSE, deadp = EINA_FALSE;
452 int progress = 7;
453 int value = 42;
454
455 ecore_init();
456
457 p = efl_add(EFL_PROMISE_CLASS, ecore_main_loop_get());
458 fail_if(!p);
459
460 f = efl_promise_future_get(p);
461 fail_if(!f);
462
463 efl_event_callback_add(f, EFL_EVENT_DEL, _death, &deadf);
464 efl_event_callback_add(p, EFL_EVENT_DEL, _death, &deadp);
465
466 fail_if(!efl_future_then(f, _then, _cancel, _progress, &fo1));
467 fail_if(!efl_future_then(f, _then, _cancel, _progress, &fo2));
468
469 fail_if(deadp || deadf);
470
471 efl_promise_progress_set(p, &progress);
472 efl_promise_value_set(p, &value, NULL);
473
474 ecore_main_loop_iterate();
475
476 fail_if(!fo1.then || fo1.cancel || !fo1.progress);
477 fail_if(!fo2.then || fo2.cancel || !fo2.progress);
478 fail_if(!deadf || deadp);
479
480 efl_del(p);
481
482 fail_if(!deadp);
483
484 ecore_shutdown();
485}
486END_TEST
487
445START_TEST(efl_test_promise_future_multi_cancel) 488START_TEST(efl_test_promise_future_multi_cancel)
446{ 489{
447 Efl_Promise *p; 490 Efl_Promise *p;
@@ -533,6 +576,47 @@ START_TEST(efl_test_promise_before_future_multi_success)
533} 576}
534END_TEST 577END_TEST
535 578
579START_TEST(efl_test_promise_before_future_multi_success_noref)
580{
581 Efl_Promise *p;
582 Efl_Future *f;
583 Future_Ok fo1 = { EINA_FALSE, EINA_FALSE, EINA_FALSE };
584 Future_Ok fo2 = { EINA_FALSE, EINA_FALSE, EINA_FALSE };
585 Eina_Bool deadf = EINA_FALSE, deadp = EINA_FALSE;
586 int progress = 7;
587 int value = 42;
588
589 ecore_init();
590
591 p = efl_add(EFL_PROMISE_CLASS, ecore_main_loop_get());
592 fail_if(!p);
593
594 f = efl_promise_future_get(p);
595 fail_if(!f);
596
597 efl_event_callback_add(f, EFL_EVENT_DEL, _death, &deadf);
598 efl_event_callback_add(p, EFL_EVENT_DEL, _death, &deadp);
599
600 efl_promise_progress_set(p, &progress);
601 efl_promise_value_set(p, &value, NULL);
602
603 fail_if(!efl_future_then(f, _then, _cancel, _progress, &fo1));
604 fail_if(!efl_future_then(f, _then, _cancel, _progress, &fo2));
605
606 ecore_main_loop_iterate();
607
608 fail_if(deadp || !deadf);
609 fail_if(!fo1.then || fo1.cancel || fo1.progress);
610 fail_if(!fo2.then || fo2.cancel || fo2.progress);
611
612 efl_del(p);
613
614 fail_if(!deadp);
615
616 ecore_shutdown();
617}
618END_TEST
619
536START_TEST(efl_test_promise_before_future_multi_cancel) 620START_TEST(efl_test_promise_before_future_multi_cancel)
537{ 621{
538 Efl_Promise *p; 622 Efl_Promise *p;
@@ -585,6 +669,58 @@ START_TEST(efl_test_promise_before_future_multi_cancel)
585} 669}
586END_TEST 670END_TEST
587 671
672START_TEST(efl_test_promise_before_future_multi_cancel_noref)
673{
674 Efl_Promise *p;
675 Efl_Future *f;
676 Future_Ok fo1 = { EINA_FALSE, EINA_FALSE, EINA_FALSE };
677 Future_Ok fo2 = { EINA_FALSE, EINA_FALSE, EINA_FALSE };
678 Future_Ok fo3 = { EINA_FALSE, EINA_FALSE, EINA_FALSE };
679 Eina_Bool deadf = EINA_FALSE, deadp = EINA_FALSE, none = EINA_FALSE;
680 int progress = 7;
681 int value = 42;
682
683 ecore_init();
684
685 p = efl_add(EFL_PROMISE_CLASS, ecore_main_loop_get());
686 fail_if(!p);
687
688 efl_future_use(&f, efl_promise_future_get(p));
689 fail_if(!f);
690
691 efl_event_callback_add(f, EFL_EVENT_DEL, _death, &deadf);
692 efl_event_callback_add(p, EFL_EVENT_DEL, _death, &deadp);
693 efl_event_callback_add(p, EFL_PROMISE_EVENT_FUTURE_NONE, _death, &none);
694
695 efl_promise_progress_set(p, &progress);
696
697 fail_if(!efl_future_then(f, _then, _cancel, _progress, &fo1));
698 fail_if(!efl_future_then(f, _then, _cancel, _progress, &fo2));
699
700 // efl_future_cancel is not delayed, only operation on promise are.
701 efl_future_cancel(f);
702
703 fail_if(efl_future_then(f, _then, _cancel, _progress, &fo3));
704
705 fail_if(deadp || !deadf);
706
707 efl_promise_value_set(p, &value, NULL);
708
709 ecore_main_loop_iterate();
710
711 fail_if(fo1.then || !fo1.cancel || fo1.progress);
712 fail_if(fo2.then || !fo2.cancel || fo2.progress);
713 fail_if(fo3.then || fo3.cancel || fo3.progress);
714 fail_if(!none);
715
716 efl_del(p);
717
718 fail_if(!deadp);
719
720 ecore_shutdown();
721}
722END_TEST
723
588static Eina_Bool cleanup = EINA_FALSE; 724static Eina_Bool cleanup = EINA_FALSE;
589 725
590static void 726static void
@@ -902,9 +1038,13 @@ void ecore_test_ecore_promise(TCase *tc)
902 tcase_add_test(tc, efl_test_promise_before_future_success); 1038 tcase_add_test(tc, efl_test_promise_before_future_success);
903 tcase_add_test(tc, efl_test_promise_before_future_cancel); 1039 tcase_add_test(tc, efl_test_promise_before_future_cancel);
904 tcase_add_test(tc, efl_test_promise_future_multi_success); 1040 tcase_add_test(tc, efl_test_promise_future_multi_success);
1041 tcase_add_test(tc, efl_test_promise_future_multi_success_noref);
905 tcase_add_test(tc, efl_test_promise_future_multi_cancel); 1042 tcase_add_test(tc, efl_test_promise_future_multi_cancel);
906 tcase_add_test(tc, efl_test_promise_before_future_multi_success); 1043 tcase_add_test(tc, efl_test_promise_before_future_multi_success);
1044 tcase_add_test(tc, efl_test_promise_before_future_multi_success_noref);
907 tcase_add_test(tc, efl_test_promise_before_future_multi_cancel); 1045 tcase_add_test(tc, efl_test_promise_before_future_multi_cancel);
1046 tcase_add_test(tc, efl_test_promise_before_future_multi_success_noref);
1047 tcase_add_test(tc, efl_test_promise_before_future_multi_cancel_noref);
908 tcase_add_test(tc, efl_test_promise_future_optional_success); 1048 tcase_add_test(tc, efl_test_promise_future_optional_success);
909 tcase_add_test(tc, efl_test_promise_future_optional_cancel); 1049 tcase_add_test(tc, efl_test_promise_future_optional_cancel);
910 tcase_add_test(tc, efl_test_promise_all); 1050 tcase_add_test(tc, efl_test_promise_all);