summaryrefslogtreecommitdiff
path: root/src/tests/ecore_wl2
diff options
context:
space:
mode:
Diffstat (limited to 'src/tests/ecore_wl2')
-rw-r--r--src/tests/ecore_wl2/ecore_wl2_suite.c7
-rw-r--r--src/tests/ecore_wl2/ecore_wl2_suite.h13
-rw-r--r--src/tests/ecore_wl2/ecore_wl2_test_display.c138
-rw-r--r--src/tests/ecore_wl2/ecore_wl2_test_ecore_wl2.c22
-rw-r--r--src/tests/ecore_wl2/ecore_wl2_test_input.c196
-rw-r--r--src/tests/ecore_wl2/ecore_wl2_test_output.c33
-rw-r--r--src/tests/ecore_wl2/ecore_wl2_test_window.c654
-rw-r--r--src/tests/ecore_wl2/ecore_wl2_tests_helper_egl.h64
-rw-r--r--src/tests/ecore_wl2/ecore_wl2_tests_helpers.h44
-rw-r--r--src/tests/ecore_wl2/meson.build14
10 files changed, 1053 insertions, 132 deletions
diff --git a/src/tests/ecore_wl2/ecore_wl2_suite.c b/src/tests/ecore_wl2/ecore_wl2_suite.c
index b6875c006d..9418de14c4 100644
--- a/src/tests/ecore_wl2/ecore_wl2_suite.c
+++ b/src/tests/ecore_wl2/ecore_wl2_suite.c
@@ -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[] =
{
@@ -13,6 +7,7 @@ static const Efl_Test_Case etc[] =
{ "Display", ecore_wl2_test_display },
{ "Window", ecore_wl2_test_window },
{ "Input", ecore_wl2_test_input },
+ { "Output", ecore_wl2_test_output },
#endif
{ NULL, NULL }
};
diff --git a/src/tests/ecore_wl2/ecore_wl2_suite.h b/src/tests/ecore_wl2/ecore_wl2_suite.h
index a8edf93074..111b388f28 100644
--- a/src/tests/ecore_wl2/ecore_wl2_suite.h
+++ b/src/tests/ecore_wl2/ecore_wl2_suite.h
@@ -1,12 +1,21 @@
#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);
void ecore_wl2_test_window(TCase *tc);
void ecore_wl2_test_input(TCase *tc);
+void ecore_wl2_test_output(TCase *tc);
#endif
diff --git a/src/tests/ecore_wl2/ecore_wl2_test_display.c b/src/tests/ecore_wl2/ecore_wl2_test_display.c
index 99b441b433..3c6dfeb394 100644
--- a/src/tests/ecore_wl2/ecore_wl2_test_display.c
+++ b/src/tests/ecore_wl2/ecore_wl2_test_display.c
@@ -1,16 +1,12 @@
-#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"
+static Ecore_Wl2_Display *
+_display_setup(void)
+{
+ return ecore_wl2_display_create(NULL);
+}
+
EFL_START_TEST(wl2_display_create)
{
Ecore_Wl2_Display *disp;
@@ -177,6 +173,118 @@ EFL_START_TEST(wl2_display_compositor_version_get)
}
EFL_END_TEST
+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;
+
+ disp = _display_connect();
+ ck_assert(disp != NULL);
+
+ //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;
+
+ 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
+
void
ecore_wl2_test_display(TCase *tc)
{
@@ -197,10 +305,16 @@ 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);
+ 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);
+ }
}
}
diff --git a/src/tests/ecore_wl2/ecore_wl2_test_ecore_wl2.c b/src/tests/ecore_wl2/ecore_wl2_test_ecore_wl2.c
index 6ed6b7343f..ce452abd89 100644
--- a/src/tests/ecore_wl2/ecore_wl2_test_ecore_wl2.c
+++ b/src/tests/ecore_wl2/ecore_wl2_test_ecore_wl2.c
@@ -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)
@@ -16,8 +5,19 @@ EFL_START_TEST(ecore_wl2_simple)
}
EFL_END_TEST
+EFL_START_TEST(wl2_session_recovery_disable)
+{
+ //FIXME: Need some discussion about how to validate this API in TC.
+ ecore_wl2_session_recovery_disable();
+}
+EFL_END_TEST
+
void
ecore_wl2_test_init(TCase *tc)
{
tcase_add_test(tc, ecore_wl2_simple);
+ if (getenv("WAYLAND_DISPLAY") && (getenv("E_START")))
+ {
+ tcase_add_test(tc, wl2_session_recovery_disable);
+ }
}
diff --git a/src/tests/ecore_wl2/ecore_wl2_test_input.c b/src/tests/ecore_wl2/ecore_wl2_test_input.c
index 73056a77fa..12b1e45338 100644
--- a/src/tests/ecore_wl2/ecore_wl2_test_input.c
+++ b/src/tests/ecore_wl2/ecore_wl2_test_input.c
@@ -1,23 +1,5 @@
-#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"
-
-static Ecore_Wl2_Display *
-_display_connect(void)
-{
- Ecore_Wl2_Display *disp;
-
- disp = ecore_wl2_display_connect(NULL);
- return disp;
-}
+#include "ecore_wl2_tests_helpers.h"
EFL_START_TEST(wl2_input_seat_get)
{
@@ -102,7 +84,9 @@ EFL_START_TEST(wl2_input_keymap_get)
EINA_ITERATOR_FOREACH(itr, input)
{
- ck_assert(ecore_wl2_input_keymap_get(input) != NULL);
+ if (ecore_wl2_input_seat_capabilities_get(input) ==
+ ECORE_WL2_SEAT_CAPABILITIES_KEYBOARD)
+ ck_assert(ecore_wl2_input_keymap_get(input) != NULL);
}
eina_iterator_free(itr);
@@ -130,6 +114,173 @@ EFL_START_TEST(wl2_input_name_get)
}
EFL_END_TEST
+static Eina_Bool
+_test_input_seat_capa_configure_complete(void *data, int type EINA_UNUSED, void *event EINA_UNUSED)
+{
+ Test_Data *td = data;
+ Ecore_Wl2_Input *input;
+ Eina_Iterator *itr;
+
+ itr = ecore_wl2_display_inputs_get(td->display);
+ ck_assert(itr != NULL);
+
+ EINA_ITERATOR_FOREACH(itr, input)
+ {
+ Ecore_Wl2_Seat_Capabilities cap = ECORE_WL2_SEAT_CAPABILITIES_NONE;
+
+ cap = ecore_wl2_input_seat_capabilities_get(input);
+ ck_assert(cap != ECORE_WL2_SEAT_CAPABILITIES_NONE);
+ }
+
+ 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
+
+EFL_START_TEST(wl2_input_pointer_xy)
+{
+ Ecore_Wl2_Display *disp;
+ Ecore_Wl2_Input *input;
+ Eina_Iterator *itr;
+
+ disp = _display_connect();
+ ck_assert(disp != NULL);
+
+ itr = ecore_wl2_display_inputs_get(disp);
+ ck_assert(itr != NULL);
+
+ EINA_ITERATOR_FOREACH(itr, input)
+ {
+ if (ecore_wl2_input_seat_capabilities_get(input) ==
+ ECORE_WL2_SEAT_CAPABILITIES_POINTER)
+ {
+ int x = 0, y = 0;
+
+ ecore_wl2_input_pointer_xy_get(input, &x, &y);
+ ck_assert_int_ne(x, 0);
+ ck_assert_int_ne(y, 0);
+ }
+ }
+
+ eina_iterator_free(itr);
+}
+EFL_END_TEST
+
+EFL_START_TEST(wl2_input_keyboard_repeat)
+{
+ Ecore_Wl2_Display *disp;
+ Ecore_Wl2_Input *input;
+ Eina_Iterator *itr;
+
+ disp = _display_connect();
+ ck_assert(disp != NULL);
+
+ itr = ecore_wl2_display_inputs_get(disp);
+ ck_assert(itr != NULL);
+
+ EINA_ITERATOR_FOREACH(itr, input)
+ {
+ if (ecore_wl2_input_seat_capabilities_get(input) ==
+ ECORE_WL2_SEAT_CAPABILITIES_KEYBOARD)
+ {
+ double rate = 0.0, delay = 0.0;
+
+ ecore_wl2_input_keyboard_repeat_set(input, 2.0, 2.0);
+ ecore_wl2_input_keyboard_repeat_get(input, &rate, &delay);
+ ck_assert(!EINA_DBL_EQ(rate, 2.0));
+ ck_assert(!EINA_DBL_EQ(delay, 2.0));
+ }
+ }
+
+ eina_iterator_free(itr);
+}
+EFL_END_TEST
+
+EFL_START_TEST(wl2_input_cursor_from_name_set)
+{
+ Ecore_Wl2_Display *disp;
+ Ecore_Wl2_Input *input;
+ Eina_Iterator *itr;
+
+ disp = _display_connect();
+ ck_assert(disp != NULL);
+
+ itr = ecore_wl2_display_inputs_get(disp);
+ ck_assert(itr != NULL);
+
+ EINA_ITERATOR_FOREACH(itr, input)
+ {
+ if (ecore_wl2_input_seat_capabilities_get(input) ==
+ ECORE_WL2_SEAT_CAPABILITIES_POINTER)
+ {
+ //FIXME: Need some discussion about how to validate this API in TC.
+ ecore_wl2_input_cursor_from_name_set(input, NULL);
+ ecore_wl2_input_cursor_from_name_set(NULL, NULL);
+ }
+ }
+
+ eina_iterator_free(itr);
+}
+EFL_END_TEST
+
+EFL_START_TEST(wl2_input_pointer_set)
+{
+ Ecore_Wl2_Display *disp;
+ Ecore_Wl2_Input *input;
+ Eina_Iterator *itr;
+
+ disp = _display_connect();
+ ck_assert(disp != NULL);
+
+ itr = ecore_wl2_display_inputs_get(disp);
+ ck_assert(itr != NULL);
+
+ EINA_ITERATOR_FOREACH(itr, input)
+ {
+ if (ecore_wl2_input_seat_capabilities_get(input) ==
+ ECORE_WL2_SEAT_CAPABILITIES_POINTER)
+ {
+ //FIXME: Need some discussion about how to validate this API in TC.
+ ecore_wl2_input_pointer_set(input, NULL, 0, 0);
+ ecore_wl2_input_pointer_set(NULL, NULL, 0, 0);
+ }
+ }
+
+ eina_iterator_free(itr);
+}
+EFL_END_TEST
+
void
ecore_wl2_test_input(TCase *tc)
{
@@ -140,5 +291,10 @@ ecore_wl2_test_input(TCase *tc)
tcase_add_test(tc, wl2_input_display_get);
tcase_add_test(tc, wl2_input_keymap_get);
tcase_add_test(tc, wl2_input_name_get);
+ tcase_add_test(tc, wl2_input_seat_capabilities);
+ tcase_add_test(tc, wl2_input_pointer_xy);
+ tcase_add_test(tc, wl2_input_keyboard_repeat);
+ tcase_add_test(tc, wl2_input_cursor_from_name_set);
+ tcase_add_test(tc, wl2_input_pointer_set);
}
}
diff --git a/src/tests/ecore_wl2/ecore_wl2_test_output.c b/src/tests/ecore_wl2/ecore_wl2_test_output.c
new file mode 100644
index 0000000000..c3dbe98de6
--- /dev/null
+++ b/src/tests/ecore_wl2/ecore_wl2_test_output.c
@@ -0,0 +1,33 @@
+#include "ecore_wl2_suite.h"
+
+EFL_START_TEST(wl2_output_dpi_get)
+{
+ int ret;
+
+ //FIXME: Need some discussion about how to validate this API in TC.
+ ret = ecore_wl2_output_dpi_get(NULL);
+
+ fail_if(ret != 75);
+}
+EFL_END_TEST
+
+EFL_START_TEST(wl2_output_transform_get)
+{
+ int ret;
+
+ //FIXME: Need some discussion about how to validate this API in TC.
+ ret = ecore_wl2_output_transform_get(NULL);
+
+ fail_if(ret != 0);
+}
+EFL_END_TEST
+
+void
+ecore_wl2_test_output(TCase *tc)
+{
+ if (getenv("WAYLAND_DISPLAY"))
+ {
+ tcase_add_test(tc, wl2_output_dpi_get);
+ tcase_add_test(tc, wl2_output_transform_get);
+ }
+}
diff --git a/src/tests/ecore_wl2/ecore_wl2_test_window.c b/src/tests/ecore_wl2/ecore_wl2_test_window.c
index bb329195ef..4b9e734d61 100644
--- a/src/tests/ecore_wl2/ecore_wl2_test_window.c
+++ b/src/tests/ecore_wl2/ecore_wl2_test_window.c
@@ -1,31 +1,14 @@
-#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"
-static Ecore_Wl2_Display *
-_display_connect(void)
-{
- Ecore_Wl2_Display *disp;
-
- disp = ecore_wl2_display_connect(NULL);
- return disp;
-}
+#ifdef GL_GLES
+#include "ecore_wl2_tests_helper_egl.h"
+#endif
-static Ecore_Wl2_Window *
-_window_create(Ecore_Wl2_Display *disp)
+static struct wl_surface *
+_surface_get(Ecore_Wl2_Window *win)
{
- Ecore_Wl2_Window *win;
-
- win = ecore_wl2_window_new(disp, NULL, 100, 100, 500, 500);
- return win;
+ return ecore_wl2_window_surface_get(win);
}
EFL_START_TEST(wl2_window_new)
@@ -86,40 +69,6 @@ EFL_START_TEST(wl2_window_rotation)
}
EFL_END_TEST
-EFL_START_TEST(wl2_window_output_find)
-{
- Ecore_Wl2_Display *disp;
- Ecore_Wl2_Window *win;
- Ecore_Wl2_Output *out;
-
- disp = _display_connect();
- ck_assert(disp != NULL);
-
- win = _window_create(disp);
- ck_assert(win != NULL);
-
- out = ecore_wl2_window_output_find(win);
- ck_assert(out != NULL);
-}
-EFL_END_TEST
-
-EFL_START_TEST(wl2_window_aux_hints_supported_get)
-{
- Ecore_Wl2_Display *disp;
- Ecore_Wl2_Window *win;
- Eina_List *l;
-
- disp = _display_connect();
- ck_assert(disp != NULL);
-
- win = _window_create(disp);
- ck_assert(win != NULL);
-
- l = ecore_wl2_window_aux_hints_supported_get(win);
- ck_assert(l != NULL);
-}
-EFL_END_TEST
-
EFL_START_TEST(wl2_window_display_get)
{
Ecore_Wl2_Display *disp;
@@ -329,23 +278,96 @@ 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)
{
- Ecore_Wl2_Display *disp;
- Ecore_Wl2_Window *win;
- Eina_Bool ret;
+ Test_Data *td;
+ Eina_Bool ret = EINA_FALSE;
- disp = _display_connect();
- ck_assert(disp != NULL);
+ ecore_wl2_init();
- win = _window_create(disp);
- ck_assert(win != NULL);
+ 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);
- ret = ecore_wl2_window_activated_get(win);
+ ecore_wl2_window_show(td->win);
+ ret = _init_egl(td);
fail_if(ret != EINA_TRUE);
+
+ 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)
{
@@ -454,6 +476,486 @@ EFL_START_TEST(wl2_window_role)
}
EFL_END_TEST
+EFL_START_TEST(wl2_window_input_region)
+{
+ Ecore_Wl2_Display *disp;
+ Ecore_Wl2_Window *win;
+ int x, y, w, h;
+
+ disp = _display_connect();
+ ck_assert(disp != NULL);
+
+ win = _window_create(disp);
+ ck_assert(win != NULL);
+
+ ecore_wl2_window_input_region_set(win, 10, 10, 100, 100);
+
+ ecore_wl2_window_input_region_get(win, &x, &y, &w, &h);
+ fail_if(x != 10);
+ fail_if(y != 10);
+ fail_if(w != 100);
+ fail_if(h != 100);
+}
+EFL_END_TEST
+
+EFL_START_TEST(wl2_window_opaque_region)
+{
+ Ecore_Wl2_Display *disp;
+ Ecore_Wl2_Window *win;
+ int x, y, w, h;
+
+ disp = _display_connect();
+ ck_assert(disp != NULL);
+
+ win = _window_create(disp);
+ ck_assert(win != NULL);
+
+ ecore_wl2_window_opaque_region_set(win, 10, 10, 100, 100);
+
+ ecore_wl2_window_opaque_region_get(win, &x, &y, &w, &h);
+ fail_if(x != 10);
+ fail_if(y != 10);
+ fail_if(w != 100);
+ fail_if(h != 100);
+}
+EFL_END_TEST
+
+EFL_START_TEST(wl2_window_popup_input)
+{
+ Ecore_Wl2_Display *disp;
+ Ecore_Wl2_Window *win;
+ Ecore_Wl2_Input *input;
+ Eina_Iterator *itr;
+
+ disp = _display_connect();
+ ck_assert(disp != NULL);
+
+ win = _window_create(disp);
+ ck_assert(win != NULL);
+
+ ecore_wl2_window_type_set(win, ECORE_WL2_WINDOW_TYPE_MENU);
+
+ itr = ecore_wl2_display_inputs_get(disp);
+ ck_assert(itr != NULL);
+
+ EINA_ITERATOR_FOREACH(itr, input)
+ {
+ if (ecore_wl2_input_seat_capabilities_get(input) !=
+ ECORE_WL2_SEAT_CAPABILITIES_POINTER)
+ continue;
+
+ ecore_wl2_window_popup_input_set(win, input);
+ fail_if(ecore_wl2_window_popup_input_get(win) != input);
+ break;
+ }
+
+ eina_iterator_free(itr);
+}
+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
+
+EFL_START_TEST(wl2_window_move)
+{
+ Ecore_Wl2_Display *disp;
+ Ecore_Wl2_Window *win;
+
+ disp = _display_connect();
+ ck_assert(disp != NULL);
+
+ win = _window_create(disp);
+ ck_assert(win != NULL);
+
+ //FIXME: Need some discussion about how to validate this API in TC.
+ ecore_wl2_window_move(NULL, NULL);
+ ecore_wl2_window_move(win, NULL);
+}
+EFL_END_TEST
+
+EFL_START_TEST(wl2_window_resize)
+{
+ Ecore_Wl2_Display *disp;
+ Ecore_Wl2_Window *win;
+
+ disp = _display_connect();
+ ck_assert(disp != NULL);
+
+ win = _window_create(disp);
+ ck_assert(win != NULL);
+
+ //FIXME: Need some discussion about how to validate this API in TC.
+ ecore_wl2_window_resize(NULL, NULL, 0);
+ ecore_wl2_window_resize(win, NULL, 0);
+}
+EFL_END_TEST
+
+EFL_START_TEST(wl2_window_resizing_get)
+{
+ Ecore_Wl2_Display *disp;
+ Ecore_Wl2_Window *win;
+ Eina_Bool ret;
+
+ disp = _display_connect();
+ ck_assert(disp != NULL);
+
+ win = _window_create(disp);
+ ck_assert(win != NULL);
+
+ ret = ecore_wl2_window_resizing_get(win);
+ fail_if (ret == EINA_TRUE);
+}
+EFL_END_TEST
+
+EFL_START_TEST(wl2_window_output_find)
+{
+ Ecore_Wl2_Display *disp;
+ Ecore_Wl2_Window *win;
+ Ecore_Wl2_Output *output;
+
+ disp = _display_connect();
+ ck_assert(disp != NULL);
+
+ win = _window_create(disp);
+ ck_assert(win != NULL);
+
+ //FIXME: Need some discussion about how to validate this API in TC.
+ output = ecore_wl2_window_output_find(win);
+ output = ecore_wl2_window_output_find(NULL);
+ fail_if (output != NULL);
+}
+EFL_END_TEST
+
void
ecore_wl2_test_window(TCase *tc)
{
@@ -463,9 +965,17 @@ ecore_wl2_test_window(TCase *tc)
tcase_add_test(tc, wl2_window_new);
tcase_add_test(tc, wl2_window_surface_test);
tcase_add_test(tc, wl2_window_rotation);
- tcase_add_test(tc, wl2_window_output_find);
if (getenv("E_START"))
- 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);
@@ -477,11 +987,17 @@ ecore_wl2_test_window(TCase *tc)
tcase_add_test(tc, wl2_wm_window_rotation_app);
tcase_add_test(tc, wl2_window_geometry);
tcase_add_test(tc, wl2_window_type);
- tcase_add_test(tc, wl2_window_activated);
tcase_add_test(tc, wl2_window_available_rotation);
tcase_add_test(tc, wl2_window_aspect);
tcase_add_test(tc, wl2_window_class);
tcase_add_test(tc, wl2_window_title);
tcase_add_test(tc, wl2_window_role);
+ tcase_add_test(tc, wl2_window_input_region);
+ tcase_add_test(tc, wl2_window_opaque_region);
+ tcase_add_test(tc, wl2_window_popup_input);
+ tcase_add_test(tc, wl2_window_move);
+ tcase_add_test(tc, wl2_window_resize);
+ tcase_add_test(tc, wl2_window_resizing_get);
+ tcase_add_test(tc, wl2_window_output_find);
}
}
diff --git a/src/tests/ecore_wl2/ecore_wl2_tests_helper_egl.h b/src/tests/ecore_wl2/ecore_wl2_tests_helper_egl.h
new file mode 100644
index 0000000000..10605428be
--- /dev/null
+++ b/src/tests/ecore_wl2/ecore_wl2_tests_helper_egl.h
@@ -0,0 +1,64 @@
+#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 Eina_Bool
+_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));
+
+ if (!eglInitialize(td->egl_display, NULL, NULL))
+ {
+ EINA_LOG_ERR("Failed to initialize egl");
+ eglTerminate(td->egl_display);
+ return EINA_FALSE;
+ }
+
+ if (!eglChooseConfig(td->egl_display, attributes, &td->egl_conf,
+ 1, &num_config))
+ {
+ EINA_LOG_ERR("Failed to choose egl config");
+ eglTerminate(td->egl_display);
+ return EINA_FALSE;
+ }
+
+ 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);
+
+ return EINA_TRUE;
+}
+
+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
diff --git a/src/tests/ecore_wl2/ecore_wl2_tests_helpers.h b/src/tests/ecore_wl2/ecore_wl2_tests_helpers.h
index f897dc9123..c1fe4657a5 100644
--- a/src/tests/ecore_wl2/ecore_wl2_tests_helpers.h
+++ b/src/tests/ecore_wl2/ecore_wl2_tests_helpers.h
@@ -1,24 +1,48 @@
#ifndef ECORE_WL2_TEST_HELPERS_H
# define ECORE_WL2_TEST_HELPERS_H
-# include <Ecore_Wl2.h>
+#include <wayland-egl.h>
-static Ecore_Wl2_Display *
-_display_setup(void)
+#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 *disp;
+ Ecore_Wl2_Display *display;
+ Ecore_Wl2_Window *win;
+ Ecore_Wl2_Frame_Cb_Handle *frame_callback_handler;
+ Ecore_Event_Handler *handler;
- disp = ecore_wl2_display_create(NULL);
- return disp;
-}
+ 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)
{
- Ecore_Wl2_Display *disp;
+ return ecore_wl2_display_connect(NULL);
+}
- disp = ecore_wl2_display_connect(NULL);
- return disp;
+static Ecore_Wl2_Window *
+_window_create(Ecore_Wl2_Display *disp)
+{
+ return ecore_wl2_window_new(disp, NULL, 100, 100, WIDTH, HEIGHT);
}
#endif
diff --git a/src/tests/ecore_wl2/meson.build b/src/tests/ecore_wl2/meson.build
index eb1a13db6a..f7472d02ed 100644
--- a/src/tests/ecore_wl2/meson.build
+++ b/src/tests/ecore_wl2/meson.build
@@ -5,12 +5,22 @@ ecore_wl2_suite_src = [
'ecore_wl2_test_ecore_wl2.c',
'ecore_wl2_test_display.c',
'ecore_wl2_test_window.c',
- 'ecore_wl2_test_input.c'
+ 'ecore_wl2_test_input.c',
+ 'ecore_wl2_test_output.c'
]
+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
+
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()+'"']