summaryrefslogtreecommitdiffstats
path: root/tests/auto/compositor/compositor/tst_compositor.cpp
diff options
context:
space:
mode:
authorJohan Klokkhammer Helsing <johan.helsing@qt.io>2018-09-26 08:45:05 +0200
committerJohan Helsing <johan.helsing@qt.io>2018-09-26 13:03:41 +0000
commitb1ae478a754435a545877fa075ad9fd19ba6f5a0 (patch)
tree4dbce1790ed3f89e536f94b76ca1f22bbba88d9c /tests/auto/compositor/compositor/tst_compositor.cpp
parenteddf343b3d2bd0c9b19cafc5e055f415a09592c6 (diff)
Compositor: Test empty and nullptr input regions
Change-Id: Iddcf6cbddd74dc41d8c14b1da06f7e320de774b4 Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
Diffstat (limited to 'tests/auto/compositor/compositor/tst_compositor.cpp')
-rw-r--r--tests/auto/compositor/compositor/tst_compositor.cpp23
1 files changed, 22 insertions, 1 deletions
diff --git a/tests/auto/compositor/compositor/tst_compositor.cpp b/tests/auto/compositor/compositor/tst_compositor.cpp
index abad9b0d..c7661e8d 100644
--- a/tests/auto/compositor/compositor/tst_compositor.cpp
+++ b/tests/auto/compositor/compositor/tst_compositor.cpp
@@ -667,12 +667,13 @@ void tst_WaylandCompositor::inputRegion()
ShmBuffer buffer(size, client.shm);
wl_surface_attach(surface, buffer.handle, 0, 0);
wl_surface_damage(surface, 0, 0, size.width(), size.height());
- wl_surface_commit(surface);
// Set the input region
wl_region *region = wl_compositor_create_region(client.compositor);
wl_region_add(region, 1, 2, 3, 4);
wl_surface_set_input_region(surface, region);
+
+ // Commit everything
wl_surface_commit(surface);
QTRY_COMPARE(compositor.surfaces.size(), 1);
@@ -683,6 +684,26 @@ void tst_WaylandCompositor::inputRegion()
QVERIFY(!waylandSurface->inputRegionContains(QPoint(0, 0)));
QVERIFY(!waylandSurface->inputRegionContains(QPoint(1, 6)));
QVERIFY(!waylandSurface->inputRegionContains(QPoint(4, 2)));
+
+ // Setting a nullptr input region means we want all events
+ wl_surface_set_input_region(surface, nullptr);
+ wl_surface_commit(surface);
+
+ QTRY_VERIFY(waylandSurface->inputRegionContains(QPoint(0, 0)));
+ QVERIFY(waylandSurface->inputRegionContains(QPoint(1, 6)));
+ QVERIFY(waylandSurface->inputRegionContains(QPoint(4, 2)));
+
+ // But points outside the buffer should still return false
+ QVERIFY(!waylandSurface->inputRegionContains(QPoint(-1, -1)));
+ QVERIFY(!waylandSurface->inputRegionContains(QPoint(16, 16)));
+
+ // Setting an empty region means we want no events
+ wl_region *emptyRegion = wl_compositor_create_region(client.compositor);
+ wl_surface_set_input_region(surface, emptyRegion);
+ wl_surface_commit(surface);
+
+ QTRY_VERIFY(!waylandSurface->inputRegionContains(QPoint(0, 0)));
+ QVERIFY(!waylandSurface->inputRegionContains(QPoint(1, 2)));
}
class XdgTestCompositor: public TestCompositor {