summaryrefslogtreecommitdiffstats
path: root/src/testlib
diff options
context:
space:
mode:
Diffstat (limited to 'src/testlib')
-rw-r--r--src/testlib/qtest.h34
-rw-r--r--src/testlib/qtest_gui.h34
-rw-r--r--src/testlib/qtestcase.cpp2
3 files changed, 62 insertions, 8 deletions
diff --git a/src/testlib/qtest.h b/src/testlib/qtest.h
index 49a0c2104b..63e79c777f 100644
--- a/src/testlib/qtest.h
+++ b/src/testlib/qtest.h
@@ -108,43 +108,63 @@ template<> inline char *toString(const QDateTime &dateTime)
template<> inline char *toString(const QChar &c)
{
+ 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);
+ }
return qstrdup(qPrintable(QString::fromLatin1("QChar: '%1' (0x%2)").arg(c).arg(QString::number(static_cast<int>(c.unicode()), 16))));
}
template<> inline char *toString(const QPoint &p)
{
- return qstrdup(QString::fromLatin1("QPoint(%1,%2)").arg(p.x()).arg(p.y()).toLatin1().constData());
+ char msg[128] = {'\0'};
+ qsnprintf(msg, sizeof(msg), "QPoint(%d,%d)", p.x(), p.y());
+ return qstrdup(msg);
}
template<> inline char *toString(const QSize &s)
{
- return qstrdup(QString::fromLatin1("QSize(%1x%2)").arg(s.width()).arg(s.height()).toLatin1().constData());
+ char msg[128] = {'\0'};
+ qsnprintf(msg, sizeof(msg), "QSize(%dx%d)", s.width(), s.height());
+ return qstrdup(msg);
}
template<> inline char *toString(const QRect &s)
{
- return qstrdup(QString::fromLatin1("QRect(%1,%2 %5x%6) (bottomright %3,%4)").arg(s.left()).arg(s.top()).arg(s.right()).arg(s.bottom()).arg(s.width()).arg(s.height()).toLatin1().constData());
+ 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);
}
template<> inline char *toString(const QPointF &p)
{
- return qstrdup(QString::fromLatin1("QPointF(%1,%2)").arg(p.x()).arg(p.y()).toLatin1().constData());
+ char msg[64] = {'\0'};
+ qsnprintf(msg, sizeof(msg), "QPointF(%g,%g)", p.x(), p.y());
+ return qstrdup(msg);
}
template<> inline char *toString(const QSizeF &s)
{
- return qstrdup(QString::fromLatin1("QSizeF(%1x%2)").arg(s.width()).arg(s.height()).toLatin1().constData());
+ char msg[64] = {'\0'};
+ qsnprintf(msg, sizeof(msg), "QSizeF(%gx%g)", s.width(), s.height());
+ return qstrdup(msg);
}
template<> inline char *toString(const QRectF &s)
{
- return qstrdup(QString::fromLatin1("QRectF(%1,%2 %5x%6) (bottomright %3,%4)").arg(s.left()).arg(s.top()).arg(s.right()).arg(s.bottom()).arg(s.width()).arg(s.height()).toLatin1().constData());
+ 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);
}
template<> inline char *toString(const QUrl &uri)
{
if (!uri.isValid())
- return qstrdup(qPrintable(QStringLiteral("Invalid URL: ") + uri.errorString()));
+ return qstrdup(qPrintable(QLatin1String("Invalid URL: ") + uri.errorString()));
return qstrdup(uri.toEncoded().constData());
}
diff --git a/src/testlib/qtest_gui.h b/src/testlib/qtest_gui.h
index 5027aea732..d0d56e7bd0 100644
--- a/src/testlib/qtest_gui.h
+++ b/src/testlib/qtest_gui.h
@@ -58,6 +58,7 @@
#include <QtGui/qcolor.h>
#include <QtGui/qpixmap.h>
#include <QtGui/qimage.h>
+#include <QtGui/qregion.h>
#ifdef QT_WIDGETS_LIB
#include <QtGui/qicon.h>
@@ -82,6 +83,39 @@ template<> inline char *toString(const QColor &color)
return qstrdup(color.name().toLocal8Bit().constData());
}
+template<> inline char *toString(const QRegion &region)
+{
+ QByteArray result = "QRegion(";
+ if (region.isNull()) {
+ result += "null";
+ } else if (region.isEmpty()) {
+ result += "empty";
+ } else {
+ const QVector<QRect> &rects = region.rects();
+ const int rectCount = rects.size();
+ if (rectCount > 1) {
+ result += QByteArray::number(rectCount);
+ result += " rectangles, ";
+ }
+ for (int i = 0; i < rectCount; ++i) {
+ if (i)
+ result += ", ";
+ const QRect &r = rects.at(i);
+ result += QByteArray::number(r.width());
+ result += 'x';
+ result += QByteArray::number(r.height());
+ if (r.x() >= 0)
+ result += '+';
+ result += QByteArray::number(r.x());
+ if (r.y() >= 0)
+ result += '+';
+ result += QByteArray::number(r.y());
+ }
+ }
+ result += ')';
+ return qstrdup(result.constData());
+}
+
inline bool qCompare(QIcon const &t1, QIcon const &t2, const char *actual, const char *expected,
const char *file, int line)
{
diff --git a/src/testlib/qtestcase.cpp b/src/testlib/qtestcase.cpp
index b6c70fdd86..cfa7d1b8ca 100644
--- a/src/testlib/qtestcase.cpp
+++ b/src/testlib/qtestcase.cpp
@@ -958,7 +958,7 @@ bool TestMethods::invokeTest(int index, const char *data, WatchDog *watchDog) co
QBenchmarkTestMethodData::current = &benchmarkData;
const QByteArray &name = m_methods[index].name();
- QBenchmarkGlobalData::current->context.slotName = QLatin1String(name) + QStringLiteral("()");
+ QBenchmarkGlobalData::current->context.slotName = QLatin1String(name) + QLatin1String("()");
char member[512];
QTestTable table;