diff options
Diffstat (limited to 'tests/auto/qmltest/bars3d')
-rw-r--r-- | tests/auto/qmltest/bars3d/tst_bars.qml | 147 | ||||
-rw-r--r-- | tests/auto/qmltest/bars3d/tst_barseries.qml | 215 | ||||
-rw-r--r-- | tests/auto/qmltest/bars3d/tst_basic.qml | 240 | ||||
-rw-r--r-- | tests/auto/qmltest/bars3d/tst_proxy.qml | 253 |
4 files changed, 855 insertions, 0 deletions
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) + } + } +} |