From d3f1d9a3fd907408fa2f02aee42fa8abd06bd223 Mon Sep 17 00:00:00 2001 From: Christian Stenger Date: Wed, 6 May 2015 09:34:36 +0200 Subject: Fix creating auto test without gui Change-Id: Id1d0b686eda09f6fb513374c9b5337ffdd83b82a Reviewed-by: Eike Ziller --- shared/autotest/src.pro | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/shared/autotest/src.pro b/shared/autotest/src.pro index 26f9b3a152..61fbe2a5bc 100644 --- a/shared/autotest/src.pro +++ b/shared/autotest/src.pro @@ -1,7 +1,9 @@ @if "%RequireGUI%" == "true" -QT += gui widgets +QT += core gui +greaterThan(QT_MAJOR_VERSION, 4): QT += widgets @else -QT += console +QT -= gui +CONFIG += console CONFIG -= app_bundle @endif -- cgit v1.2.1 From fa28f1cb303d79ff3feb1416ef0637785dade8fc Mon Sep 17 00:00:00 2001 From: Robert Loehning Date: Mon, 18 May 2015 14:55:47 +0200 Subject: Disable run buttons until tests are found Change-Id: I418b63dbdd4a641fa02a61b792ec6dbfafe39749 Reviewed-by: Christian Stenger --- plugins/autotest/testresultspane.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/plugins/autotest/testresultspane.cpp b/plugins/autotest/testresultspane.cpp index e53af910da..c2a2b5851f 100644 --- a/plugins/autotest/testresultspane.cpp +++ b/plugins/autotest/testresultspane.cpp @@ -100,11 +100,13 @@ void TestResultsPane::createToolButtons() m_runAll = new QToolButton(m_treeView); m_runAll->setIcon(QIcon(QLatin1String(":/images/run.png"))); m_runAll->setToolTip(tr("Run All Tests")); + m_runAll->setEnabled(false); connect(m_runAll, &QToolButton::clicked, this, &TestResultsPane::onRunAllTriggered); m_runSelected = new QToolButton(m_treeView); m_runSelected->setIcon(QIcon(QLatin1String(":/images/runselected.png"))); m_runSelected->setToolTip(tr("Run Selected Tests")); + m_runSelected->setEnabled(false); connect(m_runSelected, &QToolButton::clicked, this, &TestResultsPane::onRunSelectedTriggered); m_stopTestRun = new QToolButton(m_treeView); -- cgit v1.2.1 From 5b93689702d45025b4b36cf65c807be21eeb3c05 Mon Sep 17 00:00:00 2001 From: Christian Stenger Date: Tue, 19 May 2015 07:41:39 +0200 Subject: 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 --- plugins/autotest/testvisitor.cpp | 23 ++++++++++++++++------- 1 file 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 specialFunctions = QList() << 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 specialFunctions = QList() << 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); } -- cgit v1.2.1 From c5fad3756006429026165a345b9eadcd4b5425df Mon Sep 17 00:00:00 2001 From: Christian Stenger Date: Tue, 19 May 2015 11:00:45 +0200 Subject: Avoid null pointer access Change-Id: Ie6f64a97d1d97efaa1e1f3ea784a119981159e62 Reviewed-by: David Schulz --- plugins/autotest/testtreemodel.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/plugins/autotest/testtreemodel.cpp b/plugins/autotest/testtreemodel.cpp index 2ee021ad06..134a9dc214 100644 --- a/plugins/autotest/testtreemodel.cpp +++ b/plugins/autotest/testtreemodel.cpp @@ -598,7 +598,8 @@ QList TestTreeModel::getSelectedTests() const QString TestTreeModel::getMainFileForUnnamedQuickTest(const QString &qmlFile) const { const TestTreeItem *unnamed = unnamedQuickTests(); - for (int row = 0, count = unnamed->childCount(); row < count; ++row) { + const int count = unnamed ? unnamed->childCount() : 0; + for (int row = 0; row < count; ++row) { const TestTreeItem *child = unnamed->child(row); if (qmlFile == child->filePath()) return child->mainFile(); -- cgit v1.2.1