diff options
author | Tomi Korpipää <tomi.korpipaa@digia.com> | 2014-10-16 13:22:47 +0300 |
---|---|---|
committer | Tomi Korpipää <tomi.korpipaa@digia.com> | 2014-10-16 13:32:33 +0300 |
commit | a24d3628fceb70eb2cba2fa91883f5f3bfa55361 (patch) | |
tree | b9f8885b03d5653b4856be1b4fd12427d18cdb73 /tests/auto/qmltest/surface3d | |
parent | e69acebea5eae430dbf988f379cd26464930ee6b (diff) |
Test for QML proxies
Also added missing default values to some docs.
Task-number: QTRD-3368
Change-Id: I98940a80d6edfe60801c6b2606307b3ec3ab8c39
Reviewed-by: Miikka Heikkinen <miikka.heikkinen@theqtcompany.com>
Diffstat (limited to 'tests/auto/qmltest/surface3d')
-rw-r--r-- | tests/auto/qmltest/surface3d/tst_heightproxy.qml | 101 | ||||
-rw-r--r-- | tests/auto/qmltest/surface3d/tst_proxy.qml | 236 |
2 files changed, 336 insertions, 1 deletions
diff --git a/tests/auto/qmltest/surface3d/tst_heightproxy.qml b/tests/auto/qmltest/surface3d/tst_heightproxy.qml new file mode 100644 index 00000000..dc6938f8 --- /dev/null +++ b/tests/auto/qmltest/surface3d/tst_heightproxy.qml @@ -0,0 +1,101 @@ +/**************************************************************************** +** +** 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 + } + + 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) + } + } +} diff --git a/tests/auto/qmltest/surface3d/tst_proxy.qml b/tests/auto/qmltest/surface3d/tst_proxy.qml index 25753a3f..8f353153 100644 --- a/tests/auto/qmltest/surface3d/tst_proxy.qml +++ b/tests/auto/qmltest/surface3d/tst_proxy.qml @@ -25,5 +25,239 @@ Item { height: 150 width: 150 - // TODO: Add tests for ItemModelSurfaceDataProxy and HeightMapSurfaceDataProxy + 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) + } + } } |