summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOlivier Fourdan <ofourdan@redhat.com>2018-07-13 16:40:31 +0200
committerOlivier Fourdan <ofourdan@redhat.com>2018-07-18 14:30:40 +0200
commit3d5784342d7e973924833b9c6a21085d9490629c (patch)
tree30b027e2b86b80234adff63d8ed078927eb35287
parentfa9e330f2c6d3ec34ff57b2c67a9c75c09401014 (diff)
downloadmutter-3d5784342d7e973924833b9c6a21085d9490629c.tar.gz
tests: Add "set_parent_exported" command
Add a "set_parent_exported" command to test the xdg-foreign support, so that we can add a test which uses the GDK API for exported window: `gdk_wayland_window_set_transient_for_exported()` That will allow to detect if transient is applied correctly between foreign windows and detect possible crashes such as issue !174. Related: https://gitlab.gnome.org/GNOME/mutter/issues/174
-rw-r--r--src/tests/test-client.c43
-rw-r--r--src/tests/test-runner.c5
2 files changed, 46 insertions, 2 deletions
diff --git a/src/tests/test-client.c b/src/tests/test-client.c
index 0c8eafc98..1a29c15af 100644
--- a/src/tests/test-client.c
+++ b/src/tests/test-client.c
@@ -20,6 +20,7 @@
#include <gio/gunixinputstream.h>
#include <gtk/gtk.h>
#include <gdk/gdkx.h>
+#include <gdk/gdkwayland.h>
#include <stdarg.h>
#include <stdlib.h>
#include <string.h>
@@ -31,6 +32,19 @@ GHashTable *windows;
static void read_next_line (GDataInputStream *in);
+static void
+window_export_handle_cb (GdkWindow *window,
+ const char *handle_str,
+ gpointer user_data)
+{
+ GdkWindow *gdk_window = gtk_widget_get_window (GTK_WIDGET (user_data));
+
+ if (!gdk_wayland_window_set_transient_for_exported (gdk_window,
+ (gchar *) handle_str))
+ g_print ("Fail to set transient_for exported window handle %s", handle_str);
+ gdk_window_set_modal_hint (gdk_window, TRUE);
+}
+
static GtkWidget *
lookup_window (const char *window_id)
{
@@ -151,6 +165,35 @@ process_line (const char *line)
gtk_window_set_transient_for (GTK_WINDOW (window),
GTK_WINDOW (parent_window));
}
+ else if (strcmp (argv[0], "set_parent_exported") == 0)
+ {
+ if (argc != 3)
+ {
+ g_print ("usage: set_parent_exported <window-id> <parent-id>");
+ goto out;
+ }
+
+ GtkWidget *window = lookup_window (argv[1]);
+ if (!window)
+ {
+ g_print ("unknown window %s", argv[1]);
+ goto out;
+ }
+
+ GtkWidget *parent_window = lookup_window (argv[2]);
+ if (!parent_window)
+ {
+ g_print ("unknown parent window %s", argv[2]);
+ goto out;
+ }
+
+ GdkWindow *parent_gdk_window = gtk_widget_get_window (parent_window);
+ if (!gdk_wayland_window_export_handle (parent_gdk_window,
+ window_export_handle_cb,
+ window,
+ NULL))
+ g_print ("Fail to export handle for window id %s", argv[2]);
+ }
else if (strcmp (argv[0], "show") == 0)
{
if (argc != 2)
diff --git a/src/tests/test-runner.c b/src/tests/test-runner.c
index 5c3d25bc9..ecd9fa7f7 100644
--- a/src/tests/test-runner.c
+++ b/src/tests/test-runner.c
@@ -423,7 +423,8 @@ test_case_do (TestCase *test,
NULL))
return FALSE;
}
- else if (strcmp (argv[0], "set_parent") == 0)
+ else if (strcmp (argv[0], "set_parent") == 0 ||
+ strcmp (argv[0], "set_parent_exported") == 0)
{
if (argc != 3)
BAD_COMMAND("usage: %s <client-id>/<window-id> <parent-window-id>",
@@ -435,7 +436,7 @@ test_case_do (TestCase *test,
return FALSE;
if (!test_client_do (client, error,
- "set_parent", window_id,
+ argv[0], window_id,
argv[2],
NULL))
return FALSE;