summaryrefslogtreecommitdiffstats
path: root/tests/auto/compositor/compositor/tst_compositor.cpp
diff options
context:
space:
mode:
authorJohan Klokkhammer Helsing <johan.helsing@qt.io>2018-09-25 16:28:10 +0200
committerJohan Helsing <johan.helsing@qt.io>2018-09-26 06:31:51 +0000
commit73edf04050b70093ad3dbf664dbdaa42ddf0bfda (patch)
tree03b47d0a5a8c0ca65149a201feaef2413e09e9be /tests/auto/compositor/compositor/tst_compositor.cpp
parent582af70640e411d8f423f1bc0528d5a5fce08e3a (diff)
Compositor: Add test for wl_surface::set_input_region
Change-Id: I9b110647c054c897fa2a6d6fc6f392c981845f09 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.cpp35
1 files changed, 35 insertions, 0 deletions
diff --git a/tests/auto/compositor/compositor/tst_compositor.cpp b/tests/auto/compositor/compositor/tst_compositor.cpp
index e3c4dacc..abad9b0d 100644
--- a/tests/auto/compositor/compositor/tst_compositor.cpp
+++ b/tests/auto/compositor/compositor/tst_compositor.cpp
@@ -67,6 +67,7 @@ private slots:
void seatCreation();
void seatKeyboardFocus();
void seatMouseFocus();
+ void inputRegion();
void singleClient();
void multipleClients();
void geometry();
@@ -650,6 +651,40 @@ void tst_WaylandCompositor::seatMouseFocus()
delete view;
}
+void tst_WaylandCompositor::inputRegion()
+{
+ TestCompositor compositor(true);
+ compositor.create();
+
+ // Create client after all the seats have been set up as the mock client
+ // does not dynamically listen to new seats
+ MockClient client;
+ wl_surface *surface = client.createSurface();
+
+ // We need to attach a buffer, since QWaylandSurface::inputRegionContains will will return
+ // false for coordinates outside the buffer (so don't let it be 0x0).
+ QSize size(16, 16);
+ 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);
+ wl_surface_commit(surface);
+
+ QTRY_COMPARE(compositor.surfaces.size(), 1);
+ QWaylandSurface *waylandSurface = compositor.surfaces.at(0);
+
+ QVERIFY(waylandSurface->inputRegionContains(QPoint(1, 2)));
+ QVERIFY(waylandSurface->inputRegionContains(QPoint(3, 5)));
+ QVERIFY(!waylandSurface->inputRegionContains(QPoint(0, 0)));
+ QVERIFY(!waylandSurface->inputRegionContains(QPoint(1, 6)));
+ QVERIFY(!waylandSurface->inputRegionContains(QPoint(4, 2)));
+}
+
class XdgTestCompositor: public TestCompositor {
Q_OBJECT
public: