2011-04-27 10:05:43 +00:00
|
|
|
/****************************************************************************
|
|
|
|
**
|
2016-01-15 07:08:27 +00:00
|
|
|
** Copyright (C) 2016 The Qt Company Ltd.
|
2016-01-21 02:33:50 +00:00
|
|
|
** Copyright (C) 2016 Intel Corporation.
|
2016-01-15 07:08:27 +00:00
|
|
|
** Contact: https://www.qt.io/licensing/
|
2011-04-27 10:05:43 +00:00
|
|
|
**
|
|
|
|
** This file is part of the QtTest module of the Qt Toolkit.
|
|
|
|
**
|
2016-01-15 07:08:27 +00:00
|
|
|
** $QT_BEGIN_LICENSE:LGPL$
|
2012-09-19 12:28:29 +00:00
|
|
|
** Commercial License Usage
|
|
|
|
** Licensees holding valid commercial Qt licenses may use this file in
|
|
|
|
** accordance with the commercial license agreement provided with the
|
|
|
|
** Software or, alternatively, in accordance with the terms contained in
|
2015-01-28 08:44:43 +00:00
|
|
|
** a written agreement between you and The Qt Company. For licensing terms
|
2016-01-15 07:08:27 +00:00
|
|
|
** and conditions see https://www.qt.io/terms-conditions. For further
|
|
|
|
** information use the contact form at https://www.qt.io/contact-us.
|
2012-09-19 12:28:29 +00:00
|
|
|
**
|
2011-04-27 10:05:43 +00:00
|
|
|
** GNU Lesser General Public License Usage
|
2012-09-19 12:28:29 +00:00
|
|
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
2016-01-15 07:08:27 +00:00
|
|
|
** General Public License version 3 as published by the Free Software
|
|
|
|
** Foundation and appearing in the file LICENSE.LGPL3 included in the
|
|
|
|
** packaging of this file. Please review the following information to
|
|
|
|
** ensure the GNU Lesser General Public License version 3 requirements
|
|
|
|
** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
|
2012-09-19 12:28:29 +00:00
|
|
|
**
|
2016-01-15 07:08:27 +00:00
|
|
|
** GNU General Public License Usage
|
|
|
|
** Alternatively, this file may be used under the terms of the GNU
|
|
|
|
** General Public License version 2.0 or (at your option) the GNU General
|
|
|
|
** Public license version 3 or any later version approved by the KDE Free
|
|
|
|
** Qt Foundation. The licenses are as published by the Free Software
|
|
|
|
** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
|
|
|
|
** included in the packaging of this file. Please review the following
|
|
|
|
** information to ensure the GNU General Public License requirements will
|
|
|
|
** be met: https://www.gnu.org/licenses/gpl-2.0.html and
|
|
|
|
** https://www.gnu.org/licenses/gpl-3.0.html.
|
2011-04-27 10:05:43 +00:00
|
|
|
**
|
|
|
|
** $QT_END_LICENSE$
|
|
|
|
**
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#ifndef QTEST_H
|
|
|
|
#define QTEST_H
|
|
|
|
|
2018-02-13 11:25:10 +00:00
|
|
|
#include <QtTest/qttestglobal.h>
|
2011-04-27 10:05:43 +00:00
|
|
|
#include <QtTest/qtestcase.h>
|
|
|
|
#include <QtTest/qtestdata.h>
|
|
|
|
#include <QtTest/qbenchmark.h>
|
|
|
|
|
|
|
|
#include <QtCore/qbytearray.h>
|
|
|
|
#include <QtCore/qstring.h>
|
|
|
|
#include <QtCore/qstringlist.h>
|
|
|
|
#include <QtCore/qdatetime.h>
|
|
|
|
#include <QtCore/qobject.h>
|
|
|
|
#include <QtCore/qvariant.h>
|
|
|
|
#include <QtCore/qurl.h>
|
2017-04-10 16:43:51 +00:00
|
|
|
#include <QtCore/quuid.h>
|
2011-04-27 10:05:43 +00:00
|
|
|
|
|
|
|
#include <QtCore/qpoint.h>
|
|
|
|
#include <QtCore/qsize.h>
|
|
|
|
#include <QtCore/qrect.h>
|
|
|
|
|
2017-12-07 08:46:30 +00:00
|
|
|
#include <memory>
|
|
|
|
|
2011-04-27 10:05:43 +00:00
|
|
|
QT_BEGIN_NAMESPACE
|
|
|
|
|
|
|
|
|
|
|
|
namespace QTest
|
|
|
|
{
|
|
|
|
|
2017-04-21 10:13:21 +00:00
|
|
|
template <> inline char *toString(const QStringView &str)
|
|
|
|
{
|
|
|
|
return QTest::toPrettyUnicode(str);
|
|
|
|
}
|
|
|
|
|
2014-01-21 00:03:30 +00:00
|
|
|
template<> inline char *toString(const QString &str)
|
2011-04-27 10:05:43 +00:00
|
|
|
{
|
2017-04-21 10:13:21 +00:00
|
|
|
return toString(QStringView(str));
|
2011-04-27 10:05:43 +00:00
|
|
|
}
|
|
|
|
|
2014-01-21 00:03:30 +00:00
|
|
|
template<> inline char *toString(const QLatin1String &str)
|
2011-04-27 10:05:43 +00:00
|
|
|
{
|
2014-01-21 00:03:30 +00:00
|
|
|
return toString(QString(str));
|
2011-04-27 10:05:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
template<> inline char *toString(const QByteArray &ba)
|
|
|
|
{
|
2014-01-21 00:03:30 +00:00
|
|
|
return QTest::toPrettyCString(ba.constData(), ba.length());
|
2011-04-27 10:05:43 +00:00
|
|
|
}
|
|
|
|
|
2018-09-19 11:31:18 +00:00
|
|
|
#if QT_CONFIG(datestring)
|
2011-04-27 10:05:43 +00:00
|
|
|
template<> inline char *toString(const QTime &time)
|
|
|
|
{
|
|
|
|
return time.isValid()
|
2017-04-11 10:25:37 +00:00
|
|
|
? qstrdup(qPrintable(time.toString(QStringViewLiteral("hh:mm:ss.zzz"))))
|
2011-04-27 10:05:43 +00:00
|
|
|
: qstrdup("Invalid QTime");
|
|
|
|
}
|
|
|
|
|
|
|
|
template<> inline char *toString(const QDate &date)
|
|
|
|
{
|
|
|
|
return date.isValid()
|
2017-04-11 10:25:37 +00:00
|
|
|
? qstrdup(qPrintable(date.toString(QStringViewLiteral("yyyy/MM/dd"))))
|
2011-04-27 10:05:43 +00:00
|
|
|
: qstrdup("Invalid QDate");
|
|
|
|
}
|
|
|
|
|
|
|
|
template<> inline char *toString(const QDateTime &dateTime)
|
|
|
|
{
|
|
|
|
return dateTime.isValid()
|
2017-04-11 10:25:37 +00:00
|
|
|
? qstrdup(qPrintable(dateTime.toString(QStringViewLiteral("yyyy/MM/dd hh:mm:ss.zzz[t]"))))
|
2011-04-27 10:05:43 +00:00
|
|
|
: qstrdup("Invalid QDateTime");
|
|
|
|
}
|
2018-09-19 11:31:18 +00:00
|
|
|
#endif // datestring
|
2011-04-27 10:05:43 +00:00
|
|
|
|
|
|
|
template<> inline char *toString(const QChar &c)
|
|
|
|
{
|
2016-07-01 14:18:41 +00:00
|
|
|
const ushort uc = c.unicode();
|
|
|
|
if (uc < 128) {
|
|
|
|
char msg[32] = {'\0'};
|
|
|
|
qsnprintf(msg, sizeof(msg), "QChar: '%c' (0x%x)", char(uc), unsigned(uc));
|
|
|
|
return qstrdup(msg);
|
|
|
|
}
|
2013-03-06 10:17:46 +00:00
|
|
|
return qstrdup(qPrintable(QString::fromLatin1("QChar: '%1' (0x%2)").arg(c).arg(QString::number(static_cast<int>(c.unicode()), 16))));
|
2011-04-27 10:05:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
template<> inline char *toString(const QPoint &p)
|
|
|
|
{
|
2016-07-01 14:18:41 +00:00
|
|
|
char msg[128] = {'\0'};
|
|
|
|
qsnprintf(msg, sizeof(msg), "QPoint(%d,%d)", p.x(), p.y());
|
|
|
|
return qstrdup(msg);
|
2011-04-27 10:05:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
template<> inline char *toString(const QSize &s)
|
|
|
|
{
|
2016-07-01 14:18:41 +00:00
|
|
|
char msg[128] = {'\0'};
|
|
|
|
qsnprintf(msg, sizeof(msg), "QSize(%dx%d)", s.width(), s.height());
|
|
|
|
return qstrdup(msg);
|
2011-04-27 10:05:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
template<> inline char *toString(const QRect &s)
|
|
|
|
{
|
2016-07-01 14:18:41 +00:00
|
|
|
char msg[256] = {'\0'};
|
|
|
|
qsnprintf(msg, sizeof(msg), "QRect(%d,%d %dx%d) (bottomright %d,%d)",
|
|
|
|
s.left(), s.top(), s.width(), s.height(), s.right(), s.bottom());
|
|
|
|
return qstrdup(msg);
|
2011-04-27 10:05:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
template<> inline char *toString(const QPointF &p)
|
|
|
|
{
|
2016-07-01 14:18:41 +00:00
|
|
|
char msg[64] = {'\0'};
|
|
|
|
qsnprintf(msg, sizeof(msg), "QPointF(%g,%g)", p.x(), p.y());
|
|
|
|
return qstrdup(msg);
|
2011-04-27 10:05:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
template<> inline char *toString(const QSizeF &s)
|
|
|
|
{
|
2016-07-01 14:18:41 +00:00
|
|
|
char msg[64] = {'\0'};
|
|
|
|
qsnprintf(msg, sizeof(msg), "QSizeF(%gx%g)", s.width(), s.height());
|
|
|
|
return qstrdup(msg);
|
2011-04-27 10:05:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
template<> inline char *toString(const QRectF &s)
|
|
|
|
{
|
2016-07-01 14:18:41 +00:00
|
|
|
char msg[256] = {'\0'};
|
|
|
|
qsnprintf(msg, sizeof(msg), "QRectF(%g,%g %gx%g) (bottomright %g,%g)",
|
|
|
|
s.left(), s.top(), s.width(), s.height(), s.right(), s.bottom());
|
|
|
|
return qstrdup(msg);
|
2011-04-27 10:05:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
template<> inline char *toString(const QUrl &uri)
|
|
|
|
{
|
2012-09-18 21:07:46 +00:00
|
|
|
if (!uri.isValid())
|
2016-07-06 08:32:54 +00:00
|
|
|
return qstrdup(qPrintable(QLatin1String("Invalid URL: ") + uri.errorString()));
|
2012-03-30 20:48:42 +00:00
|
|
|
return qstrdup(uri.toEncoded().constData());
|
2011-04-27 10:05:43 +00:00
|
|
|
}
|
|
|
|
|
2017-04-10 16:43:51 +00:00
|
|
|
template <> inline char *toString(const QUuid &uuid)
|
|
|
|
{
|
|
|
|
return qstrdup(uuid.toByteArray().constData());
|
|
|
|
}
|
|
|
|
|
2011-04-27 10:05:43 +00:00
|
|
|
template<> inline char *toString(const QVariant &v)
|
|
|
|
{
|
|
|
|
QByteArray vstring("QVariant(");
|
|
|
|
if (v.isValid()) {
|
|
|
|
QByteArray type(v.typeName());
|
|
|
|
if (type.isEmpty()) {
|
|
|
|
type = QByteArray::number(v.userType());
|
|
|
|
}
|
|
|
|
vstring.append(type);
|
|
|
|
if (!v.isNull()) {
|
|
|
|
vstring.append(',');
|
|
|
|
if (v.canConvert(QVariant::String)) {
|
2016-05-24 13:53:04 +00:00
|
|
|
vstring.append(v.toString().toLocal8Bit());
|
2011-04-27 10:05:43 +00:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
vstring.append("<value not representable as string>");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
vstring.append(')');
|
|
|
|
|
|
|
|
return qstrdup(vstring.constData());
|
|
|
|
}
|
|
|
|
|
2017-07-20 13:14:08 +00:00
|
|
|
template <typename T1, typename T2>
|
|
|
|
inline char *toString(const QPair<T1, T2> &pair)
|
|
|
|
{
|
|
|
|
const QScopedArrayPointer<char> first(toString(pair.first));
|
|
|
|
const QScopedArrayPointer<char> second(toString(pair.second));
|
|
|
|
return toString(QString::asprintf("QPair(%s,%s)", first.data(), second.data()));
|
|
|
|
}
|
|
|
|
|
|
|
|
template <typename T1, typename T2>
|
|
|
|
inline char *toString(const std::pair<T1, T2> &pair)
|
|
|
|
{
|
|
|
|
const QScopedArrayPointer<char> first(toString(pair.first));
|
|
|
|
const QScopedArrayPointer<char> second(toString(pair.second));
|
|
|
|
return toString(QString::asprintf("std::pair(%s,%s)", first.data(), second.data()));
|
|
|
|
}
|
|
|
|
|
2017-12-07 08:46:30 +00:00
|
|
|
template <typename Tuple, int... I>
|
|
|
|
inline char *toString(const Tuple & tuple, QtPrivate::IndexesList<I...>) {
|
|
|
|
using UP = std::unique_ptr<char[]>;
|
|
|
|
// Generate a table of N + 1 elements where N is the number of
|
|
|
|
// elements in the tuple.
|
|
|
|
// The last element is needed to support the empty tuple use case.
|
|
|
|
const UP data[] = {
|
|
|
|
UP(toString(std::get<I>(tuple)))..., UP{}
|
|
|
|
};
|
|
|
|
return formatString("std::tuple(", ")", sizeof...(I), data[I].get()...);
|
|
|
|
}
|
|
|
|
|
|
|
|
template <class... Types>
|
|
|
|
inline char *toString(const std::tuple<Types...> &tuple)
|
|
|
|
{
|
|
|
|
static const std::size_t params_count = sizeof...(Types);
|
|
|
|
return toString(tuple, typename QtPrivate::Indexes<params_count>::Value());
|
|
|
|
}
|
|
|
|
|
2016-02-22 19:29:32 +00:00
|
|
|
inline char *toString(std::nullptr_t)
|
|
|
|
{
|
|
|
|
return toString(QLatin1String("nullptr"));
|
|
|
|
}
|
|
|
|
|
2011-04-27 10:05:43 +00:00
|
|
|
template<>
|
|
|
|
inline bool qCompare(QString const &t1, QLatin1String const &t2, const char *actual,
|
|
|
|
const char *expected, const char *file, int line)
|
|
|
|
{
|
2012-09-20 14:36:51 +00:00
|
|
|
return qCompare(t1, QString(t2), actual, expected, file, line);
|
2011-04-27 10:05:43 +00:00
|
|
|
}
|
|
|
|
template<>
|
|
|
|
inline bool qCompare(QLatin1String const &t1, QString const &t2, const char *actual,
|
|
|
|
const char *expected, const char *file, int line)
|
|
|
|
{
|
2012-09-20 14:36:51 +00:00
|
|
|
return qCompare(QString(t1), t2, actual, expected, file, line);
|
2011-04-27 10:05:43 +00:00
|
|
|
}
|
|
|
|
|
2013-01-19 10:52:03 +00:00
|
|
|
template <typename T>
|
|
|
|
inline bool qCompare(QList<T> const &t1, QList<T> const &t2, const char *actual, const char *expected,
|
|
|
|
const char *file, int line)
|
2011-04-27 10:05:43 +00:00
|
|
|
{
|
|
|
|
char msg[1024];
|
|
|
|
msg[0] = '\0';
|
|
|
|
bool isOk = true;
|
2011-12-14 06:36:10 +00:00
|
|
|
const int actualSize = t1.count();
|
|
|
|
const int expectedSize = t2.count();
|
|
|
|
if (actualSize != expectedSize) {
|
2013-01-19 10:52:03 +00:00
|
|
|
qsnprintf(msg, sizeof(msg), "Compared lists have different sizes.\n"
|
2014-01-21 00:03:30 +00:00
|
|
|
" Actual (%s) size: %d\n"
|
|
|
|
" Expected (%s) size: %d", actual, actualSize, expected, expectedSize);
|
2011-04-27 10:05:43 +00:00
|
|
|
isOk = false;
|
|
|
|
}
|
2011-12-14 06:36:10 +00:00
|
|
|
for (int i = 0; isOk && i < actualSize; ++i) {
|
2013-01-19 10:52:03 +00:00
|
|
|
if (!(t1.at(i) == t2.at(i))) {
|
2014-02-28 20:44:22 +00:00
|
|
|
char *val1 = toString(t1.at(i));
|
|
|
|
char *val2 = toString(t2.at(i));
|
|
|
|
|
2013-01-19 10:52:03 +00:00
|
|
|
qsnprintf(msg, sizeof(msg), "Compared lists differ at index %d.\n"
|
2014-01-21 00:03:30 +00:00
|
|
|
" Actual (%s): %s\n"
|
2014-02-28 20:44:22 +00:00
|
|
|
" Expected (%s): %s", i, actual, val1 ? val1 : "<null>",
|
|
|
|
expected, val2 ? val2 : "<null>");
|
2011-04-27 10:05:43 +00:00
|
|
|
isOk = false;
|
2014-02-28 20:44:22 +00:00
|
|
|
|
|
|
|
delete [] val1;
|
|
|
|
delete [] val2;
|
2011-04-27 10:05:43 +00:00
|
|
|
}
|
|
|
|
}
|
2017-09-18 09:49:52 +00:00
|
|
|
return compare_helper(isOk, msg, nullptr, nullptr, actual, expected, file, line);
|
2011-04-27 10:05:43 +00:00
|
|
|
}
|
|
|
|
|
2013-01-19 10:52:03 +00:00
|
|
|
template <>
|
|
|
|
inline bool qCompare(QStringList const &t1, QStringList const &t2, const char *actual, const char *expected,
|
|
|
|
const char *file, int line)
|
|
|
|
{
|
|
|
|
return qCompare<QString>(t1, t2, actual, expected, file, line);
|
|
|
|
}
|
|
|
|
|
2011-04-27 10:05:43 +00:00
|
|
|
template <typename T>
|
|
|
|
inline bool qCompare(QFlags<T> const &t1, T const &t2, const char *actual, const char *expected,
|
|
|
|
const char *file, int line)
|
|
|
|
{
|
|
|
|
return qCompare(int(t1), int(t2), actual, expected, file, line);
|
|
|
|
}
|
|
|
|
|
|
|
|
template <typename T>
|
|
|
|
inline bool qCompare(QFlags<T> const &t1, int const &t2, const char *actual, const char *expected,
|
|
|
|
const char *file, int line)
|
|
|
|
{
|
|
|
|
return qCompare(int(t1), t2, actual, expected, file, line);
|
|
|
|
}
|
|
|
|
|
2012-10-26 06:41:27 +00:00
|
|
|
template<>
|
|
|
|
inline bool qCompare(qint64 const &t1, qint32 const &t2, const char *actual,
|
|
|
|
const char *expected, const char *file, int line)
|
|
|
|
{
|
|
|
|
return qCompare(t1, static_cast<qint64>(t2), actual, expected, file, line);
|
|
|
|
}
|
|
|
|
|
|
|
|
template<>
|
|
|
|
inline bool qCompare(qint64 const &t1, quint32 const &t2, const char *actual,
|
|
|
|
const char *expected, const char *file, int line)
|
|
|
|
{
|
|
|
|
return qCompare(t1, static_cast<qint64>(t2), actual, expected, file, line);
|
|
|
|
}
|
|
|
|
|
|
|
|
template<>
|
|
|
|
inline bool qCompare(quint64 const &t1, quint32 const &t2, const char *actual,
|
|
|
|
const char *expected, const char *file, int line)
|
|
|
|
{
|
|
|
|
return qCompare(t1, static_cast<quint64>(t2), actual, expected, file, line);
|
|
|
|
}
|
|
|
|
|
|
|
|
template<>
|
|
|
|
inline bool qCompare(qint32 const &t1, qint64 const &t2, const char *actual,
|
|
|
|
const char *expected, const char *file, int line)
|
|
|
|
{
|
|
|
|
return qCompare(static_cast<qint64>(t1), t2, actual, expected, file, line);
|
|
|
|
}
|
|
|
|
|
|
|
|
template<>
|
|
|
|
inline bool qCompare(quint32 const &t1, qint64 const &t2, const char *actual,
|
|
|
|
const char *expected, const char *file, int line)
|
|
|
|
{
|
|
|
|
return qCompare(static_cast<qint64>(t1), t2, actual, expected, file, line);
|
|
|
|
}
|
|
|
|
|
|
|
|
template<>
|
|
|
|
inline bool qCompare(quint32 const &t1, quint64 const &t2, const char *actual,
|
|
|
|
const char *expected, const char *file, int line)
|
|
|
|
{
|
|
|
|
return qCompare(static_cast<quint64>(t1), t2, actual, expected, file, line);
|
|
|
|
}
|
|
|
|
|
2011-04-27 10:05:43 +00:00
|
|
|
}
|
|
|
|
QT_END_NAMESPACE
|
|
|
|
|
2015-04-28 11:40:26 +00:00
|
|
|
#ifdef QT_TESTCASE_BUILDDIR
|
|
|
|
# define QTEST_SET_MAIN_SOURCE_PATH QTest::setMainSourcePath(__FILE__, QT_TESTCASE_BUILDDIR);
|
|
|
|
#else
|
|
|
|
# define QTEST_SET_MAIN_SOURCE_PATH QTest::setMainSourcePath(__FILE__);
|
|
|
|
#endif
|
|
|
|
|
2011-04-27 10:05:43 +00:00
|
|
|
#define QTEST_APPLESS_MAIN(TestObject) \
|
|
|
|
int main(int argc, char *argv[]) \
|
|
|
|
{ \
|
|
|
|
TestObject tc; \
|
2015-04-28 11:40:26 +00:00
|
|
|
QTEST_SET_MAIN_SOURCE_PATH \
|
2011-04-27 10:05:43 +00:00
|
|
|
return QTest::qExec(&tc, argc, argv); \
|
|
|
|
}
|
|
|
|
|
|
|
|
#include <QtTest/qtestsystem.h>
|
2015-04-10 11:55:10 +00:00
|
|
|
#include <set>
|
|
|
|
|
|
|
|
#ifndef QT_NO_OPENGL
|
|
|
|
# define QTEST_ADD_GPU_BLACKLIST_SUPPORT_DEFS \
|
|
|
|
extern Q_TESTLIB_EXPORT std::set<QByteArray> *(*qgpu_features_ptr)(const QString &); \
|
|
|
|
extern Q_GUI_EXPORT std::set<QByteArray> *qgpu_features(const QString &);
|
|
|
|
# define QTEST_ADD_GPU_BLACKLIST_SUPPORT \
|
|
|
|
qgpu_features_ptr = qgpu_features;
|
|
|
|
#else
|
|
|
|
# define QTEST_ADD_GPU_BLACKLIST_SUPPORT_DEFS
|
|
|
|
# define QTEST_ADD_GPU_BLACKLIST_SUPPORT
|
|
|
|
#endif
|
2011-04-27 10:05:43 +00:00
|
|
|
|
2016-08-25 07:06:54 +00:00
|
|
|
#if defined(QT_NETWORK_LIB)
|
|
|
|
# include <QtTest/qtest_network.h>
|
|
|
|
#endif
|
|
|
|
|
2011-08-25 14:34:40 +00:00
|
|
|
#if defined(QT_WIDGETS_LIB)
|
2011-04-27 10:05:43 +00:00
|
|
|
|
2014-12-17 14:39:30 +00:00
|
|
|
#include <QtTest/qtest_widgets.h>
|
2011-04-27 10:05:43 +00:00
|
|
|
|
|
|
|
#ifdef QT_KEYPAD_NAVIGATION
|
|
|
|
# define QTEST_DISABLE_KEYPAD_NAVIGATION QApplication::setNavigationMode(Qt::NavigationModeNone);
|
|
|
|
#else
|
|
|
|
# define QTEST_DISABLE_KEYPAD_NAVIGATION
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#define QTEST_MAIN(TestObject) \
|
2015-04-10 11:55:10 +00:00
|
|
|
QT_BEGIN_NAMESPACE \
|
|
|
|
QTEST_ADD_GPU_BLACKLIST_SUPPORT_DEFS \
|
|
|
|
QT_END_NAMESPACE \
|
2011-04-27 10:05:43 +00:00
|
|
|
int main(int argc, char *argv[]) \
|
|
|
|
{ \
|
|
|
|
QApplication app(argc, argv); \
|
2012-01-11 10:49:35 +00:00
|
|
|
app.setAttribute(Qt::AA_Use96Dpi, true); \
|
2011-04-27 10:05:43 +00:00
|
|
|
QTEST_DISABLE_KEYPAD_NAVIGATION \
|
2015-04-10 11:55:10 +00:00
|
|
|
QTEST_ADD_GPU_BLACKLIST_SUPPORT \
|
2011-04-27 10:05:43 +00:00
|
|
|
TestObject tc; \
|
2015-04-28 11:40:26 +00:00
|
|
|
QTEST_SET_MAIN_SOURCE_PATH \
|
2011-04-27 10:05:43 +00:00
|
|
|
return QTest::qExec(&tc, argc, argv); \
|
|
|
|
}
|
|
|
|
|
2011-08-25 14:34:40 +00:00
|
|
|
#elif defined(QT_GUI_LIB)
|
|
|
|
|
|
|
|
#include <QtTest/qtest_gui.h>
|
|
|
|
|
|
|
|
#define QTEST_MAIN(TestObject) \
|
2015-04-10 11:55:10 +00:00
|
|
|
QT_BEGIN_NAMESPACE \
|
|
|
|
QTEST_ADD_GPU_BLACKLIST_SUPPORT_DEFS \
|
|
|
|
QT_END_NAMESPACE \
|
2011-08-25 14:34:40 +00:00
|
|
|
int main(int argc, char *argv[]) \
|
|
|
|
{ \
|
|
|
|
QGuiApplication app(argc, argv); \
|
2012-01-11 10:49:35 +00:00
|
|
|
app.setAttribute(Qt::AA_Use96Dpi, true); \
|
2015-04-10 11:55:10 +00:00
|
|
|
QTEST_ADD_GPU_BLACKLIST_SUPPORT \
|
2011-08-25 14:34:40 +00:00
|
|
|
TestObject tc; \
|
2015-04-28 11:40:26 +00:00
|
|
|
QTEST_SET_MAIN_SOURCE_PATH \
|
2011-08-25 14:34:40 +00:00
|
|
|
return QTest::qExec(&tc, argc, argv); \
|
|
|
|
}
|
|
|
|
|
2011-04-27 10:05:43 +00:00
|
|
|
#else
|
|
|
|
|
|
|
|
#define QTEST_MAIN(TestObject) \
|
|
|
|
int main(int argc, char *argv[]) \
|
|
|
|
{ \
|
|
|
|
QCoreApplication app(argc, argv); \
|
2012-01-11 10:49:35 +00:00
|
|
|
app.setAttribute(Qt::AA_Use96Dpi, true); \
|
2011-04-27 10:05:43 +00:00
|
|
|
TestObject tc; \
|
2015-04-28 11:40:26 +00:00
|
|
|
QTEST_SET_MAIN_SOURCE_PATH \
|
2011-04-27 10:05:43 +00:00
|
|
|
return QTest::qExec(&tc, argc, argv); \
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif // QT_GUI_LIB
|
|
|
|
|
2010-11-13 23:06:07 +00:00
|
|
|
#define QTEST_GUILESS_MAIN(TestObject) \
|
|
|
|
int main(int argc, char *argv[]) \
|
|
|
|
{ \
|
|
|
|
QCoreApplication app(argc, argv); \
|
2012-01-11 10:49:35 +00:00
|
|
|
app.setAttribute(Qt::AA_Use96Dpi, true); \
|
2010-11-13 23:06:07 +00:00
|
|
|
TestObject tc; \
|
2015-04-28 11:40:26 +00:00
|
|
|
QTEST_SET_MAIN_SOURCE_PATH \
|
2010-11-13 23:06:07 +00:00
|
|
|
return QTest::qExec(&tc, argc, argv); \
|
|
|
|
}
|
|
|
|
|
2011-04-27 10:05:43 +00:00
|
|
|
#endif
|