From 3b03150aa2af76b13424c988c6c7892d19cce6c5 Mon Sep 17 00:00:00 2001 From: Topi Reinio Date: Wed, 12 Dec 2018 12:36:39 +0100 Subject: Doc: Restore documentation for QTest functions in other modules Qt Test library sources specific to Core, GUI and Widgets modules were moved around in commit 88867e39b. The new source locations must be referenced in Qt Test documentation configuration. The same sources are excluded in their original doc projects, and the related snippet file is moved over to qttestlib. The commit also fixes the remaining documentation issues for Qt Test. Change-Id: Ibe011aa83639e574d647f12bc9e53e618781bce6 Reviewed-by: Martin Smith --- src/corelib/doc/qtcore.qdocconf | 3 ++ .../code/src_corelib_kernel_qtestsupport_core.cpp | 52 ---------------------- src/corelib/kernel/qtestsupport_core.cpp | 6 +-- src/gui/doc/qtgui.qdocconf | 5 ++- src/gui/kernel/qtestsupport_gui.cpp | 10 ++--- src/testlib/doc/qttestlib.qdocconf | 8 ++++ .../code/src_corelib_kernel_qtestsupport_core.cpp | 52 ++++++++++++++++++++++ src/testlib/qtestcase.qdoc | 22 +++++++++ src/widgets/doc/qtwidgets.qdocconf | 3 ++ src/widgets/kernel/qtestsupport_widgets.cpp | 17 ++++--- 10 files changed, 106 insertions(+), 72 deletions(-) delete mode 100644 src/corelib/doc/snippets/code/src_corelib_kernel_qtestsupport_core.cpp create mode 100644 src/testlib/doc/snippets/code/src_corelib_kernel_qtestsupport_core.cpp (limited to 'src') diff --git a/src/corelib/doc/qtcore.qdocconf b/src/corelib/doc/qtcore.qdocconf index 5a42e21845..85dcde4607 100644 --- a/src/corelib/doc/qtcore.qdocconf +++ b/src/corelib/doc/qtcore.qdocconf @@ -45,6 +45,9 @@ excludedirs += snippets excludefiles += ../../../examples/widgets/tools/customcompleter/doc/src/customcompleter.qdoc \ ../../../examples/widgets/tools/codecs/doc/src/codecs.qdoc +# Included in qttestlib.qdocconf instead +excludefiles += ../kernel/qtestsupport_core.cpp + manifestmeta.highlighted.names = "QtCore/JSON Save Game Example" \ "QtCore/Local Fortune*" diff --git a/src/corelib/doc/snippets/code/src_corelib_kernel_qtestsupport_core.cpp b/src/corelib/doc/snippets/code/src_corelib_kernel_qtestsupport_core.cpp deleted file mode 100644 index ed3e9bd0c0..0000000000 --- a/src/corelib/doc/snippets/code/src_corelib_kernel_qtestsupport_core.cpp +++ /dev/null @@ -1,52 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2018 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtTest module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//! [0] - MyObject obj; - obj.startup(); - QTest::qWaitFor([&]() { - return obj.isReady(); - }, 3000); -//! [0] - -//! [1] - int i = 0; - while (myNetworkServerNotResponding() && i++ < 50) - QTest::qWait(250); -//! [1] diff --git a/src/corelib/kernel/qtestsupport_core.cpp b/src/corelib/kernel/qtestsupport_core.cpp index d69551a227..aba2a136a1 100644 --- a/src/corelib/kernel/qtestsupport_core.cpp +++ b/src/corelib/kernel/qtestsupport_core.cpp @@ -59,8 +59,7 @@ Q_CORE_EXPORT void QTestPrivate::qSleep(int ms) #endif } -/*! \fn template bool qWaitFor(Functor predicate, int timeout) - \relates QTest +/*! \fn template bool QTest::qWaitFor(Functor predicate, int timeout) Waits for \a timeout milliseconds or until the \a predicate returns true. @@ -77,8 +76,7 @@ Q_CORE_EXPORT void QTestPrivate::qSleep(int ms) */ -/*! \fn void qWait(int ms) - \relates QTest +/*! \fn void QTest::qWait(int ms) Waits for \a ms milliseconds. While waiting, events will be processed and your test will stay responsive to user interface events or network communication. diff --git a/src/gui/doc/qtgui.qdocconf b/src/gui/doc/qtgui.qdocconf index e546c817a7..b8b8a00cd6 100644 --- a/src/gui/doc/qtgui.qdocconf +++ b/src/gui/doc/qtgui.qdocconf @@ -54,7 +54,10 @@ exampledirs += ../../../examples/gui \ imagedirs += images \ ../../../examples/gui/doc/images \ - ../../../doc/src/images \ + ../../../doc/src/images + +# Included in qttestlib.qdocconf instead +excludefiles += ../kernel/qtestsupport_gui.cpp manifestmeta.highlighted.names = "QtGui/Analog Clock Window Example" diff --git a/src/gui/kernel/qtestsupport_gui.cpp b/src/gui/kernel/qtestsupport_gui.cpp index 56e0eb52b3..8a6f662274 100644 --- a/src/gui/kernel/qtestsupport_gui.cpp +++ b/src/gui/kernel/qtestsupport_gui.cpp @@ -44,23 +44,21 @@ QT_BEGIN_NAMESPACE -/*! \fn bool qWaitForWindowActive(QWindow *window, int timeout) - \relates QTest +/*! \since 5.0 Waits for \a timeout milliseconds or until the \a window is active. Returns \c true if \c window is active within \a timeout milliseconds, otherwise returns \c false. - \sa QTest::qWaitForWindowExposed(), QWindow::isActive() + \sa qWaitForWindowExposed(), QWindow::isActive() */ Q_GUI_EXPORT bool QTest::qWaitForWindowActive(QWindow *window, int timeout) { return QTest::qWaitFor([&]() { return window->isActive(); }, timeout); } -/*! \fn bool qWaitForWindowExposed(QWindow *window, int timeout) - \relates QTest +/*! \since 5.0 Waits for \a timeout milliseconds or until the \a window is exposed. @@ -73,7 +71,7 @@ Q_GUI_EXPORT bool QTest::qWaitForWindowActive(QWindow *window, int timeout) area is completely covered by other windows, or if the window is otherwise not visible. This function will then time out when waiting for such a window. - \sa QTest::qWaitForWindowActive(), QWindow::isExposed() + \sa qWaitForWindowActive(), QWindow::isExposed() */ Q_GUI_EXPORT bool QTest::qWaitForWindowExposed(QWindow *window, int timeout) { diff --git a/src/testlib/doc/qttestlib.qdocconf b/src/testlib/doc/qttestlib.qdocconf index 1fdb136e78..93a5ab393c 100644 --- a/src/testlib/doc/qttestlib.qdocconf +++ b/src/testlib/doc/qttestlib.qdocconf @@ -31,8 +31,16 @@ depends += qtcore qtdoc qtwidgets qtgui qmake qtquick headerdirs += .. +headers += ../../corelib/kernel/qtestsupport_core.h \ + ../../gui/kernel/qtestsupport_gui.h \ + ../../widgets/kernel/qtestsupport_widgets.h + sourcedirs += .. +sources += ../../corelib/kernel/qtestsupport_core.cpp \ + ../../gui/kernel/qtestsupport_gui.cpp \ + ../../widgets/kernel/qtestsupport_widgets.cpp + exampledirs += ../../../examples/qtestlib \ ../ \ snippets diff --git a/src/testlib/doc/snippets/code/src_corelib_kernel_qtestsupport_core.cpp b/src/testlib/doc/snippets/code/src_corelib_kernel_qtestsupport_core.cpp new file mode 100644 index 0000000000..ed3e9bd0c0 --- /dev/null +++ b/src/testlib/doc/snippets/code/src_corelib_kernel_qtestsupport_core.cpp @@ -0,0 +1,52 @@ +/**************************************************************************** +** +** Copyright (C) 2018 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtTest module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +//! [0] + MyObject obj; + obj.startup(); + QTest::qWaitFor([&]() { + return obj.isReady(); + }, 3000); +//! [0] + +//! [1] + int i = 0; + while (myNetworkServerNotResponding() && i++ < 50) + QTest::qWait(250); +//! [1] diff --git a/src/testlib/qtestcase.qdoc b/src/testlib/qtestcase.qdoc index ad9776f7ec..b00c9e51cd 100644 --- a/src/testlib/qtestcase.qdoc +++ b/src/testlib/qtestcase.qdoc @@ -994,6 +994,22 @@ \sa QTest::toHexRepresentation() */ +/*! + \fn char *QTest::toString(const QCborError &c) + \overload + \since 5.12 + + Returns a textual representation of the given CBOR error \a c. +*/ + +/*! + \fn template char *QTest::toString(const std::tuple &tuple) + \overload + \since 5.12 + + Returns a textual representation of the given \a tuple. +*/ + /*! \fn char *QTest::toString(const QTime &time) \overload @@ -1112,6 +1128,12 @@ Returns a textual representation of size policy \a sp. */ +/*! + \fn template char *QTest::toString(const Tuple &tuple, QtPrivate::IndexesList ) + \internal + \since 5.12 +*/ + /*! \fn QTouchDevice *QTest::createTouchDevice(QTouchDevice::DeviceType devType = QTouchDevice::TouchScreen) \since 5.8 diff --git a/src/widgets/doc/qtwidgets.qdocconf b/src/widgets/doc/qtwidgets.qdocconf index 4700ee29bf..5d7262fca1 100644 --- a/src/widgets/doc/qtwidgets.qdocconf +++ b/src/widgets/doc/qtwidgets.qdocconf @@ -40,6 +40,9 @@ exampledirs += ../../../examples/widgets \ excludedirs += snippets +# Included in qttestlib.qdocconf instead +excludefiles += ../kernel/qtestsupport_widgets.cpp + imagedirs += images \ ../../../doc/src/images \ ../../../examples/widgets/doc/images \ diff --git a/src/widgets/kernel/qtestsupport_widgets.cpp b/src/widgets/kernel/qtestsupport_widgets.cpp index b227e6ff5d..0056bebdc6 100644 --- a/src/widgets/kernel/qtestsupport_widgets.cpp +++ b/src/widgets/kernel/qtestsupport_widgets.cpp @@ -46,15 +46,14 @@ QT_BEGIN_NAMESPACE -/*! \fn bool qWaitForWindowActive(QWidget *widget, int timeout) - \relates QTest +/*! \since 5.0 Waits for \a timeout milliseconds or until the \a widget's window is active. Returns \c true if \c widget's window is active within \a timeout milliseconds, otherwise returns \c false. - \sa QTest::qWaitForWindowExposed(), QWidget::isActiveWindow() + \sa qWaitForWindowExposed(), QWidget::isActiveWindow() */ Q_WIDGETS_EXPORT Q_REQUIRED_RESULT bool QTest::qWaitForWindowActive(QWidget *widget, int timeout) { @@ -63,8 +62,7 @@ Q_WIDGETS_EXPORT Q_REQUIRED_RESULT bool QTest::qWaitForWindowActive(QWidget *wid return false; } -/*! \fn bool qWaitForWindowExposed(QWidget *widget, int timeout) - \relates QTest +/*! \since 5.0 Waits for \a timeout milliseconds or until the \a widget's window is exposed. @@ -80,7 +78,7 @@ Q_WIDGETS_EXPORT Q_REQUIRED_RESULT bool QTest::qWaitForWindowActive(QWidget *wid A specific configuration where this happens is when using QGLWidget as a viewport widget on macOS: The viewport widget gets the expose event, not the parent widget. - \sa QTest::qWaitForWindowActive() + \sa qWaitForWindowActive() */ Q_WIDGETS_EXPORT Q_REQUIRED_RESULT bool QTest::qWaitForWindowExposed(QWidget *widget, int timeout) { @@ -89,11 +87,12 @@ Q_WIDGETS_EXPORT Q_REQUIRED_RESULT bool QTest::qWaitForWindowExposed(QWidget *wi return false; } -/*! \fn bool qWaitForWindowShown(QWidget *widget, int timeout) - \relates QTest +/*! \fn bool QTest::qWaitForWindowShown(QWidget *widget, int timeout) \since 5.0 \deprecated + Use qWaitForWindowExposed() instead. + Waits for \a timeout milliseconds or until the \a widget's window is exposed. Returns \c true if \c widget's window is exposed within \a timeout milliseconds, otherwise returns \c false. @@ -107,7 +106,7 @@ Q_WIDGETS_EXPORT Q_REQUIRED_RESULT bool QTest::qWaitForWindowExposed(QWidget *wi QTest::qWaitForWindowShown(&widget); \endcode - \sa QTest::qWaitForWindowActive(), QTest::qWaitForWindowExposed() + \sa qWaitForWindowActive(), qWaitForWindowExposed() */ QT_END_NAMESPACE -- cgit v1.2.3