2020-08-02 22:22:19 +00:00
|
|
|
/*
|
|
|
|
KWin - the KDE window manager
|
|
|
|
This file is part of the KDE project.
|
2015-10-22 08:08:49 +00:00
|
|
|
|
2020-08-02 22:22:19 +00:00
|
|
|
SPDX-FileCopyrightText: 2015 Martin Gräßlin <mgraesslin@kde.org>
|
2015-10-22 08:08:49 +00:00
|
|
|
|
2020-08-02 22:22:19 +00:00
|
|
|
SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
*/
|
2015-10-22 08:08:49 +00:00
|
|
|
#include "kwin_wayland_test.h"
|
2022-03-23 10:13:38 +00:00
|
|
|
|
2022-11-05 10:43:41 +00:00
|
|
|
#include "core/outputbackend.h"
|
2015-10-22 08:08:49 +00:00
|
|
|
#include "deleted.h"
|
|
|
|
#include "wayland_server.h"
|
2022-04-22 17:39:12 +00:00
|
|
|
#include "window.h"
|
2015-10-22 08:08:49 +00:00
|
|
|
#include "workspace.h"
|
2022-04-22 17:54:31 +00:00
|
|
|
#include "x11window.h"
|
2015-10-22 08:08:49 +00:00
|
|
|
|
|
|
|
#include <KDecoration2/Decoration>
|
|
|
|
|
|
|
|
namespace KWin
|
|
|
|
{
|
|
|
|
|
|
|
|
static const QString s_socketName = QStringLiteral("wayland_test_kwin_dont_crash_glxgears-0");
|
|
|
|
|
|
|
|
class DontCrashGlxgearsTest : public QObject
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
private Q_SLOTS:
|
|
|
|
void initTestCase();
|
|
|
|
void testGlxgears();
|
|
|
|
};
|
|
|
|
|
|
|
|
void DontCrashGlxgearsTest::initTestCase()
|
|
|
|
{
|
2022-03-23 10:13:38 +00:00
|
|
|
qRegisterMetaType<KWin::Deleted *>();
|
2020-07-07 09:32:29 +00:00
|
|
|
QSignalSpy applicationStartedSpy(kwinApp(), &Application::started);
|
2022-11-05 10:43:41 +00:00
|
|
|
kwinApp()->outputBackend()->setInitialWindowSize(QSize(1280, 1024));
|
2020-12-09 13:06:15 +00:00
|
|
|
QVERIFY(waylandServer()->init(s_socketName));
|
2015-10-22 08:08:49 +00:00
|
|
|
kwinApp()->start();
|
2020-07-07 09:32:29 +00:00
|
|
|
QVERIFY(applicationStartedSpy.wait());
|
2015-10-22 08:08:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void DontCrashGlxgearsTest::testGlxgears()
|
|
|
|
{
|
|
|
|
// closing a glxgears window through Aurorae themes used to crash KWin
|
|
|
|
// Let's make sure that doesn't happen anymore
|
|
|
|
|
2022-04-23 08:33:23 +00:00
|
|
|
QSignalSpy windowAddedSpy(workspace(), &Workspace::windowAdded);
|
2015-10-22 08:08:49 +00:00
|
|
|
|
|
|
|
QProcess glxgears;
|
2020-09-10 07:15:31 +00:00
|
|
|
glxgears.setProgram(QStringLiteral("glxgears"));
|
|
|
|
glxgears.start();
|
2015-10-22 08:08:49 +00:00
|
|
|
QVERIFY(glxgears.waitForStarted());
|
|
|
|
|
2022-04-23 08:33:23 +00:00
|
|
|
QVERIFY(windowAddedSpy.wait());
|
|
|
|
QCOMPARE(windowAddedSpy.count(), 1);
|
2015-10-22 08:08:49 +00:00
|
|
|
QCOMPARE(workspace()->clientList().count(), 1);
|
2022-04-23 19:51:16 +00:00
|
|
|
X11Window *glxgearsWindow = workspace()->clientList().first();
|
|
|
|
QVERIFY(glxgearsWindow->isDecorated());
|
|
|
|
QSignalSpy closedSpy(glxgearsWindow, &X11Window::windowClosed);
|
|
|
|
KDecoration2::Decoration *decoration = glxgearsWindow->decoration();
|
2015-10-22 08:08:49 +00:00
|
|
|
QVERIFY(decoration);
|
|
|
|
|
|
|
|
// send a mouse event to the position of the close button
|
2019-06-11 13:24:24 +00:00
|
|
|
// TODO: position is dependent on the decoration in use. We should use a static target instead, a fake deco for autotests.
|
|
|
|
QPointF pos = decoration->rect().topRight() + QPointF(-decoration->borderTop() / 2, decoration->borderTop() / 2);
|
2015-10-22 08:08:49 +00:00
|
|
|
QHoverEvent event(QEvent::HoverMove, pos, pos);
|
|
|
|
QCoreApplication::instance()->sendEvent(decoration, &event);
|
|
|
|
// mouse press
|
|
|
|
QMouseEvent mousePressevent(QEvent::MouseButtonPress, pos, pos, Qt::LeftButton, Qt::LeftButton, Qt::NoModifier);
|
|
|
|
mousePressevent.setAccepted(false);
|
|
|
|
QCoreApplication::sendEvent(decoration, &mousePressevent);
|
|
|
|
QVERIFY(mousePressevent.isAccepted());
|
|
|
|
// mouse Release
|
|
|
|
QMouseEvent mouseReleaseEvent(QEvent::MouseButtonRelease, pos, pos, Qt::LeftButton, Qt::LeftButton, Qt::NoModifier);
|
|
|
|
mouseReleaseEvent.setAccepted(false);
|
|
|
|
QCoreApplication::sendEvent(decoration, &mouseReleaseEvent);
|
|
|
|
QVERIFY(mouseReleaseEvent.isAccepted());
|
|
|
|
|
|
|
|
QVERIFY(closedSpy.wait());
|
|
|
|
QCOMPARE(closedSpy.count(), 1);
|
|
|
|
xcb_flush(connection());
|
|
|
|
|
|
|
|
if (glxgears.state() == QProcess::Running) {
|
|
|
|
QVERIFY(glxgears.waitForFinished());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2016-02-11 08:34:19 +00:00
|
|
|
WAYLANDTEST_MAIN(KWin::DontCrashGlxgearsTest)
|
2015-10-22 08:08:49 +00:00
|
|
|
#include "dont_crash_glxgears.moc"
|