summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@nokia.com>2011-12-09 16:16:46 +0100
committerQt by Nokia <qt-info@nokia.com>2011-12-12 10:43:44 +0100
commitb9ebb65c77ea779d4abbf92e93b8bef5a41c84bc (patch)
tree707eb23727cdd7b549637fddb7d1e475bdd133e0 /src
parent77f41a68b30b93e95808b86fc9d36838e690c8cc (diff)
Revert "Remove unused overload of QTest::qExec."
The overload is used in Qt Creator (see src/libs/extensionsystem/pluginmanager.cpp). The use case here is an application whose internal QObjects can be tested by passing a command line parameter. For this use case, it is inconvenient to have to allocate memory and create a char argv[]- array. This reverts commit ad80d42f8eefd72d9297c272139acc70e24bfa13. Change-Id: I2a2f91e2840100fd62743f6d03b33005d67b18f8 Reviewed-by: Daniel Teske <daniel.teske@nokia.com> Reviewed-by: Jason McDonald <jason.mcdonald@nokia.com>
Diffstat (limited to 'src')
-rw-r--r--src/testlib/qtestcase.cpp28
-rw-r--r--src/testlib/qtestcase.h1
2 files changed, 29 insertions, 0 deletions
diff --git a/src/testlib/qtestcase.cpp b/src/testlib/qtestcase.cpp
index 608b2ca2ea..2ddb363888 100644
--- a/src/testlib/qtestcase.cpp
+++ b/src/testlib/qtestcase.cpp
@@ -1903,6 +1903,10 @@ FatalSignalHandler::~FatalSignalHandler()
test that was executed with qExec() can't run another test via qExec() and
threads are not allowed to call qExec() simultaneously.
+ If you have programatically created the arguments, as opposed to getting them
+ from the arguments in \c main(), it is likely of interest to use
+ QTest::qExec(QObject *, const QStringList &) since it is Unicode safe.
+
\sa QTEST_MAIN()
*/
@@ -2012,6 +2016,30 @@ int QTest::qExec(QObject *testObject, int argc, char **argv)
return qMin(QTestResult::failCount(), 127);
}
+/*!
+ \overload
+ \since 4.4
+
+ Behaves identically to qExec(QObject *, int, char**) but takes a
+ QStringList of \a arguments instead of a \c char** list.
+ */
+int QTest::qExec(QObject *testObject, const QStringList &arguments)
+{
+ const int argc = arguments.count();
+ QVarLengthArray<char *> argv(argc);
+
+ QVector<QByteArray> args;
+ args.reserve(argc);
+
+ for (int i = 0; i < argc; ++i)
+ {
+ args.append(arguments.at(i).toLocal8Bit().constData());
+ argv[i] = args.last().data();
+ }
+
+ return qExec(testObject, argc, argv.data());
+}
+
/*! \internal
*/
void QTest::qFail(const char *statementStr, const char *file, int line)
diff --git a/src/testlib/qtestcase.h b/src/testlib/qtestcase.h
index 091e9a8d96..dffbedab8e 100644
--- a/src/testlib/qtestcase.h
+++ b/src/testlib/qtestcase.h
@@ -180,6 +180,7 @@ namespace QTest
Q_TESTLIB_EXPORT char *toString(const void *);
Q_TESTLIB_EXPORT int qExec(QObject *testObject, int argc = 0, char **argv = 0);
+ Q_TESTLIB_EXPORT int qExec(QObject *testObject, const QStringList &arguments);
Q_TESTLIB_EXPORT bool qVerify(bool statement, const char *statementStr, const char *description,
const char *file, int line);