diff options
author | Miikka Heikkinen <miikka.heikkinen@theqtcompany.com> | 2014-10-29 09:45:41 +0200 |
---|---|---|
committer | Miikka Heikkinen <miikka.heikkinen@theqtcompany.com> | 2014-10-29 09:45:41 +0200 |
commit | e3a4f132ca2a42af3d4bb889d6a17948b88d26a2 (patch) | |
tree | 554d2b8b3020dc71438301aa696dea1e9a36943a /tests/auto/cpptest/q3dcustom/tst_custom.cpp | |
parent | cc50608385cf77a0803431ece1385f341a400b75 (diff) | |
parent | bf716cfdf0afecccdb1f2eabb2e6a172c620fbff (diff) |
Merge branch 'develop'
Conflicts:
.qmake.conf
README
src/datavisualization/global/qdatavisualizationglobal.h
Change-Id: Ia6941dcf3e6aa17e2e9ebc6f60fac16ef5049f11
Diffstat (limited to 'tests/auto/cpptest/q3dcustom/tst_custom.cpp')
-rw-r--r-- | tests/auto/cpptest/q3dcustom/tst_custom.cpp | 128 |
1 files changed, 128 insertions, 0 deletions
diff --git a/tests/auto/cpptest/q3dcustom/tst_custom.cpp b/tests/auto/cpptest/q3dcustom/tst_custom.cpp new file mode 100644 index 00000000..abc088f9 --- /dev/null +++ b/tests/auto/cpptest/q3dcustom/tst_custom.cpp @@ -0,0 +1,128 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc +** All rights reserved. +** For any questions to Digia, please use contact form at http://qt.digia.com +** +** This file is part of the QtDataVisualization module. +** +** Licensees holding valid Qt Enterprise licenses may use this file in +** accordance with the Qt Enterprise License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. +** +** If you have questions regarding the use of this file, please use +** contact form at http://qt.digia.com +** +****************************************************************************/ + +#include <QtTest/QtTest> + +#include <QtDataVisualization/QCustom3DItem> + +using namespace QtDataVisualization; + +class tst_custom: public QObject +{ + Q_OBJECT + +private slots: + void initTestCase(); + void cleanupTestCase(); + void init(); + void cleanup(); + + void construct(); + + void initialProperties(); + void initializeProperties(); + +private: + QCustom3DItem *m_custom; +}; + +void tst_custom::initTestCase() +{ +} + +void tst_custom::cleanupTestCase() +{ +} + +void tst_custom::init() +{ + m_custom = new QCustom3DItem(); +} + +void tst_custom::cleanup() +{ + delete m_custom; +} + +void tst_custom::construct() +{ + QCustom3DItem *custom = new QCustom3DItem(); + QVERIFY(custom); + delete custom; + + custom = new QCustom3DItem(":/customitem.obj", QVector3D(1.0, 1.0, 1.0), + QVector3D(1.0, 1.0, 1.0), QQuaternion(1.0, 1.0, 10.0, 100.0), + QImage(":/customtexture.jpg")); + QVERIFY(custom); + QCOMPARE(custom->meshFile(), QString(":/customitem.obj")); + QCOMPARE(custom->position(), QVector3D(1.0, 1.0, 1.0)); + QCOMPARE(custom->isPositionAbsolute(), false); + QCOMPARE(custom->rotation(), QQuaternion(1.0, 1.0, 10.0, 100.0)); + QCOMPARE(custom->scaling(), QVector3D(1.0, 1.0, 1.0)); + QCOMPARE(custom->isScalingAbsolute(), true); + QCOMPARE(custom->isShadowCasting(), true); + QCOMPARE(custom->textureFile(), QString()); + QCOMPARE(custom->isVisible(), true); + delete custom; +} + +void tst_custom::initialProperties() +{ + QVERIFY(m_custom); + + QCOMPARE(m_custom->meshFile(), QString()); + QCOMPARE(m_custom->position(), QVector3D()); + QCOMPARE(m_custom->isPositionAbsolute(), false); + QCOMPARE(m_custom->rotation(), QQuaternion()); + QCOMPARE(m_custom->scaling(), QVector3D(0.1f, 0.1f, 0.1f)); + QCOMPARE(m_custom->isScalingAbsolute(), true); + QCOMPARE(m_custom->isShadowCasting(), true); + QCOMPARE(m_custom->textureFile(), QString()); + QCOMPARE(m_custom->isVisible(), true); +} + +void tst_custom::initializeProperties() +{ + QVERIFY(m_custom); + + m_custom->setMeshFile(":/customitem.obj"); + m_custom->setPosition(QVector3D(1.0, 1.0, 1.0)); + m_custom->setPositionAbsolute(true); + m_custom->setRotation(QQuaternion(1.0, 1.0, 10.0, 100.0)); + m_custom->setScaling(QVector3D(1.0, 1.0, 1.0)); + m_custom->setScalingAbsolute(false); + m_custom->setShadowCasting(false); + m_custom->setTextureFile(":/customtexture.jpg"); + m_custom->setVisible(false); + + QCOMPARE(m_custom->meshFile(), QString(":/customitem.obj")); + QCOMPARE(m_custom->position(), QVector3D(1.0, 1.0, 1.0)); + QCOMPARE(m_custom->isPositionAbsolute(), true); + QCOMPARE(m_custom->rotation(), QQuaternion(1.0, 1.0, 10.0, 100.0)); + QCOMPARE(m_custom->scaling(), QVector3D(1.0, 1.0, 1.0)); + QCOMPARE(m_custom->isScalingAbsolute(), false); + QCOMPARE(m_custom->isShadowCasting(), false); + QCOMPARE(m_custom->textureFile(), QString(":/customtexture.jpg")); + QCOMPARE(m_custom->isVisible(), false); + + m_custom->setTextureImage(QImage(QSize(10, 10), QImage::Format_ARGB32)); + QCOMPARE(m_custom->textureFile(), QString()); +} + +QTEST_MAIN(tst_custom) +#include "tst_custom.moc" |