diff options
Diffstat (limited to 'tests/auto/qml/debugger')
4 files changed, 116 insertions, 4 deletions
diff --git a/tests/auto/qml/debugger/qqmldebuggingenabler/qqmldebuggingenabler/tst_qqmldebuggingenabler.cpp b/tests/auto/qml/debugger/qqmldebuggingenabler/qqmldebuggingenabler/tst_qqmldebuggingenabler.cpp index a76740a3f9..52e7f85e52 100644 --- a/tests/auto/qml/debugger/qqmldebuggingenabler/qqmldebuggingenabler/tst_qqmldebuggingenabler.cpp +++ b/tests/auto/qml/debugger/qqmldebuggingenabler/qqmldebuggingenabler/tst_qqmldebuggingenabler.cpp @@ -126,8 +126,10 @@ void tst_QQmlDebuggingEnabler::qmlscene() } QCOMPARE(m_process->state(), QLatin1String("running")); - if (!blockMode) - QTRY_VERIFY(m_process->output().contains(QLatin1String("qml: Component.onCompleted"))); + if (!blockMode) { + QTRY_VERIFY_WITH_TIMEOUT(m_process->output().contains( + QLatin1String("Component.onCompleted")), 15000); + } } void tst_QQmlDebuggingEnabler::custom_data() @@ -171,8 +173,10 @@ void tst_QQmlDebuggingEnabler::custom() } QCOMPARE(m_process->state(), QLatin1String("running")); - if (!blockMode) - QTRY_VERIFY(m_process->output().contains(QLatin1String("QQmlEngine created"))); + if (!blockMode) { + QTRY_VERIFY_WITH_TIMEOUT(m_process->output().contains(QLatin1String("QQmlEngine created")), + 15000); + } } QTEST_MAIN(tst_QQmlDebuggingEnabler) diff --git a/tests/auto/qml/debugger/qqmlenginedebugservice/tst_qqmlenginedebugservice.cpp b/tests/auto/qml/debugger/qqmlenginedebugservice/tst_qqmlenginedebugservice.cpp index d01d9a6791..89217e7556 100644 --- a/tests/auto/qml/debugger/qqmlenginedebugservice/tst_qqmlenginedebugservice.cpp +++ b/tests/auto/qml/debugger/qqmlenginedebugservice/tst_qqmlenginedebugservice.cpp @@ -141,6 +141,7 @@ private slots: void queryObjectWithNonStreamableTypes(); void asynchronousCreate(); void invalidContexts(); + void createObjectOnDestruction(); }; QmlDebugObjectReference tst_QQmlEngineDebugService::findRootObject( @@ -1345,6 +1346,29 @@ void tst_QQmlEngineDebugService::invalidContexts() QCOMPARE(m_dbg->rootContext().contexts.count(), 0); } +void tst_QQmlEngineDebugService::createObjectOnDestruction() +{ + QSignalSpy spy(m_dbg, SIGNAL(newObject(int))); + { + QQmlEngine engine; + QQmlComponent component(&engine); + component.setData( + "import QtQml 2.0;" + "QtObject {" + "property Component x:" + "Qt.createQmlObject('import QtQml 2.0; Component { QtObject { } }'," + "this, 'x.qml');" + "Component.onDestruction: x.createObject(this, {});" + "}", QUrl::fromLocalFile("x.qml")); + QVERIFY(component.isReady()); + QVERIFY(component.create()); + QTRY_COMPARE(spy.count(), 2); + } + // Doesn't crash and doesn't give us another signal for the object created on destruction. + QTest::qWait(500); + QCOMPARE(spy.count(), 2); +} + int main(int argc, char *argv[]) { int _argc = argc + 1; diff --git a/tests/auto/qml/debugger/qqmlprofilerservice/tst_qqmlprofilerservice.cpp b/tests/auto/qml/debugger/qqmlprofilerservice/tst_qqmlprofilerservice.cpp index cd8e4216f3..562804bc45 100644 --- a/tests/auto/qml/debugger/qqmlprofilerservice/tst_qqmlprofilerservice.cpp +++ b/tests/auto/qml/debugger/qqmlprofilerservice/tst_qqmlprofilerservice.cpp @@ -221,6 +221,7 @@ private slots: void flushInterval(); void translationBinding(); void memory(); + void compile(); private: bool m_recordFromStart = true; @@ -525,6 +526,8 @@ void tst_QQmlProfilerService::connect() if (!traceEnabled) m_client->client->setRecording(true); + + QTRY_VERIFY(m_client->numLoadedEventTypes() > 0); m_client->client->setRecording(false); checkTraceReceived(); checkJsHeap(); @@ -643,6 +646,7 @@ void tst_QQmlProfilerService::controlFromJS() { QCOMPARE(connect(true, "controlFromJS.qml", false), ConnectSuccess); + QTRY_VERIFY(m_client->numLoadedEventTypes() > 0); m_client->client->setRecording(false); checkTraceReceived(); checkJsHeap(); @@ -749,6 +753,54 @@ void tst_QQmlProfilerService::memory() QVERIFY(smallItems > 5); } +static bool hasCompileEvents(const QVector<QQmlProfilerEventType> &types) +{ + for (const QQmlProfilerEventType &type : types) { + if (type.message() == QQmlProfilerDefinitions::MaximumMessage + && type.rangeType() == QQmlProfilerDefinitions::Compiling) + return true; + } + return false; +} + +void tst_QQmlProfilerService::compile() +{ + // Flush interval so that we actually get the events before we stop recording. + connect(true, "test.qml", true, 100); + + // 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)); + m_client->client->setRecording(false); + + checkTraceReceived(); + checkJsHeap(); + + QQmlProfilerDefinitions::Message rangeStage = QQmlProfilerDefinitions::MaximumMessage; + for (auto message : m_client->qmlMessages) { + const QQmlProfilerEventType &type = m_client->types[message.typeIndex()]; + if (type.rangeType() == QQmlProfilerDefinitions::Compiling) { + switch (rangeStage) { + case QQmlProfilerDefinitions::MaximumMessage: + QCOMPARE(message.rangeStage(), QQmlProfilerDefinitions::RangeStart); + break; + case QQmlProfilerDefinitions::RangeStart: + QCOMPARE(message.rangeStage(), QQmlProfilerDefinitions::RangeEnd); + break; + default: + QFAIL("Wrong range stage"); + } + rangeStage = message.rangeStage(); + QCOMPARE(type.message(), QQmlProfilerDefinitions::MaximumMessage); + QCOMPARE(type.location().filename(), testFileUrl("test.qml").toString()); + QCOMPARE(type.location().line(), 0); + QCOMPARE(type.location().column(), 0); + } + } + + QCOMPARE(rangeStage, QQmlProfilerDefinitions::RangeEnd); +} + QTEST_MAIN(tst_QQmlProfilerService) #include "tst_qqmlprofilerservice.moc" diff --git a/tests/auto/qml/debugger/qv4debugger/tst_qv4debugger.cpp b/tests/auto/qml/debugger/qv4debugger/tst_qv4debugger.cpp index 5dd62da15a..4ce0f9fd89 100644 --- a/tests/auto/qml/debugger/qv4debugger/tst_qv4debugger.cpp +++ b/tests/auto/qml/debugger/qv4debugger/tst_qv4debugger.cpp @@ -316,6 +316,8 @@ private slots: void lastLineOfConditional_data(); void lastLineOfConditional(); + + void readThis(); private: QV4Debugger *debugger() const { @@ -865,6 +867,36 @@ void tst_qv4debugger::lastLineOfConditional() QCOMPARE(secondState.lineNumber, lastLine); } +void tst_qv4debugger::readThis() +{ + m_debuggerAgent->m_captureContextInfo = true; + QString script = + "var x = function() {\n" + " return this.a;\n" + "}.apply({a : 5}, []);\n"; + + TestAgent::ExpressionRequest request; + request.expression = "this"; + request.frameNr = 0; + request.context = -1; // no extra context + m_debuggerAgent->m_expressionRequests << request; + + debugger()->addBreakPoint("applyThis", 2); + evaluateJavaScript(script, "applyThis"); + QVERIFY(m_debuggerAgent->m_wasPaused); + + QCOMPARE(m_debuggerAgent->m_expressionResults.count(), 1); + QJsonObject result0 = m_debuggerAgent->m_expressionResults[0]; + QCOMPARE(result0.value("type").toString(), QStringLiteral("object")); + QCOMPARE(result0.value("value").toInt(), 1); + QJsonArray properties = result0.value("properties").toArray(); + QCOMPARE(properties.size(), 1); + QJsonObject a = properties.first().toObject(); + QCOMPARE(a.value("name").toString(), QStringLiteral("a")); + QCOMPARE(a.value("type").toString(), QStringLiteral("number")); + QCOMPARE(a.value("value").toInt(), 5); +} + void tst_qv4debugger::redundancy_data() { QTest::addColumn<bool>("redundantRefs"); |