File indexing completed on 2024-05-05 17:36:14

0001 /*
0002     KWin - the KDE window manager
0003     This file is part of the KDE project.
0004 
0005     SPDX-FileCopyrightText: 2012 Martin Gräßlin <mgraesslin@kde.org>
0006 
0007     SPDX-License-Identifier: GPL-2.0-or-later
0008 */
0009 #include "../testutils.h"
0010 #include "clientmodel.h"
0011 #include "mock_tabboxhandler.h"
0012 #include <QtTest>
0013 #if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
0014 #include <private/qtx11extras_p.h>
0015 #else
0016 #include <QX11Info>
0017 #endif
0018 
0019 using namespace KWin;
0020 
0021 class TestTabBoxHandler : public QObject
0022 {
0023     Q_OBJECT
0024 private Q_SLOTS:
0025     void initTestCase();
0026     /**
0027      * Test to verify that update outline does not crash
0028      * if the ModelIndex for which the outline should be
0029      * shown is not valid. That is accessing the Pointer
0030      * to the Client returns an invalid QVariant.
0031      * BUG: 304620
0032      */
0033     void testDontCrashUpdateOutlineNullClient();
0034 };
0035 
0036 void TestTabBoxHandler::initTestCase()
0037 {
0038     qApp->setProperty("x11Connection", QVariant::fromValue<void *>(QX11Info::connection()));
0039 }
0040 
0041 void TestTabBoxHandler::testDontCrashUpdateOutlineNullClient()
0042 {
0043     MockTabBoxHandler tabboxhandler;
0044     TabBox::TabBoxConfig config;
0045     config.setTabBoxMode(TabBox::TabBoxConfig::ClientTabBox);
0046     config.setShowTabBox(false);
0047     config.setHighlightWindows(false);
0048     tabboxhandler.setConfig(config);
0049     // now show the tabbox which will attempt to show the outline
0050     tabboxhandler.show();
0051 }
0052 
0053 Q_CONSTRUCTOR_FUNCTION(forceXcb)
0054 QTEST_MAIN(TestTabBoxHandler)
0055 
0056 #include "test_tabbox_handler.moc"