tests/ecore_wl2: Reduce calls to ecore_wl2_display_connect
authorChristopher Michael <cp.michael@samsung.com>
Mon, 22 Jul 2019 13:48:19 +0000 (09:48 -0400)
committerSangHyeon Jade Lee <sh10233.lee@samsung.com>
Tue, 23 Jul 2019 05:09:40 +0000 (14:09 +0900)
In order to reduce display setup time during test execution, we can
just connect once and run all the window tests after that.

ref T8016

src/tests/ecore_wl2/ecore_wl2_test_window.c

index 3f5e98c..88c4f7b 100644 (file)
 
 #include "ecore_wl2_suite.h"
 
+static Ecore_Wl2_Display *disp;
+
 static Ecore_Wl2_Display *
 _display_connect(void)
 {
-   Ecore_Wl2_Display *disp;
-
    disp = ecore_wl2_display_connect(NULL);
+   ck_assert(disp != NULL);
    return disp;
 }
 
@@ -30,12 +31,8 @@ _window_create(Ecore_Wl2_Display *disp)
 
 EFL_START_TEST(wl2_window_new)
 {
-   Ecore_Wl2_Display *disp;
    Ecore_Wl2_Window *win;
 
-   disp = _display_connect();
-   ck_assert(disp != NULL);
-
    win = _window_create(disp);
    ck_assert(win != NULL);
 }
@@ -43,14 +40,10 @@ EFL_END_TEST
 
 EFL_START_TEST(wl2_window_surface_test)
 {
-   Ecore_Wl2_Display *disp;
    Ecore_Wl2_Window *win;
    struct wl_surface *surf;
    int id = -1;
 
-   disp = _display_connect();
-   ck_assert(disp != NULL);
-
    win = _window_create(disp);
    ck_assert(win != NULL);
 
@@ -66,13 +59,9 @@ EFL_END_TEST
 
 EFL_START_TEST(wl2_window_rotation_get)
 {
-   Ecore_Wl2_Display *disp;
    Ecore_Wl2_Window *win;
    int rot = -1;
 
-   disp = _display_connect();
-   ck_assert(disp != NULL);
-
    win = _window_create(disp);
    ck_assert(win != NULL);
 
@@ -83,13 +72,9 @@ 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);
 
@@ -100,13 +85,9 @@ 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);
 
@@ -117,12 +98,8 @@ EFL_END_TEST
 
 EFL_START_TEST(wl2_window_display_get)
 {
-   Ecore_Wl2_Display *disp;
    Ecore_Wl2_Window *win;
 
-   disp = _display_connect();
-   ck_assert(disp != NULL);
-
    win = _window_create(disp);
    ck_assert(win != NULL);
 
@@ -135,6 +112,8 @@ ecore_wl2_test_window(TCase *tc)
 {
    if (getenv("WAYLAND_DISPLAY"))
      {
+        disp = _display_connect();
+
         /* window tests can only run if there is an existing compositor */
         tcase_add_test(tc, wl2_window_new);
         tcase_add_test(tc, wl2_window_surface_test);
@@ -142,5 +121,7 @@ ecore_wl2_test_window(TCase *tc)
         tcase_add_test(tc, wl2_window_output_find);
         tcase_add_test(tc, wl2_window_aux_hints_supported_get);
         tcase_add_test(tc, wl2_window_display_get);
+
+        ecore_wl2_display_disconnect(disp);
      }
 }