forked from enlightenment/efl
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
This commit is contained in:
parent
ae30d3c57b
commit
2010c2ce13
|
@ -7,6 +7,12 @@
|
|||
#include <Eina.h>
|
||||
#include <Ecore.h>
|
||||
#include <Ecore_Wl2.h>
|
||||
#include <wayland-egl.h>
|
||||
|
||||
#ifdef GL_GLES
|
||||
#include <EGL/egl.h>
|
||||
#include <GLES2/gl2.h>
|
||||
#endif
|
||||
|
||||
#include "ecore_wl2_suite.h"
|
||||
#include "ecore_wl2_tests_helpers.h"
|
||||
|
@ -14,6 +20,27 @@
|
|||
#define WIDTH 480
|
||||
#define HEIGHT 360
|
||||
|
||||
typedef struct _Test_Data {
|
||||
Ecore_Wl2_Display *display;
|
||||
Ecore_Wl2_Window *win;
|
||||
Ecore_Wl2_Frame_Cb_Handle *frame_callback_handler;
|
||||
Ecore_Event_Handler *handler;
|
||||
|
||||
struct wl_surface *surface;
|
||||
struct wl_egl_window *egl_window;
|
||||
|
||||
int width;
|
||||
int height;
|
||||
int frame_callback_count;
|
||||
|
||||
#ifdef GL_GLES
|
||||
EGLDisplay egl_display;
|
||||
EGLConfig egl_conf;
|
||||
EGLSurface egl_surface;
|
||||
EGLContext egl_context;
|
||||
#endif
|
||||
} Test_Data;
|
||||
|
||||
static Ecore_Wl2_Window *
|
||||
_window_create(Ecore_Wl2_Display *disp)
|
||||
{
|
||||
|
@ -26,6 +53,42 @@ _surface_get(Ecore_Wl2_Window *win)
|
|||
return ecore_wl2_window_surface_get(win);
|
||||
}
|
||||
|
||||
#ifdef GL_GLES
|
||||
static void
|
||||
_init_egl(Test_Data *td)
|
||||
{
|
||||
eglBindAPI(EGL_OPENGL_API);
|
||||
EGLint num_config;
|
||||
|
||||
EGLint attributes[] = {
|
||||
EGL_RED_SIZE, 8,
|
||||
EGL_GREEN_SIZE, 8,
|
||||
EGL_BLUE_SIZE, 8,
|
||||
EGL_NONE
|
||||
};
|
||||
|
||||
td->egl_display = eglGetDisplay((EGLNativeDisplayType)ecore_wl2_display_get(td->display));
|
||||
eglInitialize(td->egl_display, NULL, NULL);
|
||||
eglChooseConfig(td->egl_display, attributes, &td->egl_conf, 1, &num_config);
|
||||
td->egl_context = eglCreateContext(td->egl_display, td->egl_conf, EGL_NO_CONTEXT, NULL);
|
||||
|
||||
td->egl_window = wl_egl_window_create(td->surface, td->width, td->height);
|
||||
td->egl_surface = eglCreateWindowSurface(td->egl_display,
|
||||
td->egl_conf, td->egl_window, NULL);
|
||||
|
||||
eglMakeCurrent(td->egl_display, td->egl_surface, td->egl_surface, td->egl_context);
|
||||
}
|
||||
|
||||
static void
|
||||
_term_egl(Test_Data *td)
|
||||
{
|
||||
eglDestroySurface(td->egl_display, td->egl_surface);
|
||||
wl_egl_window_destroy(td->egl_window);
|
||||
eglDestroyContext(td->egl_display, td->egl_context);
|
||||
eglTerminate(td->egl_display);
|
||||
}
|
||||
#endif
|
||||
|
||||
EFL_START_TEST(wl2_window_new)
|
||||
{
|
||||
Ecore_Wl2_Display *disp;
|
||||
|
@ -310,6 +373,94 @@ EFL_START_TEST(wl2_window_type)
|
|||
}
|
||||
EFL_END_TEST
|
||||
|
||||
#ifdef GL_GLES
|
||||
static void
|
||||
_test_activated_frame_cb(Ecore_Wl2_Window *win EINA_UNUSED, uint32_t timestamp EINA_UNUSED, void *data)
|
||||
{
|
||||
Test_Data *td = data;
|
||||
|
||||
td->frame_callback_count++;
|
||||
if (td->frame_callback_count % 4 == 0)
|
||||
glClearColor(0.0, 1.0, 0.0, 0.0);
|
||||
else if (td->frame_callback_count % 4 == 1)
|
||||
glClearColor(0.0, 0.0, 1.0, 0.0);
|
||||
else if (td->frame_callback_count % 4 == 2)
|
||||
glClearColor(0.0, 0.0, 0.0, 1.0);
|
||||
else
|
||||
glClearColor(1.0, 0.0, 0.0, 0.0);
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
glFlush();
|
||||
|
||||
eglSwapBuffers(td->egl_display, td->egl_surface);
|
||||
|
||||
ecore_wl2_window_commit(td->win, EINA_TRUE);
|
||||
}
|
||||
|
||||
static Eina_Bool
|
||||
_test_activated_configure_complete(void *data, int type EINA_UNUSED, void *event EINA_UNUSED)
|
||||
{
|
||||
Test_Data *td = data;
|
||||
|
||||
td->frame_callback_handler = ecore_wl2_window_frame_callback_add(td->win, _test_activated_frame_cb, td);
|
||||
ecore_wl2_window_commit(td->win, EINA_TRUE);
|
||||
|
||||
return ECORE_CALLBACK_PASS_ON;
|
||||
}
|
||||
|
||||
static Eina_Bool
|
||||
_test_activated_window_activate(void *data EINA_UNUSED, int type EINA_UNUSED, void *event EINA_UNUSED)
|
||||
{
|
||||
//TC Pass
|
||||
ecore_main_loop_quit();
|
||||
|
||||
return ECORE_CALLBACK_PASS_ON;
|
||||
}
|
||||
|
||||
EFL_START_TEST(wl2_window_activated)
|
||||
{
|
||||
Test_Data *td;
|
||||
|
||||
ecore_wl2_init();
|
||||
|
||||
td = calloc(1, sizeof(Test_Data));
|
||||
td->width = WIDTH;
|
||||
td->height = HEIGHT;
|
||||
td->frame_callback_count = 0;
|
||||
|
||||
td->display = _display_connect();
|
||||
ck_assert(td->display != NULL);
|
||||
|
||||
td->win = _window_create(td->display);
|
||||
ck_assert(td->win != NULL);
|
||||
|
||||
ecore_wl2_window_type_set(td->win, ECORE_WL2_WINDOW_TYPE_TOPLEVEL);
|
||||
|
||||
td->surface = _surface_get(td->win);
|
||||
ck_assert(td->surface != NULL);
|
||||
|
||||
ecore_wl2_window_show(td->win);
|
||||
|
||||
_init_egl(td);
|
||||
td->handler = ecore_event_handler_add(ECORE_WL2_EVENT_WINDOW_CONFIGURE_COMPLETE,
|
||||
_test_activated_configure_complete, td);
|
||||
ecore_event_handler_add(ECORE_WL2_EVENT_WINDOW_ACTIVATE,
|
||||
_test_activated_window_activate, NULL);
|
||||
|
||||
ecore_main_loop_begin();
|
||||
|
||||
_term_egl(td);
|
||||
ecore_wl2_shutdown();
|
||||
free(td);
|
||||
}
|
||||
EFL_END_TEST
|
||||
#else
|
||||
EFL_START_TEST(wl2_window_activated)
|
||||
{
|
||||
fail_if("No GL enabled GL should be enabled for API test");
|
||||
}
|
||||
EFL_END_TEST
|
||||
#endif
|
||||
|
||||
EFL_START_TEST(wl2_window_aspect)
|
||||
{
|
||||
Ecore_Wl2_Display *disp;
|
||||
|
@ -494,6 +645,339 @@ EFL_START_TEST(wl2_window_popup_input)
|
|||
}
|
||||
EFL_END_TEST
|
||||
|
||||
static void
|
||||
_test_commit_frame_cb(Ecore_Wl2_Window *win EINA_UNUSED, uint32_t timestamp EINA_UNUSED, void *data)
|
||||
{
|
||||
Test_Data *td = data;
|
||||
td->frame_callback_count++;
|
||||
ecore_main_loop_quit();
|
||||
}
|
||||
|
||||
static Eina_Bool
|
||||
_test_commit_configure_complete(void *data, int type EINA_UNUSED, void *event EINA_UNUSED)
|
||||
{
|
||||
Test_Data *td = data;
|
||||
|
||||
td->frame_callback_handler = ecore_wl2_window_frame_callback_add(td->win, _test_commit_frame_cb, td);
|
||||
ecore_wl2_window_commit(td->win, EINA_TRUE);
|
||||
|
||||
return ECORE_CALLBACK_PASS_ON;
|
||||
}
|
||||
|
||||
EFL_START_TEST(wl2_window_commit)
|
||||
{
|
||||
Test_Data *td;
|
||||
|
||||
ecore_wl2_init();
|
||||
|
||||
td = calloc(1, sizeof(Test_Data));
|
||||
td->width = WIDTH;
|
||||
td->height = HEIGHT;
|
||||
td->frame_callback_count = 0;
|
||||
|
||||
td->display = _display_connect();
|
||||
ck_assert(td->display != NULL);
|
||||
|
||||
td->win = _window_create(td->display);
|
||||
ck_assert(td->win != NULL);
|
||||
|
||||
ecore_wl2_window_type_set(td->win, ECORE_WL2_WINDOW_TYPE_TOPLEVEL);
|
||||
|
||||
td->surface = _surface_get(td->win);
|
||||
ck_assert(td->surface != NULL);
|
||||
|
||||
ecore_wl2_window_show(td->win);
|
||||
|
||||
td->handler = ecore_event_handler_add(ECORE_WL2_EVENT_WINDOW_CONFIGURE_COMPLETE,
|
||||
_test_commit_configure_complete, td);
|
||||
|
||||
ecore_main_loop_begin();
|
||||
|
||||
//Check if the frame callback was called properly by ecore_wl2_window_commit().
|
||||
fail_if(td->frame_callback_count == 0);
|
||||
|
||||
ecore_wl2_shutdown();
|
||||
free(td);
|
||||
}
|
||||
EFL_END_TEST
|
||||
|
||||
static void
|
||||
_test_frame_callback_frame_cb(Ecore_Wl2_Window *win EINA_UNUSED, uint32_t timestamp EINA_UNUSED, void *data)
|
||||
{
|
||||
Test_Data *td = data;
|
||||
td->frame_callback_count++;
|
||||
if (td->frame_callback_count == 1)
|
||||
{
|
||||
ecore_wl2_window_frame_callback_del(td->frame_callback_handler);
|
||||
td->frame_callback_handler = NULL;
|
||||
ecore_main_loop_quit();
|
||||
}
|
||||
}
|
||||
|
||||
static Eina_Bool
|
||||
_test_frame_callback_configure_complete(void *data, int type EINA_UNUSED, void *event EINA_UNUSED)
|
||||
{
|
||||
Test_Data *td = data;
|
||||
|
||||
td->frame_callback_handler = ecore_wl2_window_frame_callback_add(td->win, _test_frame_callback_frame_cb, td);
|
||||
ecore_wl2_window_commit(td->win, EINA_TRUE);
|
||||
|
||||
return ECORE_CALLBACK_PASS_ON;
|
||||
}
|
||||
|
||||
EFL_START_TEST(wl2_window_frame_callback)
|
||||
{
|
||||
Test_Data *td;
|
||||
|
||||
ecore_wl2_init();
|
||||
|
||||
td = calloc(1, sizeof(Test_Data));
|
||||
td->width = WIDTH;
|
||||
td->height = HEIGHT;
|
||||
td->frame_callback_count = 0;
|
||||
|
||||
td->display = _display_connect();
|
||||
ck_assert(td->display != NULL);
|
||||
|
||||
td->win = _window_create(td->display);
|
||||
ck_assert(td->win != NULL);
|
||||
|
||||
ecore_wl2_window_type_set(td->win, ECORE_WL2_WINDOW_TYPE_TOPLEVEL);
|
||||
|
||||
td->surface = _surface_get(td->win);
|
||||
ck_assert(td->surface != NULL);
|
||||
|
||||
ecore_wl2_window_show(td->win);
|
||||
|
||||
td->handler = ecore_event_handler_add(ECORE_WL2_EVENT_WINDOW_CONFIGURE_COMPLETE,
|
||||
_test_frame_callback_configure_complete, td);
|
||||
|
||||
ecore_main_loop_begin();
|
||||
|
||||
//Check if the frame callback called after then it sets NULL or not.
|
||||
fail_if(td->frame_callback_count != 1);
|
||||
fail_if(td->frame_callback_handler != NULL);
|
||||
|
||||
ecore_wl2_shutdown();
|
||||
free(td);
|
||||
}
|
||||
EFL_END_TEST
|
||||
|
||||
EFL_START_TEST(wl2_window_free)
|
||||
{
|
||||
Ecore_Wl2_Window *t_win;
|
||||
Test_Data *td;
|
||||
|
||||
ecore_wl2_init();
|
||||
|
||||
td = calloc(1, sizeof(Test_Data));
|
||||
|
||||
td->display = _display_connect();
|
||||
ck_assert(td->display != NULL);
|
||||
|
||||
td->win = _window_create(td->display);
|
||||
ck_assert(td->win != NULL);
|
||||
|
||||
ecore_wl2_window_type_set(td->win, ECORE_WL2_WINDOW_TYPE_TOPLEVEL);
|
||||
|
||||
td->surface = _surface_get(td->win);
|
||||
ck_assert(td->surface != NULL);
|
||||
|
||||
ecore_wl2_window_show(td->win);
|
||||
|
||||
t_win = ecore_wl2_display_window_find_by_surface(td->display, td->surface);
|
||||
|
||||
fail_if(td->win != t_win);
|
||||
|
||||
ecore_wl2_window_free(td->win);
|
||||
t_win = ecore_wl2_display_window_find_by_surface(td->display, td->surface);
|
||||
|
||||
//Check the returned window with freed window.
|
||||
fail_if(td->win == t_win);
|
||||
|
||||
ecore_wl2_shutdown();
|
||||
free(td);
|
||||
}
|
||||
EFL_END_TEST
|
||||
|
||||
static Eina_Bool
|
||||
_test_hide_window_hide(void *data EINA_UNUSED, int type EINA_UNUSED, void *event EINA_UNUSED)
|
||||
{
|
||||
//TC pass
|
||||
ecore_main_loop_quit();
|
||||
|
||||
return ECORE_CALLBACK_PASS_ON;
|
||||
}
|
||||
|
||||
EFL_START_TEST(wl2_window_hide)
|
||||
{
|
||||
Test_Data *td;
|
||||
|
||||
ecore_wl2_init();
|
||||
|
||||
td = calloc(1, sizeof(Test_Data));
|
||||
td->width = WIDTH;
|
||||
td->height = HEIGHT;
|
||||
td->frame_callback_count = 0;
|
||||
|
||||
td->display = _display_connect();
|
||||
ck_assert(td->display != NULL);
|
||||
|
||||
td->win = _window_create(td->display);
|
||||
ck_assert(td->win != NULL);
|
||||
|
||||
ecore_wl2_window_type_set(td->win, ECORE_WL2_WINDOW_TYPE_TOPLEVEL);
|
||||
|
||||
td->surface = _surface_get(td->win);
|
||||
ck_assert(td->surface != NULL);
|
||||
|
||||
ecore_wl2_window_show(td->win);
|
||||
|
||||
ecore_wl2_window_hide(td->win);
|
||||
td->handler = ecore_event_handler_add(ECORE_WL2_EVENT_WINDOW_HIDE,
|
||||
_test_hide_window_hide, NULL);
|
||||
|
||||
ecore_main_loop_begin();
|
||||
|
||||
ecore_wl2_shutdown();
|
||||
free(td);
|
||||
}
|
||||
EFL_END_TEST
|
||||
|
||||
EFL_START_TEST(wl2_window_shell_surface_exists)
|
||||
{
|
||||
Test_Data *td;
|
||||
|
||||
ecore_wl2_init();
|
||||
|
||||
td = calloc(1, sizeof(Test_Data));
|
||||
td->width = WIDTH;
|
||||
td->height = HEIGHT;
|
||||
td->frame_callback_count = 0;
|
||||
|
||||
td->display = _display_connect();
|
||||
ck_assert(td->display != NULL);
|
||||
|
||||
td->win = _window_create(td->display);
|
||||
ck_assert(td->win != NULL);
|
||||
|
||||
ecore_wl2_window_type_set(td->win, ECORE_WL2_WINDOW_TYPE_TOPLEVEL);
|
||||
|
||||
td->surface = _surface_get(td->win);
|
||||
ck_assert(td->surface != NULL);
|
||||
|
||||
ecore_wl2_window_show(td->win);
|
||||
|
||||
//window_show function will create shell surface. then checks it.
|
||||
fail_if(ecore_wl2_window_shell_surface_exists(td->win) == EINA_FALSE);
|
||||
|
||||
ecore_wl2_shutdown();
|
||||
free(td);
|
||||
}
|
||||
EFL_END_TEST
|
||||
|
||||
static Eina_Bool
|
||||
_test_show_window_show(void *data EINA_UNUSED, int type EINA_UNUSED, void *event EINA_UNUSED)
|
||||
{
|
||||
//TC pass
|
||||
ecore_main_loop_quit();
|
||||
|
||||
return ECORE_CALLBACK_PASS_ON;
|
||||
}
|
||||
|
||||
EFL_START_TEST(wl2_window_show)
|
||||
{
|
||||
Test_Data *td;
|
||||
|
||||
ecore_wl2_init();
|
||||
|
||||
td = calloc(1, sizeof(Test_Data));
|
||||
td->width = WIDTH;
|
||||
td->height = HEIGHT;
|
||||
td->frame_callback_count = 0;
|
||||
|
||||
td->display = _display_connect();
|
||||
ck_assert(td->display != NULL);
|
||||
|
||||
td->win = _window_create(td->display);
|
||||
ck_assert(td->win != NULL);
|
||||
|
||||
ecore_wl2_window_type_set(td->win, ECORE_WL2_WINDOW_TYPE_TOPLEVEL);
|
||||
|
||||
td->surface = _surface_get(td->win);
|
||||
ck_assert(td->surface != NULL);
|
||||
|
||||
ecore_wl2_window_show(td->win);
|
||||
|
||||
td->handler = ecore_event_handler_add(ECORE_WL2_EVENT_WINDOW_SHOW,
|
||||
_test_show_window_show, NULL);
|
||||
|
||||
ecore_main_loop_begin();
|
||||
|
||||
ecore_wl2_shutdown();
|
||||
free(td);
|
||||
}
|
||||
EFL_END_TEST
|
||||
|
||||
static Eina_Bool _window_configure_event_called = EINA_FALSE;
|
||||
|
||||
static Eina_Bool
|
||||
_test_update_window_configure(void *data EINA_UNUSED, int type EINA_UNUSED, void *event EINA_UNUSED)
|
||||
{
|
||||
_window_configure_event_called = EINA_TRUE;
|
||||
|
||||
return ECORE_CALLBACK_PASS_ON;
|
||||
}
|
||||
|
||||
static Eina_Bool
|
||||
_test_update_window_configure_complete(void *data EINA_UNUSED, int type EINA_UNUSED, void *event EINA_UNUSED)
|
||||
{
|
||||
//Checks if the configure_complete calling before configure calling
|
||||
//when ecore_wl2_window_update_begin() called.
|
||||
fail_if(_window_configure_event_called == EINA_TRUE);
|
||||
|
||||
ecore_main_loop_quit();
|
||||
|
||||
return ECORE_CALLBACK_PASS_ON;
|
||||
}
|
||||
|
||||
EFL_START_TEST(wl2_window_update_begin)
|
||||
{
|
||||
Test_Data *td;
|
||||
|
||||
ecore_wl2_init();
|
||||
|
||||
td = calloc(1, sizeof(Test_Data));
|
||||
td->width = WIDTH;
|
||||
td->height = HEIGHT;
|
||||
td->frame_callback_count = 0;
|
||||
|
||||
td->display = _display_connect();
|
||||
ck_assert(td->display != NULL);
|
||||
|
||||
td->win = _window_create(td->display);
|
||||
ck_assert(td->win != NULL);
|
||||
|
||||
ecore_wl2_window_type_set(td->win, ECORE_WL2_WINDOW_TYPE_TOPLEVEL);
|
||||
|
||||
td->surface = _surface_get(td->win);
|
||||
ck_assert(td->surface != NULL);
|
||||
|
||||
ecore_wl2_window_show(td->win);
|
||||
|
||||
ecore_wl2_window_update_begin(td->win);
|
||||
ecore_event_handler_add(ECORE_WL2_EVENT_WINDOW_CONFIGURE,
|
||||
_test_update_window_configure, NULL);
|
||||
ecore_event_handler_add(ECORE_WL2_EVENT_WINDOW_CONFIGURE_COMPLETE,
|
||||
_test_update_window_configure_complete, NULL);
|
||||
|
||||
ecore_main_loop_begin();
|
||||
|
||||
ecore_wl2_shutdown();
|
||||
free(td);
|
||||
}
|
||||
EFL_END_TEST
|
||||
|
||||
void
|
||||
ecore_wl2_test_window(TCase *tc)
|
||||
{
|
||||
|
@ -504,7 +988,17 @@ ecore_wl2_test_window(TCase *tc)
|
|||
tcase_add_test(tc, wl2_window_surface_test);
|
||||
tcase_add_test(tc, wl2_window_rotation);
|
||||
if (getenv("E_START"))
|
||||
tcase_add_test(tc, wl2_window_aux_hints_supported_get);
|
||||
{
|
||||
tcase_add_test(tc, wl2_window_aux_hints_supported_get);
|
||||
tcase_add_test(tc, wl2_window_commit);
|
||||
tcase_add_test(tc, wl2_window_frame_callback);
|
||||
tcase_add_test(tc, wl2_window_free);
|
||||
tcase_add_test(tc, wl2_window_hide);
|
||||
tcase_add_test(tc, wl2_window_shell_surface_exists);
|
||||
tcase_add_test(tc, wl2_window_show);
|
||||
tcase_add_test(tc, wl2_window_update_begin);
|
||||
tcase_add_test(tc, wl2_window_activated);
|
||||
}
|
||||
tcase_add_test(tc, wl2_window_display_get);
|
||||
tcase_add_test(tc, wl2_window_alpha);
|
||||
tcase_add_test(tc, wl2_window_floating_mode);
|
||||
|
|
|
@ -8,9 +8,17 @@ ecore_wl2_suite_src = [
|
|||
'ecore_wl2_test_input.c'
|
||||
]
|
||||
|
||||
wl2_test_gl_deps = []
|
||||
|
||||
if get_option('opengl') == 'es-egl'
|
||||
wl2_test_gl_deps += dependency('egl')
|
||||
wl2_test_gl_deps += dependency('gl')
|
||||
endif
|
||||
|
||||
ecore_wl2_suite = executable('ecore_wl2_suite',
|
||||
ecore_wl2_suite_src,
|
||||
dependencies: [ecore_wl2, ecore, check, wayland_protocol],
|
||||
dependencies: [ecore_wl2, ecore, ecore_input, check, wayland_protocol, wayland_client, dependency('wayland-egl'), wl2_test_gl_deps],
|
||||
|
||||
c_args : [
|
||||
'-DTESTS_BUILD_DIR="'+meson.current_build_dir()+'"',
|
||||
'-DTESTS_SRC_DIR="'+meson.current_source_dir()+'"']
|
||||
|
|
Loading…
Reference in New Issue