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>
dev
Daniel Stone 8 years ago
parent 9f3d95e0d7
commit 9983400465
  1. 142
      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;

Loading…
Cancel
Save