diff options
Diffstat (limited to 'tests/auto')
86 files changed, 8658 insertions, 0 deletions
diff --git a/tests/auto/auto.pro b/tests/auto/auto.pro new file mode 100644 index 00000000..df2943a4 --- /dev/null +++ b/tests/auto/auto.pro @@ -0,0 +1,7 @@ +TEMPLATE = subdirs + +SUBDIRS += cpptest + +qtHaveModule(quick): SUBDIRS += qmltest + +installed_cmake.depends = cmake 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 Binary files differnew file mode 100644 index 00000000..2580f5bd --- /dev/null +++ b/tests/auto/cpptest/q3dsurface-heightproxy/customtexture.jpg 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" diff --git a/tests/auto/qmltest/axis3d/tst_category.qml b/tests/auto/qmltest/axis3d/tst_category.qml new file mode 100644 index 00000000..318fa011 --- /dev/null +++ b/tests/auto/qmltest/axis3d/tst_category.qml @@ -0,0 +1,135 @@ +/**************************************************************************** +** +** 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 +** +****************************************************************************/ + +import QtQuick 2.0 +import QtDataVisualization 1.2 +import QtTest 1.0 + +Item { + id: top + height: 150 + width: 150 + + CategoryAxis3D { + id: initial + } + + CategoryAxis3D { + id: initialized + labels: ["first", "second"] + + autoAdjustRange: false + labelAutoRotation: 10.0 + max: 20 + min: 10 + title: "initialized" + titleFixed: false + titleVisible: true + } + + CategoryAxis3D { + id: change + } + + CategoryAxis3D { + id: invalid + } + + TestCase { + name: "CategoryAxis3D Initial" + + function test_initial() { + compare(initial.labels.length, 0) + + compare(initial.autoAdjustRange, true) + compare(initial.labelAutoRotation, 0.0) + compare(initial.max, 10) + compare(initial.min, 0) + compare(initial.orientation, AbstractAxis3D.AxisOrientationNone) + compare(initial.title, "") + compare(initial.titleFixed, true) + compare(initial.titleVisible, false) + compare(initial.type, AbstractAxis3D.AxisTypeCategory) + } + } + + TestCase { + name: "CategoryAxis3D Initialized" + + function test_initialized() { + compare(initialized.labels.length, 2) + compare(initialized.labels[0], "first") + compare(initialized.labels[1], "second") + + compare(initialized.autoAdjustRange, false) + compare(initialized.labelAutoRotation, 10.0) + compare(initialized.max, 20) + compare(initialized.min, 10) + compare(initialized.title, "initialized") + compare(initialized.titleFixed, false) + compare(initialized.titleVisible, true) + } + } + + TestCase { + name: "CategoryAxis3D Change" + + function test_change() { + change.labels = ["first"] + compare(change.labels.length, 1) + compare(change.labels[0], "first") + change.labels = ["first", "second"] + compare(change.labels.length, 2) + compare(change.labels[0], "first") + compare(change.labels[1], "second") + change.labels[1] = "another" + compare(change.labels[1], "another") + + change.autoAdjustRange = false + change.labelAutoRotation = 10.0 + change.max = 20 + change.min = 10 + change.title = "initialized" + change.titleFixed = false + change.titleVisible = true + + compare(change.autoAdjustRange, false) + compare(change.labelAutoRotation, 10.0) + compare(change.max, 20) + compare(change.min, 10) + compare(change.title, "initialized") + compare(change.titleFixed, false) + compare(change.titleVisible, true) + } + } + + TestCase { + name: "CategoryAxis3D Invalid" + + function test_invalid() { + invalid.labelAutoRotation = -10 + compare(invalid.labelAutoRotation, 0.0) + invalid.labelAutoRotation = 100 + compare(invalid.labelAutoRotation, 90.0) + invalid.max = -10 + compare(invalid.min, 0) + invalid.min = 10 + compare(invalid.max, 11) + } + } +} diff --git a/tests/auto/qmltest/axis3d/tst_logvalue.qml b/tests/auto/qmltest/axis3d/tst_logvalue.qml new file mode 100644 index 00000000..89228ad1 --- /dev/null +++ b/tests/auto/qmltest/axis3d/tst_logvalue.qml @@ -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 +** +****************************************************************************/ + +import QtQuick 2.0 +import QtDataVisualization 1.2 +import QtTest 1.0 + +Item { + id: top + height: 150 + width: 150 + + LogValueAxis3DFormatter { + id: initial + } + + LogValueAxis3DFormatter { + id: initialized + autoSubGrid: false + base: 0.1 + showEdgeLabels: false + } + + LogValueAxis3DFormatter { + id: change + } + + LogValueAxis3DFormatter { + id: invalid + } + + TestCase { + name: "LogValueAxis3DFormatter Initial" + + function test_initial() { + compare(initial.autoSubGrid, true) + compare(initial.base, 10) + compare(initial.showEdgeLabels, true) + } + } + + TestCase { + name: "LogValueAxis3DFormatter Initialized" + + function test_initialized() { + compare(initialized.autoSubGrid, false) + compare(initialized.base, 0.1) + compare(initialized.showEdgeLabels, false) + } + } + + TestCase { + name: "LogValueAxis3DFormatter Change" + + function test_change() { + change.autoSubGrid = false + change.base = 0.1 + change.showEdgeLabels = false + + compare(change.autoSubGrid, false) + compare(change.base, 0.1) + compare(change.showEdgeLabels, false) + } + } + + TestCase { + name: "LogValueAxis3DFormatter Invalid" + + function test_invalid() { + invalid.base = 1 + compare(invalid.base, 10) + invalid.base = -1 + compare(invalid.base, 10) + } + } +} diff --git a/tests/auto/qmltest/axis3d/tst_value.qml b/tests/auto/qmltest/axis3d/tst_value.qml new file mode 100644 index 00000000..54189c8b --- /dev/null +++ b/tests/auto/qmltest/axis3d/tst_value.qml @@ -0,0 +1,154 @@ +/**************************************************************************** +** +** 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 +** +****************************************************************************/ + +import QtQuick 2.0 +import QtDataVisualization 1.2 +import QtTest 1.0 + +Item { + id: top + height: 150 + width: 150 + + ValueAxis3D { + id: initial + } + + ValueAxis3D { + id: initialized + formatter: ValueAxis3DFormatter { objectName: "formatter1" } + labelFormat: "%f" + reversed: true + segmentCount: 10 + subSegmentCount: 5 + + autoAdjustRange: false + labelAutoRotation: 10.0 + max: 20 + min: -10 + title: "initialized" + titleFixed: false + titleVisible: true + } + + ValueAxis3D { + id: change + } + + ValueAxis3D { + id: invalid + } + + TestCase { + name: "ValueAxis3D Initial" + + function test_initial() { + verify(initial.formatter) + compare(initial.labelFormat, "%.2f") + compare(initial.reversed, false) + compare(initial.segmentCount, 5) + compare(initial.subSegmentCount, 1) + + compare(initial.autoAdjustRange, true) + compare(initial.labelAutoRotation, 0.0) + compare(initial.max, 10) + compare(initial.min, 0) + compare(initial.orientation, AbstractAxis3D.AxisOrientationNone) + compare(initial.title, "") + compare(initial.titleFixed, true) + compare(initial.titleVisible, false) + compare(initial.type, AbstractAxis3D.AxisTypeValue) + } + } + + TestCase { + name: "ValueAxis3D Initialized" + + function test_initialized() { + compare(initialized.formatter.objectName, "formatter1") + compare(initialized.labelFormat, "%f") + compare(initialized.reversed, true) + compare(initialized.segmentCount, 10) + compare(initialized.subSegmentCount, 5) + + compare(initialized.autoAdjustRange, false) + compare(initialized.labelAutoRotation, 10.0) + compare(initialized.max, 20) + compare(initialized.min, -10) + compare(initialized.title, "initialized") + compare(initialized.titleFixed, false) + compare(initialized.titleVisible, true) + } + } + + TestCase { + name: "ValueAxis3D Change" + + ValueAxis3DFormatter { id: formatter1 } + + function test_change() { + change.formatter = formatter1 + change.labelFormat = "%f" + change.reversed = true + change.segmentCount = 10 + change.subSegmentCount = 5 + + compare(change.formatter, formatter1) + compare(change.labelFormat, "%f") + compare(change.reversed, true) + compare(change.segmentCount, 10) + compare(change.subSegmentCount, 5) + + change.autoAdjustRange = false + change.labelAutoRotation = 10.0 + change.max = 20 + change.min = -10 + change.title = "initialized" + change.titleFixed = false + change.titleVisible = true + + compare(change.autoAdjustRange, false) + compare(change.labelAutoRotation, 10.0) + compare(change.max, 20) + compare(change.min, -10) + compare(change.title, "initialized") + compare(change.titleFixed, false) + compare(change.titleVisible, true) + } + } + + TestCase { + name: "ValueAxis3D Invalid" + + function test_invalid() { + invalid.segmentCount = -1 + compare(invalid.segmentCount, 1) + invalid.subSegmentCount = -1 + compare(invalid.subSegmentCount, 1) + + invalid.labelAutoRotation = -10 + compare(invalid.labelAutoRotation, 0.0) + invalid.labelAutoRotation = 100 + compare(invalid.labelAutoRotation, 90.0) + invalid.max = -10 + compare(invalid.min, -11) + invalid.min = 10 + compare(invalid.max, 11) + } + } +} diff --git a/tests/auto/qmltest/bars3d/tst_bars.qml b/tests/auto/qmltest/bars3d/tst_bars.qml new file mode 100644 index 00000000..a64aaf1a --- /dev/null +++ b/tests/auto/qmltest/bars3d/tst_bars.qml @@ -0,0 +1,147 @@ +/**************************************************************************** +** +** 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 +** +****************************************************************************/ + +import QtQuick 2.0 +import QtDataVisualization 1.2 +import QtTest 1.0 + +Item { + id: top + height: 150 + width: 150 + + Bars3D { + id: series + anchors.fill: parent + } + + TestCase { + name: "Bars3D Series" + + Bar3DSeries { id: series1 } + Bar3DSeries { id: series2 } + + function test_1_add_series() { + series.seriesList = [series1, series2] + compare(series.seriesList.length, 2) + } + + function test_2_remove_series() { + series.seriesList = [series1] + compare(series.seriesList.length, 1) + } + + function test_3_remove_series() { + series.seriesList = [] + compare(series.seriesList.length, 0) + } + + function test_4_primary_series() { + series.seriesList = [series1, series2] + compare(series.primarySeries, series1) + series.primarySeries = series2 + compare(series.primarySeries, series2) + } + + function test_5_selected_series() { + series.seriesList[0].selectedBar = Qt.point(0, 0) + compare(series.selectedSeries, series1) + } + } + + // The following tests are not required for scatter or surface, as they are handled identically + Bars3D { + id: theme + anchors.fill: parent + } + + Bars3D { + id: input + anchors.fill: parent + } + + Custom3DItem { id: item1; meshFile: ":/customitem.obj" } + Custom3DItem { id: item2; meshFile: ":/customitem.obj" } + Custom3DItem { id: item3; meshFile: ":/customitem.obj" } + Custom3DItem { id: item4; meshFile: ":/customitem.obj"; position: Qt.vector3d(0.0, 1.0, 0.0) } + + Bars3D { + id: custom + anchors.fill: parent + customItemList: [item1, item2] + } + + TestCase { + name: "Bars3D Theme" + when: windowShown + + Theme3D { id: newTheme } + + function test_1_add_theme() { + theme.theme = newTheme + compare(theme.theme, newTheme) + } + + function test_2_change_theme() { + newTheme.type = Theme3D.ThemePrimaryColors + compare(theme.theme.type, Theme3D.ThemePrimaryColors) + } + } + + TestCase { + name: "Bars3D Input" + when: windowShown + + function test_1_remove_input() { + input.inputHandler = null + compare(input.inputHandler, null) + } + } + + TestCase { + name: "Bars3D Custom" + when: windowShown + + function test_1_custom_items() { + compare(custom.customItemList.length, 2) + } + + function test_2_add_custom_items() { + custom.addCustomItem(item3) + compare(custom.customItemList.length, 3) + custom.addCustomItem(item4) + compare(custom.customItemList.length, 4) + } + + function test_3_change_custom_items() { + item1.position = Qt.vector3d(1.0, 1.0, 1.0) + compare(custom.customItemList[0].position, Qt.vector3d(1.0, 1.0, 1.0)) + } + + function test_4_remove_custom_items() { + custom.removeCustomItemAt(Qt.vector3d(0.0, 1.0, 0.0)) + compare(custom.customItemList.length, 3) + custom.releaseCustomItem(item1) + compare(custom.customItemList[0], item2) + custom.releaseCustomItem(item2) + compare(custom.customItemList.length, 1) + custom.removeCustomItems() + compare(custom.customItemList.length, 0) + } + } +} diff --git a/tests/auto/qmltest/bars3d/tst_barseries.qml b/tests/auto/qmltest/bars3d/tst_barseries.qml new file mode 100644 index 00000000..7e303ab0 --- /dev/null +++ b/tests/auto/qmltest/bars3d/tst_barseries.qml @@ -0,0 +1,215 @@ +/**************************************************************************** +** +** 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 +** +****************************************************************************/ + +import QtQuick 2.0 +import QtDataVisualization 1.2 +import QtTest 1.0 + +Item { + id: top + height: 150 + width: 150 + + Bar3DSeries { + id: initial + } + + ColorGradient { + id: gradient1; + stops: [ + ColorGradientStop { color: "red"; position: 0 }, + ColorGradientStop { color: "blue"; position: 1 } + ] + } + + ColorGradient { + id: gradient2; + stops: [ + ColorGradientStop { color: "green"; position: 0 }, + ColorGradientStop { color: "red"; position: 1 } + ] + } + + ColorGradient { + id: gradient3; + stops: [ + ColorGradientStop { color: "gray"; position: 0 }, + ColorGradientStop { color: "darkgray"; position: 1 } + ] + } + + Bar3DSeries { + id: initialized + dataProxy: ItemModelBarDataProxy { + itemModel: ListModel { + ListElement{ year: "2012"; city: "Oulu"; expenses: "4200"; } + ListElement{ year: "2012"; city: "Rauma"; expenses: "2100"; } + } + rowRole: "city" + columnRole: "year" + valueRole: "expenses" + } + meshAngle: 15.0 + selectedBar: Qt.point(0, 0) + + baseColor: "blue" + baseGradient: gradient1 + colorStyle: Theme3D.ColorStyleObjectGradient + itemLabelFormat: "%f" + itemLabelVisible: false + mesh: Abstract3DSeries.MeshCone + meshSmooth: true + multiHighlightColor: "green" + multiHighlightGradient: gradient2 + name: "series1" + singleHighlightColor: "red" + singleHighlightGradient: gradient3 + userDefinedMesh: ":/customitem.obj" + visible: false + } + + ItemModelBarDataProxy { + id: proxy1 + itemModel: ListModel { + ListElement{ year: "2012"; city: "Oulu"; expenses: "4200"; } + ListElement{ year: "2012"; city: "Rauma"; expenses: "2100"; } + ListElement{ year: "2012"; city: "Helsinki"; expenses: "7040"; } + } + rowRole: "city" + columnRole: "year" + valueRole: "expenses" + } + + Bar3DSeries { + id: change + } + + TestCase { + name: "Bar3DSeries Initial" + + function test_1_initial() { + compare(initial.dataProxy.rowCount, 0) + compare(initial.invalidSelectionPosition, Qt.point(-1, -1)) + compare(initial.meshAngle, 0) + compare(initial.selectedBar, Qt.point(-1, -1)) + } + + function test_2_initial_common() { + // Common properties + compare(initial.baseColor, "#000000") + compare(initial.baseGradient, null) + compare(initial.colorStyle, Theme3D.ColorStyleUniform) + compare(initial.itemLabel, "") + compare(initial.itemLabelFormat, "@valueLabel") + compare(initial.itemLabelVisible, true) + compare(initial.mesh, Abstract3DSeries.MeshBevelBar) + compare(initial.meshRotation, Qt.quaternion(1, 0, 0, 0)) + compare(initial.meshSmooth, false) + compare(initial.multiHighlightColor, "#000000") + compare(initial.multiHighlightGradient, null) + compare(initial.name, "") + compare(initial.singleHighlightColor, "#000000") + compare(initial.singleHighlightGradient, null) + compare(initial.type, Abstract3DSeries.SeriesTypeBar) + compare(initial.userDefinedMesh, "") + compare(initial.visible, true) + } + } + + TestCase { + name: "Bar3DSeries Initialized" + + function test_1_initialized() { + compare(initialized.dataProxy.rowCount, 2) + fuzzyCompare(initialized.meshAngle, 15.0, 0.01) + compare(initialized.selectedBar, Qt.point(0, 0)) + } + + function test_2_initialized_common() { + // Common properties + compare(initialized.baseColor, "#0000ff") + compare(initialized.baseGradient, gradient1) + compare(initialized.colorStyle, Theme3D.ColorStyleObjectGradient) + compare(initialized.itemLabelFormat, "%f") + compare(initialized.itemLabelVisible, false) + compare(initialized.mesh, Abstract3DSeries.MeshCone) + compare(initialized.meshSmooth, true) + compare(initialized.multiHighlightColor, "#008000") + compare(initialized.multiHighlightGradient, gradient2) + compare(initialized.name, "series1") + compare(initialized.singleHighlightColor, "#ff0000") + compare(initialized.singleHighlightGradient, gradient3) + compare(initialized.userDefinedMesh, ":/customitem.obj") + compare(initialized.visible, false) + } + } + + TestCase { + name: "Bar3DSeries Change" + + function test_1_change() { + change.dataProxy = proxy1 + change.meshAngle = 15.0 + change.selectedBar = Qt.point(0, 0) + } + + function test_2_test_change() { + // This test has a dependency to the previous one due to asynchronous item model resolving + compare(change.dataProxy.rowCount, 3) + fuzzyCompare(change.meshAngle, 15.0, 0.01) + compare(change.selectedBar, Qt.point(0, 0)) + } + + function test_3_change_common() { + change.baseColor = "blue" + change.baseGradient = gradient1 + change.colorStyle = Theme3D.ColorStyleObjectGradient + change.itemLabelFormat = "%f" + change.itemLabelVisible = false + change.mesh = Abstract3DSeries.MeshCone + change.meshSmooth = true + change.multiHighlightColor = "green" + change.multiHighlightGradient = gradient2 + change.name = "series1" + change.singleHighlightColor = "red" + change.singleHighlightGradient = gradient3 + change.userDefinedMesh = ":/customitem.obj" + change.visible = false + + compare(change.baseColor, "#0000ff") + compare(change.baseGradient, gradient1) + compare(change.colorStyle, Theme3D.ColorStyleObjectGradient) + compare(change.itemLabelFormat, "%f") + compare(change.itemLabelVisible, false) + compare(change.mesh, Abstract3DSeries.MeshCone) + compare(change.meshSmooth, true) + compare(change.multiHighlightColor, "#008000") + compare(change.multiHighlightGradient, gradient2) + compare(change.name, "series1") + compare(change.singleHighlightColor, "#ff0000") + compare(change.singleHighlightGradient, gradient3) + compare(change.userDefinedMesh, ":/customitem.obj") + compare(change.visible, false) + } + + function test_4_change_gradient_stop() { + gradient1.stops[0].color = "yellow" + compare(change.baseGradient.stops[0].color, "#ffff00") + } + } +} diff --git a/tests/auto/qmltest/bars3d/tst_basic.qml b/tests/auto/qmltest/bars3d/tst_basic.qml new file mode 100644 index 00000000..bf27ae8c --- /dev/null +++ b/tests/auto/qmltest/bars3d/tst_basic.qml @@ -0,0 +1,240 @@ +/**************************************************************************** +** +** 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 +** +****************************************************************************/ + +import QtQuick 2.0 +import QtDataVisualization 1.2 +import QtTest 1.0 + +Item { + id: top + height: 150 + width: 150 + + Bars3D { + id: empty + } + + Bars3D { + id: basic + anchors.fill: parent + multiSeriesUniform: true + barThickness: 0.1 + barSpacing.width: 0.1 + barSpacing.height: 0.1 + barSpacingRelative: false + floorLevel: 1.0 + } + + Bars3D { + id: common + anchors.fill: parent + } + + Bars3D { + id: common_init + anchors.fill: parent + selectionMode: AbstractGraph3D.SelectionNone + shadowQuality: AbstractGraph3D.ShadowQualityLow + msaaSamples: 2 + theme: Theme3D { } + renderingMode: AbstractGraph3D.RenderIndirect + measureFps: true + orthoProjection: false + aspectRatio: 3.0 + optimizationHints: AbstractGraph3D.OptimizationStatic + polar: false + radialLabelOffset: 2 + horizontalAspectRatio: 0.2 + reflection: true + reflectivity: 0.1 + locale: Qt.locale("UK") + margin: 0.2 + } + + TestCase { + name: "Bars3D Empty" + + function test_empty() { + compare(empty.width, 0, "width") + compare(empty.height, 0, "height") + compare(empty.multiSeriesUniform, false, "multiSeriesUniform") + compare(empty.barThickness, 1.0, "barThickness") + compare(empty.barSpacing, Qt.size(0.2, 0.2), "barSpacing") + compare(empty.barSpacingRelative, true, "barSpacingRelative") + compare(empty.seriesList.length, 0, "seriesList") + compare(empty.selectedSeries, null, "selectedSeries") + compare(empty.primarySeries, null, "primarySeries") + compare(empty.floorLevel, 0.0, "floorLevel") + compare(empty.columnAxis.orientation, AbstractAxis3D.AxisOrientationX) + compare(empty.rowAxis.orientation, AbstractAxis3D.AxisOrientationZ) + compare(empty.valueAxis.orientation, AbstractAxis3D.AxisOrientationY) + compare(empty.columnAxis.type, AbstractAxis3D.AxisTypeCategory) + compare(empty.rowAxis.type, AbstractAxis3D.AxisTypeCategory) + compare(empty.valueAxis.type, AbstractAxis3D.AxisTypeValue) + } + } + + TestCase { + name: "Bars3D Basic" + when: windowShown + + function test_basic() { + compare(basic.width, 150, "width") + compare(basic.height, 150, "height") + compare(basic.multiSeriesUniform, true, "multiSeriesUniform") + compare(basic.barThickness, 0.1, "barThickness") + compare(basic.barSpacing, Qt.size(0.1, 0.1), "barSpacing") + compare(basic.barSpacingRelative, false, "barSpacingRelative") + compare(basic.floorLevel, 1.0, "floorLevel") + } + + function test_change_basic() { + basic.multiSeriesUniform = false + basic.barThickness = 0.5 + basic.barSpacing = Qt.size(1.0, 0.0) + basic.barSpacingRelative = true + basic.floorLevel = 0.2 + compare(basic.multiSeriesUniform, false, "multiSeriesUniform") + compare(basic.barThickness, 0.5, "barThickness") + compare(basic.barSpacing, Qt.size(1.0, 0.0), "barSpacing") + compare(basic.barSpacingRelative, true, "barSpacingRelative") + compare(basic.floorLevel, 0.2, "floorLevel") + } + + function test_change_invalid_basic() { + basic.barThickness = -1 + basic.barSpacing = Qt.size(-1.0, -1.0) + compare(basic.barThickness, -1/*0.5*/, "barThickness") // TODO: Fix once QTRD-3367 is done + compare(basic.barSpacing, Qt.size(1.0, 0.0), "barSpacing") + } + } + + TestCase { + name: "Bars3D Common" + when: windowShown + + function test_1_common() { + compare(common.selectionMode, AbstractGraph3D.SelectionItem, "selectionMode") + compare(common.shadowQuality, AbstractGraph3D.ShadowQualityMedium, "shadowQuality") + if (common.shadowsSupported === true) + compare(common.msaaSamples, 4, "msaaSamples") + else + compare(common.msaaSamples, 0, "msaaSamples") + compare(common.theme.type, Theme3D.ThemeQt, "theme") + compare(common.renderingMode, AbstractGraph3D.RenderIndirect, "renderingMode") + compare(common.measureFps, false, "measureFps") + compare(common.customItemList.length, 0, "customItemList") + compare(common.orthoProjection, false, "orthoProjection") + compare(common.selectedElement, AbstractGraph3D.ElementNone, "selectedElement") + compare(common.aspectRatio, 2.0, "aspectRatio") + compare(common.optimizationHints, AbstractGraph3D.OptimizationDefault, "optimizationHints") + compare(common.polar, false, "polar") + compare(common.radialLabelOffset, 1, "radialLabelOffset") + compare(common.horizontalAspectRatio, 0, "horizontalAspectRatio") + compare(common.reflection, false, "reflection") + compare(common.reflectivity, 0.5, "reflectivity") + compare(common.locale, Qt.locale("C"), "locale") + compare(common.queriedGraphPosition, Qt.vector3d(0, 0, 0), "queriedGraphPosition") + compare(common.margin, -1, "margin") + } + + function test_2_change_common() { + common.selectionMode = AbstractGraph3D.SelectionItem | AbstractGraph3D.SelectionRow | AbstractGraph3D.SelectionSlice + common.shadowQuality = AbstractGraph3D.ShadowQualitySoftHigh + compare(common.shadowQuality, AbstractGraph3D.ShadowQualitySoftHigh, "shadowQuality") + common.msaaSamples = 8 + if (common.shadowsSupported === true) + compare(common.msaaSamples, 8, "msaaSamples") + else + compare(common.msaaSamples, 0, "msaaSamples") + common.theme.type = Theme3D.ThemeRetro + common.renderingMode = AbstractGraph3D.RenderDirectToBackground_NoClear + common.measureFps = true + common.orthoProjection = true + common.aspectRatio = 1.0 + common.optimizationHints = AbstractGraph3D.OptimizationStatic + common.polar = true + common.radialLabelOffset = 2 + common.horizontalAspectRatio = 1 + common.reflection = true + common.reflectivity = 1.0 + common.locale = Qt.locale("FI") + common.margin = 1.0 + compare(common.selectionMode, AbstractGraph3D.SelectionItem | AbstractGraph3D.SelectionRow | AbstractGraph3D.SelectionSlice, "selectionMode") + compare(common.shadowQuality, AbstractGraph3D.ShadowQualityNone, "shadowQuality") // Ortho disables shadows + compare(common.msaaSamples, 0, "msaaSamples") // Rendering mode changes this to zero + compare(common.theme.type, Theme3D.ThemeRetro, "theme") + compare(common.renderingMode, AbstractGraph3D.RenderDirectToBackground_NoClear, "renderingMode") + compare(common.measureFps, true, "measureFps") + compare(common.orthoProjection, true, "orthoProjection") + compare(common.aspectRatio, 1.0, "aspectRatio") + compare(common.optimizationHints, AbstractGraph3D.OptimizationStatic, "optimizationHints") + compare(common.polar, true, "polar") + compare(common.radialLabelOffset, 2, "radialLabelOffset") + compare(common.horizontalAspectRatio, 1, "horizontalAspectRatio") + compare(common.reflection, true, "reflection") + compare(common.reflectivity, 1.0, "reflectivity") + compare(common.locale, Qt.locale("FI"), "locale") + compare(common.margin, 1.0, "margin") + } + + function test_3_change_invalid_common() { + common.selectionMode = AbstractGraph3D.SelectionRow | AbstractGraph3D.SelectionColumn | AbstractGraph3D.SelectionSlice + common.theme.type = -2 + common.renderingMode = -1 + common.measureFps = false + common.orthoProjection = false + common.aspectRatio = -1.0 + common.polar = false + common.horizontalAspectRatio = -2 + common.reflection = false + common.reflectivity = -1.0 + compare(common.selectionMode, AbstractGraph3D.SelectionItem | AbstractGraph3D.SelectionRow | AbstractGraph3D.SelectionSlice, "selectionMode") + compare(common.theme.type, -2/*Theme3D.ThemeRetro*/, "theme") // TODO: Fix once QTRD-3367 is done + compare(common.renderingMode, -1/*AbstractGraph3D.RenderDirectToBackground_NoClear*/, "renderingMode") // TODO: Fix once QTRD-3367 is done + compare(common.aspectRatio, -1.0/*1.0*/, "aspectRatio") // TODO: Fix once QTRD-3367 is done + compare(common.horizontalAspectRatio, -2/*1*/, "horizontalAspectRatio") // TODO: Fix once QTRD-3367 is done + compare(common.reflectivity, -1.0/*1.0*/, "reflectivity") // TODO: Fix once QTRD-3367 is done + } + + function test_4_common_initialized() { + compare(common_init.selectionMode, AbstractGraph3D.SelectionNone, "selectionMode") + if (common_init.shadowsSupported === true) { + compare(common_init.shadowQuality, AbstractGraph3D.ShadowQualityLow, "shadowQuality") + compare(common_init.msaaSamples, 2, "msaaSamples") + } else { + compare(common_init.shadowQuality, AbstractGraph3D.ShadowQualityNone, "shadowQuality") + compare(common_init.msaaSamples, 0, "msaaSamples") + } + compare(common_init.theme.type, Theme3D.ThemeUserDefined, "theme") + compare(common_init.renderingMode, AbstractGraph3D.RenderIndirect, "renderingMode") + compare(common_init.measureFps, true, "measureFps") + compare(common_init.customItemList.length, 0, "customItemList") + compare(common_init.orthoProjection, false, "orthoProjection") + compare(common_init.aspectRatio, 3.0, "aspectRatio") + compare(common_init.optimizationHints, AbstractGraph3D.OptimizationStatic, "optimizationHints") + compare(common_init.polar, false, "polar") + compare(common_init.radialLabelOffset, 2, "radialLabelOffset") + compare(common_init.horizontalAspectRatio, 0.2, "horizontalAspectRatio") + compare(common_init.reflection, true, "reflection") + compare(common_init.reflectivity, 0.1, "reflectivity") + compare(common_init.locale, Qt.locale("UK"), "locale") + compare(common_init.margin, 0.2, "margin") + } + } +} diff --git a/tests/auto/qmltest/bars3d/tst_proxy.qml b/tests/auto/qmltest/bars3d/tst_proxy.qml new file mode 100644 index 00000000..8d91c055 --- /dev/null +++ b/tests/auto/qmltest/bars3d/tst_proxy.qml @@ -0,0 +1,253 @@ +/**************************************************************************** +** +** 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 +** +****************************************************************************/ + +import QtQuick 2.0 +import QtDataVisualization 1.2 +import QtTest 1.0 + +Item { + id: top + height: 150 + width: 150 + + ItemModelBarDataProxy { + id: initial + } + + ItemModelBarDataProxy { + id: initialized + + autoColumnCategories: false + autoRowCategories: false + columnCategories: ["colcat1", "colcat2"] + columnRole: "col" + columnRolePattern: /^.*-(\d\d)$/ + columnRoleReplace: "\\1" + itemModel: ListModel { objectName: "model1" } + multiMatchBehavior: ItemModelBarDataProxy.MMBAverage + rotationRole: "rot" + rotationRolePattern: /-/ + rotationRoleReplace: "\\1" + rowCategories: ["rowcat1", "rowcat2"] + rowRole: "row" + rowRolePattern: /^(\d\d\d\d).*$/ + rowRoleReplace: "\\1" + valueRole: "val" + valueRolePattern: /-/ + valueRoleReplace: "\\1" + + columnLabels: ["col1", "col2"] + rowLabels: ["row1", "row2"] + } + + ItemModelBarDataProxy { + id: change + } + + TestCase { + name: "ItemModelBarDataProxy Initial" + + function test_initial() { + compare(initial.autoColumnCategories, true) + compare(initial.autoRowCategories, true) + compare(initial.columnCategories, []) + compare(initial.columnRole, "") + verify(initial.columnRolePattern) + compare(initial.columnRoleReplace, "") + verify(!initial.itemModel) + compare(initial.multiMatchBehavior, ItemModelBarDataProxy.MMBLast) + compare(initial.rotationRole, "") + verify(initial.rotationRolePattern) + compare(initial.rotationRoleReplace, "") + compare(initial.rowCategories, []) + compare(initial.rowRole, "") + verify(initial.rowRolePattern) + compare(initial.rowRoleReplace, "") + compare(initial.useModelCategories, false) + compare(initial.valueRole, "") + verify(initial.valueRolePattern) + compare(initial.valueRoleReplace, "") + + compare(initial.columnLabels.length, 0) + compare(initial.rowCount, 0) + compare(initial.rowLabels.length, 0) + verify(!initial.series) + + compare(initial.type, AbstractDataProxy.DataTypeBar) + } + } + + TestCase { + name: "ItemModelBarDataProxy Initialized" + + function test_initialized() { + compare(initialized.autoColumnCategories, false) + compare(initialized.autoRowCategories, false) + compare(initialized.columnCategories.length, 2) + compare(initialized.columnCategories[0], "colcat1") + compare(initialized.columnCategories[1], "colcat2") + compare(initialized.columnRole, "col") + compare(initialized.columnRolePattern, /^.*-(\d\d)$/) + compare(initialized.columnRoleReplace, "\\1") + compare(initialized.itemModel.objectName, "model1") + compare(initialized.multiMatchBehavior, ItemModelBarDataProxy.MMBAverage) + compare(initialized.rotationRole, "rot") + compare(initialized.rotationRolePattern, /-/) + compare(initialized.rotationRoleReplace, "\\1") + compare(initialized.rowCategories.length, 2) + compare(initialized.rowCategories[0], "rowcat1") + compare(initialized.rowCategories[1], "rowcat2") + compare(initialized.rowRole, "row") + compare(initialized.rowRolePattern, /^(\d\d\d\d).*$/) + compare(initialized.rowRoleReplace, "\\1") + compare(initialized.valueRole, "val") + compare(initialized.valueRolePattern, /-/) + compare(initialized.valueRoleReplace, "\\1") + + compare(initialized.columnLabels.length, 2) + compare(initialized.rowCount, 2) + compare(initialized.rowLabels.length, 2) + } + } + + TestCase { + name: "ItemModelBarDataProxy Change" + + ListModel { id: model1; objectName: "model1" } + + function test_1_change() { + change.autoColumnCategories = false + change.autoRowCategories = false + change.columnCategories = ["colcat1", "colcat2"] + change.columnRole = "col" + change.columnRolePattern = /^.*-(\d\d)$/ + change.columnRoleReplace = "\\1" + change.itemModel = model1 + change.multiMatchBehavior = ItemModelBarDataProxy.MMBAverage + change.rotationRole = "rot" + change.rotationRolePattern = /-/ + change.rotationRoleReplace = "\\1" + change.rowCategories = ["rowcat1", "rowcat2"] + change.rowRole = "row" + change.rowRolePattern = /^(\d\d\d\d).*$/ + change.rowRoleReplace = "\\1" + change.useModelCategories = true // Overwrites columnLabels and rowLabels + change.valueRole = "val" + change.valueRolePattern = /-/ + change.valueRoleReplace = "\\1" + + change.columnLabels = ["col1", "col2"] + change.rowLabels = ["row1", "row2"] + } + + function test_2_test_change() { + // This test has a dependency to the previous one due to asynchronous item model resolving + compare(change.autoColumnCategories, false) + compare(change.autoRowCategories, false) + compare(change.columnCategories.length, 2) + compare(change.columnCategories[0], "colcat1") + compare(change.columnCategories[1], "colcat2") + compare(change.columnRole, "col") + compare(change.columnRolePattern, /^.*-(\d\d)$/) + compare(change.columnRoleReplace, "\\1") + compare(change.itemModel.objectName, "model1") + compare(change.multiMatchBehavior, ItemModelBarDataProxy.MMBAverage) + compare(change.rotationRole, "rot") + compare(change.rotationRolePattern, /-/) + compare(change.rotationRoleReplace, "\\1") + compare(change.rowCategories.length, 2) + compare(change.rowCategories[0], "rowcat1") + compare(change.rowCategories[1], "rowcat2") + compare(change.rowRole, "row") + compare(change.rowRolePattern, /^(\d\d\d\d).*$/) + compare(change.rowRoleReplace, "\\1") + compare(change.useModelCategories, true) + compare(change.valueRole, "val") + compare(change.valueRolePattern, /-/) + compare(change.valueRoleReplace, "\\1") + + compare(change.columnLabels.length, 1) + compare(change.rowCount, 0) + compare(change.rowLabels.length, 0) + } + } + + TestCase { + name: "ItemModelBarDataProxy MultiMatchBehaviour" + + Bars3D { + id: bars1 + + Bar3DSeries { + ItemModelBarDataProxy { + id: barProxy + itemModel: ListModel { + ListElement{ coords: "0,0"; data: "5"; } + ListElement{ coords: "0,0"; data: "15"; } + } + rowRole: "coords" + columnRole: "coords" + valueRole: "data" + rowRolePattern: /(\d),\d/ + columnRolePattern: /(\d),(\d)/ + rowRoleReplace: "\\1" + columnRoleReplace: "\\2" + } + } + } + + function test_0_async_dummy() { + } + + function test_1_test_multimatch() { + compare(bars1.valueAxis.max, 15) + } + + function test_2_multimatch() { + barProxy.multiMatchBehavior = ItemModelBarDataProxy.MMBFirst + } + + function test_3_test_multimatch() { + compare(bars1.valueAxis.max, 5) + } + + function test_4_multimatch() { + barProxy.multiMatchBehavior = ItemModelBarDataProxy.MMBLast + } + + function test_5_test_multimatch() { + compare(bars1.valueAxis.max, 15) + } + + function test_6_multimatch() { + barProxy.multiMatchBehavior = ItemModelBarDataProxy.MMBAverage + } + + function test_7_test_multimatch() { + compare(bars1.valueAxis.max, 10) + } + + function test_8_multimatch() { + barProxy.multiMatchBehavior = ItemModelBarDataProxy.MMBCumulative + } + + function test_9_test_multimatch() { + compare(bars1.valueAxis.max, 20) + } + } +} diff --git a/tests/auto/qmltest/custom3d/tst_customitem.qml b/tests/auto/qmltest/custom3d/tst_customitem.qml new file mode 100644 index 00000000..ee3d10fc --- /dev/null +++ b/tests/auto/qmltest/custom3d/tst_customitem.qml @@ -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 +** +****************************************************************************/ + +import QtQuick 2.0 +import QtDataVisualization 1.2 +import QtTest 1.0 + +Item { + id: top + width: 150 + height: 150 + + Custom3DItem { + id: initial + } + + Custom3DItem { + id: initialized + meshFile: ":\customitem.obj" + position: Qt.vector3d(1.0, 0.5, 1.0) + positionAbsolute: true + rotation: Qt.quaternion(1, 0.5, 0, 0) + scaling: Qt.vector3d(0.2, 0.2, 0.2) + scalingAbsolute: false + shadowCasting: false + textureFile: ":\customtexture.jpg" + visible: false + } + + Custom3DItem { + id: change + } + + TestCase { + name: "Custom3DItem Initial" + + function test_initial() { + compare(initial.meshFile, "") + compare(initial.position, Qt.vector3d(0.0, 0.0, 0.0)) + compare(initial.positionAbsolute, false) + compare(initial.rotation, Qt.quaternion(0, 0, 0, 0)) + compare(initial.scaling, Qt.vector3d(0.1, 0.1, 0.1)) + compare(initial.scalingAbsolute, true) + compare(initial.shadowCasting, true) + compare(initial.textureFile, "") + compare(initial.visible, true) + } + } + + TestCase { + name: "Custom3DItem Initialized" + + function test_initialized() { + compare(initialized.meshFile, ":\customitem.obj") + compare(initialized.position, Qt.vector3d(1.0, 0.5, 1.0)) + compare(initialized.positionAbsolute, true) + compare(initialized.rotation, Qt.quaternion(1, 0.5, 0, 0)) + compare(initialized.scaling, Qt.vector3d(0.2, 0.2, 0.2)) + compare(initialized.scalingAbsolute, false) + compare(initialized.shadowCasting, false) + compare(initialized.textureFile, ":\customtexture.jpg") + compare(initialized.visible, false) + } + } + + TestCase { + name: "Custom3DItem Change" + + function test_change() { + change.meshFile = ":\customitem.obj" + change.position = Qt.vector3d(1.0, 0.5, 1.0) + change.positionAbsolute = true + change.rotation = Qt.quaternion(1, 0.5, 0, 0) + change.scaling = Qt.vector3d(0.2, 0.2, 0.2) + change.scalingAbsolute = false + change.shadowCasting = false + change.textureFile = ":\customtexture.jpg" + change.visible = false + + compare(change.meshFile, ":\customitem.obj") + compare(change.position, Qt.vector3d(1.0, 0.5, 1.0)) + compare(change.positionAbsolute, true) + compare(change.rotation, Qt.quaternion(1, 0.5, 0, 0)) + compare(change.scaling, Qt.vector3d(0.2, 0.2, 0.2)) + compare(change.scalingAbsolute, false) + compare(change.shadowCasting, false) + compare(change.textureFile, ":\customtexture.jpg") + compare(change.visible, false) + } + } +} diff --git a/tests/auto/qmltest/custom3d/tst_customlabel.qml b/tests/auto/qmltest/custom3d/tst_customlabel.qml new file mode 100644 index 00000000..acac1b63 --- /dev/null +++ b/tests/auto/qmltest/custom3d/tst_customlabel.qml @@ -0,0 +1,134 @@ +/**************************************************************************** +** +** 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 +** +****************************************************************************/ + +import QtQuick 2.0 +import QtDataVisualization 1.2 +import QtTest 1.0 + +Item { + id: top + width: 150 + height: 150 + + Custom3DLabel { + id: initial + } + + Custom3DLabel { + id: initialized + backgroundColor: "red" + backgroundEnabled: false + borderEnabled: false + facingCamera: true + font.family: "Times New Roman" + text: "test label" + textColor: "blue" + + position: Qt.vector3d(1.0, 0.5, 1.0) + positionAbsolute: true + rotation: Qt.quaternion(1, 0.5, 0, 0) + scaling: Qt.vector3d(0.2, 0.2, 0.2) + shadowCasting: true + visible: false + } + + Custom3DLabel { + id: change + } + + TestCase { + name: "Custom3DLabel Initial" + + function test_initial() { + compare(initial.backgroundColor, "#a0a0a4") + compare(initial.backgroundEnabled, true) + compare(initial.borderEnabled, true) + compare(initial.facingCamera, false) + compare(initial.font.family, "Arial") + compare(initial.text, "") + compare(initial.textColor, "#ffffff") + + compare(initial.meshFile, ":/defaultMeshes/plane") + compare(initial.position, Qt.vector3d(0.0, 0.0, 0.0)) + compare(initial.positionAbsolute, false) + compare(initial.rotation, Qt.quaternion(0, 0, 0, 0)) + compare(initial.scaling, Qt.vector3d(0.1, 0.1, 0.1)) + compare(initial.scalingAbsolute, true) + compare(initial.shadowCasting, false) + compare(initial.textureFile, "") + compare(initial.visible, true) + } + } + + TestCase { + name: "Custom3DLabel Initialized" + + function test_initialized() { + compare(initialized.backgroundColor, "#ff0000") + compare(initialized.backgroundEnabled, false) + compare(initialized.borderEnabled, false) + compare(initialized.facingCamera, true) + compare(initialized.font.family, "Times New Roman") + compare(initialized.text, "test label") + compare(initialized.textColor, "#0000ff") + + compare(initialized.position, Qt.vector3d(1.0, 0.5, 1.0)) + compare(initialized.positionAbsolute, true) + compare(initialized.rotation, Qt.quaternion(1, 0.5, 0, 0)) + compare(initialized.scaling, Qt.vector3d(0.2, 0.2, 0.2)) + compare(initialized.shadowCasting, true) + compare(initialized.visible, false) + } + } + + TestCase { + name: "Custom3DLabel Change" + + function test_change() { + change.backgroundColor = "red" + change.backgroundEnabled = false + change.borderEnabled = false + change.facingCamera = true + change.font.family = "Times New Roman" + change.text = "test label" + change.textColor = "blue" + + change.position = Qt.vector3d(1.0, 0.5, 1.0) + change.positionAbsolute = true + change.rotation = Qt.quaternion(1, 0.5, 0, 0) + change.scaling = Qt.vector3d(0.2, 0.2, 0.2) + change.shadowCasting = true + change.visible = false + + compare(change.backgroundColor, "#ff0000") + compare(change.backgroundEnabled, false) + compare(change.borderEnabled, false) + compare(change.facingCamera, true) + compare(change.font.family, "Times New Roman") + compare(change.text, "test label") + compare(change.textColor, "#0000ff") + + compare(change.position, Qt.vector3d(1.0, 0.5, 1.0)) + compare(change.positionAbsolute, true) + compare(change.rotation, Qt.quaternion(1, 0.5, 0, 0)) + compare(change.scaling, Qt.vector3d(0.2, 0.2, 0.2)) + compare(change.shadowCasting, true) + compare(change.visible, false) + } + } +} diff --git a/tests/auto/qmltest/custom3d/tst_customvolume.qml b/tests/auto/qmltest/custom3d/tst_customvolume.qml new file mode 100644 index 00000000..08c15013 --- /dev/null +++ b/tests/auto/qmltest/custom3d/tst_customvolume.qml @@ -0,0 +1,182 @@ +/**************************************************************************** +** +** 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 +** +****************************************************************************/ + +import QtQuick 2.0 +import QtDataVisualization 1.2 +import QtTest 1.0 + +Item { + id: top + width: 150 + height: 150 + + Custom3DVolume { + id: initial + } + + Custom3DVolume { + id: initialized + alphaMultiplier: 0.1 + drawSliceFrames: true + drawSlices: true + preserveOpacity: false + sliceFrameColor: "red" + sliceFrameGaps: Qt.vector3d(2.0, 2.0, 2.0) + sliceFrameThicknesses: Qt.vector3d(2.0, 2.0, 2.0) + sliceFrameWidths: Qt.vector3d(2.0, 2.0, 2.0) + sliceIndexX: 0 + sliceIndexY: 0 + sliceIndexZ: 0 + useHighDefShader: false + + position: Qt.vector3d(1.0, 0.5, 1.0) + positionAbsolute: true + rotation: Qt.quaternion(1, 0.5, 0, 0) + scaling: Qt.vector3d(0.2, 0.2, 0.2) + scalingAbsolute: false + shadowCasting: false + visible: false + } + + Custom3DVolume { + id: change + } + + Custom3DVolume { + id: invalid + } + + TestCase { + name: "Custom3DVolume Initial" + + function test_initial() { + compare(initial.alphaMultiplier, 1.0) + compare(initial.drawSliceFrames, false) + compare(initial.drawSlices, false) + compare(initial.preserveOpacity, true) + compare(initial.sliceFrameColor, "#000000") + compare(initial.sliceFrameGaps, Qt.vector3d(0.01, 0.01, 0.01)) + compare(initial.sliceFrameThicknesses, Qt.vector3d(0.01, 0.01, 0.01)) + compare(initial.sliceFrameWidths, Qt.vector3d(0.01, 0.01, 0.01)) + compare(initial.sliceIndexX, -1) + compare(initial.sliceIndexY, -1) + compare(initial.sliceIndexZ, -1) + compare(initial.useHighDefShader, true) + + compare(initial.meshFile, ":/defaultMeshes/barFull") + compare(initial.position, Qt.vector3d(0.0, 0.0, 0.0)) + compare(initial.positionAbsolute, false) + compare(initial.rotation, Qt.quaternion(0, 0, 0, 0)) + compare(initial.scaling, Qt.vector3d(0.1, 0.1, 0.1)) + compare(initial.scalingAbsolute, true) + compare(initial.shadowCasting, true) + compare(initial.textureFile, "") + compare(initial.visible, true) + } + } + + TestCase { + name: "Custom3DVolume Initialized" + + function test_initialized() { + compare(initialized.alphaMultiplier, 0.1) + compare(initialized.drawSliceFrames, true) + compare(initialized.drawSlices, true) + compare(initialized.preserveOpacity, false) + compare(initialized.sliceFrameColor, "#ff0000") + compare(initialized.sliceFrameGaps, Qt.vector3d(2.0, 2.0, 2.0)) + compare(initialized.sliceFrameThicknesses, Qt.vector3d(2.0, 2.0, 2.0)) + compare(initialized.sliceFrameWidths, Qt.vector3d(2.0, 2.0, 2.0)) + compare(initialized.sliceIndexX, 0) + compare(initialized.sliceIndexY, 0) + compare(initialized.sliceIndexZ, 0) + compare(initialized.useHighDefShader, false) + + compare(initialized.position, Qt.vector3d(1.0, 0.5, 1.0)) + compare(initialized.positionAbsolute, true) + compare(initialized.rotation, Qt.quaternion(1, 0.5, 0, 0)) + compare(initialized.scaling, Qt.vector3d(0.2, 0.2, 0.2)) + compare(initialized.scalingAbsolute, false) + compare(initialized.shadowCasting, false) + compare(initialized.visible, false) + } + } + + TestCase { + name: "Custom3DVolume Change" + + function test_change() { + change.alphaMultiplier = 0.1 + change.drawSliceFrames = true + change.drawSlices = true + change.preserveOpacity = false + change.sliceFrameColor = "red" + change.sliceFrameGaps = Qt.vector3d(2.0, 2.0, 2.0) + change.sliceFrameThicknesses = Qt.vector3d(2.0, 2.0, 2.0) + change.sliceFrameWidths = Qt.vector3d(2.0, 2.0, 2.0) + change.sliceIndexX = 0 + change.sliceIndexY = 0 + change.sliceIndexZ = 0 + change.useHighDefShader = false + + change.position = Qt.vector3d(1.0, 0.5, 1.0) + change.positionAbsolute = true + change.rotation = Qt.quaternion(1, 0.5, 0, 0) + change.scaling = Qt.vector3d(0.2, 0.2, 0.2) + change.scalingAbsolute = false + change.shadowCasting = false + change.visible = false + + compare(change.alphaMultiplier, 0.1) + compare(change.drawSliceFrames, true) + compare(change.drawSlices, true) + compare(change.preserveOpacity, false) + compare(change.sliceFrameColor, "#ff0000") + compare(change.sliceFrameGaps, Qt.vector3d(2.0, 2.0, 2.0)) + compare(change.sliceFrameThicknesses, Qt.vector3d(2.0, 2.0, 2.0)) + compare(change.sliceFrameWidths, Qt.vector3d(2.0, 2.0, 2.0)) + compare(change.sliceIndexX, 0) + compare(change.sliceIndexY, 0) + compare(change.sliceIndexZ, 0) + compare(change.useHighDefShader, false) + + compare(change.position, Qt.vector3d(1.0, 0.5, 1.0)) + compare(change.positionAbsolute, true) + compare(change.rotation, Qt.quaternion(1, 0.5, 0, 0)) + compare(change.scaling, Qt.vector3d(0.2, 0.2, 0.2)) + compare(change.scalingAbsolute, false) + compare(change.shadowCasting, false) + compare(change.visible, false) + } + } + + TestCase { + name: "Custom3DVolume Invalid" + + function test_invalid() { + invalid.alphaMultiplier = -1.0 + compare(invalid.alphaMultiplier, 1.0) + invalid.sliceFrameGaps = Qt.vector3d(-0.1, -0.1, -0.1) + compare(invalid.sliceFrameGaps, Qt.vector3d(0.01, 0.01, 0.01)) + invalid.sliceFrameThicknesses = Qt.vector3d(-0.1, -0.1, -0.1) + compare(invalid.sliceFrameThicknesses, Qt.vector3d(0.01, 0.01, 0.01)) + invalid.sliceFrameWidths = Qt.vector3d(-0.1, -0.1, -0.1) + compare(invalid.sliceFrameWidths, Qt.vector3d(0.01, 0.01, 0.01)) + } + } +} diff --git a/tests/auto/qmltest/customitem.obj b/tests/auto/qmltest/customitem.obj new file mode 100644 index 00000000..108cf7ac --- /dev/null +++ b/tests/auto/qmltest/customitem.obj @@ -0,0 +1,54 @@ +# Blender v2.66 (sub 0) OBJ File: 'cube_filled.blend' +# www.blender.org +o Cube +v -1.000000 -1.000000 1.000000 +v -1.000000 -1.000000 -1.000000 +v 1.000000 -1.000000 -1.000000 +v 1.000000 -1.000000 1.000000 +v -1.000000 1.000000 1.000000 +v -1.000000 1.000000 -1.000000 +v 1.000000 1.000000 -1.000000 +v 1.000000 1.000000 1.000000 +vt 0.666667 0.332314 +vt 0.334353 0.333333 +vt 0.665647 0.000000 +vt 0.001020 0.333333 +vt 0.000000 0.001020 +vt 0.333333 0.332314 +vt 0.333333 0.665647 +vt 0.001019 0.666667 +vt 0.000000 0.334353 +vt 0.334353 0.666667 +vt 0.333333 0.334353 +vt 0.665647 0.333333 +vt 0.333333 0.667686 +vt 0.665647 0.666667 +vt 0.666667 0.998980 +vt 0.667686 0.333333 +vt 0.666667 0.001019 +vt 0.998980 0.000000 +vt 0.333333 0.001019 +vt 0.332314 0.000000 +vt 0.332314 0.333333 +vt 0.666667 0.665647 +vt 0.334353 1.000000 +vt 1.000000 0.332314 +vn -1.000000 0.000000 0.000000 +vn 0.000000 0.000000 -1.000000 +vn 1.000000 -0.000000 0.000000 +vn 0.000000 0.000000 1.000000 +vn 0.000000 1.000000 0.000000 +vn -0.000000 -1.000000 -0.000000 +s off +f 5/1/1 6/2/1 1/3/1 +f 6/4/2 7/5/2 2/6/2 +f 7/7/3 8/8/3 4/9/3 +f 8/10/4 5/11/4 1/12/4 +f 8/13/5 7/14/5 6/15/5 +f 2/16/6 3/17/6 4/18/6 +f 6/2/1 2/19/1 1/3/1 +f 7/5/2 3/20/2 2/6/2 +f 3/21/3 7/7/3 4/9/3 +f 4/22/4 8/10/4 1/12/4 +f 5/23/5 8/13/5 6/15/5 +f 1/24/6 2/16/6 4/18/6 diff --git a/tests/auto/qmltest/customtexture.jpg b/tests/auto/qmltest/customtexture.jpg Binary files differnew file mode 100644 index 00000000..2580f5bd --- /dev/null +++ b/tests/auto/qmltest/customtexture.jpg diff --git a/tests/auto/qmltest/input3d/tst_input.qml b/tests/auto/qmltest/input3d/tst_input.qml new file mode 100644 index 00000000..fefb585e --- /dev/null +++ b/tests/auto/qmltest/input3d/tst_input.qml @@ -0,0 +1,83 @@ +/**************************************************************************** +** +** 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 +** +****************************************************************************/ + +import QtQuick 2.0 +import QtDataVisualization 1.2 +import QtTest 1.0 + +Item { + id: top + width: 150 + height: 150 + + InputHandler3D { + id: initial + } + + InputHandler3D { + id: initialized + rotationEnabled: false + selectionEnabled: false + zoomAtTargetEnabled: false + zoomEnabled: false + } + + InputHandler3D { + id: change + } + + TestCase { + name: "InputHandler3D Initial" + + function test_initial() { + compare(initial.rotationEnabled, true) + compare(initial.selectionEnabled, true) + compare(initial.zoomAtTargetEnabled, true) + compare(initial.zoomEnabled, true) + } + } + + TestCase { + name: "InputHandler3D Initialized" + + function test_initialized() { + compare(initialized.rotationEnabled, false) + compare(initialized.selectionEnabled, false) + compare(initialized.zoomAtTargetEnabled, false) + compare(initialized.zoomEnabled, false) + } + } + + TestCase { + name: "InputHandler3D Change" + + function test_change() { + change.rotationEnabled = false + change.selectionEnabled = false + change.zoomAtTargetEnabled = false + change.zoomEnabled = false + + compare(change.rotationEnabled, false) + compare(change.selectionEnabled, false) + compare(change.zoomAtTargetEnabled, false) + compare(change.zoomEnabled, false) + } + + // TODO: QTRD-3380 (mouse events) + } +} diff --git a/tests/auto/qmltest/input3d/tst_touch.qml b/tests/auto/qmltest/input3d/tst_touch.qml new file mode 100644 index 00000000..626da68f --- /dev/null +++ b/tests/auto/qmltest/input3d/tst_touch.qml @@ -0,0 +1,83 @@ +/**************************************************************************** +** +** 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 +** +****************************************************************************/ + +import QtQuick 2.0 +import QtDataVisualization 1.2 +import QtTest 1.0 + +Item { + id: top + width: 150 + height: 150 + + TouchInputHandler3D { + id: initial + } + + TouchInputHandler3D { + id: initialized + rotationEnabled: false + selectionEnabled: false + zoomAtTargetEnabled: false + zoomEnabled: false + } + + TouchInputHandler3D { + id: change + } + + TestCase { + name: "TouchInputHandler3D Initial" + + function test_initial() { + compare(initial.rotationEnabled, true) + compare(initial.selectionEnabled, true) + compare(initial.zoomAtTargetEnabled, true) + compare(initial.zoomEnabled, true) + } + } + + TestCase { + name: "TouchInputHandler3D Initialized" + + function test_initialized() { + compare(initialized.rotationEnabled, false) + compare(initialized.selectionEnabled, false) + compare(initialized.zoomAtTargetEnabled, false) + compare(initialized.zoomEnabled, false) + } + } + + TestCase { + name: "TouchInputHandler3D Change" + + function test_change() { + change.rotationEnabled = false + change.selectionEnabled = false + change.zoomAtTargetEnabled = false + change.zoomEnabled = false + + compare(change.rotationEnabled, false) + compare(change.selectionEnabled, false) + compare(change.zoomAtTargetEnabled, false) + compare(change.zoomEnabled, false) + + // TODO: QTRD-3380 (mouse events) + } + } +} diff --git a/tests/auto/qmltest/qmltest.pro b/tests/auto/qmltest/qmltest.pro new file mode 100644 index 00000000..cbb9b8b8 --- /dev/null +++ b/tests/auto/qmltest/qmltest.pro @@ -0,0 +1,35 @@ +TEMPLATE = app +TARGET = tst_qmltest +CONFIG += qmltestcase +CONFIG += console +SOURCES += tst_qmltest.cpp +OTHER_FILES += bars3d\tst_basic.qml \ + bars3d\tst_bars.qml \ + bars3d\tst_barseries.qml \ + bars3d\tst_proxy.qml \ + scatter3d\tst_basic.qml \ + scatter3d\tst_scatter.qml \ + scatter3d\tst_scatterseries.qml \ + scatter3d\tst_proxy.qml \ + surface3d\tst_basic.qml \ + surface3d\tst_surface.qml \ + surface3d\tst_surfaceseries.qml \ + surface3d\tst_proxy.qml \ + surface3d\tst_heightproxy.qml \ + theme3d\tst_theme.qml \ + theme3d\tst_colorgradient.qml \ + theme3d\tst_themecolor.qml \ + custom3d\tst_customitem.qml \ + custom3d\tst_customlabel.qml \ + custom3d\tst_customvolume.qml \ + scene3d\tst_scene.qml \ + scene3d\tst_camera.qml \ + scene3d\tst_light.qml \ + input3d\tst_input.qml \ + input3d\tst_touch.qml \ + axis3d\tst_category.qml \ + axis3d\tst_value.qml \ + axis3d\tst_logvalue.qml \ + +RESOURCES += \ + qmltest.qrc diff --git a/tests/auto/qmltest/qmltest.qrc b/tests/auto/qmltest/qmltest.qrc new file mode 100644 index 00000000..61f19086 --- /dev/null +++ b/tests/auto/qmltest/qmltest.qrc @@ -0,0 +1,6 @@ +<RCC> + <qresource prefix="/"> + <file>customitem.obj</file> + <file>customtexture.jpg</file> + </qresource> +</RCC> diff --git a/tests/auto/qmltest/scatter3d/tst_basic.qml b/tests/auto/qmltest/scatter3d/tst_basic.qml new file mode 100644 index 00000000..b7221701 --- /dev/null +++ b/tests/auto/qmltest/scatter3d/tst_basic.qml @@ -0,0 +1,203 @@ +/**************************************************************************** +** +** 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 +** +****************************************************************************/ + +import QtQuick 2.0 +import QtDataVisualization 1.2 +import QtTest 1.0 + +Item { + id: top + height: 150 + width: 150 + + Scatter3D { + id: empty + } + + Scatter3D { + id: basic + anchors.fill: parent + } + + Scatter3D { + id: common + anchors.fill: parent + } + + Scatter3D { + id: common_init + anchors.fill: parent + selectionMode: AbstractGraph3D.SelectionNone + shadowQuality: AbstractGraph3D.ShadowQualityLow + msaaSamples: 2 + theme: Theme3D { } + renderingMode: AbstractGraph3D.RenderIndirect + measureFps: true + orthoProjection: false + aspectRatio: 3.0 + optimizationHints: AbstractGraph3D.OptimizationStatic + polar: false + radialLabelOffset: 2 + horizontalAspectRatio: 0.2 + reflection: true + reflectivity: 0.1 + locale: Qt.locale("UK") + margin: 0.2 + } + + TestCase { + name: "Scatter3D Empty" + + function test_empty() { + compare(empty.width, 0, "width") + compare(empty.height, 0, "height") + compare(empty.seriesList.length, 0, "seriesList") + compare(empty.selectedSeries, null, "selectedSeries") + compare(empty.axisX.orientation, AbstractAxis3D.AxisOrientationX) + compare(empty.axisZ.orientation, AbstractAxis3D.AxisOrientationZ) + compare(empty.axisY.orientation, AbstractAxis3D.AxisOrientationY) + compare(empty.axisX.type, AbstractAxis3D.AxisTypeValue) + compare(empty.axisZ.type, AbstractAxis3D.AxisTypeValue) + compare(empty.axisY.type, AbstractAxis3D.AxisTypeValue) + } + } + + TestCase { + name: "Scatter3D Basic" + when: windowShown + + function test_basic() { + compare(basic.width, 150, "width") + compare(basic.height, 150, "height") + } + } + + TestCase { + name: "Scatter3D Common" + when: windowShown + + function test_1_common() { + compare(common.selectionMode, AbstractGraph3D.SelectionItem, "selectionMode") + compare(common.shadowQuality, AbstractGraph3D.ShadowQualityMedium, "shadowQuality") + if (common.shadowsSupported === true) + compare(common.msaaSamples, 4, "msaaSamples") + else + compare(common.msaaSamples, 0, "msaaSamples") + compare(common.theme.type, Theme3D.ThemeQt, "theme") + compare(common.renderingMode, AbstractGraph3D.RenderIndirect, "renderingMode") + compare(common.measureFps, false, "measureFps") + compare(common.customItemList.length, 0, "customItemList") + compare(common.orthoProjection, false, "orthoProjection") + compare(common.selectedElement, AbstractGraph3D.ElementNone, "selectedElement") + compare(common.aspectRatio, 2.0, "aspectRatio") + compare(common.optimizationHints, AbstractGraph3D.OptimizationDefault, "optimizationHints") + compare(common.polar, false, "polar") + compare(common.radialLabelOffset, 1, "radialLabelOffset") + compare(common.horizontalAspectRatio, 0, "horizontalAspectRatio") + compare(common.reflection, false, "reflection") + compare(common.reflectivity, 0.5, "reflectivity") + compare(common.locale, Qt.locale("C"), "locale") + compare(common.queriedGraphPosition, Qt.vector3d(0, 0, 0), "queriedGraphPosition") + compare(common.margin, -1, "margin") + } + + function test_2_change_common() { + common.selectionMode = AbstractGraph3D.SelectionNone + common.shadowQuality = AbstractGraph3D.ShadowQualitySoftHigh + compare(common.shadowQuality, AbstractGraph3D.ShadowQualitySoftHigh, "shadowQuality") + common.msaaSamples = 8 + if (common.shadowsSupported === true) + compare(common.msaaSamples, 8, "msaaSamples") + else + compare(common.msaaSamples, 0, "msaaSamples") + common.theme.type = Theme3D.ThemeRetro + common.renderingMode = AbstractGraph3D.RenderDirectToBackground_NoClear + common.measureFps = true + common.orthoProjection = true + common.aspectRatio = 1.0 + common.optimizationHints = AbstractGraph3D.OptimizationStatic + common.polar = true + common.radialLabelOffset = 2 + common.horizontalAspectRatio = 1 + common.reflection = true + common.reflectivity = 1.0 + common.locale = Qt.locale("FI") + common.margin = 1.0 + compare(common.selectionMode, AbstractGraph3D.SelectionNone, "selectionMode") + compare(common.shadowQuality, AbstractGraph3D.ShadowQualityNone, "shadowQuality") // Ortho disables shadows + compare(common.msaaSamples, 0, "msaaSamples") // Rendering mode changes this to zero + compare(common.theme.type, Theme3D.ThemeRetro, "theme") + compare(common.renderingMode, AbstractGraph3D.RenderDirectToBackground_NoClear, "renderingMode") + compare(common.measureFps, true, "measureFps") + compare(common.orthoProjection, true, "orthoProjection") + compare(common.aspectRatio, 1.0, "aspectRatio") + compare(common.optimizationHints, AbstractGraph3D.OptimizationStatic, "optimizationHints") + compare(common.polar, true, "polar") + compare(common.radialLabelOffset, 2, "radialLabelOffset") + compare(common.horizontalAspectRatio, 1, "horizontalAspectRatio") + compare(common.reflection, true, "reflection") + compare(common.reflectivity, 1.0, "reflectivity") + compare(common.locale, Qt.locale("FI"), "locale") + compare(common.margin, 1.0, "margin") + } + + function test_3_change_invalid_common() { + common.selectionMode = AbstractGraph3D.SelectionRow | AbstractGraph3D.SelectionColumn | AbstractGraph3D.SelectionSlice + common.theme.type = -2 + common.renderingMode = -1 + common.measureFps = false + common.orthoProjection = false + common.aspectRatio = -1.0 + common.polar = false + common.horizontalAspectRatio = -2 + common.reflection = false + common.reflectivity = -1.0 + compare(common.selectionMode, AbstractGraph3D.SelectionNone, "selectionMode") + compare(common.theme.type, -2/*Theme3D.ThemeRetro*/, "theme") // TODO: Fix once QTRD-3367 is done + compare(common.renderingMode, -1/*AbstractGraph3D.RenderDirectToBackground_NoClear*/, "renderingMode") // TODO: Fix once QTRD-3367 is done + compare(common.aspectRatio, -1.0/*1.0*/, "aspectRatio") // TODO: Fix once QTRD-3367 is done + compare(common.horizontalAspectRatio, -2/*1*/, "horizontalAspectRatio") // TODO: Fix once QTRD-3367 is done + compare(common.reflectivity, -1.0/*1.0*/, "reflectivity") // TODO: Fix once QTRD-3367 is done + } + + function test_4_common_initialized() { + compare(common_init.selectionMode, AbstractGraph3D.SelectionNone, "selectionMode") + if (common_init.shadowsSupported === true) { + compare(common_init.shadowQuality, AbstractGraph3D.ShadowQualityLow, "shadowQuality") + compare(common_init.msaaSamples, 2, "msaaSamples") + } else { + compare(common_init.shadowQuality, AbstractGraph3D.ShadowQualityNone, "shadowQuality") + compare(common_init.msaaSamples, 0, "msaaSamples") + } + compare(common_init.theme.type, Theme3D.ThemeUserDefined, "theme") + compare(common_init.renderingMode, AbstractGraph3D.RenderIndirect, "renderingMode") + compare(common_init.measureFps, true, "measureFps") + compare(common_init.customItemList.length, 0, "customItemList") + compare(common_init.orthoProjection, false, "orthoProjection") + compare(common_init.aspectRatio, 3.0, "aspectRatio") + compare(common_init.optimizationHints, AbstractGraph3D.OptimizationStatic, "optimizationHints") + compare(common_init.polar, false, "polar") + compare(common_init.radialLabelOffset, 2, "radialLabelOffset") + compare(common_init.horizontalAspectRatio, 0.2, "horizontalAspectRatio") + compare(common_init.reflection, true, "reflection") + compare(common_init.reflectivity, 0.1, "reflectivity") + compare(common_init.locale, Qt.locale("UK"), "locale") + compare(common_init.margin, 0.2, "margin") + } + } +} diff --git a/tests/auto/qmltest/scatter3d/tst_proxy.qml b/tests/auto/qmltest/scatter3d/tst_proxy.qml new file mode 100644 index 00000000..e6478f15 --- /dev/null +++ b/tests/auto/qmltest/scatter3d/tst_proxy.qml @@ -0,0 +1,134 @@ +/**************************************************************************** +** +** 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 +** +****************************************************************************/ + +import QtQuick 2.0 +import QtDataVisualization 1.2 +import QtTest 1.0 + +Item { + id: top + height: 150 + width: 150 + + ItemModelScatterDataProxy { + id: initial + } + + ItemModelScatterDataProxy { + id: initialized + + itemModel: ListModel { objectName: "model1" } + rotationRole: "rot" + rotationRolePattern: /-/ + rotationRoleReplace: "\\1" + xPosRole: "x" + xPosRolePattern: /^.*-(\d\d)$/ + xPosRoleReplace: "\\1" + yPosRole: "y" + yPosRolePattern: /^(\d\d\d\d).*$/ + yPosRoleReplace: "\\1" + zPosRole: "z" + zPosRolePattern: /-/ + zPosRoleReplace: "\\1" + } + + ItemModelScatterDataProxy { + id: change + } + + TestCase { + name: "ItemModelScatterDataProxy Initial" + + function test_initial() { + verify(!initial.itemModel) + compare(initial.rotationRole, "") + verify(initial.rotationRolePattern) + compare(initial.rotationRoleReplace, "") + compare(initial.xPosRole, "") + verify(initial.xPosRolePattern) + compare(initial.xPosRoleReplace, "") + compare(initial.yPosRole, "") + verify(initial.yPosRolePattern) + compare(initial.yPosRoleReplace, "") + compare(initial.zPosRole, "") + verify(initial.zPosRolePattern) + compare(initial.zPosRoleReplace, "") + + compare(initial.itemCount, 0) + verify(!initial.series) + + compare(initial.type, AbstractDataProxy.DataTypeScatter) + } + } + + TestCase { + name: "ItemModelScatterDataProxy Initialized" + + function test_initialized() { + compare(initialized.itemModel.objectName, "model1") + compare(initialized.rotationRole, "rot") + compare(initialized.rotationRolePattern, /-/) + compare(initialized.rotationRoleReplace, "\\1") + compare(initialized.xPosRole, "x") + compare(initialized.xPosRolePattern, /^.*-(\d\d)$/) + compare(initialized.xPosRoleReplace, "\\1") + compare(initialized.yPosRole, "y") + compare(initialized.yPosRolePattern, /^(\d\d\d\d).*$/) + compare(initialized.yPosRoleReplace, "\\1") + compare(initialized.zPosRole, "z") + compare(initialized.zPosRolePattern, /-/) + compare(initialized.zPosRoleReplace, "\\1") + } + } + + TestCase { + name: "ItemModelScatterDataProxy Change" + + ListModel { id: model1; objectName: "model1" } + + function test_change() { + change.itemModel = model1 + change.rotationRole = "rot" + change.rotationRolePattern = /-/ + change.rotationRoleReplace = "\\1" + change.xPosRole = "x" + change.xPosRolePattern = /^.*-(\d\d)$/ + change.xPosRoleReplace = "\\1" + change.yPosRole = "y" + change.yPosRolePattern = /^(\d\d\d\d).*$/ + change.yPosRoleReplace = "\\1" + change.zPosRole = "z" + change.zPosRolePattern = /-/ + change.zPosRoleReplace = "\\1" + + compare(change.itemModel.objectName, "model1") + compare(change.rotationRole, "rot") + compare(change.rotationRolePattern, /-/) + compare(change.rotationRoleReplace, "\\1") + compare(change.xPosRole, "x") + compare(change.xPosRolePattern, /^.*-(\d\d)$/) + compare(change.xPosRoleReplace, "\\1") + compare(change.yPosRole, "y") + compare(change.yPosRolePattern, /^(\d\d\d\d).*$/) + compare(change.yPosRoleReplace, "\\1") + compare(change.zPosRole, "z") + compare(change.zPosRolePattern, /-/) + compare(change.zPosRoleReplace, "\\1") + } + } +} diff --git a/tests/auto/qmltest/scatter3d/tst_scatter.qml b/tests/auto/qmltest/scatter3d/tst_scatter.qml new file mode 100644 index 00000000..b070b5f0 --- /dev/null +++ b/tests/auto/qmltest/scatter3d/tst_scatter.qml @@ -0,0 +1,60 @@ +/**************************************************************************** +** +** 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 +** +****************************************************************************/ + +import QtQuick 2.0 +import QtDataVisualization 1.2 +import QtTest 1.0 + +Item { + id: top + height: 150 + width: 150 + + Scatter3D { + id: series + anchors.fill: parent + } + + TestCase { + name: "Scatter3D Series" + + Scatter3DSeries { id: series1 } + Scatter3DSeries { id: series2 } + + function test_1_add_series() { + series.seriesList = [series1, series2] + compare(series.seriesList.length, 2) + } + + function test_2_remove_series() { + series.seriesList = [series1] + compare(series.seriesList.length, 1) + } + + function test_3_remove_series() { + series.seriesList = [] + compare(series.seriesList.length, 0) + } + + function test_4_selected_series() { + series.seriesList = [series1, series2] + series.seriesList[0].selectedItem = 0 + compare(series.selectedSeries, series1) + } + } +} diff --git a/tests/auto/qmltest/scatter3d/tst_scatterseries.qml b/tests/auto/qmltest/scatter3d/tst_scatterseries.qml new file mode 100644 index 00000000..4df58303 --- /dev/null +++ b/tests/auto/qmltest/scatter3d/tst_scatterseries.qml @@ -0,0 +1,233 @@ +/**************************************************************************** +** +** 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 +** +****************************************************************************/ + +import QtQuick 2.0 +import QtDataVisualization 1.2 +import QtTest 1.0 + +Item { + id: top + height: 150 + width: 150 + + Scatter3DSeries { + id: initial + } + + ColorGradient { + id: gradient1; + stops: [ + ColorGradientStop { color: "red"; position: 0 }, + ColorGradientStop { color: "blue"; position: 1 } + ] + } + + ColorGradient { + id: gradient2; + stops: [ + ColorGradientStop { color: "green"; position: 0 }, + ColorGradientStop { color: "red"; position: 1 } + ] + } + + ColorGradient { + id: gradient3; + stops: [ + ColorGradientStop { color: "gray"; position: 0 }, + ColorGradientStop { color: "darkgray"; position: 1 } + ] + } + + Scatter3DSeries { + id: initialized + dataProxy: ItemModelScatterDataProxy { + itemModel: ListModel { + ListElement{ xPos: "2.754"; yPos: "1.455"; zPos: "3.362"; } + ListElement{ xPos: "3.164"; yPos: "2.022"; zPos: "4.348"; } + } + xPosRole: "xPos" + yPosRole: "yPos" + zPosRole: "zPos" + } + itemSize: 0.5 + selectedItem: 0 + + baseColor: "blue" + baseGradient: gradient1 + colorStyle: Theme3D.ColorStyleObjectGradient + itemLabelFormat: "%f" + itemLabelVisible: false + mesh: Abstract3DSeries.MeshMinimal + meshRotation: Qt.quaternion(1, 1, 1, 1) + meshSmooth: true + multiHighlightColor: "green" + multiHighlightGradient: gradient2 + name: "series1" + singleHighlightColor: "red" + singleHighlightGradient: gradient3 + userDefinedMesh: ":/customitem.obj" + visible: false + } + + ItemModelScatterDataProxy { + id: proxy1 + itemModel: ListModel { + ListElement{ xPos: "2.754"; yPos: "1.455"; zPos: "3.362"; } + ListElement{ xPos: "3.164"; yPos: "2.022"; zPos: "4.348"; } + ListElement{ xPos: "4.564"; yPos: "1.865"; zPos: "1.346"; } + } + xPosRole: "xPos" + yPosRole: "yPos" + zPosRole: "zPos" + } + + Scatter3DSeries { + id: change + } + + Scatter3DSeries { + id: invalid + } + + TestCase { + name: "Scatter3DSeries Initial" + + function test_1_initial() { + compare(initial.dataProxy.itemCount, 0) + compare(initial.invalidSelectionIndex, -1) + compare(initial.itemSize, 0.0) + compare(initial.selectedItem, -1) + } + + function test_2_initial_common() { + // Common properties + compare(initial.baseColor, "#000000") + compare(initial.baseGradient, null) + compare(initial.colorStyle, Theme3D.ColorStyleUniform) + compare(initial.itemLabel, "") + compare(initial.itemLabelFormat, "@xLabel, @yLabel, @zLabel") + compare(initial.itemLabelVisible, true) + compare(initial.mesh, Abstract3DSeries.MeshSphere) + compare(initial.meshRotation, Qt.quaternion(1, 0, 0, 0)) + compare(initial.meshSmooth, false) + compare(initial.multiHighlightColor, "#000000") + compare(initial.multiHighlightGradient, null) + compare(initial.name, "") + compare(initial.singleHighlightColor, "#000000") + compare(initial.singleHighlightGradient, null) + compare(initial.type, Abstract3DSeries.SeriesTypeScatter) + compare(initial.userDefinedMesh, "") + compare(initial.visible, true) + } + } + + TestCase { + name: "Scatter3DSeries Initialized" + + function test_1_initialized() { + compare(initialized.dataProxy.itemCount, 2) + compare(initialized.itemSize, 0.5) + compare(initialized.selectedItem, 0) + } + + function test_2_initialized_common() { + // Common properties + compare(initialized.baseColor, "#0000ff") + compare(initialized.baseGradient, gradient1) + compare(initialized.colorStyle, Theme3D.ColorStyleObjectGradient) + compare(initialized.itemLabelFormat, "%f") + compare(initialized.itemLabelVisible, false) + compare(initialized.mesh, Abstract3DSeries.MeshMinimal) + compare(initialized.meshRotation, Qt.quaternion(1, 1, 1, 1)) + compare(initialized.meshSmooth, true) + compare(initialized.multiHighlightColor, "#008000") + compare(initialized.multiHighlightGradient, gradient2) + compare(initialized.name, "series1") + compare(initialized.singleHighlightColor, "#ff0000") + compare(initialized.singleHighlightGradient, gradient3) + compare(initialized.userDefinedMesh, ":/customitem.obj") + compare(initialized.visible, false) + } + } + + TestCase { + name: "Scatter3DSeries Change" + + function test_1_change() { + change.dataProxy = proxy1 + change.itemSize = 0.5 + change.selectedItem = 0 + } + + function test_2_test_change() { + // This test has a dependency to the previous one due to asynchronous item model resolving + compare(change.dataProxy.itemCount, 3) + compare(change.itemSize, 0.5) + compare(change.selectedItem, 0) + } + + function test_3_change_common() { + change.baseColor = "blue" + change.baseGradient = gradient1 + change.colorStyle = Theme3D.ColorStyleObjectGradient + change.itemLabelFormat = "%f" + change.itemLabelVisible = false + change.mesh = Abstract3DSeries.MeshMinimal + change.meshRotation = Qt.quaternion(1, 1, 1, 1) + change.meshSmooth = true + change.multiHighlightColor = "green" + change.multiHighlightGradient = gradient2 + change.name = "series1" + change.singleHighlightColor = "red" + change.singleHighlightGradient = gradient3 + change.userDefinedMesh = ":/customitem.obj" + change.visible = false + + compare(change.baseColor, "#0000ff") + compare(change.baseGradient, gradient1) + compare(change.colorStyle, Theme3D.ColorStyleObjectGradient) + compare(change.itemLabelFormat, "%f") + compare(change.itemLabelVisible, false) + compare(change.mesh, Abstract3DSeries.MeshMinimal) + compare(change.meshRotation, Qt.quaternion(1, 1, 1, 1)) + compare(change.meshSmooth, true) + compare(change.multiHighlightColor, "#008000") + compare(change.multiHighlightGradient, gradient2) + compare(change.name, "series1") + compare(change.singleHighlightColor, "#ff0000") + compare(change.singleHighlightGradient, gradient3) + compare(change.userDefinedMesh, ":/customitem.obj") + compare(change.visible, false) + } + + function test_4_change_gradient_stop() { + gradient1.stops[0].color = "yellow" + compare(change.baseGradient.stops[0].color, "#ffff00") + } + } + TestCase { + name: "Scatter3DSeries Invalid" + + function test_invalid() { + invalid.itemSize = -1.0 + compare(invalid.itemSize, 0.0) + invalid.itemSize = 1.1 + compare(invalid.itemSize, 0.0) + } + } +} diff --git a/tests/auto/qmltest/scene3d/tst_camera.qml b/tests/auto/qmltest/scene3d/tst_camera.qml new file mode 100644 index 00000000..07adf633 --- /dev/null +++ b/tests/auto/qmltest/scene3d/tst_camera.qml @@ -0,0 +1,135 @@ +/**************************************************************************** +** +** 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 +** +****************************************************************************/ + +import QtQuick 2.0 +import QtDataVisualization 1.2 +import QtTest 1.0 + +Item { + id: top + width: 150 + height: 150 + + Camera3D { + id: initial + } + + Camera3D { + id: initialized + maxZoomLevel: 1000.0 + minZoomLevel: 100.0 + target: Qt.vector3d(1.0, -1.0, 1.0) + wrapXRotation: false + wrapYRotation: true + xRotation: 30.0 + yRotation: 30.0 + zoomLevel: 500.0 + } + + Camera3D { + id: change + } + + Camera3D { + id: invalid + } + + TestCase { + name: "Camera3D Initial" + + function test_initial() { + compare(initial.cameraPreset, Camera3D.CameraPresetNone) + compare(initial.maxZoomLevel, 500.0) + compare(initial.minZoomLevel, 10.0) + compare(initial.target, Qt.vector3d(0.0, 0.0, 0.0)) + compare(initial.wrapXRotation, true) + compare(initial.wrapYRotation, false) + compare(initial.xRotation, 0.0) + compare(initial.yRotation, 0.0) + compare(initial.zoomLevel, 100.0) + } + } + + TestCase { + name: "Camera3D Initialized" + + function test_initialized() { + compare(initialized.maxZoomLevel, 1000.0) + compare(initialized.minZoomLevel, 100.0) + compare(initialized.target, Qt.vector3d(1.0, -1.0, 1.0)) + compare(initialized.wrapXRotation, false) + compare(initialized.wrapYRotation, true) + compare(initialized.xRotation, 30.0) + compare(initialized.yRotation, 30.0) + compare(initialized.zoomLevel, 500.0) + } + } + + TestCase { + name: "Camera3D Change" + + function test_1_change() { + change.cameraPreset = Camera3D.CameraPresetBehind // Will be overridden by the the following sets + change.maxZoomLevel = 1000.0 + change.minZoomLevel = 100.0 + change.target = Qt.vector3d(1.0, -1.0, 1.0) + change.wrapXRotation = false + change.wrapYRotation = true + change.xRotation = 30.0 + change.yRotation = 30.0 + change.zoomLevel = 500.0 + + compare(change.cameraPreset, Camera3D.CameraPresetNone) + compare(change.maxZoomLevel, 1000.0) + compare(change.minZoomLevel, 100.0) + compare(change.target, Qt.vector3d(1.0, -1.0, 1.0)) + compare(change.wrapXRotation, false) + compare(change.wrapYRotation, true) + compare(change.xRotation, 30.0) + compare(change.yRotation, 30.0) + compare(change.zoomLevel, 500.0) + } + + function test_2_change_preset() { + change.cameraPreset = Camera3D.CameraPresetBehind // Sets target and rotations + + compare(change.cameraPreset, Camera3D.CameraPresetBehind) + compare(change.maxZoomLevel, 1000.0) + compare(change.minZoomLevel, 100.0) + compare(change.target, Qt.vector3d(0.0, 0.0, 0.0)) + compare(change.wrapXRotation, false) + compare(change.wrapYRotation, true) + compare(change.xRotation, 180.0) + compare(change.yRotation, 22.5) + compare(change.zoomLevel, 500.0) + } + } + + TestCase { + name: "Camera3D Invalid" + + function test_invalid() { + invalid.target = Qt.vector3d(-1.5, -1.5, -1.5) + compare(invalid.target, Qt.vector3d(-1.0, -1.0, -1.0)) + invalid.target = Qt.vector3d(1.5, 1.5, 1.5) + compare(invalid.target, Qt.vector3d(1.0, 1.0, 1.0)) + invalid.minZoomLevel = 0.1 + compare(invalid.minZoomLevel, 1.0) + } + } +} diff --git a/tests/auto/qmltest/scene3d/tst_light.qml b/tests/auto/qmltest/scene3d/tst_light.qml new file mode 100644 index 00000000..d9fa282b --- /dev/null +++ b/tests/auto/qmltest/scene3d/tst_light.qml @@ -0,0 +1,65 @@ +/**************************************************************************** +** +** 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 +** +****************************************************************************/ + +import QtQuick 2.0 +import QtDataVisualization 1.2 +import QtTest 1.0 + +Item { + id: top + height: 150 + width: 150 + + // TODO: Has no adjustable properties yet. + // Keeping this as a placeholder for future implementations (QTRD-2406) + /* + Light3D { + id: initial + } + + Light3D { + id: initialized + } + + + Light3D { + id: change + } + + TestCase { + name: "Light3D Initial" + + function test_initial() { + } + } + + TestCase { + name: "Light3D Initialized" + + function test_initialized() { + } + } + + TestCase { + name: "Light3D Change" + + function test_change() { + } + } + */ +} diff --git a/tests/auto/qmltest/scene3d/tst_scene.qml b/tests/auto/qmltest/scene3d/tst_scene.qml new file mode 100644 index 00000000..d53042ca --- /dev/null +++ b/tests/auto/qmltest/scene3d/tst_scene.qml @@ -0,0 +1,125 @@ +/**************************************************************************** +** +** 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 +** +****************************************************************************/ + +import QtQuick 2.0 +import QtDataVisualization 1.2 +import QtTest 1.0 + +Item { + id: top + height: 150 + width: 150 + + // Scene3D is uncreatable, so it needs to be accessed via a graph + Bars3D { + id: initial + } + + Bars3D { + id: initialized + scene.activeCamera: Camera3D { zoomLevel: 200 } + scene.devicePixelRatio: 2.0 + //scene.graphPositionQuery: Qt.point(0, 0) // TODO: Unusable until QTBUG-40043 is fixed + scene.primarySubViewport: Qt.rect(0, 0, 50, 50) + scene.secondarySubViewport: Qt.rect(50, 50, 100, 100) + scene.secondarySubviewOnTop: false + scene.selectionQueryPosition: Qt.point(0, 0) + scene.slicingActive: true + } + + Bars3D { + id: change + } + + Bars3D { + id: invalid + } + + TestCase { + name: "Scene3D Initial" + + function test_initial() { + verify(initial.scene.activeCamera) + verify(initial.scene.activeLight) + compare(initial.scene.devicePixelRatio, 1.0) + compare(initial.scene.graphPositionQuery, Qt.point(-1, -1)) + compare(initial.scene.invalidSelectionPoint, Qt.point(-1, -1)) + compare(initial.scene.primarySubViewport, Qt.rect(0, 0, 0, 0)) + compare(initial.scene.secondarySubViewport, Qt.rect(0, 0, 0, 0)) + compare(initial.scene.secondarySubviewOnTop, true) + compare(initial.scene.selectionQueryPosition, Qt.point(-1, -1)) + compare(initial.scene.slicingActive, false) + compare(initial.scene.viewport, Qt.rect(0, 0, 0, 0)) + } + } + + TestCase { + name: "Scene3D Initialized" + + function test_initialized() { + compare(initialized.scene.activeCamera.zoomLevel, 200) + compare(initialized.scene.devicePixelRatio, 2.0) + //compare(initialized.scene.graphPositionQuery, Qt.point(0, 0)) // TODO: Unusable until QTBUG-40043 is fixed + compare(initialized.scene.primarySubViewport, Qt.rect(0, 0, 50, 50)) + compare(initialized.scene.secondarySubViewport, Qt.rect(50, 50, 100, 100)) + compare(initialized.scene.secondarySubviewOnTop, false) + compare(initialized.scene.selectionQueryPosition, Qt.point(0, 0)) + compare(initialized.scene.slicingActive, true) + compare(initialized.scene.viewport, Qt.rect(0, 0, 100, 100)) + } + } + + TestCase { + name: "Scene3D Change" + + Camera3D { + id: camera1 + zoomLevel: 200 + } + + function test_change() { + change.scene.activeCamera = camera1 + change.scene.devicePixelRatio = 2.0 + change.scene.graphPositionQuery = Qt.point(0, 0) + change.scene.primarySubViewport = Qt.rect(0, 0, 50, 50) + change.scene.secondarySubViewport = Qt.rect(50, 50, 100, 100) + change.scene.secondarySubviewOnTop = false + change.scene.selectionQueryPosition = Qt.point(0, 0) // TODO: When doing signal checks, add tests to check that queries return something (asynchronously) + change.scene.slicingActive = true + + compare(change.scene.activeCamera.zoomLevel, 200) + compare(change.scene.devicePixelRatio, 2.0) + compare(change.scene.graphPositionQuery, Qt.point(0, 0)) + compare(change.scene.primarySubViewport, Qt.rect(0, 0, 50, 50)) + compare(change.scene.secondarySubViewport, Qt.rect(50, 50, 100, 100)) + compare(change.scene.secondarySubviewOnTop, false) + compare(change.scene.selectionQueryPosition, Qt.point(0, 0)) + compare(change.scene.slicingActive, true) + compare(change.scene.viewport, Qt.rect(0, 0, 100, 100)) + } + } + + TestCase { + name: "Scene3D Invalid" + + function test_invalid() { + invalid.scene.primarySubViewport = Qt.rect(0, 0, -50, -50) + compare(invalid.scene.primarySubViewport, Qt.rect(0, 0, 0, 0)) + } + } +} diff --git a/tests/auto/qmltest/surface3d/tst_basic.qml b/tests/auto/qmltest/surface3d/tst_basic.qml new file mode 100644 index 00000000..dfcc4542 --- /dev/null +++ b/tests/auto/qmltest/surface3d/tst_basic.qml @@ -0,0 +1,211 @@ +/**************************************************************************** +** +** 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 +** +****************************************************************************/ + +import QtQuick 2.0 +import QtDataVisualization 1.2 +import QtTest 1.0 + +Item { + id: top + height: 150 + width: 150 + + Surface3D { + id: empty + } + + Surface3D { + id: basic + anchors.fill: parent + flipHorizontalGrid: true + } + + Surface3D { + id: common + anchors.fill: parent + } + + Surface3D { + id: common_init + anchors.fill: parent + selectionMode: AbstractGraph3D.SelectionNone + shadowQuality: AbstractGraph3D.ShadowQualityLow + msaaSamples: 2 + theme: Theme3D { } + renderingMode: AbstractGraph3D.RenderIndirect + measureFps: true + orthoProjection: false + aspectRatio: 3.0 + optimizationHints: AbstractGraph3D.OptimizationStatic + polar: false + radialLabelOffset: 2 + horizontalAspectRatio: 0.2 + reflection: true + reflectivity: 0.1 + locale: Qt.locale("UK") + margin: 0.2 + } + + TestCase { + name: "Surface3D Empty" + + function test_empty() { + compare(empty.width, 0, "width") + compare(empty.height, 0, "height") + compare(empty.seriesList.length, 0, "seriesList") + compare(empty.selectedSeries, null, "selectedSeries") + compare(empty.flipHorizontalGrid, false, "flipHorizontalGrid") + compare(empty.axisX.orientation, AbstractAxis3D.AxisOrientationX) + compare(empty.axisZ.orientation, AbstractAxis3D.AxisOrientationZ) + compare(empty.axisY.orientation, AbstractAxis3D.AxisOrientationY) + compare(empty.axisX.type, AbstractAxis3D.AxisTypeValue) + compare(empty.axisZ.type, AbstractAxis3D.AxisTypeValue) + compare(empty.axisY.type, AbstractAxis3D.AxisTypeValue) + } + } + + TestCase { + name: "Surface3D Basic" + when: windowShown + + function test_basic() { + compare(basic.width, 150, "width") + compare(basic.height, 150, "height") + compare(basic.flipHorizontalGrid, true, "flipHorizontalGrid") + } + + function test_change_basic() { + basic.flipHorizontalGrid = false + compare(basic.flipHorizontalGrid, false, "flipHorizontalGrid") + } + } + + TestCase { + name: "Surface3D Common" + when: windowShown + + function test_1_common() { + compare(common.selectionMode, AbstractGraph3D.SelectionItem, "selectionMode") + compare(common.shadowQuality, AbstractGraph3D.ShadowQualityMedium, "shadowQuality") + if (common.shadowsSupported === true) + compare(common.msaaSamples, 4, "msaaSamples") + else + compare(common.msaaSamples, 0, "msaaSamples") + compare(common.theme.type, Theme3D.ThemeQt, "theme") + compare(common.renderingMode, AbstractGraph3D.RenderIndirect, "renderingMode") + compare(common.measureFps, false, "measureFps") + compare(common.customItemList.length, 0, "customItemList") + compare(common.orthoProjection, false, "orthoProjection") + compare(common.selectedElement, AbstractGraph3D.ElementNone, "selectedElement") + compare(common.aspectRatio, 2.0, "aspectRatio") + compare(common.optimizationHints, AbstractGraph3D.OptimizationDefault, "optimizationHints") + compare(common.polar, false, "polar") + compare(common.radialLabelOffset, 1, "radialLabelOffset") + compare(common.horizontalAspectRatio, 0, "horizontalAspectRatio") + compare(common.reflection, false, "reflection") + compare(common.reflectivity, 0.5, "reflectivity") + compare(common.locale, Qt.locale("C"), "locale") + compare(common.queriedGraphPosition, Qt.vector3d(0, 0, 0), "queriedGraphPosition") + compare(common.margin, -1, "margin") + } + + function test_2_change_common() { + common.selectionMode = AbstractGraph3D.SelectionItem | AbstractGraph3D.SelectionRow | AbstractGraph3D.SelectionSlice + common.shadowQuality = AbstractGraph3D.ShadowQualitySoftHigh + compare(common.shadowQuality, AbstractGraph3D.ShadowQualitySoftHigh, "shadowQuality") + common.msaaSamples = 8 + if (common.shadowsSupported === true) + compare(common.msaaSamples, 8, "msaaSamples") + else + compare(common.msaaSamples, 0, "msaaSamples") + common.theme.type = Theme3D.ThemeRetro + common.renderingMode = AbstractGraph3D.RenderDirectToBackground_NoClear + common.measureFps = true + common.orthoProjection = true + common.aspectRatio = 1.0 + common.optimizationHints = AbstractGraph3D.OptimizationStatic + common.polar = true + common.radialLabelOffset = 2 + common.horizontalAspectRatio = 1 + common.reflection = true + common.reflectivity = 1.0 + common.locale = Qt.locale("FI") + common.margin = 1.0 + compare(common.selectionMode, AbstractGraph3D.SelectionItem | AbstractGraph3D.SelectionRow | AbstractGraph3D.SelectionSlice, "selectionMode") + compare(common.shadowQuality, AbstractGraph3D.ShadowQualityNone, "shadowQuality") // Ortho disables shadows + compare(common.msaaSamples, 0, "msaaSamples") // Rendering mode changes this to zero + compare(common.theme.type, Theme3D.ThemeRetro, "theme") + compare(common.renderingMode, AbstractGraph3D.RenderDirectToBackground_NoClear, "renderingMode") + compare(common.measureFps, true, "measureFps") + compare(common.orthoProjection, true, "orthoProjection") + compare(common.aspectRatio, 1.0, "aspectRatio") + compare(common.optimizationHints, AbstractGraph3D.OptimizationStatic, "optimizationHints") + compare(common.polar, true, "polar") + compare(common.radialLabelOffset, 2, "radialLabelOffset") + compare(common.horizontalAspectRatio, 1, "horizontalAspectRatio") + compare(common.reflection, true, "reflection") + compare(common.reflectivity, 1.0, "reflectivity") + compare(common.locale, Qt.locale("FI"), "locale") + compare(common.margin, 1.0, "margin") + } + + function test_3_change_invalid_common() { + common.selectionMode = AbstractGraph3D.SelectionRow | AbstractGraph3D.SelectionColumn | AbstractGraph3D.SelectionSlice + common.theme.type = -2 + common.renderingMode = -1 + common.measureFps = false + common.orthoProjection = false + common.aspectRatio = -1.0 + common.polar = false + common.horizontalAspectRatio = -2 + common.reflection = false + common.reflectivity = -1.0 + compare(common.selectionMode, AbstractGraph3D.SelectionItem | AbstractGraph3D.SelectionRow | AbstractGraph3D.SelectionSlice, "selectionMode") + compare(common.theme.type, -2/*Theme3D.ThemeRetro*/, "theme") // TODO: Fix once QTRD-3367 is done + compare(common.renderingMode, -1/*AbstractGraph3D.RenderDirectToBackground_NoClear*/, "renderingMode") // TODO: Fix once QTRD-3367 is done + compare(common.aspectRatio, -1.0/*1.0*/, "aspectRatio") // TODO: Fix once QTRD-3367 is done + compare(common.horizontalAspectRatio, -2/*1*/, "horizontalAspectRatio") // TODO: Fix once QTRD-3367 is done + compare(common.reflectivity, -1.0/*1.0*/, "reflectivity") // TODO: Fix once QTRD-3367 is done + } + + function test_4_common_initialized() { + compare(common_init.selectionMode, AbstractGraph3D.SelectionNone, "selectionMode") + if (common_init.shadowsSupported === true) { + compare(common_init.shadowQuality, AbstractGraph3D.ShadowQualityLow, "shadowQuality") + compare(common_init.msaaSamples, 2, "msaaSamples") + } else { + compare(common_init.shadowQuality, AbstractGraph3D.ShadowQualityNone, "shadowQuality") + compare(common_init.msaaSamples, 0, "msaaSamples") + } + compare(common_init.theme.type, Theme3D.ThemeUserDefined, "theme") + compare(common_init.renderingMode, AbstractGraph3D.RenderIndirect, "renderingMode") + compare(common_init.measureFps, true, "measureFps") + compare(common_init.customItemList.length, 0, "customItemList") + compare(common_init.orthoProjection, false, "orthoProjection") + compare(common_init.aspectRatio, 3.0, "aspectRatio") + compare(common_init.optimizationHints, AbstractGraph3D.OptimizationStatic, "optimizationHints") + compare(common_init.polar, false, "polar") + compare(common_init.radialLabelOffset, 2, "radialLabelOffset") + compare(common_init.horizontalAspectRatio, 0.2, "horizontalAspectRatio") + compare(common_init.reflection, true, "reflection") + compare(common_init.reflectivity, 0.1, "reflectivity") + compare(common_init.locale, Qt.locale("UK"), "locale") + compare(common_init.margin, 0.2, "margin") + } + } +} diff --git a/tests/auto/qmltest/surface3d/tst_heightproxy.qml b/tests/auto/qmltest/surface3d/tst_heightproxy.qml new file mode 100644 index 00000000..29772451 --- /dev/null +++ b/tests/auto/qmltest/surface3d/tst_heightproxy.qml @@ -0,0 +1,116 @@ +/**************************************************************************** +** +** 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 +** +****************************************************************************/ + +import QtQuick 2.0 +import QtDataVisualization 1.2 +import QtTest 1.0 + +Item { + id: top + height: 150 + width: 150 + + HeightMapSurfaceDataProxy { + id: initial + } + + HeightMapSurfaceDataProxy { + id: initialized + heightMapFile: ":/customtexture.jpg" + maxXValue: 10.0 + maxZValue: 10.0 + minXValue: -10.0 + minZValue: -10.0 + } + + HeightMapSurfaceDataProxy { + id: change + } + + HeightMapSurfaceDataProxy { + id: invalid + } + + TestCase { + name: "HeightMapSurfaceDataProxy Initial" + + function test_initial() { + compare(initial.heightMapFile, "") + compare(initial.maxXValue, 10.0) + compare(initial.maxZValue, 10.0) + compare(initial.minXValue, 0) + compare(initial.minZValue, 0) + + compare(initial.columnCount, 0) + compare(initial.rowCount, 0) + verify(!initial.series) + + compare(initial.type, AbstractDataProxy.DataTypeSurface) + } + } + + TestCase { + name: "HeightMapSurfaceDataProxy Initialized" + + function test_initialized() { + compare(initialized.heightMapFile, ":/customtexture.jpg") + compare(initialized.maxXValue, 10.0) + compare(initialized.maxZValue, 10.0) + compare(initialized.minXValue, -10.0) + compare(initialized.minZValue, -10.0) + + compare(initialized.columnCount, 24) + compare(initialized.rowCount, 24) + } + } + + TestCase { + name: "HeightMapSurfaceDataProxy Change" + + function test_1_change() { + change.heightMapFile = ":/customtexture.jpg" + change.maxXValue = 10.0 + change.maxZValue = 10.0 + change.minXValue = -10.0 + change.minZValue = -10.0 + } + + function test_2_test_change() { + // This test has a dependency to the previous one due to asynchronous item model resolving + compare(change.heightMapFile, ":/customtexture.jpg") + compare(change.maxXValue, 10.0) + compare(change.maxZValue, 10.0) + compare(change.minXValue, -10.0) + compare(change.minZValue, -10.0) + + compare(change.columnCount, 24) + compare(change.rowCount, 24) + } + } + + TestCase { + name: "HeightMapSurfaceDataProxy Invalid" + + function test_invalid() { + invalid.maxXValue = -10 + compare(invalid.minXValue, -11) + invalid.minZValue = 20 + compare(invalid.maxZValue, 21) + } + } +} diff --git a/tests/auto/qmltest/surface3d/tst_proxy.qml b/tests/auto/qmltest/surface3d/tst_proxy.qml new file mode 100644 index 00000000..8f353153 --- /dev/null +++ b/tests/auto/qmltest/surface3d/tst_proxy.qml @@ -0,0 +1,263 @@ +/**************************************************************************** +** +** 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 +** +****************************************************************************/ + +import QtQuick 2.0 +import QtDataVisualization 1.2 +import QtTest 1.0 + +Item { + id: top + height: 150 + width: 150 + + ItemModelSurfaceDataProxy { + id: initial + } + + ItemModelSurfaceDataProxy { + id: initialized + + autoColumnCategories: false + autoRowCategories: false + columnCategories: ["colcat1", "colcat2"] + columnRole: "col" + columnRolePattern: /^.*-(\d\d)$/ + columnRoleReplace: "\\1" + itemModel: ListModel { objectName: "model1" } + multiMatchBehavior: ItemModelSurfaceDataProxy.MMBAverage + rowCategories: ["rowcat1", "rowcat2"] + rowRole: "row" + rowRolePattern: /^(\d\d\d\d).*$/ + rowRoleReplace: "\\1" + xPosRole: "x" + xPosRolePattern: /^.*-(\d\d)$/ + xPosRoleReplace: "\\1" + yPosRole: "y" + yPosRolePattern: /^(\d\d\d\d).*$/ + yPosRoleReplace: "\\1" + zPosRole: "z" + zPosRolePattern: /-/ + zPosRoleReplace: "\\1" + } + + ItemModelSurfaceDataProxy { + id: change + } + + TestCase { + name: "ItemModelSurfaceDataProxy Initial" + + function test_initial() { + compare(initial.autoColumnCategories, true) + compare(initial.autoRowCategories, true) + compare(initial.columnCategories, []) + compare(initial.columnRole, "") + verify(initial.columnRolePattern) + compare(initial.columnRoleReplace, "") + verify(!initial.itemModel) + compare(initial.multiMatchBehavior, ItemModelSurfaceDataProxy.MMBLast) + compare(initial.rowCategories, []) + compare(initial.rowRole, "") + verify(initial.rowRolePattern) + compare(initial.rowRoleReplace, "") + compare(initial.useModelCategories, false) + compare(initial.xPosRole, "") + verify(initial.xPosRolePattern) + compare(initial.xPosRoleReplace, "") + compare(initial.yPosRole, "") + verify(initial.yPosRolePattern) + compare(initial.yPosRoleReplace, "") + compare(initial.zPosRole, "") + verify(initial.zPosRolePattern) + compare(initial.zPosRoleReplace, "") + + compare(initial.columnCount, 0) + compare(initial.rowCount, 0) + verify(!initial.series) + + compare(initial.type, AbstractDataProxy.DataTypeSurface) + } + } + + TestCase { + name: "ItemModelSurfaceDataProxy Initialized" + + function test_initialized() { + compare(initialized.autoColumnCategories, false) + compare(initialized.autoRowCategories, false) + compare(initialized.columnCategories.length, 2) + compare(initialized.columnCategories[0], "colcat1") + compare(initialized.columnCategories[1], "colcat2") + compare(initialized.columnRole, "col") + compare(initialized.columnRolePattern, /^.*-(\d\d)$/) + compare(initialized.columnRoleReplace, "\\1") + compare(initialized.itemModel.objectName, "model1") + compare(initialized.multiMatchBehavior, ItemModelSurfaceDataProxy.MMBAverage) + compare(initialized.rowCategories.length, 2) + compare(initialized.rowCategories[0], "rowcat1") + compare(initialized.rowCategories[1], "rowcat2") + compare(initialized.rowRole, "row") + compare(initialized.rowRolePattern, /^(\d\d\d\d).*$/) + compare(initialized.rowRoleReplace, "\\1") + compare(initialized.xPosRole, "x") + compare(initialized.xPosRolePattern, /^.*-(\d\d)$/) + compare(initialized.xPosRoleReplace, "\\1") + compare(initialized.yPosRole, "y") + compare(initialized.yPosRolePattern, /^(\d\d\d\d).*$/) + compare(initialized.yPosRoleReplace, "\\1") + compare(initialized.zPosRole, "z") + compare(initialized.zPosRolePattern, /-/) + compare(initialized.zPosRoleReplace, "\\1") + + compare(initialized.columnCount, 2) + compare(initialized.rowCount, 2) + } + } + + TestCase { + name: "ItemModelSurfaceDataProxy Change" + + ListModel { id: model1; objectName: "model1" } + + function test_1_change() { + change.autoColumnCategories = false + change.autoRowCategories = false + change.columnCategories = ["colcat1", "colcat2"] + change.columnRole = "col" + change.columnRolePattern = /^.*-(\d\d)$/ + change.columnRoleReplace = "\\1" + change.itemModel = model1 + change.multiMatchBehavior = ItemModelSurfaceDataProxy.MMBAverage + change.rowCategories = ["rowcat1", "rowcat2"] + change.rowRole = "row" + change.rowRolePattern = /^(\d\d\d\d).*$/ + change.rowRoleReplace = "\\1" + change.useModelCategories = true // Overwrites columnLabels and rowLabels + change.xPosRole = "x" + change.xPosRolePattern = /^.*-(\d\d)$/ + change.xPosRoleReplace = "\\1" + change.yPosRole = "y" + change.yPosRolePattern = /^(\d\d\d\d).*$/ + change.yPosRoleReplace = "\\1" + change.zPosRole = "z" + change.zPosRolePattern = /-/ + change.zPosRoleReplace = "\\1" + } + + function test_2_test_change() { + // This test has a dependency to the previous one due to asynchronous item model resolving + compare(change.autoColumnCategories, false) + compare(change.autoRowCategories, false) + compare(change.columnCategories.length, 2) + compare(change.columnCategories[0], "colcat1") + compare(change.columnCategories[1], "colcat2") + compare(change.columnRole, "col") + compare(change.columnRolePattern, /^.*-(\d\d)$/) + compare(change.columnRoleReplace, "\\1") + compare(change.itemModel.objectName, "model1") + compare(change.multiMatchBehavior, ItemModelSurfaceDataProxy.MMBAverage) + compare(change.rowCategories.length, 2) + compare(change.rowCategories[0], "rowcat1") + compare(change.rowCategories[1], "rowcat2") + compare(change.rowRole, "row") + compare(change.rowRolePattern, /^(\d\d\d\d).*$/) + compare(change.rowRoleReplace, "\\1") + compare(change.useModelCategories, true) + compare(change.xPosRole, "x") + compare(change.xPosRolePattern, /^.*-(\d\d)$/) + compare(change.xPosRoleReplace, "\\1") + compare(change.yPosRole, "y") + compare(change.yPosRolePattern, /^(\d\d\d\d).*$/) + compare(change.yPosRoleReplace, "\\1") + compare(change.zPosRole, "z") + compare(change.zPosRolePattern, /-/) + compare(change.zPosRoleReplace, "\\1") + + compare(change.columnCount, 0) + compare(change.rowCount, 0) + } + } + + TestCase { + name: "ItemModelSurfaceDataProxy MultiMatchBehaviour" + + Surface3D { + id: surface1 + Surface3DSeries { + ItemModelSurfaceDataProxy { + id: surfaceProxy + itemModel: ListModel { + ListElement{ coords: "0,0"; data: "5"; } + ListElement{ coords: "0,0"; data: "15"; } + ListElement{ coords: "0,1"; data: "5"; } + ListElement{ coords: "0,1"; data: "15"; } + ListElement{ coords: "1,0"; data: "5"; } + ListElement{ coords: "1,0"; data: "15"; } + ListElement{ coords: "1,1"; data: "0"; } + } + rowRole: "coords" + columnRole: "coords" + yPosRole: "data" + rowRolePattern: /(\d),\d/ + columnRolePattern: /(\d),(\d)/ + rowRoleReplace: "\\1" + columnRoleReplace: "\\2" + } + } + } + + function test_0_async_dummy() { + } + + function test_1_test_multimatch() { + compare(surface1.axisY.max, 15) + } + + function test_2_multimatch() { + surfaceProxy.multiMatchBehavior = ItemModelSurfaceDataProxy.MMBFirst + } + + function test_3_test_multimatch() { + compare(surface1.axisY.max, 5) + } + + function test_4_multimatch() { + surfaceProxy.multiMatchBehavior = ItemModelSurfaceDataProxy.MMBLast + } + + function test_5_test_multimatch() { + compare(surface1.axisY.max, 15) + } + + function test_6_multimatch() { + surfaceProxy.multiMatchBehavior = ItemModelSurfaceDataProxy.MMBAverage + } + + function test_7_test_multimatch() { + compare(surface1.axisY.max, 10) + } + + function test_8_multimatch() { + surfaceProxy.multiMatchBehavior = ItemModelSurfaceDataProxy.MMBCumulativeY + } + + function test_9_test_multimatch() { + compare(surface1.axisY.max, 20) + } + } +} diff --git a/tests/auto/qmltest/surface3d/tst_surface.qml b/tests/auto/qmltest/surface3d/tst_surface.qml new file mode 100644 index 00000000..31c86da2 --- /dev/null +++ b/tests/auto/qmltest/surface3d/tst_surface.qml @@ -0,0 +1,60 @@ +/**************************************************************************** +** +** 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 +** +****************************************************************************/ + +import QtQuick 2.0 +import QtDataVisualization 1.2 +import QtTest 1.0 + +Item { + id: top + height: 150 + width: 150 + + Surface3D { + id: series + anchors.fill: parent + } + + TestCase { + name: "Surface3D Series" + + Surface3DSeries { id: series1 } + Surface3DSeries { id: series2 } + + function test_1_add_series() { + series.seriesList = [series1, series2] + compare(series.seriesList.length, 2) + } + + function test_2_remove_series() { + series.seriesList = [series1] + compare(series.seriesList.length, 1) + } + + function test_3_remove_series() { + series.seriesList = [] + compare(series.seriesList.length, 0) + } + + function test_4_selected_series() { + series.seriesList = [series1, series2] + series.seriesList[0].selectedPoint = Qt.point(0, 0) + compare(series.selectedSeries, series1) + } + } +} diff --git a/tests/auto/qmltest/surface3d/tst_surfaceseries.qml b/tests/auto/qmltest/surface3d/tst_surfaceseries.qml new file mode 100644 index 00000000..dff2e4a8 --- /dev/null +++ b/tests/auto/qmltest/surface3d/tst_surfaceseries.qml @@ -0,0 +1,229 @@ +/**************************************************************************** +** +** 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 +** +****************************************************************************/ + +import QtQuick 2.0 +import QtDataVisualization 1.2 +import QtTest 1.0 + +Item { + id: top + height: 150 + width: 150 + + Surface3DSeries { + id: initial + } + + ColorGradient { + id: gradient1; + stops: [ + ColorGradientStop { color: "red"; position: 0 }, + ColorGradientStop { color: "blue"; position: 1 } + ] + } + + ColorGradient { + id: gradient2; + stops: [ + ColorGradientStop { color: "green"; position: 0 }, + ColorGradientStop { color: "red"; position: 1 } + ] + } + + ColorGradient { + id: gradient3; + stops: [ + ColorGradientStop { color: "gray"; position: 0 }, + ColorGradientStop { color: "darkgray"; position: 1 } + ] + } + + Surface3DSeries { + id: initialized + dataProxy: ItemModelSurfaceDataProxy { + itemModel: ListModel { + ListElement{ longitude: "20"; latitude: "10"; pop_density: "4.75"; } + ListElement{ longitude: "21"; latitude: "10"; pop_density: "3.00"; } + } + rowRole: "longitude" + columnRole: "latitude" + yPosRole: "pop_density" + } + drawMode: Surface3DSeries.DrawSurface + flatShadingEnabled: false + selectedPoint: Qt.point(0, 0) + textureFile: ":\customtexture.jpg" + + baseColor: "blue" + baseGradient: gradient1 + colorStyle: Theme3D.ColorStyleObjectGradient + itemLabelFormat: "%f" + itemLabelVisible: false + mesh: Abstract3DSeries.MeshCube + meshRotation: Qt.quaternion(1, 1, 1, 1) + meshSmooth: true + multiHighlightColor: "green" + multiHighlightGradient: gradient2 + name: "series1" + singleHighlightColor: "red" + singleHighlightGradient: gradient3 + userDefinedMesh: ":/customitem.obj" + visible: false + } + + ItemModelSurfaceDataProxy { + id: proxy1 + itemModel: ListModel { + ListElement{ longitude: "20"; latitude: "10"; pop_density: "4.75"; } + ListElement{ longitude: "21"; latitude: "10"; pop_density: "3.00"; } + ListElement{ longitude: "22"; latitude: "10"; pop_density: "1.24"; } + } + rowRole: "longitude" + columnRole: "latitude" + yPosRole: "pop_density" + } + + Surface3DSeries { + id: change + } + + TestCase { + name: "Surface3DSeries Initial" + + function test_1_initial() { + compare(initial.dataProxy.rowCount, 0) + compare(initial.invalidSelectionPosition, Qt.point(-1, -1)) + compare(initial.drawMode, Surface3DSeries.DrawSurfaceAndWireframe) + compare(initial.flatShadingEnabled, true) + compare(initial.flatShadingSupported, true) + compare(initial.selectedPoint, Qt.point(-1, -1)) + } + + function test_2_initial_common() { + // Common properties + compare(initial.baseColor, "#000000") + compare(initial.baseGradient, null) + compare(initial.colorStyle, Theme3D.ColorStyleUniform) + compare(initial.itemLabel, "") + compare(initial.itemLabelFormat, "@xLabel, @yLabel, @zLabel") + compare(initial.itemLabelVisible, true) + compare(initial.mesh, Abstract3DSeries.MeshSphere) + compare(initial.meshRotation, Qt.quaternion(1, 0, 0, 0)) + compare(initial.meshSmooth, false) + compare(initial.multiHighlightColor, "#000000") + compare(initial.multiHighlightGradient, null) + compare(initial.name, "") + compare(initial.singleHighlightColor, "#000000") + compare(initial.singleHighlightGradient, null) + compare(initial.type, Abstract3DSeries.SeriesTypeSurface) + compare(initial.userDefinedMesh, "") + compare(initial.visible, true) + } + } + + TestCase { + name: "Surface3DSeries Initialized" + + function test_1_initialized() { + compare(initialized.dataProxy.rowCount, 2) + compare(initialized.drawMode, Surface3DSeries.DrawSurface) + compare(initialized.flatShadingEnabled, false) + compare(initialized.selectedPoint, Qt.point(0, 0)) + compare(initialized.textureFile, ":\customtexture.jpg") + } + + function test_2_initialized_common() { + // Common properties + compare(initialized.baseColor, "#0000ff") + compare(initialized.baseGradient, gradient1) + compare(initialized.colorStyle, Theme3D.ColorStyleObjectGradient) + compare(initialized.itemLabelFormat, "%f") + compare(initialized.itemLabelVisible, false) + compare(initialized.mesh, Abstract3DSeries.MeshCube) + compare(initialized.meshRotation, Qt.quaternion(1, 1, 1, 1)) + compare(initialized.meshSmooth, true) + compare(initialized.multiHighlightColor, "#008000") + compare(initialized.multiHighlightGradient, gradient2) + compare(initialized.name, "series1") + compare(initialized.singleHighlightColor, "#ff0000") + compare(initialized.singleHighlightGradient, gradient3) + compare(initialized.userDefinedMesh, ":/customitem.obj") + compare(initialized.visible, false) + } + } + + TestCase { + name: "Surface3DSeries Change" + + function test_1_change() { + change.dataProxy = proxy1 + change.drawMode = Surface3DSeries.DrawSurface + change.flatShadingEnabled = false + change.selectedPoint = Qt.point(0, 0) + change.textureFile = ":\customtexture.jpg" + } + + function test_2_test_change() { + // This test has a dependency to the previous one due to asynchronous item model resolving + compare(change.dataProxy.rowCount, 3) + compare(change.drawMode, Surface3DSeries.DrawSurface) + compare(change.flatShadingEnabled, false) + compare(change.selectedPoint, Qt.point(0, 0)) + compare(change.textureFile, ":\customtexture.jpg") + } + + function test_3_change_common() { + change.baseColor = "blue" + change.baseGradient = gradient1 + change.colorStyle = Theme3D.ColorStyleObjectGradient + change.itemLabelFormat = "%f" + change.itemLabelVisible = false + change.mesh = Abstract3DSeries.MeshCube + change.meshRotation = Qt.quaternion(1, 1, 1, 1) + change.meshSmooth = true + change.multiHighlightColor = "green" + change.multiHighlightGradient = gradient2 + change.name = "series1" + change.singleHighlightColor = "red" + change.singleHighlightGradient = gradient3 + change.userDefinedMesh = ":/customitem.obj" + change.visible = false + + compare(change.baseColor, "#0000ff") + compare(change.baseGradient, gradient1) + compare(change.colorStyle, Theme3D.ColorStyleObjectGradient) + compare(change.itemLabelFormat, "%f") + compare(change.itemLabelVisible, false) + compare(change.mesh, Abstract3DSeries.MeshCube) + compare(change.meshRotation, Qt.quaternion(1, 1, 1, 1)) + compare(change.meshSmooth, true) + compare(change.multiHighlightColor, "#008000") + compare(change.multiHighlightGradient, gradient2) + compare(change.name, "series1") + compare(change.singleHighlightColor, "#ff0000") + compare(change.singleHighlightGradient, gradient3) + compare(change.userDefinedMesh, ":/customitem.obj") + compare(change.visible, false) + } + + function test_4_change_gradient_stop() { + gradient1.stops[0].color = "yellow" + compare(change.baseGradient.stops[0].color, "#ffff00") + } + } +} diff --git a/tests/auto/qmltest/theme3d/tst_colorgradient.qml b/tests/auto/qmltest/theme3d/tst_colorgradient.qml new file mode 100644 index 00000000..395b6672 --- /dev/null +++ b/tests/auto/qmltest/theme3d/tst_colorgradient.qml @@ -0,0 +1,89 @@ +/**************************************************************************** +** +** 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 +** +****************************************************************************/ + +import QtQuick 2.0 +import QtDataVisualization 1.2 +import QtTest 1.0 + +Item { + id: top + width: 150 + height: 150 + + ColorGradient { + id: initial + } + + ColorGradient { + id: initialized + stops: [ + ColorGradientStop { color: "blue"; position: 0 }, + ColorGradientStop { color: "white"; position: 0.5 }, + ColorGradientStop { color: "red"; position: 1 } + ] + } + + ColorGradient { + id: change + } + + TestCase { + name: "ColorGradient Initial" + + function test_initial() { + compare(initial.stops.length, 0) + } + } + + TestCase { + name: "ColorGradient Initialized" + + function test_initialized() { + compare(initialized.stops.length, 3) + compare(initialized.stops[0].color, "#0000ff") + compare(initialized.stops[1].color, "#ffffff") + compare(initialized.stops[2].color, "#ff0000") + } + } + + TestCase { + name: "ColorGradient Change" + + ColorGradientStop { id: stop1; color: "blue"; position: 0 } + ColorGradientStop { id: stop2; color: "red"; position: 1.0 } + ColorGradientStop { id: stop3; color: "white"; position: 0.5 } + + function test_change() { + change.stops = [stop1] + compare(change.stops.length, 1) + change.stops = [stop1, stop2] + compare(change.stops.length, 2) + compare(change.stops[0].color, "#0000ff") + change.stops[0].color = "red" + compare(change.stops[0].color, "#ff0000") + compare(change.stops[1].color, "#ff0000") + change.stops = [stop1, stop2, stop3] + compare(change.stops[2].color, "#ffffff") + compare(change.stops.length, 3) + stop2.position = 0.25 + stop3.position = 1.0 + compare(change.stops[1].position, 0.25) + compare(change.stops[2].position, 1.0) + } + } +} diff --git a/tests/auto/qmltest/theme3d/tst_theme.qml b/tests/auto/qmltest/theme3d/tst_theme.qml new file mode 100644 index 00000000..3e42b300 --- /dev/null +++ b/tests/auto/qmltest/theme3d/tst_theme.qml @@ -0,0 +1,266 @@ +/**************************************************************************** +** +** 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 +** +****************************************************************************/ + +import QtQuick 2.0 +import QtDataVisualization 1.2 +import QtTest 1.0 + +Item { + id: top + width: 150 + height: 150 + + Theme3D { + id: initial + } + + ColorGradient { + id: gradient1 + stops: [ + ColorGradientStop { color: "red"; position: 0 }, + ColorGradientStop { color: "blue"; position: 1 } + ] + } + + ColorGradient { + id: gradient2 + stops: [ + ColorGradientStop { color: "green"; position: 0 }, + ColorGradientStop { color: "red"; position: 1 } + ] + } + + ColorGradient { + id: gradient3 + stops: [ + ColorGradientStop { color: "gray"; position: 0 }, + ColorGradientStop { color: "darkgray"; position: 1 } + ] + } + + ThemeColor { + id: color1 + color: "red" + } + + ThemeColor { + id: color2 + color: "blue" + } + + Theme3D { + id: initialized + ambientLightStrength: 0.3 + backgroundColor: "#ff0000" + backgroundEnabled: false + baseColors: [color1, color2] + baseGradients: [gradient1, gradient2] + colorStyle: Theme3D.ColorStyleRangeGradient + font.family: "Arial" + gridEnabled: false + gridLineColor: "#00ff00" + highlightLightStrength: 5.0 + labelBackgroundColor: "#ff00ff" + labelBackgroundEnabled: false + labelBorderEnabled: false + labelTextColor: "#00ffff" + lightColor: "#ffff00" + lightStrength: 2.5 + multiHighlightColor: "#ff00ff" + multiHighlightGradient: gradient3 + singleHighlightColor: "#ff0000" + singleHighlightGradient: gradient3 + type: Theme3D.ThemeQt // Default values will be overwritten by initialized values + windowColor: "#fff00f" + } + + Theme3D { + id: change + } + + Theme3D { + id: invalid + } + + TestCase { + name: "Theme3D Initial" + + Text { id: dummy } + + function test_initial() { + compare(initial.ambientLightStrength, 0.25) + compare(initial.backgroundColor, "#000000") + compare(initial.backgroundEnabled, true) + compare(initial.baseColors.length, 1) + compare(initial.baseColors[0].color, "#000000") + compare(initial.baseGradients.length, 1) + compare(initial.baseGradients[0].stops[0].color, "#000000") + compare(initial.baseGradients[0].stops[1].color, "#ffffff") + compare(initial.colorStyle, Theme3D.ColorStyleUniform) + // Initial font needs to be tested like this, as different platforms have different default font (QFont()) + compare(initial.font.family, dummy.font.family) + compare(initial.gridEnabled, true) + compare(initial.gridLineColor, "#ffffff") + compare(initial.highlightLightStrength, 7.5) + compare(initial.labelBackgroundColor, "#a0a0a4") + compare(initial.labelBackgroundEnabled, true) + compare(initial.labelBorderEnabled, true) + compare(initial.labelTextColor, "#ffffff") + compare(initial.lightColor, "#ffffff") + compare(initial.lightStrength, 5) + compare(initial.multiHighlightColor, "#0000ff") + compare(initial.multiHighlightGradient, null) + compare(initial.singleHighlightColor, "#ff0000") + compare(initial.singleHighlightGradient, null) + compare(initial.type, Theme3D.ThemeUserDefined) + compare(initial.windowColor, "#000000") + } + } + + TestCase { + name: "Theme3D Initialized" + + function test_initialized() { + compare(initialized.ambientLightStrength, 0.3) + compare(initialized.backgroundColor, "#ff0000") + compare(initialized.backgroundEnabled, false) + compare(initialized.baseColors.length, 2) + compare(initialized.baseColors[0].color, "#ff0000") + compare(initialized.baseColors[1].color, "#0000ff") + compare(initialized.baseGradients.length, 2) + compare(initialized.baseGradients[0], gradient1) + compare(initialized.baseGradients[1], gradient2) + compare(initialized.colorStyle, Theme3D.ColorStyleRangeGradient) + compare(initialized.font.family, "Arial") + compare(initialized.gridEnabled, false) + compare(initialized.gridLineColor, "#00ff00") + compare(initialized.highlightLightStrength, 5.0) + compare(initialized.labelBackgroundColor, "#ff00ff") + compare(initialized.labelBackgroundEnabled, false) + compare(initialized.labelBorderEnabled, false) + compare(initialized.labelTextColor, "#00ffff") + compare(initialized.lightColor, "#ffff00") + compare(initialized.lightStrength, 2.5) + compare(initialized.multiHighlightColor, "#ff00ff") + compare(initialized.multiHighlightGradient, gradient3) + compare(initialized.singleHighlightColor, "#ff0000") + compare(initialized.singleHighlightGradient, gradient3) + compare(initialized.type, Theme3D.ThemeQt) + compare(initialized.windowColor, "#fff00f") + } + } + + TestCase { + name: "Theme3D Change" + + ThemeColor { + id: color3 + color: "red" + } + + ColorGradient { + id: gradient4 + stops: [ + ColorGradientStop { color: "red"; position: 0 }, + ColorGradientStop { color: "blue"; position: 1 } + ] + } + + function test_1_change() { + change.type = Theme3D.ThemeStoneMoss // Default values will be overwritten by the following sets + change.ambientLightStrength = 0.3 + change.backgroundColor = "#ff0000" + change.backgroundEnabled = false + change.baseColors = [color3, color2] + change.baseGradients = [gradient4, gradient2] + change.colorStyle = Theme3D.ColorStyleObjectGradient + change.font.family = "Arial" + change.gridEnabled = false + change.gridLineColor = "#00ff00" + change.highlightLightStrength = 5.0 + change.labelBackgroundColor = "#ff00ff" + change.labelBackgroundEnabled = false + change.labelBorderEnabled = false + change.labelTextColor = "#00ffff" + change.lightColor = "#ffff00" + change.lightStrength = 2.5 + change.multiHighlightColor = "#ff00ff" + change.multiHighlightGradient = gradient3 + change.singleHighlightColor = "#ff0000" + change.singleHighlightGradient = gradient3 + change.windowColor = "#fff00f" + + compare(change.ambientLightStrength, 0.3) + compare(change.backgroundColor, "#ff0000") + compare(change.backgroundEnabled, false) + compare(change.baseColors.length, 2) + compare(change.baseColors[0].color, "#ff0000") + compare(change.baseColors[1].color, "#0000ff") + compare(change.baseGradients.length, 2) + compare(change.baseGradients[0], gradient4) + compare(change.baseGradients[1], gradient2) + compare(change.colorStyle, Theme3D.ColorStyleObjectGradient) + compare(change.font.family, "Arial") + compare(change.gridEnabled, false) + compare(change.gridLineColor, "#00ff00") + compare(change.highlightLightStrength, 5.0) + compare(change.labelBackgroundColor, "#ff00ff") + compare(change.labelBackgroundEnabled, false) + compare(change.labelBorderEnabled, false) + compare(change.labelTextColor, "#00ffff") + compare(change.lightColor, "#ffff00") + compare(change.lightStrength, 2.5) + compare(change.multiHighlightColor, "#ff00ff") + compare(change.multiHighlightGradient, gradient3) + compare(change.singleHighlightColor, "#ff0000") + compare(change.singleHighlightGradient, gradient3) + compare(change.type, Theme3D.ThemeStoneMoss) + compare(change.windowColor, "#fff00f") + } + + function test_2_change_color() { + color3.color = "white" + compare(change.baseColors[0].color, "#ffffff") + } + + function test_3_change_gradient() { + gradient4.stops[0].color = "black" + compare(change.baseGradients[0].stops[0].color, "#000000") + } + } + + + TestCase { + name: "Theme3D Invalid" + + function test_invalid() { + invalid.ambientLightStrength = -1.0 + compare(invalid.ambientLightStrength, 0.25) + invalid.ambientLightStrength = 1.1 + compare(invalid.ambientLightStrength, 0.25) + invalid.highlightLightStrength = -1.0 + compare(invalid.highlightLightStrength, 7.5) + invalid.highlightLightStrength = 10.1 + compare(invalid.highlightLightStrength, 7.5) + invalid.lightStrength = -1.0 + compare(invalid.lightStrength, 5.0) + invalid.lightStrength = 10.1 + compare(invalid.lightStrength, 5.0) + } + } +} diff --git a/tests/auto/qmltest/theme3d/tst_themecolor.qml b/tests/auto/qmltest/theme3d/tst_themecolor.qml new file mode 100644 index 00000000..421a5775 --- /dev/null +++ b/tests/auto/qmltest/theme3d/tst_themecolor.qml @@ -0,0 +1,66 @@ +/**************************************************************************** +** +** 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 +** +****************************************************************************/ + +import QtQuick 2.0 +import QtDataVisualization 1.2 +import QtTest 1.0 + +Item { + id: top + width: 150 + height: 150 + + ThemeColor { + id: initial + } + + ThemeColor { + id: initialized + color: "red" + } + + ThemeColor { + id: change + } + + TestCase { + name: "ThemeColor Initial" + + function test_initial() { + compare(initial.color, "#000000") + } + } + + TestCase { + name: "ThemeColor Initialized" + + function test_initialized() { + compare(initialized.color, "#ff0000") + } + } + + TestCase { + name: "ThemeColor Change" + + function test_change() { + change.color = "blue" + + compare(change.color, "#0000ff") + } + } +} diff --git a/tests/auto/qmltest/tst_qmltest.cpp b/tests/auto/qmltest/tst_qmltest.cpp new file mode 100644 index 00000000..569d9150 --- /dev/null +++ b/tests/auto/qmltest/tst_qmltest.cpp @@ -0,0 +1,20 @@ +/**************************************************************************** +** +** 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 <QtQuickTest/quicktest.h> +QUICK_TEST_MAIN(qmltest) |