tests/ecore_wl2: Code clean up and Add, Modify TCs.

Summary:
Code clean up.
Add flush, sync_is_done APIs.
Modify input_find.

ref T8016

Reviewers: devilhorns

Subscribers: cedric, #reviewers, #committers

Tags: #efl

Maniphest Tasks: T8016

Differential Revision: https://phab.enlightenment.org/D11111
This commit is contained in:
Woochanlee 2020-01-21 08:13:52 -05:00 committed by Christopher Michael
parent d066dcf543
commit 87be474bb5
9 changed files with 238 additions and 137 deletions

View File

@ -1,10 +1,4 @@
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include "ecore_wl2_suite.h"
#include "../efl_check.h"
#include <Ecore_Wl2.h>
static const Efl_Test_Case etc[] =
{

View File

@ -1,8 +1,16 @@
#ifndef _ECORE_WL2_SUITE_H
# define _ECORE_WL2_SUITE_H
# include <check.h>
# include "../efl_check.h"
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <check.h>
#include "../efl_check.h"
#include <stdio.h>
#include <unistd.h>
#include <Ecore.h>
#include <Ecore_Wl2.h>
void ecore_wl2_test_init(TCase *tc);
void ecore_wl2_test_display(TCase *tc);

View File

@ -1,13 +1,3 @@
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <stdio.h>
#include <unistd.h>
#include <Eina.h>
#include <Ecore.h>
#include <Ecore_Wl2.h>
#include "ecore_wl2_suite.h"
#include "ecore_wl2_tests_helpers.h"
@ -183,21 +173,115 @@ EFL_START_TEST(wl2_display_compositor_version_get)
}
EFL_END_TEST
EFL_START_TEST(wl2_display_input_find_by_name)
Ecore_Wl2_Input *test_input;
static Eina_Bool
_test_input_find_configure_complete(void *data, int type EINA_UNUSED, void *event EINA_UNUSED)
{
Test_Data *td = data;
/* NB: Enlightenment uses "seat0" here, but Weston uses "default" */
if (getenv("E_START"))
test_input = ecore_wl2_display_input_find_by_name(td->display, "seat0");
else
test_input = ecore_wl2_display_input_find_by_name(td->display, "default");
ck_assert(test_input != NULL);
test_input = NULL;
if (getenv("E_START"))
{
test_input = ecore_wl2_display_input_find(td->display, 13);
ck_assert(test_input != NULL);
}
ecore_main_loop_quit();
return ECORE_CALLBACK_PASS_ON;
}
EFL_START_TEST(wl2_display_input_find)
{
Test_Data *td;
ecore_wl2_init();
td = calloc(1, sizeof(Test_Data));
td->width = WIDTH;
td->height = HEIGHT;
td->display = _display_connect();
ck_assert(td->display != NULL);
td->win = _window_create(td->display);
ck_assert(td->win != NULL);
ecore_wl2_window_show(td->win);
td->handler = ecore_event_handler_add(ECORE_WL2_EVENT_WINDOW_CONFIGURE_COMPLETE,
_test_input_find_configure_complete, td);
ecore_main_loop_begin();
ecore_wl2_shutdown();
free(td);
}
EFL_END_TEST
EFL_START_TEST(wl2_display_flush)
{
Ecore_Wl2_Display *disp;
Ecore_Wl2_Input *input;
disp = _display_connect();
ck_assert(disp != NULL);
/* NB: Enlightenment uses "seat0" here, but Weston uses "default" */
if (getenv("E_START"))
input = ecore_wl2_display_input_find_by_name(disp, "seat0");
else
input = ecore_wl2_display_input_find_by_name(disp, "default");
//FIXME: Ambiguous way to check with code to make sure flushing was successful.
// We might think it's being verified by another TC that actually draws to the screen buffer ...
ecore_wl2_display_flush(disp);
}
EFL_END_TEST
ck_assert(input != NULL);
static Eina_Bool
_test_sync_done(void *data, int type EINA_UNUSED, void *event EINA_UNUSED)
{
Test_Data *td = data;
Eina_Bool ret;
ret = ecore_wl2_display_sync_is_done(td->display);
fail_if(ret == EINA_FALSE);
ecore_main_loop_quit();
return ECORE_CALLBACK_PASS_ON;
}
EFL_START_TEST(wl2_display_sync_is_done)
{
Test_Data *td;
ecore_wl2_init();
td = calloc(1, sizeof(Test_Data));
td->width = WIDTH;
td->height = HEIGHT;
td->display = _display_connect();
ck_assert(td->display != NULL);
td->win = _window_create(td->display);
ck_assert(td->win != NULL);
ecore_wl2_window_show(td->win);
ecore_event_handler_add(ECORE_WL2_EVENT_SYNC_DONE,
_test_sync_done, td);
ecore_main_loop_begin();
ecore_wl2_shutdown();
free(td);
}
EFL_END_TEST
@ -221,11 +305,17 @@ ecore_wl2_test_display(TCase *tc)
tcase_add_test(tc, wl2_display_disconnect);
tcase_add_test(tc, wl2_display_registry_get);
tcase_add_test(tc, wl2_display_shm_get);
tcase_add_test(tc, wl2_display_dmabuf_get);
tcase_add_test(tc, wl2_display_globals_get);
tcase_add_test(tc, wl2_display_screen_size_get);
tcase_add_test(tc, wl2_display_inputs_get);
tcase_add_test(tc, wl2_display_compositor_version_get);
tcase_add_test(tc, wl2_display_input_find_by_name);
tcase_add_test(tc, wl2_display_input_find);
tcase_add_test(tc, wl2_display_flush);
tcase_add_test(tc, wl2_display_sync_is_done);
}
if (!getenv("E_START"))
{
tcase_add_test(tc, wl2_display_dmabuf_get);
tcase_add_test(tc, wl2_display_screen_size_get);
}
}

View File

@ -1,14 +1,3 @@
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <stdio.h>
#include <unistd.h>
#include <Eina.h>
#include <Ecore.h>
#include <Ecore_Wl2.h>
#include "ecore_wl2_suite.h"
EFL_START_TEST(ecore_wl2_simple)

View File

@ -1,13 +1,3 @@
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <stdio.h>
#include <unistd.h>
#include <Eina.h>
#include <Ecore.h>
#include <Ecore_Wl2.h>
#include "ecore_wl2_suite.h"
#include "ecore_wl2_tests_helpers.h"
@ -124,16 +114,14 @@ EFL_START_TEST(wl2_input_name_get)
}
EFL_END_TEST
EFL_START_TEST(wl2_input_seat_capabilities)
static Eina_Bool
_test_input_seat_capa_configure_complete(void *data, int type EINA_UNUSED, void *event EINA_UNUSED)
{
Ecore_Wl2_Display *disp;
Test_Data *td = data;
Ecore_Wl2_Input *input;
Eina_Iterator *itr;
disp = _display_connect();
ck_assert(disp != NULL);
itr = ecore_wl2_display_inputs_get(disp);
itr = ecore_wl2_display_inputs_get(td->display);
ck_assert(itr != NULL);
EINA_ITERATOR_FOREACH(itr, input)
@ -145,6 +133,38 @@ EFL_START_TEST(wl2_input_seat_capabilities)
}
eina_iterator_free(itr);
ecore_main_loop_quit();
return ECORE_CALLBACK_PASS_ON;
}
EFL_START_TEST(wl2_input_seat_capabilities)
{
Test_Data *td;
ecore_wl2_init();
td = calloc(1, sizeof(Test_Data));
td->width = WIDTH;
td->height = HEIGHT;
td->display = _display_connect();
ck_assert(td->display != NULL);
td->win = _window_create(td->display);
ck_assert(td->win != NULL);
ecore_wl2_window_show(td->win);
td->handler = ecore_event_handler_add(ECORE_WL2_EVENT_WINDOW_CONFIGURE_COMPLETE,
_test_input_seat_capa_configure_complete, td);
ecore_main_loop_begin();
ecore_wl2_shutdown();
free(td);
}
EFL_END_TEST

View File

@ -1,52 +1,9 @@
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <stdio.h>
#include <unistd.h>
#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"
#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;
#include "ecore_wl2_tests_helper_egl.h"
#endif
} Test_Data;
static Ecore_Wl2_Window *
_window_create(Ecore_Wl2_Display *disp)
{
return ecore_wl2_window_new(disp, NULL, 100, 100, WIDTH, HEIGHT);
}
static struct wl_surface *
_surface_get(Ecore_Wl2_Window *win)
@ -54,42 +11,6 @@ _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;

View File

@ -0,0 +1,42 @@
#ifndef ECORE_WL2_TEST_HELPER_EGL_H
# define ECORE_WL2_TEST_HELPER_EGL_H
#include <wayland-egl.h>
#include <EGL/egl.h>
#include <GLES2/gl2.h>
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

View File

@ -1,7 +1,37 @@
#ifndef ECORE_WL2_TEST_HELPERS_H
# define ECORE_WL2_TEST_HELPERS_H
# include <Ecore_Wl2.h>
#include <wayland-egl.h>
#ifdef GL_GLES
#include <EGL/egl.h>
#include <GLES2/gl2.h>
#endif
#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_Display *
_display_connect(void)
@ -9,4 +39,10 @@ _display_connect(void)
return ecore_wl2_display_connect(NULL);
}
static Ecore_Wl2_Window *
_window_create(Ecore_Wl2_Display *disp)
{
return ecore_wl2_window_new(disp, NULL, 100, 100, WIDTH, HEIGHT);
}
#endif

View File

@ -11,6 +11,7 @@ ecore_wl2_suite_src = [
wl2_test_gl_deps = []
if get_option('opengl') == 'es-egl'
ecore_wl2_suite_src += 'ecore_wl2_tests_helper_egl.h'
wl2_test_gl_deps += dependency('egl')
wl2_test_gl_deps += dependency('gl')
endif