summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorDaniel Stone <daniels@collabora.com>2016-11-22 12:40:34 +0000
committerDaniel Stone <daniels@collabora.com>2016-11-23 10:17:43 +0000
commit998340046535aee0949e0678b329b0034fd0de1a (patch)
tree0b81210ca027bff2746fa199ff6f5b47ccbfe956 /tests
parent9f3d95e0d7e3c6453ddf149c1b62439c70d80ddf (diff)
tests: Extend subsurface place_{above,below} hierarchy
Following on from b8c16c995b, extend the family tree being tested by place_above and place_below a little, ensuring that subsurfaces can't be placed above or below surfaces which are related to them, but aren't their immediate parent or sibling. Signed-off-by: Daniel Stone <daniels@collabora.com> Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Diffstat (limited to 'tests')
-rw-r--r--tests/subsurface-test.c142
1 files changed, 142 insertions, 0 deletions
diff --git a/tests/subsurface-test.c b/tests/subsurface-test.c
index 03ff5392..edb08422 100644
--- a/tests/subsurface-test.c
+++ b/tests/subsurface-test.c
@@ -272,6 +272,77 @@ TEST(test_subsurface_place_above_nested_parent)
client_roundtrip(client);
}
+TEST(test_subsurface_place_above_grandparent)
+{
+ struct client *client;
+ struct compound_surface com;
+ struct wl_surface *grandchild;
+ struct wl_subsurface *sub;
+ struct wl_subcompositor *subco;
+
+ client = create_client_and_test_surface(100, 50, 123, 77);
+ assert(client);
+
+ populate_compound_surface(&com, client);
+
+ subco = get_subcompositor(client);
+ grandchild = wl_compositor_create_surface(client->wl_compositor);
+ sub = wl_subcompositor_get_subsurface(subco, grandchild, com.child[0]);
+
+ /* can't place a subsurface above its grandparent */
+ wl_subsurface_place_above(sub, com.parent);
+
+ expect_protocol_error(client, &wl_subsurface_interface,
+ WL_SUBSURFACE_ERROR_BAD_SURFACE);
+}
+
+TEST(test_subsurface_place_above_great_aunt)
+{
+ struct client *client;
+ struct compound_surface com;
+ struct wl_surface *grandchild;
+ struct wl_subsurface *sub;
+ struct wl_subcompositor *subco;
+
+ client = create_client_and_test_surface(100, 50, 123, 77);
+ assert(client);
+
+ populate_compound_surface(&com, client);
+
+ subco = get_subcompositor(client);
+ grandchild = wl_compositor_create_surface(client->wl_compositor);
+ sub = wl_subcompositor_get_subsurface(subco, grandchild, com.child[0]);
+
+ /* can't place a subsurface above its parents' siblings */
+ wl_subsurface_place_above(sub, com.child[1]);
+
+ expect_protocol_error(client, &wl_subsurface_interface,
+ WL_SUBSURFACE_ERROR_BAD_SURFACE);
+}
+
+TEST(test_subsurface_place_above_child)
+{
+ struct client *client;
+ struct compound_surface com;
+ struct wl_surface *grandchild;
+ struct wl_subcompositor *subco;
+
+ client = create_client_and_test_surface(100, 50, 123, 77);
+ assert(client);
+
+ populate_compound_surface(&com, client);
+
+ subco = get_subcompositor(client);
+ grandchild = wl_compositor_create_surface(client->wl_compositor);
+ wl_subcompositor_get_subsurface(subco, grandchild, com.child[0]);
+
+ /* can't place a subsurface above its own child subsurface */
+ wl_subsurface_place_above(com.sub[0], grandchild);
+
+ expect_protocol_error(client, &wl_subsurface_interface,
+ WL_SUBSURFACE_ERROR_BAD_SURFACE);
+}
+
TEST(test_subsurface_place_below_nested_parent)
{
struct client *client;
@@ -294,6 +365,77 @@ TEST(test_subsurface_place_below_nested_parent)
client_roundtrip(client);
}
+TEST(test_subsurface_place_below_grandparent)
+{
+ struct client *client;
+ struct compound_surface com;
+ struct wl_surface *grandchild;
+ struct wl_subsurface *sub;
+ struct wl_subcompositor *subco;
+
+ client = create_client_and_test_surface(100, 50, 123, 77);
+ assert(client);
+
+ populate_compound_surface(&com, client);
+
+ subco = get_subcompositor(client);
+ grandchild = wl_compositor_create_surface(client->wl_compositor);
+ sub = wl_subcompositor_get_subsurface(subco, grandchild, com.child[0]);
+
+ /* can't place a subsurface below its grandparent */
+ wl_subsurface_place_below(sub, com.parent);
+
+ expect_protocol_error(client, &wl_subsurface_interface,
+ WL_SUBSURFACE_ERROR_BAD_SURFACE);
+}
+
+TEST(test_subsurface_place_below_great_aunt)
+{
+ struct client *client;
+ struct compound_surface com;
+ struct wl_surface *grandchild;
+ struct wl_subsurface *sub;
+ struct wl_subcompositor *subco;
+
+ client = create_client_and_test_surface(100, 50, 123, 77);
+ assert(client);
+
+ populate_compound_surface(&com, client);
+
+ subco = get_subcompositor(client);
+ grandchild = wl_compositor_create_surface(client->wl_compositor);
+ sub = wl_subcompositor_get_subsurface(subco, grandchild, com.child[0]);
+
+ /* can't place a subsurface below its parents' siblings */
+ wl_subsurface_place_below(sub, com.child[1]);
+
+ expect_protocol_error(client, &wl_subsurface_interface,
+ WL_SUBSURFACE_ERROR_BAD_SURFACE);
+}
+
+TEST(test_subsurface_place_below_child)
+{
+ struct client *client;
+ struct compound_surface com;
+ struct wl_surface *grandchild;
+ struct wl_subcompositor *subco;
+
+ client = create_client_and_test_surface(100, 50, 123, 77);
+ assert(client);
+
+ populate_compound_surface(&com, client);
+
+ subco = get_subcompositor(client);
+ grandchild = wl_compositor_create_surface(client->wl_compositor);
+ wl_subcompositor_get_subsurface(subco, grandchild, com.child[0]);
+
+ /* can't place a subsurface below its own child subsurface */
+ wl_subsurface_place_below(com.sub[0], grandchild);
+
+ expect_protocol_error(client, &wl_subsurface_interface,
+ WL_SUBSURFACE_ERROR_BAD_SURFACE);
+}
+
TEST(test_subsurface_place_above_stranger)
{
struct client *client;