summaryrefslogtreecommitdiffstats
path: root/tests/auto/client/xdgoutput/tst_xdgoutput.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/client/xdgoutput/tst_xdgoutput.cpp')
-rw-r--r--tests/auto/client/xdgoutput/tst_xdgoutput.cpp83
1 files changed, 46 insertions, 37 deletions
diff --git a/tests/auto/client/xdgoutput/tst_xdgoutput.cpp b/tests/auto/client/xdgoutput/tst_xdgoutput.cpp
index 0e5b2c878..d021e3883 100644
--- a/tests/auto/client/xdgoutput/tst_xdgoutput.cpp
+++ b/tests/auto/client/xdgoutput/tst_xdgoutput.cpp
@@ -1,35 +1,9 @@
-/****************************************************************************
-**
-** Copyright (C) 2018 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2018 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include "xdgoutputv1.h"
#include "mockcompositor.h"
-#include <QtOpenGL/QOpenGLWindow>
#include <QtGui/QRasterWindow>
#include <QtGui/QScreen>
@@ -55,6 +29,7 @@ private slots:
void primaryScreen();
void overrideGeometry();
void changeGeometry();
+ void outputCreateEnterRace();
};
void tst_xdgoutput::cleanup()
@@ -68,7 +43,7 @@ void tst_xdgoutput::primaryScreen()
{
// Verify that the client has bound to the global
QCOMPOSITOR_TRY_COMPARE(get<XdgOutputManagerV1>()->resourceMap().size(), 1);
- exec([=] {
+ exec([&] {
auto *resource = xdgOutput()->resourceMap().value(client());
QCOMPARE(resource->version(), 3);
QCOMPARE(xdgOutput()->m_logicalGeometry.size(), QSize(1920, 1080));
@@ -81,7 +56,7 @@ void tst_xdgoutput::primaryScreen()
void tst_xdgoutput::overrideGeometry()
{
- exec([=] {
+ exec([&] {
auto *output = add<Output>();
auto *xdgOutput = get<XdgOutputManagerV1>()->getXdgOutput(output);
xdgOutput->m_logicalGeometry = QRect(10, 20, 800, 1200);
@@ -93,12 +68,12 @@ void tst_xdgoutput::overrideGeometry()
QTRY_COMPARE(s->size(), QSize(800, 1200));
QTRY_COMPARE(s->geometry().topLeft(), QPoint(10, 20));
- exec([=] { remove(output(1)); });
+ exec([&] { remove(output(1)); });
}
void tst_xdgoutput::changeGeometry()
{
- auto *xdgOutput = exec([=] {
+ auto *xdgOutput = exec([&] {
auto *output = add<Output>();
auto *xdgOutput = get<XdgOutputManagerV1>()->getXdgOutput(output);
xdgOutput->m_logicalGeometry = QRect(10, 20, 800, 1200);
@@ -109,7 +84,7 @@ void tst_xdgoutput::changeGeometry()
auto *screen = QGuiApplication::screens()[1];
QTRY_COMPARE(screen->size(), QSize(800, 1200));
- exec([=] {
+ exec([&] {
xdgOutput->sendLogicalSize(QSize(1024, 768));
});
@@ -117,21 +92,55 @@ void tst_xdgoutput::changeGeometry()
// done event. If we TRY_COMPARE immediately, we risk that the client just hasn't handled the
// logical_size request yet, so we add a screen and verify it on the client side just to give
// the client a chance to mess up.
- exec([=] { add<Output>(); });
+ exec([&] { add<Output>(); });
QTRY_COMPARE(QGuiApplication::screens().size(), 3);
- exec([=] { remove(output(2)); });
+ exec([&] { remove(output(2)); });
// The logical_size event should have been handled by now, but state should not have been applied yet.
QTRY_COMPARE(screen->size(), QSize(800, 1200));
- exec([=] {
+ exec([&] {
xdgOutput->m_output->sendDone();
});
// Finally, the size should change
QTRY_COMPARE(screen->size(), QSize(1024, 768));
- exec([=] { remove(output(1)); });
+ exec([&] { remove(output(1)); });
+}
+
+void tst_xdgoutput::outputCreateEnterRace()
+{
+ m_config.autoConfigure = true;
+ m_config.autoEnter = false;
+ QRasterWindow window;
+ QSignalSpy screenChanged(&window, &QWindow::screenChanged);
+ window.resize(400, 320);
+ window.show();
+ QCOMPOSITOR_TRY_VERIFY(xdgSurface() && xdgSurface()->m_committedConfigureSerial);
+ exec([&] { xdgToplevel()->surface()->sendEnter(output(0));});
+
+ QTRY_COMPARE(QGuiApplication::screens().size(), 1);
+ QScreen *primaryScreen = QGuiApplication::screens().first();
+ QCOMPARE(window.screen(), primaryScreen);
+
+ auto *out = exec([&] {
+ return add<Output>();
+ });
+
+ // In Compositor Thread
+ connect(out, &Output::outputBound, this, [this](QtWaylandServer::wl_output::Resource *resource){
+ auto surface = xdgToplevel()->surface();
+ surface->sendLeave(output(0));
+ surface->QtWaylandServer::wl_surface::send_enter(surface->resource()->handle, resource->handle);
+ }, Qt::DirectConnection);
+
+ QTRY_COMPARE(QGuiApplication::screens().size(), 2);
+ QTRY_COMPARE(window.screen(), QGuiApplication::screens()[1]);
+
+ exec([&] { remove(out); });
+ m_config.autoConfigure = false;
+ m_config.autoEnter = true;
}
QCOMPOSITOR_TEST_MAIN(tst_xdgoutput)