From 153f3a834a8e321507db989bed09069c8601f57d Mon Sep 17 00:00:00 2001 From: Sean Harmer Date: Sun, 16 Nov 2014 13:35:55 +0000 Subject: Add skeleton unit tests for QEntity and QAspectEngine QAspectEngine is crashing upon shutdown so adding a test case to investigate. Without a root entity set we just get warnings about threads being killed whilst still running. With a root entity set, it crashes. Need to solve these before we can test any more work towards a clean shutdown. Next commit solves the crash so merge it together with this one. Change-Id: Ic90c0f130ed48b418bb376b38eb10f23ea90590e Reviewed-by: Paul Lemire --- tests/auto/core/core.pro | 2 + tests/auto/core/qaspectengine/qaspectengine.pro | 7 ++ .../auto/core/qaspectengine/tst_qaspectengine.cpp | 88 ++++++++++++++++++++++ tests/auto/core/qentity/qentity.pro | 7 ++ tests/auto/core/qentity/tst_qentity.cpp | 75 ++++++++++++++++++ 5 files changed, 179 insertions(+) create mode 100644 tests/auto/core/qaspectengine/qaspectengine.pro create mode 100644 tests/auto/core/qaspectengine/tst_qaspectengine.cpp create mode 100644 tests/auto/core/qentity/qentity.pro create mode 100644 tests/auto/core/qentity/tst_qentity.cpp (limited to 'tests/auto') diff --git a/tests/auto/core/core.pro b/tests/auto/core/core.pro index ee7595502..9d4ca453e 100644 --- a/tests/auto/core/core.pro +++ b/tests/auto/core/core.pro @@ -8,6 +8,8 @@ SUBDIRS = \ qcircularbuffer \ qboundedcircularbuffer \ nodes \ + qentity \ + qaspectengine \ qchangearbiter \ qscene diff --git a/tests/auto/core/qaspectengine/qaspectengine.pro b/tests/auto/core/qaspectengine/qaspectengine.pro new file mode 100644 index 000000000..14ba51b3d --- /dev/null +++ b/tests/auto/core/qaspectengine/qaspectengine.pro @@ -0,0 +1,7 @@ +TARGET = tst_qaspectengine +CONFIG += testcase +TEMPLATE = app + +SOURCES += tst_qaspectengine.cpp + +QT += testlib 3dcore diff --git a/tests/auto/core/qaspectengine/tst_qaspectengine.cpp b/tests/auto/core/qaspectengine/tst_qaspectengine.cpp new file mode 100644 index 000000000..8a6adc8b2 --- /dev/null +++ b/tests/auto/core/qaspectengine/tst_qaspectengine.cpp @@ -0,0 +1,88 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Klaralvdalens Datakonsult AB (KDAB). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt3D module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include +#include + +using namespace Qt3D; + +class tst_QAspectEngine : public QObject +{ + Q_OBJECT +public: + tst_QAspectEngine() : QObject() {} + ~tst_QAspectEngine() {} + +private slots: + void constructionDestruction(); + void setRootEntity(); + + // TODO: Add more QAspectEngine tests +}; + +void tst_QAspectEngine::constructionDestruction() +{ + QAspectEngine *engine = new QAspectEngine; + QVERIFY(engine->rootEntity() == Q_NULLPTR); + delete engine; +} + +void tst_QAspectEngine::setRootEntity() +{ + QAspectEngine *engine = new QAspectEngine; + + QEntity *e = new QEntity; + e->setObjectName("root"); + engine->setRootEntity(e); + + QSharedPointer root = engine->rootEntity(); + QVERIFY(root == e); + QVERIFY(root->objectName() == "root"); + root = QSharedPointer(); + QVERIFY(engine->rootEntity()->objectName() == "root"); + + delete engine; +} + +QTEST_MAIN(tst_QAspectEngine) + +#include "tst_qaspectengine.moc" diff --git a/tests/auto/core/qentity/qentity.pro b/tests/auto/core/qentity/qentity.pro new file mode 100644 index 000000000..639ec0972 --- /dev/null +++ b/tests/auto/core/qentity/qentity.pro @@ -0,0 +1,7 @@ +TARGET = tst_qentity +CONFIG += testcase +TEMPLATE = app + +SOURCES += tst_qentity.cpp + +QT += testlib 3dcore diff --git a/tests/auto/core/qentity/tst_qentity.cpp b/tests/auto/core/qentity/tst_qentity.cpp new file mode 100644 index 000000000..4abab45fe --- /dev/null +++ b/tests/auto/core/qentity/tst_qentity.cpp @@ -0,0 +1,75 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Klaralvdalens Datakonsult AB (KDAB). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt3D module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include +#include + +using namespace Qt3D; + +class tst_Entity : public QObject +{ + Q_OBJECT +public: + tst_Entity() : QObject() {} + ~tst_Entity() {} + +private slots: + void constructionDestruction(); + + // TODO: Add more entity tests +}; + +void tst_Entity::constructionDestruction() +{ + QEntity *entity = Q_NULLPTR; + entity = new QEntity; + QVERIFY(entity != Q_NULLPTR); + + delete entity; + + QScopedPointer entity2(new QEntity); + entity2.reset(Q_NULLPTR); +} + +QTEST_APPLESS_MAIN(tst_Entity) + +#include "tst_qentity.moc" -- cgit v1.2.3