From a5c79599c8d3f6306697743e2f6186fd600c142d Mon Sep 17 00:00:00 2001 From: Johan Klokkhammer Helsing Date: Tue, 29 Aug 2017 14:40:05 +0200 Subject: [PATCH] Client: Add removePrimaryScreen test Test that removing the primary screen will not crash the application. Task-number: QTBUG-62044 Change-Id: I8ba870e1d608629318ef897f88a6cc0d6e6aa85e Reviewed-by: Pier Luigi Fiorini --- tests/auto/wayland/client/tst_client.cpp | 33 ++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/tests/auto/wayland/client/tst_client.cpp b/tests/auto/wayland/client/tst_client.cpp index e02aa9f8f32..3cf19546fd3 100644 --- a/tests/auto/wayland/client/tst_client.cpp +++ b/tests/auto/wayland/client/tst_client.cpp @@ -140,6 +140,7 @@ private slots: void primaryScreen(); void screens(); void windowScreens(); + void removePrimaryScreen(); void createDestroyWindow(); void events(); void backingStore(); @@ -211,6 +212,38 @@ void tst_WaylandClient::windowScreens() QTRY_VERIFY(!compositor->surface()); } +void tst_WaylandClient::removePrimaryScreen() +{ + QSharedPointer firstOutput; + QTRY_VERIFY(firstOutput = compositor->output()); + + TestWindow window; + window.show(); + + QSharedPointer surface; + QTRY_VERIFY(surface = compositor->surface()); + QTRY_COMPARE(QGuiApplication::screens().size(), 1); + QScreen *primaryScreen = QGuiApplication::screens().first(); + QCOMPARE(window.screen(), primaryScreen); + + compositor->sendAddOutput(); + + QTRY_COMPARE(QGuiApplication::screens().size(), 2); + QScreen *secondaryScreen = QGuiApplication::screens().at(1); + QVERIFY(secondaryScreen); + + compositor->sendRemoveOutput(firstOutput); + QTRY_COMPARE(QGuiApplication::screens().size(), 1); + + compositor->sendMousePress(surface, QPoint(10, 10)); + QTRY_COMPARE(window.mousePressEventCount, 1); + compositor->sendMouseRelease(surface); + QTRY_COMPARE(window.mouseReleaseEventCount, 1); + + window.destroy(); + QTRY_VERIFY(!compositor->surface()); +} + void tst_WaylandClient::createDestroyWindow() { TestWindow window;