summaryrefslogtreecommitdiffstats
path: root/src/testlib
diff options
context:
space:
mode:
authorJoão Abecasis <joao.abecasis@nokia.com>2012-03-08 12:01:25 +0100
committerJoão Abecasis <joao.abecasis@nokia.com>2012-03-08 12:02:41 +0100
commit79f2480c868523a7d8ffc9fb15055e8eab3237ba (patch)
tree8336143e8c09810dc97324970fed61af27e26a97 /src/testlib
parent7e4f32993498db0e06346e32458a1ec7d0c7b3ec (diff)
parent12f221410fbe41d0b2efda4cd3289dfcf9044aa8 (diff)
Merge remote-tracking branch 'origin/api_changes' into containters
Conflicts: src/corelib/kernel/qmetaobject.cpp src/corelib/kernel/qvariant.cpp src/tools/moc/moc.h Change-Id: I2cd3d95b41d2636738c6b98064864941e3b0b4e6
Diffstat (limited to 'src/testlib')
-rw-r--r--src/testlib/qsignalspy.qdoc2
-rw-r--r--src/testlib/qtestcase.cpp52
-rw-r--r--src/testlib/qtestcase.h26
-rw-r--r--src/testlib/qtestdata.h8
-rw-r--r--src/testlib/qtestkeyboard.h12
5 files changed, 47 insertions, 53 deletions
diff --git a/src/testlib/qsignalspy.qdoc b/src/testlib/qsignalspy.qdoc
index 5fa3667d6b..dddaed74f6 100644
--- a/src/testlib/qsignalspy.qdoc
+++ b/src/testlib/qsignalspy.qdoc
@@ -48,7 +48,7 @@
\snippet doc/src/snippets/code/doc_src_qsignalspy.cpp 1
- \bold {Note:} Non-standard data types need to be registered, using
+ \b {Note:} Non-standard data types need to be registered, using
the qRegisterMetaType() function, before you can create a
QSignalSpy. For example:
diff --git a/src/testlib/qtestcase.cpp b/src/testlib/qtestcase.cpp
index d02f449d70..c1d19b8098 100644
--- a/src/testlib/qtestcase.cpp
+++ b/src/testlib/qtestcase.cpp
@@ -109,7 +109,7 @@ QT_BEGIN_NAMESPACE
true, execution continues. If not, a failure is recorded in the test log
and the test won't be executed further.
- \bold {Note:} This macro can only be used in a test function that is invoked
+ \b {Note:} This macro can only be used in a test function that is invoked
by the test framework.
Example:
@@ -246,7 +246,7 @@ QT_BEGIN_NAMESPACE
\c aString and \c expected are variables on the stack that are initialized with
the current test data.
- \bold {Note:} This macro can only be used in a test function that is invoked
+ \b {Note:} This macro can only be used in a test function that is invoked
by the test framework. The test function must have a _data function.
*/
@@ -266,7 +266,7 @@ QT_BEGIN_NAMESPACE
This macro can be used to force a test failure. The test stops
executing and the failure \a message is appended to the test log.
- \bold {Note:} This macro can only be used in a test function that is invoked
+ \b {Note:} This macro can only be used in a test function that is invoked
by the test framework.
Example:
@@ -316,7 +316,7 @@ QT_BEGIN_NAMESPACE
If called from initTestCase() or initTestCase_data(), the QSKIP() macro will
skip all test and _data functions.
- \bold {Note:} This macro can only be used in a test function or _data
+ \b {Note:} This macro can only be used in a test function or _data
function that is invoked by the test framework.
Example:
@@ -343,7 +343,7 @@ QT_BEGIN_NAMESPACE
\a mode is a \l QTest::TestFailMode and sets whether the test should
continue to execute or not.
- \bold {Note:} This macro can only be used in a test function that is invoked
+ \b {Note:} This macro can only be used in a test function that is invoked
by the test framework.
Example 1:
@@ -379,11 +379,11 @@ QT_BEGIN_NAMESPACE
resolves to an existing file or directory:
\list
- \o \a filename relative to QCoreApplication::applicationDirPath()
+ \li \a filename relative to QCoreApplication::applicationDirPath()
(only if a QCoreApplication or QApplication object has been created).
- \o \a filename relative to the test's standard install directory
+ \li \a filename relative to the test's standard install directory
(QLibraryInfo::TestsPath with the lowercased testcase name appended).
- \o \a filename relative to the directory containing the source file from which
+ \li \a filename relative to the directory containing the source file from which
QFINDTESTDATA is invoked.
\endlist
@@ -396,16 +396,16 @@ QT_BEGIN_NAMESPACE
The testdata file will be resolved as the first existing file from:
\list
- \o \c{/home/user/build/myxmlparser/tests/tst_myxmlparser/testxml/simple1.xml}
- \o \c{/usr/local/Qt-5.0.0/tests/tst_myxmlparser/testxml/simple1.xml}
- \o \c{/home/user/sources/myxmlparser/tests/tst_myxmlparser/testxml/simple1.xml}
+ \li \c{/home/user/build/myxmlparser/tests/tst_myxmlparser/testxml/simple1.xml}
+ \li \c{/usr/local/Qt-5.0.0/tests/tst_myxmlparser/testxml/simple1.xml}
+ \li \c{/home/user/sources/myxmlparser/tests/tst_myxmlparser/testxml/simple1.xml}
\endlist
This allows the test to find its testdata regardless of whether the
test has been installed, and regardless of whether the test's build tree
is equal to the test's source tree.
- \bold {Note:} reliable detection of testdata from the source directory requires
+ \b {Note:} reliable detection of testdata from the source directory requires
either that qmake is used, or the \c{QT_TESTCASE_BUILDDIR} macro is defined to
point to the working directory from which the compiler is invoked, or only
absolute paths to the source files are passed to the compiler. Otherwise, the
@@ -427,7 +427,7 @@ QT_BEGIN_NAMESPACE
Similarly, if qmake is used and the configuration includes \c{QT += gui}, then
\c QT_GUI_LIB will be defined automatically.
- \bold {Note:} On platforms that have keypad navigation enabled by default,
+ \b {Note:} On platforms that have keypad navigation enabled by default,
this macro will forcefully disable it if \c QT_WIDGETS_LIB is defined. This is done
to simplify the usage of key events when writing autotests. If you wish to write a
test case that uses keypad navigation, you should enable it either in the
@@ -597,7 +597,7 @@ QT_BEGIN_NAMESPACE
Simulates pressing a \a key with an optional \a modifier on a \a widget. If \a delay
is larger than 0, the test will wait for \a delay milliseconds before pressing the key.
- \bold {Note:} At some point you should release the key using \l keyRelease().
+ \b {Note:} At some point you should release the key using \l keyRelease().
\sa QTest::keyRelease(), QTest::keyClick()
*/
@@ -610,7 +610,7 @@ QT_BEGIN_NAMESPACE
If \a delay is larger than 0, the test will wait for \a delay milliseconds
before pressing the key.
- \bold {Note:} At some point you should release the key using \l keyRelease().
+ \b {Note:} At some point you should release the key using \l keyRelease().
\sa QTest::keyRelease(), QTest::keyClick()
*/
@@ -714,7 +714,7 @@ QT_BEGIN_NAMESPACE
You can add specializations of this function to your test to enable
verbose output.
- \bold {Note:} The caller of toString() must delete the returned data
+ \b {Note:} The caller of toString() must delete the returned data
using \c{delete[]}. Your implementation should return a string
created with \c{new[]} or qstrdup().
@@ -1192,11 +1192,13 @@ Q_TESTLIB_EXPORT void qtest_qParseArgs(int argc, char *argv[], bool qml)
" *** If no output file is specified, stdout is assumed.\n"
" *** If no output format is specified, -txt is assumed.\n"
"\n"
- " Detail options:\n"
- " -silent : Only output failures and fatal errors in plain text output\n"
- " -v1 : Print enter messages for each testfunction\n"
- " -v2 : Also print out each QVERIFY/QCOMPARE/QTEST\n"
- " -vs : Print every signal emitted\n"
+ " Test log detail options:\n"
+ " -silent : Log failures and fatal errors only\n"
+ " -v1 : Log the start of each testfunction\n"
+ " -v2 : Log each QVERIFY/QCOMPARE/QTEST (implies -v1)\n"
+ " -vs : Log every signal emission and resulting slot invocations\n"
+ "\n"
+ " *** The -silent and -v1 options only affect plain text output.\n"
"\n"
" Testing options:\n"
" -functions : Returns a list of current testfunctions\n"
@@ -2127,7 +2129,7 @@ void QTest::qWarn(const char *message, const char *file, int line)
test log. If the test finished and the \a message was not outputted,
a test failure is appended to the test log.
- \bold {Note:} Invoking this function will only ignore one message.
+ \b {Note:} Invoking this function will only ignore one message.
If the message you want to ignore is outputted twice, you have to
call ignoreMessage() twice, too.
@@ -2294,7 +2296,7 @@ void QTest::addColumnInternal(int id, const char *name)
Example:
\snippet doc/src/snippets/code/src_qtestlib_qtestcase.cpp 20
- \bold {Note:} This macro can only be used in a test's data function
+ \b {Note:} This macro can only be used in a test's data function
that is invoked by the test framework.
See \l {Chapter 2: Data Driven Testing}{Data Driven Testing} for
@@ -2327,7 +2329,7 @@ QTestData &QTest::newRow(const char *dataTag)
To add custom types to the testdata, the type must be registered with
QMetaType via \l Q_DECLARE_METATYPE().
- \bold {Note:} This macro can only be used in a test's data function
+ \b {Note:} This macro can only be used in a test's data function
that is invoked by the test framework.
See \l {Chapter 2: Data Driven Testing}{Data Driven Testing} for
@@ -2373,7 +2375,7 @@ bool QTest::currentTestFailed()
\a ms must be greater than 0.
- \bold {Note:} The qSleep() function calls either \c nanosleep() on
+ \b {Note:} The qSleep() function calls either \c nanosleep() on
unix or \c Sleep() on windows, so the accuracy of time spent in
qSleep() depends on the operating system.
diff --git a/src/testlib/qtestcase.h b/src/testlib/qtestcase.h
index e4f4020461..c64420b000 100644
--- a/src/testlib/qtestcase.h
+++ b/src/testlib/qtestcase.h
@@ -264,38 +264,20 @@ namespace QTest
template <typename T1, typename T2>
bool qCompare(T1 const &, T2 const &, const char *, const char *, const char *, int);
-#if defined(QT_COORD_TYPE) && (defined(Q_PROCESSOR_ARM) || defined(QT_NO_FPU) || defined(Q_OS_WINCE))
template <>
- inline bool qCompare<qreal, float>(qreal const &t1, float const &t2, const char *actual,
+ inline bool qCompare<double, float>(double const &t1, float const &t2, const char *actual,
const char *expected, const char *file, int line)
{
- return qCompare<qreal>(t1, qreal(t2), actual, expected, file, line);
+ return qCompare<qreal>(qreal(t1), qreal(t2), actual, expected, file, line);
}
template <>
- inline bool qCompare<float, qreal>(float const &t1, qreal const &t2, const char *actual,
+ inline bool qCompare<float, double>(float const &t1, double const &t2, const char *actual,
const char *expected, const char *file, int line)
{
- return qCompare<qreal>(qreal(t1), t2, actual, expected, file, line);
+ return qCompare<qreal>(qreal(t1), qreal(t2), actual, expected, file, line);
}
-#elif defined(QT_COORD_TYPE) || defined(Q_PROCESSOR_ARM) || defined(QT_NO_FPU) || defined(Q_OS_WINCE)
- template <>
- inline bool qCompare<qreal, double>(qreal const &t1, double const &t2, const char *actual,
- const char *expected, const char *file, int line)
- {
- return qCompare<float>(float(t1), float(t2), actual, expected, file, line);
- }
-
- template <>
- inline bool qCompare<double, qreal>(double const &t1, qreal const &t2, const char *actual,
- const char *expected, const char *file, int line)
- {
- return qCompare<float>(float(t1), float(t2), actual, expected, file, line);
- }
-
-#endif
-
template <typename T>
inline bool qCompare(const T *t1, const T *t2, const char *actual, const char *expected,
const char *file, int line)
diff --git a/src/testlib/qtestdata.h b/src/testlib/qtestdata.h
index 22dae76167..8849b15ddb 100644
--- a/src/testlib/qtestdata.h
+++ b/src/testlib/qtestdata.h
@@ -89,6 +89,14 @@ inline QTestData &operator<<(QTestData &data, const char * value)
return data;
}
+#ifdef QT_USE_QSTRINGBUILDER
+template<typename A, typename B>
+inline QTestData &operator<<(QTestData &data, const QStringBuilder<A, B> &value)
+{
+ return data << typename QConcatenable<QStringBuilder<A, B> >::ConvertTo(value);
+}
+#endif
+
QT_END_NAMESPACE
QT_END_HEADER
diff --git a/src/testlib/qtestkeyboard.h b/src/testlib/qtestkeyboard.h
index 897c732f45..5625bd606c 100644
--- a/src/testlib/qtestkeyboard.h
+++ b/src/testlib/qtestkeyboard.h
@@ -192,18 +192,20 @@ namespace QTest
if (!widget)
widget = QWidget::keyboardGrabber();
if (!widget) {
+ // Popup widgets stealthily steal the keyboard grab
+ if (QWidget *apw = QApplication::activePopupWidget())
+ widget = apw->focusWidget() ? apw->focusWidget() : apw;
+ }
+ if (!widget) {
QWindow *window = QGuiApplication::focusWindow();
if (window) {
sendKeyEvent(action, window, code, text, modifier, delay);
return;
}
-
- if (QWidget *apw = QApplication::activePopupWidget())
- widget = apw->focusWidget() ? apw->focusWidget() : apw;
- else
- widget = QApplication::focusWidget();
}
if (!widget)
+ widget = QApplication::focusWidget();
+ if (!widget)
widget = QApplication::activeWindow();
QTEST_ASSERT(widget);