File indexing completed on 2024-11-10 04:56:00
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 "keyboard_input.h" 0012 #include "keyboard_layout.h" 0013 #include "virtualdesktops.h" 0014 #include "wayland_server.h" 0015 #include "window.h" 0016 #include "workspace.h" 0017 0018 #include <KConfigGroup> 0019 #include <KGlobalAccel> 0020 0021 #include <linux/input.h> 0022 0023 using namespace KWin; 0024 0025 static const QString s_socketName = QStringLiteral("wayland_test_kwin_keymap_creation_failure-0"); 0026 0027 class KeymapCreationFailureTest : public QObject 0028 { 0029 Q_OBJECT 0030 private Q_SLOTS: 0031 void initTestCase(); 0032 void init(); 0033 void cleanup(); 0034 0035 void testPointerButton(); 0036 }; 0037 0038 void KeymapCreationFailureTest::initTestCase() 0039 { 0040 // situation for for BUG 381210 0041 // this will fail to create keymap 0042 qputenv("XKB_DEFAULT_RULES", "no"); 0043 qputenv("XKB_DEFAULT_MODEL", "no"); 0044 qputenv("XKB_DEFAULT_LAYOUT", "no"); 0045 qputenv("XKB_DEFAULT_VARIANT", "no"); 0046 qputenv("XKB_DEFAULT_OPTIONS", "no"); 0047 0048 qRegisterMetaType<KWin::Window *>(); 0049 QSignalSpy applicationStartedSpy(kwinApp(), &Application::started); 0050 QVERIFY(waylandServer()->init(s_socketName)); 0051 Test::setOutputConfig({ 0052 QRect(0, 0, 1280, 1024), 0053 QRect(1280, 0, 1280, 1024), 0054 }); 0055 0056 kwinApp()->setConfig(KSharedConfig::openConfig(QString(), KConfig::SimpleConfig)); 0057 kwinApp()->setKxkbConfig(KSharedConfig::openConfig(QString(), KConfig::SimpleConfig)); 0058 KConfigGroup layoutGroup = kwinApp()->kxkbConfig()->group(QStringLiteral("Layout")); 0059 layoutGroup.writeEntry("LayoutList", QStringLiteral("no")); 0060 layoutGroup.writeEntry("Model", "no"); 0061 layoutGroup.writeEntry("Options", "no"); 0062 layoutGroup.sync(); 0063 0064 kwinApp()->start(); 0065 QVERIFY(applicationStartedSpy.wait()); 0066 } 0067 0068 void KeymapCreationFailureTest::init() 0069 { 0070 QVERIFY(Test::setupWaylandConnection()); 0071 } 0072 0073 void KeymapCreationFailureTest::cleanup() 0074 { 0075 Test::destroyWaylandConnection(); 0076 } 0077 0078 void KeymapCreationFailureTest::testPointerButton() 0079 { 0080 // test case for BUG 381210 0081 // pressing a pointer button results in crash 0082 0083 // now create the crashing condition 0084 // which is sending in a pointer event 0085 Test::pointerButtonPressed(BTN_LEFT, 0); 0086 Test::pointerButtonReleased(BTN_LEFT, 1); 0087 } 0088 0089 WAYLANDTEST_MAIN(KeymapCreationFailureTest) 0090 #include "keymap_creation_failure_test.moc"