diff options
author | Jonas Ådahl <jadahl@gmail.com> | 2015-09-08 16:03:45 +0800 |
---|---|---|
committer | Jonas Ådahl <jadahl@gmail.com> | 2015-12-23 12:19:36 +0800 |
commit | 5054b2a99c3b06146c0ae75f7ce875ac5f5a4972 (patch) | |
tree | d3d39c862d4164eb8bd10af9d1e8ddbbb522998c | |
parent | d455de32a0ec4e5e87259c67662dc1eadb3177a7 (diff) | |
download | mutter-5054b2a99c3b06146c0ae75f7ce875ac5f5a4972.tar.gz |
tests: Don't rely on latency for actually showing Wayland windows
The test runner sends a "show" command to the test clients and assumes
this was enough work done by the client to enable the compositor to map
the window. Now that we wait to show a Wayland window until the first
buffer is attached (see bug 750552), we need to make sure that we attach
a buffer before assuming that we have the final stacking order.
So, to in order to continue relying on "show" to be enough to actually
show a window, let the test client wait until it has drawn the first
frame.
This makes the tests using Wayland clients test non-flaky.
https://bugzilla.gnome.org/show_bug.cgi?id=754711
-rw-r--r-- | src/tests/test-client.c | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/src/tests/test-client.c b/src/tests/test-client.c index 4c4480c28..7e24ab2ea 100644 --- a/src/tests/test-client.c +++ b/src/tests/test-client.c @@ -42,6 +42,16 @@ lookup_window (const char *window_id) } static void +on_after_paint (GdkFrameClock *clock, + GMainLoop *loop) +{ + g_signal_handlers_disconnect_by_func (clock, + (gpointer) on_after_paint, + loop); + g_main_loop_quit (loop); +} + +static void process_line (const char *line) { GError *error = NULL; @@ -135,10 +145,25 @@ process_line (const char *line) } GtkWidget *window = lookup_window (argv[1]); + GdkWindow *gdk_window = gtk_widget_get_window (window); if (!window) goto out; gtk_widget_show (window); + + /* When a Wayland client, we cannot be really sure that the window has + * been mappable until after we have painted. So, in order to have the + * test runner rely on the "show" command to have done what the client + * needs to do in order for a window to be mappable compositor side, lets + * wait with returning until after the first frame. + */ + GdkFrameClock *frame_clock = gdk_window_get_frame_clock (gdk_window); + GMainLoop *loop = g_main_loop_new (NULL, FALSE); + g_signal_connect (frame_clock, "after-paint", + G_CALLBACK (on_after_paint), + loop); + g_main_loop_run (loop); + g_main_loop_unref (loop); } else if (strcmp (argv[0], "hide") == 0) { |