2020-08-02 22:22:19 +00:00
|
|
|
/*
|
|
|
|
KWin - the KDE window manager
|
|
|
|
This file is part of the KDE project.
|
2017-07-06 17:07:01 +00:00
|
|
|
|
2020-08-02 22:22:19 +00:00
|
|
|
SPDX-FileCopyrightText: 2017 Martin Flöser <mgraesslin@kde.org>
|
2017-07-06 17:07:01 +00:00
|
|
|
|
2020-08-02 22:22:19 +00:00
|
|
|
SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
*/
|
2017-07-06 17:07:01 +00:00
|
|
|
#include "kwin_wayland_test.h"
|
2020-03-04 07:55:26 +00:00
|
|
|
#include "abstract_client.h"
|
2017-07-06 17:07:01 +00:00
|
|
|
#include "cursor.h"
|
|
|
|
#include "keyboard_input.h"
|
|
|
|
#include "platform.h"
|
|
|
|
#include "pointer_input.h"
|
|
|
|
#include "screens.h"
|
|
|
|
#include "useractions.h"
|
|
|
|
#include "wayland_server.h"
|
|
|
|
#include "workspace.h"
|
|
|
|
|
|
|
|
#include <KWayland/Client/compositor.h>
|
|
|
|
#include <KWayland/Client/keyboard.h>
|
|
|
|
#include <KWayland/Client/pointer.h>
|
|
|
|
#include <KWayland/Client/seat.h>
|
|
|
|
#include <KWayland/Client/shm_pool.h>
|
|
|
|
#include <KWayland/Client/surface.h>
|
|
|
|
#include <KWayland/Client/touch.h>
|
|
|
|
|
|
|
|
#include <linux/input.h>
|
|
|
|
|
|
|
|
using namespace KWin;
|
|
|
|
using namespace KWayland::Client;
|
|
|
|
|
|
|
|
static const QString s_socketName = QStringLiteral("wayland_test_kwin_dont_crash_useractions_menu-0");
|
|
|
|
|
|
|
|
class TestDontCrashUseractionsMenu : public QObject
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
private Q_SLOTS:
|
|
|
|
void initTestCase();
|
|
|
|
void init();
|
|
|
|
void cleanup();
|
|
|
|
|
|
|
|
void testShowHideShowUseractionsMenu();
|
|
|
|
};
|
|
|
|
|
|
|
|
void TestDontCrashUseractionsMenu::initTestCase()
|
|
|
|
{
|
|
|
|
qRegisterMetaType<KWin::AbstractClient*>();
|
2020-07-07 09:32:29 +00:00
|
|
|
QSignalSpy applicationStartedSpy(kwinApp(), &Application::started);
|
|
|
|
QVERIFY(applicationStartedSpy.isValid());
|
2017-07-06 17:07:01 +00:00
|
|
|
kwinApp()->platform()->setInitialWindowSize(QSize(1280, 1024));
|
|
|
|
QVERIFY(waylandServer()->init(s_socketName.toLocal8Bit()));
|
2019-08-26 21:16:53 +00:00
|
|
|
QMetaObject::invokeMethod(kwinApp()->platform(), "setVirtualOutputs", Qt::DirectConnection, Q_ARG(int, 2));
|
2017-07-06 17:07:01 +00:00
|
|
|
|
2017-07-08 08:47:17 +00:00
|
|
|
// force style to breeze as that's the one which triggered the crash
|
|
|
|
QVERIFY(kwinApp()->setStyle(QStringLiteral("breeze")));
|
|
|
|
|
2017-07-06 17:07:01 +00:00
|
|
|
kwinApp()->start();
|
2020-07-07 09:32:29 +00:00
|
|
|
QVERIFY(applicationStartedSpy.wait());
|
2017-07-06 17:07:01 +00:00
|
|
|
QCOMPARE(screens()->count(), 2);
|
|
|
|
QCOMPARE(screens()->geometry(0), QRect(0, 0, 1280, 1024));
|
|
|
|
QCOMPARE(screens()->geometry(1), QRect(1280, 0, 1280, 1024));
|
|
|
|
waylandServer()->initWorkspace();
|
|
|
|
}
|
|
|
|
|
|
|
|
void TestDontCrashUseractionsMenu::init()
|
|
|
|
{
|
|
|
|
QVERIFY(Test::setupWaylandConnection());
|
|
|
|
|
|
|
|
screens()->setCurrent(0);
|
2020-04-02 16:18:01 +00:00
|
|
|
KWin::Cursors::self()->mouse()->setPos(QPoint(1280, 512));
|
2017-07-06 17:07:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void TestDontCrashUseractionsMenu::cleanup()
|
|
|
|
{
|
|
|
|
Test::destroyWaylandConnection();
|
|
|
|
}
|
|
|
|
|
|
|
|
void TestDontCrashUseractionsMenu::testShowHideShowUseractionsMenu()
|
|
|
|
{
|
|
|
|
// this test creates the condition of BUG 382063
|
|
|
|
QScopedPointer<Surface> surface1(Test::createSurface());
|
2019-08-27 15:01:14 +00:00
|
|
|
QScopedPointer<XdgShellSurface> shellSurface1(Test::createXdgShellStableSurface(surface1.data()));
|
2017-07-06 17:07:01 +00:00
|
|
|
auto client = Test::renderAndWaitForShown(surface1.data(), QSize(100, 50), Qt::blue);
|
|
|
|
QVERIFY(client);
|
|
|
|
|
|
|
|
workspace()->showWindowMenu(QRect(), client);
|
|
|
|
auto userActionsMenu = workspace()->userActionsMenu();
|
|
|
|
QTRY_VERIFY(userActionsMenu->isShown());
|
|
|
|
QVERIFY(userActionsMenu->hasClient());
|
|
|
|
|
|
|
|
kwinApp()->platform()->keyboardKeyPressed(KEY_ESC, 0);
|
|
|
|
kwinApp()->platform()->keyboardKeyReleased(KEY_ESC, 1);
|
|
|
|
QTRY_VERIFY(!userActionsMenu->isShown());
|
|
|
|
QVERIFY(!userActionsMenu->hasClient());
|
|
|
|
|
|
|
|
// and show again, this triggers BUG 382063
|
|
|
|
workspace()->showWindowMenu(QRect(), client);
|
|
|
|
QTRY_VERIFY(userActionsMenu->isShown());
|
|
|
|
QVERIFY(userActionsMenu->hasClient());
|
|
|
|
}
|
|
|
|
|
|
|
|
WAYLANDTEST_MAIN(TestDontCrashUseractionsMenu)
|
|
|
|
#include "dont_crash_useractions_menu.moc"
|