From 3478f6c4474e86f2431c22533dbffefb48af93a9 Mon Sep 17 00:00:00 2001 From: Leena Miettinen Date: Fri, 11 Oct 2019 16:30:33 +0200 Subject: Doc: Describe using QVERIFY to verify validity of QSignalSpy From https://wiki.qt.io/Writing_Unit_Tests Change-Id: I3186efe30cde465766800aee1f0a530fb80907fb Reviewed-by: Edward Welbourne --- src/testlib/qsignalspy.qdoc | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'src/testlib') diff --git a/src/testlib/qsignalspy.qdoc b/src/testlib/qsignalspy.qdoc index 3352307d69..39639d0a09 100644 --- a/src/testlib/qsignalspy.qdoc +++ b/src/testlib/qsignalspy.qdoc @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. +** Copyright (C) 2019 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the documentation of the Qt Toolkit. @@ -48,7 +48,7 @@ \snippet code/doc_src_qsignalspy.cpp 1 - \b {Note:} Non-standard data types need to be registered, using + \note Non-standard data types need to be registered, using the qRegisterMetaType() function, before you can create a QSignalSpy. For example: @@ -57,6 +57,18 @@ To retrieve the instance, you can use qvariant_cast: \snippet code/doc_src_qsignalspy.cpp 3 + + \section1 Verifying Signal Emissions + + The QSignalSpy class provides an elegant mechanism for capturing the list + of signals emitted by an object. However, you should verify its validity + after construction. The constructor does a number of sanity checks, such as + verifying that the signal to be spied upon actually exists. To make the + diagnosis of test failures easier, the results of these checks should be + checked by calling \c QVERIFY(spy.isValid()) before proceeding further with + a test. + + \sa QVERIFY() */ /*! \fn QSignalSpy::QSignalSpy(const QObject *object, const char *signal) -- cgit v1.2.3