summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorJohan Klokkhammer Helsing <johan.helsing@qt.io>2017-08-28 16:05:43 +0200
committerJohan Helsing <johan.helsing@qt.io>2017-11-15 14:54:30 +0000
commit53c5a267b225c7492ac2ce0ba828d4de18ec59cc (patch)
treea6cbca2d8b76eba2a9528c4587cf5b6a41b51073 /tests
parent69d587b9a8e336cff4356c49e4f37aae2a474a4f (diff)
downloadqtwayland-53c5a267b225c7492ac2ce0ba828d4de18ec59cc.tar.gz
Verify that the client supports the compositor removing outputs
Change-Id: I799d29fa43ad429b7973d7a210aca554d6b0ce26 Reviewed-by: Pier Luigi Fiorini <pierluigi.fiorini@liri.io>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/client/client/tst_client.cpp16
-rw-r--r--tests/auto/client/shared/mockcompositor.cpp7
-rw-r--r--tests/auto/client/shared/mockcompositor.h2
-rw-r--r--tests/auto/client/shared/mockoutput.cpp10
4 files changed, 35 insertions, 0 deletions
diff --git a/tests/auto/client/client/tst_client.cpp b/tests/auto/client/client/tst_client.cpp
index b4dc7513..e02aa9f8 100644
--- a/tests/auto/client/client/tst_client.cpp
+++ b/tests/auto/client/client/tst_client.cpp
@@ -138,6 +138,7 @@ public slots:
private slots:
void primaryScreen();
+ void screens();
void windowScreens();
void createDestroyWindow();
void events();
@@ -158,6 +159,17 @@ void tst_WaylandClient::primaryScreen()
QTRY_COMPARE(QGuiApplication::primaryScreen()->size(), screenSize);
}
+void tst_WaylandClient::screens()
+{
+ QTRY_COMPARE(QGuiApplication::screens().size(), 1);
+ compositor->sendAddOutput();
+ QTRY_COMPARE(QGuiApplication::screens().size(), 2);
+ QSharedPointer<MockOutput> secondOutput;
+ QTRY_VERIFY(secondOutput = compositor->output(1));
+ compositor->sendRemoveOutput(secondOutput);
+ QTRY_COMPARE(QGuiApplication::screens().size(), 1);
+}
+
void tst_WaylandClient::windowScreens()
{
QSharedPointer<MockOutput> firstOutput;
@@ -191,6 +203,10 @@ void tst_WaylandClient::windowScreens()
compositor->sendSurfaceLeave(surface, firstOutput);
QTRY_COMPARE(window.screen(), secondaryScreen);
+ compositor->sendRemoveOutput(secondOutput);
+ QTRY_COMPARE(QGuiApplication::screens().size(), 1);
+ QCOMPARE(window.screen(), primaryScreen);
+
window.destroy();
QTRY_VERIFY(!compositor->surface());
}
diff --git a/tests/auto/client/shared/mockcompositor.cpp b/tests/auto/client/shared/mockcompositor.cpp
index 67c05b90..e7c6e90d 100644
--- a/tests/auto/client/shared/mockcompositor.cpp
+++ b/tests/auto/client/shared/mockcompositor.cpp
@@ -189,6 +189,13 @@ void MockCompositor::sendAddOutput()
processCommand(command);
}
+void MockCompositor::sendRemoveOutput(const QSharedPointer<MockOutput> &output)
+{
+ Command command = makeCommand(Impl::Compositor::sendRemoveOutput, m_compositor);
+ command.parameters << QVariant::fromValue(output);
+ processCommand(command);
+}
+
void MockCompositor::sendSurfaceEnter(const QSharedPointer<MockSurface> &surface, QSharedPointer<MockOutput> &output)
{
Command command = makeCommand(Impl::Compositor::sendSurfaceEnter, m_compositor);
diff --git a/tests/auto/client/shared/mockcompositor.h b/tests/auto/client/shared/mockcompositor.h
index 54706bd8..9258b192 100644
--- a/tests/auto/client/shared/mockcompositor.h
+++ b/tests/auto/client/shared/mockcompositor.h
@@ -88,6 +88,7 @@ public:
static void waitForStartDrag(void *data, const QList<QVariant> &parameters);
static void setOutputMode(void *compositor, const QList<QVariant> &parameters);
static void sendAddOutput(void *data, const QList<QVariant> &parameters);
+ static void sendRemoveOutput(void *data, const QList<QVariant> &parameters);
static void sendSurfaceEnter(void *data, const QList<QVariant> &parameters);
static void sendSurfaceLeave(void *data, const QList<QVariant> &parameters);
@@ -179,6 +180,7 @@ public:
void sendDataDeviceDrop(const QSharedPointer<MockSurface> &surface);
void sendDataDeviceLeave(const QSharedPointer<MockSurface> &surface);
void sendAddOutput();
+ void sendRemoveOutput(const QSharedPointer<MockOutput> &output);
void sendSurfaceEnter(const QSharedPointer<MockSurface> &surface, QSharedPointer<MockOutput> &output);
void sendSurfaceLeave(const QSharedPointer<MockSurface> &surface, QSharedPointer<MockOutput> &output);
void waitForStartDrag();
diff --git a/tests/auto/client/shared/mockoutput.cpp b/tests/auto/client/shared/mockoutput.cpp
index de8e019a..7d7b7413 100644
--- a/tests/auto/client/shared/mockoutput.cpp
+++ b/tests/auto/client/shared/mockoutput.cpp
@@ -44,6 +44,16 @@ void Compositor::sendAddOutput(void *data, const QList<QVariant> &parameters) {
compositor->dispatchEvents();
}
+void Compositor::sendRemoveOutput(void *data, const QList<QVariant> &parameters) {
+ Compositor *compositor = static_cast<Compositor *>(data);
+ Q_ASSERT(compositor);
+ Output *output = resolveOutput(parameters.first());
+ Q_ASSERT(output);
+ bool wasRemoved = compositor->m_outputs.removeOne(output);
+ Q_ASSERT(wasRemoved);
+ delete output;
+}
+
void Compositor::setOutputMode(void *data, const QList<QVariant> &parameters)
{
Compositor *compositor = static_cast<Compositor *>(data);