From c98d8af1763df3e8f3c2b8b2117ebcd882b6b16d 2013-10-24 06:19:39 From: Titta Heikkala Date: 2013-10-24 06:19:39 Subject: [PATCH] Fix Charts QML api auto test Charts QML api auto tests, qml-qtquicktest, has been fixed so that the tests are runnable with Qt5 / QtQuick 2.0. Task-number: QTRD-1692 Change-Id: I8e1e52781570cde413fab7f511cce17ab91e20d3 Reviewed-by: Miikka Heikkinen --- diff --git a/tests/auto/qml-qtquicktest/main.cpp b/tests/auto/qml-qtquicktest/main.cpp index e5ab5fc..2dd4d48 100644 --- a/tests/auto/qml-qtquicktest/main.cpp +++ b/tests/auto/qml-qtquicktest/main.cpp @@ -19,4 +19,10 @@ ****************************************************************************/ #include -QUICK_TEST_MAIN(example) +#include + +int main(int argc, char *argv[]) +{ + QApplication app(argc, argv); + return quick_test_main(argc, argv, "example", QUICK_TEST_SOURCE_DIR); +} diff --git a/tests/auto/qml-qtquicktest/qml-qtquicktest.pro b/tests/auto/qml-qtquicktest/qml-qtquicktest.pro index b34338b..9406227 100644 --- a/tests/auto/qml-qtquicktest/qml-qtquicktest.pro +++ b/tests/auto/qml-qtquicktest/qml-qtquicktest.pro @@ -2,7 +2,12 @@ error( "Couldn't find the auto.pri file!" ) } -TEMPLATE = app -CONFIG += warn_on qmltestcase -SOURCES += main.cpp -DEFINES += QUICK_TEST_SOURCE_DIR=\"\\\"$$PWD\\\"\" +greaterThan(QT_MAJOR_VERSION, 4) { + TEMPLATE = app + CONFIG += warn_on qmltestcase + SOURCES += main.cpp + OTHER_FILES += tst_*.qml + DEFINES += QUICK_TEST_SOURCE_DIR=\"\\\"$$PWD\\\"\" +} else { + error("These auto tests are designed for Qt5 / QtQuick 2.0") +} diff --git a/tests/auto/qml-qtquicktest/tst_barcategoryaxis.qml b/tests/auto/qml-qtquicktest/tst_barcategoryaxis.qml index 5ae077c..bb3dcc0 100644 --- a/tests/auto/qml-qtquicktest/tst_barcategoryaxis.qml +++ b/tests/auto/qml-qtquicktest/tst_barcategoryaxis.qml @@ -18,9 +18,9 @@ ** ****************************************************************************/ -import QtQuick 1.0 -import QtQuickTest 1.0 -import QtCommercial.Chart 1.2 +import QtQuick 2.0 +import QtTest 1.0 +import QtCommercial.Chart 1.3 Rectangle { width: 400 @@ -40,20 +40,30 @@ Rectangle { function test_categories() { compare(barSeries1.axisX.count, 6, "AxisX count"); + categoriesCountChangedSpy.clear(); + categoriesChangedSpy.clear(); // Replace categories - var cat = barSeries1.axisX.categories; barSeries1.axisX.categories = ["Tam", "Hel", "Maa", "Huh"]; compare(barSeries1.axisX.count, 4, "AxisX count"); compare(categoriesCountChangedSpy.count, 1, "onCountChanged"); compare(categoriesChangedSpy.count, 1, "onCategoriesChanged"); // Reset the original categories - barSeries1.axisX.categories = cat; + barSeries1.axisX.categories = ["Jan", "Feb", "Mar", "Apr", "May", "Jun"] compare(barSeries1.axisX.count, 6, "AxisX count"); compare(categoriesCountChangedSpy.count, 2, "onCountChanged"); compare(categoriesChangedSpy.count, 2, "onCategoriesChanged"); } + + function test_minMaxChanged() { + axisY.min = -1; + compare(minChangedSpy.count, 1, "onMinChanged"); + compare(maxChangedSpy.count, 0, "onMaxChanged"); + axisY.max = 12; + compare(minChangedSpy.count, 1, "onMinChanged"); + compare(maxChangedSpy.count, 1, "onMaxChanged"); + } } ChartView { @@ -83,5 +93,15 @@ Rectangle { target: axisX signalName: "categoriesChanged" } + SignalSpy { + id: minChangedSpy + target: axisY + signalName: "minChanged" + } + SignalSpy { + id: maxChangedSpy + target: axisY + signalName: "maxChanged" + } } } diff --git a/tests/auto/qml-qtquicktest/tst_barcategoryaxis_1_1.qml b/tests/auto/qml-qtquicktest/tst_barcategoryaxis_1_1.qml index c98ae09..69644b7 100644 --- a/tests/auto/qml-qtquicktest/tst_barcategoryaxis_1_1.qml +++ b/tests/auto/qml-qtquicktest/tst_barcategoryaxis_1_1.qml @@ -18,8 +18,8 @@ ** ****************************************************************************/ -import QtQuick 1.0 -import QtQuickTest 1.0 +import QtQuick 2.0 +import QtTest 1.0 import QtCommercial.Chart 1.1 Rectangle { @@ -40,20 +40,30 @@ Rectangle { function test_categories() { compare(barSeries1.axisX.count, 6, "AxisX count"); + categoriesCountChangedSpy.clear(); + categoriesChangedSpy.clear(); // Replace categories - var cat = barSeries1.axisX.categories; barSeries1.axisX.categories = ["Tam", "Hel", "Maa", "Huh"]; compare(barSeries1.axisX.count, 4, "AxisX count"); compare(categoriesCountChangedSpy.count, 1, "onCountChanged"); compare(categoriesChangedSpy.count, 1, "onCategoriesChanged"); // Reset the original categories - barSeries1.axisX.categories = cat; + barSeries1.axisX.categories = ["Jan", "Feb", "Mar", "Apr", "May", "Jun"] compare(barSeries1.axisX.count, 6, "AxisX count"); compare(categoriesCountChangedSpy.count, 2, "onCountChanged"); compare(categoriesChangedSpy.count, 2, "onCategoriesChanged"); } + + function test_minMaxChanged() { + axisY.min = -1; + compare(minChangedSpy.count, 1, "onMinChanged"); + compare(maxChangedSpy.count, 0, "onMaxChanged"); + axisY.max = 12; + compare(minChangedSpy.count, 1, "onMinChanged"); + compare(maxChangedSpy.count, 1, "onMaxChanged"); + } } ChartView { @@ -83,5 +93,15 @@ Rectangle { target: axisX signalName: "categoriesChanged" } + SignalSpy { + id: minChangedSpy + target: axisY + signalName: "minChanged" + } + SignalSpy { + id: maxChangedSpy + target: axisY + signalName: "maxChanged" + } } } diff --git a/tests/auto/qml-qtquicktest/tst_barcategoryaxis_1_2.qml b/tests/auto/qml-qtquicktest/tst_barcategoryaxis_1_2.qml new file mode 100644 index 0000000..52424e5 --- /dev/null +++ b/tests/auto/qml-qtquicktest/tst_barcategoryaxis_1_2.qml @@ -0,0 +1,107 @@ +/**************************************************************************** +** +** Copyright (C) 2013 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 Qt Enterprise Charts Add-on. +** +** $QT_BEGIN_LICENSE$ +** 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 +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtTest 1.0 +import QtCommercial.Chart 1.2 + +Rectangle { + width: 400 + height: 300 + + TestCase { + id: tc1 + name: "tst_qml-qtquicktest BarCategoryAxis 1.2" + when: windowShown + + function test_minMax() { + compare(barSeries1.axisX.min, "Jan", "AxisX min"); + compare(barSeries1.axisX.max, "Jun", "AxisX max"); + compare(barSeries1.axisY.min, 0, "AxisY min"); + compare(barSeries1.axisY.max, 10, "AxisY max"); + } + + function test_categories() { + compare(barSeries1.axisX.count, 6, "AxisX count"); + categoriesCountChangedSpy.clear(); + categoriesChangedSpy.clear(); + + // Replace categories + barSeries1.axisX.categories = ["Tam", "Hel", "Maa", "Huh"]; + compare(barSeries1.axisX.count, 4, "AxisX count"); + compare(categoriesCountChangedSpy.count, 1, "onCountChanged"); + compare(categoriesChangedSpy.count, 1, "onCategoriesChanged"); + + // Reset the original categories + barSeries1.axisX.categories = ["Jan", "Feb", "Mar", "Apr", "May", "Jun"] + compare(barSeries1.axisX.count, 6, "AxisX count"); + compare(categoriesCountChangedSpy.count, 2, "onCountChanged"); + compare(categoriesChangedSpy.count, 2, "onCategoriesChanged"); + } + + function test_minMaxChanged() { + axisY.min = -1; + compare(minChangedSpy.count, 1, "onMinChanged"); + compare(maxChangedSpy.count, 0, "onMaxChanged"); + axisY.max = 12; + compare(minChangedSpy.count, 1, "onMinChanged"); + compare(maxChangedSpy.count, 1, "onMaxChanged"); + } + } + + ChartView { + id: chartView + anchors.fill: parent + + BarSeries { + id: barSeries1 + axisX: BarCategoryAxis { + id: axisX + categories: ["Jan", "Feb", "Mar", "Apr", "May", "Jun" ] + } + axisY: ValuesAxis { + id: axisY + min: 0 + max: 10 + } + } + + SignalSpy { + id: categoriesCountChangedSpy + target: axisX + signalName: "countChanged" + } + SignalSpy { + id: categoriesChangedSpy + target: axisX + signalName: "categoriesChanged" + } + SignalSpy { + id: minChangedSpy + target: axisY + signalName: "minChanged" + } + SignalSpy { + id: maxChangedSpy + target: axisY + signalName: "maxChanged" + } + } +} diff --git a/tests/auto/qml-qtquicktest/tst_barseries.qml b/tests/auto/qml-qtquicktest/tst_barseries.qml index ecdd5be..b092399 100644 --- a/tests/auto/qml-qtquicktest/tst_barseries.qml +++ b/tests/auto/qml-qtquicktest/tst_barseries.qml @@ -18,9 +18,9 @@ ** ****************************************************************************/ -import QtQuick 1.0 -import QtQuickTest 1.0 -import QtCommercial.Chart 1.2 +import QtQuick 2.0 +import QtTest 1.0 +import QtCommercial.Chart 1.3 Rectangle { width: 400 @@ -37,9 +37,8 @@ Rectangle { } function test_axes() { - compare(chartView.axes.length, 2); - verify(chartView.axes[0] == barSeries.axisX || chartView.axes[1] == barSeries.axisX); - verify(chartView.axes[0] == barSeries.axisY || chartView.axes[1] == barSeries.axisY); + verify(chartView.axisX() == barSeries.axisX); + verify(chartView.axisY() == barSeries.axisY); compare(barSeries.axisX, stackedBarSeries.axisX); compare(barSeries.axisY, stackedBarSeries.axisY); diff --git a/tests/auto/qml-qtquicktest/tst_barseries_1_1.qml b/tests/auto/qml-qtquicktest/tst_barseries_1_1.qml index 5ae9da9..97d484b 100644 --- a/tests/auto/qml-qtquicktest/tst_barseries_1_1.qml +++ b/tests/auto/qml-qtquicktest/tst_barseries_1_1.qml @@ -18,8 +18,8 @@ ** ****************************************************************************/ -import QtQuick 1.0 -import QtQuickTest 1.0 +import QtQuick 2.0 +import QtTest 1.0 import QtCommercial.Chart 1.1 Rectangle { diff --git a/tests/auto/qml-qtquicktest/tst_barseries_1_2.qml b/tests/auto/qml-qtquicktest/tst_barseries_1_2.qml new file mode 100644 index 0000000..e221cd2 --- /dev/null +++ b/tests/auto/qml-qtquicktest/tst_barseries_1_2.qml @@ -0,0 +1,146 @@ +/**************************************************************************** +** +** Copyright (C) 2013 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 Qt Enterprise Charts Add-on. +** +** $QT_BEGIN_LICENSE$ +** 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 +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtTest 1.0 +import QtCommercial.Chart 1.2 + +Rectangle { + width: 400 + height: 300 + + TestCase { + id: tc1 + name: "tst_qml-qtquicktest BarSeries 1.2" + when: windowShown + + function test_properties() { + compare(barSeries.barWidth, 0.5); + compare(barSeries.labelsVisible, false); + } + + function test_axes() { + verify(chartView.axisX() == barSeries.axisX); + verify(chartView.axisY() == barSeries.axisY); + + compare(barSeries.axisX, stackedBarSeries.axisX); + compare(barSeries.axisY, stackedBarSeries.axisY); + + compare(barSeries.axisX, percentBarSeries.axisX); + compare(barSeries.axisY, percentBarSeries.axisY); + } + + function test_append() { + var setCount = 5; + var valueCount = 50; + addedSpy.clear(); + append(setCount, valueCount); + + compare(barSeries.count, setCount); + for (var k = 0; k < setCount; k++) { + compare(barSeries.at(k).count, valueCount); + compare(barSeries.at(k).label, "barset" + k); + } + compare(addedSpy.count, setCount); + + barSeries.clear(); + compare(barSeries.count, 0); + } + + function test_insert() { + var setCount = 5; + var valueCount = 50; + addedSpy.clear(); + append(setCount, valueCount); + + for (var i = 0; i < setCount; i++) { + var values = []; + for (var j = 0; j < valueCount; j++) + values[j] = Math.random() * 10; + var set = barSeries.insert(i, "barset" + i, values); + compare(set.label, "barset" + i); + } + + compare(barSeries.count, setCount * 2); + for (var k = 0; k < setCount * 2; k++) + compare(barSeries.at(k).count, valueCount); + compare(addedSpy.count, 2 * setCount); + + barSeries.clear(); + compare(barSeries.count, 0); + } + + function test_remove() { + var setCount = 5; + var valueCount = 50; + removedSpy.clear(); + append(setCount, valueCount); + + for (var k = 0; k < setCount; k++) + barSeries.remove(barSeries.at(0)); + + compare(barSeries.count, 0); + compare(removedSpy.count, setCount); + } + + // Not a test function, used by one or more test functions + function append(setCount, valueCount) { + for (var i = 0; i < setCount; i++) { + var values = []; + for (var j = 0; j < valueCount; j++) + values[j] = Math.random() * 10; + barSeries.append("barset" + i, values); + } + } + } + + ChartView { + id: chartView + anchors.fill: parent + + BarSeries { + id: barSeries + name: "bar" + axisX: BarCategoryAxis {} + axisY: ValueAxis { min: 0; max: 10 } + + SignalSpy { + id: addedSpy + target: barSeries + signalName: "barsetsAdded" + } + SignalSpy { + id: removedSpy + target: barSeries + signalName: "barsetsRemoved" + } + } + + StackedBarSeries { + id: stackedBarSeries + name: "stackedBar" + } + + PercentBarSeries { + id: percentBarSeries + name: "percentBar" + } + } +} diff --git a/tests/auto/qml-qtquicktest/tst_boxplotseries.qml b/tests/auto/qml-qtquicktest/tst_boxplotseries.qml new file mode 100644 index 0000000..56eba68 --- /dev/null +++ b/tests/auto/qml-qtquicktest/tst_boxplotseries.qml @@ -0,0 +1,96 @@ +/**************************************************************************** +** +** Copyright (C) 2013 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 Qt Enterprise Charts Add-on. +** +** $QT_BEGIN_LICENSE$ +** 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 +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtTest 1.0 +import QtCommercial.Chart 1.3 + +Rectangle { + width: 400 + height: 300 + + TestCase { + id: tc1 + name: "tst_qml-qtquicktest BoxPlotSeries" + when: windowShown + + function test_properties() { + compare(boxPlotSeries.boxWidth, 0.5); + } + + function test_setproperties() { + var set = boxPlotSeries.append("boxplot", [1, 2, 5, 6, 8]); + compare(set.label, "boxplot"); + compare(set.count, 5); + } + + function test_append() { + addedSpy.clear(); + countChangedSpy.clear(); + var count = 50; + for (var i = 0; i < count; i++) + boxPlotSeries.append("boxplot" + i, Math.random()); + compare(addedSpy.count, count); + compare(countChangedSpy.count, count); + console.log("Check the series count once QTRD-2504 is implemented"); + boxPlotSeries.clear(); + } + + function test_remove() { + removedSpy.clear(); + countChangedSpy.clear(); + var count = 50; + for (var i = 0; i < count; i++) + boxPlotSeries.append("boxplot" + i, Math.random()); + for (var j = 0; j < count; j++) + boxPlotSeries.remove(boxPlotSeries.at(0)); + compare(removedSpy.count, count); + compare(countChangedSpy.count, 2 * count); + console.log("Check the series count once QTRD-2504 is implemented"); + } + } + + ChartView { + id: chartView + anchors.fill: parent + + BoxPlotSeries { + id: boxPlotSeries + name: "boxplot" + BoxSet { label: "Jan"; values: [3, 4, 5.1, 6.2, 8.5] } + + SignalSpy { + id: addedSpy + target: boxPlotSeries + signalName: "boxsetsAdded" + } + SignalSpy { + id: removedSpy + target: boxPlotSeries + signalName: "boxsetsRemoved" + } + SignalSpy { + id: countChangedSpy + target: boxPlotSeries + signalName: "countChanged" + } + } + } +} diff --git a/tests/auto/qml-qtquicktest/tst_categoryaxis.qml b/tests/auto/qml-qtquicktest/tst_categoryaxis.qml index 4c39294..a5b2f96 100644 --- a/tests/auto/qml-qtquicktest/tst_categoryaxis.qml +++ b/tests/auto/qml-qtquicktest/tst_categoryaxis.qml @@ -18,9 +18,9 @@ ** ****************************************************************************/ -import QtQuick 1.0 -import QtQuickTest 1.0 -import QtCommercial.Chart 1.2 +import QtQuick 2.0 +import QtTest 1.0 +import QtCommercial.Chart 1.3 Rectangle { width: 400 diff --git a/tests/auto/qml-qtquicktest/tst_categoryaxis_1_1.qml b/tests/auto/qml-qtquicktest/tst_categoryaxis_1_1.qml index 14b8868..38a98c9 100644 --- a/tests/auto/qml-qtquicktest/tst_categoryaxis_1_1.qml +++ b/tests/auto/qml-qtquicktest/tst_categoryaxis_1_1.qml @@ -18,8 +18,8 @@ ** ****************************************************************************/ -import QtQuick 1.0 -import QtQuickTest 1.0 +import QtQuick 2.0 +import QtTest 1.0 import QtCommercial.Chart 1.1 Rectangle { diff --git a/tests/auto/qml-qtquicktest/tst_categoryaxis_1_2.qml b/tests/auto/qml-qtquicktest/tst_categoryaxis_1_2.qml new file mode 100644 index 0000000..ec6b882 --- /dev/null +++ b/tests/auto/qml-qtquicktest/tst_categoryaxis_1_2.qml @@ -0,0 +1,84 @@ +/**************************************************************************** +** +** Copyright (C) 2013 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 Qt Enterprise Charts Add-on. +** +** $QT_BEGIN_LICENSE$ +** 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 +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtTest 1.0 +import QtCommercial.Chart 1.2 + +Rectangle { + width: 400 + height: 300 + + TestCase { + id: tc1 + name: "tst_qml-qtquicktest CategoryAxis 1.2" + when: windowShown + + function test_minMax() { + compare(lineSeries1.axisX.min, 0, "AxisX min"); + compare(lineSeries1.axisX.max, 10, "AxisX max"); + compare(lineSeries1.axisY.min, 0, "AxisY min"); + compare(lineSeries1.axisY.max, 10, "AxisY max"); + } + + function test_categories() { + compare(lineSeries1.axisY.startValue, 0, "AxisY start value"); + compare(lineSeries1.axisY.count, 3, "AxisY count"); + compare(lineSeries1.axisY.categoriesLabels[0], "label0", "AxisY categories labels"); + compare(lineSeries1.axisY.categoriesLabels[1], "label1", "AxisY categories labels"); + compare(lineSeries1.axisY.categoriesLabels[2], "label2", "AxisY categories labels"); + } + } + + ChartView { + id: chartView + anchors.fill: parent + + LineSeries { + id: lineSeries1 + axisX: ValuesAxis { + id: axisX + min: 0 + max: 10 + } + axisY: CategoryAxis { + id: axisY + min: 0 + max: 10 + startValue: 0 + CategoryRange { + label: "label0" + endValue: 1 + } + CategoryRange { + label: "label1" + endValue: 3 + } + CategoryRange { + label: "label2" + endValue: 10 + } + } + XYPoint { x: -1; y: -1 } + XYPoint { x: 0; y: 0 } + XYPoint { x: 5; y: 5 } + } + } +} diff --git a/tests/auto/qml-qtquicktest/tst_chartview.qml b/tests/auto/qml-qtquicktest/tst_chartview.qml index 2b35ce0..11e4e19 100644 --- a/tests/auto/qml-qtquicktest/tst_chartview.qml +++ b/tests/auto/qml-qtquicktest/tst_chartview.qml @@ -18,9 +18,9 @@ ** ****************************************************************************/ -import QtQuick 1.0 -import QtQuickTest 1.0 -import QtCommercial.Chart 1.2 +import QtQuick 2.0 +import QtTest 1.0 +import QtCommercial.Chart 1.3 Rectangle { width: 400 @@ -34,10 +34,6 @@ Rectangle { function test_chartViewProperties() { compare(chartView.animationOptions, ChartView.NoAnimation, "ChartView.animationOptions"); verify(chartView.backgroundColor != undefined); - verify(chartView.bottomMargin > 0, "ChartView.bottomMargin"); - verify(chartView.topMargin > 0, "ChartView.topMargin"); - verify(chartView.leftMargin > 0, "ChartView.leftMargin"); - verify(chartView.rightMargin > 0, "ChartView.rightMargin"); verify(chartView.margins.bottom > 0, "ChartView.margins.bottom"); verify(chartView.margins.top > 0, "ChartView.margins.top"); verify(chartView.margins.left > 0, "ChartView.margins.left"); @@ -73,7 +69,6 @@ Rectangle { compare(chartView.legend.font.underline, false, "ChartView.legend.font.underline"); compare(chartView.legend.font.weight, Font.Normal, "ChartView.legend.font.weight"); compare(chartView.legend.font.wordSpacing, 0.0, "ChartView.legend.font.wordSpacing"); - compare(chartView.axes.length, 0, "ChartView.axes.length"); } } diff --git a/tests/auto/qml-qtquicktest/tst_chartview_1_1.qml b/tests/auto/qml-qtquicktest/tst_chartview_1_1.qml index 3be7b76..bff76e0 100644 --- a/tests/auto/qml-qtquicktest/tst_chartview_1_1.qml +++ b/tests/auto/qml-qtquicktest/tst_chartview_1_1.qml @@ -18,8 +18,8 @@ ** ****************************************************************************/ -import QtQuick 1.0 -import QtQuickTest 1.0 +import QtQuick 2.0 +import QtTest 1.0 import QtCommercial.Chart 1.1 Rectangle { diff --git a/tests/auto/qml-qtquicktest/tst_chartview_1_2.qml b/tests/auto/qml-qtquicktest/tst_chartview_1_2.qml new file mode 100644 index 0000000..c28e42a --- /dev/null +++ b/tests/auto/qml-qtquicktest/tst_chartview_1_2.qml @@ -0,0 +1,79 @@ +/**************************************************************************** +** +** Copyright (C) 2013 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 Qt Enterprise Charts Add-on. +** +** $QT_BEGIN_LICENSE$ +** 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 +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtTest 1.0 +import QtCommercial.Chart 1.2 + +Rectangle { + width: 400 + height: 300 + + TestCase { + id: tc1 + name: "tst_qml-qtquicktest ChartView Properties 1.2" + when: windowShown + + function test_chartViewProperties() { + compare(chartView.animationOptions, ChartView.NoAnimation, "ChartView.animationOptions"); + verify(chartView.backgroundColor != undefined); + verify(chartView.margins.bottom > 0, "ChartView.margins.bottom"); + verify(chartView.margins.top > 0, "ChartView.margins.top"); + verify(chartView.margins.left > 0, "ChartView.margins.left"); + verify(chartView.margins.right > 0, "ChartView.margins.right"); + compare(chartView.count, 0, "ChartView.count"); + compare(chartView.dropShadowEnabled, false, "ChartView.dropShadowEnabled"); + verify(chartView.plotArea.height > 0, "ChartView.plotArea.height"); + verify(chartView.plotArea.width > 0, "ChartView.plotArea.width"); + verify(chartView.plotArea.x > 0, "ChartView.plotArea.x"); + verify(chartView.plotArea.y > 0, "ChartView.plotArea.y"); + compare(chartView.theme, ChartView.ChartThemeLight, "ChartView.theme"); + compare(chartView.title, "", "ChartView.title"); + compare(chartView.title, "", "ChartView.title"); + verify(chartView.titleColor != undefined, "ChartView.titleColor"); + compare(chartView.titleFont.bold, false, "ChartView.titleFont.bold"); + // Legend + compare(chartView.legend.visible, true, "ChartView.legend.visible"); + compare(chartView.legend.alignment, Qt.AlignTop, "ChartView.legend.alignment"); + compare(chartView.legend.backgroundVisible, false, "ChartView.legend.backgroundVisible"); + verify(chartView.legend.borderColor != undefined, "ChartView.legend.borderColor"); + verify(chartView.legend.color != undefined, "ChartView.legend.color"); + // Legend font + compare(chartView.legend.font.bold, false, "ChartView.legend.font.bold"); + compare(chartView.legend.font.capitalization, Font.MixedCase, "ChartView.legend.font.capitalization"); + verify(chartView.legend.font.family != "", "ChartView.legend.font.family"); + compare(chartView.legend.font.italic, false, "ChartView.legend.font.italic"); + compare(chartView.legend.font.letterSpacing, 0.0, "ChartView.legend.font.letterSpacing"); + verify(chartView.legend.font.pixelSize > 0 + && chartView.legend.font.pixelSize < 50, "ChartView.legend.font.pixelSize"); + verify(chartView.legend.font.pointSize > 0 + && chartView.legend.font.pointSize < 50, "ChartView.legend.font.pointSize"); + compare(chartView.legend.font.strikeout, false, "ChartView.legend.font.strikeout"); + compare(chartView.legend.font.underline, false, "ChartView.legend.font.underline"); + compare(chartView.legend.font.weight, Font.Normal, "ChartView.legend.font.weight"); + compare(chartView.legend.font.wordSpacing, 0.0, "ChartView.legend.font.wordSpacing"); + } + } + + ChartView { + id: chartView + anchors.fill: parent + } +} diff --git a/tests/auto/qml-qtquicktest/tst_chartviewfunctions.qml b/tests/auto/qml-qtquicktest/tst_chartviewfunctions.qml index e3dcf74..2f20211 100644 --- a/tests/auto/qml-qtquicktest/tst_chartviewfunctions.qml +++ b/tests/auto/qml-qtquicktest/tst_chartviewfunctions.qml @@ -18,9 +18,9 @@ ** ****************************************************************************/ -import QtQuick 1.0 -import QtQuickTest 1.0 -import QtCommercial.Chart 1.2 +import QtQuick 2.0 +import QtTest 1.0 +import QtCommercial.Chart 1.3 Rectangle { width: 400 diff --git a/tests/auto/qml-qtquicktest/tst_chartviewfunctions_1_1.qml b/tests/auto/qml-qtquicktest/tst_chartviewfunctions_1_1.qml index a0e240a..90e5a0c 100644 --- a/tests/auto/qml-qtquicktest/tst_chartviewfunctions_1_1.qml +++ b/tests/auto/qml-qtquicktest/tst_chartviewfunctions_1_1.qml @@ -18,8 +18,8 @@ ** ****************************************************************************/ -import QtQuick 1.0 -import QtQuickTest 1.0 +import QtQuick 2.0 +import QtTest 1.0 import QtCommercial.Chart 1.1 Rectangle { @@ -132,6 +132,7 @@ Rectangle { yMax = chartView.axisY().max; yMin = chartView.axisY().min; + // Scroll left chartView.scrollLeft(10); verify(chartView.axisX().max < xMax); verify(chartView.axisX().min < xMin); @@ -142,6 +143,7 @@ Rectangle { yMax = chartView.axisY().max; yMin = chartView.axisY().min; + // Scroll right chartView.scrollRight(10); verify(chartView.axisX().max > xMax); verify(chartView.axisX().min > xMin); diff --git a/tests/auto/qml-qtquicktest/tst_chartviewfunctions_1_2.qml b/tests/auto/qml-qtquicktest/tst_chartviewfunctions_1_2.qml new file mode 100644 index 0000000..ba436ad --- /dev/null +++ b/tests/auto/qml-qtquicktest/tst_chartviewfunctions_1_2.qml @@ -0,0 +1,160 @@ +/**************************************************************************** +** +** Copyright (C) 2013 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 Qt Enterprise Charts Add-on. +** +** $QT_BEGIN_LICENSE$ +** 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 +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtTest 1.0 +import QtCommercial.Chart 1.2 + +Rectangle { + width: 400 + height: 300 + + TestCase { + id: tc1 + name: "tst_qml-qtquicktest ChartView Functions 1.2" + when: windowShown + + function test_chartViewSeriesAndAxes() { + // Create XY series + var line = chartView.createSeries(ChartView.SeriesTypeLine, "line"); + verify(line != null && line != undefined); + var spline = chartView.createSeries(ChartView.SeriesTypeSpline, "spline"); + verify(spline != null && spline != undefined); + var scatter = chartView.createSeries(ChartView.SeriesTypeScatter, "scatter"); + verify(scatter != null && scatter != undefined); + + // Create a series with specific axes + var line2 = chartView.createSeries(ChartView.SeriesTypeLine, "line2", chartView.axisX(line), chartView.axisY(line)); + + // Check that all the XY series use the same axes + verify(chartView.axisX(line) != null); + verify(chartView.axisY(line) != null); + compare(chartView.axisX(line), chartView.axisX(line2)); + compare(chartView.axisY(line), chartView.axisY(line2)); + compare(chartView.axisX(line), chartView.axisX(spline)); + compare(chartView.axisY(line), chartView.axisY(spline)); + compare(chartView.axisX(line), chartView.axisX(scatter)); + compare(chartView.axisY(line), chartView.axisY(scatter)); + + var bar = chartView.createSeries(ChartView.SeriesTypeBar, "bar"); + verify(bar != null && bar != undefined); + var stackedbar = chartView.createSeries(ChartView.SeriesTypeStackedBar, "stackedbar"); + verify(stackedbar != null && stackedbar != undefined); + var percentbar = chartView.createSeries(ChartView.SeriesTypePercentBar, "percentbar"); + verify(percentbar != null && percentbar != undefined); + var horizontalbar = chartView.createSeries(ChartView.SeriesTypeHorizontalBar, "horizontalbar"); + verify(horizontalbar != null && horizontalbar != undefined); + var horizontalstackedbar = chartView.createSeries(ChartView.SeriesTypeHorizontalStackedBar, "horizontalstackedbar"); + verify(horizontalstackedbar != null && horizontalstackedbar != undefined); + var horizontalpercentbar = chartView.createSeries(ChartView.SeriesTypeHorizontalPercentBar, "horizontalpercentbar"); + verify(horizontalpercentbar != null && horizontalpercentbar != undefined); + var area = chartView.createSeries(ChartView.SeriesTypeArea, "area"); + verify(area != null && area != undefined); + + // Remove all series + chartView.removeAllSeries(); + compare(chartView.count, 0); + } + + function test_chartViewRange() { + // Set initial values + chartView.createSeries(ChartView.SeriesTypeLine, "line"); + verify(chartView.axisX() != null); + verify(chartView.axisY() != null); + chartView.axisX().min = 1.0; + chartView.axisX().max = 2.0; + chartView.axisY().min = 1.0; + chartView.axisY().max = 2.0; + + var xMax = chartView.axisX().max; + var xMin = chartView.axisX().min; + var yMax = chartView.axisY().max; + var yMin = chartView.axisY().min; + + // zoom x 2.5 + chartView.zoom(1.5); + verify(chartView.axisX().max < xMax); + verify(chartView.axisX().min > xMin); + verify(chartView.axisY().max < yMax); + verify(chartView.axisY().min > yMin); + xMax = chartView.axisX().max; + xMin = chartView.axisX().min; + yMax = chartView.axisY().max; + yMin = chartView.axisY().min; + + // zoom x 0.5 + chartView.zoom(0.5); + verify(chartView.axisX().max > xMax); + verify(chartView.axisX().min < xMin); + verify(chartView.axisY().max > yMax); + verify(chartView.axisY().min < yMin); + xMax = chartView.axisX().max; + xMin = chartView.axisX().min; + yMax = chartView.axisY().max; + yMin = chartView.axisY().min; + + // Scroll up + chartView.scrollUp(10); + compare(chartView.axisX().max, xMax); + compare(chartView.axisX().min, xMin); + verify(chartView.axisY().max > yMax); + verify(chartView.axisY().min > yMin); + xMax = chartView.axisX().max; + xMin = chartView.axisX().min; + yMax = chartView.axisY().max; + yMin = chartView.axisY().min; + + // Scroll down + chartView.scrollDown(10); + compare(chartView.axisX().max, xMax); + compare(chartView.axisX().min, xMin); + verify(chartView.axisY().max < yMax); + verify(chartView.axisY().min < yMin); + xMax = chartView.axisX().max; + xMin = chartView.axisX().min; + yMax = chartView.axisY().max; + yMin = chartView.axisY().min; + + // Scroll left + chartView.scrollLeft(10); + verify(chartView.axisX().max < xMax); + verify(chartView.axisX().min < xMin); + compare(chartView.axisY().max, yMax); + compare(chartView.axisY().min, yMin); + xMax = chartView.axisX().max; + xMin = chartView.axisX().min; + yMax = chartView.axisY().max; + yMin = chartView.axisY().min; + + // Scroll right + chartView.scrollRight(10); + verify(chartView.axisX().max > xMax); + verify(chartView.axisX().min > xMin); + compare(chartView.axisY().max, yMax); + compare(chartView.axisY().min, yMin); + } + } + + ChartView { + id: chartView + anchors.fill: parent + title: "Chart" + } +} diff --git a/tests/auto/qml-qtquicktest/tst_chartviewsignals.qml b/tests/auto/qml-qtquicktest/tst_chartviewsignals.qml index 92560c4..f4f3156 100644 --- a/tests/auto/qml-qtquicktest/tst_chartviewsignals.qml +++ b/tests/auto/qml-qtquicktest/tst_chartviewsignals.qml @@ -18,9 +18,9 @@ ** ****************************************************************************/ -import QtQuick 1.0 -import QtQuickTest 1.0 -import QtCommercial.Chart 1.2 +import QtQuick 2.0 +import QtTest 1.0 +import QtCommercial.Chart 1.3 Rectangle { width: 400 diff --git a/tests/auto/qml-qtquicktest/tst_chartviewsignals_1_1.qml b/tests/auto/qml-qtquicktest/tst_chartviewsignals_1_1.qml index 64230b7..ca86f48 100644 --- a/tests/auto/qml-qtquicktest/tst_chartviewsignals_1_1.qml +++ b/tests/auto/qml-qtquicktest/tst_chartviewsignals_1_1.qml @@ -18,8 +18,8 @@ ** ****************************************************************************/ -import QtQuick 1.0 -import QtQuickTest 1.0 +import QtQuick 2.0 +import QtTest 1.0 import QtCommercial.Chart 1.1 Rectangle { diff --git a/tests/auto/qml-qtquicktest/tst_chartviewsignals_1_2.qml b/tests/auto/qml-qtquicktest/tst_chartviewsignals_1_2.qml new file mode 100644 index 0000000..457f029 --- /dev/null +++ b/tests/auto/qml-qtquicktest/tst_chartviewsignals_1_2.qml @@ -0,0 +1,73 @@ +/**************************************************************************** +** +** Copyright (C) 2013 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 Qt Enterprise Charts Add-on. +** +** $QT_BEGIN_LICENSE$ +** 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 +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtTest 1.0 +import QtCommercial.Chart 1.2 + +Rectangle { + width: 400 + height: 300 + + TestCase { + id: tc1 + name: "tst_qml-qtquicktest ChartView Signals 1.2" + when: windowShown + + // Verify onSeriesAdded and onSeriesRemoved signals + function test_chartView() { + var series = chartView.createSeries(ChartView.SeriesTypeLine, "line"); + seriesAddedSpy.wait(); + compare(seriesAddedSpy.count, 1, "ChartView.onSeriesAdded"); + + // Modifying layout triggers more than one plotAreaChanged signal + chartView.titleFont.pixelSize = 50; + verify(plotAreaChangedSpy.count > 0, "ChartView.onPlotAreaChanged"); + + chartView.removeSeries(series); + seriesRemovedSpy.wait(); + compare(seriesRemovedSpy.count, 1, "ChartView.onSeriesAdded"); + } + } + + ChartView { + id: chartView + anchors.fill: parent + title: "Chart" + + SignalSpy { + id: plotAreaChangedSpy + target: chartView + signalName: "plotAreaChanged" + } + + SignalSpy { + id: seriesAddedSpy + target: chartView + signalName: "seriesAdded" + } + + SignalSpy { + id: seriesRemovedSpy + target: chartView + signalName: "seriesRemoved" + } + } +} diff --git a/tests/auto/qml-qtquicktest/tst_pieseries.qml b/tests/auto/qml-qtquicktest/tst_pieseries.qml index 9ab1178..e6dc6de 100644 --- a/tests/auto/qml-qtquicktest/tst_pieseries.qml +++ b/tests/auto/qml-qtquicktest/tst_pieseries.qml @@ -18,9 +18,9 @@ ** ****************************************************************************/ -import QtQuick 1.0 -import QtQuickTest 1.0 -import QtCommercial.Chart 1.2 +import QtQuick 2.0 +import QtTest 1.0 +import QtCommercial.Chart 1.3 Rectangle { width: 400 @@ -45,7 +45,7 @@ Rectangle { var slice = pieSeries.append("slice", 10); compare(slice.angleSpan, 360.0); verify(slice.borderColor != undefined); - compare(slice.borderWidth, 0); + compare(slice.borderWidth, 1); verify(slice.color != undefined); compare(slice.explodeDistanceFactor, 0.15); compare(slice.exploded, false); diff --git a/tests/auto/qml-qtquicktest/tst_pieseries_1_1.qml b/tests/auto/qml-qtquicktest/tst_pieseries_1_1.qml index 0e1ab14..54e1716 100644 --- a/tests/auto/qml-qtquicktest/tst_pieseries_1_1.qml +++ b/tests/auto/qml-qtquicktest/tst_pieseries_1_1.qml @@ -18,8 +18,8 @@ ** ****************************************************************************/ -import QtQuick 1.0 -import QtQuickTest 1.0 +import QtQuick 2.0 +import QtTest 1.0 import QtCommercial.Chart 1.1 Rectangle { @@ -45,7 +45,7 @@ Rectangle { var slice = pieSeries.append("slice", 10); compare(slice.angleSpan, 360.0); verify(slice.borderColor != undefined); - compare(slice.borderWidth, 0); + compare(slice.borderWidth, 1); verify(slice.color != undefined); compare(slice.explodeDistanceFactor, 0.15); compare(slice.exploded, false); diff --git a/tests/auto/qml-qtquicktest/tst_pieseries_1_2.qml b/tests/auto/qml-qtquicktest/tst_pieseries_1_2.qml new file mode 100644 index 0000000..f207cb0 --- /dev/null +++ b/tests/auto/qml-qtquicktest/tst_pieseries_1_2.qml @@ -0,0 +1,131 @@ +/**************************************************************************** +** +** Copyright (C) 2013 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 Qt Enterprise Charts Add-on. +** +** $QT_BEGIN_LICENSE$ +** 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 +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtTest 1.0 +import QtCommercial.Chart 1.2 + +Rectangle { + width: 400 + height: 300 + + TestCase { + id: tc1 + name: "tst_qml-qtquicktest PieSeries 1.2" + when: windowShown + + function test_properties() { + compare(pieSeries.endAngle, 360); + compare(pieSeries.holeSize, 0); + compare(pieSeries.horizontalPosition, 0.5); + compare(pieSeries.size, 0.7); + compare(pieSeries.startAngle, 0); + compare(pieSeries.sum, 0); + compare(pieSeries.verticalPosition, 0.5); + } + + function test_sliceproperties() { + var slice = pieSeries.append("slice", 10); + compare(slice.angleSpan, 360.0); + verify(slice.borderColor != undefined); + compare(slice.borderWidth, 1); + verify(slice.color != undefined); + compare(slice.explodeDistanceFactor, 0.15); + compare(slice.exploded, false); + compare(slice.label, "slice"); + compare(slice.labelArmLengthFactor, 0.15); + verify(slice.labelColor != undefined); + compare(slice.labelFont.bold, false); + compare(slice.labelPosition, PieSlice.LabelOutside); + compare(slice.labelVisible, false); + compare(slice.percentage, 1.0); + compare(slice.startAngle, 0.0); + compare(slice.value, 10.0); + } + + function test_append() { + addedSpy.clear(); + countChangedSpy.clear(); + sumChangedSpy.clear(); + var count = 50; + for (var i = 0; i < count; i++) + pieSeries.append("slice" + i, Math.random()); + compare(addedSpy.count, count); + compare(countChangedSpy.count, count); + compare(sumChangedSpy.count, count); + pieSeries.clear(); + } + + function test_remove() { + removedSpy.clear(); + countChangedSpy.clear(); + sumChangedSpy.clear(); + var count = 50; + for (var i = 0; i < count; i++) + pieSeries.append("slice" + i, Math.random()); + for (var j = 0; j < count; j++) + pieSeries.remove(pieSeries.at(0)); + compare(removedSpy.count, count); + compare(countChangedSpy.count, 2 * count); + compare(sumChangedSpy.count, 2 * count); + compare(pieSeries.count, 0); + } + + function test_find() { + var count = 50; + for (var i = 0; i < count; i++) + pieSeries.append("slice" + i, Math.random()); + for (var j = 0; j < count; j++) + compare(pieSeries.find("slice" + j).label, "slice" + j); + pieSeries.clear(); + } + } + + ChartView { + id: chartView + anchors.fill: parent + + PieSeries { + id: pieSeries + name: "pie" + + SignalSpy { + id: addedSpy + target: pieSeries + signalName: "added" + } + SignalSpy { + id: removedSpy + target: pieSeries + signalName: "removed" + } + SignalSpy { + id: sumChangedSpy + target: pieSeries + signalName: "sumChanged" + } + SignalSpy { + id: countChangedSpy + target: pieSeries + signalName: "countChanged" + } + } + } +} diff --git a/tests/auto/qml-qtquicktest/tst_valueaxis.qml b/tests/auto/qml-qtquicktest/tst_valueaxis.qml index 54d03ae..747c243 100644 --- a/tests/auto/qml-qtquicktest/tst_valueaxis.qml +++ b/tests/auto/qml-qtquicktest/tst_valueaxis.qml @@ -18,9 +18,9 @@ ** ****************************************************************************/ -import QtQuick 1.0 -import QtQuickTest 1.0 -import QtCommercial.Chart 1.2 +import QtQuick 2.0 +import QtTest 1.0 +import QtCommercial.Chart 1.3 Rectangle { width: 400 @@ -31,31 +31,30 @@ Rectangle { name: "tst_qml-qtquicktest ValueAxis" when: windowShown - function test_properties() { + // test functions are run in alphabetical order, the name has 'a' so that it + // will be the first function to execute. + function test_a_properties() { // Default properties verify(axisX.min < 0, "AxisX min"); verify(axisX.max > 0, "AxisX max"); verify(axisY.min < 0, "AxisY min"); verify(axisY.max > 0, "AxisY max"); - verify(axisX.tickCount > 0, "AxisX tick count"); - verify(axisY.tickCount > 0, "AxisX tick count"); - compare(axisX.niceNumbersEnabled, false, "nice numbers"); - compare(axisX.labelFormat, "", "label format"); + verify(axisX.tickCount == 5, "AxisX tick count"); + verify(axisY.tickCount == 5, "AxisY tick count"); + verify(axisX.labelFormat == "", "label format"); // Modify properties axisX.tickCount = 3; - compare(axisX.tickCount, 3, "set tick count"); - axisX.niceNumbersEnabled = true; - compare(axisX.niceNumbersEnabled, true, "nice numbers"); + verify(axisX.tickCount == 3, "set tick count"); } function test_functions() { // Set the axis ranges to not "nice" ones... var min = 0.032456456; var max = 10.67845634; - axisX.max = min; + axisX.min = min; axisX.max = max; - axisY.max = min; + axisY.min = min; axisY.max = max; // ...And then apply nice numbers and verify the range was changed diff --git a/tests/auto/qml-qtquicktest/tst_valueaxis_1_1.qml b/tests/auto/qml-qtquicktest/tst_valueaxis_1_1.qml index f8c2307..fa7079f 100644 --- a/tests/auto/qml-qtquicktest/tst_valueaxis_1_1.qml +++ b/tests/auto/qml-qtquicktest/tst_valueaxis_1_1.qml @@ -18,8 +18,8 @@ ** ****************************************************************************/ -import QtQuick 1.0 -import QtQuickTest 1.0 +import QtQuick 2.0 +import QtTest 1.0 import QtCommercial.Chart 1.1 Rectangle { diff --git a/tests/auto/qml-qtquicktest/tst_valueaxis_1_2.qml b/tests/auto/qml-qtquicktest/tst_valueaxis_1_2.qml new file mode 100644 index 0000000..f892b9a --- /dev/null +++ b/tests/auto/qml-qtquicktest/tst_valueaxis_1_2.qml @@ -0,0 +1,116 @@ +/**************************************************************************** +** +** Copyright (C) 2013 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 Qt Enterprise Charts Add-on. +** +** $QT_BEGIN_LICENSE$ +** 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 +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtTest 1.0 +import QtCommercial.Chart 1.2 + +Rectangle { + width: 400 + height: 300 + + TestCase { + id: tc1 + name: "tst_qml-qtquicktest ValueAxis 1.2" + when: windowShown + + // test functions are run in alphabetical order, the name has 'a' so that it + // will be the first function to execute. + function test_a_properties() { + // Default properties + verify(axisX.min < 0, "AxisX min"); + verify(axisX.max > 0, "AxisX max"); + verify(axisY.min < 0, "AxisY min"); + verify(axisY.max > 0, "AxisY max"); + verify(axisX.tickCount == 5, "AxisX tick count"); + verify(axisY.tickCount == 5, "AxisY tick count"); + verify(axisX.labelFormat == "", "label format"); + + // Modify properties + axisX.tickCount = 3; + verify(axisX.tickCount == 3, "set tick count"); + } + + function test_functions() { + // Set the axis ranges to not "nice" ones... + var min = 0.032456456; + var max = 10.67845634; + axisX.min = min; + axisX.max = max; + axisY.min = min; + axisY.max = max; + + // ...And then apply nice numbers and verify the range was changed + axisX.applyNiceNumbers(); + axisY.applyNiceNumbers(); + verify(axisX.min != min); + verify(axisX.max != max); + verify(axisY.min != min); + verify(axisY.max != max); + } + + function test_signals() { + minChangedSpy.clear(); + maxChangedSpy.clear(); + axisX.min = 2; + compare(minChangedSpy.count, 1, "onMinChanged"); + compare(maxChangedSpy.count, 0, "onMaxChanged"); + + axisX.max = 8; + compare(minChangedSpy.count, 1, "onMinChanged"); + compare(maxChangedSpy.count, 1, "onMaxChanged"); + + // restore original values + axisX.min = 0; + axisX.max = 10; + compare(minChangedSpy.count, 2, "onMinChanged"); + compare(maxChangedSpy.count, 2, "onMaxChanged"); + } + } + + ChartView { + id: chartView + anchors.fill: parent + + LineSeries { + id: lineSeries1 + axisX: ValueAxis { + id: axisX + } + axisY: ValueAxis { + id: axisY + } + XYPoint { x: -1; y: -1 } + XYPoint { x: 0; y: 0 } + XYPoint { x: 5; y: 5 } + } + + SignalSpy { + id: minChangedSpy + target: axisX + signalName: "minChanged" + } + SignalSpy { + id: maxChangedSpy + target: axisX + signalName: "maxChanged" + } + } +} diff --git a/tests/auto/qml-qtquicktest/tst_xyseries.qml b/tests/auto/qml-qtquicktest/tst_xyseries.qml index 0a13b98..4b57f31 100644 --- a/tests/auto/qml-qtquicktest/tst_xyseries.qml +++ b/tests/auto/qml-qtquicktest/tst_xyseries.qml @@ -18,9 +18,9 @@ ** ****************************************************************************/ -import QtQuick 1.0 -import QtQuickTest 1.0 -import QtCommercial.Chart 1.2 +import QtQuick 2.0 +import QtTest 1.0 +import QtCommercial.Chart 1.3 Rectangle { width: 400 @@ -57,23 +57,12 @@ Rectangle { function test_axes() { // Axis initialization - compare(chartView.axes.length, 2); - verify(chartView.axes[0] == lineSeries.axisX || chartView.axes[1] == lineSeries.axisX); - verify(chartView.axes[0] == lineSeries.axisY || chartView.axes[1] == lineSeries.axisY); + compare(chartView.axisX(), lineSeries.axisX); + compare(chartView.axisY(), lineSeries.axisY); compare(lineSeries.axisX, splineSeries.axisX); compare(lineSeries.axisY, splineSeries.axisY); compare(lineSeries.axisX, areaSeries.axisX); compare(lineSeries.axisY, areaSeries.axisY); - - // Set illegal axes - lineSeries.axisX = lineSeries.axisY; - compare(lineSeries.axisX, splineSeries.axisX); - lineSeries.axisXTop = lineSeries.axisX; - compare(lineSeries.axisX, splineSeries.axisX); - lineSeries.axisY = lineSeries.axisX; - compare(lineSeries.axisY, splineSeries.axisY); - lineSeries.axisYRight = lineSeries.axisY; - compare(lineSeries.axisY, splineSeries.axisY); } function test_append() { @@ -84,9 +73,9 @@ Rectangle { compare(lineSeries.count, count); compare(splineSeries.count, count); compare(scatterSeries.count, count); - tryCompare(lineSeriesPointAddedSpy.count, count); - tryCompare(splineSeriesPointAddedSpy.count, count); - tryCompare(scatterSeriesPointAddedSpy.count, count); + compare(lineSeriesPointAddedSpy.count, count); + compare(splineSeriesPointAddedSpy.count, count); + compare(scatterSeriesPointAddedSpy.count, count); clear(); compare(lineSeries.count, 0); compare(splineSeries.count, 0); @@ -103,9 +92,9 @@ Rectangle { compare(lineSeries.count, count); compare(splineSeries.count, count); compare(scatterSeries.count, count); - tryCompare(lineSeriesPointReplacedSpy.count, count); - tryCompare(splineSeriesPointReplacedSpy.count, count); - tryCompare(scatterSeriesPointReplacedSpy.count, count); + compare(lineSeriesPointReplacedSpy.count, count); + compare(splineSeriesPointReplacedSpy.count, count); + compare(scatterSeriesPointReplacedSpy.count, count); clear(); } @@ -122,9 +111,9 @@ Rectangle { compare(lineSeries.count, count * 2); compare(splineSeries.count, count * 2); compare(scatterSeries.count, count * 2); - tryCompare(lineSeriesPointAddedSpy.count, count); - tryCompare(splineSeriesPointAddedSpy.count, count); - tryCompare(scatterSeriesPointAddedSpy.count, count); + compare(lineSeriesPointAddedSpy.count, count); + compare(splineSeriesPointAddedSpy.count, count); + compare(scatterSeriesPointAddedSpy.count, count); clear(); } @@ -141,9 +130,9 @@ Rectangle { compare(lineSeries.count, 0); compare(splineSeries.count, 0); compare(scatterSeries.count, 0); - tryCompare(lineSeriesPointRemovedSpy.count, count); - tryCompare(splineSeriesPointRemovedSpy.count, count); - tryCompare(scatterSeriesPointRemovedSpy.count, count); + compare(lineSeriesPointRemovedSpy.count, count); + compare(splineSeriesPointRemovedSpy.count, count); + compare(scatterSeriesPointRemovedSpy.count, count); } // Not a test function, called from test functions diff --git a/tests/auto/qml-qtquicktest/tst_xyseries_1_1.qml b/tests/auto/qml-qtquicktest/tst_xyseries_1_1.qml index 199af71..4484c3b 100644 --- a/tests/auto/qml-qtquicktest/tst_xyseries_1_1.qml +++ b/tests/auto/qml-qtquicktest/tst_xyseries_1_1.qml @@ -18,8 +18,8 @@ ** ****************************************************************************/ -import QtQuick 1.0 -import QtQuickTest 1.0 +import QtQuick 2.0 +import QtTest 1.0 import QtCommercial.Chart 1.1 Rectangle { @@ -63,9 +63,9 @@ Rectangle { compare(lineSeries.count, count); compare(splineSeries.count, count); compare(scatterSeries.count, count); - tryCompare(lineSeriesPointAddedSpy.count, count); - tryCompare(splineSeriesPointAddedSpy.count, count); - tryCompare(scatterSeriesPointAddedSpy.count, count); + compare(lineSeriesPointAddedSpy.count, count); + compare(splineSeriesPointAddedSpy.count, count); + compare(scatterSeriesPointAddedSpy.count, count); clear(); compare(lineSeries.count, 0); compare(splineSeries.count, 0); @@ -82,9 +82,9 @@ Rectangle { compare(lineSeries.count, count); compare(splineSeries.count, count); compare(scatterSeries.count, count); - tryCompare(lineSeriesPointReplacedSpy.count, count); - tryCompare(splineSeriesPointReplacedSpy.count, count); - tryCompare(scatterSeriesPointReplacedSpy.count, count); + compare(lineSeriesPointReplacedSpy.count, count); + compare(splineSeriesPointReplacedSpy.count, count); + compare(scatterSeriesPointReplacedSpy.count, count); clear(); } @@ -101,9 +101,9 @@ Rectangle { compare(lineSeries.count, count * 2); compare(splineSeries.count, count * 2); compare(scatterSeries.count, count * 2); - tryCompare(lineSeriesPointAddedSpy.count, count); - tryCompare(splineSeriesPointAddedSpy.count, count); - tryCompare(scatterSeriesPointAddedSpy.count, count); + compare(lineSeriesPointAddedSpy.count, count); + compare(splineSeriesPointAddedSpy.count, count); + compare(scatterSeriesPointAddedSpy.count, count); clear(); } @@ -120,9 +120,9 @@ Rectangle { compare(lineSeries.count, 0); compare(splineSeries.count, 0); compare(scatterSeries.count, 0); - tryCompare(lineSeriesPointRemovedSpy.count, count); - tryCompare(splineSeriesPointRemovedSpy.count, count); - tryCompare(scatterSeriesPointRemovedSpy.count, count); + compare(lineSeriesPointRemovedSpy.count, count); + compare(splineSeriesPointRemovedSpy.count, count); + compare(scatterSeriesPointRemovedSpy.count, count); } // Not a test function, called from test functions diff --git a/tests/auto/qml-qtquicktest/tst_xyseries_1_2.qml b/tests/auto/qml-qtquicktest/tst_xyseries_1_2.qml new file mode 100644 index 0000000..2445407 --- /dev/null +++ b/tests/auto/qml-qtquicktest/tst_xyseries_1_2.qml @@ -0,0 +1,260 @@ +/**************************************************************************** +** +** Copyright (C) 2013 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 Qt Enterprise Charts Add-on. +** +** $QT_BEGIN_LICENSE$ +** 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 +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtTest 1.0 +import QtCommercial.Chart 1.2 + +Rectangle { + width: 400 + height: 300 + + TestCase { + id: tc1 + name: "tst_qml-qtquicktest XY Series 1.2" + when: windowShown + + function test_properties() { + verify(lineSeries.color != undefined); + compare(lineSeries.pointsVisible, false); + compare(lineSeries.capStyle, Qt.SquareCap); + compare(lineSeries.style, Qt.SolidLine); + compare(lineSeries.width, 2.0); + + verify(splineSeries.color != undefined); + compare(splineSeries.pointsVisible, false); + compare(splineSeries.capStyle, Qt.SquareCap); + compare(splineSeries.style, Qt.SolidLine); + compare(splineSeries.width, 2.0); + + verify(scatterSeries.color != undefined); + verify(scatterSeries.borderColor != undefined); + compare(scatterSeries.borderWidth, 2.0); + compare(scatterSeries.markerShape, ScatterSeries.MarkerShapeCircle); + compare(scatterSeries.markerSize, 15.0); + + verify(areaSeries.color != undefined); + verify(areaSeries.borderColor != undefined); + compare(areaSeries.borderWidth, 2.0); + } + + function test_axes() { + // Axis initialization + compare(chartView.axisX(), lineSeries.axisX); + compare(chartView.axisY(), lineSeries.axisY); + compare(lineSeries.axisX, splineSeries.axisX); + compare(lineSeries.axisY, splineSeries.axisY); + compare(lineSeries.axisX, areaSeries.axisX); + compare(lineSeries.axisY, areaSeries.axisY); + } + + function test_append() { + lineSeriesPointAddedSpy.clear(); + splineSeriesPointAddedSpy.clear(); + scatterSeriesPointAddedSpy.clear(); + var count = append(); + compare(lineSeries.count, count); + compare(splineSeries.count, count); + compare(scatterSeries.count, count); + compare(lineSeriesPointAddedSpy.count, count); + compare(splineSeriesPointAddedSpy.count, count); + compare(scatterSeriesPointAddedSpy.count, count); + clear(); + compare(lineSeries.count, 0); + compare(splineSeries.count, 0); + compare(scatterSeries.count, 0); + } + + function test_replace() { + var count = append(); + for (var i = 0; i < count; i++) { + lineSeries.replace(lineSeries.at(i).x, lineSeries.at(i).y, i, Math.random()); + splineSeries.replace(splineSeries.at(i).x, splineSeries.at(i).y, i, Math.random()); + scatterSeries.replace(scatterSeries.at(i).x, scatterSeries.at(i).y, i, Math.random()); + } + compare(lineSeries.count, count); + compare(splineSeries.count, count); + compare(scatterSeries.count, count); + compare(lineSeriesPointReplacedSpy.count, count); + compare(splineSeriesPointReplacedSpy.count, count); + compare(scatterSeriesPointReplacedSpy.count, count); + clear(); + } + + function test_insert() { + var count = append(); + lineSeriesPointAddedSpy.clear(); + splineSeriesPointAddedSpy.clear(); + scatterSeriesPointAddedSpy.clear(); + for (var i = 0; i < count; i++) { + lineSeries.insert(i * 2, i, Math.random()); + splineSeries.insert(i * 2, i, Math.random()); + scatterSeries.insert(i * 2, i, Math.random()); + } + compare(lineSeries.count, count * 2); + compare(splineSeries.count, count * 2); + compare(scatterSeries.count, count * 2); + compare(lineSeriesPointAddedSpy.count, count); + compare(splineSeriesPointAddedSpy.count, count); + compare(scatterSeriesPointAddedSpy.count, count); + clear(); + } + + function test_remove() { + lineSeriesPointRemovedSpy.clear(); + splineSeriesPointRemovedSpy.clear(); + scatterSeriesPointRemovedSpy.clear(); + var count = append(); + for (var i = 0; i < count; i++) { + lineSeries.remove(lineSeries.at(0).x, lineSeries.at(0).y); + splineSeries.remove(splineSeries.at(0).x, splineSeries.at(0).y); + scatterSeries.remove(scatterSeries.at(0).x, scatterSeries.at(0).y); + } + compare(lineSeries.count, 0); + compare(splineSeries.count, 0); + compare(scatterSeries.count, 0); + compare(lineSeriesPointRemovedSpy.count, count); + compare(splineSeriesPointRemovedSpy.count, count); + compare(scatterSeriesPointRemovedSpy.count, count); + } + + // Not a test function, called from test functions + function append() { + var count = 100; + chartView.axisX().min = 0; + chartView.axisX().max = 100; + chartView.axisY().min = 0; + chartView.axisY().max = 1; + + for (var i = 0; i < count; i++) { + lineSeries.append(i, Math.random()); + splineSeries.append(i, Math.random()); + scatterSeries.append(i, Math.random()); + } + + return count; + } + + // Not a test function, called from test functions + function clear() { + lineSeries.clear(); + splineSeries.clear(); + scatterSeries.clear(); + } + } + + ChartView { + id: chartView + anchors.fill: parent + + LineSeries { + id: lineSeries + name: "line" + + SignalSpy { + id: lineSeriesPointAddedSpy + target: lineSeries + signalName: "pointAdded" + } + + SignalSpy { + id: lineSeriesPointReplacedSpy + target: lineSeries + signalName: "pointReplaced" + } + + SignalSpy { + id: lineSeriesPointsReplacedSpy + target: lineSeries + signalName: "pointsReplaced" + } + + SignalSpy { + id: lineSeriesPointRemovedSpy + target: lineSeries + signalName: "pointRemoved" + } + } + + AreaSeries { + id: areaSeries + name: "area" + upperSeries: lineSeries + } + + SplineSeries { + id: splineSeries + name: "spline" + + SignalSpy { + id: splineSeriesPointAddedSpy + target: splineSeries + signalName: "pointAdded" + } + + SignalSpy { + id: splineSeriesPointReplacedSpy + target: splineSeries + signalName: "pointReplaced" + } + + SignalSpy { + id: splineSeriesPointsReplacedSpy + target: splineSeries + signalName: "pointsReplaced" + } + + SignalSpy { + id: splineSeriesPointRemovedSpy + target: splineSeries + signalName: "pointRemoved" + } + } + + ScatterSeries { + id: scatterSeries + name: "scatter" + + SignalSpy { + id: scatterSeriesPointAddedSpy + target: scatterSeries + signalName: "pointAdded" + } + + SignalSpy { + id: scatterSeriesPointReplacedSpy + target: scatterSeries + signalName: "pointReplaced" + } + + SignalSpy { + id: scatterSeriesPointsReplacedSpy + target: scatterSeries + signalName: "pointsReplaced" + } + + SignalSpy { + id: scatterSeriesPointRemovedSpy + target: scatterSeries + signalName: "pointRemoved" + } + } + } +}