diff options
-rw-r--r-- | tests/auto/client/client/tst_client.cpp | 16 | ||||
-rw-r--r-- | tests/auto/client/shared/mockcompositor.cpp | 7 | ||||
-rw-r--r-- | tests/auto/client/shared/mockcompositor.h | 2 | ||||
-rw-r--r-- | tests/auto/client/shared/mockoutput.cpp | 10 |
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> ¶meters); static void setOutputMode(void *compositor, const QList<QVariant> ¶meters); static void sendAddOutput(void *data, const QList<QVariant> ¶meters); + static void sendRemoveOutput(void *data, const QList<QVariant> ¶meters); static void sendSurfaceEnter(void *data, const QList<QVariant> ¶meters); static void sendSurfaceLeave(void *data, const QList<QVariant> ¶meters); @@ -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> ¶meters) { compositor->dispatchEvents(); } +void Compositor::sendRemoveOutput(void *data, const QList<QVariant> ¶meters) { + 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> ¶meters) { Compositor *compositor = static_cast<Compositor *>(data); |