File indexing completed on 2024-05-12 16:39:56

0001 /* This file is part of the KDE project
0002    Copyright (C) 2012-2017 Jarosław Staniek <staniek@kde.org>
0003 
0004    This program is free software; you can redistribute it and/or
0005    modify it under the terms of the GNU Library General Public
0006    License as published by the Free Software Foundation; either
0007    version 2 of the License, or (at your option) any later version.
0008 
0009    This program is distributed in the hope that it will be useful,
0010    but WITHOUT ANY WARRANTY; without even the implied warranty of
0011    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0012    Library General Public License for more details.
0013 
0014    You should have received a copy of the GNU Library General Public License
0015    along with this program; see the file COPYING.  If not, write to
0016    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
0017  * Boston, MA 02110-1301, USA.
0018 */
0019 
0020 #ifndef KEXITESTHANDLER_H
0021 #define KEXITESTHANDLER_H
0022 
0023 #include <kexiutils_export.h>
0024 
0025 #include <QtTest>
0026 #include <QtTest/qtestkeyboard.h>
0027 #include <QtTest/qtestmouse.h>
0028 #include <QCommandLineOption>
0029 #include <QObject>
0030 
0031 //! A handler for Kexi test objects
0032 class KEXIUTILS_EXPORT KexiTestHandler : public QObject
0033 {
0034     Q_OBJECT
0035 public:
0036     KexiTestHandler();
0037 
0038     ~KexiTestHandler();
0039 
0040     void addExtraOption(const QCommandLineOption &option);
0041 
0042     QList<QCommandLineOption> extraOptions() const;
0043 
0044     void removeOwnOptions(QStringList *args);
0045 
0046 private:
0047     class Private;
0048     Private * const d;
0049 };
0050 
0051 // Override but still use the same macro so Qt Creator lists the test(s)
0052 // Note: don't link against QtTest lib, otherwise Creator will mark KexiUtils as tests
0053 #undef QTEST_MAIN
0054 #define QTEST_MAIN(TestObject) \
0055     QT_BEGIN_NAMESPACE \
0056     QTEST_ADD_GPU_BLACKLIST_SUPPORT_DEFS \
0057     QT_END_NAMESPACE \
0058     int main(int argc, char *argv[]) \
0059     { \
0060         QApplication app(argc, argv); \
0061         app.setAttribute(Qt::AA_Use96Dpi, true); \
0062         QTEST_DISABLE_KEYPAD_NAVIGATION \
0063         QTEST_ADD_GPU_BLACKLIST_SUPPORT \
0064         TestObject tc; \
0065         QStringList args(QCoreApplication::arguments()); \
0066         tc.removeOwnOptions(&args); \
0067         return QTest::qExec(&tc, args); \
0068     }
0069 
0070 #endif