summaryrefslogtreecommitdiffstats
path: root/tests/auto/compositor/compositor/tst_compositor.cpp
diff options
context:
space:
mode:
authorPier Luigi Fiorini <pierluigi.fiorini@liri.io>2019-01-06 18:09:00 +0100
committerPier Luigi Fiorini <pierluigi.fiorini@liri.io>2019-08-16 10:13:34 +0200
commit3be538b89c82d580133aadcf1615311a49786761 (patch)
tree518d8f5c6db6cc46140c2222fcc3ec003b9e71a5 /tests/auto/compositor/compositor/tst_compositor.cpp
parente0115d9ccdbb541033b9ebc43c11fb4943becaff (diff)
Compositor: Add idle-inhibit unstable v1 protocol
Allows disabling of screen blanking on a per-surface basis. [ChangeLog][Compositor] Added support for idle-inhibit unstable v1 Wayland extension. Change-Id: I3cd392f9e1bb3604691f2a496579aad3b87383b6 Reviewed-by: Johan Helsing <johan.helsing@qt.io>
Diffstat (limited to 'tests/auto/compositor/compositor/tst_compositor.cpp')
-rw-r--r--tests/auto/compositor/compositor/tst_compositor.cpp39
1 files changed, 39 insertions, 0 deletions
diff --git a/tests/auto/compositor/compositor/tst_compositor.cpp b/tests/auto/compositor/compositor/tst_compositor.cpp
index da5acc27..4749d857 100644
--- a/tests/auto/compositor/compositor/tst_compositor.cpp
+++ b/tests/auto/compositor/compositor/tst_compositor.cpp
@@ -47,8 +47,10 @@
#include <QtWaylandCompositor/QWaylandResource>
#include <QtWaylandCompositor/QWaylandKeymap>
#include <QtWaylandCompositor/QWaylandViewporter>
+#include <QtWaylandCompositor/QWaylandIdleInhibitManagerV1>
#include <qwayland-xdg-shell.h>
#include <qwayland-ivi-application.h>
+#include <QtWaylandCompositor/private/qwaylandsurface_p.h>
#include <QtTest/QtTest>
@@ -111,6 +113,8 @@ private slots:
void viewportDestinationNoSurfaceError();
void viewportSourceNoSurfaceError();
void viewportHiDpi();
+
+ void idleInhibit();
};
void tst_WaylandCompositor::init() {
@@ -1716,5 +1720,40 @@ void tst_WaylandCompositor::viewportHiDpi()
wl_surface_destroy(surface);
}
+class IdleInhibitCompositor : public TestCompositor
+{
+ Q_OBJECT
+public:
+ IdleInhibitCompositor() : idleInhibitManager(this) {}
+ QWaylandIdleInhibitManagerV1 idleInhibitManager;
+};
+
+void tst_WaylandCompositor::idleInhibit()
+{
+ IdleInhibitCompositor compositor;
+ compositor.create();
+ MockClient client;
+ QTRY_VERIFY(client.idleInhibitManager);
+
+ auto *surface = client.createSurface();
+ QVERIFY(surface);
+ QTRY_COMPARE(compositor.surfaces.size(), 1);
+
+ QWaylandSurface *waylandSurface = compositor.surfaces.at(0);
+ auto *waylandSurfacePrivate =
+ QWaylandSurfacePrivate::get(waylandSurface);
+ QVERIFY(waylandSurfacePrivate);
+
+ QSignalSpy changedSpy(waylandSurface, SIGNAL(inhibitsIdleChanged()));
+
+ QCOMPARE(waylandSurface->inhibitsIdle(), false);
+
+ auto *idleInhibitor = client.createIdleInhibitor(surface);
+ QVERIFY(idleInhibitor);
+ QTRY_COMPARE(waylandSurfacePrivate->idleInhibitors.size(), 1);
+ QCOMPARE(waylandSurface->inhibitsIdle(), true);
+ QTRY_COMPARE(changedSpy.count(), 1);
+}
+
#include <tst_compositor.moc>
QTEST_MAIN(tst_WaylandCompositor);