File indexing completed on 2025-03-09 04:56:53
0001 /* 0002 * SPDX-FileCopyrightText: 2016 Kevin Ottens <ervin@kde.org> 0003 * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 0004 */ 0005 0006 0007 #ifndef QTEST_ZANSHIN_H 0008 #define QTEST_ZANSHIN_H 0009 0010 #include <QtTest> 0011 #include <QDebug> 0012 0013 // We have our own test macro in order to: 0014 // * make sure QHash instances are not randomized 0015 // * avoid DrKonqi in case of crashes 0016 // * Use a much simpler style during tests to avoid 0017 // animations or such polluting the environment 0018 0019 #ifdef QT_GUI_LIB 0020 #define _ZANSHIN_TESTLIB_INTERNAL_FORCE_GUI_ENVIRONMENT \ 0021 bool _zanshin_testlib_internal_forceGuiEnvironment() \ 0022 { \ 0023 QGuiApplication::setDesktopSettingsAware(false); \ 0024 qputenv("QT_STYLE_OVERRIDE", "fusion"); \ 0025 return true; \ 0026 } \ 0027 Q_CONSTRUCTOR_FUNCTION(_zanshin_testlib_internal_forceGuiEnvironment) 0028 #else 0029 #define _ZANSHIN_TESTLIB_INTERNAL_FORCE_GUI_ENVIRONMENT 0030 #endif 0031 0032 #define ZANSHIN_TEST_MAIN(TestCase) \ 0033 _ZANSHIN_TESTLIB_INTERNAL_FORCE_GUI_ENVIRONMENT \ 0034 \ 0035 bool _zanshin_testlib_internal_forceEnvironment() \ 0036 { \ 0037 qSetGlobalQHashSeed(0); \ 0038 qputenv("KDE_DEBUG", "1"); \ 0039 qunsetenv("LANG"); \ 0040 qunsetenv("LANGUAGE"); \ 0041 qputenv("LC_ALL", "en_US"); \ 0042 return true; \ 0043 } \ 0044 Q_CONSTRUCTOR_FUNCTION(_zanshin_testlib_internal_forceEnvironment) \ 0045 \ 0046 void _zanshin_testlib_internal_workaround_kxmlgui_startupfunc_leak() \ 0047 { \ 0048 QCoreApplication::processEvents(); \ 0049 QCoreApplication::processEvents(); \ 0050 } \ 0051 \ 0052 extern "C" void Q_CORE_EXPORT qt_startup_hook() \ 0053 { \ 0054 _zanshin_testlib_internal_workaround_kxmlgui_startupfunc_leak(); \ 0055 } \ 0056 \ 0057 QTEST_MAIN(TestCase) 0058 0059 #endif // QTEST_ZANSHIN_H