mirror of https://github.com/qt/qt3d.git
Add private module qt3dcoretest
Static library containing helpers for unit tests to avoid having to build the same files 200 times. Change-Id: I89d63abbd7777a96276154298c2748e2d6774514 Reviewed-by: Paul Lemire <paul.lemire@kdab.com>
This commit is contained in:
parent
5156fcf380
commit
1071f3e6a2
|
|
@ -11,6 +11,7 @@
|
|||
"Qt3DExtras" => "$basedir/src/extras",
|
||||
"Qt3DQuickExtras" => "$basedir/src/quick3d/quick3dextras",
|
||||
"Qt3DQuickScene2D" => "$basedir/src/quick3d/quick3dscene2d",
|
||||
"Qt3DCoreTest" => "$basedir/tests/auto/coretest",
|
||||
);
|
||||
%moduleheaders = ( # restrict the module headers to those found in relative path
|
||||
);
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
TEMPLATE = subdirs
|
||||
|
||||
SUBDIRS = \
|
||||
coretest \
|
||||
core \
|
||||
render \
|
||||
quick3d \
|
||||
|
|
@ -10,3 +11,9 @@ SUBDIRS = \
|
|||
extras
|
||||
|
||||
installed_cmake.depends = cmake
|
||||
|
||||
for(subdir, SUBDIRS) {
|
||||
!equals(subdir, coretest) {
|
||||
$${subdir}.depends += coretest
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,25 @@
|
|||
TARGET = Qt3DCoreTest
|
||||
MODULE = 3dcoretest
|
||||
CONFIG += static internal_module
|
||||
|
||||
DEFINES += QT_NO_CAST_FROM_ASCII QT_NO_FOREACH
|
||||
PRECOMPILED_HEADER =
|
||||
INCLUDEPATH += $$PWD
|
||||
|
||||
SOURCES += \
|
||||
$$PWD/testpostmanarbiter.cpp
|
||||
|
||||
HEADERS += \
|
||||
$$PWD/testpostmanarbiter_p.h
|
||||
|
||||
qtConfig(private_tests) {
|
||||
SOURCES += \
|
||||
$$PWD/qbackendnodetester.cpp
|
||||
|
||||
HEADERS += \
|
||||
$$PWD/qbackendnodetester_p.h
|
||||
}
|
||||
|
||||
QT += core-private 3dcore 3dcore-private
|
||||
|
||||
load(qt_module)
|
||||
|
|
@ -0,0 +1,73 @@
|
|||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2016 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:LGPL3$
|
||||
** 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 http://www.qt.io/terms-conditions. For further
|
||||
** information use the contact form at http://www.qt.io/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 3 as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.LGPLv3 included in the
|
||||
** packaging of this file. Please review the following information to
|
||||
** ensure the GNU Lesser General Public License version 3 requirements
|
||||
** will be met: https://www.gnu.org/licenses/lgpl.html.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU
|
||||
** General Public License version 2.0 or later 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 2.0 requirements will be
|
||||
** met: http://www.gnu.org/licenses/gpl-2.0.html.
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "qbackendnodetester_p.h"
|
||||
#include <Qt3DCore/qbackendnode.h>
|
||||
#include <Qt3DCore/qnode.h>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
namespace Qt3DCore {
|
||||
|
||||
QBackendNodeTester::QBackendNodeTester(QObject *parent)
|
||||
: QObject(parent)
|
||||
{
|
||||
}
|
||||
|
||||
void QBackendNodeTester::setPeerId(QBackendNode *backend, QNodeId id)
|
||||
{
|
||||
Q_ASSERT(backend);
|
||||
backend->setPeerId(id);
|
||||
}
|
||||
|
||||
void QBackendNodeTester::simulateInitialization(QNode *frontend, QBackendNode *backend)
|
||||
{
|
||||
Q_ASSERT(frontend);
|
||||
Q_ASSERT(backend);
|
||||
const auto change = frontend->createNodeCreationChange();
|
||||
backend->setPeerId(change->subjectId());
|
||||
backend->setEnabled(change->isNodeEnabled());
|
||||
backend->initializeFromPeer(change);
|
||||
}
|
||||
|
||||
void QBackendNodeTester::sceneChangeEvent(QBackendNode *backend, const Qt3DCore::QSceneChangePtr &e)
|
||||
{
|
||||
backend->sceneChangeEvent(e);
|
||||
}
|
||||
|
||||
} // namespace Qt3DCore
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
|
@ -0,0 +1,78 @@
|
|||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2016 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:LGPL3$
|
||||
** 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 http://www.qt.io/terms-conditions. For further
|
||||
** information use the contact form at http://www.qt.io/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 3 as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.LGPLv3 included in the
|
||||
** packaging of this file. Please review the following information to
|
||||
** ensure the GNU Lesser General Public License version 3 requirements
|
||||
** will be met: https://www.gnu.org/licenses/lgpl.html.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU
|
||||
** General Public License version 2.0 or later 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 2.0 requirements will be
|
||||
** met: http://www.gnu.org/licenses/gpl-2.0.html.
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef QT3DCORE_QBACKENDNODETESTER_P_H
|
||||
#define QT3DCORE_QBACKENDNODETESTER_P_H
|
||||
|
||||
//
|
||||
// W A R N I N G
|
||||
// -------------
|
||||
//
|
||||
// This file is not part of the Qt API. It exists for the convenience
|
||||
// of other Qt classes. This header file may change from version to
|
||||
// version without notice, or even be removed.
|
||||
//
|
||||
// We mean it.
|
||||
//
|
||||
|
||||
#include <QObject>
|
||||
#include <Qt3DCore/qnodeid.h>
|
||||
#include <Qt3DCore/qscenechange.h>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
namespace Qt3DCore {
|
||||
|
||||
class QBackendNode;
|
||||
class QNode;
|
||||
|
||||
class QBackendNodeTester : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit QBackendNodeTester(QObject *parent = 0);
|
||||
|
||||
// Proxies to allow test classes to call private methods on QBackendNode
|
||||
void setPeerId(QBackendNode *backend, QNodeId id);
|
||||
void simulateInitialization(QNode *frontend, QBackendNode *backend);
|
||||
void sceneChangeEvent(QBackendNode *backend, const Qt3DCore::QSceneChangePtr &e);
|
||||
};
|
||||
|
||||
} // namespace Qt3DCore
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#endif // QT3DCORE_QBACKENDNODETESTER_P_H
|
||||
|
|
@ -0,0 +1,90 @@
|
|||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2015 Klaralvdalens Datakonsult AB (KDAB).
|
||||
** 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 "testpostmanarbiter_p.h"
|
||||
#include <Qt3DCore/private/qnode_p.h>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
TestPostman::TestPostman(TestArbiter *arbiter)
|
||||
: m_arbiter(arbiter)
|
||||
{}
|
||||
|
||||
void TestPostman::setScene(Qt3DCore::QScene *)
|
||||
{}
|
||||
|
||||
void TestPostman::sceneChangeEvent(const Qt3DCore::QSceneChangePtr &)
|
||||
{}
|
||||
|
||||
void TestPostman::notifyBackend(const Qt3DCore::QSceneChangePtr &e)
|
||||
{
|
||||
m_arbiter->sceneChangeEventWithLock(e);
|
||||
}
|
||||
|
||||
bool TestPostman::shouldNotifyFrontend(const Qt3DCore::QSceneChangePtr &)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
TestArbiter::TestArbiter()
|
||||
: m_postman(new TestPostman(this))
|
||||
{
|
||||
}
|
||||
|
||||
TestArbiter::~TestArbiter()
|
||||
{
|
||||
}
|
||||
|
||||
void TestArbiter::sceneChangeEvent(const Qt3DCore::QSceneChangePtr &e)
|
||||
{
|
||||
events.push_back(e);
|
||||
}
|
||||
|
||||
void TestArbiter::sceneChangeEventWithLock(const Qt3DCore::QSceneChangePtr &e)
|
||||
{
|
||||
events.push_back(e);
|
||||
}
|
||||
|
||||
void TestArbiter::sceneChangeEventWithLock(const Qt3DCore::QSceneChangeList &e)
|
||||
{
|
||||
events += QVector<Qt3DCore::QSceneChangePtr>::fromStdVector(e);
|
||||
}
|
||||
|
||||
Qt3DCore::QAbstractPostman *TestArbiter::postman() const
|
||||
{
|
||||
return m_postman;
|
||||
}
|
||||
|
||||
void TestArbiter::setArbiterOnNode(Qt3DCore::QNode *node)
|
||||
{
|
||||
Qt3DCore::QNodePrivate::get(node)->setArbiter(this);
|
||||
for (Qt3DCore::QNode *n : node->childNodes())
|
||||
setArbiterOnNode(n);
|
||||
}
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
|
@ -0,0 +1,92 @@
|
|||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2015 Klaralvdalens Datakonsult AB (KDAB).
|
||||
** 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$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef QT3DCORE_TESTPOSTMANARBITER_P_H
|
||||
#define QT3DCORE_TESTPOSTMANARBITER_P_H
|
||||
|
||||
//
|
||||
// W A R N I N G
|
||||
// -------------
|
||||
//
|
||||
// This file is not part of the Qt API. It exists for the convenience
|
||||
// of other Qt classes. This header file may change from version to
|
||||
// version without notice, or even be removed.
|
||||
//
|
||||
// We mean it.
|
||||
//
|
||||
|
||||
#include <Qt3DCore/private/qpostman_p.h>
|
||||
#include <Qt3DCore/private/qchangearbiter_p.h>
|
||||
#include <Qt3DCore/qpropertyupdatedchange.h>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
namespace Qt3DCore {
|
||||
class QNode;
|
||||
} // Qt3D
|
||||
|
||||
class TestArbiter;
|
||||
|
||||
class TestPostman : public Qt3DCore::QAbstractPostman
|
||||
{
|
||||
public:
|
||||
explicit TestPostman(TestArbiter *arbiter);
|
||||
void sceneChangeEvent(const Qt3DCore::QSceneChangePtr &) Q_DECL_FINAL;
|
||||
void setScene(Qt3DCore::QScene *) Q_DECL_FINAL;
|
||||
void notifyBackend(const Qt3DCore::QSceneChangePtr &e) Q_DECL_FINAL;
|
||||
bool shouldNotifyFrontend(const Qt3DCore::QSceneChangePtr &e) Q_DECL_FINAL;
|
||||
|
||||
private:
|
||||
TestArbiter *m_arbiter;
|
||||
};
|
||||
|
||||
class TestArbiter : public Qt3DCore::QAbstractArbiter
|
||||
{
|
||||
public:
|
||||
TestArbiter();
|
||||
~TestArbiter();
|
||||
|
||||
void sceneChangeEvent(const Qt3DCore::QSceneChangePtr &e) Q_DECL_FINAL;
|
||||
|
||||
void sceneChangeEventWithLock(const Qt3DCore::QSceneChangePtr &e) Q_DECL_FINAL;
|
||||
|
||||
void sceneChangeEventWithLock(const Qt3DCore::QSceneChangeList &e) Q_DECL_FINAL;
|
||||
|
||||
Qt3DCore::QAbstractPostman *postman() const Q_DECL_FINAL;
|
||||
|
||||
QVector<Qt3DCore::QSceneChangePtr> events;
|
||||
|
||||
void setArbiterOnNode(Qt3DCore::QNode *node);
|
||||
|
||||
private:
|
||||
TestPostman *m_postman;
|
||||
};
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#endif // QT3DCORE_TESTPOSTMANARBITER_P_H
|
||||
Loading…
Reference in New Issue