diff options
author | Ulf Hermann <ulf.hermann@qt.io> | 2018-06-06 10:18:23 +0200 |
---|---|---|
committer | Ulf Hermann <ulf.hermann@qt.io> | 2018-06-22 15:17:40 +0000 |
commit | 1916a25aaf57df9036783addc6d5af4aebfacd27 (patch) | |
tree | 3dc789c870b3af0281bfd453f67a7888bf9e6fd6 | |
parent | 769bc094a6a74adc1bc34dc1a31522cfa590c0a7 (diff) |
Tests: Guard against corner cases in profiler service test
If the process fails to start, the debug client isn't available and we
shouldn't access it then.
Change-Id: Ifddbbfeb92b1583345a5f4c954dca5920a0cc53b
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
-rw-r--r-- | tests/auto/qml/debugger/qqmlprofilerservice/tst_qqmlprofilerservice.cpp | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/tests/auto/qml/debugger/qqmlprofilerservice/tst_qqmlprofilerservice.cpp b/tests/auto/qml/debugger/qqmlprofilerservice/tst_qqmlprofilerservice.cpp index 624e488c91..323048f7d8 100644 --- a/tests/auto/qml/debugger/qqmlprofilerservice/tst_qqmlprofilerservice.cpp +++ b/tests/auto/qml/debugger/qqmlprofilerservice/tst_qqmlprofilerservice.cpp @@ -284,6 +284,7 @@ void tst_QQmlProfilerService::checkTraceReceived() void tst_QQmlProfilerService::checkJsHeap() { + QVERIFY(m_client); QVERIFY2(m_client->jsHeapMessages.count() > 0, "no JavaScript heap messages received"); bool seen_alloc = false; @@ -342,6 +343,11 @@ bool tst_QQmlProfilerService::verify(tst_QQmlProfilerService::MessageListType ty int expectedPosition, const QQmlProfilerEventType &expected, quint32 checks, const QVector<qint64> &expectedNumbers) { + if (!m_client) { + qWarning() << "No debug client available"; + return false; + } + const QVector<QQmlProfilerEvent> *target = nullptr; switch (type) { case MessageListQML: target = &(m_client->qmlMessages); break; @@ -351,6 +357,11 @@ bool tst_QQmlProfilerService::verify(tst_QQmlProfilerService::MessageListType ty case MessageListPixmap: target = &(m_client->pixmapMessages); break; } + if (!target) { + qWarning() << "Invalid MessageListType" << type; + return false; + } + if (target->length() <= expectedPosition) { qWarning() << "Not enough events. expected position:" << expectedPosition << "length:" << target->length(); @@ -735,6 +746,7 @@ void tst_QQmlProfilerService::memory() checkTraceReceived(); checkJsHeap(); + QVERIFY(m_client); int smallItems = 0; for (auto message : m_client->jsHeapMessages) { const QQmlProfilerEventType &type = m_client->types[message.typeIndex()]; @@ -759,6 +771,8 @@ void tst_QQmlProfilerService::compile() // Flush interval so that we actually get the events before we stop recording. connect(true, "test.qml", true, 100); + QVERIFY(m_client); + // We need to check specifically for compile events as we can otherwise stop recording after the // StartTrace has arrived, but before it compiles anything. QTRY_VERIFY(hasCompileEvents(m_client->types)); |