summaryrefslogtreecommitdiffstats
path: root/tests/auto/cpptest
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/cpptest')
-rw-r--r--tests/auto/cpptest/cpptest.pro26
-rw-r--r--tests/auto/cpptest/q3daxis-category/q3daxis-category.pro8
-rw-r--r--tests/auto/cpptest/q3daxis-category/tst_axis.cpp133
-rw-r--r--tests/auto/cpptest/q3daxis-logvalue/q3daxis-logvalue.pro8
-rw-r--r--tests/auto/cpptest/q3daxis-logvalue/tst_axis.cpp102
-rw-r--r--tests/auto/cpptest/q3daxis-value/q3daxis-value.pro8
-rw-r--r--tests/auto/cpptest/q3daxis-value/tst_axis.cpp158
-rw-r--r--tests/auto/cpptest/q3dbars-modelproxy/q3dbars-modelproxy.pro8
-rw-r--r--tests/auto/cpptest/q3dbars-modelproxy/tst_proxy.cpp267
-rw-r--r--tests/auto/cpptest/q3dbars-proxy/q3dbars-proxy.pro8
-rw-r--r--tests/auto/cpptest/q3dbars-proxy/tst_proxy.cpp97
-rw-r--r--tests/auto/cpptest/q3dbars-series/q3dbars-series.pro8
-rw-r--r--tests/auto/cpptest/q3dbars-series/tst_series.cpp169
-rw-r--r--tests/auto/cpptest/q3dbars/q3dbars.pro8
-rw-r--r--tests/auto/cpptest/q3dbars/tst_bars.cpp401
-rw-r--r--tests/auto/cpptest/q3dcustom-label/q3dcustom-label.pro8
-rw-r--r--tests/auto/cpptest/q3dcustom-label/tst_custom.cpp158
-rw-r--r--tests/auto/cpptest/q3dcustom-volume/q3dcustom-volume.pro8
-rw-r--r--tests/auto/cpptest/q3dcustom-volume/tst_custom.cpp204
-rw-r--r--tests/auto/cpptest/q3dcustom/q3dcustom.pro8
-rw-r--r--tests/auto/cpptest/q3dcustom/tst_custom.cpp128
-rw-r--r--tests/auto/cpptest/q3dinput-touch/q3dinput-touch.pro8
-rw-r--r--tests/auto/cpptest/q3dinput-touch/tst_input.cpp106
-rw-r--r--tests/auto/cpptest/q3dinput/q3dinput.pro8
-rw-r--r--tests/auto/cpptest/q3dinput/tst_input.cpp109
-rw-r--r--tests/auto/cpptest/q3dscatter-modelproxy/q3dscatter-modelproxy.pro8
-rw-r--r--tests/auto/cpptest/q3dscatter-modelproxy/tst_proxy.cpp193
-rw-r--r--tests/auto/cpptest/q3dscatter-proxy/q3dscatter-proxy.pro8
-rw-r--r--tests/auto/cpptest/q3dscatter-proxy/tst_proxy.cpp91
-rw-r--r--tests/auto/cpptest/q3dscatter-series/q3dscatter-series.pro8
-rw-r--r--tests/auto/cpptest/q3dscatter-series/tst_series.cpp110
-rw-r--r--tests/auto/cpptest/q3dscatter/q3dscatter.pro8
-rw-r--r--tests/auto/cpptest/q3dscatter/tst_scatter.cpp237
-rw-r--r--tests/auto/cpptest/q3dscene-camera/q3dscene-camera.pro8
-rw-r--r--tests/auto/cpptest/q3dscene-camera/tst_camera.cpp179
-rw-r--r--tests/auto/cpptest/q3dscene-light/q3dscene-light.pro8
-rw-r--r--tests/auto/cpptest/q3dscene-light/tst_light.cpp92
-rw-r--r--tests/auto/cpptest/q3dscene/q3dscene.pro8
-rw-r--r--tests/auto/cpptest/q3dscene/tst_scene.cpp170
-rw-r--r--tests/auto/cpptest/q3dsurface-heightproxy/customtexture.jpgbin0 -> 516 bytes
-rw-r--r--tests/auto/cpptest/q3dsurface-heightproxy/q3dsurface-heightproxy.pro11
-rw-r--r--tests/auto/cpptest/q3dsurface-heightproxy/q3dsurface-heightproxy.qrc5
-rw-r--r--tests/auto/cpptest/q3dsurface-heightproxy/tst_proxy.cpp156
-rw-r--r--tests/auto/cpptest/q3dsurface-modelproxy/q3dsurface-modelproxy.pro8
-rw-r--r--tests/auto/cpptest/q3dsurface-modelproxy/tst_proxy.cpp283
-rw-r--r--tests/auto/cpptest/q3dsurface-proxy/q3dsurface-proxy.pro8
-rw-r--r--tests/auto/cpptest/q3dsurface-proxy/tst_proxy.cpp98
-rw-r--r--tests/auto/cpptest/q3dsurface-series/q3dsurface-series.pro8
-rw-r--r--tests/auto/cpptest/q3dsurface-series/tst_series.cpp120
-rw-r--r--tests/auto/cpptest/q3dsurface/q3dsurface.pro8
-rw-r--r--tests/auto/cpptest/q3dsurface/tst_surface.cpp247
-rw-r--r--tests/auto/cpptest/q3dtheme/q3dtheme.pro8
-rw-r--r--tests/auto/cpptest/q3dtheme/tst_theme.cpp216
53 files changed, 4458 insertions, 0 deletions
diff --git a/tests/auto/cpptest/cpptest.pro b/tests/auto/cpptest/cpptest.pro
new file mode 100644
index 00000000..abd8f38e
--- /dev/null
+++ b/tests/auto/cpptest/cpptest.pro
@@ -0,0 +1,26 @@
+TEMPLATE = subdirs
+SUBDIRS = q3dbars \
+ q3dbars-proxy \
+ q3dbars-modelproxy \
+ q3dbars-series \
+ q3dscatter \
+ q3dscatter-proxy \
+ q3dscatter-modelproxy \
+ q3dscatter-series \
+ q3dsurface \
+ q3dsurface-proxy \
+ q3dsurface-modelproxy \
+ q3dsurface-heightproxy \
+ q3dsurface-series \
+ q3daxis-category \
+ q3daxis-logvalue \
+ q3daxis-value \
+ q3dscene \
+ q3dscene-camera \
+ q3dscene-light \
+ q3dtheme \
+ q3dinput \
+ q3dinput-touch \
+ q3dcustom \
+ q3dcustom-label \
+ q3dcustom-volume
diff --git a/tests/auto/cpptest/q3daxis-category/q3daxis-category.pro b/tests/auto/cpptest/q3daxis-category/q3daxis-category.pro
new file mode 100644
index 00000000..74415397
--- /dev/null
+++ b/tests/auto/cpptest/q3daxis-category/q3daxis-category.pro
@@ -0,0 +1,8 @@
+QT += testlib datavisualization
+
+TARGET = tst_cpptest
+CONFIG += console testcase
+
+TEMPLATE = app
+
+SOURCES += tst_axis.cpp
diff --git a/tests/auto/cpptest/q3daxis-category/tst_axis.cpp b/tests/auto/cpptest/q3daxis-category/tst_axis.cpp
new file mode 100644
index 00000000..800a0953
--- /dev/null
+++ b/tests/auto/cpptest/q3daxis-category/tst_axis.cpp
@@ -0,0 +1,133 @@
+/****************************************************************************
+**
+** 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/QCategory3DAxis>
+
+using namespace QtDataVisualization;
+
+class tst_axis: public QObject
+{
+ Q_OBJECT
+
+private slots:
+ void initTestCase();
+ void cleanupTestCase();
+ void init();
+ void cleanup();
+
+ void construct();
+
+ void initialProperties();
+ void initializeProperties();
+ void invalidProperties();
+
+private:
+ QCategory3DAxis *m_axis;
+};
+
+void tst_axis::initTestCase()
+{
+}
+
+void tst_axis::cleanupTestCase()
+{
+}
+
+void tst_axis::init()
+{
+ m_axis = new QCategory3DAxis();
+}
+
+void tst_axis::cleanup()
+{
+ delete m_axis;
+}
+
+void tst_axis::construct()
+{
+ QCategory3DAxis *axis = new QCategory3DAxis();
+ QVERIFY(axis);
+ delete axis;
+}
+
+void tst_axis::initialProperties()
+{
+ QVERIFY(m_axis);
+
+ QCOMPARE(m_axis->labels().length(), 0);
+
+ // Common (from QAbstract3DAxis)
+ QCOMPARE(m_axis->isAutoAdjustRange(), true);
+ QCOMPARE(m_axis->labelAutoRotation(), 0.0f);
+ QCOMPARE(m_axis->max(), 10.0f);
+ QCOMPARE(m_axis->min(), 0.0f);
+ QCOMPARE(m_axis->orientation(), QAbstract3DAxis::AxisOrientationNone);
+ QCOMPARE(m_axis->title(), QString(""));
+ QCOMPARE(m_axis->isTitleFixed(), true);
+ QCOMPARE(m_axis->isTitleVisible(), false);
+ QCOMPARE(m_axis->type(), QAbstract3DAxis::AxisTypeCategory);
+}
+
+void tst_axis::initializeProperties()
+{
+ QVERIFY(m_axis);
+
+ m_axis->setLabels(QStringList() << "first" << "second");
+
+ QCOMPARE(m_axis->labels().length(), 2);
+ QCOMPARE(m_axis->labels().at(1), QString("second"));
+
+ // Common (from QAbstract3DAxis)
+ m_axis->setAutoAdjustRange(false);
+ m_axis->setLabelAutoRotation(15.0f);
+ m_axis->setMax(25.0f);
+ m_axis->setMin(5.0f);
+ m_axis->setTitle("title");
+ m_axis->setTitleFixed(false);
+ m_axis->setTitleVisible(true);
+
+ QCOMPARE(m_axis->isAutoAdjustRange(), false);
+ QCOMPARE(m_axis->labelAutoRotation(), 15.0f);
+ QCOMPARE(m_axis->max(), 25.0f);
+ QCOMPARE(m_axis->min(), 5.0f);
+ QCOMPARE(m_axis->title(), QString("title"));
+ QCOMPARE(m_axis->isTitleFixed(), false);
+ QCOMPARE(m_axis->isTitleVisible(), true);
+}
+
+void tst_axis::invalidProperties()
+{
+ m_axis->setLabelAutoRotation(-15.0f);
+ QCOMPARE(m_axis->labelAutoRotation(), 0.0f);
+
+ m_axis->setLabelAutoRotation(100.0f);
+ QCOMPARE(m_axis->labelAutoRotation(), 90.0f);
+
+ m_axis->setMax(-10.0f);
+ QCOMPARE(m_axis->max(), 0.0f);
+ QCOMPARE(m_axis->min(), 0.0f);
+
+ m_axis->setMin(10.0f);
+ QCOMPARE(m_axis->max(), 11.0f);
+ QCOMPARE(m_axis->min(), 10.0f);
+}
+
+QTEST_MAIN(tst_axis)
+#include "tst_axis.moc"
diff --git a/tests/auto/cpptest/q3daxis-logvalue/q3daxis-logvalue.pro b/tests/auto/cpptest/q3daxis-logvalue/q3daxis-logvalue.pro
new file mode 100644
index 00000000..74415397
--- /dev/null
+++ b/tests/auto/cpptest/q3daxis-logvalue/q3daxis-logvalue.pro
@@ -0,0 +1,8 @@
+QT += testlib datavisualization
+
+TARGET = tst_cpptest
+CONFIG += console testcase
+
+TEMPLATE = app
+
+SOURCES += tst_axis.cpp
diff --git a/tests/auto/cpptest/q3daxis-logvalue/tst_axis.cpp b/tests/auto/cpptest/q3daxis-logvalue/tst_axis.cpp
new file mode 100644
index 00000000..adbedb24
--- /dev/null
+++ b/tests/auto/cpptest/q3daxis-logvalue/tst_axis.cpp
@@ -0,0 +1,102 @@
+/****************************************************************************
+**
+** 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/QLogValue3DAxisFormatter>
+
+using namespace QtDataVisualization;
+
+class tst_axis: public QObject
+{
+ Q_OBJECT
+
+private slots:
+ void initTestCase();
+ void cleanupTestCase();
+ void init();
+ void cleanup();
+
+ void construct();
+
+ void initialProperties();
+ void initializeProperties();
+ void invalidProperties();
+
+private:
+ QLogValue3DAxisFormatter *m_formatter;
+};
+
+void tst_axis::initTestCase()
+{
+}
+
+void tst_axis::cleanupTestCase()
+{
+}
+
+void tst_axis::init()
+{
+ m_formatter = new QLogValue3DAxisFormatter();
+}
+
+void tst_axis::cleanup()
+{
+ delete m_formatter;
+}
+
+void tst_axis::construct()
+{
+ QLogValue3DAxisFormatter *formatter = new QLogValue3DAxisFormatter();
+ QVERIFY(formatter);
+ delete formatter;
+}
+
+void tst_axis::initialProperties()
+{
+ QVERIFY(m_formatter);
+
+ QCOMPARE(m_formatter->autoSubGrid(), true);
+ QCOMPARE(m_formatter->base(), 10.0);
+ QCOMPARE(m_formatter->showEdgeLabels(), true);
+}
+
+void tst_axis::initializeProperties()
+{
+ QVERIFY(m_formatter);
+
+ m_formatter->setAutoSubGrid(false);
+ m_formatter->setBase(0.1);
+ m_formatter->setShowEdgeLabels(false);
+
+ QCOMPARE(m_formatter->autoSubGrid(), false);
+ QCOMPARE(m_formatter->base(), 0.1);
+ QCOMPARE(m_formatter->showEdgeLabels(), false);
+}
+
+void tst_axis::invalidProperties()
+{
+ m_formatter->setBase(-1.0);
+ QCOMPARE(m_formatter->base(), 10.0);
+
+ m_formatter->setBase(1.0);
+ QCOMPARE(m_formatter->base(), 10.0);
+}
+
+QTEST_MAIN(tst_axis)
+#include "tst_axis.moc"
diff --git a/tests/auto/cpptest/q3daxis-value/q3daxis-value.pro b/tests/auto/cpptest/q3daxis-value/q3daxis-value.pro
new file mode 100644
index 00000000..74415397
--- /dev/null
+++ b/tests/auto/cpptest/q3daxis-value/q3daxis-value.pro
@@ -0,0 +1,8 @@
+QT += testlib datavisualization
+
+TARGET = tst_cpptest
+CONFIG += console testcase
+
+TEMPLATE = app
+
+SOURCES += tst_axis.cpp
diff --git a/tests/auto/cpptest/q3daxis-value/tst_axis.cpp b/tests/auto/cpptest/q3daxis-value/tst_axis.cpp
new file mode 100644
index 00000000..92029f13
--- /dev/null
+++ b/tests/auto/cpptest/q3daxis-value/tst_axis.cpp
@@ -0,0 +1,158 @@
+/****************************************************************************
+**
+** 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/QValue3DAxis>
+
+using namespace QtDataVisualization;
+
+class tst_axis: public QObject
+{
+ Q_OBJECT
+
+private slots:
+ void initTestCase();
+ void cleanupTestCase();
+ void init();
+ void cleanup();
+
+ void construct();
+
+ void initialProperties();
+ void initializeProperties();
+ void invalidProperties();
+
+private:
+ QValue3DAxis *m_axis;
+};
+
+void tst_axis::initTestCase()
+{
+}
+
+void tst_axis::cleanupTestCase()
+{
+}
+
+void tst_axis::init()
+{
+ m_axis = new QValue3DAxis();
+}
+
+void tst_axis::cleanup()
+{
+ delete m_axis;
+}
+
+void tst_axis::construct()
+{
+ QValue3DAxis *axis = new QValue3DAxis();
+ QVERIFY(axis);
+ delete axis;
+}
+
+void tst_axis::initialProperties()
+{
+ QVERIFY(m_axis);
+
+ QCOMPARE(m_axis->labelFormat(), QString("%.2f"));
+ QCOMPARE(m_axis->reversed(), false);
+ QCOMPARE(m_axis->segmentCount(), 5);
+ QCOMPARE(m_axis->subSegmentCount(), 1);
+
+ // Common (from QAbstract3DAxis)
+ QCOMPARE(m_axis->isAutoAdjustRange(), true);
+ QCOMPARE(m_axis->labelAutoRotation(), 0.0f);
+ QCOMPARE(m_axis->labels().length(), 6);
+ QCOMPARE(m_axis->labels().at(0), QString("0.00"));
+ QCOMPARE(m_axis->labels().at(1), QString("2.00"));
+ QCOMPARE(m_axis->labels().at(2), QString("4.00"));
+ QCOMPARE(m_axis->labels().at(3), QString("6.00"));
+ QCOMPARE(m_axis->labels().at(4), QString("8.00"));
+ QCOMPARE(m_axis->labels().at(5), QString("10.00"));
+ QCOMPARE(m_axis->max(), 10.0f);
+ QCOMPARE(m_axis->min(), 0.0f);
+ QCOMPARE(m_axis->orientation(), QAbstract3DAxis::AxisOrientationNone);
+ QCOMPARE(m_axis->title(), QString(""));
+ QCOMPARE(m_axis->isTitleFixed(), true);
+ QCOMPARE(m_axis->isTitleVisible(), false);
+ QCOMPARE(m_axis->type(), QAbstract3DAxis::AxisTypeValue);
+}
+
+void tst_axis::initializeProperties()
+{
+ QVERIFY(m_axis);
+
+ m_axis->setLabelFormat("%.0fm");
+ m_axis->setReversed(true);
+ m_axis->setSegmentCount(2);
+ m_axis->setSubSegmentCount(5);
+
+ QCOMPARE(m_axis->labelFormat(), QString("%.0fm"));
+ QCOMPARE(m_axis->reversed(), true);
+ QCOMPARE(m_axis->segmentCount(), 2);
+ QCOMPARE(m_axis->subSegmentCount(), 5);
+
+ // Common (from QAbstract3DAxis)
+ m_axis->setAutoAdjustRange(false);
+ m_axis->setLabelAutoRotation(15.0f);
+ m_axis->setMax(25.0f);
+ m_axis->setMin(5.0f);
+ m_axis->setTitle("title");
+ m_axis->setTitleFixed(false);
+ m_axis->setTitleVisible(true);
+
+ QCOMPARE(m_axis->isAutoAdjustRange(), false);
+ QCOMPARE(m_axis->labelAutoRotation(), 15.0f);
+ QCOMPARE(m_axis->labels().length(), 3);
+ QCOMPARE(m_axis->labels().at(0), QString("5m"));
+ QCOMPARE(m_axis->labels().at(1), QString("15m"));
+ QCOMPARE(m_axis->labels().at(2), QString("25m"));
+ QCOMPARE(m_axis->max(), 25.0f);
+ QCOMPARE(m_axis->min(), 5.0f);
+ QCOMPARE(m_axis->title(), QString("title"));
+ QCOMPARE(m_axis->isTitleFixed(), false);
+ QCOMPARE(m_axis->isTitleVisible(), true);
+}
+
+void tst_axis::invalidProperties()
+{
+ m_axis->setSegmentCount(-1);
+ QCOMPARE(m_axis->segmentCount(), 1);
+
+ m_axis->setSubSegmentCount(-1);
+ QCOMPARE(m_axis->subSegmentCount(), 1);
+
+ m_axis->setLabelAutoRotation(-15.0f);
+ QCOMPARE(m_axis->labelAutoRotation(), 0.0f);
+
+ m_axis->setLabelAutoRotation(100.0f);
+ QCOMPARE(m_axis->labelAutoRotation(), 90.0f);
+
+ m_axis->setMax(-10.0f);
+ QCOMPARE(m_axis->max(), -10.0f);
+ QCOMPARE(m_axis->min(), -11.0f);
+
+ m_axis->setMin(10.0f);
+ QCOMPARE(m_axis->max(), 11.0f);
+ QCOMPARE(m_axis->min(), 10.0f);
+}
+
+QTEST_MAIN(tst_axis)
+#include "tst_axis.moc"
diff --git a/tests/auto/cpptest/q3dbars-modelproxy/q3dbars-modelproxy.pro b/tests/auto/cpptest/q3dbars-modelproxy/q3dbars-modelproxy.pro
new file mode 100644
index 00000000..c383ec25
--- /dev/null
+++ b/tests/auto/cpptest/q3dbars-modelproxy/q3dbars-modelproxy.pro
@@ -0,0 +1,8 @@
+QT += testlib datavisualization widgets
+
+TARGET = tst_cpptest
+CONFIG += console testcase
+
+TEMPLATE = app
+
+SOURCES += tst_proxy.cpp
diff --git a/tests/auto/cpptest/q3dbars-modelproxy/tst_proxy.cpp b/tests/auto/cpptest/q3dbars-modelproxy/tst_proxy.cpp
new file mode 100644
index 00000000..c65e151b
--- /dev/null
+++ b/tests/auto/cpptest/q3dbars-modelproxy/tst_proxy.cpp
@@ -0,0 +1,267 @@
+/****************************************************************************
+**
+** 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/QItemModelBarDataProxy>
+#include <QtDataVisualization/Q3DBars>
+#include <QtWidgets/QTableWidget>
+
+using namespace QtDataVisualization;
+
+class tst_proxy: public QObject
+{
+ Q_OBJECT
+
+private slots:
+ void initTestCase();
+ void cleanupTestCase();
+ void init();
+ void cleanup();
+
+ void construct();
+
+ void initialProperties();
+ void initializeProperties();
+
+ void multiMatch();
+
+private:
+ QItemModelBarDataProxy *m_proxy;
+};
+
+void tst_proxy::initTestCase()
+{
+}
+
+void tst_proxy::cleanupTestCase()
+{
+}
+
+void tst_proxy::init()
+{
+ m_proxy = new QItemModelBarDataProxy();
+}
+
+void tst_proxy::cleanup()
+{
+ delete m_proxy;
+}
+
+void tst_proxy::construct()
+{
+ QItemModelBarDataProxy *proxy = new QItemModelBarDataProxy();
+ QVERIFY(proxy);
+ delete proxy;
+
+ QTableWidget *table = new QTableWidget();
+
+ proxy = new QItemModelBarDataProxy(table->model());
+ QVERIFY(proxy);
+ delete proxy;
+
+ proxy = new QItemModelBarDataProxy(table->model(), "val");
+ QVERIFY(proxy);
+ QCOMPARE(proxy->rowRole(), QString(""));
+ QCOMPARE(proxy->columnRole(), QString(""));
+ QCOMPARE(proxy->valueRole(), QString("val"));
+ QCOMPARE(proxy->rotationRole(), QString(""));
+ QCOMPARE(proxy->rowCategories().length(), 0);
+ QCOMPARE(proxy->columnCategories().length(), 0);
+ delete proxy;
+
+ proxy = new QItemModelBarDataProxy(table->model(), "row", "col", "val");
+ QVERIFY(proxy);
+ QCOMPARE(proxy->rowRole(), QString("row"));
+ QCOMPARE(proxy->columnRole(), QString("col"));
+ QCOMPARE(proxy->valueRole(), QString("val"));
+ QCOMPARE(proxy->rotationRole(), QString(""));
+ QCOMPARE(proxy->rowCategories().length(), 0);
+ QCOMPARE(proxy->columnCategories().length(), 0);
+ delete proxy;
+
+ proxy = new QItemModelBarDataProxy(table->model(), "row", "col", "val", "rot");
+ QVERIFY(proxy);
+ QCOMPARE(proxy->rowRole(), QString("row"));
+ QCOMPARE(proxy->columnRole(), QString("col"));
+ QCOMPARE(proxy->valueRole(), QString("val"));
+ QCOMPARE(proxy->rotationRole(), QString("rot"));
+ QCOMPARE(proxy->rowCategories().length(), 0);
+ QCOMPARE(proxy->columnCategories().length(), 0);
+ delete proxy;
+
+ proxy = new QItemModelBarDataProxy(table->model(), "row", "col", "val",
+ QStringList() << "rowCat", QStringList() << "colCat");
+ QVERIFY(proxy);
+ QCOMPARE(proxy->rowRole(), QString("row"));
+ QCOMPARE(proxy->columnRole(), QString("col"));
+ QCOMPARE(proxy->valueRole(), QString("val"));
+ QCOMPARE(proxy->rotationRole(), QString(""));
+ QCOMPARE(proxy->rowCategories().length(), 1);
+ QCOMPARE(proxy->columnCategories().length(), 1);
+ delete proxy;
+
+ proxy = new QItemModelBarDataProxy(table->model(), "row", "col", "val", "rot",
+ QStringList() << "rowCat", QStringList() << "colCat");
+ QVERIFY(proxy);
+ QCOMPARE(proxy->rowRole(), QString("row"));
+ QCOMPARE(proxy->columnRole(), QString("col"));
+ QCOMPARE(proxy->valueRole(), QString("val"));
+ QCOMPARE(proxy->rotationRole(), QString("rot"));
+ QCOMPARE(proxy->rowCategories().length(), 1);
+ QCOMPARE(proxy->columnCategories().length(), 1);
+ delete proxy;
+}
+
+void tst_proxy::initialProperties()
+{
+ QVERIFY(m_proxy);
+
+ QCOMPARE(m_proxy->autoColumnCategories(), true);
+ QCOMPARE(m_proxy->autoRowCategories(), true);
+ QCOMPARE(m_proxy->columnCategories(), QStringList());
+ QCOMPARE(m_proxy->columnRole(), QString());
+ QCOMPARE(m_proxy->columnRolePattern(), QRegExp());
+ QCOMPARE(m_proxy->columnRoleReplace(), QString());
+ QVERIFY(!m_proxy->itemModel());
+ QCOMPARE(m_proxy->multiMatchBehavior(), QItemModelBarDataProxy::MMBLast);
+ QCOMPARE(m_proxy->rotationRole(), QString());
+ QCOMPARE(m_proxy->rotationRolePattern(), QRegExp());
+ QCOMPARE(m_proxy->rotationRoleReplace(), QString());
+ QCOMPARE(m_proxy->rowCategories(), QStringList());
+ QCOMPARE(m_proxy->rowRole(), QString());
+ QCOMPARE(m_proxy->rowRolePattern(), QRegExp());
+ QCOMPARE(m_proxy->rowRoleReplace(), QString());
+ QCOMPARE(m_proxy->useModelCategories(), false);
+ QCOMPARE(m_proxy->valueRole(), QString());
+ QCOMPARE(m_proxy->valueRolePattern(), QRegExp());
+ QCOMPARE(m_proxy->valueRoleReplace(), QString());
+
+ QCOMPARE(m_proxy->columnLabels().count(), 0);
+ QCOMPARE(m_proxy->rowCount(), 0);
+ QCOMPARE(m_proxy->rowLabels().count(), 0);
+ QVERIFY(!m_proxy->series());
+
+ QCOMPARE(m_proxy->type(), QAbstractDataProxy::DataTypeBar);
+}
+
+void tst_proxy::initializeProperties()
+{
+ QVERIFY(m_proxy);
+
+ QTableWidget *table = new QTableWidget();
+
+ m_proxy->setAutoColumnCategories(false);
+ m_proxy->setAutoRowCategories(false);
+ m_proxy->setColumnCategories(QStringList() << "col1" << "col2");
+ m_proxy->setColumnRole("column");
+ m_proxy->setColumnRolePattern(QRegExp("/^.*-(\\d\\d)$/"));
+ m_proxy->setColumnRoleReplace("\\\\1");
+ m_proxy->setItemModel(table->model());
+ m_proxy->setMultiMatchBehavior(QItemModelBarDataProxy::MMBAverage);
+ m_proxy->setRotationRole("rotation");
+ m_proxy->setRotationRolePattern(QRegExp("/-/"));
+ m_proxy->setRotationRoleReplace("\\\\1");
+ m_proxy->setRowCategories(QStringList() << "row1" << "row2");
+ m_proxy->setRowRole("row");
+ m_proxy->setRowRolePattern(QRegExp("/^(\\d\\d\\d\\d).*$/"));
+ m_proxy->setRowRoleReplace("\\\\1");
+ m_proxy->setUseModelCategories(true);
+ m_proxy->setValueRole("value");
+ m_proxy->setValueRolePattern(QRegExp("/-/"));
+ m_proxy->setValueRoleReplace("\\\\1");
+
+ QCOMPARE(m_proxy->autoColumnCategories(), false);
+ QCOMPARE(m_proxy->autoRowCategories(), false);
+ QCOMPARE(m_proxy->columnCategories().count(), 2);
+ QCOMPARE(m_proxy->columnRole(), QString("column"));
+ QCOMPARE(m_proxy->columnRolePattern(), QRegExp("/^.*-(\\d\\d)$/"));
+ QCOMPARE(m_proxy->columnRoleReplace(), QString("\\\\1"));
+ QVERIFY(m_proxy->itemModel());
+ QCOMPARE(m_proxy->multiMatchBehavior(), QItemModelBarDataProxy::MMBAverage);
+ QCOMPARE(m_proxy->rotationRole(), QString("rotation"));
+ QCOMPARE(m_proxy->rotationRolePattern(), QRegExp("/-/"));
+ QCOMPARE(m_proxy->rotationRoleReplace(), QString("\\\\1"));
+ QCOMPARE(m_proxy->rowCategories().count(), 2);
+ QCOMPARE(m_proxy->rowRole(), QString("row"));
+ QCOMPARE(m_proxy->rowRolePattern(), QRegExp("/^(\\d\\d\\d\\d).*$/"));
+ QCOMPARE(m_proxy->rowRoleReplace(), QString("\\\\1"));
+ QCOMPARE(m_proxy->useModelCategories(), true);
+ QCOMPARE(m_proxy->valueRole(), QString("value"));
+ QCOMPARE(m_proxy->valueRolePattern(), QRegExp("/-/"));
+ QCOMPARE(m_proxy->valueRoleReplace(), QString("\\\\1"));
+}
+
+void tst_proxy::multiMatch()
+{
+ Q3DBars *graph = new Q3DBars();
+
+ QTableWidget *table = new QTableWidget();
+ QStringList rows;
+ rows << "row 1" << "row 2" << "row 3";
+ QStringList columns;
+ columns << "col 1";
+ const char *values[1][3] = {{"0/0/3.5/30", "0/0/5.0/30", "0/0/6.5/30"}};
+
+ table->setRowCount(1);
+ table->setColumnCount(3);
+
+ for (int col = 0; col < columns.size(); col++) {
+ for (int row = 0; row < rows.size(); row++) {
+ QModelIndex index = table->model()->index(col, row);
+ table->model()->setData(index, values[col][row]);
+ }
+ }
+
+ m_proxy->setItemModel(table->model());
+ m_proxy->setRowRole(table->model()->roleNames().value(Qt::DisplayRole));
+ m_proxy->setColumnRole(table->model()->roleNames().value(Qt::DisplayRole));
+ m_proxy->setRowRolePattern(QRegExp(QStringLiteral("^(\\d*)\\/(\\d*)\\/\\d*[\\.\\,]?\\d*\\/\\d*[\\.\\,]?\\d*$")));
+ m_proxy->setRowRoleReplace(QStringLiteral("\\2"));
+ m_proxy->setValueRolePattern(QRegExp(QStringLiteral("^\\d*(\\/)(\\d*)\\/(\\d*[\\.\\,]?\\d*)\\/\\d*[\\.\\,]?\\d*$")));
+ m_proxy->setValueRoleReplace(QStringLiteral("\\3"));
+ m_proxy->setColumnRolePattern(QRegExp(QStringLiteral("^(\\d*)(\\/)(\\d*)\\/\\d*[\\.\\,]?\\d*\\/\\d*[\\.\\,]?\\d*$")));
+ m_proxy->setColumnRoleReplace(QStringLiteral("\\1"));
+
+ QBar3DSeries *series = new QBar3DSeries(m_proxy);
+
+ graph->addSeries(series);
+
+ QCoreApplication::processEvents();
+ QCOMPARE(graph->valueAxis()->max(), 6.5f);
+ m_proxy->setMultiMatchBehavior(QItemModelBarDataProxy::MMBFirst);
+ QCoreApplication::processEvents();
+ QCOMPARE(graph->valueAxis()->max(), 3.5f);
+ m_proxy->setMultiMatchBehavior(QItemModelBarDataProxy::MMBLast);
+ QCoreApplication::processEvents();
+ QCOMPARE(graph->valueAxis()->max(), 6.5f);
+ m_proxy->setMultiMatchBehavior(QItemModelBarDataProxy::MMBAverage);
+ QCoreApplication::processEvents();
+ QCOMPARE(graph->valueAxis()->max(), 5.0f);
+ m_proxy->setMultiMatchBehavior(QItemModelBarDataProxy::MMBCumulative);
+ QCoreApplication::processEvents();
+ QCOMPARE(graph->valueAxis()->max(), 15.0f);
+
+ QCOMPARE(m_proxy->columnLabels().count(), 1);
+ QCOMPARE(m_proxy->rowCount(), 1);
+ QCOMPARE(m_proxy->rowLabels().count(), 1);
+ QVERIFY(m_proxy->series());
+}
+
+QTEST_MAIN(tst_proxy)
+#include "tst_proxy.moc"
diff --git a/tests/auto/cpptest/q3dbars-proxy/q3dbars-proxy.pro b/tests/auto/cpptest/q3dbars-proxy/q3dbars-proxy.pro
new file mode 100644
index 00000000..b0b5d361
--- /dev/null
+++ b/tests/auto/cpptest/q3dbars-proxy/q3dbars-proxy.pro
@@ -0,0 +1,8 @@
+QT += testlib datavisualization
+
+TARGET = tst_cpptest
+CONFIG += console testcase
+
+TEMPLATE = app
+
+SOURCES += tst_proxy.cpp
diff --git a/tests/auto/cpptest/q3dbars-proxy/tst_proxy.cpp b/tests/auto/cpptest/q3dbars-proxy/tst_proxy.cpp
new file mode 100644
index 00000000..8d64ed54
--- /dev/null
+++ b/tests/auto/cpptest/q3dbars-proxy/tst_proxy.cpp
@@ -0,0 +1,97 @@
+/****************************************************************************
+**
+** 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/QBarDataProxy>
+
+using namespace QtDataVisualization;
+
+class tst_proxy: public QObject
+{
+ Q_OBJECT
+
+private slots:
+ void initTestCase();
+ void cleanupTestCase();
+ void init();
+ void cleanup();
+
+ void construct();
+
+ void initialProperties();
+ void initializeProperties();
+
+private:
+ QBarDataProxy *m_proxy;
+};
+
+void tst_proxy::initTestCase()
+{
+}
+
+void tst_proxy::cleanupTestCase()
+{
+}
+
+void tst_proxy::init()
+{
+ m_proxy = new QBarDataProxy();
+}
+
+void tst_proxy::cleanup()
+{
+ delete m_proxy;
+}
+
+void tst_proxy::construct()
+{
+ QBarDataProxy *proxy = new QBarDataProxy();
+ QVERIFY(proxy);
+ delete proxy;
+}
+
+void tst_proxy::initialProperties()
+{
+ QVERIFY(m_proxy);
+
+ QCOMPARE(m_proxy->columnLabels().count(), 0);
+ QCOMPARE(m_proxy->rowCount(), 0);
+ QCOMPARE(m_proxy->rowLabels().count(), 0);
+ QVERIFY(!m_proxy->series());
+
+ QCOMPARE(m_proxy->type(), QAbstractDataProxy::DataTypeBar);
+}
+
+void tst_proxy::initializeProperties()
+{
+ QVERIFY(m_proxy);
+
+ m_proxy->setColumnLabels(QStringList() << "1" << "2" << "3");
+ QBarDataRow *data = new QBarDataRow;
+ *data << 1.0f << 3.0f << 7.5f;
+ m_proxy->addRow(data);
+ m_proxy->setRowLabels(QStringList() << "1");
+
+ QCOMPARE(m_proxy->columnLabels().count(), 3);
+ QCOMPARE(m_proxy->rowCount(), 1);
+ QCOMPARE(m_proxy->rowLabels().count(), 1);
+}
+
+QTEST_MAIN(tst_proxy)
+#include "tst_proxy.moc"
diff --git a/tests/auto/cpptest/q3dbars-series/q3dbars-series.pro b/tests/auto/cpptest/q3dbars-series/q3dbars-series.pro
new file mode 100644
index 00000000..481653ef
--- /dev/null
+++ b/tests/auto/cpptest/q3dbars-series/q3dbars-series.pro
@@ -0,0 +1,8 @@
+QT += testlib datavisualization
+
+TARGET = tst_cpptest
+CONFIG += console testcase
+
+TEMPLATE = app
+
+SOURCES += tst_series.cpp
diff --git a/tests/auto/cpptest/q3dbars-series/tst_series.cpp b/tests/auto/cpptest/q3dbars-series/tst_series.cpp
new file mode 100644
index 00000000..e2a40ae7
--- /dev/null
+++ b/tests/auto/cpptest/q3dbars-series/tst_series.cpp
@@ -0,0 +1,169 @@
+/****************************************************************************
+**
+** 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/QBar3DSeries>
+
+using namespace QtDataVisualization;
+
+class tst_series: public QObject
+{
+ Q_OBJECT
+
+private slots:
+ void initTestCase();
+ void cleanupTestCase();
+ void init();
+ void cleanup();
+
+ void construct();
+
+ void initialProperties();
+ void initializeProperties();
+ void invalidProperties();
+
+private:
+ QBar3DSeries *m_series;
+};
+
+void tst_series::initTestCase()
+{
+}
+
+void tst_series::cleanupTestCase()
+{
+}
+
+void tst_series::init()
+{
+ m_series = new QBar3DSeries();
+}
+
+void tst_series::cleanup()
+{
+ delete m_series;
+}
+
+void tst_series::construct()
+{
+ QBar3DSeries *series = new QBar3DSeries();
+ QVERIFY(series);
+ delete series;
+
+ QBarDataProxy *proxy = new QBarDataProxy();
+
+ series = new QBar3DSeries(proxy);
+ QVERIFY(series);
+ QCOMPARE(series->dataProxy(), proxy);
+ delete series;
+}
+
+void tst_series::initialProperties()
+{
+ QVERIFY(m_series);
+
+ QVERIFY(m_series->dataProxy());
+ QCOMPARE(m_series->meshAngle(), 0.0f);
+ QCOMPARE(m_series->selectedBar(), m_series->invalidSelectionPosition());
+
+ // Common properties
+ QCOMPARE(m_series->baseColor(), QColor(Qt::black));
+ QCOMPARE(m_series->baseGradient(), QLinearGradient());
+ QCOMPARE(m_series->colorStyle(), Q3DTheme::ColorStyleUniform);
+ QCOMPARE(m_series->itemLabel(), QString(""));
+ QCOMPARE(m_series->itemLabelFormat(), QString("@valueLabel"));
+ QCOMPARE(m_series->isItemLabelVisible(), true);
+ QCOMPARE(m_series->mesh(), QAbstract3DSeries::MeshBevelBar);
+ QCOMPARE(m_series->meshRotation(), QQuaternion(1, 0, 0, 0));
+ QCOMPARE(m_series->isMeshSmooth(), false);
+ QCOMPARE(m_series->multiHighlightColor(), QColor(Qt::black));
+ QCOMPARE(m_series->multiHighlightGradient(), QLinearGradient());
+ QCOMPARE(m_series->name(), QString(""));
+ QCOMPARE(m_series->singleHighlightColor(), QColor(Qt::black));
+ QCOMPARE(m_series->singleHighlightGradient(), QLinearGradient());
+ QCOMPARE(m_series->type(), QAbstract3DSeries::SeriesTypeBar);
+ QCOMPARE(m_series->userDefinedMesh(), QString(""));
+ QCOMPARE(m_series->isVisible(), true);
+}
+
+void tst_series::initializeProperties()
+{
+ QVERIFY(m_series);
+
+ m_series->setDataProxy(new QBarDataProxy());
+ m_series->setMeshAngle(15.0f);
+ m_series->setSelectedBar(QPoint(0, 0));
+
+ QCOMPARE(m_series->meshAngle(), 15.0f);
+ QCOMPARE(m_series->selectedBar(), QPoint(0, 0));
+
+ QLinearGradient gradient1;
+ gradient1.setColorAt(0.0, Qt::red);
+ gradient1.setColorAt(1.0, Qt::blue);
+ QLinearGradient gradient2;
+ gradient2.setColorAt(0.0, Qt::yellow);
+ gradient2.setColorAt(1.0, Qt::green);
+ QLinearGradient gradient3;
+ gradient3.setColorAt(0.0, Qt::white);
+ gradient3.setColorAt(1.0, Qt::gray);
+
+ // Common properties
+ m_series->setBaseColor(QColor(Qt::blue));
+ m_series->setBaseGradient(gradient1);
+ m_series->setColorStyle(Q3DTheme::ColorStyleRangeGradient);
+ m_series->setItemLabelFormat("%f");
+ m_series->setItemLabelVisible(false);
+ m_series->setMesh(QAbstract3DSeries::MeshCone);
+ m_series->setMeshSmooth(true);
+ m_series->setMultiHighlightColor(QColor(Qt::green));
+ m_series->setMultiHighlightGradient(gradient2);
+ m_series->setName("name");
+ m_series->setSingleHighlightColor(QColor(Qt::red));
+ m_series->setSingleHighlightGradient(gradient3);
+ m_series->setUserDefinedMesh(":/customitem.obj");
+ m_series->setVisible(false);
+
+ QCOMPARE(m_series->baseColor(), QColor(Qt::blue));
+ QCOMPARE(m_series->baseGradient(), gradient1);
+ QCOMPARE(m_series->baseGradient().stops().at(0).second, QColor(Qt::red));
+ QCOMPARE(m_series->colorStyle(), Q3DTheme::ColorStyleRangeGradient);
+ QCOMPARE(m_series->itemLabelFormat(), QString("%f"));
+ QCOMPARE(m_series->isItemLabelVisible(), false);
+ QCOMPARE(m_series->mesh(), QAbstract3DSeries::MeshCone);
+ QCOMPARE(m_series->isMeshSmooth(), true);
+ QCOMPARE(m_series->multiHighlightColor(), QColor(Qt::green));
+ QCOMPARE(m_series->multiHighlightGradient(), gradient2);
+ QCOMPARE(m_series->multiHighlightGradient().stops().at(0).second, QColor(Qt::yellow));
+ QCOMPARE(m_series->name(), QString("name"));
+ QCOMPARE(m_series->singleHighlightColor(), QColor(Qt::red));
+ QCOMPARE(m_series->singleHighlightGradient(), gradient3);
+ QCOMPARE(m_series->singleHighlightGradient().stops().at(0).second, QColor(Qt::white));
+ QCOMPARE(m_series->userDefinedMesh(), QString(":/customitem.obj"));
+ QCOMPARE(m_series->isVisible(), false);
+}
+
+void tst_series::invalidProperties()
+{
+ m_series->setMesh(QAbstract3DSeries::MeshMinimal);
+
+ QCOMPARE(m_series->mesh(), QAbstract3DSeries::MeshBevelBar);
+}
+
+QTEST_MAIN(tst_series)
+#include "tst_series.moc"
diff --git a/tests/auto/cpptest/q3dbars/q3dbars.pro b/tests/auto/cpptest/q3dbars/q3dbars.pro
new file mode 100644
index 00000000..a7f7c809
--- /dev/null
+++ b/tests/auto/cpptest/q3dbars/q3dbars.pro
@@ -0,0 +1,8 @@
+QT += testlib datavisualization
+
+TARGET = tst_cpptest
+CONFIG += console testcase
+
+TEMPLATE = app
+
+SOURCES += tst_bars.cpp
diff --git a/tests/auto/cpptest/q3dbars/tst_bars.cpp b/tests/auto/cpptest/q3dbars/tst_bars.cpp
new file mode 100644
index 00000000..6910e4fa
--- /dev/null
+++ b/tests/auto/cpptest/q3dbars/tst_bars.cpp
@@ -0,0 +1,401 @@
+/****************************************************************************
+**
+** 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/Q3DBars>
+#include <QtDataVisualization/QCustom3DItem>
+#include <QtDataVisualization/Q3DInputHandler>
+#include <QtDataVisualization/QTouch3DInputHandler>
+
+using namespace QtDataVisualization;
+
+class tst_bars: public QObject
+{
+ Q_OBJECT
+
+private slots:
+ void initTestCase();
+ void cleanupTestCase();
+ void init();
+ void cleanup();
+
+ void construct();
+
+ void initialProperties();
+ void initializeProperties();
+ void invalidProperties();
+
+ void addSeries();
+ void addMultipleSeries();
+ void selectSeries();
+ void removeSeries();
+ void removeMultipleSeries();
+
+ // The following tests are not required for scatter or surface, as they are handled identically
+ void addInputHandler();
+ void removeInputHandler();
+
+ void addTheme();
+ void removeTheme();
+
+ void addCustomItem();
+ void removeCustomItem();
+
+ void renderToImage();
+
+private:
+ Q3DBars *m_graph;
+};
+
+QBar3DSeries *newSeries()
+{
+ QBar3DSeries *series = new QBar3DSeries;
+ QBarDataRow *data = new QBarDataRow;
+ *data << -1.0f << 3.0f << 7.5f << 5.0f << 2.2f;
+ series->dataProxy()->addRow(data);
+ return series;
+}
+
+void tst_bars::initTestCase()
+{
+}
+
+void tst_bars::cleanupTestCase()
+{
+}
+
+void tst_bars::init()
+{
+ m_graph = new Q3DBars();
+}
+
+void tst_bars::cleanup()
+{
+ delete m_graph;
+}
+
+void tst_bars::construct()
+{
+ Q3DBars *graph = new Q3DBars();
+ QVERIFY(graph);
+ delete graph;
+
+ graph = new Q3DBars(new QSurfaceFormat());
+ QVERIFY(graph);
+ delete graph;
+}
+
+void tst_bars::initialProperties()
+{
+ QVERIFY(m_graph);
+ QCOMPARE(m_graph->isMultiSeriesUniform(), false);
+ QCOMPARE(m_graph->barThickness(), 1.0);
+ QCOMPARE(m_graph->barSpacing(), QSizeF(1.0f, 1.0f));
+ QCOMPARE(m_graph->isBarSpacingRelative(), true);
+ QCOMPARE(m_graph->seriesList().length(), 0);
+ QVERIFY(!m_graph->selectedSeries());
+ QVERIFY(!m_graph->primarySeries());
+ QCOMPARE(m_graph->floorLevel(), 0.0);
+ QCOMPARE(m_graph->columnAxis()->orientation(), QAbstract3DAxis::AxisOrientationX);
+ QCOMPARE(m_graph->valueAxis()->orientation(), QAbstract3DAxis::AxisOrientationY);
+ QCOMPARE(m_graph->rowAxis()->orientation(), QAbstract3DAxis::AxisOrientationZ);
+
+ // Common properties
+ QCOMPARE(m_graph->activeTheme()->type(), Q3DTheme::ThemeQt);
+ QCOMPARE(m_graph->selectionMode(), QAbstract3DGraph::SelectionItem);
+ QCOMPARE(m_graph->shadowQuality(), QAbstract3DGraph::ShadowQualityMedium);
+ QVERIFY(m_graph->scene());
+ QCOMPARE(m_graph->measureFps(), false);
+ QCOMPARE(m_graph->isOrthoProjection(), false);
+ QCOMPARE(m_graph->selectedElement(), QAbstract3DGraph::ElementNone);
+ QCOMPARE(m_graph->aspectRatio(), 2.0);
+ QCOMPARE(m_graph->optimizationHints(), QAbstract3DGraph::OptimizationDefault);
+ QCOMPARE(m_graph->isPolar(), false);
+ QCOMPARE(m_graph->radialLabelOffset(), 1.0);
+ QCOMPARE(m_graph->horizontalAspectRatio(), 0.0);
+ QCOMPARE(m_graph->isReflection(), false);
+ QCOMPARE(m_graph->reflectivity(), 0.5);
+ QCOMPARE(m_graph->locale(), QLocale("C"));
+ QCOMPARE(m_graph->queriedGraphPosition(), QVector3D(0, 0, 0));
+ QCOMPARE(m_graph->margin(), -1.0);
+}
+
+void tst_bars::initializeProperties()
+{
+ QVERIFY(m_graph);
+
+ m_graph->setMultiSeriesUniform(true);
+ m_graph->setBarThickness(0.2f);
+ m_graph->setBarSpacing(QSizeF(0.1f, 0.1f));
+ m_graph->setBarSpacingRelative(false);
+ m_graph->setFloorLevel(1.0f);
+
+ QCOMPARE(m_graph->isMultiSeriesUniform(), true);
+ QCOMPARE(m_graph->barThickness(), 0.2f);
+ QCOMPARE(m_graph->barSpacing(), QSizeF(0.1f, 0.1f));
+ QCOMPARE(m_graph->isBarSpacingRelative(), false);
+ QCOMPARE(m_graph->floorLevel(), 1.0f);
+
+ Q3DTheme *theme = new Q3DTheme(Q3DTheme::ThemeDigia);
+ m_graph->setActiveTheme(theme);
+ m_graph->setSelectionMode(QAbstract3DGraph::SelectionItem | QAbstract3DGraph::SelectionRow | QAbstract3DGraph::SelectionSlice);
+ m_graph->setShadowQuality(QAbstract3DGraph::ShadowQualitySoftHigh);
+ QCOMPARE(m_graph->shadowQuality(), QAbstract3DGraph::ShadowQualitySoftHigh);
+ m_graph->setMeasureFps(true);
+ m_graph->setOrthoProjection(true);
+ m_graph->setAspectRatio(1.0);
+ m_graph->setOptimizationHints(QAbstract3DGraph::OptimizationStatic);
+ m_graph->setPolar(true);
+ m_graph->setRadialLabelOffset(0.1f);
+ m_graph->setHorizontalAspectRatio(1.0);
+ m_graph->setReflection(true);
+ m_graph->setReflectivity(0.1);
+ m_graph->setLocale(QLocale("FI"));
+ m_graph->setMargin(1.0);
+
+ QCOMPARE(m_graph->activeTheme()->type(), Q3DTheme::ThemeDigia);
+ QCOMPARE(m_graph->selectionMode(), QAbstract3DGraph::SelectionItem | QAbstract3DGraph::SelectionRow | QAbstract3DGraph::SelectionSlice);
+ QCOMPARE(m_graph->shadowQuality(), QAbstract3DGraph::ShadowQualityNone); // Ortho disables shadows
+ QCOMPARE(m_graph->measureFps(), true);
+ QCOMPARE(m_graph->isOrthoProjection(), true);
+ QCOMPARE(m_graph->aspectRatio(), 1.0);
+ QCOMPARE(m_graph->optimizationHints(), QAbstract3DGraph::OptimizationStatic);
+ QCOMPARE(m_graph->isPolar(), true);
+ QCOMPARE(m_graph->radialLabelOffset(), 0.1f);
+ QCOMPARE(m_graph->horizontalAspectRatio(), 1.0);
+ QCOMPARE(m_graph->isReflection(), true);
+ QCOMPARE(m_graph->reflectivity(), 0.1);
+ QCOMPARE(m_graph->locale(), QLocale("FI"));
+ QCOMPARE(m_graph->margin(), 1.0);
+}
+
+void tst_bars::invalidProperties()
+{
+ m_graph->setSelectionMode(QAbstract3DGraph::SelectionColumn | QAbstract3DGraph::SelectionRow | QAbstract3DGraph::SelectionSlice);
+ m_graph->setAspectRatio(-1.0);
+ m_graph->setHorizontalAspectRatio(-1.0);
+ m_graph->setReflectivity(-1.0);
+ m_graph->setLocale(QLocale("XX"));
+
+ QCOMPARE(m_graph->selectionMode(), QAbstract3DGraph::SelectionItem);
+ QCOMPARE(m_graph->aspectRatio(), -1.0/*2.0*/); // TODO: Fix once QTRD-3367 is done
+ QCOMPARE(m_graph->horizontalAspectRatio(), -1.0/*0.0*/); // TODO: Fix once QTRD-3367 is done
+ QCOMPARE(m_graph->reflectivity(), -1.0/*0.5*/); // TODO: Fix once QTRD-3367 is done
+ QCOMPARE(m_graph->locale(), QLocale("C"));
+}
+
+void tst_bars::addSeries()
+{
+ QBar3DSeries *series = newSeries();
+
+ m_graph->addSeries(series);
+
+ QCOMPARE(m_graph->seriesList().length(), 1);
+ QVERIFY(!m_graph->selectedSeries());
+ QCOMPARE(m_graph->primarySeries(), series);
+}
+
+void tst_bars::addMultipleSeries()
+{
+ QBar3DSeries *series = newSeries();
+ QBar3DSeries *series2 = newSeries();
+ QBar3DSeries *series3 = newSeries();
+
+ m_graph->addSeries(series);
+ m_graph->addSeries(series2);
+ m_graph->addSeries(series3);
+
+ QCOMPARE(m_graph->seriesList().length(), 3);
+ QCOMPARE(m_graph->primarySeries(), series);
+
+ m_graph->setPrimarySeries(series2);
+
+ QCOMPARE(m_graph->primarySeries(), series2);
+}
+
+void tst_bars::selectSeries()
+{
+ QBar3DSeries *series = newSeries();
+
+ m_graph->addSeries(series);
+ m_graph->primarySeries()->setSelectedBar(QPoint(0, 0));
+
+ QCOMPARE(m_graph->seriesList().length(), 1);
+ QCOMPARE(m_graph->selectedSeries(), series);
+
+ m_graph->clearSelection();
+ QVERIFY(!m_graph->selectedSeries());
+}
+
+void tst_bars::removeSeries()
+{
+ QBar3DSeries *series = newSeries();
+
+ m_graph->addSeries(series);
+ m_graph->removeSeries(series);
+ QCOMPARE(m_graph->seriesList().length(), 0);
+}
+
+void tst_bars::removeMultipleSeries()
+{
+ QBar3DSeries *series = newSeries();
+ QBar3DSeries *series2 = newSeries();
+ QBar3DSeries *series3 = newSeries();
+
+ m_graph->addSeries(series);
+ m_graph->addSeries(series2);
+ m_graph->addSeries(series3);
+
+ m_graph->primarySeries()->setSelectedBar(QPoint(0, 0));
+ QCOMPARE(m_graph->selectedSeries(), series);
+
+ m_graph->removeSeries(series);
+ QCOMPARE(m_graph->seriesList().length(), 2);
+ QCOMPARE(m_graph->primarySeries(), series2);
+ QVERIFY(!m_graph->selectedSeries());
+
+ m_graph->removeSeries(series2);
+ QCOMPARE(m_graph->seriesList().length(), 1);
+ QCOMPARE(m_graph->primarySeries(), series3);
+
+ m_graph->removeSeries(series3);
+ QCOMPARE(m_graph->seriesList().length(), 0);
+}
+
+// The following tests are not required for scatter or surface, as they are handled identically
+void tst_bars::addInputHandler()
+{
+ Q3DInputHandler *handler = new Q3DInputHandler();
+ QTouch3DInputHandler *handler2 = new QTouch3DInputHandler();
+ QAbstract3DInputHandler *initialHandler = m_graph->activeInputHandler();
+
+ m_graph->addInputHandler(handler);
+ m_graph->addInputHandler(handler2);
+
+ QCOMPARE(m_graph->inputHandlers().length(), 3); // Default, as it is still active, plus added ones
+ QCOMPARE(m_graph->activeInputHandler(), initialHandler);
+ m_graph->setActiveInputHandler(handler2);
+ QCOMPARE(m_graph->activeInputHandler(), handler2);
+
+ m_graph->setActiveInputHandler(NULL);
+ QVERIFY(!m_graph->activeInputHandler());
+ QCOMPARE(m_graph->inputHandlers().length(), 2);
+}
+
+void tst_bars::removeInputHandler()
+{
+ Q3DInputHandler *handler = new Q3DInputHandler();
+ QTouch3DInputHandler *handler2 = new QTouch3DInputHandler();
+
+ m_graph->addInputHandler(handler);
+ m_graph->addInputHandler(handler2);
+
+ m_graph->setActiveInputHandler(handler2);
+ QCOMPARE(m_graph->inputHandlers().length(), 2); // Default handler removed by previous call
+ QCOMPARE(m_graph->activeInputHandler(), handler2);
+ m_graph->releaseInputHandler(handler2);
+ QCOMPARE(m_graph->inputHandlers().length(), 1);
+ m_graph->releaseInputHandler(handler);
+ QCOMPARE(m_graph->inputHandlers().length(), 0);
+
+ delete handler2;
+ delete handler;
+}
+
+void tst_bars::addTheme()
+{
+ Q3DTheme *theme = new Q3DTheme(Q3DTheme::ThemeDigia);
+ Q3DTheme *theme2 = new Q3DTheme();
+ Q3DTheme *initialTheme = m_graph->activeTheme();
+ m_graph->addTheme(theme);
+ m_graph->addTheme(theme2);
+
+ QCOMPARE(m_graph->themes().length(), 3); // Default, plus added ones
+ QCOMPARE(m_graph->activeTheme(), initialTheme);
+ m_graph->setActiveTheme(theme2);
+ QCOMPARE(m_graph->activeTheme(), theme2);
+}
+
+void tst_bars::removeTheme()
+{
+ Q3DTheme *theme = new Q3DTheme(Q3DTheme::ThemeDigia);
+ Q3DTheme *theme2 = new Q3DTheme();
+ m_graph->addTheme(theme);
+ m_graph->addTheme(theme2);
+
+ m_graph->setActiveTheme(theme2);
+ QCOMPARE(m_graph->activeTheme(), theme2);
+ m_graph->releaseTheme(theme2);
+ QCOMPARE(m_graph->themes().length(), 2);
+ m_graph->releaseTheme(theme);
+ QCOMPARE(m_graph->themes().length(), 1); // Default theme remains
+
+ delete theme2;
+ delete theme;
+}
+
+void tst_bars::addCustomItem()
+{
+ QCustom3DItem *item = new QCustom3DItem();
+ QCustom3DItem *item2 = new QCustom3DItem();
+
+ m_graph->addCustomItem(item);
+ QCOMPARE(m_graph->customItems().length(), 1);
+ m_graph->addCustomItem(item2);
+ QCOMPARE(m_graph->customItems().length(), 2);
+}
+
+void tst_bars::removeCustomItem()
+{
+ QCustom3DItem *item = new QCustom3DItem();
+ QCustom3DItem *item2 = new QCustom3DItem();
+ QCustom3DItem *item3 = new QCustom3DItem();
+ item3->setPosition(QVector3D(1, 1, 1));
+
+ m_graph->addCustomItem(item);
+ m_graph->addCustomItem(item2);
+ m_graph->addCustomItem(item3);
+
+ m_graph->releaseCustomItem(item);
+ QCOMPARE(m_graph->customItems().length(), 2);
+ m_graph->removeCustomItem(item2);
+ QCOMPARE(m_graph->customItems().length(), 1);
+ m_graph->addCustomItem(item);
+ m_graph->removeCustomItemAt(QVector3D(1, 1, 1));
+ QCOMPARE(m_graph->customItems().length(), 1);
+ m_graph->removeCustomItems();
+ QCOMPARE(m_graph->customItems().length(), 0);
+}
+
+void tst_bars::renderToImage()
+{
+ m_graph->addSeries(newSeries());
+
+ QImage image = m_graph->renderToImage();
+ QCOMPARE(image.size(), m_graph->size());
+
+ image = m_graph->renderToImage(8);
+ QCOMPARE(image.size(), m_graph->size());
+
+ image = m_graph->renderToImage(4, QSize(300, 300));
+ QCOMPARE(image.size(), QSize(300, 300));
+}
+
+QTEST_MAIN(tst_bars)
+#include "tst_bars.moc"
diff --git a/tests/auto/cpptest/q3dcustom-label/q3dcustom-label.pro b/tests/auto/cpptest/q3dcustom-label/q3dcustom-label.pro
new file mode 100644
index 00000000..af584baa
--- /dev/null
+++ b/tests/auto/cpptest/q3dcustom-label/q3dcustom-label.pro
@@ -0,0 +1,8 @@
+QT += testlib datavisualization
+
+TARGET = tst_cpptest
+CONFIG += console testcase
+
+TEMPLATE = app
+
+SOURCES += tst_custom.cpp
diff --git a/tests/auto/cpptest/q3dcustom-label/tst_custom.cpp b/tests/auto/cpptest/q3dcustom-label/tst_custom.cpp
new file mode 100644
index 00000000..40bd5eac
--- /dev/null
+++ b/tests/auto/cpptest/q3dcustom-label/tst_custom.cpp
@@ -0,0 +1,158 @@
+/****************************************************************************
+**
+** 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/QCustom3DLabel>
+
+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();
+ void invalidProperties();
+
+private:
+ QCustom3DLabel *m_custom;
+};
+
+void tst_custom::initTestCase()
+{
+}
+
+void tst_custom::cleanupTestCase()
+{
+}
+
+void tst_custom::init()
+{
+ m_custom = new QCustom3DLabel();
+}
+
+void tst_custom::cleanup()
+{
+ delete m_custom;
+}
+
+void tst_custom::construct()
+{
+ QCustom3DLabel *custom = new QCustom3DLabel();
+ QVERIFY(custom);
+ delete custom;
+
+ custom = new QCustom3DLabel("label", QFont("Times New Roman", 10.0), QVector3D(1.0, 1.0, 1.0),
+ QVector3D(1.0, 1.0, 1.0), QQuaternion(1.0, 1.0, 10.0, 100.0));
+ QVERIFY(custom);
+ QCOMPARE(custom->backgroundColor(), QColor(Qt::gray));
+ QCOMPARE(custom->isBackgroundEnabled(), true);
+ QCOMPARE(custom->isBorderEnabled(), true);
+ QCOMPARE(custom->isFacingCamera(), false);
+ QCOMPARE(custom->font(), QFont("Times New Roman", 10));
+ QCOMPARE(custom->text(), QString("label"));
+ QCOMPARE(custom->textColor(), QColor(Qt::white));
+ QCOMPARE(custom->meshFile(), QString(":/defaultMeshes/plane"));
+ 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(), false);
+ QCOMPARE(custom->textureFile(), QString());
+ QCOMPARE(custom->isVisible(), true);
+ delete custom;
+}
+
+void tst_custom::initialProperties()
+{
+ QVERIFY(m_custom);
+
+ QCOMPARE(m_custom->backgroundColor(), QColor(Qt::gray));
+ QCOMPARE(m_custom->isBackgroundEnabled(), true);
+ QCOMPARE(m_custom->isBorderEnabled(), true);
+ QCOMPARE(m_custom->isFacingCamera(), false);
+ QCOMPARE(m_custom->font(), QFont("Arial", 20));
+ QCOMPARE(m_custom->text(), QString());
+ QCOMPARE(m_custom->textColor(), QColor(Qt::white));
+
+ // Common (from QCustom3DItem)
+ QCOMPARE(m_custom->meshFile(), QString(":/defaultMeshes/plane"));
+ 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(), false);
+ QCOMPARE(m_custom->textureFile(), QString());
+ QCOMPARE(m_custom->isVisible(), true);
+}
+
+void tst_custom::initializeProperties()
+{
+ QVERIFY(m_custom);
+
+ m_custom->setBackgroundColor(QColor(Qt::red));
+ m_custom->setBackgroundEnabled(false);
+ m_custom->setBorderEnabled(false);
+ m_custom->setFacingCamera(true);
+ m_custom->setFont(QFont("Times New Roman", 10));
+ m_custom->setText(QString("This is a Custom Label"));
+ m_custom->setTextColor(QColor(Qt::blue));
+
+ QCOMPARE(m_custom->backgroundColor(), QColor(Qt::red));
+ QCOMPARE(m_custom->isBackgroundEnabled(), false);
+ QCOMPARE(m_custom->isBorderEnabled(), false);
+ QCOMPARE(m_custom->isFacingCamera(), true);
+ QCOMPARE(m_custom->font(), QFont("Times New Roman", 10));
+ QCOMPARE(m_custom->text(), QString("This is a Custom Label"));
+ QCOMPARE(m_custom->textColor(), QColor(Qt::blue));
+
+ // Common (from QCustom3DItem)
+ 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->setShadowCasting(true);
+ m_custom->setVisible(false);
+
+ 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->isShadowCasting(), true);
+ QCOMPARE(m_custom->isVisible(), false);
+}
+
+void tst_custom::invalidProperties()
+{
+ m_custom->setScalingAbsolute(false);
+ QCOMPARE(m_custom->isScalingAbsolute(), true);
+}
+
+QTEST_MAIN(tst_custom)
+#include "tst_custom.moc"
diff --git a/tests/auto/cpptest/q3dcustom-volume/q3dcustom-volume.pro b/tests/auto/cpptest/q3dcustom-volume/q3dcustom-volume.pro
new file mode 100644
index 00000000..af584baa
--- /dev/null
+++ b/tests/auto/cpptest/q3dcustom-volume/q3dcustom-volume.pro
@@ -0,0 +1,8 @@
+QT += testlib datavisualization
+
+TARGET = tst_cpptest
+CONFIG += console testcase
+
+TEMPLATE = app
+
+SOURCES += tst_custom.cpp
diff --git a/tests/auto/cpptest/q3dcustom-volume/tst_custom.cpp b/tests/auto/cpptest/q3dcustom-volume/tst_custom.cpp
new file mode 100644
index 00000000..372e8ecf
--- /dev/null
+++ b/tests/auto/cpptest/q3dcustom-volume/tst_custom.cpp
@@ -0,0 +1,204 @@
+/****************************************************************************
+**
+** 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/QCustom3DVolume>
+
+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();
+ void invalidProperties();
+
+private:
+ QCustom3DVolume *m_custom;
+};
+
+void tst_custom::initTestCase()
+{
+}
+
+void tst_custom::cleanupTestCase()
+{
+}
+
+void tst_custom::init()
+{
+ m_custom = new QCustom3DVolume();
+}
+
+void tst_custom::cleanup()
+{
+ delete m_custom;
+}
+
+void tst_custom::construct()
+{
+ QCustom3DVolume *custom = new QCustom3DVolume();
+ QVERIFY(custom);
+ delete custom;
+
+ QVector<uchar> *tdata = new QVector<uchar>(1000);
+
+ QVector<QRgb> table;
+ table << QRgb(0xff00ff) << QRgb(0x00ff00);
+
+ custom = new QCustom3DVolume(QVector3D(1.0, 1.0, 1.0), QVector3D(1.0, 1.0, 1.0),
+ QQuaternion(1.0, 1.0, 10.0, 100.0), 10, 10, 10,
+ tdata, QImage::Format_ARGB32, table);
+ QVERIFY(custom);
+ QCOMPARE(custom->alphaMultiplier(), 1.0f);
+ QCOMPARE(custom->drawSliceFrames(), false);
+ QCOMPARE(custom->drawSliceFrames(), false);
+ QCOMPARE(custom->preserveOpacity(), true);
+ QCOMPARE(custom->sliceFrameColor(), QColor(Qt::black));
+ QCOMPARE(custom->sliceFrameGaps(), QVector3D(0.01f, 0.01f, 0.01f));
+ QCOMPARE(custom->sliceFrameThicknesses(), QVector3D(0.01f, 0.01f, 0.01f));
+ QCOMPARE(custom->sliceFrameWidths(), QVector3D(0.01f, 0.01f, 0.01f));
+ QCOMPARE(custom->sliceIndexX(), -1);
+ QCOMPARE(custom->sliceIndexY(), -1);
+ QCOMPARE(custom->sliceIndexZ(), -1);
+ QCOMPARE(custom->useHighDefShader(), true);
+ QCOMPARE(custom->textureData()->length(), 1000);
+ QCOMPARE(custom->textureDataWidth(), 40);
+ QCOMPARE(custom->textureFormat(), QImage::Format_ARGB32);
+ QCOMPARE(custom->textureHeight(), 10);
+ QCOMPARE(custom->textureWidth(), 10);
+ QCOMPARE(custom->textureDepth(), 10);
+ QCOMPARE(custom->meshFile(), QString(":/defaultMeshes/barFull"));
+ 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(), false);
+ QCOMPARE(custom->textureFile(), QString());
+ QCOMPARE(custom->isVisible(), true);
+ delete custom;
+}
+
+void tst_custom::initialProperties()
+{
+ QVERIFY(m_custom);
+
+ QCOMPARE(m_custom->alphaMultiplier(), 1.0f);
+ QCOMPARE(m_custom->drawSliceFrames(), false);
+ QCOMPARE(m_custom->drawSliceFrames(), false);
+ QCOMPARE(m_custom->preserveOpacity(), true);
+ QCOMPARE(m_custom->sliceFrameColor(), QColor(Qt::black));
+ QCOMPARE(m_custom->sliceFrameGaps(), QVector3D(0.01f, 0.01f, 0.01f));
+ QCOMPARE(m_custom->sliceFrameThicknesses(), QVector3D(0.01f, 0.01f, 0.01f));
+ QCOMPARE(m_custom->sliceFrameWidths(), QVector3D(0.01f, 0.01f, 0.01f));
+ QCOMPARE(m_custom->sliceIndexX(), -1);
+ QCOMPARE(m_custom->sliceIndexY(), -1);
+ QCOMPARE(m_custom->sliceIndexZ(), -1);
+ QCOMPARE(m_custom->useHighDefShader(), true);
+
+ // Common (from QCustom3DVolume)
+ QCOMPARE(m_custom->meshFile(), QString(":/defaultMeshes/barFull"));
+ 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->setAlphaMultiplier(0.1f);
+ m_custom->setDrawSliceFrames(true);
+ m_custom->setDrawSliceFrames(true);
+ m_custom->setPreserveOpacity(false);
+ m_custom->setSliceFrameColor(QColor(Qt::red));
+ m_custom->setSliceFrameGaps(QVector3D(2.0f, 2.0f, 2.0f));
+ m_custom->setSliceFrameThicknesses(QVector3D(2.0f, 2.0f, 2.0f));
+ m_custom->setSliceFrameWidths(QVector3D(2.0f, 2.0f, 2.0f));
+ m_custom->setSliceIndexX(0);
+ m_custom->setSliceIndexY(0);
+ m_custom->setSliceIndexZ(0);
+ m_custom->setUseHighDefShader(false);
+
+ QCOMPARE(m_custom->alphaMultiplier(), 0.1f);
+ QCOMPARE(m_custom->drawSliceFrames(), true);
+ QCOMPARE(m_custom->drawSliceFrames(), true);
+ QCOMPARE(m_custom->preserveOpacity(), false);
+ QCOMPARE(m_custom->sliceFrameColor(), QColor(Qt::red));
+ QCOMPARE(m_custom->sliceFrameGaps(), QVector3D(2.0f, 2.0f, 2.0f));
+ QCOMPARE(m_custom->sliceFrameThicknesses(), QVector3D(2.0f, 2.0f, 2.0f));
+ QCOMPARE(m_custom->sliceFrameWidths(), QVector3D(2.0f, 2.0f, 2.0f));
+ QCOMPARE(m_custom->sliceIndexX(), 0);
+ QCOMPARE(m_custom->sliceIndexY(), 0);
+ QCOMPARE(m_custom->sliceIndexZ(), 0);
+ QCOMPARE(m_custom->useHighDefShader(), false);
+
+ // Common (from QCustom3DVolume)
+ 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->setVisible(false);
+
+ 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->isVisible(), false);
+}
+
+void tst_custom::invalidProperties()
+{
+ m_custom->setAlphaMultiplier(-1.0f);
+ QCOMPARE(m_custom->alphaMultiplier(), 1.0f);
+
+ m_custom->setSliceFrameGaps(QVector3D(-0.1f, -0.1f, -0.1f));
+ QCOMPARE(m_custom->sliceFrameGaps(), QVector3D(0.01f, 0.01f, 0.01f));
+
+ m_custom->setSliceFrameThicknesses(QVector3D(-0.1f, -0.1f, -0.1f));
+ QCOMPARE(m_custom->sliceFrameThicknesses(), QVector3D(0.01f, 0.01f, 0.01f));
+
+ m_custom->setSliceFrameWidths(QVector3D(-0.1f, -0.1f, -0.1f));
+ QCOMPARE(m_custom->sliceFrameWidths(), QVector3D(0.01f, 0.01f, 0.01f));
+
+ m_custom->setTextureFormat(QImage::Format_ARGB8555_Premultiplied);
+ QCOMPARE(m_custom->textureFormat(), QImage::Format_ARGB32);
+}
+
+QTEST_MAIN(tst_custom)
+#include "tst_custom.moc"
diff --git a/tests/auto/cpptest/q3dcustom/q3dcustom.pro b/tests/auto/cpptest/q3dcustom/q3dcustom.pro
new file mode 100644
index 00000000..af584baa
--- /dev/null
+++ b/tests/auto/cpptest/q3dcustom/q3dcustom.pro
@@ -0,0 +1,8 @@
+QT += testlib datavisualization
+
+TARGET = tst_cpptest
+CONFIG += console testcase
+
+TEMPLATE = app
+
+SOURCES += tst_custom.cpp
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"
diff --git a/tests/auto/cpptest/q3dinput-touch/q3dinput-touch.pro b/tests/auto/cpptest/q3dinput-touch/q3dinput-touch.pro
new file mode 100644
index 00000000..2de48158
--- /dev/null
+++ b/tests/auto/cpptest/q3dinput-touch/q3dinput-touch.pro
@@ -0,0 +1,8 @@
+QT += testlib datavisualization
+
+TARGET = tst_cpptest
+CONFIG += console testcase
+
+TEMPLATE = app
+
+SOURCES += tst_input.cpp
diff --git a/tests/auto/cpptest/q3dinput-touch/tst_input.cpp b/tests/auto/cpptest/q3dinput-touch/tst_input.cpp
new file mode 100644
index 00000000..53d760ae
--- /dev/null
+++ b/tests/auto/cpptest/q3dinput-touch/tst_input.cpp
@@ -0,0 +1,106 @@
+/****************************************************************************
+**
+** 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/QTouch3DInputHandler>
+
+using namespace QtDataVisualization;
+
+class tst_input: public QObject
+{
+ Q_OBJECT
+
+private slots:
+ void initTestCase();
+ void cleanupTestCase();
+ void init();
+ void cleanup();
+
+ void construct();
+
+ void initialProperties();
+ void initializeProperties();
+
+private:
+ QTouch3DInputHandler *m_input;
+};
+
+void tst_input::initTestCase()
+{
+}
+
+void tst_input::cleanupTestCase()
+{
+}
+
+void tst_input::init()
+{
+ m_input = new QTouch3DInputHandler();
+}
+
+void tst_input::cleanup()
+{
+ delete m_input;
+}
+
+void tst_input::construct()
+{
+ QTouch3DInputHandler *input = new QTouch3DInputHandler();
+ QVERIFY(input);
+ delete input;
+}
+
+void tst_input::initialProperties()
+{
+ QVERIFY(m_input);
+
+ // Common (from Q3DInputHandler and QAbstract3DInputHandler)
+ QCOMPARE(m_input->isRotationEnabled(), true);
+ QCOMPARE(m_input->isSelectionEnabled(), true);
+ QCOMPARE(m_input->isZoomAtTargetEnabled(), true);
+ QCOMPARE(m_input->isZoomEnabled(), true);
+ QCOMPARE(m_input->inputPosition(), QPoint(0, 0));
+ QCOMPARE(m_input->inputView(), QAbstract3DInputHandler::InputViewNone);
+ QVERIFY(!m_input->scene());
+}
+
+void tst_input::initializeProperties()
+{
+ QVERIFY(m_input);
+
+ // Common (from Q3DInputHandler and QAbstract3DInputHandler)
+ m_input->setRotationEnabled(false);
+ m_input->setSelectionEnabled(false);
+ m_input->setZoomAtTargetEnabled(false);
+ m_input->setZoomEnabled(false);
+ m_input->setInputPosition(QPoint(100, 100));
+ m_input->setInputView(QAbstract3DInputHandler::InputViewOnPrimary);
+
+ QCOMPARE(m_input->isRotationEnabled(), false);
+ QCOMPARE(m_input->isSelectionEnabled(), false);
+ QCOMPARE(m_input->isZoomAtTargetEnabled(), false);
+ QCOMPARE(m_input->isZoomEnabled(), false);
+ QCOMPARE(m_input->inputPosition(), QPoint(100, 100));
+ QCOMPARE(m_input->inputView(), QAbstract3DInputHandler::InputViewOnPrimary);
+}
+
+// TODO: QTRD-3380 (mouse/touch events)
+
+QTEST_MAIN(tst_input)
+#include "tst_input.moc"
diff --git a/tests/auto/cpptest/q3dinput/q3dinput.pro b/tests/auto/cpptest/q3dinput/q3dinput.pro
new file mode 100644
index 00000000..2de48158
--- /dev/null
+++ b/tests/auto/cpptest/q3dinput/q3dinput.pro
@@ -0,0 +1,8 @@
+QT += testlib datavisualization
+
+TARGET = tst_cpptest
+CONFIG += console testcase
+
+TEMPLATE = app
+
+SOURCES += tst_input.cpp
diff --git a/tests/auto/cpptest/q3dinput/tst_input.cpp b/tests/auto/cpptest/q3dinput/tst_input.cpp
new file mode 100644
index 00000000..68b2225c
--- /dev/null
+++ b/tests/auto/cpptest/q3dinput/tst_input.cpp
@@ -0,0 +1,109 @@
+/****************************************************************************
+**
+** 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/Q3DInputHandler>
+
+using namespace QtDataVisualization;
+
+class tst_input: public QObject
+{
+ Q_OBJECT
+
+private slots:
+ void initTestCase();
+ void cleanupTestCase();
+ void init();
+ void cleanup();
+
+ void construct();
+
+ void initialProperties();
+ void initializeProperties();
+
+private:
+ Q3DInputHandler *m_input;
+};
+
+void tst_input::initTestCase()
+{
+}
+
+void tst_input::cleanupTestCase()
+{
+}
+
+void tst_input::init()
+{
+ m_input = new Q3DInputHandler();
+}
+
+void tst_input::cleanup()
+{
+ delete m_input;
+}
+
+void tst_input::construct()
+{
+ Q3DInputHandler *input = new Q3DInputHandler();
+ QVERIFY(input);
+ delete input;
+}
+
+void tst_input::initialProperties()
+{
+ QVERIFY(m_input);
+
+ QCOMPARE(m_input->isRotationEnabled(), true);
+ QCOMPARE(m_input->isSelectionEnabled(), true);
+ QCOMPARE(m_input->isZoomAtTargetEnabled(), true);
+ QCOMPARE(m_input->isZoomEnabled(), true);
+
+ // Common (from QAbstract3DInputHandler)
+ QCOMPARE(m_input->inputPosition(), QPoint(0, 0));
+ QCOMPARE(m_input->inputView(), QAbstract3DInputHandler::InputViewNone);
+ QVERIFY(!m_input->scene());
+}
+
+void tst_input::initializeProperties()
+{
+ QVERIFY(m_input);
+
+ m_input->setRotationEnabled(false);
+ m_input->setSelectionEnabled(false);
+ m_input->setZoomAtTargetEnabled(false);
+ m_input->setZoomEnabled(false);
+
+ QCOMPARE(m_input->isRotationEnabled(), false);
+ QCOMPARE(m_input->isSelectionEnabled(), false);
+ QCOMPARE(m_input->isZoomAtTargetEnabled(), false);
+ QCOMPARE(m_input->isZoomEnabled(), false);
+
+ // Common (from QAbstract3DInputHandler)
+ m_input->setInputPosition(QPoint(100, 100));
+ m_input->setInputView(QAbstract3DInputHandler::InputViewOnPrimary);
+
+ QCOMPARE(m_input->inputPosition(), QPoint(100, 100));
+ QCOMPARE(m_input->inputView(), QAbstract3DInputHandler::InputViewOnPrimary);
+}
+
+// TODO: QTRD-3380 (mouse events)
+
+QTEST_MAIN(tst_input)
+#include "tst_input.moc"
diff --git a/tests/auto/cpptest/q3dscatter-modelproxy/q3dscatter-modelproxy.pro b/tests/auto/cpptest/q3dscatter-modelproxy/q3dscatter-modelproxy.pro
new file mode 100644
index 00000000..c383ec25
--- /dev/null
+++ b/tests/auto/cpptest/q3dscatter-modelproxy/q3dscatter-modelproxy.pro
@@ -0,0 +1,8 @@
+QT += testlib datavisualization widgets
+
+TARGET = tst_cpptest
+CONFIG += console testcase
+
+TEMPLATE = app
+
+SOURCES += tst_proxy.cpp
diff --git a/tests/auto/cpptest/q3dscatter-modelproxy/tst_proxy.cpp b/tests/auto/cpptest/q3dscatter-modelproxy/tst_proxy.cpp
new file mode 100644
index 00000000..9d5cea90
--- /dev/null
+++ b/tests/auto/cpptest/q3dscatter-modelproxy/tst_proxy.cpp
@@ -0,0 +1,193 @@
+/****************************************************************************
+**
+** 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/QItemModelScatterDataProxy>
+#include <QtDataVisualization/Q3DScatter>
+#include <QtWidgets/QTableWidget>
+
+using namespace QtDataVisualization;
+
+class tst_proxy: public QObject
+{
+ Q_OBJECT
+
+private slots:
+ void initTestCase();
+ void cleanupTestCase();
+ void init();
+ void cleanup();
+
+ void construct();
+
+ void initialProperties();
+ void initializeProperties();
+
+ void addModel();
+
+private:
+ QItemModelScatterDataProxy *m_proxy;
+};
+
+void tst_proxy::initTestCase()
+{
+}
+
+void tst_proxy::cleanupTestCase()
+{
+}
+
+void tst_proxy::init()
+{
+ m_proxy = new QItemModelScatterDataProxy();
+}
+
+void tst_proxy::cleanup()
+{
+ delete m_proxy;
+}
+
+void tst_proxy::construct()
+{
+ QItemModelScatterDataProxy *proxy = new QItemModelScatterDataProxy();
+ QVERIFY(proxy);
+ delete proxy;
+
+ QTableWidget *table = new QTableWidget();
+
+ proxy = new QItemModelScatterDataProxy(table->model());
+ QVERIFY(proxy);
+ delete proxy;
+
+ proxy = new QItemModelScatterDataProxy(table->model(), "x", "y", "z");
+ QVERIFY(proxy);
+ QCOMPARE(proxy->xPosRole(), QString("x"));
+ QCOMPARE(proxy->yPosRole(), QString("y"));
+ QCOMPARE(proxy->zPosRole(), QString("z"));
+ QCOMPARE(proxy->rotationRole(), QString(""));
+ delete proxy;
+
+ proxy = new QItemModelScatterDataProxy(table->model(), "x", "y", "z", "rot");
+ QVERIFY(proxy);
+ QCOMPARE(proxy->xPosRole(), QString("x"));
+ QCOMPARE(proxy->yPosRole(), QString("y"));
+ QCOMPARE(proxy->zPosRole(), QString("z"));
+ QCOMPARE(proxy->rotationRole(), QString("rot"));
+ delete proxy;
+}
+
+void tst_proxy::initialProperties()
+{
+ QVERIFY(m_proxy);
+
+ QVERIFY(!m_proxy->itemModel());
+ QCOMPARE(m_proxy->rotationRole(), QString());
+ QCOMPARE(m_proxy->rotationRolePattern(), QRegExp());
+ QCOMPARE(m_proxy->rotationRoleReplace(), QString());
+ QCOMPARE(m_proxy->xPosRole(), QString());
+ QCOMPARE(m_proxy->xPosRolePattern(), QRegExp());
+ QCOMPARE(m_proxy->xPosRoleReplace(), QString());
+ QCOMPARE(m_proxy->yPosRole(), QString());
+ QCOMPARE(m_proxy->yPosRolePattern(), QRegExp());
+ QCOMPARE(m_proxy->yPosRoleReplace(), QString());
+ QCOMPARE(m_proxy->zPosRole(), QString());
+ QCOMPARE(m_proxy->zPosRolePattern(), QRegExp());
+ QCOMPARE(m_proxy->zPosRoleReplace(), QString());
+
+ QCOMPARE(m_proxy->itemCount(), 0);
+ QVERIFY(!m_proxy->series());
+
+ QCOMPARE(m_proxy->type(), QAbstractDataProxy::DataTypeScatter);
+}
+
+void tst_proxy::initializeProperties()
+{
+ QVERIFY(m_proxy);
+
+ QTableWidget *table = new QTableWidget();
+
+ m_proxy->setItemModel(table->model());
+ m_proxy->setRotationRole("rotation");
+ m_proxy->setRotationRolePattern(QRegExp("/-/"));
+ m_proxy->setRotationRoleReplace("\\\\1");
+ m_proxy->setXPosRole("X");
+ m_proxy->setXPosRolePattern(QRegExp("/-/"));
+ m_proxy->setXPosRoleReplace("\\\\1");
+ m_proxy->setYPosRole("Y");
+ m_proxy->setYPosRolePattern(QRegExp("/-/"));
+ m_proxy->setYPosRoleReplace("\\\\1");
+ m_proxy->setZPosRole("Z");
+ m_proxy->setZPosRolePattern(QRegExp("/-/"));
+ m_proxy->setZPosRoleReplace("\\\\1");
+
+ QVERIFY(m_proxy->itemModel());
+ QCOMPARE(m_proxy->rotationRole(), QString("rotation"));
+ QCOMPARE(m_proxy->rotationRolePattern(), QRegExp("/-/"));
+ QCOMPARE(m_proxy->rotationRoleReplace(), QString("\\\\1"));
+ QCOMPARE(m_proxy->xPosRole(), QString("X"));
+ QCOMPARE(m_proxy->xPosRolePattern(), QRegExp("/-/"));
+ QCOMPARE(m_proxy->xPosRoleReplace(), QString("\\\\1"));
+ QCOMPARE(m_proxy->yPosRole(), QString("Y"));
+ QCOMPARE(m_proxy->yPosRolePattern(), QRegExp("/-/"));
+ QCOMPARE(m_proxy->yPosRoleReplace(), QString("\\\\1"));
+ QCOMPARE(m_proxy->zPosRole(), QString("Z"));
+ QCOMPARE(m_proxy->zPosRolePattern(), QRegExp("/-/"));
+ QCOMPARE(m_proxy->zPosRoleReplace(), QString("\\\\1"));
+}
+
+void tst_proxy::addModel()
+{
+ QTableWidget *table = new QTableWidget();
+ QStringList rows;
+ rows << "row 1";
+ QStringList columns;
+ columns << "col 1";
+ const char *values[1][2] = {{"0/0/5.5/30", "0/0/10.5/30"}};
+
+ table->setRowCount(2);
+ table->setColumnCount(1);
+
+ for (int col = 0; col < columns.size(); col++) {
+ for (int row = 0; row < rows.size(); row++) {
+ QModelIndex index = table->model()->index(col, row);
+ table->model()->setData(index, values[col][row]);
+ }
+ }
+
+ m_proxy->setItemModel(table->model());
+ m_proxy->setXPosRole(table->model()->roleNames().value(Qt::DisplayRole));
+ m_proxy->setZPosRole(table->model()->roleNames().value(Qt::DisplayRole));
+ m_proxy->setXPosRolePattern(QRegExp(QStringLiteral("^(\\d*)\\/(\\d*)\\/\\d*[\\.\\,]?\\d*\\/\\d*[\\.\\,]?\\d*$")));
+ m_proxy->setXPosRoleReplace(QStringLiteral("\\2"));
+ m_proxy->setYPosRolePattern(QRegExp(QStringLiteral("^\\d*(\\/)(\\d*)\\/(\\d*[\\.\\,]?\\d*)\\/\\d*[\\.\\,]?\\d*$")));
+ m_proxy->setYPosRoleReplace(QStringLiteral("\\3"));
+ m_proxy->setZPosRolePattern(QRegExp(QStringLiteral("^(\\d*)(\\/)(\\d*)\\/\\d*[\\.\\,]?\\d*\\/\\d*[\\.\\,]?\\d*$")));
+ m_proxy->setZPosRoleReplace(QStringLiteral("\\1"));
+
+ QScatter3DSeries *series = new QScatter3DSeries(m_proxy);
+ Q_UNUSED(series)
+
+ QCoreApplication::processEvents();
+
+ QCOMPARE(m_proxy->itemCount(), 2);
+ QVERIFY(m_proxy->series());
+}
+
+QTEST_MAIN(tst_proxy)
+#include "tst_proxy.moc"
diff --git a/tests/auto/cpptest/q3dscatter-proxy/q3dscatter-proxy.pro b/tests/auto/cpptest/q3dscatter-proxy/q3dscatter-proxy.pro
new file mode 100644
index 00000000..b0b5d361
--- /dev/null
+++ b/tests/auto/cpptest/q3dscatter-proxy/q3dscatter-proxy.pro
@@ -0,0 +1,8 @@
+QT += testlib datavisualization
+
+TARGET = tst_cpptest
+CONFIG += console testcase
+
+TEMPLATE = app
+
+SOURCES += tst_proxy.cpp
diff --git a/tests/auto/cpptest/q3dscatter-proxy/tst_proxy.cpp b/tests/auto/cpptest/q3dscatter-proxy/tst_proxy.cpp
new file mode 100644
index 00000000..436350dc
--- /dev/null
+++ b/tests/auto/cpptest/q3dscatter-proxy/tst_proxy.cpp
@@ -0,0 +1,91 @@
+/****************************************************************************
+**
+** 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/QScatterDataProxy>
+
+using namespace QtDataVisualization;
+
+class tst_proxy: public QObject
+{
+ Q_OBJECT
+
+private slots:
+ void initTestCase();
+ void cleanupTestCase();
+ void init();
+ void cleanup();
+
+ void construct();
+
+ void initialProperties();
+ void initializeProperties();
+
+private:
+ QScatterDataProxy *m_proxy;
+};
+
+void tst_proxy::initTestCase()
+{
+}
+
+void tst_proxy::cleanupTestCase()
+{
+}
+
+void tst_proxy::init()
+{
+ m_proxy = new QScatterDataProxy();
+}
+
+void tst_proxy::cleanup()
+{
+ delete m_proxy;
+}
+
+void tst_proxy::construct()
+{
+ QScatterDataProxy *proxy = new QScatterDataProxy();
+ QVERIFY(proxy);
+ delete proxy;
+}
+
+void tst_proxy::initialProperties()
+{
+ QVERIFY(m_proxy);
+
+ QCOMPARE(m_proxy->itemCount(), 0);
+ QVERIFY(!m_proxy->series());
+
+ QCOMPARE(m_proxy->type(), QAbstractDataProxy::DataTypeScatter);
+}
+
+void tst_proxy::initializeProperties()
+{
+ QVERIFY(m_proxy);
+
+ QScatterDataArray data;
+ data << QVector3D(0.5f, 0.5f, 0.5f) << QVector3D(-0.3f, -0.5f, -0.4f);
+ m_proxy->addItems(data);
+
+ QCOMPARE(m_proxy->itemCount(), 2);
+}
+
+QTEST_MAIN(tst_proxy)
+#include "tst_proxy.moc"
diff --git a/tests/auto/cpptest/q3dscatter-series/q3dscatter-series.pro b/tests/auto/cpptest/q3dscatter-series/q3dscatter-series.pro
new file mode 100644
index 00000000..481653ef
--- /dev/null
+++ b/tests/auto/cpptest/q3dscatter-series/q3dscatter-series.pro
@@ -0,0 +1,8 @@
+QT += testlib datavisualization
+
+TARGET = tst_cpptest
+CONFIG += console testcase
+
+TEMPLATE = app
+
+SOURCES += tst_series.cpp
diff --git a/tests/auto/cpptest/q3dscatter-series/tst_series.cpp b/tests/auto/cpptest/q3dscatter-series/tst_series.cpp
new file mode 100644
index 00000000..df290579
--- /dev/null
+++ b/tests/auto/cpptest/q3dscatter-series/tst_series.cpp
@@ -0,0 +1,110 @@
+/****************************************************************************
+**
+** 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/QScatter3DSeries>
+
+using namespace QtDataVisualization;
+
+class tst_series: public QObject
+{
+ Q_OBJECT
+
+private slots:
+ void initTestCase();
+ void cleanupTestCase();
+ void init();
+ void cleanup();
+
+ void construct();
+
+ void initialProperties();
+ void initializeProperties();
+
+private:
+ QScatter3DSeries *m_series;
+};
+
+void tst_series::initTestCase()
+{
+}
+
+void tst_series::cleanupTestCase()
+{
+}
+
+void tst_series::init()
+{
+ m_series = new QScatter3DSeries();
+}
+
+void tst_series::cleanup()
+{
+ delete m_series;
+}
+
+void tst_series::construct()
+{
+ QScatter3DSeries *series = new QScatter3DSeries();
+ QVERIFY(series);
+ delete series;
+
+ QScatterDataProxy *proxy = new QScatterDataProxy();
+
+ series = new QScatter3DSeries(proxy);
+ QVERIFY(series);
+ QCOMPARE(series->dataProxy(), proxy);
+ delete series;
+}
+
+void tst_series::initialProperties()
+{
+ QVERIFY(m_series);
+
+ QVERIFY(m_series->dataProxy());
+ QCOMPARE(m_series->itemSize(), 0.0f);
+ QCOMPARE(m_series->selectedItem(), m_series->invalidSelectionIndex());
+
+ // Common properties. The ones identical between different series are tested in QBar3DSeries tests
+ QCOMPARE(m_series->itemLabelFormat(), QString("@xLabel, @yLabel, @zLabel"));
+ QCOMPARE(m_series->mesh(), QAbstract3DSeries::MeshSphere);
+ QCOMPARE(m_series->type(), QAbstract3DSeries::SeriesTypeScatter);
+}
+
+void tst_series::initializeProperties()
+{
+ QVERIFY(m_series);
+
+ m_series->setDataProxy(new QScatterDataProxy());
+ m_series->setItemSize(0.5f);
+ m_series->setSelectedItem(0);
+
+ QCOMPARE(m_series->itemSize(), 0.5f);
+ QCOMPARE(m_series->selectedItem(), 0);
+
+ // Common properties. The ones identical between different series are tested in QBar3DSeries tests
+ m_series->setMesh(QAbstract3DSeries::MeshPoint);
+ m_series->setMeshRotation(QQuaternion(1, 1, 10, 20));
+
+ QCOMPARE(m_series->mesh(), QAbstract3DSeries::MeshPoint);
+ QCOMPARE(m_series->meshRotation(), QQuaternion(1, 1, 10, 20));
+}
+
+QTEST_MAIN(tst_series)
+#include "tst_series.moc"
diff --git a/tests/auto/cpptest/q3dscatter/q3dscatter.pro b/tests/auto/cpptest/q3dscatter/q3dscatter.pro
new file mode 100644
index 00000000..9f356ebc
--- /dev/null
+++ b/tests/auto/cpptest/q3dscatter/q3dscatter.pro
@@ -0,0 +1,8 @@
+QT += testlib datavisualization
+
+TARGET = tst_cpptest
+CONFIG += console testcase
+
+TEMPLATE = app
+
+SOURCES += tst_scatter.cpp
diff --git a/tests/auto/cpptest/q3dscatter/tst_scatter.cpp b/tests/auto/cpptest/q3dscatter/tst_scatter.cpp
new file mode 100644
index 00000000..5a3b6550
--- /dev/null
+++ b/tests/auto/cpptest/q3dscatter/tst_scatter.cpp
@@ -0,0 +1,237 @@
+/****************************************************************************
+**
+** 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/Q3DScatter>
+
+using namespace QtDataVisualization;
+
+class tst_scatter: public QObject
+{
+ Q_OBJECT
+
+private slots:
+ void initTestCase();
+ void cleanupTestCase();
+ void init();
+ void cleanup();
+
+ void construct();
+
+ void initialProperties();
+ void initializeProperties();
+ void invalidProperties();
+
+ void addSeries();
+ void addMultipleSeries();
+ void selectSeries();
+ void removeSeries();
+ void removeMultipleSeries();
+
+private:
+ Q3DScatter *m_graph;
+};
+
+QScatter3DSeries *newSeries()
+{
+ QScatter3DSeries *series = new QScatter3DSeries;
+ QScatterDataArray data;
+ data << QVector3D(0.5f, 0.5f, 0.5f) << QVector3D(-0.3f, -0.5f, -0.4f) << QVector3D(0.0f, -0.3f, 0.2f);
+ series->dataProxy()->addItems(data);
+ return series;
+}
+
+void tst_scatter::initTestCase()
+{
+}
+
+void tst_scatter::cleanupTestCase()
+{
+}
+
+void tst_scatter::init()
+{
+ m_graph = new Q3DScatter();
+}
+
+void tst_scatter::cleanup()
+{
+ delete m_graph;
+}
+
+void tst_scatter::construct()
+{
+ Q3DScatter *graph = new Q3DScatter();
+ QVERIFY(graph);
+ delete graph;
+
+ graph = new Q3DScatter(new QSurfaceFormat());
+ QVERIFY(graph);
+ delete graph;
+}
+
+void tst_scatter::initialProperties()
+{
+ QVERIFY(m_graph);
+ QCOMPARE(m_graph->seriesList().length(), 0);
+ QVERIFY(!m_graph->selectedSeries());
+ QCOMPARE(m_graph->axisX()->orientation(), QAbstract3DAxis::AxisOrientationX);
+ QCOMPARE(m_graph->axisY()->orientation(), QAbstract3DAxis::AxisOrientationY);
+ QCOMPARE(m_graph->axisZ()->orientation(), QAbstract3DAxis::AxisOrientationZ);
+
+ // Common properties
+ QCOMPARE(m_graph->activeTheme()->type(), Q3DTheme::ThemeQt);
+ QCOMPARE(m_graph->selectionMode(), QAbstract3DGraph::SelectionItem);
+ QCOMPARE(m_graph->shadowQuality(), QAbstract3DGraph::ShadowQualityMedium);
+ QVERIFY(m_graph->scene());
+ QCOMPARE(m_graph->measureFps(), false);
+ QCOMPARE(m_graph->isOrthoProjection(), false);
+ QCOMPARE(m_graph->selectedElement(), QAbstract3DGraph::ElementNone);
+ QCOMPARE(m_graph->aspectRatio(), 2.0);
+ QCOMPARE(m_graph->optimizationHints(), QAbstract3DGraph::OptimizationDefault);
+ QCOMPARE(m_graph->isPolar(), false);
+ QCOMPARE(m_graph->radialLabelOffset(), 1.0);
+ QCOMPARE(m_graph->horizontalAspectRatio(), 0.0);
+ QCOMPARE(m_graph->isReflection(), false);
+ QCOMPARE(m_graph->reflectivity(), 0.5);
+ QCOMPARE(m_graph->locale(), QLocale("C"));
+ QCOMPARE(m_graph->queriedGraphPosition(), QVector3D(0, 0, 0));
+ QCOMPARE(m_graph->margin(), -1.0);
+}
+
+void tst_scatter::initializeProperties()
+{
+ Q3DTheme *theme = new Q3DTheme(Q3DTheme::ThemeDigia);
+ m_graph->setActiveTheme(theme);
+ m_graph->setSelectionMode(QAbstract3DGraph::SelectionNone);
+ m_graph->setShadowQuality(QAbstract3DGraph::ShadowQualitySoftHigh);
+ QCOMPARE(m_graph->shadowQuality(), QAbstract3DGraph::ShadowQualitySoftHigh);
+ m_graph->setMeasureFps(true);
+ m_graph->setOrthoProjection(true);
+ m_graph->setAspectRatio(1.0);
+ m_graph->setOptimizationHints(QAbstract3DGraph::OptimizationStatic);
+ m_graph->setPolar(true);
+ m_graph->setRadialLabelOffset(0.1f);
+ m_graph->setHorizontalAspectRatio(1.0);
+ m_graph->setReflection(true);
+ m_graph->setReflectivity(0.1);
+ m_graph->setLocale(QLocale("FI"));
+ m_graph->setMargin(1.0);
+
+ QCOMPARE(m_graph->activeTheme()->type(), Q3DTheme::ThemeDigia);
+ QCOMPARE(m_graph->selectionMode(), QAbstract3DGraph::SelectionNone);
+ QCOMPARE(m_graph->shadowQuality(), QAbstract3DGraph::ShadowQualityNone); // Ortho disables shadows
+ QCOMPARE(m_graph->measureFps(), true);
+ QCOMPARE(m_graph->isOrthoProjection(), true);
+ QCOMPARE(m_graph->aspectRatio(), 1.0);
+ QCOMPARE(m_graph->optimizationHints(), QAbstract3DGraph::OptimizationStatic);
+ QCOMPARE(m_graph->isPolar(), true);
+ QCOMPARE(m_graph->radialLabelOffset(), 0.1f);
+ QCOMPARE(m_graph->horizontalAspectRatio(), 1.0);
+ QCOMPARE(m_graph->isReflection(), true);
+ QCOMPARE(m_graph->reflectivity(), 0.1);
+ QCOMPARE(m_graph->locale(), QLocale("FI"));
+ QCOMPARE(m_graph->margin(), 1.0);
+}
+
+void tst_scatter::invalidProperties()
+{
+ m_graph->setSelectionMode(QAbstract3DGraph::SelectionColumn | QAbstract3DGraph::SelectionRow | QAbstract3DGraph::SelectionSlice);
+ m_graph->setAspectRatio(-1.0);
+ m_graph->setHorizontalAspectRatio(-1.0);
+ m_graph->setReflectivity(-1.0);
+ m_graph->setLocale(QLocale("XX"));
+
+ QCOMPARE(m_graph->selectionMode(), QAbstract3DGraph::SelectionItem);
+ QCOMPARE(m_graph->aspectRatio(), -1.0/*2.0*/); // TODO: Fix once QTRD-3367 is done
+ QCOMPARE(m_graph->horizontalAspectRatio(), -1.0/*0.0*/); // TODO: Fix once QTRD-3367 is done
+ QCOMPARE(m_graph->reflectivity(), -1.0/*0.5*/); // TODO: Fix once QTRD-3367 is done
+ QCOMPARE(m_graph->locale(), QLocale("C"));
+}
+
+void tst_scatter::addSeries()
+{
+ m_graph->addSeries(newSeries());
+
+ QCOMPARE(m_graph->seriesList().length(), 1);
+ QVERIFY(!m_graph->selectedSeries());
+}
+
+void tst_scatter::addMultipleSeries()
+{
+ QScatter3DSeries *series = newSeries();
+ QScatter3DSeries *series2 = newSeries();
+ QScatter3DSeries *series3 = newSeries();
+
+ m_graph->addSeries(series);
+ m_graph->addSeries(series2);
+ m_graph->addSeries(series3);
+
+ QCOMPARE(m_graph->seriesList().length(), 3);
+}
+
+void tst_scatter::selectSeries()
+{
+ QScatter3DSeries *series = newSeries();
+
+ m_graph->addSeries(series);
+ m_graph->seriesList()[0]->setSelectedItem(1);
+
+ QCOMPARE(m_graph->seriesList().length(), 1);
+ QCOMPARE(m_graph->selectedSeries(), series);
+
+ m_graph->clearSelection();
+ QVERIFY(!m_graph->selectedSeries());
+}
+
+void tst_scatter::removeSeries()
+{
+ QScatter3DSeries *series = newSeries();
+
+ m_graph->addSeries(series);
+ m_graph->removeSeries(series);
+ QCOMPARE(m_graph->seriesList().length(), 0);
+}
+
+void tst_scatter::removeMultipleSeries()
+{
+ QScatter3DSeries *series = newSeries();
+ QScatter3DSeries *series2 = newSeries();
+ QScatter3DSeries *series3 = newSeries();
+
+ m_graph->addSeries(series);
+ m_graph->addSeries(series2);
+ m_graph->addSeries(series3);
+
+ m_graph->seriesList()[0]->setSelectedItem(1);
+ QCOMPARE(m_graph->selectedSeries(), series);
+
+ m_graph->removeSeries(series);
+ QCOMPARE(m_graph->seriesList().length(), 2);
+ QVERIFY(!m_graph->selectedSeries());
+
+ m_graph->removeSeries(series2);
+ QCOMPARE(m_graph->seriesList().length(), 1);
+
+ m_graph->removeSeries(series3);
+ QCOMPARE(m_graph->seriesList().length(), 0);
+}
+
+QTEST_MAIN(tst_scatter)
+#include "tst_scatter.moc"
diff --git a/tests/auto/cpptest/q3dscene-camera/q3dscene-camera.pro b/tests/auto/cpptest/q3dscene-camera/q3dscene-camera.pro
new file mode 100644
index 00000000..c575a55e
--- /dev/null
+++ b/tests/auto/cpptest/q3dscene-camera/q3dscene-camera.pro
@@ -0,0 +1,8 @@
+QT += testlib datavisualization
+
+TARGET = tst_cpptest
+CONFIG += console testcase
+
+TEMPLATE = app
+
+SOURCES += tst_camera.cpp
diff --git a/tests/auto/cpptest/q3dscene-camera/tst_camera.cpp b/tests/auto/cpptest/q3dscene-camera/tst_camera.cpp
new file mode 100644
index 00000000..ee321b22
--- /dev/null
+++ b/tests/auto/cpptest/q3dscene-camera/tst_camera.cpp
@@ -0,0 +1,179 @@
+/****************************************************************************
+**
+** 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/Q3DCamera>
+
+using namespace QtDataVisualization;
+
+class tst_camera: public QObject
+{
+ Q_OBJECT
+
+private slots:
+ void initTestCase();
+ void cleanupTestCase();
+ void init();
+ void cleanup();
+
+ void construct();
+
+ void initialProperties();
+ void initializeProperties();
+ void invalidProperties();
+
+ void changePresets();
+
+private:
+ Q3DCamera *m_camera;
+};
+
+void tst_camera::initTestCase()
+{
+}
+
+void tst_camera::cleanupTestCase()
+{
+}
+
+void tst_camera::init()
+{
+ m_camera = new Q3DCamera();
+}
+
+void tst_camera::cleanup()
+{
+ delete m_camera;
+}
+
+void tst_camera::construct()
+{
+ Q3DCamera *camera = new Q3DCamera();
+ QVERIFY(camera);
+ delete camera;
+}
+
+void tst_camera::initialProperties()
+{
+ QVERIFY(m_camera);
+
+ QCOMPARE(m_camera->cameraPreset(), Q3DCamera::CameraPresetNone);
+ QCOMPARE(m_camera->maxZoomLevel(), 500.0f);
+ QCOMPARE(m_camera->minZoomLevel(), 10.0f);
+ QCOMPARE(m_camera->target(), QVector3D(0.0, 0.0, 0.0));
+ QCOMPARE(m_camera->wrapXRotation(), true);
+ QCOMPARE(m_camera->wrapYRotation(), false);
+ QCOMPARE(m_camera->xRotation(), 0.0f);
+ QCOMPARE(m_camera->yRotation(), 0.0f);
+ QCOMPARE(m_camera->zoomLevel(), 100.0f);
+
+ // Common (from Q3DObject)
+ QVERIFY(!m_camera->parentScene());
+ QCOMPARE(m_camera->position(), QVector3D(0, 0, 0));
+}
+
+void tst_camera::initializeProperties()
+{
+ QVERIFY(m_camera);
+
+ m_camera->setMaxZoomLevel(1000.0f);
+ m_camera->setMinZoomLevel(100.0f);
+ m_camera->setTarget(QVector3D(1.0, -1.0, 1.0));
+ m_camera->setWrapXRotation(false);
+ m_camera->setWrapYRotation(true);
+ m_camera->setXRotation(30.0f);
+ m_camera->setYRotation(30.0f);
+ m_camera->setZoomLevel(500.0f);
+
+ QCOMPARE(m_camera->maxZoomLevel(), 1000.0f);
+ QCOMPARE(m_camera->minZoomLevel(), 100.0f);
+ QCOMPARE(m_camera->target(), QVector3D(1.0, -1.0, 1.0));
+ QCOMPARE(m_camera->wrapXRotation(), false);
+ QCOMPARE(m_camera->wrapYRotation(), true);
+ QCOMPARE(m_camera->xRotation(), 30.0f);
+ QCOMPARE(m_camera->yRotation(), 30.0f);
+ QCOMPARE(m_camera->zoomLevel(), 500.0f);
+
+ m_camera->setPosition(QVector3D(1.0, 1.0, 1.0));
+
+ // Common (from Q3DObject)
+ QCOMPARE(m_camera->position(), QVector3D(1.0, 1.0, 1.0));
+}
+
+void tst_camera::invalidProperties()
+{
+ m_camera->setTarget(QVector3D(-1.5, -1.5, -1.5));
+ QCOMPARE(m_camera->target(), QVector3D(-1.0, -1.0, -1.0));
+
+ m_camera->setTarget(QVector3D(1.5, 1.5, 1.5));
+ QCOMPARE(m_camera->target(), QVector3D(1.0, 1.0, 1.0));
+
+ m_camera->setMinZoomLevel(0.1f);
+ QCOMPARE(m_camera->minZoomLevel(), 1.0f);
+}
+
+void tst_camera::changePresets()
+{
+ m_camera->setCameraPreset(Q3DCamera::CameraPresetBehind); // Will be overridden by the the following sets
+ m_camera->setMaxZoomLevel(1000.0f);
+ m_camera->setMinZoomLevel(100.0f);
+ m_camera->setTarget(QVector3D(1.0, -1.0, 1.0));
+ m_camera->setWrapXRotation(false);
+ m_camera->setWrapYRotation(true);
+ m_camera->setXRotation(30.0f);
+ m_camera->setYRotation(30.0f);
+ m_camera->setZoomLevel(500.0f);
+
+ QCOMPARE(m_camera->cameraPreset(), Q3DCamera::CameraPresetNone);
+ QCOMPARE(m_camera->maxZoomLevel(), 1000.0f);
+ QCOMPARE(m_camera->minZoomLevel(), 100.0f);
+ QCOMPARE(m_camera->target(), QVector3D(1.0, -1.0, 1.0));
+ QCOMPARE(m_camera->wrapXRotation(), false);
+ QCOMPARE(m_camera->wrapYRotation(), true);
+ QCOMPARE(m_camera->xRotation(), 30.0f);
+ QCOMPARE(m_camera->yRotation(), 30.0f);
+ QCOMPARE(m_camera->zoomLevel(), 500.0f);
+
+ m_camera->setCameraPreset(Q3DCamera::CameraPresetBehind); // Sets target and rotations
+
+ QCOMPARE(m_camera->cameraPreset(), Q3DCamera::CameraPresetBehind);
+ QCOMPARE(m_camera->maxZoomLevel(), 1000.0f);
+ QCOMPARE(m_camera->minZoomLevel(), 100.0f);
+ QCOMPARE(m_camera->target(), QVector3D(0.0, 0.0, 0.0));
+ QCOMPARE(m_camera->wrapXRotation(), false);
+ QCOMPARE(m_camera->wrapYRotation(), true);
+ QCOMPARE(m_camera->xRotation(), 180.0f);
+ QCOMPARE(m_camera->yRotation(), 22.5f);
+ QCOMPARE(m_camera->zoomLevel(), 500.0f);
+
+ m_camera->setCameraPosition(10.0f, 15.0f, 125.0f); // Overrides preset
+
+ QCOMPARE(m_camera->cameraPreset(), Q3DCamera::CameraPresetNone);
+ QCOMPARE(m_camera->maxZoomLevel(), 1000.0f);
+ QCOMPARE(m_camera->minZoomLevel(), 100.0f);
+ QCOMPARE(m_camera->target(), QVector3D(0.0, 0.0, 0.0));
+ QCOMPARE(m_camera->wrapXRotation(), false);
+ QCOMPARE(m_camera->wrapYRotation(), true);
+ QCOMPARE(m_camera->xRotation(), 10.0f);
+ QCOMPARE(m_camera->yRotation(), 15.0f);
+ QCOMPARE(m_camera->zoomLevel(), 125.0f);
+}
+
+QTEST_MAIN(tst_camera)
+#include "tst_camera.moc"
diff --git a/tests/auto/cpptest/q3dscene-light/q3dscene-light.pro b/tests/auto/cpptest/q3dscene-light/q3dscene-light.pro
new file mode 100644
index 00000000..21a3c934
--- /dev/null
+++ b/tests/auto/cpptest/q3dscene-light/q3dscene-light.pro
@@ -0,0 +1,8 @@
+QT += testlib datavisualization
+
+TARGET = tst_cpptest
+CONFIG += console testcase
+
+TEMPLATE = app
+
+SOURCES += tst_light.cpp
diff --git a/tests/auto/cpptest/q3dscene-light/tst_light.cpp b/tests/auto/cpptest/q3dscene-light/tst_light.cpp
new file mode 100644
index 00000000..4568b01e
--- /dev/null
+++ b/tests/auto/cpptest/q3dscene-light/tst_light.cpp
@@ -0,0 +1,92 @@
+/****************************************************************************
+**
+** 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/Q3DLight>
+
+using namespace QtDataVisualization;
+
+class tst_light: public QObject
+{
+ Q_OBJECT
+
+private slots:
+ void initTestCase();
+ void cleanupTestCase();
+ void init();
+ void cleanup();
+
+ void construct();
+
+ void initialProperties();
+ void initializeProperties();
+
+private:
+ Q3DLight *m_light;
+};
+
+void tst_light::initTestCase()
+{
+}
+
+void tst_light::cleanupTestCase()
+{
+}
+
+void tst_light::init()
+{
+ m_light = new Q3DLight();
+}
+
+void tst_light::cleanup()
+{
+ delete m_light;
+}
+
+void tst_light::construct()
+{
+ Q3DLight *light = new Q3DLight();
+ QVERIFY(light);
+ delete light;
+}
+
+void tst_light::initialProperties()
+{
+ QVERIFY(m_light);
+
+ // TODO: Has no adjustable properties yet.
+ // Keeping this as a placeholder for future implementations (QTRD-2406)
+
+ // Common (from Q3DObject)
+ QVERIFY(!m_light->parentScene());
+ QCOMPARE(m_light->position(), QVector3D(0, 0, 0));
+}
+
+void tst_light::initializeProperties()
+{
+ QVERIFY(m_light);
+
+ m_light->setPosition(QVector3D(1.0, 1.0, 1.0));
+
+ // Common (from Q3DObject)
+ QCOMPARE(m_light->position(), QVector3D(1.0, 1.0, 1.0));
+}
+
+QTEST_MAIN(tst_light)
+#include "tst_light.moc"
diff --git a/tests/auto/cpptest/q3dscene/q3dscene.pro b/tests/auto/cpptest/q3dscene/q3dscene.pro
new file mode 100644
index 00000000..b9be69c0
--- /dev/null
+++ b/tests/auto/cpptest/q3dscene/q3dscene.pro
@@ -0,0 +1,8 @@
+QT += testlib datavisualization
+
+TARGET = tst_cpptest
+CONFIG += console testcase
+
+TEMPLATE = app
+
+SOURCES += tst_scene.cpp
diff --git a/tests/auto/cpptest/q3dscene/tst_scene.cpp b/tests/auto/cpptest/q3dscene/tst_scene.cpp
new file mode 100644
index 00000000..7d1ecad3
--- /dev/null
+++ b/tests/auto/cpptest/q3dscene/tst_scene.cpp
@@ -0,0 +1,170 @@
+/****************************************************************************
+**
+** 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/Q3DScene>
+#include <QtDataVisualization/Q3DBars>
+
+using namespace QtDataVisualization;
+
+class tst_scene: public QObject
+{
+ Q_OBJECT
+
+private slots:
+ void initTestCase();
+ void cleanupTestCase();
+ void init();
+ void cleanup();
+
+ void construct();
+
+ void initialProperties();
+ void initializeProperties();
+ void invalidProperties();
+
+ void subViews();
+
+private:
+ Q3DScene *m_scene;
+};
+
+void tst_scene::initTestCase()
+{
+}
+
+void tst_scene::cleanupTestCase()
+{
+}
+
+void tst_scene::init()
+{
+ m_scene = new Q3DScene();
+}
+
+void tst_scene::cleanup()
+{
+ delete m_scene;
+}
+
+void tst_scene::construct()
+{
+ Q3DScene *scene = new Q3DScene();
+ QVERIFY(scene);
+ delete scene;
+}
+
+void tst_scene::initialProperties()
+{
+ QVERIFY(m_scene);
+
+ QVERIFY(m_scene->activeCamera());
+ QVERIFY(m_scene->activeLight());
+ QCOMPARE(m_scene->devicePixelRatio(), 1.0f);
+ QCOMPARE(m_scene->graphPositionQuery(), m_scene->invalidSelectionPoint());
+ QCOMPARE(m_scene->primarySubViewport(), QRect(0, 0, 0, 0));
+ QCOMPARE(m_scene->secondarySubViewport(), QRect(0, 0, 0, 0));
+ QCOMPARE(m_scene->isSecondarySubviewOnTop(), true);
+ QCOMPARE(m_scene->selectionQueryPosition(), m_scene->invalidSelectionPoint());
+ QCOMPARE(m_scene->isSlicingActive(), false);
+ QCOMPARE(m_scene->viewport(), QRect(0, 0, 0, 0));
+}
+
+void tst_scene::initializeProperties()
+{
+ QVERIFY(m_scene);
+
+ Q3DCamera *camera1 = new Q3DCamera();
+ Q3DLight *light1 = new Q3DLight();
+
+ m_scene->setActiveCamera(camera1);
+ m_scene->setActiveLight(light1);
+ m_scene->setDevicePixelRatio(2.0f);
+ m_scene->setGraphPositionQuery(QPoint(0, 0));
+ m_scene->setPrimarySubViewport(QRect(0, 0, 50, 50));
+ m_scene->setSecondarySubViewport(QRect(50, 50, 100, 100));
+ m_scene->setSecondarySubviewOnTop(false);
+ m_scene->setSelectionQueryPosition(QPoint(0, 0));
+ m_scene->setSlicingActive(true);
+
+ QCOMPARE(m_scene->activeCamera(), camera1);
+ QCOMPARE(m_scene->activeLight(), light1);
+ QCOMPARE(m_scene->devicePixelRatio(), 2.0f);
+ QCOMPARE(m_scene->graphPositionQuery(), QPoint(0, 0)); // TODO: When doing signal checks, add tests to check that queries return something (asynchronously)
+ // TODO: subviewports are not set (QTRD-2435)
+ //QCOMPARE(m_scene->primarySubViewport(), QRect(0, 0, 50, 50));
+ //QCOMPARE(m_scene->secondarySubViewport(), QRect(50, 50, 100, 100));
+ QCOMPARE(m_scene->isSecondarySubviewOnTop(), false);
+ QCOMPARE(m_scene->selectionQueryPosition(), QPoint(0, 0)); // TODO: When doing signal checks, add tests to check that queries return something (asynchronously)
+ QCOMPARE(m_scene->isSlicingActive(), true);
+ // TODO: viewport is not set by subviewports (QTRD-2435)
+ //QCOMPARE(m_scene->viewport(), QRect(0, 0, 100, 100));
+}
+
+void tst_scene::invalidProperties()
+{
+ m_scene->setPrimarySubViewport(QRect(0, 0, -50, -50));
+ m_scene->setSecondarySubViewport(QRect(-50, -50, -100, -100));
+ QCOMPARE(m_scene->primarySubViewport(), QRect(0, 0, 0, 0));
+ QCOMPARE(m_scene->secondarySubViewport(), QRect(0, 0, 0, 0));
+}
+
+void tst_scene::subViews()
+{
+ Q3DBars *graph = new Q3DBars();
+ graph->setPosition(QPoint(0, 0));
+ graph->setWidth(200);
+ graph->setHeight(200);
+
+ Q3DScene *scene = graph->scene();
+
+ QCoreApplication::processEvents();
+
+ QCOMPARE(scene->viewport(), QRect(0, 0, 200, 200));
+ QCOMPARE(scene->primarySubViewport(), QRect(0, 0, 200, 200));
+ QCOMPARE(scene->secondarySubViewport(), QRect(0, 0, 0, 0));
+
+ QCOMPARE(scene->isSecondarySubviewOnTop(), true);
+ QCOMPARE(scene->isPointInPrimarySubView(QPoint(100, 100)), true);
+ QCOMPARE(scene->isPointInPrimarySubView(QPoint(201, 201)), false);
+ QCOMPARE(scene->isPointInSecondarySubView(QPoint(100, 100)), false);
+
+ scene->setSlicingActive(true);
+
+ QCOMPARE(scene->isSecondarySubviewOnTop(), false);
+ QCOMPARE(scene->primarySubViewport(), QRect(0, 0, 40, 40));
+ QCOMPARE(scene->secondarySubViewport(), QRect(0, 0, 200, 200));
+ QCOMPARE(scene->isPointInPrimarySubView(QPoint(100, 100)), false);
+ QCOMPARE(scene->isPointInPrimarySubView(QPoint(30, 30)), true);
+ QCOMPARE(scene->isPointInSecondarySubView(QPoint(100, 100)), true);
+ QCOMPARE(scene->isPointInSecondarySubView(QPoint(30, 30)), false);
+
+ scene->setSecondarySubviewOnTop(true);
+
+ QCOMPARE(scene->isSecondarySubviewOnTop(), true);
+ QCOMPARE(scene->primarySubViewport(), QRect(0, 0, 40, 40));
+ QCOMPARE(scene->secondarySubViewport(), QRect(0, 0, 200, 200));
+ QCOMPARE(scene->isPointInPrimarySubView(QPoint(100, 100)), false);
+ QCOMPARE(scene->isPointInPrimarySubView(QPoint(30, 30)), false);
+ QCOMPARE(scene->isPointInSecondarySubView(QPoint(100, 100)), true);
+ QCOMPARE(scene->isPointInSecondarySubView(QPoint(30, 30)), true);
+}
+
+QTEST_MAIN(tst_scene)
+#include "tst_scene.moc"
diff --git a/tests/auto/cpptest/q3dsurface-heightproxy/customtexture.jpg b/tests/auto/cpptest/q3dsurface-heightproxy/customtexture.jpg
new file mode 100644
index 00000000..2580f5bd
--- /dev/null
+++ b/tests/auto/cpptest/q3dsurface-heightproxy/customtexture.jpg
Binary files differ
diff --git a/tests/auto/cpptest/q3dsurface-heightproxy/q3dsurface-heightproxy.pro b/tests/auto/cpptest/q3dsurface-heightproxy/q3dsurface-heightproxy.pro
new file mode 100644
index 00000000..56a964d0
--- /dev/null
+++ b/tests/auto/cpptest/q3dsurface-heightproxy/q3dsurface-heightproxy.pro
@@ -0,0 +1,11 @@
+QT += testlib datavisualization
+
+TARGET = tst_cpptest
+CONFIG += console testcase
+
+TEMPLATE = app
+
+SOURCES += tst_proxy.cpp
+
+RESOURCES += \
+ q3dsurface-heightproxy.qrc
diff --git a/tests/auto/cpptest/q3dsurface-heightproxy/q3dsurface-heightproxy.qrc b/tests/auto/cpptest/q3dsurface-heightproxy/q3dsurface-heightproxy.qrc
new file mode 100644
index 00000000..b83c7ef9
--- /dev/null
+++ b/tests/auto/cpptest/q3dsurface-heightproxy/q3dsurface-heightproxy.qrc
@@ -0,0 +1,5 @@
+<RCC>
+ <qresource prefix="/">
+ <file>customtexture.jpg</file>
+ </qresource>
+</RCC>
diff --git a/tests/auto/cpptest/q3dsurface-heightproxy/tst_proxy.cpp b/tests/auto/cpptest/q3dsurface-heightproxy/tst_proxy.cpp
new file mode 100644
index 00000000..20ed1aeb
--- /dev/null
+++ b/tests/auto/cpptest/q3dsurface-heightproxy/tst_proxy.cpp
@@ -0,0 +1,156 @@
+/****************************************************************************
+**
+** 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/QHeightMapSurfaceDataProxy>
+
+using namespace QtDataVisualization;
+
+class tst_proxy: public QObject
+{
+ Q_OBJECT
+
+private slots:
+ void initTestCase();
+ void cleanupTestCase();
+ void init();
+ void cleanup();
+
+ void construct();
+
+ void initialProperties();
+ void initializeProperties();
+ void invalidProperties();
+
+private:
+ QHeightMapSurfaceDataProxy *m_proxy;
+};
+
+void tst_proxy::initTestCase()
+{
+}
+
+void tst_proxy::cleanupTestCase()
+{
+}
+
+void tst_proxy::init()
+{
+ m_proxy = new QHeightMapSurfaceDataProxy();
+}
+
+void tst_proxy::cleanup()
+{
+ delete m_proxy;
+}
+
+void tst_proxy::construct()
+{
+ QHeightMapSurfaceDataProxy *proxy = new QHeightMapSurfaceDataProxy();
+ QVERIFY(proxy);
+ delete proxy;
+
+ proxy = new QHeightMapSurfaceDataProxy(QImage(QSize(10, 10), QImage::Format_ARGB32));
+ QVERIFY(proxy);
+ QCoreApplication::processEvents();
+ QCOMPARE(proxy->columnCount(), 10);
+ QCOMPARE(proxy->rowCount(), 10);
+ delete proxy;
+
+ proxy = new QHeightMapSurfaceDataProxy(":/customtexture.jpg");
+ QVERIFY(proxy);
+ QCoreApplication::processEvents();
+ QCOMPARE(proxy->columnCount(), 24);
+ QCOMPARE(proxy->rowCount(), 24);
+ delete proxy;
+}
+
+void tst_proxy::initialProperties()
+{
+ QVERIFY(m_proxy);
+
+ QCOMPARE(m_proxy->heightMap(), QImage());
+ QCOMPARE(m_proxy->heightMapFile(), QString(""));
+ QCOMPARE(m_proxy->maxXValue(), 10.0f);
+ QCOMPARE(m_proxy->maxZValue(), 10.0f);
+ QCOMPARE(m_proxy->minXValue(), 0.0f);
+ QCOMPARE(m_proxy->minZValue(), 0.0f);
+
+ QCOMPARE(m_proxy->columnCount(), 0);
+ QCOMPARE(m_proxy->rowCount(), 0);
+ QVERIFY(!m_proxy->series());
+
+ QCOMPARE(m_proxy->type(), QAbstractDataProxy::DataTypeSurface);
+}
+
+void tst_proxy::initializeProperties()
+{
+ QVERIFY(m_proxy);
+
+ m_proxy->setHeightMapFile(":/customtexture.jpg");
+ m_proxy->setMaxXValue(11.0f);
+ m_proxy->setMaxZValue(11.0f);
+ m_proxy->setMinXValue(-10.0f);
+ m_proxy->setMinZValue(-10.0f);
+
+ QCoreApplication::processEvents();
+
+ QCOMPARE(m_proxy->heightMapFile(), QString(":/customtexture.jpg"));
+ QCOMPARE(m_proxy->maxXValue(), 11.0f);
+ QCOMPARE(m_proxy->maxZValue(), 11.0f);
+ QCOMPARE(m_proxy->minXValue(), -10.0f);
+ QCOMPARE(m_proxy->minZValue(), -10.0f);
+
+ QCOMPARE(m_proxy->columnCount(), 24);
+ QCOMPARE(m_proxy->rowCount(), 24);
+
+ m_proxy->setHeightMapFile("");
+
+ QCoreApplication::processEvents();
+
+ QCOMPARE(m_proxy->columnCount(), 0);
+ QCOMPARE(m_proxy->rowCount(), 0);
+
+ m_proxy->setHeightMap(QImage(":/customtexture.jpg"));
+
+ QCoreApplication::processEvents();
+
+ QCOMPARE(m_proxy->columnCount(), 24);
+ QCOMPARE(m_proxy->rowCount(), 24);
+}
+
+void tst_proxy::invalidProperties()
+{
+ m_proxy->setMaxXValue(-10.0f);
+ m_proxy->setMaxZValue(-10.0f);
+ QCOMPARE(m_proxy->maxXValue(), -10.0f);
+ QCOMPARE(m_proxy->maxZValue(), -10.0f);
+ QCOMPARE(m_proxy->minXValue(), -11.0f);
+ QCOMPARE(m_proxy->minZValue(), -11.0f);
+
+ m_proxy->setMinXValue(10.0f);
+ m_proxy->setMinZValue(10.0f);
+ QCOMPARE(m_proxy->maxXValue(), 11.0f);
+ QCOMPARE(m_proxy->maxZValue(), 11.0f);
+ QCOMPARE(m_proxy->minXValue(), 10.0f);
+ QCOMPARE(m_proxy->minZValue(), 10.0f);
+}
+
+QTEST_MAIN(tst_proxy)
+#include "tst_proxy.moc"
diff --git a/tests/auto/cpptest/q3dsurface-modelproxy/q3dsurface-modelproxy.pro b/tests/auto/cpptest/q3dsurface-modelproxy/q3dsurface-modelproxy.pro
new file mode 100644
index 00000000..c383ec25
--- /dev/null
+++ b/tests/auto/cpptest/q3dsurface-modelproxy/q3dsurface-modelproxy.pro
@@ -0,0 +1,8 @@
+QT += testlib datavisualization widgets
+
+TARGET = tst_cpptest
+CONFIG += console testcase
+
+TEMPLATE = app
+
+SOURCES += tst_proxy.cpp
diff --git a/tests/auto/cpptest/q3dsurface-modelproxy/tst_proxy.cpp b/tests/auto/cpptest/q3dsurface-modelproxy/tst_proxy.cpp
new file mode 100644
index 00000000..6bef9478
--- /dev/null
+++ b/tests/auto/cpptest/q3dsurface-modelproxy/tst_proxy.cpp
@@ -0,0 +1,283 @@
+/****************************************************************************
+**
+** 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/QItemModelSurfaceDataProxy>
+#include <QtDataVisualization/Q3DSurface>
+#include <QtWidgets/QTableWidget>
+
+using namespace QtDataVisualization;
+
+class tst_proxy: public QObject
+{
+ Q_OBJECT
+
+private slots:
+ void initTestCase();
+ void cleanupTestCase();
+ void init();
+ void cleanup();
+
+ void construct();
+
+ void initialProperties();
+ void initializeProperties();
+
+ void multiMatch();
+
+private:
+ QItemModelSurfaceDataProxy *m_proxy;
+};
+
+void tst_proxy::initTestCase()
+{
+}
+
+void tst_proxy::cleanupTestCase()
+{
+}
+
+void tst_proxy::init()
+{
+ m_proxy = new QItemModelSurfaceDataProxy();
+}
+
+void tst_proxy::cleanup()
+{
+ delete m_proxy;
+}
+
+
+void tst_proxy::construct()
+{
+ QItemModelSurfaceDataProxy *proxy = new QItemModelSurfaceDataProxy();
+ QVERIFY(proxy);
+ delete proxy;
+
+ QTableWidget *table = new QTableWidget();
+
+ proxy = new QItemModelSurfaceDataProxy(table->model());
+ QVERIFY(proxy);
+ delete proxy;
+
+ proxy = new QItemModelSurfaceDataProxy(table->model(), "y");
+ QVERIFY(proxy);
+ QCOMPARE(proxy->rowRole(), QString(""));
+ QCOMPARE(proxy->columnRole(), QString(""));
+ QCOMPARE(proxy->xPosRole(), QString(""));
+ QCOMPARE(proxy->yPosRole(), QString("y"));
+ QCOMPARE(proxy->zPosRole(), QString(""));
+ QCOMPARE(proxy->rowCategories().length(), 0);
+ QCOMPARE(proxy->columnCategories().length(), 0);
+ delete proxy;
+
+ proxy = new QItemModelSurfaceDataProxy(table->model(), "row", "column", "y");
+ QVERIFY(proxy);
+ QCOMPARE(proxy->rowRole(), QString("row"));
+ QCOMPARE(proxy->columnRole(), QString("column"));
+ QCOMPARE(proxy->xPosRole(), QString("column"));
+ QCOMPARE(proxy->yPosRole(), QString("y"));
+ QCOMPARE(proxy->zPosRole(), QString("row"));
+ QCOMPARE(proxy->rowCategories().length(), 0);
+ QCOMPARE(proxy->columnCategories().length(), 0);
+ delete proxy;
+
+ proxy = new QItemModelSurfaceDataProxy(table->model(), "row", "column", "x", "y", "z");
+ QVERIFY(proxy);
+ QCOMPARE(proxy->rowRole(), QString("row"));
+ QCOMPARE(proxy->columnRole(), QString("column"));
+ QCOMPARE(proxy->xPosRole(), QString("x"));
+ QCOMPARE(proxy->yPosRole(), QString("y"));
+ QCOMPARE(proxy->zPosRole(), QString("z"));
+ QCOMPARE(proxy->rowCategories().length(), 0);
+ QCOMPARE(proxy->columnCategories().length(), 0);
+ delete proxy;
+
+ proxy = new QItemModelSurfaceDataProxy(table->model(), "row", "column", "y",
+ QStringList() << "rowCat", QStringList() << "colCat");
+ QVERIFY(proxy);
+ QCOMPARE(proxy->rowRole(), QString("row"));
+ QCOMPARE(proxy->columnRole(), QString("column"));
+ QCOMPARE(proxy->xPosRole(), QString("column"));
+ QCOMPARE(proxy->yPosRole(), QString("y"));
+ QCOMPARE(proxy->zPosRole(), QString("row"));
+ QCOMPARE(proxy->rowCategories().length(), 1);
+ QCOMPARE(proxy->columnCategories().length(), 1);
+ delete proxy;
+
+ proxy = new QItemModelSurfaceDataProxy(table->model(), "row", "column", "x", "y", "z",
+ QStringList() << "rowCat", QStringList() << "colCat");
+ QVERIFY(proxy);
+ QCOMPARE(proxy->rowRole(), QString("row"));
+ QCOMPARE(proxy->columnRole(), QString("column"));
+ QCOMPARE(proxy->xPosRole(), QString("x"));
+ QCOMPARE(proxy->yPosRole(), QString("y"));
+ QCOMPARE(proxy->zPosRole(), QString("z"));
+ QCOMPARE(proxy->rowCategories().length(), 1);
+ QCOMPARE(proxy->columnCategories().length(), 1);
+ delete proxy;
+}
+
+void tst_proxy::initialProperties()
+{
+ QVERIFY(m_proxy);
+
+ QCOMPARE(m_proxy->autoColumnCategories(), true);
+ QCOMPARE(m_proxy->autoRowCategories(), true);
+ QCOMPARE(m_proxy->columnCategories(), QStringList());
+ QCOMPARE(m_proxy->columnRole(), QString());
+ QCOMPARE(m_proxy->columnRolePattern(), QRegExp());
+ QCOMPARE(m_proxy->columnRoleReplace(), QString());
+ QVERIFY(!m_proxy->itemModel());
+ QCOMPARE(m_proxy->multiMatchBehavior(), QItemModelSurfaceDataProxy::MMBLast);
+ QCOMPARE(m_proxy->rowCategories(), QStringList());
+ QCOMPARE(m_proxy->rowRole(), QString());
+ QCOMPARE(m_proxy->rowRolePattern(), QRegExp());
+ QCOMPARE(m_proxy->rowRoleReplace(), QString());
+ QCOMPARE(m_proxy->useModelCategories(), false);
+ QCOMPARE(m_proxy->xPosRole(), QString());
+ QCOMPARE(m_proxy->xPosRolePattern(), QRegExp());
+ QCOMPARE(m_proxy->xPosRoleReplace(), QString());
+ QCOMPARE(m_proxy->yPosRole(), QString());
+ QCOMPARE(m_proxy->yPosRolePattern(), QRegExp());
+ QCOMPARE(m_proxy->yPosRoleReplace(), QString());
+ QCOMPARE(m_proxy->zPosRole(), QString());
+ QCOMPARE(m_proxy->zPosRolePattern(), QRegExp());
+ QCOMPARE(m_proxy->zPosRoleReplace(), QString());
+
+ QCOMPARE(m_proxy->columnCount(), 0);
+ QCOMPARE(m_proxy->rowCount(), 0);
+ QVERIFY(!m_proxy->series());
+
+ QCOMPARE(m_proxy->type(), QAbstractDataProxy::DataTypeSurface);
+}
+
+void tst_proxy::initializeProperties()
+{
+ QVERIFY(m_proxy);
+
+ QTableWidget *table = new QTableWidget();
+
+ m_proxy->setAutoColumnCategories(false);
+ m_proxy->setAutoRowCategories(false);
+ m_proxy->setColumnCategories(QStringList() << "col1" << "col2");
+ m_proxy->setColumnRole("column");
+ m_proxy->setColumnRolePattern(QRegExp("/^.*-(\\d\\d)$/"));
+ m_proxy->setColumnRoleReplace("\\\\1");
+ m_proxy->setItemModel(table->model());
+ m_proxy->setMultiMatchBehavior(QItemModelSurfaceDataProxy::MMBAverage);
+ m_proxy->setRowCategories(QStringList() << "row1" << "row2");
+ m_proxy->setRowRole("row");
+ m_proxy->setRowRolePattern(QRegExp("/^(\\d\\d\\d\\d).*$/"));
+ m_proxy->setRowRoleReplace("\\\\1");
+ m_proxy->setUseModelCategories(true);
+ m_proxy->setXPosRole("X");
+ m_proxy->setXPosRolePattern(QRegExp("/-/"));
+ m_proxy->setXPosRoleReplace("\\\\1");
+ m_proxy->setYPosRole("Y");
+ m_proxy->setYPosRolePattern(QRegExp("/-/"));
+ m_proxy->setYPosRoleReplace("\\\\1");
+ m_proxy->setZPosRole("Z");
+ m_proxy->setZPosRolePattern(QRegExp("/-/"));
+ m_proxy->setZPosRoleReplace("\\\\1");
+
+ QCOMPARE(m_proxy->autoColumnCategories(), false);
+ QCOMPARE(m_proxy->autoRowCategories(), false);
+ QCOMPARE(m_proxy->columnCategories().count(), 2);
+ QCOMPARE(m_proxy->columnRole(), QString("column"));
+ QCOMPARE(m_proxy->columnRolePattern(), QRegExp("/^.*-(\\d\\d)$/"));
+ QCOMPARE(m_proxy->columnRoleReplace(), QString("\\\\1"));
+ QVERIFY(m_proxy->itemModel());
+ QCOMPARE(m_proxy->multiMatchBehavior(), QItemModelSurfaceDataProxy::MMBAverage);
+ QCOMPARE(m_proxy->rowCategories().count(), 2);
+ QCOMPARE(m_proxy->rowRole(), QString("row"));
+ QCOMPARE(m_proxy->rowRolePattern(), QRegExp("/^(\\d\\d\\d\\d).*$/"));
+ QCOMPARE(m_proxy->rowRoleReplace(), QString("\\\\1"));
+ QCOMPARE(m_proxy->useModelCategories(), true);
+ QCOMPARE(m_proxy->xPosRole(), QString("X"));
+ QCOMPARE(m_proxy->xPosRolePattern(), QRegExp("/-/"));
+ QCOMPARE(m_proxy->xPosRoleReplace(), QString("\\\\1"));
+ QCOMPARE(m_proxy->yPosRole(), QString("Y"));
+ QCOMPARE(m_proxy->yPosRolePattern(), QRegExp("/-/"));
+ QCOMPARE(m_proxy->yPosRoleReplace(), QString("\\\\1"));
+ QCOMPARE(m_proxy->zPosRole(), QString("Z"));
+ QCOMPARE(m_proxy->zPosRolePattern(), QRegExp("/-/"));
+ QCOMPARE(m_proxy->zPosRoleReplace(), QString("\\\\1"));
+}
+
+void tst_proxy::multiMatch()
+{
+ Q3DSurface *graph = new Q3DSurface();
+
+ QTableWidget *table = new QTableWidget();
+ QStringList rows;
+ rows << "row 1" << "row 2";
+ QStringList columns;
+ columns << "col 1" << "col 2" << "col 3" << "col 4";
+ const char *values[4][2] = {{"0/0/5.5/30", "0/0/10.5/30"},
+ {"0/1/5.5/30", "0/1/0.5/30"},
+ {"1/0/5.5/30", "1/0/0.5/30"},
+ {"1/1/0.0/30", "1/1/0.0/30"}};
+
+ table->setRowCount(2);
+ table->setColumnCount(4);
+
+ for (int col = 0; col < columns.size(); col++) {
+ for (int row = 0; row < rows.size(); row++) {
+ QModelIndex index = table->model()->index(col, row);
+ table->model()->setData(index, values[col][row]);
+ }
+ }
+
+ m_proxy->setItemModel(table->model());
+ m_proxy->setRowRole(table->model()->roleNames().value(Qt::DisplayRole));
+ m_proxy->setColumnRole(table->model()->roleNames().value(Qt::DisplayRole));
+ m_proxy->setRowRolePattern(QRegExp(QStringLiteral("^(\\d*)\\/(\\d*)\\/\\d*[\\.\\,]?\\d*\\/\\d*[\\.\\,]?\\d*$")));
+ m_proxy->setRowRoleReplace(QStringLiteral("\\2"));
+ m_proxy->setYPosRolePattern(QRegExp(QStringLiteral("^\\d*(\\/)(\\d*)\\/(\\d*[\\.\\,]?\\d*)\\/\\d*[\\.\\,]?\\d*$")));
+ m_proxy->setYPosRoleReplace(QStringLiteral("\\3"));
+ m_proxy->setColumnRolePattern(QRegExp(QStringLiteral("^(\\d*)(\\/)(\\d*)\\/\\d*[\\.\\,]?\\d*\\/\\d*[\\.\\,]?\\d*$")));
+ m_proxy->setColumnRoleReplace(QStringLiteral("\\1"));
+
+ QSurface3DSeries *series = new QSurface3DSeries(m_proxy);
+
+ graph->addSeries(series);
+
+ QCoreApplication::processEvents();
+ QCOMPARE(graph->axisY()->max(), 10.5f);
+ m_proxy->setMultiMatchBehavior(QItemModelSurfaceDataProxy::MMBFirst);
+ QCoreApplication::processEvents();
+ QCOMPARE(graph->axisY()->max(), 5.5f);
+ m_proxy->setMultiMatchBehavior(QItemModelSurfaceDataProxy::MMBLast);
+ QCoreApplication::processEvents();
+ QCOMPARE(graph->axisY()->max(), 10.5f);
+ m_proxy->setMultiMatchBehavior(QItemModelSurfaceDataProxy::MMBAverage);
+ QCoreApplication::processEvents();
+ QCOMPARE(graph->axisY()->max(), 8.0f);
+ m_proxy->setMultiMatchBehavior(QItemModelSurfaceDataProxy::MMBCumulativeY);
+ QCoreApplication::processEvents();
+ QCOMPARE(graph->axisY()->max(), 16.0f);
+
+ QCOMPARE(m_proxy->columnCount(), 2);
+ QCOMPARE(m_proxy->rowCount(), 3);
+ QVERIFY(m_proxy->series());
+}
+
+QTEST_MAIN(tst_proxy)
+#include "tst_proxy.moc"
diff --git a/tests/auto/cpptest/q3dsurface-proxy/q3dsurface-proxy.pro b/tests/auto/cpptest/q3dsurface-proxy/q3dsurface-proxy.pro
new file mode 100644
index 00000000..b0b5d361
--- /dev/null
+++ b/tests/auto/cpptest/q3dsurface-proxy/q3dsurface-proxy.pro
@@ -0,0 +1,8 @@
+QT += testlib datavisualization
+
+TARGET = tst_cpptest
+CONFIG += console testcase
+
+TEMPLATE = app
+
+SOURCES += tst_proxy.cpp
diff --git a/tests/auto/cpptest/q3dsurface-proxy/tst_proxy.cpp b/tests/auto/cpptest/q3dsurface-proxy/tst_proxy.cpp
new file mode 100644
index 00000000..4274899d
--- /dev/null
+++ b/tests/auto/cpptest/q3dsurface-proxy/tst_proxy.cpp
@@ -0,0 +1,98 @@
+/****************************************************************************
+**
+** 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/QSurfaceDataProxy>
+
+using namespace QtDataVisualization;
+
+class tst_proxy: public QObject
+{
+ Q_OBJECT
+
+private slots:
+ void initTestCase();
+ void cleanupTestCase();
+ void init();
+ void cleanup();
+
+ void construct();
+
+ void initialProperties();
+ void initializeProperties();
+
+private:
+ QSurfaceDataProxy *m_proxy;
+};
+
+void tst_proxy::initTestCase()
+{
+}
+
+void tst_proxy::cleanupTestCase()
+{
+}
+
+void tst_proxy::init()
+{
+ m_proxy = new QSurfaceDataProxy();
+}
+
+void tst_proxy::cleanup()
+{
+ delete m_proxy;
+}
+
+void tst_proxy::construct()
+{
+ QSurfaceDataProxy *proxy = new QSurfaceDataProxy();
+ QVERIFY(proxy);
+ delete proxy;
+}
+
+void tst_proxy::initialProperties()
+{
+ QVERIFY(m_proxy);
+
+ QCOMPARE(m_proxy->columnCount(), 0);
+ QCOMPARE(m_proxy->rowCount(), 0);
+ QVERIFY(!m_proxy->series());
+
+ QCOMPARE(m_proxy->type(), QAbstractDataProxy::DataTypeSurface);
+}
+
+void tst_proxy::initializeProperties()
+{
+ QVERIFY(m_proxy);
+
+ QSurfaceDataArray *data = new QSurfaceDataArray;
+ QSurfaceDataRow *dataRow1 = new QSurfaceDataRow;
+ QSurfaceDataRow *dataRow2 = new QSurfaceDataRow;
+ *dataRow1 << QVector3D(0.0f, 0.1f, 0.5f) << QVector3D(1.0f, 0.5f, 0.5f);
+ *dataRow2 << QVector3D(0.0f, 1.8f, 1.0f) << QVector3D(1.0f, 1.2f, 1.0f);
+ *data << dataRow1 << dataRow2;
+
+ m_proxy->resetArray(data);
+
+ QCOMPARE(m_proxy->columnCount(), 2);
+ QCOMPARE(m_proxy->rowCount(), 2);
+}
+
+QTEST_MAIN(tst_proxy)
+#include "tst_proxy.moc"
diff --git a/tests/auto/cpptest/q3dsurface-series/q3dsurface-series.pro b/tests/auto/cpptest/q3dsurface-series/q3dsurface-series.pro
new file mode 100644
index 00000000..481653ef
--- /dev/null
+++ b/tests/auto/cpptest/q3dsurface-series/q3dsurface-series.pro
@@ -0,0 +1,8 @@
+QT += testlib datavisualization
+
+TARGET = tst_cpptest
+CONFIG += console testcase
+
+TEMPLATE = app
+
+SOURCES += tst_series.cpp
diff --git a/tests/auto/cpptest/q3dsurface-series/tst_series.cpp b/tests/auto/cpptest/q3dsurface-series/tst_series.cpp
new file mode 100644
index 00000000..50eed686
--- /dev/null
+++ b/tests/auto/cpptest/q3dsurface-series/tst_series.cpp
@@ -0,0 +1,120 @@
+/****************************************************************************
+**
+** 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/QSurface3DSeries>
+
+using namespace QtDataVisualization;
+
+class tst_series: public QObject
+{
+ Q_OBJECT
+
+private slots:
+ void initTestCase();
+ void cleanupTestCase();
+ void init();
+ void cleanup();
+
+ void construct();
+
+ void initialProperties();
+ void initializeProperties();
+ void invalidProperties();
+
+private:
+ QSurface3DSeries *m_series;
+};
+
+void tst_series::initTestCase()
+{
+}
+
+void tst_series::cleanupTestCase()
+{
+}
+
+void tst_series::init()
+{
+ m_series = new QSurface3DSeries();
+}
+
+void tst_series::cleanup()
+{
+ delete m_series;
+}
+
+void tst_series::construct()
+{
+ QSurface3DSeries *series = new QSurface3DSeries();
+ QVERIFY(series);
+ delete series;
+
+ QSurfaceDataProxy *proxy = new QSurfaceDataProxy();
+
+ series = new QSurface3DSeries(proxy);
+ QVERIFY(series);
+ QCOMPARE(series->dataProxy(), proxy);
+ delete series;
+}
+
+void tst_series::initialProperties()
+{
+ QVERIFY(m_series);
+
+ QVERIFY(m_series->dataProxy());
+ QCOMPARE(m_series->drawMode(), QSurface3DSeries::DrawSurfaceAndWireframe);
+ QCOMPARE(m_series->isFlatShadingEnabled(), true);
+ QCOMPARE(m_series->isFlatShadingSupported(), true);
+ QCOMPARE(m_series->selectedPoint(), m_series->invalidSelectionPosition());
+
+ // Common properties. The ones identical between different series are tested in QBar3DSeries tests
+ QCOMPARE(m_series->itemLabelFormat(), QString("@xLabel, @yLabel, @zLabel"));
+ QCOMPARE(m_series->mesh(), QAbstract3DSeries::MeshSphere);
+ QCOMPARE(m_series->type(), QAbstract3DSeries::SeriesTypeSurface);
+}
+
+void tst_series::initializeProperties()
+{
+ QVERIFY(m_series);
+
+ m_series->setDataProxy(new QSurfaceDataProxy());
+ m_series->setDrawMode(QSurface3DSeries::DrawWireframe);
+ m_series->setFlatShadingEnabled(false);
+ m_series->setSelectedPoint(QPoint(0, 0));
+
+ QCOMPARE(m_series->drawMode(), QSurface3DSeries::DrawWireframe);
+ QCOMPARE(m_series->isFlatShadingEnabled(), false);
+ QCOMPARE(m_series->selectedPoint(), QPoint(0, 0));
+
+ // Common properties. The ones identical between different series are tested in QBar3DSeries tests
+ m_series->setMesh(QAbstract3DSeries::MeshPyramid);
+
+ QCOMPARE(m_series->mesh(), QAbstract3DSeries::MeshPyramid);
+}
+
+void tst_series::invalidProperties()
+{
+ m_series->setMesh(QAbstract3DSeries::MeshPoint);
+
+ QCOMPARE(m_series->mesh(), QAbstract3DSeries::MeshSphere);
+}
+
+QTEST_MAIN(tst_series)
+#include "tst_series.moc"
diff --git a/tests/auto/cpptest/q3dsurface/q3dsurface.pro b/tests/auto/cpptest/q3dsurface/q3dsurface.pro
new file mode 100644
index 00000000..b7a6bf08
--- /dev/null
+++ b/tests/auto/cpptest/q3dsurface/q3dsurface.pro
@@ -0,0 +1,8 @@
+QT += testlib datavisualization
+
+TARGET = tst_cpptest
+CONFIG += console testcase
+
+TEMPLATE = app
+
+SOURCES += tst_surface.cpp
diff --git a/tests/auto/cpptest/q3dsurface/tst_surface.cpp b/tests/auto/cpptest/q3dsurface/tst_surface.cpp
new file mode 100644
index 00000000..0ae0a326
--- /dev/null
+++ b/tests/auto/cpptest/q3dsurface/tst_surface.cpp
@@ -0,0 +1,247 @@
+/****************************************************************************
+**
+** 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/Q3DSurface>
+
+using namespace QtDataVisualization;
+
+class tst_surface: public QObject
+{
+ Q_OBJECT
+
+private slots:
+ void initTestCase();
+ void cleanupTestCase();
+ void init();
+ void cleanup();
+
+ void construct();
+
+ void initialProperties();
+ void initializeProperties();
+ void invalidProperties();
+
+ void addSeries();
+ void addMultipleSeries();
+ void selectSeries();
+ void removeSeries();
+ void removeMultipleSeries();
+
+private:
+ Q3DSurface *m_graph;
+};
+
+QSurface3DSeries *newSeries()
+{
+ QSurface3DSeries *series = new QSurface3DSeries;
+ QSurfaceDataArray *data = new QSurfaceDataArray;
+ QSurfaceDataRow *dataRow1 = new QSurfaceDataRow;
+ QSurfaceDataRow *dataRow2 = new QSurfaceDataRow;
+ *dataRow1 << QVector3D(0.0f, 0.1f, 0.5f) << QVector3D(1.0f, 0.5f, 0.5f);
+ *dataRow2 << QVector3D(0.0f, 1.8f, 1.0f) << QVector3D(1.0f, 1.2f, 1.0f);
+ *data << dataRow1 << dataRow2;
+ series->dataProxy()->resetArray(data);
+
+ return series;
+}
+
+void tst_surface::initTestCase()
+{
+}
+
+void tst_surface::cleanupTestCase()
+{
+}
+
+void tst_surface::init()
+{
+ m_graph = new Q3DSurface();
+}
+
+void tst_surface::cleanup()
+{
+ delete m_graph;
+}
+
+void tst_surface::construct()
+{
+ Q3DSurface *graph = new Q3DSurface();
+ QVERIFY(graph);
+ delete graph;
+
+ graph = new Q3DSurface(new QSurfaceFormat());
+ QVERIFY(graph);
+ delete graph;
+}
+
+void tst_surface::initialProperties()
+{
+ QVERIFY(m_graph);
+ QCOMPARE(m_graph->seriesList().length(), 0);
+ QVERIFY(!m_graph->selectedSeries());
+ QCOMPARE(m_graph->flipHorizontalGrid(), false);
+ QCOMPARE(m_graph->axisX()->orientation(), QAbstract3DAxis::AxisOrientationX);
+ QCOMPARE(m_graph->axisY()->orientation(), QAbstract3DAxis::AxisOrientationY);
+ QCOMPARE(m_graph->axisZ()->orientation(), QAbstract3DAxis::AxisOrientationZ);
+
+ // Common properties
+ QCOMPARE(m_graph->activeTheme()->type(), Q3DTheme::ThemeQt);
+ QCOMPARE(m_graph->selectionMode(), QAbstract3DGraph::SelectionItem);
+ QCOMPARE(m_graph->shadowQuality(), QAbstract3DGraph::ShadowQualityMedium);
+ QVERIFY(m_graph->scene());
+ QCOMPARE(m_graph->measureFps(), false);
+ QCOMPARE(m_graph->isOrthoProjection(), false);
+ QCOMPARE(m_graph->selectedElement(), QAbstract3DGraph::ElementNone);
+ QCOMPARE(m_graph->aspectRatio(), 2.0);
+ QCOMPARE(m_graph->optimizationHints(), QAbstract3DGraph::OptimizationDefault);
+ QCOMPARE(m_graph->isPolar(), false);
+ QCOMPARE(m_graph->radialLabelOffset(), 1.0);
+ QCOMPARE(m_graph->horizontalAspectRatio(), 0.0);
+ QCOMPARE(m_graph->isReflection(), false);
+ QCOMPARE(m_graph->reflectivity(), 0.5);
+ QCOMPARE(m_graph->locale(), QLocale("C"));
+ QCOMPARE(m_graph->queriedGraphPosition(), QVector3D(0, 0, 0));
+ QCOMPARE(m_graph->margin(), -1.0);
+}
+
+void tst_surface::initializeProperties()
+{
+ m_graph->setFlipHorizontalGrid(true);
+
+ QCOMPARE(m_graph->flipHorizontalGrid(), true);
+
+ Q3DTheme *theme = new Q3DTheme(Q3DTheme::ThemeDigia);
+ m_graph->setActiveTheme(theme);
+ m_graph->setSelectionMode(QAbstract3DGraph::SelectionItem | QAbstract3DGraph::SelectionRow | QAbstract3DGraph::SelectionSlice);
+ m_graph->setShadowQuality(QAbstract3DGraph::ShadowQualitySoftHigh);
+ QCOMPARE(m_graph->shadowQuality(), QAbstract3DGraph::ShadowQualitySoftHigh);
+ m_graph->setMeasureFps(true);
+ m_graph->setOrthoProjection(true);
+ m_graph->setAspectRatio(1.0);
+ m_graph->setOptimizationHints(QAbstract3DGraph::OptimizationStatic);
+ m_graph->setPolar(true);
+ m_graph->setRadialLabelOffset(0.1f);
+ m_graph->setHorizontalAspectRatio(1.0);
+ m_graph->setReflection(true);
+ m_graph->setReflectivity(0.1);
+ m_graph->setLocale(QLocale("FI"));
+ m_graph->setMargin(1.0);
+
+ QCOMPARE(m_graph->activeTheme()->type(), Q3DTheme::ThemeDigia);
+ QCOMPARE(m_graph->selectionMode(), QAbstract3DGraph::SelectionItem | QAbstract3DGraph::SelectionRow | QAbstract3DGraph::SelectionSlice);
+ QCOMPARE(m_graph->shadowQuality(), QAbstract3DGraph::ShadowQualityNone); // Ortho disables shadows
+ QCOMPARE(m_graph->measureFps(), true);
+ QCOMPARE(m_graph->isOrthoProjection(), true);
+ QCOMPARE(m_graph->aspectRatio(), 1.0);
+ QCOMPARE(m_graph->optimizationHints(), QAbstract3DGraph::OptimizationStatic);
+ QCOMPARE(m_graph->isPolar(), true);
+ QCOMPARE(m_graph->radialLabelOffset(), 0.1f);
+ QCOMPARE(m_graph->horizontalAspectRatio(), 1.0);
+ QCOMPARE(m_graph->isReflection(), true);
+ QCOMPARE(m_graph->reflectivity(), 0.1);
+ QCOMPARE(m_graph->locale(), QLocale("FI"));
+ QCOMPARE(m_graph->margin(), 1.0);
+}
+
+void tst_surface::invalidProperties()
+{
+ m_graph->setSelectionMode(QAbstract3DGraph::SelectionColumn | QAbstract3DGraph::SelectionRow | QAbstract3DGraph::SelectionSlice);
+ m_graph->setAspectRatio(-1.0);
+ m_graph->setHorizontalAspectRatio(-1.0);
+ m_graph->setReflectivity(-1.0);
+ m_graph->setLocale(QLocale("XX"));
+
+ QCOMPARE(m_graph->selectionMode(), QAbstract3DGraph::SelectionItem);
+ QCOMPARE(m_graph->aspectRatio(), -1.0/*2.0*/); // TODO: Fix once QTRD-3367 is done
+ QCOMPARE(m_graph->horizontalAspectRatio(), -1.0/*0.0*/); // TODO: Fix once QTRD-3367 is done
+ QCOMPARE(m_graph->reflectivity(), -1.0/*0.5*/); // TODO: Fix once QTRD-3367 is done
+ QCOMPARE(m_graph->locale(), QLocale("C"));
+}
+
+void tst_surface::addSeries()
+{
+ m_graph->addSeries(newSeries());
+
+ QCOMPARE(m_graph->seriesList().length(), 1);
+ QVERIFY(!m_graph->selectedSeries());
+}
+
+void tst_surface::addMultipleSeries()
+{
+ QSurface3DSeries *series = newSeries();
+ QSurface3DSeries *series2 = newSeries();
+ QSurface3DSeries *series3 = newSeries();
+
+ m_graph->addSeries(series);
+ m_graph->addSeries(series2);
+ m_graph->addSeries(series3);
+
+ QCOMPARE(m_graph->seriesList().length(), 3);
+}
+
+void tst_surface::selectSeries()
+{
+ QSurface3DSeries *series = newSeries();
+
+ m_graph->addSeries(series);
+ m_graph->seriesList()[0]->setSelectedPoint(QPoint(0, 0));
+
+ QCOMPARE(m_graph->seriesList().length(), 1);
+ QCOMPARE(m_graph->selectedSeries(), series);
+
+ m_graph->clearSelection();
+ QVERIFY(!m_graph->selectedSeries());
+}
+
+void tst_surface::removeSeries()
+{
+ QSurface3DSeries *series = newSeries();
+
+ m_graph->addSeries(series);
+ m_graph->removeSeries(series);
+ QCOMPARE(m_graph->seriesList().length(), 0);
+}
+
+void tst_surface::removeMultipleSeries()
+{
+ QSurface3DSeries *series = newSeries();
+ QSurface3DSeries *series2 = newSeries();
+ QSurface3DSeries *series3 = newSeries();
+
+ m_graph->addSeries(series);
+ m_graph->addSeries(series2);
+ m_graph->addSeries(series3);
+
+ m_graph->seriesList()[0]->setSelectedPoint(QPoint(0, 0));
+ QCOMPARE(m_graph->selectedSeries(), series);
+
+ m_graph->removeSeries(series);
+ QCOMPARE(m_graph->seriesList().length(), 2);
+ QVERIFY(!m_graph->selectedSeries());
+
+ m_graph->removeSeries(series2);
+ QCOMPARE(m_graph->seriesList().length(), 1);
+
+ m_graph->removeSeries(series3);
+ QCOMPARE(m_graph->seriesList().length(), 0);
+}
+
+QTEST_MAIN(tst_surface)
+#include "tst_surface.moc"
diff --git a/tests/auto/cpptest/q3dtheme/q3dtheme.pro b/tests/auto/cpptest/q3dtheme/q3dtheme.pro
new file mode 100644
index 00000000..30a4802c
--- /dev/null
+++ b/tests/auto/cpptest/q3dtheme/q3dtheme.pro
@@ -0,0 +1,8 @@
+QT += testlib datavisualization
+
+TARGET = tst_cpptest
+CONFIG += console testcase
+
+TEMPLATE = app
+
+SOURCES += tst_theme.cpp
diff --git a/tests/auto/cpptest/q3dtheme/tst_theme.cpp b/tests/auto/cpptest/q3dtheme/tst_theme.cpp
new file mode 100644
index 00000000..35945aef
--- /dev/null
+++ b/tests/auto/cpptest/q3dtheme/tst_theme.cpp
@@ -0,0 +1,216 @@
+/****************************************************************************
+**
+** 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/Q3DTheme>
+
+using namespace QtDataVisualization;
+
+class tst_theme: public QObject
+{
+ Q_OBJECT
+
+private slots:
+ void initTestCase();
+ void cleanupTestCase();
+ void init();
+ void cleanup();
+
+ void construct();
+
+ void initialProperties();
+ void initializeProperties();
+ void invalidProperties();
+
+private:
+ Q3DTheme *m_theme;
+};
+
+void tst_theme::initTestCase()
+{
+}
+
+void tst_theme::cleanupTestCase()
+{
+}
+
+void tst_theme::init()
+{
+ m_theme = new Q3DTheme();
+}
+
+void tst_theme::cleanup()
+{
+ delete m_theme;
+}
+
+void tst_theme::construct()
+{
+ Q3DTheme *theme = new Q3DTheme();
+ QVERIFY(theme);
+ delete theme;
+
+ theme = new Q3DTheme(Q3DTheme::ThemeEbony);
+ QVERIFY(theme);
+ QCOMPARE(theme->ambientLightStrength(), 0.5f);
+ QCOMPARE(theme->backgroundColor(), QColor(Qt::black));
+ QCOMPARE(theme->isBackgroundEnabled(), true);
+ QCOMPARE(theme->baseColors().length(), 5);
+ QCOMPARE(theme->baseColors().at(0), QColor(Qt::white));
+ QCOMPARE(theme->baseColors().at(4), QColor(QRgb(0x6b6b6b)));
+ QCOMPARE(theme->baseGradients().length(), 5);
+ QCOMPARE(theme->baseGradients().at(0).stops().at(1).second, QColor(Qt::white));
+ QCOMPARE(theme->baseGradients().at(4).stops().at(1).second, QColor(QRgb(0x6b6b6b)));
+ QCOMPARE(theme->colorStyle(), Q3DTheme::ColorStyleUniform);
+ QCOMPARE(theme->font(), QFont("Arial"));
+ QCOMPARE(theme->isGridEnabled(), true);
+ QCOMPARE(theme->gridLineColor(), QColor(QRgb(0x35322f)));
+ QCOMPARE(theme->highlightLightStrength(), 5.0f);
+ QCOMPARE(theme->labelBackgroundColor(), QColor(0x00, 0x00, 0x00, 0xcd));
+ QCOMPARE(theme->isLabelBackgroundEnabled(), true);
+ QCOMPARE(theme->isLabelBorderEnabled(), false);
+ QCOMPARE(theme->labelTextColor(), QColor(QRgb(0xaeadac)));
+ QCOMPARE(theme->lightColor(), QColor(Qt::white));
+ QCOMPARE(theme->lightStrength(), 5.0f);
+ QCOMPARE(theme->multiHighlightColor(), QColor(QRgb(0xd72222)));
+ QCOMPARE(theme->multiHighlightGradient().stops().at(1).second, QColor(QRgb(0xd72222)));
+ QCOMPARE(theme->singleHighlightColor(), QColor(QRgb(0xf5dc0d)));
+ QCOMPARE(theme->singleHighlightGradient().stops().at(1).second, QColor(QRgb(0xf5dc0d)));
+ QCOMPARE(theme->type(), Q3DTheme::ThemeEbony);
+ QCOMPARE(theme->windowColor(), QColor(Qt::black));
+ delete theme;
+}
+
+void tst_theme::initialProperties()
+{
+ QVERIFY(m_theme);
+
+ QCOMPARE(m_theme->ambientLightStrength(), 0.25f);
+ QCOMPARE(m_theme->backgroundColor(), QColor(Qt::black));
+ QCOMPARE(m_theme->isBackgroundEnabled(), true);
+ QCOMPARE(m_theme->baseColors().length(), 1);
+ QCOMPARE(m_theme->baseColors().at(0), QColor(Qt::black));
+ QCOMPARE(m_theme->baseGradients().length(), 1);
+ QCOMPARE(m_theme->baseGradients().at(0).stops().at(0).second, QColor(Qt::black));
+ QCOMPARE(m_theme->baseGradients().at(0).stops().at(1).second, QColor(Qt::white));
+ QCOMPARE(m_theme->colorStyle(), Q3DTheme::ColorStyleUniform);
+ QCOMPARE(m_theme->font(), QFont());
+ QCOMPARE(m_theme->isGridEnabled(), true);
+ QCOMPARE(m_theme->gridLineColor(), QColor(Qt::white));
+ QCOMPARE(m_theme->highlightLightStrength(), 7.5f);
+ QCOMPARE(m_theme->labelBackgroundColor(), QColor(Qt::gray));
+ QCOMPARE(m_theme->isLabelBackgroundEnabled(), true);
+ QCOMPARE(m_theme->isLabelBorderEnabled(), true);
+ QCOMPARE(m_theme->labelTextColor(), QColor(Qt::white));
+ QCOMPARE(m_theme->lightColor(), QColor(Qt::white));
+ QCOMPARE(m_theme->lightStrength(), 5.0f);
+ QCOMPARE(m_theme->multiHighlightColor(), QColor(Qt::blue));
+ QCOMPARE(m_theme->multiHighlightGradient().stops(), QLinearGradient().stops());
+ QCOMPARE(m_theme->singleHighlightColor(), QColor(Qt::red));
+ QCOMPARE(m_theme->singleHighlightGradient().stops(), QLinearGradient().stops());
+ QCOMPARE(m_theme->type(), Q3DTheme::ThemeUserDefined);
+ QCOMPARE(m_theme->windowColor(), QColor(Qt::black));
+}
+
+void tst_theme::initializeProperties()
+{
+ QVERIFY(m_theme);
+
+ QLinearGradient gradient1;
+ QLinearGradient gradient2;
+ QLinearGradient gradient3;
+ QLinearGradient gradient4;
+
+ QList<QColor> basecolors;
+ basecolors << QColor(Qt::red) << QColor(Qt::blue);
+
+ QList<QLinearGradient> basegradients;
+ basegradients << gradient1 << gradient2;
+
+ m_theme->setType(Q3DTheme::ThemeQt); // We'll override default values with the following setters
+ m_theme->setAmbientLightStrength(0.3f);
+ m_theme->setBackgroundColor(QColor(Qt::red));
+ m_theme->setBackgroundEnabled(false);
+ m_theme->setBaseColors(basecolors);
+ m_theme->setBaseGradients(basegradients);
+ m_theme->setColorStyle(Q3DTheme::ColorStyleRangeGradient);
+ m_theme->setFont(QFont("Arial"));
+ m_theme->setGridEnabled(false);
+ m_theme->setGridLineColor(QColor(Qt::green));
+ m_theme->setHighlightLightStrength(5.0f);
+ m_theme->setLabelBackgroundColor(QColor(Qt::gray));
+ m_theme->setLabelBackgroundEnabled(false);
+ m_theme->setLabelBorderEnabled(false);
+ m_theme->setLabelTextColor(QColor(Qt::cyan));
+ m_theme->setLightColor(QColor(Qt::yellow));
+ m_theme->setLightStrength(2.5f);
+ m_theme->setMultiHighlightColor(QColor(Qt::darkBlue));
+ m_theme->setMultiHighlightGradient(gradient3);
+ m_theme->setSingleHighlightColor(QColor(Qt::darkRed));
+ m_theme->setSingleHighlightGradient(gradient4);
+ m_theme->setWindowColor(QColor(Qt::darkYellow));
+
+ QCOMPARE(m_theme->ambientLightStrength(), 0.3f);
+ QCOMPARE(m_theme->backgroundColor(), QColor(Qt::red));
+ QCOMPARE(m_theme->isBackgroundEnabled(), false);
+ QCOMPARE(m_theme->baseColors().length(), 2);
+ QCOMPARE(m_theme->baseColors().at(0), QColor(Qt::red));
+ QCOMPARE(m_theme->baseColors().at(1), QColor(Qt::blue));
+ QCOMPARE(m_theme->baseGradients().length(), 2);
+ QCOMPARE(m_theme->baseGradients().at(0), gradient1);
+ QCOMPARE(m_theme->baseGradients().at(0), gradient2);
+ QCOMPARE(m_theme->colorStyle(), Q3DTheme::ColorStyleRangeGradient);
+ QCOMPARE(m_theme->font(), QFont("Arial"));
+ QCOMPARE(m_theme->isGridEnabled(), false);
+ QCOMPARE(m_theme->gridLineColor(), QColor(Qt::green));
+ QCOMPARE(m_theme->highlightLightStrength(), 5.0f);
+ QCOMPARE(m_theme->labelBackgroundColor(), QColor(Qt::gray));
+ QCOMPARE(m_theme->isLabelBackgroundEnabled(), false);
+ QCOMPARE(m_theme->isLabelBorderEnabled(), false);
+ QCOMPARE(m_theme->labelTextColor(), QColor(Qt::cyan));
+ QCOMPARE(m_theme->lightColor(), QColor(Qt::yellow));
+ QCOMPARE(m_theme->lightStrength(), 2.5f);
+ QCOMPARE(m_theme->multiHighlightColor(), QColor(Qt::darkBlue));
+ QCOMPARE(m_theme->multiHighlightGradient(), gradient3);
+ QCOMPARE(m_theme->singleHighlightColor(), QColor(Qt::darkRed));
+ QCOMPARE(m_theme->singleHighlightGradient(), gradient4);
+ QCOMPARE(m_theme->type(), Q3DTheme::ThemeQt);
+ QCOMPARE(m_theme->windowColor(), QColor(Qt::darkYellow));
+}
+
+void tst_theme::invalidProperties()
+{
+ m_theme->setAmbientLightStrength(-1.0f);
+ QCOMPARE(m_theme->ambientLightStrength(), 0.25f);
+ m_theme->setAmbientLightStrength(1.1f);
+ QCOMPARE(m_theme->ambientLightStrength(), 0.25f);
+
+ m_theme->setHighlightLightStrength(-1.0f);
+ QCOMPARE(m_theme->highlightLightStrength(), 7.5f);
+ m_theme->setHighlightLightStrength(10.1f);
+ QCOMPARE(m_theme->highlightLightStrength(), 7.5f);
+
+ m_theme->setLightStrength(-1.0f);
+ QCOMPARE(m_theme->lightStrength(), 5.0f);
+ m_theme->setLightStrength(10.1f);
+ QCOMPARE(m_theme->lightStrength(), 5.0f);
+}
+
+QTEST_MAIN(tst_theme)
+#include "tst_theme.moc"