From 3b1e9a7f9bb2825555db48d77b8ebaba810de3b1 Mon Sep 17 00:00:00 2001 From: Jason McDonald Date: Sat, 22 Feb 2014 17:15:09 +1000 Subject: Doc: Address some "No documentation for..." warnings in QTest Task-number: QTBUG-36985 Change-Id: I811b4711edc3420911fcd706ecef2d090f41bc89 Reviewed-by: Sergio Ahumada --- .../doc/snippets/code/src_qtestlib_qtestcase.cpp | 11 ++ src/testlib/qtestcase.cpp | 219 +++++++++++++++++++-- 2 files changed, 216 insertions(+), 14 deletions(-) (limited to 'src/testlib') diff --git a/src/testlib/doc/snippets/code/src_qtestlib_qtestcase.cpp b/src/testlib/doc/snippets/code/src_qtestlib_qtestcase.cpp index a17628155a..7bcae3bf74 100644 --- a/src/testlib/doc/snippets/code/src_qtestlib_qtestcase.cpp +++ b/src/testlib/doc/snippets/code/src_qtestlib_qtestcase.cpp @@ -260,5 +260,16 @@ void TestBenchmark::simple() } //! [27] +//! [28] +QTest::keyClick(myWindow, 'a'); +//! [28] + + +//! [29] +QTest::keyClick(myWindow, Qt::Key_Escape); + +QTest::keyClick(myWindow, Qt::Key_Escape, Qt::ShiftModifier, 200); +//! [29] + } diff --git a/src/testlib/qtestcase.cpp b/src/testlib/qtestcase.cpp index 6c1df8815c..f0520330af 100644 --- a/src/testlib/qtestcase.cpp +++ b/src/testlib/qtestcase.cpp @@ -567,8 +567,24 @@ QT_BEGIN_NAMESPACE \value MouseMove The mouse pointer has moved. */ -/*! \fn void QTest::keyClick(QWidget *widget, char key, Qt::KeyboardModifiers modifier = Qt::NoModifier, int delay=-1) +/*! \fn void QTest::keyClick(QWidget *widget, Qt::Key key, Qt::KeyboardModifiers modifier = Qt::NoModifier, int delay=-1) + + Simulates clicking of \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 clicking the key. + + Examples: + \snippet code/src_qtestlib_qtestcase.cpp 14 + + The first example above simulates clicking the \c escape key on \c + myWidget without any keyboard modifiers and without delay. The + second example simulates clicking \c shift-escape on \c myWidget + following a 200 ms delay of the test. + + \sa QTest::keyClicks() +*/ +/*! \fn void QTest::keyClick(QWidget *widget, char key, Qt::KeyboardModifiers modifier = Qt::NoModifier, int delay=-1) \overload Simulates clicking of \a key with an optional \a modifier on a \a widget. @@ -584,23 +600,42 @@ QT_BEGIN_NAMESPACE \sa QTest::keyClicks() */ -/*! \fn void QTest::keyClick(QWidget *widget, Qt::Key key, Qt::KeyboardModifiers modifier = Qt::NoModifier, int delay=-1) +/*! \fn void QTest::keyClick(QWindow *window, Qt::Key key, Qt::KeyboardModifiers modifier = Qt::NoModifier, int delay=-1) + \overload + \since 5.0 - Simulates clicking of \a key with an optional \a modifier on a \a widget. + Simulates clicking of \a key with an optional \a modifier on a \a window. If \a delay is larger than 0, the test will wait for \a delay milliseconds before clicking the key. Examples: - \snippet code/src_qtestlib_qtestcase.cpp 14 + \snippet code/src_qtestlib_qtestcase.cpp 29 The first example above simulates clicking the \c escape key on \c - myWidget without any keyboard modifiers and without delay. The - second example simulates clicking \c shift-escape on \c myWidget + myWindow without any keyboard modifiers and without delay. The + second example simulates clicking \c shift-escape on \c myWindow following a 200 ms delay of the test. \sa QTest::keyClicks() */ +/*! \fn void QTest::keyClick(QWindow *window, char key, Qt::KeyboardModifiers modifier = Qt::NoModifier, int delay=-1) + \overload + \since 5.0 + + Simulates clicking of \a key with an optional \a modifier on a \a window. + If \a delay is larger than 0, the test will wait for \a delay milliseconds + before clicking the key. + + Example: + \snippet code/src_qtestlib_qtestcase.cpp 28 + + The example above simulates clicking \c a on \c myWindow without + any keyboard modifiers and without delay of the test. + + \sa QTest::keyClicks() +*/ + /*! \fn void QTest::keyEvent(KeyAction action, QWidget *widget, Qt::Key key, Qt::KeyboardModifiers modifier = Qt::NoModifier, int delay=-1) Sends a Qt key event to \a widget with the given \a key and an associated \a action. @@ -609,13 +644,29 @@ QT_BEGIN_NAMESPACE */ /*! \fn void QTest::keyEvent(KeyAction action, QWidget *widget, char ascii, Qt::KeyboardModifiers modifier = Qt::NoModifier, int delay=-1) - \overload Sends a Qt key event to \a widget with the given key \a ascii and an associated \a action. Optionally, a keyboard \a modifier can be specified, as well as a \a delay (in milliseconds) of the test before sending the event. +*/ + +/*! \fn void QTest::keyEvent(KeyAction action, QWindow *window, Qt::Key key, Qt::KeyboardModifiers modifier = Qt::NoModifier, int delay=-1) + \overload + \since 5.0 + + Sends a Qt key event to \a window with the given \a key and an associated \a action. + Optionally, a keyboard \a modifier can be specified, as well as a \a delay + (in milliseconds) of the test before sending the event. +*/ +/*! \fn void QTest::keyEvent(KeyAction action, QWindow *window, char ascii, Qt::KeyboardModifiers modifier = Qt::NoModifier, int delay=-1) + \overload + \since 5.0 + + Sends a Qt key event to \a window with the given key \a ascii and an associated \a action. + Optionally, a keyboard \a modifier can be specified, as well as a \a delay + (in milliseconds) of the test before sending the event. */ /*! \fn void QTest::keyPress(QWidget *widget, Qt::Key key, Qt::KeyboardModifiers modifier = Qt::NoModifier, int delay=-1) @@ -629,7 +680,6 @@ QT_BEGIN_NAMESPACE */ /*! \fn void QTest::keyPress(QWidget *widget, char key, Qt::KeyboardModifiers modifier = Qt::NoModifier, int delay=-1) - \overload Simulates pressing a \a key with an optional \a modifier on a \a widget. @@ -641,6 +691,31 @@ QT_BEGIN_NAMESPACE \sa QTest::keyRelease(), QTest::keyClick() */ +/*! \fn void QTest::keyPress(QWindow *window, Qt::Key key, Qt::KeyboardModifiers modifier = Qt::NoModifier, int delay=-1) + \overload + \since 5.0 + + Simulates pressing a \a key with an optional \a modifier on a \a window. If \a delay + is larger than 0, the test will wait for \a delay milliseconds before pressing the key. + + \b {Note:} At some point you should release the key using \l keyRelease(). + + \sa QTest::keyRelease(), QTest::keyClick() +*/ + +/*! \fn void QTest::keyPress(QWindow *window, char key, Qt::KeyboardModifiers modifier = Qt::NoModifier, int delay=-1) + \overload + \since 5.0 + + Simulates pressing a \a key with an optional \a modifier on a \a window. + If \a delay is larger than 0, the test will wait for \a delay milliseconds + before pressing the key. + + \b {Note:} At some point you should release the key using \l keyRelease(). + + \sa QTest::keyRelease(), QTest::keyClick() +*/ + /*! \fn void QTest::keyRelease(QWidget *widget, Qt::Key key, Qt::KeyboardModifiers modifier = Qt::NoModifier, int delay=-1) Simulates releasing a \a key with an optional \a modifier on a \a widget. @@ -651,7 +726,6 @@ QT_BEGIN_NAMESPACE */ /*! \fn void QTest::keyRelease(QWidget *widget, char key, Qt::KeyboardModifiers modifier = Qt::NoModifier, int delay=-1) - \overload Simulates releasing a \a key with an optional \a modifier on a \a widget. @@ -661,6 +735,27 @@ QT_BEGIN_NAMESPACE \sa QTest::keyClick() */ +/*! \fn void QTest::keyRelease(QWindow *window, Qt::Key key, Qt::KeyboardModifiers modifier = Qt::NoModifier, int delay=-1) + \overload + \since 5.0 + + Simulates releasing a \a key with an optional \a modifier on a \a window. + If \a delay is larger than 0, the test will wait for \a delay milliseconds + before releasing the key. + + \sa QTest::keyPress(), QTest::keyClick() +*/ + +/*! \fn void QTest::keyRelease(QWindow *window, char key, Qt::KeyboardModifiers modifier = Qt::NoModifier, int delay=-1) + \overload + \since 5.0 + + Simulates releasing a \a key with an optional \a modifier on a \a window. + If \a delay is larger than 0, the test will wait for \a delay milliseconds + before releasing the key. + + \sa QTest::keyClick() +*/ /*! \fn void QTest::keyClicks(QWidget *widget, const QString &sequence, Qt::KeyboardModifiers modifier = Qt::NoModifier, int delay=-1) @@ -679,6 +774,18 @@ QT_BEGIN_NAMESPACE \sa QTest::keyClick() */ +/*! \fn void QTest::waitForEvents() + \internal +*/ + +/*! \fn void QTest::mouseEvent(MouseAction action, QWidget *widget, Qt::MouseButton button, Qt::KeyboardModifiers stateKey, QPoint pos, int delay=-1) + \internal +*/ + +/*! \fn void QTest::mouseEvent(MouseAction action, QWindow *window, Qt::MouseButton button, Qt::KeyboardModifiers stateKey, QPoint pos, int delay=-1) + \internal +*/ + /*! \fn void QTest::mousePress(QWidget *widget, Qt::MouseButton button, Qt::KeyboardModifiers modifier = 0, QPoint pos = QPoint(), int delay=-1) Simulates pressing a mouse \a button with an optional \a modifier @@ -690,6 +797,19 @@ QT_BEGIN_NAMESPACE \sa QTest::mouseRelease(), QTest::mouseClick() */ +/*! \fn void QTest::mousePress(QWindow *window, Qt::MouseButton button, Qt::KeyboardModifiers stateKey = 0, QPoint pos = QPoint(), int delay=-1) + \overload + \since 5.0 + + Simulates pressing a mouse \a button with an optional \a stateKey modifier + on a \a window. The position is defined by \a pos; the default + position is the center of the window. If \a delay is specified, + the test will wait for the specified amount of milliseconds before + the press. + + \sa QTest::mouseRelease(), QTest::mouseClick() +*/ + /*! \fn void QTest::mouseRelease(QWidget *widget, Qt::MouseButton button, Qt::KeyboardModifiers modifier = 0, QPoint pos = QPoint(), int delay=-1) Simulates releasing a mouse \a button with an optional \a modifier @@ -701,6 +821,19 @@ QT_BEGIN_NAMESPACE \sa QTest::mousePress(), QTest::mouseClick() */ +/*! \fn void QTest::mouseRelease(QWindow *window, Qt::MouseButton button, Qt::KeyboardModifiers stateKey = 0, QPoint pos = QPoint(), int delay=-1) + \overload + \since 5.0 + + Simulates releasing a mouse \a button with an optional \a stateKey modifier + on a \a window. The position of the release is defined by \a pos; + the default position is the center of the window. If \a delay is + specified, the test will wait for the specified amount of + milliseconds before releasing the button. + + \sa QTest::mousePress(), QTest::mouseClick() +*/ + /*! \fn void QTest::mouseClick(QWidget *widget, Qt::MouseButton button, Qt::KeyboardModifiers modifier = 0, QPoint pos = QPoint(), int delay=-1) Simulates clicking a mouse \a button with an optional \a modifier @@ -712,6 +845,19 @@ QT_BEGIN_NAMESPACE \sa QTest::mousePress(), QTest::mouseRelease() */ +/*! \fn void QTest::mouseClick(QWindow *window, Qt::MouseButton button, Qt::KeyboardModifiers stateKey = 0, QPoint pos = QPoint(), int delay=-1) + \overload + \since 5.0 + + Simulates clicking a mouse \a button with an optional \a stateKey modifier + on a \a window. The position of the click is defined by \a pos; + the default position is the center of the window. If \a delay is + specified, the test will wait for the specified amount of + milliseconds before pressing and before releasing the button. + + \sa QTest::mousePress(), QTest::mouseRelease() +*/ + /*! \fn void QTest::mouseDClick(QWidget *widget, Qt::MouseButton button, Qt::KeyboardModifiers modifier = 0, QPoint pos = QPoint(), int delay=-1) Simulates double clicking a mouse \a button with an optional \a @@ -723,6 +869,19 @@ QT_BEGIN_NAMESPACE \sa QTest::mouseClick() */ +/*! \fn void QTest::mouseDClick(QWindow *window, Qt::MouseButton button, Qt::KeyboardModifiers stateKey = 0, QPoint pos = QPoint(), int delay=-1) + \overload + \since 5.0 + + Simulates double clicking a mouse \a button with an optional \a stateKey + modifier on a \a window. The position of the click is defined by + \a pos; the default position is the center of the window. If \a + delay is specified, the test will wait for the specified amount of + milliseconds before each press and release. + + \sa QTest::mouseClick() +*/ + /*! \fn void QTest::mouseMove(QWidget *widget, QPoint pos = QPoint(), int delay=-1) Moves the mouse pointer to a \a widget. If \a pos is not @@ -731,6 +890,16 @@ QT_BEGIN_NAMESPACE moving the mouse pointer. */ +/*! \fn void QTest::mouseMove(QWindow *window, QPoint pos = QPoint(), int delay=-1) + \overload + \since 5.0 + + Moves the mouse pointer to a \a window. If \a pos is not + specified, the mouse pointer moves to the center of the window. If + a \a delay (in milliseconds) is given, the test will wait before + moving the mouse pointer. +*/ + /*! \fn char *QTest::toString(const T &value) @@ -2448,6 +2617,9 @@ static inline bool isWindowsBuildDirectory(const QString &dirName) } #endif +/*! \internal + */ + QString QTest::qFindTestData(const QString& base, const char *file, int line, const char *builddir) { QString found; @@ -2726,7 +2898,7 @@ bool QTest::compare_helper(bool success, const char *failureMsg, } /*! \fn bool QTest::qCompare(float const &t1, float const &t2, const char *actual, const char *expected, const char *file, int line) -\internal + \internal */ bool QTest::qCompare(float const &t1, float const &t2, const char *actual, const char *expected, const char *file, int line) @@ -2736,7 +2908,7 @@ bool QTest::qCompare(float const &t1, float const &t2, const char *actual, const } /*! \fn bool QTest::qCompare(double const &t1, double const &t2, const char *actual, const char *expected, const char *file, int line) -\internal + \internal */ bool QTest::qCompare(double const &t1, double const &t2, const char *actual, const char *expected, const char *file, int line) @@ -2745,6 +2917,14 @@ bool QTest::qCompare(double const &t1, double const &t2, const char *actual, con toString(t1), toString(t2), actual, expected, file, line); } +/*! \fn bool QTest::qCompare(double const &t1, float const &t2, const char *actual, const char *expected, const char *file, int line) + \internal + */ + +/*! \fn bool QTest::qCompare(float const &t1, double const &t2, const char *actual, const char *expected, const char *file, int line) + \internal + */ + #define TO_STRING_IMPL(TYPE, FORMAT) \ template <> Q_TESTLIB_EXPORT char *QTest::toString(const TYPE &t) \ { \ @@ -2807,12 +2987,11 @@ bool QTest::compare_string_helper(const char *t1, const char *t2, const char *ac \internal */ - -/*! \fn void QTest::mouseEvent(MouseAction action, QWidget *widget, Qt::MouseButton button, Qt::KeyboardModifiers stateKey, QPoint pos, int delay=-1) +/*! \fn bool QTest::qCompare(QIcon const &t1, QIcon const &t2, const char *actual, const char *expected, const char *file, int line) \internal */ -/*! \fn bool QTest::qCompare(QIcon const &t1, QIcon const &t2, const char *actual, const char *expected, const char *file, int line) +/*! \fn bool QTest::qCompare(QImage const &t1, QImage const &t2, const char *actual, const char *expected, const char *file, int line) \internal */ @@ -2916,12 +3095,24 @@ bool QTest::compare_string_helper(const char *t1, const char *t2, const char *ac \internal */ +/*! \fn void QTest::sendKeyEvent(KeyAction action, QWindow *window, Qt::Key code, QString text, Qt::KeyboardModifiers modifier, int delay=-1) + \internal +*/ + /*! \fn void QTest::sendKeyEvent(KeyAction action, QWidget *widget, Qt::Key code, char ascii, Qt::KeyboardModifiers modifier, int delay=-1) \internal */ +/*! \fn void QTest::sendKeyEvent(KeyAction action, QWindow *window, Qt::Key code, char ascii, Qt::KeyboardModifiers modifier, int delay=-1) + \internal +*/ + /*! \fn void QTest::simulateEvent(QWidget *widget, bool press, int code, Qt::KeyboardModifiers modifier, QString text, bool repeat, int delay=-1) \internal */ +/*! \fn void QTest::simulateEvent(QWindow *window, bool press, int code, Qt::KeyboardModifiers modifier, QString text, bool repeat, int delay=-1) + \internal +*/ + QT_END_NAMESPACE -- cgit v1.2.3