[weston,1/2] shot: add test for sub-surface with unmapped parent

Submitted by Emilio Pozuelo Monfort on July 9, 2018, 3:24 p.m.

Details

Message ID 20180709152459.21057-2-emilio.pozuelo@collabora.co.uk
State New
Series "Series without cover letter"
Headers show

Commit Message

Emilio Pozuelo Monfort July 9, 2018, 3:24 p.m.
This reproduces https://bugs.freedesktop.org/show_bug.cgi?id=94735.

Signed-off-by: Emilio Pozuelo Monfort <emilio.pozuelo@collabora.co.uk>
---
 tests/reference/subsurface_mapped-00.png | Bin 0 -> 799 bytes
 tests/reference/subsurface_mapped-01.png | Bin 0 -> 841 bytes
 tests/subsurface-shot-test.c             |  76 +++++++++++++++++++++++
 3 files changed, 76 insertions(+)
 create mode 100644 tests/reference/subsurface_mapped-00.png
 create mode 100644 tests/reference/subsurface_mapped-01.png

Patch hide | download patch | download mbox

diff --git a/tests/reference/subsurface_mapped-00.png b/tests/reference/subsurface_mapped-00.png
new file mode 100644
index 0000000000000000000000000000000000000000..32cf32a0ed11d38b9028eda29109e06c99dce000
GIT binary patch
literal 799
zcmeAS@N?(olHy`uVBq!ia0y~yU~~YoKX5Ps$$$P@Hb9Ck$=lt9;Xep2*t>i(0|V0)
zPZ!6KiaBpDJMtb-U^sBV(DcSZzE>X)w43Y<zTkg6<~Q@Kf7clg*fKlMXjD9NKp-uF
u!`PrjQsNK~Pa<2J!Km<Pm<+lE!M8n->GIc&-r>L$&*16m=d#Wzp$P!YDfm(V

literal 0
HcmV?d00001

diff --git a/tests/reference/subsurface_mapped-01.png b/tests/reference/subsurface_mapped-01.png
new file mode 100644
index 0000000000000000000000000000000000000000..4e7196a2229a2e63adbf49d32a8c47db043f1c1c
GIT binary patch
literal 841
zcmeAS@N?(olHy`uVBq!ia0y~yU~~YoKX5Ps$$$P@Hb9Ck$=lt9;Xep2*t>i(0|V1P
zPZ!6KiaBquZsa}Wz`){YUu2kf{Oyc6Wg6{8K0QxPoXkGz!#aIUUe52048Hw0nHzqy
z@FX&|88AA}Xi)SyAfT4OA#BjXDRF32cth#8hDqmtn^qrc-8g5ndd!V)&);y?A7max
zA$7y5+Tmoxxtqcd+SvzD9B$b7_V^p#1HN)}PDa0(vIRL#J}^{z1<V@^p00i_>zopr
E02fd6egFUf

literal 0
HcmV?d00001

diff --git a/tests/subsurface-shot-test.c b/tests/subsurface-shot-test.c
index e8bab676..53c54578 100644
--- a/tests/subsurface-shot-test.c
+++ b/tests/subsurface-shot-test.c
@@ -261,3 +261,79 @@  TEST(subsurface_z_order)
 		if (bufs[i])
 			buffer_destroy(bufs[i]);
 }
+
+TEST(subsurface_mapped)
+{
+	const char *test_name = get_test_name();
+	struct client *client;
+	struct wl_surface *surface;
+	struct rectangle clip;
+	int fail = 0;
+	struct wl_subcompositor *subco;
+	struct wl_surface *child;
+	struct wl_subsurface *sub;
+	struct buffer *buf, *child_buf;
+	pixman_color_t red, blue;
+
+	color(&red, 255, 0, 0);
+	color(&blue, 0, 0, 255);
+
+	/* Create the client */
+	client = create_client();
+	assert(client);
+	client->surface = create_test_surface(client);
+	surface = client->surface->wl_surface;
+
+	/* move the pointer clearly away from our screenshooting area */
+	weston_test_move_pointer(client->test->weston_test, 0, 1, 0, 2, 30);
+
+	client->surface->x = 100;
+	client->surface->y = 100;
+	weston_test_move_surface(client->test->weston_test, client->surface->wl_surface,
+				 client->surface->x, client->surface->y);
+
+	wl_surface_set_buffer_scale(surface, 1);
+	wl_surface_set_buffer_transform(surface, WL_OUTPUT_TRANSFORM_NORMAL);
+
+	wl_surface_commit(surface);
+
+	clip.x = 100;
+	clip.y = 100;
+	clip.width = 100;
+	clip.height = 100;
+	printf("Clip: %d,%d %d x %d\n", clip.x, clip.y, clip.width, clip.height);
+
+	/* create a wl_surface */
+	subco = get_subcompositor(client);
+	assert(subco);
+
+	child = wl_compositor_create_surface(client->wl_compositor);
+	assert(child);
+
+	/* make it a sub-surface */
+	sub = wl_subcompositor_get_subsurface(subco, child, surface);
+	assert(sub);
+
+	wl_subsurface_set_desync(sub);
+
+	/* give it content */
+	child_buf = surface_commit_color(client, child, &red, 50, 50);
+
+	/* verify that the sub-surface is not mapped */
+	fail += check_screen(client, test_name, 0, &clip, 0);
+
+	/* give a buffer to the parent surface and make sure both the
+	 * parent and the child get mapped */
+	buf = surface_commit_color(client, surface, &blue, 100, 100);
+
+	fail += check_screen(client, test_name, 1, &clip, 1);
+
+	printf("Test complete\n");
+	assert(fail == 0);
+
+	wl_subsurface_destroy(sub);
+	wl_surface_destroy(child);
+	buffer_destroy(child_buf);
+	wl_surface_destroy(surface);
+	buffer_destroy(buf);
+}