[gtk/wip/otte/reftests: 1/7] testsuite: Make reftests work again
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/wip/otte/reftests: 1/7] testsuite: Make reftests work again
- Date: Wed, 27 Mar 2019 03:30:53 +0000 (UTC)
commit f0a76fa016b328ff2ed740457ec3755b4cd0cc99
Author: Benjamin Otte <otte redhat com>
Date: Tue Mar 26 17:35:26 2019 +0100
testsuite: Make reftests work again
Well, the testrunner works again, the tests don't all succeed.
So exclude them from CI.
.gitlab-ci/test-docker.sh | 1 +
testsuite/meson.build | 2 +-
testsuite/reftests/reftest-snapshot.c | 103 ++++++-----------------------
testsuite/reftests/set-default-direction.c | 2 +-
4 files changed, 23 insertions(+), 85 deletions(-)
---
diff --git a/.gitlab-ci/test-docker.sh b/.gitlab-ci/test-docker.sh
index 8a952d7356..17cc7f7313 100755
--- a/.gitlab-ci/test-docker.sh
+++ b/.gitlab-ci/test-docker.sh
@@ -30,4 +30,5 @@ xvfb-run -a -s "-screen 0 1024x768x24" \
--print-errorlogs \
--suite=gtk \
--no-suite=gtk:gsk \
+ --no-suite=gtk:reftest \
--no-suite=gtk:a11y
diff --git a/testsuite/meson.build b/testsuite/meson.build
index f966e769da..10dabd8152 100644
--- a/testsuite/meson.build
+++ b/testsuite/meson.build
@@ -8,4 +8,4 @@ subdir('gtk')
subdir('css')
subdir('a11y')
subdir('tools')
-#subdir('reftests')
+subdir('reftests')
diff --git a/testsuite/reftests/reftest-snapshot.c b/testsuite/reftests/reftest-snapshot.c
index b84d2f5832..b93c4e5233 100644
--- a/testsuite/reftests/reftest-snapshot.c
+++ b/testsuite/reftests/reftest-snapshot.c
@@ -25,17 +25,12 @@
#include "reftest-module.h"
#ifdef GDK_WINDOWING_X11
-#include <gdk/gdkx.h>
+#include <gdk/x11/gdkx.h>
#include <cairo-xlib.h>
#endif
#include <string.h>
-typedef enum {
- SNAPSHOT_WINDOW,
- SNAPSHOT_DRAW
-} SnapshotMode;
-
static GtkWidget *
builder_get_toplevel (GtkBuilder *builder)
{
@@ -86,58 +81,19 @@ reftest_uninhibit_snapshot (void)
}
static void
-check_for_draw (GdkEvent *event, gpointer data)
+check_for_draw (GdkPaintable *paintable,
+ gpointer unused)
{
- if (gdk_event_get_event_type (event) == GDK_EXPOSE)
- {
- reftest_uninhibit_snapshot ();
- gdk_event_handler_set ((GdkEventFunc) gtk_main_do_event, NULL, NULL);
- }
-
- gtk_main_do_event (event);
-}
-
-static void
-snapshot_window_native (GdkSurface *window,
- cairo_t *cr)
-{
-#ifdef GDK_WINDOWING_X11
- if (GDK_IS_X11_SURFACE (window))
- {
- cairo_surface_t *surface;
- XWindowAttributes attrs;
-
- if (gdk_surface_get_surface_type (window) == GDK_SURFACE_TOPLEVEL ||
- gdk_surface_get_surface_type (window) == GDK_SURFACE_TEMP)
- {
- /* give the WM/server some time to sync. They need it.
- * Also, do use popups instead of toplevels in your tests
- * whenever you can.
- */
- gdk_display_sync (gdk_surface_get_display (window));
- g_timeout_add (500, quit_when_idle, loop);
- g_main_loop_run (loop);
- }
-
- XGetWindowAttributes (gdk_x11_display_get_xdisplay (gdk_surface_get_display (window)),
- gdk_x11_surface_get_xid (window),
- &attrs);
- surface = cairo_xlib_surface_create (gdk_x11_display_get_xdisplay (gdk_surface_get_display (window)),
- gdk_x11_surface_get_xid (window),
- attrs.visual,
- attrs.width,
- attrs.height);
-
- cairo_set_source_surface (cr, surface, 0, 0);
- cairo_paint (cr);
- cairo_surface_destroy (surface);
- }
-#endif
+ reftest_uninhibit_snapshot ();
+ g_signal_handlers_disconnect_by_func (paintable, check_for_draw, NULL);
}
static cairo_surface_t *
-snapshot_widget (GtkWidget *widget, SnapshotMode mode)
+snapshot_widget (GtkWidget *widget)
{
+ GtkSnapshot *snapshot;
+ GdkPaintable *paintable;
+ GskRenderNode *node;
cairo_surface_t *surface;
cairo_t *cr;
@@ -146,16 +102,13 @@ snapshot_widget (GtkWidget *widget, SnapshotMode mode)
loop = g_main_loop_new (NULL, FALSE);
/* We wait until the widget is drawn for the first time.
- * We can not wait for a GtkWidget::draw event, because that might not
- * happen if the window is fully obscured by windowed child widgets.
- * Alternatively, we could wait for an expose event on widget's window.
- * Both of these are rather hairy, not sure what's best.
*
* We also use an inhibit mechanism, to give module functions a chance
* to delay the snapshot.
*/
reftest_inhibit_snapshot ();
- gdk_event_handler_set (check_for_draw, NULL, NULL);
+ paintable = gtk_widget_paintable_new (widget);
+ g_signal_connect (paintable, "invalidate-contents", G_CALLBACK (check_for_draw), NULL);
g_main_loop_run (loop);
surface = gdk_surface_create_similar_surface (gtk_widget_get_surface (widget),
@@ -165,30 +118,14 @@ snapshot_widget (GtkWidget *widget, SnapshotMode mode)
cr = cairo_create (surface);
- switch (mode)
- {
- case SNAPSHOT_WINDOW:
- snapshot_window_native (gtk_widget_get_surface (widget), cr);
- break;
- case SNAPSHOT_DRAW:
- {
- GtkSnapshot *snapshot = gtk_snapshot_new (FALSE, "ReftestSnapshot");
- GdkPaintable *paintable = gtk_widget_paintable_new (widget);
- GskRenderNode *node;
-
- gdk_paintable_snapshot (paintable,
- snapshot,
- gtk_widget_get_allocated_width (widget),
- gtk_widget_get_allocated_height (widget));
- g_object_unref (paintable);
- node = gtk_snapshot_free_to_node (snapshot);
- gsk_render_node_draw (node, cr);
- }
- break;
- default:
- g_assert_not_reached();
- break;
- }
+ snapshot = gtk_snapshot_new ();
+ gdk_paintable_snapshot (paintable,
+ snapshot,
+ gtk_widget_get_allocated_width (widget),
+ gtk_widget_get_allocated_height (widget));
+ g_object_unref (paintable);
+ node = gtk_snapshot_free_to_node (snapshot);
+ gsk_render_node_draw (node, cr);
cairo_destroy (cr);
g_main_loop_unref (loop);
@@ -305,5 +242,5 @@ reftest_snapshot_ui_file (const char *ui_file)
gtk_widget_show (window);
- return snapshot_widget (window, SNAPSHOT_WINDOW);
+ return snapshot_widget (window);
}
diff --git a/testsuite/reftests/set-default-direction.c b/testsuite/reftests/set-default-direction.c
index 638045db1d..468d3dc922 100644
--- a/testsuite/reftests/set-default-direction.c
+++ b/testsuite/reftests/set-default-direction.c
@@ -82,7 +82,7 @@ swap_child (GtkWidget *window)
gtk_container_remove (GTK_CONTAINER (window), gtk_bin_get_child (GTK_BIN (window)));
- image = gtk_image_new_from_icon_name ("go-next", GTK_ICON_SIZE_BUTTON);
+ image = gtk_image_new_from_icon_name ("go-next");
gtk_widget_show (image);
gtk_container_add (GTK_CONTAINER (window), image);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]