1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195
|
/*
* Copyright (C) 2020 Purism SPC
*
* SPDX-License-Identifier: GPL-3.0-or-later
*
* Author: Guido Günther <agx@sigxcpu.org>
*/
#include "testlib.h"
#include "xdg-shell-client-protocol.h"
typedef struct {
gboolean auto_maximize;
const char *screenshot_maximized;
} PhocTestXdgShellTestData;
static gboolean
test_client_xdg_shell_normal (PhocTestClientGlobals *globals, gpointer data)
{
PhocTestXdgToplevelSurface *ls_green;
ls_green = phoc_test_xdg_toplevel_new_with_buffer (globals, 0, 0, NULL, 0xFF00FF00);
g_assert_nonnull (ls_green);
phoc_assert_screenshot (globals, "test-xdg-shell-normal-1.png");
phoc_test_xdg_toplevel_free (ls_green);
phoc_assert_screenshot (globals, "empty.png");
return TRUE;
}
static gboolean
test_client_xdg_shell_auto_maximized (PhocTestClientGlobals *globals, gpointer data)
{
PhocTestXdgToplevelSurface *ls_green;
ls_green = phoc_test_xdg_toplevel_new_with_buffer (globals, 0, 0, NULL, 0xFF00FF00);
g_assert_nonnull (ls_green);
phoc_assert_screenshot (globals, "test-xdg-shell-maximized-1.png");
phoc_test_xdg_toplevel_free (ls_green);
phoc_assert_screenshot (globals, "empty.png");
return TRUE;
}
static gboolean
test_client_xdg_shell_toplevel_maximized (PhocTestClientGlobals *globals, gpointer data)
{
PhocTestXdgToplevelSurface *xs;
guint32 color = 0xFF00FF00;
xs = phoc_test_xdg_toplevel_new_with_buffer (globals, 0, 0, "to-max", color);
g_assert_nonnull (xs);
/* Maximize */
zwlr_foreign_toplevel_handle_v1_set_maximized (xs->foreign_toplevel->handle);
wl_surface_commit (xs->wl_surface);
wl_display_dispatch (globals->display);
/* We got the maximized size, update the buffer */
phoc_test_xdg_update_buffer (globals, xs, color);
phoc_assert_screenshot (globals, "test-xdg-shell-maximized-1.png");
/* Back to normal state */
zwlr_foreign_toplevel_handle_v1_unset_maximized (xs->foreign_toplevel->handle);
wl_display_dispatch (globals->display);
phoc_test_xdg_update_buffer (globals, xs, color);
phoc_assert_screenshot (globals, "test-xdg-shell-normal-1.png");
phoc_test_xdg_toplevel_free (xs);
phoc_assert_screenshot (globals, "empty.png");
return TRUE;
}
static gboolean
test_client_xdg_shell_toplevel_maximized_scale (PhocTestClientGlobals *globals, gpointer data)
{
PhocTestXdgToplevelSurface *xs;
guint32 color = 0xFF00FF00;
xs = phoc_test_xdg_toplevel_new_with_buffer (globals, 0, 0, "to-max", color);
g_assert_nonnull (xs);
/* Maximize */
zwlr_foreign_toplevel_handle_v1_set_maximized (xs->foreign_toplevel->handle);
wl_surface_commit (xs->wl_surface);
wl_display_dispatch (globals->display);
/* We got the maximized size, update the buffer */
phoc_test_xdg_update_buffer (globals, xs, color);
phoc_assert_screenshot (globals, "test-xdg-shell-maximized-2.5.png");
/* Back to normal state */
zwlr_foreign_toplevel_handle_v1_unset_maximized (xs->foreign_toplevel->handle);
wl_display_dispatch (globals->display);
phoc_test_xdg_update_buffer (globals, xs, color);
phoc_assert_screenshot (globals, "test-xdg-shell-normal-2.5.png");
phoc_test_xdg_toplevel_free (xs);
phoc_assert_screenshot (globals, "empty-2.5.png");
return TRUE;
}
static gboolean
test_client_xdg_shell_server_prepare (PhocServer *server, gpointer data)
{
PhocDesktop *desktop = phoc_server_get_desktop (server);
gboolean maximize = GPOINTER_TO_INT (data);
g_assert_nonnull (desktop);
phoc_desktop_set_auto_maximize (desktop, maximize);
return TRUE;
}
static void
test_xdg_shell_normal (void)
{
PhocTestClientIface iface = {
.server_prepare = test_client_xdg_shell_server_prepare,
.client_run = test_client_xdg_shell_normal,
.debug_flags = PHOC_SERVER_DEBUG_FLAG_DISABLE_ANIMATIONS,
};
phoc_test_client_run (TEST_PHOC_CLIENT_TIMEOUT, &iface, GINT_TO_POINTER (FALSE));
}
static void
test_xdg_shell_auto_maximized (void)
{
PhocTestClientIface iface = {
.server_prepare = test_client_xdg_shell_server_prepare,
.client_run = test_client_xdg_shell_auto_maximized,
.debug_flags = PHOC_SERVER_DEBUG_FLAG_DISABLE_ANIMATIONS,
};
phoc_test_client_run (TEST_PHOC_CLIENT_TIMEOUT, &iface, GINT_TO_POINTER (TRUE));
}
static void
test_xdg_shell_toplevel_maximized (void)
{
PhocTestClientIface iface = {
.server_prepare = test_client_xdg_shell_server_prepare,
.client_run = test_client_xdg_shell_toplevel_maximized,
.debug_flags = PHOC_SERVER_DEBUG_FLAG_DISABLE_ANIMATIONS,
};
phoc_test_client_run (TEST_PHOC_CLIENT_TIMEOUT, &iface, GINT_TO_POINTER (FALSE));
}
static void
test_xdg_shell_toplevel_maximized_scale (void)
{
PhocTestClientIface iface = {
.server_prepare = test_client_xdg_shell_server_prepare,
.client_run = test_client_xdg_shell_toplevel_maximized_scale,
.debug_flags = PHOC_SERVER_DEBUG_FLAG_DISABLE_ANIMATIONS,
.output_config = (PhocTestOutputConfig){
.width = 360,
.height = 720,
.scale = 2.5,
.transform = WL_OUTPUT_TRANSFORM_270,
},
};
phoc_test_client_run (TEST_PHOC_CLIENT_TIMEOUT, &iface, GINT_TO_POINTER (FALSE));
}
int
main (int argc, char *argv[])
{
g_test_init (&argc, &argv, NULL);
PHOC_TEST_ADD ("/phoc/xdg-shell/simple/normal", test_xdg_shell_normal);
PHOC_TEST_ADD ("/phoc/xdg-shell/auto-maximize/normal", test_xdg_shell_auto_maximized);
PHOC_TEST_ADD ("/phoc/xdg-shell/toplevel/maximize/normal", test_xdg_shell_toplevel_maximized);
PHOC_TEST_ADD ("/phoc/xdg-shell/toplevel/maximize/scale",
test_xdg_shell_toplevel_maximized_scale);
return g_test_run ();
}
|