| Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/testlib/qsignaldumper.cpp |
| Switch to Source code | Preprocessed file |
| Line | Source | Count | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | - | |||||||||||||
| 2 | - | |||||||||||||
| 3 | - | |||||||||||||
| 4 | - | |||||||||||||
| 5 | - | |||||||||||||
| 6 | - | |||||||||||||
| 7 | namespace QTest | - | ||||||||||||
| 8 | { | - | ||||||||||||
| 9 | - | |||||||||||||
| 10 | inline static void qPrintMessage(const QByteArray &ba) | - | ||||||||||||
| 11 | { | - | ||||||||||||
| 12 | QTestLog::info(ba.constData(), 0, 0); | - | ||||||||||||
| 13 | } never executed: end of block | 0 | ||||||||||||
| 14 | - | |||||||||||||
| 15 | namespace { namespace Q_QGS_ignoreClasses { typedef QList<QByteArray> Type; QBasicAtomicInt guard = { QtGlobalStatic::Uninitialized }; __attribute__((visibility("hidden"))) inline Type *innerFunction() { struct HolderBase { ~HolderBase() noexcept { if (guard.load() == QtGlobalStatic::Initialized
never executed: }guard.store(QtGlobalStatic::Destroyed);never executed: }; static struct Holder : public HolderBase { Type value; Holder() noexcept(noexcept(Type ())) : value () { guard.store(QtGlobalStatic::Initialized); } } holder; returnend of blocknever executed: &holder.value;return &holder.value;never executed: } } } static QGlobalStatic<QList<QByteArray>, Q_QGS_ignoreClasses::innerFunction, Q_QGS_ignoreClasses::guard> ignoreClasses;return &holder.value; | 0 | ||||||||||||
| 16 | static int iLevel = 0; | - | ||||||||||||
| 17 | static int ignoreLevel = 0; | - | ||||||||||||
| 18 | enum { IndentSpacesCount = 4 }; | - | ||||||||||||
| 19 | - | |||||||||||||
| 20 | static void qSignalDumperCallback(QObject *caller, int signal_index, void **argv) | - | ||||||||||||
| 21 | { | - | ||||||||||||
| 22 | ((!(caller)) ? qt_assert("caller",__FILE__,63) : qt_noop()); ((!(argv)) ? qt_assert("argv",__FILE__,63) : qt_noop()); (void)argv;; | - | ||||||||||||
| 23 | const QMetaObject *mo = caller->metaObject(); | - | ||||||||||||
| 24 | ((!(mo)) ? qt_assert("mo",__FILE__,65) : qt_noop()); | - | ||||||||||||
| 25 | QMetaMethod member = QMetaObjectPrivate::signal(mo, signal_index); | - | ||||||||||||
| 26 | ((!(member.isValid())) ? qt_assert("member.isValid()",__FILE__,67) : qt_noop()); | - | ||||||||||||
| 27 | - | |||||||||||||
| 28 | if (QTest::ignoreClasses()
| 0 | ||||||||||||
| 29 | ++QTest::ignoreLevel; | - | ||||||||||||
| 30 | return; never executed: return; | 0 | ||||||||||||
| 31 | } | - | ||||||||||||
| 32 | - | |||||||||||||
| 33 | QByteArray str; | - | ||||||||||||
| 34 | str.fill(' ', QTest::iLevel++ * QTest::IndentSpacesCount); | - | ||||||||||||
| 35 | str += "Signal: "; | - | ||||||||||||
| 36 | str += mo->className(); | - | ||||||||||||
| 37 | str += '('; | - | ||||||||||||
| 38 | - | |||||||||||||
| 39 | QString objname = caller->objectName(); | - | ||||||||||||
| 40 | str += objname.toLocal8Bit(); | - | ||||||||||||
| 41 | if (!objname.isEmpty()
| 0 | ||||||||||||
| 42 | str += ' '; never executed: str += ' '; | 0 | ||||||||||||
| 43 | str += QByteArray::number(quintptr(caller), 16); | - | ||||||||||||
| 44 | - | |||||||||||||
| 45 | str += ") "; | - | ||||||||||||
| 46 | str += member.name(); | - | ||||||||||||
| 47 | str += " ("; | - | ||||||||||||
| 48 | - | |||||||||||||
| 49 | QList<QByteArray> args = member.parameterTypes(); | - | ||||||||||||
| 50 | for (int i = 0; i < args.count()
| 0 | ||||||||||||
| 51 | const QByteArray &arg = args.at(i); | - | ||||||||||||
| 52 | int typeId = QMetaType::type(args.at(i).constData()); | - | ||||||||||||
| 53 | if (arg.endsWith('*')
| 0 | ||||||||||||
| 54 | str += '('; | - | ||||||||||||
| 55 | str += arg; | - | ||||||||||||
| 56 | str += ')'; | - | ||||||||||||
| 57 | if (arg.endsWith('&')
| 0 | ||||||||||||
| 58 | str += '@'; never executed: str += '@'; | 0 | ||||||||||||
| 59 | - | |||||||||||||
| 60 | quintptr addr = quintptr(*reinterpret_cast<void **>(argv[i + 1])); | - | ||||||||||||
| 61 | str.append(QByteArray::number(addr, 16)); | - | ||||||||||||
| 62 | } never executed: else if (typeId != QMetaType::UnknownTypeend of block
| 0 | ||||||||||||
| 63 | ((!(typeId != QMetaType::Void)) ? qt_assert("typeId != QMetaType::Void",__FILE__,104) : qt_noop()); | - | ||||||||||||
| 64 | str.append(arg) | - | ||||||||||||
| 65 | .append('(') | - | ||||||||||||
| 66 | .append(QVariant(typeId, argv[i + 1]).toString().toLocal8Bit()) | - | ||||||||||||
| 67 | .append(')'); | - | ||||||||||||
| 68 | } never executed: end of block | 0 | ||||||||||||
| 69 | str.append(", "); | - | ||||||||||||
| 70 | } never executed: end of block | 0 | ||||||||||||
| 71 | if (str.endsWith(", ")
| 0 | ||||||||||||
| 72 | str.chop(2); never executed: str.chop(2); | 0 | ||||||||||||
| 73 | str.append(')'); | - | ||||||||||||
| 74 | qPrintMessage(str); | - | ||||||||||||
| 75 | } never executed: end of block | 0 | ||||||||||||
| 76 | - | |||||||||||||
| 77 | static void qSignalDumperCallbackSlot(QObject *caller, int method_index, void **argv) | - | ||||||||||||
| 78 | { | - | ||||||||||||
| 79 | ((!(caller)) ? qt_assert("caller",__FILE__,120) : qt_noop()); ((!(argv)) ? qt_assert("argv",__FILE__,120) : qt_noop()); (void)argv;; | - | ||||||||||||
| 80 | const QMetaObject *mo = caller->metaObject(); | - | ||||||||||||
| 81 | ((!(mo)) ? qt_assert("mo",__FILE__,122) : qt_noop()); | - | ||||||||||||
| 82 | QMetaMethod member = mo->method(method_index); | - | ||||||||||||
| 83 | if (!member.isValid()
| 0 | ||||||||||||
| 84 | return; never executed: return; | 0 | ||||||||||||
| 85 | - | |||||||||||||
| 86 | if (QTest::ignoreLevel
| 0 | ||||||||||||
| 87 | (QTest::ignoreClasses()
| 0 | ||||||||||||
| 88 | return; never executed: return; | 0 | ||||||||||||
| 89 | - | |||||||||||||
| 90 | QByteArray str; | - | ||||||||||||
| 91 | str.fill(' ', QTest::iLevel * QTest::IndentSpacesCount); | - | ||||||||||||
| 92 | str += "Slot: "; | - | ||||||||||||
| 93 | str += mo->className(); | - | ||||||||||||
| 94 | str += '('; | - | ||||||||||||
| 95 | - | |||||||||||||
| 96 | QString objname = caller->objectName(); | - | ||||||||||||
| 97 | str += objname.toLocal8Bit(); | - | ||||||||||||
| 98 | if (!objname.isEmpty()
| 0 | ||||||||||||
| 99 | str += ' '; never executed: str += ' '; | 0 | ||||||||||||
| 100 | str += QByteArray::number(quintptr(caller), 16); | - | ||||||||||||
| 101 | - | |||||||||||||
| 102 | str += ") "; | - | ||||||||||||
| 103 | str += member.methodSignature(); | - | ||||||||||||
| 104 | qPrintMessage(str); | - | ||||||||||||
| 105 | } never executed: end of block | 0 | ||||||||||||
| 106 | - | |||||||||||||
| 107 | static void qSignalDumperCallbackEndSignal(QObject *caller, int ) | - | ||||||||||||
| 108 | { | - | ||||||||||||
| 109 | ((!(caller)) ? qt_assert("caller",__FILE__,150) : qt_noop()); ((!(caller->metaObject())) ? qt_assert("caller->metaObject()",__FILE__,150) : qt_noop()); | - | ||||||||||||
| 110 | if (QTest::ignoreClasses()
| 0 | ||||||||||||
| 111 | && QTest::ignoreClasses()->contains(caller->metaObject()->className())
| 0 | ||||||||||||
| 112 | --QTest::ignoreLevel; | - | ||||||||||||
| 113 | ((!(QTest::ignoreLevel >= 0)) ? qt_assert("QTest::ignoreLevel >= 0",__FILE__,154) : qt_noop()); | - | ||||||||||||
| 114 | return; never executed: return; | 0 | ||||||||||||
| 115 | } | - | ||||||||||||
| 116 | --QTest::iLevel; | - | ||||||||||||
| 117 | ((!(QTest::iLevel >= 0)) ? qt_assert("QTest::iLevel >= 0",__FILE__,158) : qt_noop()); | - | ||||||||||||
| 118 | } never executed: end of block | 0 | ||||||||||||
| 119 | - | |||||||||||||
| 120 | } | - | ||||||||||||
| 121 | - | |||||||||||||
| 122 | void QSignalDumper::startDump() | - | ||||||||||||
| 123 | { | - | ||||||||||||
| 124 | static QSignalSpyCallbackSet set = { QTest::qSignalDumperCallback, | - | ||||||||||||
| 125 | QTest::qSignalDumperCallbackSlot, QTest::qSignalDumperCallbackEndSignal, 0 }; | - | ||||||||||||
| 126 | qt_register_signal_spy_callbacks(set); | - | ||||||||||||
| 127 | } never executed: end of block | 0 | ||||||||||||
| 128 | - | |||||||||||||
| 129 | void QSignalDumper::endDump() | - | ||||||||||||
| 130 | { | - | ||||||||||||
| 131 | static QSignalSpyCallbackSet nset = { 0, 0, 0 ,0 }; | - | ||||||||||||
| 132 | qt_register_signal_spy_callbacks(nset); | - | ||||||||||||
| 133 | } executed 1167 times by 541 tests: end of blockExecuted by:
| 1167 | ||||||||||||
| 134 | - | |||||||||||||
| 135 | void QSignalDumper::ignoreClass(const QByteArray &klass) | - | ||||||||||||
| 136 | { | - | ||||||||||||
| 137 | if (QTest::ignoreClasses()
| 0 | ||||||||||||
| 138 | QTest::ignoreClasses()->append(klass); never executed: QTest::ignoreClasses()->append(klass); | 0 | ||||||||||||
| 139 | } never executed: end of block | 0 | ||||||||||||
| 140 | - | |||||||||||||
| 141 | void QSignalDumper::clearIgnoredClasses() | - | ||||||||||||
| 142 | { | - | ||||||||||||
| 143 | if (QTest::ignoreClasses()
| 0 | ||||||||||||
| 144 | QTest::ignoreClasses()->clear(); never executed: QTest::ignoreClasses()->clear(); | 0 | ||||||||||||
| 145 | } never executed: end of block | 0 | ||||||||||||
| 146 | - | |||||||||||||
| 147 | - | |||||||||||||
| Switch to Source code | Preprocessed file |