File indexing completed on 2025-03-23 13:47:58
0001 /* 0002 KWin - the KDE window manager 0003 This file is part of the KDE project. 0004 0005 SPDX-FileCopyrightText: 2017 Martin Flöser <mgraesslin@kde.org> 0006 0007 SPDX-License-Identifier: GPL-2.0-or-later 0008 */ 0009 #include "kwin_wayland_test.h" 0010 0011 #include "core/outputbackend.h" 0012 #include "keyboard_input.h" 0013 #include "keyboard_layout.h" 0014 #include "virtualdesktops.h" 0015 #include "wayland_server.h" 0016 #include "window.h" 0017 #include "workspace.h" 0018 0019 #include <KConfigGroup> 0020 #include <KGlobalAccel> 0021 0022 #include <linux/input.h> 0023 0024 using namespace KWin; 0025 0026 static const QString s_socketName = QStringLiteral("wayland_test_kwin_keymap_creation_failure-0"); 0027 0028 class KeymapCreationFailureTest : public QObject 0029 { 0030 Q_OBJECT 0031 private Q_SLOTS: 0032 void initTestCase(); 0033 void init(); 0034 void cleanup(); 0035 0036 void testPointerButton(); 0037 }; 0038 0039 void KeymapCreationFailureTest::initTestCase() 0040 { 0041 // situation for for BUG 381210 0042 // this will fail to create keymap 0043 qputenv("XKB_DEFAULT_RULES", "no"); 0044 qputenv("XKB_DEFAULT_MODEL", "no"); 0045 qputenv("XKB_DEFAULT_LAYOUT", "no"); 0046 qputenv("XKB_DEFAULT_VARIANT", "no"); 0047 qputenv("XKB_DEFAULT_OPTIONS", "no"); 0048 0049 qRegisterMetaType<KWin::Window *>(); 0050 QSignalSpy applicationStartedSpy(kwinApp(), &Application::started); 0051 QVERIFY(waylandServer()->init(s_socketName)); 0052 QMetaObject::invokeMethod(kwinApp()->outputBackend(), "setVirtualOutputs", Qt::DirectConnection, Q_ARG(QVector<QRect>, QVector<QRect>() << QRect(0, 0, 1280, 1024) << QRect(1280, 0, 1280, 1024))); 0053 0054 kwinApp()->setConfig(KSharedConfig::openConfig(QString(), KConfig::SimpleConfig)); 0055 kwinApp()->setKxkbConfig(KSharedConfig::openConfig(QString(), KConfig::SimpleConfig)); 0056 KConfigGroup layoutGroup = kwinApp()->kxkbConfig()->group("Layout"); 0057 layoutGroup.writeEntry("LayoutList", QStringLiteral("no")); 0058 layoutGroup.writeEntry("Model", "no"); 0059 layoutGroup.writeEntry("Options", "no"); 0060 layoutGroup.sync(); 0061 0062 kwinApp()->start(); 0063 QVERIFY(applicationStartedSpy.wait()); 0064 } 0065 0066 void KeymapCreationFailureTest::init() 0067 { 0068 QVERIFY(Test::setupWaylandConnection()); 0069 } 0070 0071 void KeymapCreationFailureTest::cleanup() 0072 { 0073 Test::destroyWaylandConnection(); 0074 } 0075 0076 void KeymapCreationFailureTest::testPointerButton() 0077 { 0078 // test case for BUG 381210 0079 // pressing a pointer button results in crash 0080 0081 // now create the crashing condition 0082 // which is sending in a pointer event 0083 Test::pointerButtonPressed(BTN_LEFT, 0); 0084 Test::pointerButtonReleased(BTN_LEFT, 1); 0085 } 0086 0087 WAYLANDTEST_MAIN(KeymapCreationFailureTest) 0088 #include "keymap_creation_failure_test.moc"