summaryrefslogtreecommitdiffstats
path: root/tests/auto/qmltest/scene3d
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/qmltest/scene3d')
-rw-r--r--tests/auto/qmltest/scene3d/tst_camera.qml135
-rw-r--r--tests/auto/qmltest/scene3d/tst_light.qml65
-rw-r--r--tests/auto/qmltest/scene3d/tst_scene.qml125
3 files changed, 325 insertions, 0 deletions
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))
+ }
+ }
+}