summaryrefslogtreecommitdiff
path: root/src/plugins/autotest/quick/quicktestparser.cpp
diff options
context:
space:
mode:
authorChristian Stenger <christian.stenger@qt.io>2019-07-26 08:28:17 +0200
committerChristian Stenger <christian.stenger@qt.io>2019-07-30 10:45:09 +0000
commitc020fb6e3e5e2cb4ab4dcdb76fbc7693b1e45c96 (patch)
tree6952fbb53db38d26482359140564de8018f2a0cb /src/plugins/autotest/quick/quicktestparser.cpp
parent6c3be76c8d6f4d0918c8cb3e49f59e8a1a7c06f1 (diff)
downloadqt-creator-c020fb6e3e5e2cb4ab4dcdb76fbc7693b1e45c96.tar.gz
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>
Diffstat (limited to 'src/plugins/autotest/quick/quicktestparser.cpp')
-rw-r--r--src/plugins/autotest/quick/quicktestparser.cpp41
1 files changed, 21 insertions, 20 deletions
diff --git a/src/plugins/autotest/quick/quicktestparser.cpp b/src/plugins/autotest/quick/quicktestparser.cpp
index 2542325510..14e04c8a2f 100644
--- a/src/plugins/autotest/quick/quicktestparser.cpp
+++ b/src/plugins/autotest/quick/quicktestparser.cpp
@@ -190,20 +190,26 @@ static bool checkQmlDocumentForQuickTestCode(QFutureInterface<TestParseResultPtr
if (!qmlVisitor.isValid())
return false;
- const QString testCaseName = qmlVisitor.testCaseName();
- const TestCodeLocationAndType tcLocationAndType = qmlVisitor.testCaseLocation();
- const QMap<QString, TestCodeLocationAndType> &testFunctions = qmlVisitor.testFunctions();
-
- QuickTestParseResult *parseResult = new QuickTestParseResult(id);
- parseResult->proFile = proFile;
- parseResult->itemType = TestTreeItem::TestCase;
- QMap<QString, TestCodeLocationAndType>::ConstIterator it = testFunctions.begin();
- const QMap<QString, TestCodeLocationAndType>::ConstIterator end = testFunctions.end();
- for ( ; it != end; ++it) {
- const TestCodeLocationAndType &loc = it.value();
+ const QVector<QuickTestCaseSpec> &testFunctions = qmlVisitor.testFunctions();
+
+ for (const QuickTestCaseSpec &it : testFunctions) {
+ const QString testCaseName = it.m_caseName;
+ const QString functionName = it.m_functionName;
+ const TestCodeLocationAndType &loc = it.m_functionLocationAndType;
+
+ QuickTestParseResult *parseResult = new QuickTestParseResult(id);
+ parseResult->proFile = proFile;
+ parseResult->itemType = TestTreeItem::TestCase;
+ if (!testCaseName.isEmpty()) {
+ parseResult->fileName = it.m_name;
+ parseResult->name = testCaseName;
+ parseResult->line = it.m_line;
+ parseResult->column = it.m_column;
+ }
+
QuickTestParseResult *funcResult = new QuickTestParseResult(id);
- funcResult->name = it.key();
- funcResult->displayName = it.key();
+ funcResult->name = functionName;
+ funcResult->displayName = functionName;
funcResult->itemType = loc.m_type;
funcResult->fileName = loc.m_name;
funcResult->line = loc.m_line;
@@ -211,14 +217,9 @@ static bool checkQmlDocumentForQuickTestCode(QFutureInterface<TestParseResultPtr
funcResult->proFile = proFile;
parseResult->children.append(funcResult);
+
+ futureInterface.reportResult(TestParseResultPtr(parseResult));
}
- if (!testCaseName.isEmpty()) {
- parseResult->fileName = tcLocationAndType.m_name;
- parseResult->name = testCaseName;
- parseResult->line = tcLocationAndType.m_line;
- parseResult->column = tcLocationAndType.m_column;
- }
- futureInterface.reportResult(TestParseResultPtr(parseResult));
return true;
}