summaryrefslogtreecommitdiffstats
path: root/tests/auto/compositor/compositor/tst_compositor.cpp
diff options
context:
space:
mode:
authorJohan Klokkhammer Helsing <johan.helsing@qt.io>2016-04-20 10:41:20 +0200
committerJohan Helsing <johan.helsing@qt.io>2016-09-30 13:55:30 +0000
commitf7896fdc6505d8c6f3b3a239884dadab034e1fb5 (patch)
tree11f73dd52db4ecf33d5289b234f72500bd3c8a91 /tests/auto/compositor/compositor/tst_compositor.cpp
parent863bf669ed0b8fce782c177dfcfa1702fc28196a (diff)
C++ API and tests for the ivi-application extension
Note, this is only an implementation of the ivi-application extension, not ivi-controller which contains layer management interfaces. Task-number: QTBUG-53149 Change-Id: Ic5a31156de1768f846b714a9aee9bbf8a945cbbe 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.cpp154
1 files changed, 154 insertions, 0 deletions
diff --git a/tests/auto/compositor/compositor/tst_compositor.cpp b/tests/auto/compositor/compositor/tst_compositor.cpp
index d6c72b34..3052b7b4 100644
--- a/tests/auto/compositor/compositor/tst_compositor.cpp
+++ b/tests/auto/compositor/compositor/tst_compositor.cpp
@@ -36,9 +36,12 @@
#include "qwaylandseat.h"
#include <QtWaylandCompositor/QWaylandXdgShellV5>
+#include <QtWaylandCompositor/QWaylandIviApplication>
+#include <QtWaylandCompositor/QWaylandIviSurface>
#include <QtWaylandCompositor/QWaylandSurface>
#include <QtWaylandCompositor/QWaylandResource>
#include <qwayland-xdg-shell.h>
+#include <qwayland-ivi-application.h>
#include <QtTest/QtTest>
@@ -57,11 +60,18 @@ private slots:
void geometry();
void mapSurface();
void frameCallback();
+
void advertisesXdgShellSupport();
void createsXdgSurfaces();
void reportsXdgSurfaceWindowGeometry();
void setsXdgAppId();
void sendsXdgConfigure();
+
+ void advertisesIviApplicationSupport();
+ void createsIviSurfaces();
+ void emitsErrorOnSameIviId();
+ void sendsIviConfigure();
+ void destroysIviSurfaces();
};
void tst_WaylandCompositor::init() {
@@ -572,5 +582,149 @@ void tst_WaylandCompositor::sendsXdgConfigure()
QTRY_VERIFY(!xdgSurface->resizing());
}
+class IviTestCompositor: public TestCompositor {
+ Q_OBJECT
+public:
+ IviTestCompositor() : iviApplication(this) {}
+ QWaylandIviApplication iviApplication;
+};
+
+void tst_WaylandCompositor::advertisesIviApplicationSupport()
+{
+ IviTestCompositor compositor;
+ compositor.create();
+
+ MockClient client;
+ QTRY_VERIFY(&client.iviApplication);
+}
+
+void tst_WaylandCompositor::createsIviSurfaces()
+{
+ IviTestCompositor compositor;
+ compositor.create();
+
+ MockClient client;
+ QTRY_VERIFY(&client.iviApplication);
+
+ QSignalSpy iviSurfaceCreatedSpy(&compositor.iviApplication, &QWaylandIviApplication::iviSurfaceRequested);
+ QWaylandIviSurface *iviSurface = nullptr;
+ QObject::connect(&compositor.iviApplication, &QWaylandIviApplication::iviSurfaceCreated, [&](QWaylandIviSurface *s) {
+ iviSurface = s;
+ });
+
+ wl_surface *surface = client.createSurface();
+ client.createIviSurface(surface, 123);
+ QTRY_COMPARE(iviSurfaceCreatedSpy.count(), 1);
+ QTRY_VERIFY(iviSurface);
+ QTRY_VERIFY(iviSurface->surface());
+ QTRY_COMPARE(iviSurface->iviId(), 123u);
+}
+
+void tst_WaylandCompositor::emitsErrorOnSameIviId()
+{
+ IviTestCompositor compositor;
+ compositor.create();
+
+ {
+ MockClient firstClient;
+ QTRY_VERIFY(&firstClient.iviApplication);
+
+ QWaylandIviSurface *firstIviSurface = nullptr;
+ QObject::connect(&compositor.iviApplication, &QWaylandIviApplication::iviSurfaceCreated, [&](QWaylandIviSurface *s) {
+ firstIviSurface = s;
+ });
+
+ firstClient.createIviSurface(firstClient.createSurface(), 123);
+ QTRY_VERIFY(firstIviSurface);
+ QTRY_COMPARE(firstIviSurface->iviId(), 123u);
+
+ {
+ MockClient secondClient;
+ QTRY_VERIFY(&secondClient.iviApplication);
+ QTRY_COMPARE(compositor.clients().count(), 2);
+
+ secondClient.createIviSurface(secondClient.createSurface(), 123);
+ compositor.flushClients();
+
+ QTRY_COMPARE(secondClient.error, EPROTO);
+ QTRY_COMPARE(secondClient.protocolError.interface, &ivi_application_interface);
+ QTRY_COMPARE(static_cast<ivi_application_error>(secondClient.protocolError.code), IVI_APPLICATION_ERROR_IVI_ID);
+ QTRY_COMPARE(compositor.clients().count(), 1);
+ }
+ }
+
+ // The other clients have passed out of scope and have been destroyed,
+ // it should now be ok to create new application with the same id
+ MockClient thirdClient;
+ QTRY_VERIFY(&thirdClient.iviApplication);
+
+ QWaylandIviSurface *thirdIviSurface = nullptr;
+ QObject::connect(&compositor.iviApplication, &QWaylandIviApplication::iviSurfaceCreated, [&](QWaylandIviSurface *s) {
+ thirdIviSurface = s;
+ });
+ thirdClient.createIviSurface(thirdClient.createSurface(), 123);
+ compositor.flushClients();
+
+ QTRY_VERIFY(thirdIviSurface);
+ QTRY_COMPARE(thirdIviSurface->iviId(), 123u);
+ QTRY_COMPARE(thirdClient.error, 0);
+}
+
+void tst_WaylandCompositor::sendsIviConfigure()
+{
+ class MockIviSurface : public QtWayland::ivi_surface
+ {
+ public:
+ MockIviSurface(::ivi_surface *iviSurface) : QtWayland::ivi_surface(iviSurface) {}
+ void ivi_surface_configure(int32_t width, int32_t height) Q_DECL_OVERRIDE
+ {
+ configureSize = QSize(width, height);
+ }
+ QSize configureSize;
+ };
+
+ IviTestCompositor compositor;
+ compositor.create();
+
+ MockClient client;
+ QTRY_VERIFY(&client.iviApplication);
+
+ QWaylandIviSurface *iviSurface = nullptr;
+ QObject::connect(&compositor.iviApplication, &QWaylandIviApplication::iviSurfaceCreated, [&](QWaylandIviSurface *s) {
+ iviSurface = s;
+ });
+
+ wl_surface *surface = client.createSurface();
+ ivi_surface *clientIviSurface = client.createIviSurface(surface, 123);
+ MockIviSurface mockIviSurface(clientIviSurface);
+
+ QTRY_VERIFY(iviSurface);
+ iviSurface->sendConfigure(QSize(800, 600));
+ compositor.flushClients();
+
+ QTRY_COMPARE(mockIviSurface.configureSize, QSize(800, 600));
+}
+
+void tst_WaylandCompositor::destroysIviSurfaces()
+{
+ IviTestCompositor compositor;
+ compositor.create();
+
+ MockClient client;
+ QTRY_VERIFY(&client.iviApplication);
+
+ QWaylandIviSurface *iviSurface = nullptr;
+ QObject::connect(&compositor.iviApplication, &QWaylandIviApplication::iviSurfaceCreated, [&](QWaylandIviSurface *s) {
+ iviSurface = s;
+ });
+
+ QtWayland::ivi_surface mockIviSurface(client.createIviSurface(client.createSurface(), 123));
+ QTRY_VERIFY(iviSurface);
+
+ QSignalSpy destroySpy(iviSurface, SIGNAL(destroyed()));
+ mockIviSurface.destroy();
+ QTRY_VERIFY(destroySpy.count() == 1);
+}
+
#include <tst_compositor.moc>
QTEST_MAIN(tst_WaylandCompositor);