2019-07-15 06:49:31 -07:00
|
|
|
#include "ecore_wl2_suite.h"
|
|
|
|
#include "ecore_wl2_tests_helpers.h"
|
|
|
|
|
2020-01-09 07:46:54 -08:00
|
|
|
static Ecore_Wl2_Display *
|
|
|
|
_display_setup(void)
|
|
|
|
{
|
|
|
|
return ecore_wl2_display_create(NULL);
|
|
|
|
}
|
|
|
|
|
2019-07-15 06:49:31 -07:00
|
|
|
EFL_START_TEST(wl2_display_create)
|
|
|
|
{
|
|
|
|
Ecore_Wl2_Display *disp;
|
|
|
|
|
2019-07-22 05:34:11 -07:00
|
|
|
disp = _display_setup();
|
2019-07-15 06:49:31 -07:00
|
|
|
ck_assert(disp != NULL);
|
|
|
|
}
|
|
|
|
EFL_END_TEST
|
|
|
|
|
|
|
|
EFL_START_TEST(wl2_display_destroy)
|
|
|
|
{
|
|
|
|
Ecore_Wl2_Display *disp;
|
|
|
|
|
2019-07-22 05:34:11 -07:00
|
|
|
disp = _display_setup();
|
2019-07-15 06:49:31 -07:00
|
|
|
ck_assert(disp != NULL);
|
|
|
|
|
|
|
|
ecore_wl2_display_destroy(disp);
|
|
|
|
}
|
|
|
|
EFL_END_TEST
|
|
|
|
|
2019-07-15 07:08:32 -07:00
|
|
|
EFL_START_TEST(wl2_display_get)
|
|
|
|
{
|
|
|
|
Ecore_Wl2_Display *disp;
|
|
|
|
struct wl_display *wdisp;
|
|
|
|
|
2019-07-22 05:34:11 -07:00
|
|
|
disp = _display_setup();
|
2019-07-15 07:08:32 -07:00
|
|
|
ck_assert(disp != NULL);
|
|
|
|
|
|
|
|
wdisp = ecore_wl2_display_get(disp);
|
|
|
|
ck_assert(wdisp != NULL);
|
|
|
|
}
|
|
|
|
EFL_END_TEST
|
|
|
|
|
|
|
|
EFL_START_TEST(wl2_display_name_get)
|
|
|
|
{
|
|
|
|
Ecore_Wl2_Display *disp;
|
|
|
|
|
2019-07-22 05:34:11 -07:00
|
|
|
disp = _display_setup();
|
2019-07-15 07:08:32 -07:00
|
|
|
ck_assert(disp != NULL);
|
|
|
|
|
|
|
|
ck_assert(ecore_wl2_display_name_get(disp) != NULL);
|
|
|
|
}
|
|
|
|
EFL_END_TEST
|
|
|
|
|
2019-07-15 07:28:29 -07:00
|
|
|
EFL_START_TEST(wl2_display_connect)
|
|
|
|
{
|
|
|
|
Ecore_Wl2_Display *disp;
|
|
|
|
|
2019-07-22 05:34:11 -07:00
|
|
|
disp = _display_connect();
|
2019-07-15 07:28:29 -07:00
|
|
|
ck_assert(disp != NULL);
|
|
|
|
}
|
|
|
|
EFL_END_TEST
|
|
|
|
|
|
|
|
EFL_START_TEST(wl2_display_disconnect)
|
|
|
|
{
|
|
|
|
Ecore_Wl2_Display *disp;
|
|
|
|
|
2019-07-22 05:34:11 -07:00
|
|
|
disp = _display_connect();
|
2019-07-15 07:28:29 -07:00
|
|
|
ck_assert(disp != NULL);
|
|
|
|
|
|
|
|
ecore_wl2_display_disconnect(disp);
|
|
|
|
}
|
|
|
|
EFL_END_TEST
|
|
|
|
|
2019-07-15 08:00:05 -07:00
|
|
|
EFL_START_TEST(wl2_display_registry_get)
|
|
|
|
{
|
|
|
|
Ecore_Wl2_Display *disp;
|
|
|
|
|
2019-07-22 05:34:11 -07:00
|
|
|
disp = _display_connect();
|
2019-07-15 08:00:05 -07:00
|
|
|
ck_assert(disp != NULL);
|
|
|
|
|
|
|
|
ck_assert(ecore_wl2_display_registry_get(disp) != NULL);
|
|
|
|
}
|
|
|
|
EFL_END_TEST
|
|
|
|
|
2019-07-15 07:31:56 -07:00
|
|
|
EFL_START_TEST(wl2_display_shm_get)
|
|
|
|
{
|
|
|
|
Ecore_Wl2_Display *disp;
|
|
|
|
struct wl_shm *shm;
|
|
|
|
|
2019-07-22 05:34:11 -07:00
|
|
|
disp = _display_connect();
|
2019-07-15 07:31:56 -07:00
|
|
|
ck_assert(disp != NULL);
|
|
|
|
|
|
|
|
shm = ecore_wl2_display_shm_get(disp);
|
|
|
|
ck_assert(shm != NULL);
|
|
|
|
}
|
|
|
|
EFL_END_TEST
|
|
|
|
|
2019-07-15 07:33:37 -07:00
|
|
|
EFL_START_TEST(wl2_display_dmabuf_get)
|
|
|
|
{
|
|
|
|
Ecore_Wl2_Display *disp;
|
|
|
|
void *dma;
|
|
|
|
|
2019-07-22 05:34:11 -07:00
|
|
|
disp = _display_connect();
|
2019-07-15 07:33:37 -07:00
|
|
|
ck_assert(disp != NULL);
|
|
|
|
|
|
|
|
dma = ecore_wl2_display_dmabuf_get(disp);
|
|
|
|
ck_assert(dma != NULL);
|
|
|
|
}
|
|
|
|
EFL_END_TEST
|
|
|
|
|
2019-07-15 07:47:36 -07:00
|
|
|
EFL_START_TEST(wl2_display_globals_get)
|
|
|
|
{
|
|
|
|
Ecore_Wl2_Display *disp;
|
|
|
|
Ecore_Wl2_Global *global;
|
|
|
|
Eina_Iterator *itr;
|
|
|
|
void *data;
|
|
|
|
|
2019-07-22 05:34:11 -07:00
|
|
|
disp = _display_connect();
|
2019-07-15 07:47:36 -07:00
|
|
|
ck_assert(disp != NULL);
|
|
|
|
|
|
|
|
itr = ecore_wl2_display_globals_get(disp);
|
|
|
|
ck_assert(itr != NULL);
|
|
|
|
|
|
|
|
EINA_ITERATOR_FOREACH(itr, data)
|
|
|
|
{
|
|
|
|
global = (Ecore_Wl2_Global *)data;
|
|
|
|
printf("Interface: <%s>\n", global->interface);
|
|
|
|
}
|
|
|
|
|
|
|
|
eina_iterator_free(itr);
|
|
|
|
}
|
|
|
|
EFL_END_TEST
|
|
|
|
|
2019-07-15 07:53:42 -07:00
|
|
|
EFL_START_TEST(wl2_display_screen_size_get)
|
|
|
|
{
|
|
|
|
Ecore_Wl2_Display *disp;
|
|
|
|
int w, h;
|
|
|
|
|
2019-07-22 05:34:11 -07:00
|
|
|
disp = _display_connect();
|
2019-07-15 07:53:42 -07:00
|
|
|
ck_assert(disp != NULL);
|
|
|
|
|
|
|
|
ecore_wl2_display_screen_size_get(disp, &w, &h);
|
|
|
|
ck_assert_int_ne(w, 0);
|
|
|
|
ck_assert_int_ne(h, 0);
|
|
|
|
}
|
|
|
|
EFL_END_TEST
|
|
|
|
|
2019-07-15 09:32:50 -07:00
|
|
|
EFL_START_TEST(wl2_display_inputs_get)
|
|
|
|
{
|
|
|
|
Ecore_Wl2_Display *disp;
|
|
|
|
Eina_Iterator *itr;
|
|
|
|
|
2019-07-22 05:34:11 -07:00
|
|
|
disp = _display_connect();
|
2019-07-15 09:32:50 -07:00
|
|
|
ck_assert(disp != NULL);
|
|
|
|
|
|
|
|
itr = ecore_wl2_display_inputs_get(disp);
|
|
|
|
ck_assert(itr != NULL);
|
2019-09-17 06:35:43 -07:00
|
|
|
|
|
|
|
eina_iterator_free(itr);
|
2019-07-15 09:32:50 -07:00
|
|
|
}
|
|
|
|
EFL_END_TEST
|
|
|
|
|
2019-11-12 06:22:09 -08:00
|
|
|
EFL_START_TEST(wl2_display_compositor_version_get)
|
|
|
|
{
|
|
|
|
Ecore_Wl2_Display *disp;
|
|
|
|
int ver;
|
|
|
|
|
|
|
|
disp = _display_connect();
|
|
|
|
ck_assert(disp != NULL);
|
|
|
|
|
|
|
|
ver = ecore_wl2_display_compositor_version_get(disp);
|
|
|
|
ck_assert_int_ne(ver, 0);
|
|
|
|
}
|
|
|
|
EFL_END_TEST
|
|
|
|
|
2020-01-21 05:13:52 -08:00
|
|
|
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)
|
2020-01-08 08:02:11 -08:00
|
|
|
{
|
|
|
|
Ecore_Wl2_Display *disp;
|
|
|
|
|
|
|
|
disp = _display_connect();
|
|
|
|
ck_assert(disp != NULL);
|
|
|
|
|
2020-01-21 05:13:52 -08:00
|
|
|
//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
|
|
|
|
|
|
|
|
static Eina_Bool
|
|
|
|
_test_sync_done(void *data, int type EINA_UNUSED, void *event EINA_UNUSED)
|
|
|
|
{
|
|
|
|
Test_Data *td = data;
|
|
|
|
Eina_Bool ret;
|
2020-01-09 06:48:58 -08:00
|
|
|
|
2020-01-21 05:13:52 -08:00
|
|
|
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);
|
2020-01-08 08:02:11 -08:00
|
|
|
}
|
|
|
|
EFL_END_TEST
|
|
|
|
|
2019-07-15 06:49:31 -07:00
|
|
|
void
|
|
|
|
ecore_wl2_test_display(TCase *tc)
|
|
|
|
{
|
2019-07-15 11:21:36 -07:00
|
|
|
if ((!getenv("WAYLAND_DISPLAY")) && (getenv("XDG_RUNTIME_DIR")))
|
2019-07-15 07:28:29 -07:00
|
|
|
{
|
|
|
|
/* tests here are for server-side functions */
|
2019-07-15 07:42:27 -07:00
|
|
|
printf("No Wayland Compositor detected. Testing server-side functions\n");
|
2019-07-15 07:28:29 -07:00
|
|
|
tcase_add_test(tc, wl2_display_create);
|
|
|
|
tcase_add_test(tc, wl2_display_destroy);
|
|
|
|
tcase_add_test(tc, wl2_display_get);
|
|
|
|
tcase_add_test(tc, wl2_display_name_get);
|
|
|
|
}
|
2019-08-01 05:41:07 -07:00
|
|
|
else if (getenv("WAYLAND_DISPLAY"))
|
2019-07-15 07:28:29 -07:00
|
|
|
{
|
|
|
|
/* tests here are for client-side functions */
|
2019-07-15 07:42:27 -07:00
|
|
|
printf("Wayland Compositor detected. Testing client-side functions\n");
|
2019-07-15 07:28:29 -07:00
|
|
|
tcase_add_test(tc, wl2_display_connect);
|
|
|
|
tcase_add_test(tc, wl2_display_disconnect);
|
2019-07-15 08:00:05 -07:00
|
|
|
tcase_add_test(tc, wl2_display_registry_get);
|
2019-07-15 07:31:56 -07:00
|
|
|
tcase_add_test(tc, wl2_display_shm_get);
|
2019-07-15 07:47:36 -07:00
|
|
|
tcase_add_test(tc, wl2_display_globals_get);
|
2019-07-15 09:32:50 -07:00
|
|
|
tcase_add_test(tc, wl2_display_inputs_get);
|
2019-11-12 06:22:09 -08:00
|
|
|
tcase_add_test(tc, wl2_display_compositor_version_get);
|
2020-01-21 05:13:52 -08:00
|
|
|
tcase_add_test(tc, wl2_display_input_find);
|
|
|
|
tcase_add_test(tc, wl2_display_flush);
|
|
|
|
tcase_add_test(tc, wl2_display_sync_is_done);
|
2020-01-21 10:04:06 -08:00
|
|
|
if (!getenv("E_START"))
|
|
|
|
{
|
|
|
|
tcase_add_test(tc, wl2_display_dmabuf_get);
|
|
|
|
tcase_add_test(tc, wl2_display_screen_size_get);
|
|
|
|
}
|
2019-07-15 07:28:29 -07:00
|
|
|
}
|
2019-07-15 06:49:31 -07:00
|
|
|
}
|