summaryrefslogtreecommitdiffstats
path: root/src/testlib
diff options
context:
space:
mode:
Diffstat (limited to 'src/testlib')
-rw-r--r--src/testlib/qabstracttestlogger_p.h7
-rw-r--r--src/testlib/qsignaldumper.cpp13
-rw-r--r--src/testlib/qsignalspy.h4
-rw-r--r--src/testlib/qtest.h6
-rw-r--r--src/testlib/qtest_global.h5
-rw-r--r--src/testlib/qtest_gui.h4
-rw-r--r--src/testlib/qtestcase.cpp40
-rw-r--r--src/testlib/qtestcase.h22
-rw-r--r--src/testlib/qtestresult.cpp9
-rw-r--r--src/testlib/qtestresult_p.h1
10 files changed, 23 insertions, 88 deletions
diff --git a/src/testlib/qabstracttestlogger_p.h b/src/testlib/qabstracttestlogger_p.h
index fcd2feeeb4..585ef0bc7f 100644
--- a/src/testlib/qabstracttestlogger_p.h
+++ b/src/testlib/qabstracttestlogger_p.h
@@ -55,6 +55,7 @@
#include <qglobal.h>
#include <stdio.h>
+#include <stdlib.h>
QT_BEGIN_NAMESPACE
@@ -116,7 +117,7 @@ struct QTestCharBuffer
inline ~QTestCharBuffer()
{
if (buf != staticBuf)
- qFree(buf);
+ free(buf);
}
inline char *data()
@@ -144,10 +145,10 @@ struct QTestCharBuffer
char *newBuf = 0;
if (buf == staticBuf) {
// if we point to our internal buffer, we need to malloc first
- newBuf = reinterpret_cast<char *>(qMalloc(newSize));
+ newBuf = reinterpret_cast<char *>(malloc(newSize));
} else {
// if we already malloc'ed, just realloc
- newBuf = reinterpret_cast<char *>(qRealloc(buf, newSize));
+ newBuf = reinterpret_cast<char *>(realloc(buf, newSize));
}
// if the allocation went wrong (newBuf == 0), we leave the object as is
diff --git a/src/testlib/qsignaldumper.cpp b/src/testlib/qsignaldumper.cpp
index 4fd870b644..2da4174e3a 100644
--- a/src/testlib/qsignaldumper.cpp
+++ b/src/testlib/qsignaldumper.cpp
@@ -64,12 +64,6 @@ static int iLevel = 0;
static int ignoreLevel = 0;
enum { IndentSpacesCount = 4 };
-static QByteArray memberName(const QMetaMethod &member)
-{
- QByteArray ba = member.signature();
- return ba.left(ba.indexOf('('));
-}
-
static void qSignalDumperCallback(QObject *caller, int method_index, void **argv)
{
Q_ASSERT(caller); Q_ASSERT(argv); Q_UNUSED(argv);
@@ -96,7 +90,7 @@ static void qSignalDumperCallback(QObject *caller, int method_index, void **argv
str += QByteArray::number(quintptr(caller), 16);
str += ") ";
- str += QTest::memberName(member);
+ str += member.name();
str += " (";
QList<QByteArray> args = member.parameterTypes();
@@ -112,7 +106,8 @@ static void qSignalDumperCallback(QObject *caller, int method_index, void **argv
quintptr addr = quintptr(*reinterpret_cast<void **>(argv[i + 1]));
str.append(QByteArray::number(addr, 16));
- } else if (typeId != QMetaType::Void) {
+ } else if (typeId != QMetaType::UnknownType) {
+ Q_ASSERT(typeId != QMetaType::Void); // void parameter => metaobject is corrupt
str.append(arg)
.append('(')
.append(QVariant(typeId, argv[i + 1]).toString().toLocal8Bit())
@@ -152,7 +147,7 @@ static void qSignalDumperCallbackSlot(QObject *caller, int method_index, void **
str += QByteArray::number(quintptr(caller), 16);
str += ") ";
- str += member.signature();
+ str += member.methodSignature();
qPrintMessage(str);
}
diff --git a/src/testlib/qsignalspy.h b/src/testlib/qsignalspy.h
index eb52ebf706..70944baadf 100644
--- a/src/testlib/qsignalspy.h
+++ b/src/testlib/qsignalspy.h
@@ -122,9 +122,11 @@ private:
QList<QByteArray> params = member.parameterTypes();
for (int i = 0; i < params.count(); ++i) {
int tp = QMetaType::type(params.at(i).constData());
- if (tp == QMetaType::Void)
+ if (tp == QMetaType::UnknownType) {
+ Q_ASSERT(tp != QMetaType::Void); // void parameter => metaobject is corrupt
qWarning("Don't know how to handle '%s', use qRegisterMetaType to register it.",
params.at(i).constData());
+ }
args << tp;
}
}
diff --git a/src/testlib/qtest.h b/src/testlib/qtest.h
index d167324aef..90705b3d40 100644
--- a/src/testlib/qtest.h
+++ b/src/testlib/qtest.h
@@ -142,7 +142,7 @@ template<> inline char *toString(const QRectF &s)
template<> inline char *toString(const QUrl &uri)
{
- return qstrdup(uri.toEncoded().constData());
+ return qstrdup(uri.toEncoded(QUrl::DecodeUnambiguousDelimiters).constData());
}
template<> inline char *toString(const QVariant &v)
@@ -169,17 +169,13 @@ template<> inline char *toString(const QVariant &v)
return qstrdup(vstring.constData());
}
-#ifndef QTEST_NO_SPECIALIZATIONS
template<>
-#endif
inline bool qCompare(QString const &t1, QLatin1String const &t2, const char *actual,
const char *expected, const char *file, int line)
{
return qCompare<QString>(t1, QString(t2), actual, expected, file, line);
}
-#ifndef QTEST_NO_SPECIALIZATIONS
template<>
-#endif
inline bool qCompare(QLatin1String const &t1, QString const &t2, const char *actual,
const char *expected, const char *file, int line)
{
diff --git a/src/testlib/qtest_global.h b/src/testlib/qtest_global.h
index 27a6801db9..b567fe7c00 100644
--- a/src/testlib/qtest_global.h
+++ b/src/testlib/qtest_global.h
@@ -59,11 +59,6 @@ QT_BEGIN_NAMESPACE
# endif
#endif
-#if defined (Q_CC_SUN) || defined (Q_CC_XLC)
-# define QTEST_NO_SPECIALIZATIONS
-#endif
-
-
#if (defined Q_CC_HPACC) && (defined __ia64)
# ifdef Q_TESTLIB_EXPORT
# undef Q_TESTLIB_EXPORT
diff --git a/src/testlib/qtest_gui.h b/src/testlib/qtest_gui.h
index f10ddd8473..24abd00e0f 100644
--- a/src/testlib/qtest_gui.h
+++ b/src/testlib/qtest_gui.h
@@ -88,9 +88,7 @@ inline bool qCompare(QIcon const &t1, QIcon const &t2, const char *actual, const
}
#endif
-#ifndef QTEST_NO_SPECIALIZATIONS
template<>
-#endif
inline bool qCompare(QImage const &t1, QImage const &t2,
const char *actual, const char *expected, const char *file, int line)
{
@@ -125,9 +123,7 @@ inline bool qCompare(QImage const &t1, QImage const &t2,
toString(t1), toString(t2), actual, expected, file, line);
}
-#ifndef QTEST_NO_SPECIALIZATIONS
template<>
-#endif
inline bool qCompare(QPixmap const &t1, QPixmap 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 a26fa71eb4..08dd4a9f80 100644
--- a/src/testlib/qtestcase.cpp
+++ b/src/testlib/qtestcase.cpp
@@ -1095,19 +1095,16 @@ int Q_TESTLIB_EXPORT defaultKeyDelay()
static bool isValidSlot(const QMetaMethod &sl)
{
- if (sl.access() != QMetaMethod::Private || !sl.parameterTypes().isEmpty()
- || qstrlen(sl.typeName()) || sl.methodType() != QMetaMethod::Slot)
+ if (sl.access() != QMetaMethod::Private || sl.parameterCount() != 0
+ || sl.returnType() != QMetaType::Void || sl.methodType() != QMetaMethod::Slot)
return false;
- const char *sig = sl.signature();
- int len = qstrlen(sig);
- if (len < 2)
+ QByteArray name = sl.name();
+ if (name.isEmpty())
return false;
- if (sig[len - 2] != '(' || sig[len - 1] != ')')
+ if (name.endsWith("_data"))
return false;
- if (len > 7 && strcmp(sig + (len - 7), "_data()") == 0)
- return false;
- if (strcmp(sig, "initTestCase()") == 0 || strcmp(sig, "cleanupTestCase()") == 0
- || strcmp(sig, "cleanup()") == 0 || strcmp(sig, "init()") == 0)
+ if (name == "initTestCase" || name == "cleanupTestCase"
+ || name == "cleanup" || name == "init")
return false;
return true;
}
@@ -1121,7 +1118,7 @@ static void qPrintTestSlots(FILE *stream)
for (int i = 0; i < QTest::currentTestObject->metaObject()->methodCount(); ++i) {
QMetaMethod sl = QTest::currentTestObject->metaObject()->method(i);
if (isValidSlot(sl))
- fprintf(stream, "%s\n", sl.signature());
+ fprintf(stream, "%s\n", sl.methodSignature().constData());
}
}
@@ -1146,7 +1143,7 @@ static void qPrintDataTags(FILE *stream)
// Retrieve local tags:
QStringList localTags;
QTestTable table;
- char *slot = qstrdup(tf.signature());
+ char *slot = qstrdup(tf.methodSignature().constData());
slot[strlen(slot) - 2] = '\0';
QByteArray member;
member.resize(qstrlen(slot) + qstrlen("_data()") + 1);
@@ -1818,7 +1815,7 @@ static void qInvokeTestMethods(QObject *testObject)
if (QTest::testFuncs) {
for (int i = 0; i != QTest::testFuncCount; i++) {
- if (!qInvokeTestMethod(metaObject->method(QTest::testFuncs[i].function()).signature(),
+ if (!qInvokeTestMethod(metaObject->method(QTest::testFuncs[i].function()).methodSignature().constData(),
QTest::testFuncs[i].data())) {
break;
}
@@ -1832,7 +1829,7 @@ static void qInvokeTestMethods(QObject *testObject)
for (int i = 0; i != methodCount; i++) {
if (!isValidSlot(testMethods[i]))
continue;
- if (!qInvokeTestMethod(testMethods[i].signature()))
+ if (!qInvokeTestMethod(testMethods[i].methodSignature().constData()))
break;
}
delete[] testMethods;
@@ -2440,21 +2437,6 @@ QObject *QTest::testObject()
}
/*! \internal
- */
-bool QTest::compare_helper(bool success, const char *msg, const char *file, int line)
-{
- static bool warned = false;
- if (!warned) {
- warned = true;
- QTest::qWarn("QTest::compare_helper(bool, const char *, const char *, int) is obsolete "
- "and will soon be removed. Please update your code to use the other "
- "version of this function.");
- }
-
- return QTestResult::compare(success, msg, file, line);
-}
-
-/*! \internal
This function is called by various specializations of QTest::qCompare
to decide whether to report a failure and to produce verbose test output.
diff --git a/src/testlib/qtestcase.h b/src/testlib/qtestcase.h
index a344736f7b..661aaa08e8 100644
--- a/src/testlib/qtestcase.h
+++ b/src/testlib/qtestcase.h
@@ -198,8 +198,6 @@ namespace QTest
Q_TESTLIB_EXPORT Qt::Key asciiToKey(char ascii);
Q_TESTLIB_EXPORT char keyToAscii(Qt::Key key);
- Q_TESTLIB_EXPORT bool compare_helper(bool success, const char *msg, const char *file,
- int line);
Q_TESTLIB_EXPORT bool compare_helper(bool success, const char *failureMsg,
char *val1, char *val2,
const char *actual, const char *expected,
@@ -256,7 +254,6 @@ namespace QTest
QTEST_COMPARE_DECL(bool)
#endif
-#ifndef QTEST_NO_SPECIALIZATIONS
template <typename T1, typename T2>
bool qCompare(T1 const &, T2 const &, const char *, const char *, const char *, int);
@@ -312,34 +309,17 @@ namespace QTest
{
return compare_string_helper(t1, t2, actual, expected, file, line);
}
-#else /* QTEST_NO_SPECIALIZATIONS */
- inline bool qCompare(const char *t1, const char *t2, const char *actual,
- const char *expected, const char *file, int line)
- {
- return compare_string_helper(t1, t2, actual, expected, file, line);
- }
-
- inline bool qCompare(char *t1, char *t2, const char *actual, const char *expected,
- const char *file, int line)
- {
- return compare_string_helper(t1, t2, actual, expected, file, line);
- }
-#endif
/* The next two specializations are for MSVC that shows problems with implicit
conversions
*/
-#ifndef QTEST_NO_SPECIALIZATIONS
template<>
-#endif
inline bool qCompare(char *t1, const char *t2, const char *actual,
const char *expected, const char *file, int line)
{
return compare_string_helper(t1, t2, actual, expected, file, line);
}
-#ifndef QTEST_NO_SPECIALIZATIONS
template<>
-#endif
inline bool qCompare(const char *t1, char *t2, const char *actual,
const char *expected, const char *file, int line)
{
@@ -347,9 +327,7 @@ namespace QTest
}
// NokiaX86 and RVCT do not like implicitly comparing bool with int
-#ifndef QTEST_NO_SPECIALIZATIONS
template <>
-#endif
inline bool qCompare(bool const &t1, int const &t2,
const char *actual, const char *expected, const char *file, int line)
{
diff --git a/src/testlib/qtestresult.cpp b/src/testlib/qtestresult.cpp
index 9d62a9eb57..15630de627 100644
--- a/src/testlib/qtestresult.cpp
+++ b/src/testlib/qtestresult.cpp
@@ -247,15 +247,6 @@ bool QTestResult::verify(bool statement, const char *statementStr,
return checkStatement(statement, msg, file, line);
}
-bool QTestResult::compare(bool success, const char *msg, const char *file, int line)
-{
- if (QTestLog::verboseLevel() >= 2) {
- QTestLog::info(msg, file, line);
- }
-
- return checkStatement(success, msg, file, line);
-}
-
bool QTestResult::compare(bool success, const char *failureMsg,
char *val1, char *val2,
const char *actual, const char *expected,
diff --git a/src/testlib/qtestresult_p.h b/src/testlib/qtestresult_p.h
index 1bf070f6cf..44294c3128 100644
--- a/src/testlib/qtestresult_p.h
+++ b/src/testlib/qtestresult_p.h
@@ -76,7 +76,6 @@ public:
static void reset();
static void addFailure(const char *message, const char *file, int line);
- static bool compare(bool success, const char *msg, const char *file, int line);
static bool compare(bool success, const char *failureMsg,
char *val1, char *val2,
const char *actual, const char *expected,