summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWoochanlee <wc0917.lee@samsung.com>2020-01-14 08:24:22 -0500
committerChristopher Michael <cp.michael@samsung.com>2020-01-14 08:33:03 -0500
commit2010c2ce132a4638f062a00b301c23bc41192b77 (patch)
tree1510efecf225ef299bba4fe9358a51d2ba44e287
parentae30d3c57bc28bddd9e3a6c18163719fd8958f06 (diff)
tests/ecore_wl2: Add test for ecore_wl2_window_xxx functions
Summary: Add below APIs. ecore_wl2_window_commit ecore_wl2_window_frame_callback_add, del ecore_wl2_window_free ecore_wl2_window_hide ecore_wl2_window_shell_surface_exists ecore_wl2_window_show ecore_wl2_window_update_begin + Fix ecore_wl2_activated_get() ref T8016 Reviewers: devilhorns Subscribers: cedric, #reviewers, #committers Tags: #efl Maniphest Tasks: T8016 Differential Revision: https://phab.enlightenment.org/D11007
-rw-r--r--src/tests/ecore_wl2/ecore_wl2_test_window.c496
-rw-r--r--src/tests/ecore_wl2/meson.build10
2 files changed, 504 insertions, 2 deletions
diff --git a/src/tests/ecore_wl2/ecore_wl2_test_window.c b/src/tests/ecore_wl2/ecore_wl2_test_window.c
index ca843730af..86ff1145c3 100644
--- a/src/tests/ecore_wl2/ecore_wl2_test_window.c
+++ b/src/tests/ecore_wl2/ecore_wl2_test_window.c
@@ -7,6 +7,12 @@
7#include <Eina.h> 7#include <Eina.h>
8#include <Ecore.h> 8#include <Ecore.h>
9#include <Ecore_Wl2.h> 9#include <Ecore_Wl2.h>
10#include <wayland-egl.h>
11
12#ifdef GL_GLES
13#include <EGL/egl.h>
14#include <GLES2/gl2.h>
15#endif
10 16
11#include "ecore_wl2_suite.h" 17#include "ecore_wl2_suite.h"
12#include "ecore_wl2_tests_helpers.h" 18#include "ecore_wl2_tests_helpers.h"
@@ -14,6 +20,27 @@
14#define WIDTH 480 20#define WIDTH 480
15#define HEIGHT 360 21#define HEIGHT 360
16 22
23typedef struct _Test_Data {
24 Ecore_Wl2_Display *display;
25 Ecore_Wl2_Window *win;
26 Ecore_Wl2_Frame_Cb_Handle *frame_callback_handler;
27 Ecore_Event_Handler *handler;
28
29 struct wl_surface *surface;
30 struct wl_egl_window *egl_window;
31
32 int width;
33 int height;
34 int frame_callback_count;
35
36#ifdef GL_GLES
37 EGLDisplay egl_display;
38 EGLConfig egl_conf;
39 EGLSurface egl_surface;
40 EGLContext egl_context;
41#endif
42} Test_Data;
43
17static Ecore_Wl2_Window * 44static Ecore_Wl2_Window *
18_window_create(Ecore_Wl2_Display *disp) 45_window_create(Ecore_Wl2_Display *disp)
19{ 46{
@@ -26,6 +53,42 @@ _surface_get(Ecore_Wl2_Window *win)
26 return ecore_wl2_window_surface_get(win); 53 return ecore_wl2_window_surface_get(win);
27} 54}
28 55
56#ifdef GL_GLES
57static void
58_init_egl(Test_Data *td)
59{
60 eglBindAPI(EGL_OPENGL_API);
61 EGLint num_config;
62
63 EGLint attributes[] = {
64 EGL_RED_SIZE, 8,
65 EGL_GREEN_SIZE, 8,
66 EGL_BLUE_SIZE, 8,
67 EGL_NONE
68 };
69
70 td->egl_display = eglGetDisplay((EGLNativeDisplayType)ecore_wl2_display_get(td->display));
71 eglInitialize(td->egl_display, NULL, NULL);
72 eglChooseConfig(td->egl_display, attributes, &td->egl_conf, 1, &num_config);
73 td->egl_context = eglCreateContext(td->egl_display, td->egl_conf, EGL_NO_CONTEXT, NULL);
74
75 td->egl_window = wl_egl_window_create(td->surface, td->width, td->height);
76 td->egl_surface = eglCreateWindowSurface(td->egl_display,
77 td->egl_conf, td->egl_window, NULL);
78
79 eglMakeCurrent(td->egl_display, td->egl_surface, td->egl_surface, td->egl_context);
80}
81
82static void
83_term_egl(Test_Data *td)
84{
85 eglDestroySurface(td->egl_display, td->egl_surface);
86 wl_egl_window_destroy(td->egl_window);
87 eglDestroyContext(td->egl_display, td->egl_context);
88 eglTerminate(td->egl_display);
89}
90#endif
91
29EFL_START_TEST(wl2_window_new) 92EFL_START_TEST(wl2_window_new)
30{ 93{
31 Ecore_Wl2_Display *disp; 94 Ecore_Wl2_Display *disp;
@@ -310,6 +373,94 @@ EFL_START_TEST(wl2_window_type)
310} 373}
311EFL_END_TEST 374EFL_END_TEST
312 375
376#ifdef GL_GLES
377static void
378_test_activated_frame_cb(Ecore_Wl2_Window *win EINA_UNUSED, uint32_t timestamp EINA_UNUSED, void *data)
379{
380 Test_Data *td = data;
381
382 td->frame_callback_count++;
383 if (td->frame_callback_count % 4 == 0)
384 glClearColor(0.0, 1.0, 0.0, 0.0);
385 else if (td->frame_callback_count % 4 == 1)
386 glClearColor(0.0, 0.0, 1.0, 0.0);
387 else if (td->frame_callback_count % 4 == 2)
388 glClearColor(0.0, 0.0, 0.0, 1.0);
389 else
390 glClearColor(1.0, 0.0, 0.0, 0.0);
391 glClear(GL_COLOR_BUFFER_BIT);
392 glFlush();
393
394 eglSwapBuffers(td->egl_display, td->egl_surface);
395
396 ecore_wl2_window_commit(td->win, EINA_TRUE);
397}
398
399static Eina_Bool
400_test_activated_configure_complete(void *data, int type EINA_UNUSED, void *event EINA_UNUSED)
401{
402 Test_Data *td = data;
403
404 td->frame_callback_handler = ecore_wl2_window_frame_callback_add(td->win, _test_activated_frame_cb, td);
405 ecore_wl2_window_commit(td->win, EINA_TRUE);
406
407 return ECORE_CALLBACK_PASS_ON;
408}
409
410static Eina_Bool
411_test_activated_window_activate(void *data EINA_UNUSED, int type EINA_UNUSED, void *event EINA_UNUSED)
412{
413 //TC Pass
414 ecore_main_loop_quit();
415
416 return ECORE_CALLBACK_PASS_ON;
417}
418
419EFL_START_TEST(wl2_window_activated)
420{
421 Test_Data *td;
422
423 ecore_wl2_init();
424
425 td = calloc(1, sizeof(Test_Data));
426 td->width = WIDTH;
427 td->height = HEIGHT;
428 td->frame_callback_count = 0;
429
430 td->display = _display_connect();
431 ck_assert(td->display != NULL);
432
433 td->win = _window_create(td->display);
434 ck_assert(td->win != NULL);
435
436 ecore_wl2_window_type_set(td->win, ECORE_WL2_WINDOW_TYPE_TOPLEVEL);
437
438 td->surface = _surface_get(td->win);
439 ck_assert(td->surface != NULL);
440
441 ecore_wl2_window_show(td->win);
442
443 _init_egl(td);
444 td->handler = ecore_event_handler_add(ECORE_WL2_EVENT_WINDOW_CONFIGURE_COMPLETE,
445 _test_activated_configure_complete, td);
446 ecore_event_handler_add(ECORE_WL2_EVENT_WINDOW_ACTIVATE,
447 _test_activated_window_activate, NULL);
448
449 ecore_main_loop_begin();
450
451 _term_egl(td);
452 ecore_wl2_shutdown();
453 free(td);
454}
455EFL_END_TEST
456#else
457EFL_START_TEST(wl2_window_activated)
458{
459 fail_if("No GL enabled GL should be enabled for API test");
460}
461EFL_END_TEST
462#endif
463
313EFL_START_TEST(wl2_window_aspect) 464EFL_START_TEST(wl2_window_aspect)
314{ 465{
315 Ecore_Wl2_Display *disp; 466 Ecore_Wl2_Display *disp;
@@ -494,6 +645,339 @@ EFL_START_TEST(wl2_window_popup_input)
494} 645}
495EFL_END_TEST 646EFL_END_TEST
496 647
648static void
649_test_commit_frame_cb(Ecore_Wl2_Window *win EINA_UNUSED, uint32_t timestamp EINA_UNUSED, void *data)
650{
651 Test_Data *td = data;
652 td->frame_callback_count++;
653 ecore_main_loop_quit();
654}
655
656static Eina_Bool
657_test_commit_configure_complete(void *data, int type EINA_UNUSED, void *event EINA_UNUSED)
658{
659 Test_Data *td = data;
660
661 td->frame_callback_handler = ecore_wl2_window_frame_callback_add(td->win, _test_commit_frame_cb, td);
662 ecore_wl2_window_commit(td->win, EINA_TRUE);
663
664 return ECORE_CALLBACK_PASS_ON;
665}
666
667EFL_START_TEST(wl2_window_commit)
668{
669 Test_Data *td;
670
671 ecore_wl2_init();
672
673 td = calloc(1, sizeof(Test_Data));
674 td->width = WIDTH;
675 td->height = HEIGHT;
676 td->frame_callback_count = 0;
677
678 td->display = _display_connect();
679 ck_assert(td->display != NULL);
680
681 td->win = _window_create(td->display);
682 ck_assert(td->win != NULL);
683
684 ecore_wl2_window_type_set(td->win, ECORE_WL2_WINDOW_TYPE_TOPLEVEL);
685
686 td->surface = _surface_get(td->win);
687 ck_assert(td->surface != NULL);
688
689 ecore_wl2_window_show(td->win);
690
691 td->handler = ecore_event_handler_add(ECORE_WL2_EVENT_WINDOW_CONFIGURE_COMPLETE,
692 _test_commit_configure_complete, td);
693
694 ecore_main_loop_begin();
695
696 //Check if the frame callback was called properly by ecore_wl2_window_commit().
697 fail_if(td->frame_callback_count == 0);
698
699 ecore_wl2_shutdown();
700 free(td);
701}
702EFL_END_TEST
703
704static void
705_test_frame_callback_frame_cb(Ecore_Wl2_Window *win EINA_UNUSED, uint32_t timestamp EINA_UNUSED, void *data)
706{
707 Test_Data *td = data;
708 td->frame_callback_count++;
709 if (td->frame_callback_count == 1)
710 {
711 ecore_wl2_window_frame_callback_del(td->frame_callback_handler);
712 td->frame_callback_handler = NULL;
713 ecore_main_loop_quit();
714 }
715}
716
717static Eina_Bool
718_test_frame_callback_configure_complete(void *data, int type EINA_UNUSED, void *event EINA_UNUSED)
719{
720 Test_Data *td = data;
721
722 td->frame_callback_handler = ecore_wl2_window_frame_callback_add(td->win, _test_frame_callback_frame_cb, td);
723 ecore_wl2_window_commit(td->win, EINA_TRUE);
724
725 return ECORE_CALLBACK_PASS_ON;
726}
727
728EFL_START_TEST(wl2_window_frame_callback)
729{
730 Test_Data *td;
731
732 ecore_wl2_init();
733
734 td = calloc(1, sizeof(Test_Data));
735 td->width = WIDTH;
736 td->height = HEIGHT;
737 td->frame_callback_count = 0;
738
739 td->display = _display_connect();
740 ck_assert(td->display != NULL);
741
742 td->win = _window_create(td->display);
743 ck_assert(td->win != NULL);
744
745 ecore_wl2_window_type_set(td->win, ECORE_WL2_WINDOW_TYPE_TOPLEVEL);
746
747 td->surface = _surface_get(td->win);
748 ck_assert(td->surface != NULL);
749
750 ecore_wl2_window_show(td->win);
751
752 td->handler = ecore_event_handler_add(ECORE_WL2_EVENT_WINDOW_CONFIGURE_COMPLETE,
753 _test_frame_callback_configure_complete, td);
754
755 ecore_main_loop_begin();
756
757 //Check if the frame callback called after then it sets NULL or not.
758 fail_if(td->frame_callback_count != 1);
759 fail_if(td->frame_callback_handler != NULL);
760
761 ecore_wl2_shutdown();
762 free(td);
763}
764EFL_END_TEST
765
766EFL_START_TEST(wl2_window_free)
767{
768 Ecore_Wl2_Window *t_win;
769 Test_Data *td;
770
771 ecore_wl2_init();
772
773 td = calloc(1, sizeof(Test_Data));
774
775 td->display = _display_connect();
776 ck_assert(td->display != NULL);
777
778 td->win = _window_create(td->display);
779 ck_assert(td->win != NULL);
780
781 ecore_wl2_window_type_set(td->win, ECORE_WL2_WINDOW_TYPE_TOPLEVEL);
782
783 td->surface = _surface_get(td->win);
784 ck_assert(td->surface != NULL);
785
786 ecore_wl2_window_show(td->win);
787
788 t_win = ecore_wl2_display_window_find_by_surface(td->display, td->surface);
789
790 fail_if(td->win != t_win);
791
792 ecore_wl2_window_free(td->win);
793 t_win = ecore_wl2_display_window_find_by_surface(td->display, td->surface);
794
795 //Check the returned window with freed window.
796 fail_if(td->win == t_win);
797
798 ecore_wl2_shutdown();
799 free(td);
800}
801EFL_END_TEST
802
803static Eina_Bool
804_test_hide_window_hide(void *data EINA_UNUSED, int type EINA_UNUSED, void *event EINA_UNUSED)
805{
806 //TC pass
807 ecore_main_loop_quit();
808
809 return ECORE_CALLBACK_PASS_ON;
810}
811
812EFL_START_TEST(wl2_window_hide)
813{
814 Test_Data *td;
815
816 ecore_wl2_init();
817
818 td = calloc(1, sizeof(Test_Data));
819 td->width = WIDTH;
820 td->height = HEIGHT;
821 td->frame_callback_count = 0;
822
823 td->display = _display_connect();
824 ck_assert(td->display != NULL);
825
826 td->win = _window_create(td->display);
827 ck_assert(td->win != NULL);
828
829 ecore_wl2_window_type_set(td->win, ECORE_WL2_WINDOW_TYPE_TOPLEVEL);
830
831 td->surface = _surface_get(td->win);
832 ck_assert(td->surface != NULL);
833
834 ecore_wl2_window_show(td->win);
835
836 ecore_wl2_window_hide(td->win);
837 td->handler = ecore_event_handler_add(ECORE_WL2_EVENT_WINDOW_HIDE,
838 _test_hide_window_hide, NULL);
839
840 ecore_main_loop_begin();
841
842 ecore_wl2_shutdown();
843 free(td);
844}
845EFL_END_TEST
846
847EFL_START_TEST(wl2_window_shell_surface_exists)
848{
849 Test_Data *td;
850
851 ecore_wl2_init();
852
853 td = calloc(1, sizeof(Test_Data));
854 td->width = WIDTH;
855 td->height = HEIGHT;
856 td->frame_callback_count = 0;
857
858 td->display = _display_connect();
859 ck_assert(td->display != NULL);
860
861 td->win = _window_create(td->display);
862 ck_assert(td->win != NULL);
863
864 ecore_wl2_window_type_set(td->win, ECORE_WL2_WINDOW_TYPE_TOPLEVEL);
865
866 td->surface = _surface_get(td->win);
867 ck_assert(td->surface != NULL);
868
869 ecore_wl2_window_show(td->win);
870
871 //window_show function will create shell surface. then checks it.
872 fail_if(ecore_wl2_window_shell_surface_exists(td->win) == EINA_FALSE);
873
874 ecore_wl2_shutdown();
875 free(td);
876}
877EFL_END_TEST
878
879static Eina_Bool
880_test_show_window_show(void *data EINA_UNUSED, int type EINA_UNUSED, void *event EINA_UNUSED)
881{
882 //TC pass
883 ecore_main_loop_quit();
884
885 return ECORE_CALLBACK_PASS_ON;
886}
887
888EFL_START_TEST(wl2_window_show)
889{
890 Test_Data *td;
891
892 ecore_wl2_init();
893
894 td = calloc(1, sizeof(Test_Data));
895 td->width = WIDTH;
896 td->height = HEIGHT;
897 td->frame_callback_count = 0;
898
899 td->display = _display_connect();
900 ck_assert(td->display != NULL);
901
902 td->win = _window_create(td->display);
903 ck_assert(td->win != NULL);
904
905 ecore_wl2_window_type_set(td->win, ECORE_WL2_WINDOW_TYPE_TOPLEVEL);
906
907 td->surface = _surface_get(td->win);
908 ck_assert(td->surface != NULL);
909
910 ecore_wl2_window_show(td->win);
911
912 td->handler = ecore_event_handler_add(ECORE_WL2_EVENT_WINDOW_SHOW,
913 _test_show_window_show, NULL);
914
915 ecore_main_loop_begin();
916
917 ecore_wl2_shutdown();
918 free(td);
919}
920EFL_END_TEST
921
922static Eina_Bool _window_configure_event_called = EINA_FALSE;
923
924static Eina_Bool
925_test_update_window_configure(void *data EINA_UNUSED, int type EINA_UNUSED, void *event EINA_UNUSED)
926{
927 _window_configure_event_called = EINA_TRUE;
928
929 return ECORE_CALLBACK_PASS_ON;
930}
931
932static Eina_Bool
933_test_update_window_configure_complete(void *data EINA_UNUSED, int type EINA_UNUSED, void *event EINA_UNUSED)
934{
935 //Checks if the configure_complete calling before configure calling
936 //when ecore_wl2_window_update_begin() called.
937 fail_if(_window_configure_event_called == EINA_TRUE);
938
939 ecore_main_loop_quit();
940
941 return ECORE_CALLBACK_PASS_ON;
942}
943
944EFL_START_TEST(wl2_window_update_begin)
945{
946 Test_Data *td;
947
948 ecore_wl2_init();
949
950 td = calloc(1, sizeof(Test_Data));
951 td->width = WIDTH;
952 td->height = HEIGHT;
953 td->frame_callback_count = 0;
954
955 td->display = _display_connect();
956 ck_assert(td->display != NULL);
957
958 td->win = _window_create(td->display);
959 ck_assert(td->win != NULL);
960
961 ecore_wl2_window_type_set(td->win, ECORE_WL2_WINDOW_TYPE_TOPLEVEL);
962
963 td->surface = _surface_get(td->win);
964 ck_assert(td->surface != NULL);
965
966 ecore_wl2_window_show(td->win);
967
968 ecore_wl2_window_update_begin(td->win);
969 ecore_event_handler_add(ECORE_WL2_EVENT_WINDOW_CONFIGURE,
970 _test_update_window_configure, NULL);
971 ecore_event_handler_add(ECORE_WL2_EVENT_WINDOW_CONFIGURE_COMPLETE,
972 _test_update_window_configure_complete, NULL);
973
974 ecore_main_loop_begin();
975
976 ecore_wl2_shutdown();
977 free(td);
978}
979EFL_END_TEST
980
497void 981void
498ecore_wl2_test_window(TCase *tc) 982ecore_wl2_test_window(TCase *tc)
499{ 983{
@@ -504,7 +988,17 @@ ecore_wl2_test_window(TCase *tc)
504 tcase_add_test(tc, wl2_window_surface_test); 988 tcase_add_test(tc, wl2_window_surface_test);
505 tcase_add_test(tc, wl2_window_rotation); 989 tcase_add_test(tc, wl2_window_rotation);
506 if (getenv("E_START")) 990 if (getenv("E_START"))
507 tcase_add_test(tc, wl2_window_aux_hints_supported_get); 991 {
992 tcase_add_test(tc, wl2_window_aux_hints_supported_get);
993 tcase_add_test(tc, wl2_window_commit);
994 tcase_add_test(tc, wl2_window_frame_callback);
995 tcase_add_test(tc, wl2_window_free);
996 tcase_add_test(tc, wl2_window_hide);
997 tcase_add_test(tc, wl2_window_shell_surface_exists);
998 tcase_add_test(tc, wl2_window_show);
999 tcase_add_test(tc, wl2_window_update_begin);
1000 tcase_add_test(tc, wl2_window_activated);
1001 }
508 tcase_add_test(tc, wl2_window_display_get); 1002 tcase_add_test(tc, wl2_window_display_get);
509 tcase_add_test(tc, wl2_window_alpha); 1003 tcase_add_test(tc, wl2_window_alpha);
510 tcase_add_test(tc, wl2_window_floating_mode); 1004 tcase_add_test(tc, wl2_window_floating_mode);
diff --git a/src/tests/ecore_wl2/meson.build b/src/tests/ecore_wl2/meson.build
index eb1a13db6a..2491b6d631 100644
--- a/src/tests/ecore_wl2/meson.build
+++ b/src/tests/ecore_wl2/meson.build
@@ -8,9 +8,17 @@ ecore_wl2_suite_src = [
8 'ecore_wl2_test_input.c' 8 'ecore_wl2_test_input.c'
9] 9]
10 10
11wl2_test_gl_deps = []
12
13if get_option('opengl') == 'es-egl'
14 wl2_test_gl_deps += dependency('egl')
15 wl2_test_gl_deps += dependency('gl')
16endif
17
11ecore_wl2_suite = executable('ecore_wl2_suite', 18ecore_wl2_suite = executable('ecore_wl2_suite',
12 ecore_wl2_suite_src, 19 ecore_wl2_suite_src,
13 dependencies: [ecore_wl2, ecore, check, wayland_protocol], 20 dependencies: [ecore_wl2, ecore, ecore_input, check, wayland_protocol, wayland_client, dependency('wayland-egl'), wl2_test_gl_deps],
21
14 c_args : [ 22 c_args : [
15 '-DTESTS_BUILD_DIR="'+meson.current_build_dir()+'"', 23 '-DTESTS_BUILD_DIR="'+meson.current_build_dir()+'"',
16 '-DTESTS_SRC_DIR="'+meson.current_source_dir()+'"'] 24 '-DTESTS_SRC_DIR="'+meson.current_source_dir()+'"']