diff options
Diffstat (limited to 'src/testlib/qtest_gui.h')
-rw-r--r-- | src/testlib/qtest_gui.h | 57 |
1 files changed, 40 insertions, 17 deletions
diff --git a/src/testlib/qtest_gui.h b/src/testlib/qtest_gui.h index d0d56e7bd0..e5101e6955 100644 --- a/src/testlib/qtest_gui.h +++ b/src/testlib/qtest_gui.h @@ -59,10 +59,10 @@ #include <QtGui/qpixmap.h> #include <QtGui/qimage.h> #include <QtGui/qregion.h> - -#ifdef QT_WIDGETS_LIB +#include <QtGui/qvector2d.h> +#include <QtGui/qvector3d.h> +#include <QtGui/qvector4d.h> #include <QtGui/qicon.h> -#endif #if 0 // inform syncqt @@ -75,12 +75,9 @@ QT_BEGIN_NAMESPACE namespace QTest { -/*! - \internal - */ template<> inline char *toString(const QColor &color) { - return qstrdup(color.name().toLocal8Bit().constData()); + return qstrdup(color.name(QColor::HexArgb).toLocal8Bit().constData()); } template<> inline char *toString(const QRegion ®ion) @@ -91,8 +88,8 @@ template<> inline char *toString(const QRegion ®ion) } else if (region.isEmpty()) { result += "empty"; } else { - const QVector<QRect> &rects = region.rects(); - const int rectCount = rects.size(); + const auto rects = region.begin(); + const int rectCount = region.rectCount(); if (rectCount > 1) { result += QByteArray::number(rectCount); result += " rectangles, "; @@ -100,7 +97,7 @@ template<> inline char *toString(const QRegion ®ion) for (int i = 0; i < rectCount; ++i) { if (i) result += ", "; - const QRect &r = rects.at(i); + const QRect &r = rects[i]; result += QByteArray::number(r.width()); result += 'x'; result += QByteArray::number(r.height()); @@ -116,6 +113,32 @@ template<> inline char *toString(const QRegion ®ion) return qstrdup(result.constData()); } +#if !defined(QT_NO_VECTOR2D) || defined(Q_CLANG_QDOC) +template<> inline char *toString(const QVector2D &v) +{ + QByteArray result = "QVector2D(" + QByteArray::number(double(v.x())) + ", " + + QByteArray::number(double(v.y())) + ')'; + return qstrdup(result.constData()); +} +#endif // !QT_NO_VECTOR2D +#if !defined(QT_NO_VECTOR3D) || defined(Q_CLANG_QDOC) +template<> inline char *toString(const QVector3D &v) +{ + QByteArray result = "QVector3D(" + QByteArray::number(double(v.x())) + ", " + + QByteArray::number(double(v.y())) + ", " + QByteArray::number(double(v.z())) + ')'; + return qstrdup(result.constData()); +} +#endif // !QT_NO_VECTOR3D +#if !defined(QT_NO_VECTOR4D) || defined(Q_CLANG_QDOC) +template<> inline char *toString(const QVector4D &v) +{ + QByteArray result = "QVector4D(" + QByteArray::number(double(v.x())) + ", " + + QByteArray::number(double(v.y())) + ", " + QByteArray::number(double(v.z())) + + ", " + QByteArray::number(double(v.w())) + ')'; + return qstrdup(result.constData()); +} +#endif // !QT_NO_VECTOR4D + inline bool qCompare(QIcon const &t1, QIcon const &t2, const char *actual, const char *expected, const char *file, int line) { @@ -135,24 +158,24 @@ inline bool qCompare(QImage const &t1, QImage const &t2, qsnprintf(msg, 1024, "Compared QImages differ.\n" " Actual (%s).isNull(): %d\n" " Expected (%s).isNull(): %d", actual, t1Null, expected, t2Null); - return compare_helper(false, msg, Q_NULLPTR, Q_NULLPTR, actual, expected, file, line); + return compare_helper(false, msg, nullptr, nullptr, actual, expected, file, line); } if (t1Null && t2Null) - return compare_helper(true, Q_NULLPTR, Q_NULLPTR, Q_NULLPTR, actual, expected, file, line); + return compare_helper(true, nullptr, nullptr, nullptr, actual, expected, file, line); if (t1.width() != t2.width() || t1.height() != t2.height()) { qsnprintf(msg, 1024, "Compared QImages differ in size.\n" " Actual (%s): %dx%d\n" " Expected (%s): %dx%d", actual, t1.width(), t1.height(), expected, t2.width(), t2.height()); - return compare_helper(false, msg, Q_NULLPTR, Q_NULLPTR, actual, expected, file, line); + return compare_helper(false, msg, nullptr, nullptr, actual, expected, file, line); } if (t1.format() != t2.format()) { qsnprintf(msg, 1024, "Compared QImages differ in format.\n" " Actual (%s): %d\n" " Expected (%s): %d", actual, t1.format(), expected, t2.format()); - return compare_helper(false, msg, Q_NULLPTR, Q_NULLPTR, actual, expected, file, line); + return compare_helper(false, msg, nullptr, nullptr, actual, expected, file, line); } return compare_helper(t1 == t2, "Compared values are not the same", toString(t1), toString(t2), actual, expected, file, line); @@ -169,17 +192,17 @@ inline bool qCompare(QPixmap const &t1, QPixmap const &t2, const char *actual, c qsnprintf(msg, 1024, "Compared QPixmaps differ.\n" " Actual (%s).isNull(): %d\n" " Expected (%s).isNull(): %d", actual, t1Null, expected, t2Null); - return compare_helper(false, msg, Q_NULLPTR, Q_NULLPTR, actual, expected, file, line); + return compare_helper(false, msg, nullptr, nullptr, actual, expected, file, line); } if (t1Null && t2Null) - return compare_helper(true, Q_NULLPTR, Q_NULLPTR, Q_NULLPTR, actual, expected, file, line); + return compare_helper(true, nullptr, nullptr, nullptr, actual, expected, file, line); if (t1.width() != t2.width() || t1.height() != t2.height()) { qsnprintf(msg, 1024, "Compared QPixmaps differ in size.\n" " Actual (%s): %dx%d\n" " Expected (%s): %dx%d", actual, t1.width(), t1.height(), expected, t2.width(), t2.height()); - return compare_helper(false, msg, Q_NULLPTR, Q_NULLPTR, actual, expected, file, line); + return compare_helper(false, msg, nullptr, nullptr, actual, expected, file, line); } return qCompare(t1.toImage(), t2.toImage(), actual, expected, file, line); } |