summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorTomi Korpipää <tomi.korpipaa@digia.com>2014-10-22 11:49:21 +0300
committerTomi Korpipää <tomi.korpipaa@digia.com>2014-10-22 12:28:49 +0300
commit8b40f40c4b51fb5a9e02bf4f2c17658500497eff (patch)
tree0210f940e358adeade731887ebaf656681ddb049 /tests
parenta845ef527b650af3ce95e03ea2670e120f053b36 (diff)
Added C++ autotests for input
Task-number: QTRD-3368 Change-Id: I0ca32bcaf4025cac24ece2e80fab6a2eee3562b0 Change-Id: I0ca32bcaf4025cac24ece2e80fab6a2eee3562b0 Reviewed-by: Miikka Heikkinen <miikka.heikkinen@theqtcompany.com> Reviewed-by: Mika Salmela <mika.salmela@theqtcompany.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/cpptest/cpptest.pro4
-rw-r--r--tests/auto/cpptest/q3dinput-touch/q3dinput-touch.pro8
-rw-r--r--tests/auto/cpptest/q3dinput-touch/tst_input.cpp106
-rw-r--r--tests/auto/cpptest/q3dinput/q3dinput.pro8
-rw-r--r--tests/auto/cpptest/q3dinput/tst_input.cpp109
5 files changed, 234 insertions, 1 deletions
diff --git a/tests/auto/cpptest/cpptest.pro b/tests/auto/cpptest/cpptest.pro
index 34fbe4e0..b3b9b076 100644
--- a/tests/auto/cpptest/cpptest.pro
+++ b/tests/auto/cpptest/cpptest.pro
@@ -18,4 +18,6 @@ SUBDIRS = q3dbars \
q3dscene \
q3dscene-camera \
q3dscene-light \
- q3dtheme
+ q3dtheme \
+ q3dinput \
+ q3dinput-touch
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"