summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Stenger <christian.stenger@theqtcompany.com>2015-05-19 07:41:39 +0200
committerChristian Stenger <christian.stenger@theqtcompany.com>2015-05-19 09:00:15 +0300
commit5b93689702d45025b4b36cf65c807be21eeb3c05 (patch)
treee5b1343482fba7ee69ea70984bff20510621b16a
parentfa28f1cb303d79ff3feb1416ef0637785dade8fc (diff)
downloadqt-creator-5b93689702d45025b4b36cf65c807be21eeb3c05.tar.gz
Detect special functions for Quick Tests
Quick Tests are capable of having benchmarks, data driven tests and special functions (init/cleanup/...) as well. Change-Id: Ieb9b6b1f842f1211a9d3192b486f789c987fa27b Reviewed-by: David Schulz <david.schulz@theqtcompany.com>
-rw-r--r--plugins/autotest/testvisitor.cpp23
1 files changed, 16 insertions, 7 deletions
diff --git a/plugins/autotest/testvisitor.cpp b/plugins/autotest/testvisitor.cpp
index b43a0c0271..2d38cb56b4 100644
--- a/plugins/autotest/testvisitor.cpp
+++ b/plugins/autotest/testvisitor.cpp
@@ -34,6 +34,12 @@
namespace Autotest {
namespace Internal {
+// names of special functions (applies for QTest as well as Quick Tests)
+static QList<QString> specialFunctions = QList<QString>() << QLatin1String("initTestCase")
+ << QLatin1String("cleanupTestCase")
+ << QLatin1String("init")
+ << QLatin1String("cleanup");
+
/************************** Cpp Test Symbol Visitor ***************************/
TestVisitor::TestVisitor(const QString &fullQualifiedClassName)
@@ -45,11 +51,6 @@ TestVisitor::~TestVisitor()
{
}
-static QList<QString> specialFunctions = QList<QString>() << QLatin1String("initTestCase")
- << QLatin1String("cleanupTestCase")
- << QLatin1String("init")
- << QLatin1String("cleanup");
-
bool TestVisitor::visit(CPlusPlus::Class *symbol)
{
const CPlusPlus::Overview o;
@@ -177,13 +178,21 @@ bool TestQmlVisitor::visit(QmlJS::AST::UiScriptBinding *ast)
bool TestQmlVisitor::visit(QmlJS::AST::FunctionDeclaration *ast)
{
const QStringRef name = ast->name;
- if (name.startsWith(QLatin1String("test_"))) {
+ if (name.startsWith(QLatin1String("test_"))
+ || name.startsWith(QLatin1String("benchmark_"))
+ || name.endsWith(QLatin1String("_data"))
+ || specialFunctions.contains(name.toString())) {
const auto sourceLocation = ast->firstSourceLocation();
TestCodeLocationAndType locationAndType;
locationAndType.m_fileName = m_currentDoc->fileName();
locationAndType.m_line = sourceLocation.startLine;
locationAndType.m_column = sourceLocation.startColumn - 1;
- locationAndType.m_type = TestTreeItem::TEST_FUNCTION;
+ if (specialFunctions.contains(name.toString()))
+ locationAndType.m_type = TestTreeItem::TEST_SPECIALFUNCTION;
+ else if (name.endsWith(QLatin1String("_data")))
+ locationAndType.m_type = TestTreeItem::TEST_DATAFUNCTION;
+ else
+ locationAndType.m_type = TestTreeItem::TEST_FUNCTION;
m_testFunctions.insert(name.toString(), locationAndType);
}