diff options
Diffstat (limited to 'tests/auto/qmltest/surface3d')
-rw-r--r-- | tests/auto/qmltest/surface3d/tst_basic.qml | 211 | ||||
-rw-r--r-- | tests/auto/qmltest/surface3d/tst_heightproxy.qml | 116 | ||||
-rw-r--r-- | tests/auto/qmltest/surface3d/tst_proxy.qml | 263 | ||||
-rw-r--r-- | tests/auto/qmltest/surface3d/tst_surface.qml | 60 | ||||
-rw-r--r-- | tests/auto/qmltest/surface3d/tst_surfaceseries.qml | 229 |
5 files changed, 879 insertions, 0 deletions
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") + } + } +} |