summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorPaul Lemire <paul.lemire@kdab.com>2017-08-18 11:46:05 +0200
committerSean Harmer <sean.harmer@kdab.com>2017-08-18 19:45:45 +0000
commit0ebfeccafe2ae87dbc10da25a34afdccc7e55124 (patch)
treeb23e1eaf86a92dc48847ebeec223cb9d58d7cd9d /tests
parentecffd9a9351bb9a5e6099a17e09c92495c34ccc8 (diff)
Add ProximityFilter backend node
Change-Id: I2e3fa11cae9113106e4a8c77832e3a2a3c27a24a Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/render/proximityfilter/proximityfilter.pro12
-rw-r--r--tests/auto/render/proximityfilter/tst_proximityfilter.cpp133
-rw-r--r--tests/auto/render/render.pro3
3 files changed, 147 insertions, 1 deletions
diff --git a/tests/auto/render/proximityfilter/proximityfilter.pro b/tests/auto/render/proximityfilter/proximityfilter.pro
new file mode 100644
index 000000000..74599e4f0
--- /dev/null
+++ b/tests/auto/render/proximityfilter/proximityfilter.pro
@@ -0,0 +1,12 @@
+TEMPLATE = app
+
+TARGET = tst_proximityfilter
+
+QT += 3dcore 3dcore-private 3drender 3drender-private testlib
+
+CONFIG += testcase
+
+SOURCES += tst_proximityfilter.cpp
+
+include(../../core/common/common.pri)
+include(../commons/commons.pri)
diff --git a/tests/auto/render/proximityfilter/tst_proximityfilter.cpp b/tests/auto/render/proximityfilter/tst_proximityfilter.cpp
new file mode 100644
index 000000000..774e2dd1f
--- /dev/null
+++ b/tests/auto/render/proximityfilter/tst_proximityfilter.cpp
@@ -0,0 +1,133 @@
+/****************************************************************************
+**
+** Copyright (C) 2017 Paul Lemire <paul.lemire350@gmail.com>
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the Qt3D module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** 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 The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+
+#include <QtTest/QTest>
+#include <Qt3DRender/qproximityfilter.h>
+#include <Qt3DRender/private/qproximityfilter_p.h>
+#include <Qt3DRender/private/proximityfilter_p.h>
+#include <Qt3DCore/qpropertyupdatedchange.h>
+#include "qbackendnodetester.h"
+#include "testrenderer.h"
+
+class tst_ProximityFilter : public Qt3DCore::QBackendNodeTester
+{
+ Q_OBJECT
+
+private Q_SLOTS:
+
+ void checkInitialState()
+ {
+ // GIVEN
+ Qt3DRender::Render::ProximityFilter backendProximityFilter;
+
+ // THEN
+ QCOMPARE(backendProximityFilter.isEnabled(), false);
+ QVERIFY(backendProximityFilter.peerId().isNull());
+ QCOMPARE(backendProximityFilter.distanceThreshold(), 0.0f);
+ QCOMPARE(backendProximityFilter.entityId(), Qt3DCore::QNodeId());
+ }
+
+ void checkInitializeFromPeer()
+ {
+ // GIVEN
+ Qt3DRender::QProximityFilter proximityFilter;
+ Qt3DCore::QEntity entity;
+ proximityFilter.setDistanceThreshold(1340.0f);
+ proximityFilter.setEntity(&entity);
+
+ {
+ // WHEN
+ Qt3DRender::Render::ProximityFilter backendProximityFilter;
+ simulateInitialization(&proximityFilter, &backendProximityFilter);
+
+ // THEN
+ QCOMPARE(backendProximityFilter.isEnabled(), true);
+ QCOMPARE(backendProximityFilter.peerId(), proximityFilter.id());
+ QCOMPARE(backendProximityFilter.distanceThreshold(), 1340.f);
+ QCOMPARE(backendProximityFilter.entityId(), entity.id());
+ }
+ {
+ // WHEN
+ Qt3DRender::Render::ProximityFilter backendProximityFilter;
+ proximityFilter.setEnabled(false);
+ simulateInitialization(&proximityFilter, &backendProximityFilter);
+
+ // THEN
+ QCOMPARE(backendProximityFilter.peerId(), proximityFilter.id());
+ QCOMPARE(backendProximityFilter.isEnabled(), false);
+ }
+ }
+
+ void checkSceneChangeEvents()
+ {
+ // GIVEN
+ Qt3DRender::Render::ProximityFilter backendProximityFilter;
+ TestRenderer renderer;
+ backendProximityFilter.setRenderer(&renderer);
+
+ {
+ // WHEN
+ const bool newValue = false;
+ const auto change = Qt3DCore::QPropertyUpdatedChangePtr::create(Qt3DCore::QNodeId());
+ change->setPropertyName("enabled");
+ change->setValue(newValue);
+ backendProximityFilter.sceneChangeEvent(change);
+
+ // THEN
+ QCOMPARE(backendProximityFilter.isEnabled(), newValue);
+ }
+ {
+ // WHEN
+ const float newValue = 383.0f;
+ const auto change = Qt3DCore::QPropertyUpdatedChangePtr::create(Qt3DCore::QNodeId());
+ change->setPropertyName("distanceThreshold");
+ change->setValue(QVariant::fromValue(newValue));
+ backendProximityFilter.sceneChangeEvent(change);
+
+ // THEN
+ QCOMPARE(backendProximityFilter.distanceThreshold(), newValue);
+ }
+ {
+ // WHEN
+ const Qt3DCore::QNodeId newValue = Qt3DCore::QNodeId::createId();
+ const auto change = Qt3DCore::QPropertyUpdatedChangePtr::create(Qt3DCore::QNodeId());
+ change->setPropertyName("entity");
+ change->setValue(QVariant::fromValue(newValue));
+ backendProximityFilter.sceneChangeEvent(change);
+
+ // THEN
+ QCOMPARE(backendProximityFilter.entityId(), newValue);
+ }
+ }
+
+};
+
+QTEST_MAIN(tst_ProximityFilter)
+
+#include "tst_proximityfilter.moc"
diff --git a/tests/auto/render/render.pro b/tests/auto/render/render.pro
index 146c61c01..8e9a5441f 100644
--- a/tests/auto/render/render.pro
+++ b/tests/auto/render/render.pro
@@ -104,7 +104,8 @@ qtConfig(private_tests) {
armature \
skeleton \
joint \
- qproximityfilter
+ qproximityfilter \
+ proximityfilter
QT_FOR_CONFIG = 3dcore-private
qtConfig(qt3d-extras) {