AutoTest: Fix parsing of multiple test cases in single qml file

Quick tests allow definition of more than one TestCase inside a
qml file and even nesting is possible, so support this correctly.

Fixes: QTCREATORBUG-22761
Change-Id: I65fcc7cd6063d976d798c3e900d3299a12e2d73f
Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
Christian Stenger
2019-07-26 08:28:17 +02:00
parent 6c3be76c8d
commit c020fb6e3e
7 changed files with 104 additions and 56 deletions

View File

@@ -37,6 +37,14 @@
namespace Autotest {
namespace Internal {
class QuickTestCaseSpec : public TestCodeLocationAndType
{
public:
QString m_caseName;
QString m_functionName;
TestCodeLocationAndType m_functionLocationAndType;
};
class TestQmlVisitor : public QmlJS::AST::Visitor
{
public:
@@ -50,17 +58,14 @@ public:
bool visit(QmlJS::AST::FunctionDeclaration *ast) override;
bool visit(QmlJS::AST::StringLiteral *ast) override;
QString testCaseName() const { return m_currentTestCaseName; }
TestCodeLocationAndType testCaseLocation() const { return m_testCaseLocation; }
QMap<QString, TestCodeLocationAndType> testFunctions() const { return m_testFunctions; }
QVector<QuickTestCaseSpec> testFunctions() const { return m_testFunctions; }
bool isValid() const { return m_typeIsTestCase; }
private:
QmlJS::Document::Ptr m_currentDoc;
QmlJS::Snapshot m_snapshot;
QString m_currentTestCaseName;
TestCodeLocationAndType m_testCaseLocation;
QMap<QString, TestCodeLocationAndType> m_testFunctions;
QStack<QuickTestCaseSpec> m_testCases;
QVector<QuickTestCaseSpec> m_testFunctions;
QStack<QString> m_objectStack;
bool m_typeIsTestCase = false;
bool m_insideTestCase = false;