forked from qt-creator/qt-creator
AutoTest: Handle sub-typed TestCases correctly
Furthermore ensure that TestCase is really the Qml type to avoid handling self-defined types as Quick Tests. Task-number: QTCREATORBUG-17787 Change-Id: I08a6c70c3c166eefec6f24669cc225f568e51c7a Reviewed-by: Marco Benelli <marco.benelli@qt.io>
This commit is contained in:
@@ -165,6 +165,7 @@ static QList<QmlJS::Document::Ptr> scanDirectoryForQuickTestQmlFiles(const QStri
|
||||
}
|
||||
|
||||
static bool checkQmlDocumentForQuickTestCode(QFutureInterface<TestParseResultPtr> futureInterface,
|
||||
const QmlJS::Snapshot &snapshot,
|
||||
const QmlJS::Document::Ptr &qmlJSDoc,
|
||||
const Core::Id &id,
|
||||
const QString &proFile = QString())
|
||||
@@ -173,8 +174,10 @@ static bool checkQmlDocumentForQuickTestCode(QFutureInterface<TestParseResultPtr
|
||||
return false;
|
||||
QmlJS::AST::Node *ast = qmlJSDoc->ast();
|
||||
QTC_ASSERT(ast, return false);
|
||||
TestQmlVisitor qmlVisitor(qmlJSDoc);
|
||||
TestQmlVisitor qmlVisitor(qmlJSDoc, snapshot);
|
||||
QmlJS::AST::Node::accept(ast, &qmlVisitor);
|
||||
if (!qmlVisitor.isValid())
|
||||
return false;
|
||||
|
||||
const QString testCaseName = qmlVisitor.testCaseName();
|
||||
const TestCodeLocationAndType tcLocationAndType = qmlVisitor.testCaseLocation();
|
||||
@@ -209,6 +212,7 @@ static bool checkQmlDocumentForQuickTestCode(QFutureInterface<TestParseResultPtr
|
||||
}
|
||||
|
||||
static bool handleQtQuickTest(QFutureInterface<TestParseResultPtr> futureInterface,
|
||||
const QmlJS::Snapshot &snapshot,
|
||||
CPlusPlus::Document::Ptr document,
|
||||
const Core::Id &id)
|
||||
{
|
||||
@@ -229,7 +233,7 @@ static bool handleQtQuickTest(QFutureInterface<TestParseResultPtr> futureInterfa
|
||||
const QList<QmlJS::Document::Ptr> qmlDocs = scanDirectoryForQuickTestQmlFiles(srcDir);
|
||||
bool result = false;
|
||||
for (const QmlJS::Document::Ptr &qmlJSDoc : qmlDocs)
|
||||
result |= checkQmlDocumentForQuickTestCode(futureInterface, qmlJSDoc, id, proFile);
|
||||
result |= checkQmlDocumentForQuickTestCode(futureInterface, snapshot, qmlJSDoc, id, proFile);
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -276,14 +280,14 @@ bool QuickTestParser::processDocument(QFutureInterface<TestParseResultPtr> futur
|
||||
if (proFile.isEmpty())
|
||||
return false;
|
||||
QmlJS::Document::Ptr qmlJSDoc = m_qmlSnapshot.document(fileName);
|
||||
return checkQmlDocumentForQuickTestCode(futureInterface, qmlJSDoc, id(), proFile);
|
||||
return checkQmlDocumentForQuickTestCode(futureInterface, m_qmlSnapshot, qmlJSDoc, id(), proFile);
|
||||
}
|
||||
if (!m_cppSnapshot.contains(fileName) || !selectedForBuilding(fileName))
|
||||
return false;
|
||||
CPlusPlus::Document::Ptr document = m_cppSnapshot.find(fileName).value();
|
||||
if (!includesQtQuickTest(document, m_cppSnapshot))
|
||||
return false;
|
||||
return handleQtQuickTest(futureInterface, document, id());
|
||||
return handleQtQuickTest(futureInterface, m_qmlSnapshot, document, id());
|
||||
}
|
||||
|
||||
} // namespace Internal
|
||||
|
||||
Reference in New Issue
Block a user