summaryrefslogtreecommitdiffstats
path: root/tests/auto/client/client/tst_client.cpp
diff options
context:
space:
mode:
authorJohan Klokkhammer Helsing <johan.helsing@qt.io>2017-08-18 17:28:01 +0200
committerJohan Helsing <johan.helsing@qt.io>2017-11-15 08:34:27 +0000
commit69d587b9a8e336cff4356c49e4f37aae2a474a4f (patch)
treecd53978cb4c7ea0b8933034e04b600d0f41e3c41 /tests/auto/client/client/tst_client.cpp
parent9cf680f94b78baf1bb92051021ebc243dec1f02e (diff)
Client: Test that the current screen is updated by surface events
Change-Id: If96691a2d844263a1e01a86df8b0d58f23848a4c Reviewed-by: Pier Luigi Fiorini <pierluigi.fiorini@liri.io>
Diffstat (limited to 'tests/auto/client/client/tst_client.cpp')
-rw-r--r--tests/auto/client/client/tst_client.cpp45
1 files changed, 42 insertions, 3 deletions
diff --git a/tests/auto/client/client/tst_client.cpp b/tests/auto/client/client/tst_client.cpp
index f337e6b4a..b4dc75131 100644
--- a/tests/auto/client/client/tst_client.cpp
+++ b/tests/auto/client/client/tst_client.cpp
@@ -137,7 +137,8 @@ public slots:
}
private slots:
- void screen();
+ void primaryScreen();
+ void windowScreens();
void createDestroyWindow();
void events();
void backingStore();
@@ -151,11 +152,49 @@ private:
MockCompositor *compositor;
};
-void tst_WaylandClient::screen()
+void tst_WaylandClient::primaryScreen()
{
+ compositor->setOutputMode(screenSize);
QTRY_COMPARE(QGuiApplication::primaryScreen()->size(), screenSize);
}
+void tst_WaylandClient::windowScreens()
+{
+ QSharedPointer<MockOutput> firstOutput;
+ QTRY_VERIFY(firstOutput = compositor->output());
+
+ TestWindow window;
+ window.show();
+
+ QSharedPointer<MockSurface> 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);
+
+ window.setScreen(secondaryScreen);
+ QCOMPARE(window.screen(), secondaryScreen);
+
+ QSharedPointer<MockOutput> secondOutput;
+ QTRY_VERIFY(secondOutput = compositor->output(1));
+ compositor->sendSurfaceEnter(surface, firstOutput);
+
+ compositor->sendSurfaceEnter(surface, secondOutput);
+ QTRY_COMPARE(window.screen(), primaryScreen);
+
+ compositor->sendSurfaceLeave(surface, firstOutput);
+ QTRY_COMPARE(window.screen(), secondaryScreen);
+
+ window.destroy();
+ QTRY_VERIFY(!compositor->surface());
+}
+
void tst_WaylandClient::createDestroyWindow()
{
TestWindow window;
@@ -417,7 +456,7 @@ int main(int argc, char **argv)
setenv("QT_WAYLAND_DISABLE_WINDOWDECORATION", "1", 1);
MockCompositor compositor;
- compositor.setOutputGeometry(QRect(QPoint(), screenSize));
+ compositor.setOutputMode(screenSize);
QGuiApplication app(argc, argv);
compositor.applicationInitialized();