diff options
author | Tomi Korpipää <tomi.korpipaa@digia.com> | 2014-10-14 11:32:04 +0300 |
---|---|---|
committer | Tomi Korpipää <tomi.korpipaa@digia.com> | 2014-10-14 11:35:19 +0300 |
commit | 7d954d485255acd7f40d6facb1b90e75e375641f (patch) | |
tree | d5f3af1f33deff489565f4b55b18f443f8281e35 | |
parent | 961600f6549756754ae155ef9cf63bb990e00f2c (diff) |
QML series tests added
Task-number: QTRD-3368
Change-Id: I80ecdb1a9bcef6ed83d278d975d70f7794ff03c1
Reviewed-by: Miikka Heikkinen <miikka.heikkinen@theqtcompany.com>
-rw-r--r-- | tests/auto/qmltest/bars3d/tst_barseries.qml | 215 | ||||
-rw-r--r-- | tests/auto/qmltest/qmltest.pro | 5 | ||||
-rw-r--r-- | tests/auto/qmltest/scatter3d/tst_scatterseries.qml | 219 | ||||
-rw-r--r-- | tests/auto/qmltest/surface3d/tst_surfaceseries.qml | 225 |
4 files changed, 663 insertions, 1 deletions
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/qmltest.pro b/tests/auto/qmltest/qmltest.pro index e1901817..a6430862 100644 --- a/tests/auto/qmltest/qmltest.pro +++ b/tests/auto/qmltest/qmltest.pro @@ -5,10 +5,13 @@ CONFIG += console SOURCES += tst_qmltest.cpp OTHER_FILES += bars3d\tst_basic.qml \ bars3d\tst_bars.qml \ + bars3d\tst_barseries.qml \ scatter3d\tst_basic.qml \ scatter3d\tst_scatter.qml \ + scatter3d\tst_scatterseries.qml \ surface3d\tst_basic.qml \ - surface3d\tst_surface.qml + surface3d\tst_surface.qml \ + surface3d\tst_surfaceseries.qml RESOURCES += \ qmltest.qrc diff --git a/tests/auto/qmltest/scatter3d/tst_scatterseries.qml b/tests/auto/qmltest/scatter3d/tst_scatterseries.qml new file mode 100644 index 00000000..e42443ad --- /dev/null +++ b/tests/auto/qmltest/scatter3d/tst_scatterseries.qml @@ -0,0 +1,219 @@ +/**************************************************************************** +** +** 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 + } + + 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") + } + } +} diff --git a/tests/auto/qmltest/surface3d/tst_surfaceseries.qml b/tests/auto/qmltest/surface3d/tst_surfaceseries.qml new file mode 100644 index 00000000..866a04b9 --- /dev/null +++ b/tests/auto/qmltest/surface3d/tst_surfaceseries.qml @@ -0,0 +1,225 @@ +/**************************************************************************** +** +** 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) + + 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)) + } + + 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) + } + + 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)) + } + + 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") + } + } +} |