[PATCH weston 3/3] tests: fix the cursor race in internal-screenshot
Pekka Paalanen
ppaalanen at gmail.com
Thu Jun 16 10:36:17 UTC 2016
From: Pekka Paalanen <pekka.paalanen at collabora.co.uk>
This fix also depends on "compositor-headless: do not create a seat".
If we lose the race against weston-desktop-shell setting cursors, which
is very rare, we get a cursor image in the screenshot, causing the test
to fail. This is now fixed by moving the (remaining) cursor out of the
way.
Arguably we should have better solutions for this, but that is another
story. This is a stop-gap measure we can copy also in new
screenshooting tests.
Code and explanation on how to lose the race for sure are included.
Signed-off-by: Pekka Paalanen <pekka.paalanen at collabora.co.uk>
---
tests/internal-screenshot-test.c | 27 +++++++++++++++++++++++++++
1 file changed, 27 insertions(+)
diff --git a/tests/internal-screenshot-test.c b/tests/internal-screenshot-test.c
index 563aa3d..e022d20 100644
--- a/tests/internal-screenshot-test.c
+++ b/tests/internal-screenshot-test.c
@@ -26,6 +26,7 @@
#include "config.h"
#include <stdio.h>
+#include <time.h>
#include "weston-test-client-helper.h"
@@ -48,6 +49,27 @@ draw_stuff(void *pixels, int w, int h)
}
}
+/*
+ * We are racing our screenshooting against weston-desktop-shell setting the
+ * cursor. If w-d-s wins, our screenshot will have a cursor shown, which makes
+ * the image comparison fail. Our window and the default pointer position are
+ * accidentally causing an overlap that intersects our test clip rectangle.
+ *
+ * This delay, if enabled, ensures this test loses that race.
+ *
+ * To actually see the failure, comment out the workaround call to
+ * weston_test_move_pointer() below.
+ */
+static void
+lose_the_race(void)
+{
+#if 0
+ struct timespec delay = { .tv_sec = 0, .tv_nsec = 100 * 1000 * 1000 };
+
+ nanosleep(&delay, NULL);
+#endif
+}
+
TEST(internal_screenshot)
{
struct wl_buffer *buf;
@@ -62,12 +84,17 @@ TEST(internal_screenshot)
bool dump_all_images = true;
void *pixels;
+ lose_the_race();
+
/* Create the client */
printf("Creating client for test\n");
client = create_client_and_test_surface(100, 100, 100, 100);
assert(client);
surface = client->surface->wl_surface;
+ /* Move the pointer away from the screenshot area. */
+ weston_test_move_pointer(client->test->weston_test, 0, 0);
+
buf = create_shm_buffer(client, 100, 100, &pixels);
draw_stuff(pixels, 100, 100);
wl_surface_attach(surface, buf, 0, 0);
--
2.7.3
More information about the wayland-devel
mailing list