summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorSean Harmer <sean.harmer@kdab.com>2014-11-16 13:35:55 +0000
committerSean Harmer <sean.harmer@kdab.com>2014-11-17 18:35:38 +0100
commit153f3a834a8e321507db989bed09069c8601f57d (patch)
treeb871b5285b33c1d4fd0c7d4b6744748f8945d339 /tests
parentb923e2690038cebbabcdccf9e3ccfa041c3257de (diff)
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 <paul.lemire@kdab.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/core/core.pro2
-rw-r--r--tests/auto/core/qaspectengine/qaspectengine.pro7
-rw-r--r--tests/auto/core/qaspectengine/tst_qaspectengine.cpp88
-rw-r--r--tests/auto/core/qentity/qentity.pro7
-rw-r--r--tests/auto/core/qentity/tst_qentity.cpp75
5 files changed, 179 insertions, 0 deletions
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 <QtTest/QtTest>
+#include <Qt3DCore/qaspectengine.h>
+#include <Qt3DCore/qentity.h>
+
+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<QEntity> root = engine->rootEntity();
+ QVERIFY(root == e);
+ QVERIFY(root->objectName() == "root");
+ root = QSharedPointer<QEntity>();
+ 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 <QtTest/QtTest>
+#include <Qt3DCore/qentity.h>
+#include <QtCore/qscopedpointer.h>
+
+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<QEntity> entity2(new QEntity);
+ entity2.reset(Q_NULLPTR);
+}
+
+QTEST_APPLESS_MAIN(tst_Entity)
+
+#include "tst_qentity.moc"