qsignaldumper.cpp

Absolute File Name:/home/qt/qt5_coco/qt5/qtbase/src/testlib/qsignaldumper.cpp
Source codeSwitch to Preprocessed file
LineSourceCount
1/****************************************************************************-
2**-
3** Copyright (C) 2016 The Qt Company Ltd.-
4** Contact: https://www.qt.io/licensing/-
5**-
6** This file is part of the QtTest module of the Qt Toolkit.-
7**-
8** $QT_BEGIN_LICENSE:LGPL$-
9** Commercial License Usage-
10** Licensees holding valid commercial Qt licenses may use this file in-
11** accordance with the commercial license agreement provided with the-
12** Software or, alternatively, in accordance with the terms contained in-
13** a written agreement between you and The Qt Company. For licensing terms-
14** and conditions see https://www.qt.io/terms-conditions. For further-
15** information use the contact form at https://www.qt.io/contact-us.-
16**-
17** GNU Lesser General Public License Usage-
18** Alternatively, this file may be used under the terms of the GNU Lesser-
19** General Public License version 3 as published by the Free Software-
20** Foundation and appearing in the file LICENSE.LGPL3 included in the-
21** packaging of this file. Please review the following information to-
22** ensure the GNU Lesser General Public License version 3 requirements-
23** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.-
24**-
25** GNU General Public License Usage-
26** Alternatively, this file may be used under the terms of the GNU-
27** General Public License version 2.0 or (at your option) the GNU General-
28** Public license version 3 or any later version approved by the KDE Free-
29** Qt Foundation. The licenses are as published by the Free Software-
30** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3-
31** included in the packaging of this file. Please review the following-
32** information to ensure the GNU General Public License requirements will-
33** be met: https://www.gnu.org/licenses/gpl-2.0.html and-
34** https://www.gnu.org/licenses/gpl-3.0.html.-
35**-
36** $QT_END_LICENSE$-
37**-
38****************************************************************************/-
39-
40#include <QtTest/private/qsignaldumper_p.h>-
41-
42#include <QtCore/qlist.h>-
43#include <QtCore/qmetaobject.h>-
44#include <QtCore/qmetatype.h>-
45#include <QtCore/qobject.h>-
46#include <QtCore/qvariant.h>-
47-
48#include <QtTest/private/qtestlog_p.h>-
49-
50#include <QtCore/private/qmetaobject_p.h>-
51-
52QT_BEGIN_NAMESPACE-
53-
54namespace QTest-
55{-
56-
57inline static void qPrintMessage(const QByteArray &ba)-
58{-
59 QTestLog::info(ba.constData(), 0, 0);-
60}
never executed: end of block
0
61-
62Q_GLOBAL_STATIC(QList<QByteArray>, ignoreClasses)
never executed: end of block
never executed: guard.store(QtGlobalStatic::Destroyed);
never executed: return &holder.value;
guard.load() =...c::InitializedDescription
TRUEnever evaluated
FALSEnever evaluated
0
63static int iLevel = 0;-
64static int ignoreLevel = 0;-
65enum { IndentSpacesCount = 4 };-
66-
67static void qSignalDumperCallback(QObject *caller, int signal_index, void **argv)-
68{-
69 Q_ASSERT(caller); Q_ASSERT(argv); Q_UNUSED(argv);-
70 const QMetaObject *mo = caller->metaObject();-
71 Q_ASSERT(mo);-
72 QMetaMethod member = QMetaObjectPrivate::signal(mo, signal_index);-
73 Q_ASSERT(member.isValid());-
74-
75 if (QTest::ignoreClasses() && QTest::ignoreClasses()->contains(mo->className())) {
QTest::ignoreClasses()Description
TRUEnever evaluated
FALSEnever evaluated
QTest::ignoreC...->className())Description
TRUEnever evaluated
FALSEnever evaluated
0
76 ++QTest::ignoreLevel;-
77 return;
never executed: return;
0
78 }-
79-
80 QByteArray str;-
81 str.fill(' ', QTest::iLevel++ * QTest::IndentSpacesCount);-
82 str += "Signal: ";-
83 str += mo->className();-
84 str += '(';-
85-
86 QString objname = caller->objectName();-
87 str += objname.toLocal8Bit();-
88 if (!objname.isEmpty())
!objname.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
89 str += ' ';
never executed: str += ' ';
0
90 str += QByteArray::number(quintptr(caller), 16);-
91-
92 str += ") ";-
93 str += member.name();-
94 str += " (";-
95-
96 QList<QByteArray> args = member.parameterTypes();-
97 for (int i = 0; i < args.count(); ++i) {
i < args.count()Description
TRUEnever evaluated
FALSEnever evaluated
0
98 const QByteArray &arg = args.at(i);-
99 int typeId = QMetaType::type(args.at(i).constData());-
100 if (arg.endsWith('*') || arg.endsWith('&')) {
arg.endsWith('*')Description
TRUEnever evaluated
FALSEnever evaluated
arg.endsWith('&')Description
TRUEnever evaluated
FALSEnever evaluated
0
101 str += '(';-
102 str += arg;-
103 str += ')';-
104 if (arg.endsWith('&'))
arg.endsWith('&')Description
TRUEnever evaluated
FALSEnever evaluated
0
105 str += '@';
never executed: str += '@';
0
106-
107 quintptr addr = quintptr(*reinterpret_cast<void **>(argv[i + 1]));-
108 str.append(QByteArray::number(addr, 16));-
109 } else if (typeId != QMetaType::UnknownType) {
never executed: end of block
typeId != QMet...e::UnknownTypeDescription
TRUEnever evaluated
FALSEnever evaluated
0
110 Q_ASSERT(typeId != QMetaType::Void); // void parameter => metaobject is corrupt-
111 str.append(arg)-
112 .append('(')-
113 .append(QVariant(typeId, argv[i + 1]).toString().toLocal8Bit())-
114 .append(')');-
115 }
never executed: end of block
0
116 str.append(", ");-
117 }
never executed: end of block
0
118 if (str.endsWith(", "))
str.endsWith(", ")Description
TRUEnever evaluated
FALSEnever evaluated
0
119 str.chop(2);
never executed: str.chop(2);
0
120 str.append(')');-
121 qPrintMessage(str);-
122}
never executed: end of block
0
123-
124static void qSignalDumperCallbackSlot(QObject *caller, int method_index, void **argv)-
125{-
126 Q_ASSERT(caller); Q_ASSERT(argv); Q_UNUSED(argv);-
127 const QMetaObject *mo = caller->metaObject();-
128 Q_ASSERT(mo);-
129 QMetaMethod member = mo->method(method_index);-
130 if (!member.isValid())
!member.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
131 return;
never executed: return;
0
132-
133 if (QTest::ignoreLevel ||
QTest::ignoreLevelDescription
TRUEnever evaluated
FALSEnever evaluated
0
134 (QTest::ignoreClasses() && QTest::ignoreClasses()->contains(mo->className())))
QTest::ignoreClasses()Description
TRUEnever evaluated
FALSEnever evaluated
QTest::ignoreC...->className())Description
TRUEnever evaluated
FALSEnever evaluated
0
135 return;
never executed: return;
0
136-
137 QByteArray str;-
138 str.fill(' ', QTest::iLevel * QTest::IndentSpacesCount);-
139 str += "Slot: ";-
140 str += mo->className();-
141 str += '(';-
142-
143 QString objname = caller->objectName();-
144 str += objname.toLocal8Bit();-
145 if (!objname.isEmpty())
!objname.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
146 str += ' ';
never executed: str += ' ';
0
147 str += QByteArray::number(quintptr(caller), 16);-
148-
149 str += ") ";-
150 str += member.methodSignature();-
151 qPrintMessage(str);-
152}
never executed: end of block
0
153-
154static void qSignalDumperCallbackEndSignal(QObject *caller, int /*signal_index*/)-
155{-
156 Q_ASSERT(caller); Q_ASSERT(caller->metaObject());-
157 if (QTest::ignoreClasses()
QTest::ignoreClasses()Description
TRUEnever evaluated
FALSEnever evaluated
0
158 && QTest::ignoreClasses()->contains(caller->metaObject()->className())) {
QTest::ignoreC...->className())Description
TRUEnever evaluated
FALSEnever evaluated
0
159 --QTest::ignoreLevel;-
160 Q_ASSERT(QTest::ignoreLevel >= 0);-
161 return;
never executed: return;
0
162 }-
163 --QTest::iLevel;-
164 Q_ASSERT(QTest::iLevel >= 0);-
165}
never executed: end of block
0
166-
167}-
168-
169void QSignalDumper::startDump()-
170{-
171 static QSignalSpyCallbackSet set = { QTest::qSignalDumperCallback,-
172 QTest::qSignalDumperCallbackSlot, QTest::qSignalDumperCallbackEndSignal, 0 };-
173 qt_register_signal_spy_callbacks(set);-
174}
never executed: end of block
0
175-
176void QSignalDumper::endDump()-
177{-
178 static QSignalSpyCallbackSet nset = { 0, 0, 0 ,0 };-
179 qt_register_signal_spy_callbacks(nset);-
180}
executed 1238 times by 508 tests: end of block
Executed by:
  • tst_collections - unknown status
  • tst_compiler - unknown status
  • tst_gestures - unknown status
  • tst_lancelot - unknown status
  • tst_languagechange - unknown status
  • tst_largefile - unknown status
  • tst_modeltest - unknown status
  • tst_networkselftest - unknown status
  • tst_platformsocketengine - unknown status
  • tst_q_func_info - unknown status
  • tst_qabstractanimation - unknown status
  • tst_qabstractbutton - unknown status
  • tst_qabstractfileengine - unknown status
  • tst_qabstractitemmodel - unknown status
  • tst_qabstractitemview - unknown status
  • tst_qabstractnetworkcache - unknown status
  • tst_qabstractprintdialog - unknown status
  • tst_qabstractproxymodel - unknown status
  • tst_qabstractscrollarea - unknown status
  • tst_qabstractslider - unknown status
  • tst_qabstractsocket - unknown status
  • tst_qabstractspinbox - unknown status
  • tst_qabstracttextdocumentlayout - unknown status
  • tst_qaccessibility - unknown status
  • tst_qaction - unknown status
  • ...
1238
181-
182void QSignalDumper::ignoreClass(const QByteArray &klass)-
183{-
184 if (QTest::ignoreClasses())
QTest::ignoreClasses()Description
TRUEnever evaluated
FALSEnever evaluated
0
185 QTest::ignoreClasses()->append(klass);
never executed: QTest::ignoreClasses()->append(klass);
0
186}
never executed: end of block
0
187-
188void QSignalDumper::clearIgnoredClasses()-
189{-
190 if (QTest::ignoreClasses())
QTest::ignoreClasses()Description
TRUEnever evaluated
FALSEnever evaluated
0
191 QTest::ignoreClasses()->clear();
never executed: QTest::ignoreClasses()->clear();
0
192}
never executed: end of block
0
193-
194QT_END_NAMESPACE-
Source codeSwitch to Preprocessed file

Generated by Squish Coco Non-Commercial 4.3.0-BETA-master-30-08-2018-4cb69e9