diff --git a/tests/auto/qml-qtquicktest/tst_barcategoryaxis.qml b/tests/auto/qml-qtquicktest/tst_barcategoryaxis.qml index a18ab54..6a008d3 100644 --- a/tests/auto/qml-qtquicktest/tst_barcategoryaxis.qml +++ b/tests/auto/qml-qtquicktest/tst_barcategoryaxis.qml @@ -18,7 +18,7 @@ import QtQuick 2.0 import QtTest 1.0 -import QtCharts 2.0 +import QtCharts 2.1 Rectangle { width: 400 diff --git a/tests/auto/qml-qtquicktest/tst_barcategoryaxis_2_0.qml b/tests/auto/qml-qtquicktest/tst_barcategoryaxis_2_0.qml new file mode 100644 index 0000000..88850fc --- /dev/null +++ b/tests/auto/qml-qtquicktest/tst_barcategoryaxis_2_0.qml @@ -0,0 +1,116 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd +** All rights reserved. +** For any questions to The Qt Company, please use contact form at http://qt.io +** +** This file is part of the Qt Charts module. +** +** Licensees holding valid commercial license for Qt may use this file in +** accordance with the Qt License Agreement provided with the Software +** or, alternatively, in accordance with the terms contained in a written +** agreement between you and The Qt Company. +** +** If you have questions regarding the use of this file, please use +** contact form at http://qt.io +** +****************************************************************************/ + +import QtQuick 2.0 +import QtTest 1.0 +import QtCharts 2.0 + +Rectangle { + width: 400 + height: 300 + + TestCase { + id: tc1 + name: "tst_qml-qtquicktest BarCategoryAxis 2.0" + 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"); + } + + function test_seriesAxisClear() { + verify(barSeries1.axisX.min !== "", "barSeries1.axisX.min"); + verify(barSeries1.axisX.max !== "", "barSeries1.axisX.max"); + verify(barSeries1.axisX.count !== 0, "barSeries1.axisX.count"); // category count + barSeries1.axisX.clear(); + verify(barSeries1.axisX.min === "", "barSeries1.axisX.min"); + verify(barSeries1.axisX.max === "", "barSeries1.axisX.max"); + verify(barSeries1.axisX.count === 0); + } + + } + + ChartView { + id: chartView + anchors.fill: parent + + BarSeries { + id: barSeries1 + axisX: BarCategoryAxis { + id: axisX + categories: ["Jan", "Feb", "Mar", "Apr", "May", "Jun" ] + } + axisY: ValueAxis { + 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 9faa4e6..aa80ee8 100644 --- a/tests/auto/qml-qtquicktest/tst_barseries.qml +++ b/tests/auto/qml-qtquicktest/tst_barseries.qml @@ -18,7 +18,7 @@ import QtQuick 2.0 import QtTest 1.0 -import QtCharts 2.0 +import QtCharts 2.1 Rectangle { width: 400 diff --git a/tests/auto/qml-qtquicktest/tst_barseries_2_0.qml b/tests/auto/qml-qtquicktest/tst_barseries_2_0.qml new file mode 100644 index 0000000..d1f32e3 --- /dev/null +++ b/tests/auto/qml-qtquicktest/tst_barseries_2_0.qml @@ -0,0 +1,161 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd +** All rights reserved. +** For any questions to The Qt Company, please use contact form at http://qt.io +** +** This file is part of the Qt Charts module. +** +** Licensees holding valid commercial license for Qt may use this file in +** accordance with the Qt License Agreement provided with the Software +** or, alternatively, in accordance with the terms contained in a written +** agreement between you and The Qt Company. +** +** If you have questions regarding the use of this file, please use +** contact form at http://qt.io +** +****************************************************************************/ + +import QtQuick 2.0 +import QtTest 1.0 +import QtCharts 2.0 + +Rectangle { + width: 400 + height: 300 + + TestCase { + id: tc1 + name: "tst_qml-qtquicktest BarSeries 2.0" + when: windowShown + + function test_properties() { + compare(barSeries.barWidth, 0.5); + compare(barSeries.labelsVisible, false); + compare(barSeries.labelsPosition, BarSeries.LabelsCenter); + } + + function test_setproperties() { + var set = barSeries.append("property", [1, 2, 3]) + compare(set.brushFilename, ""); + } + + 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_signals() { + labelsPositionSpy.clear(); + barSeries.labelsPosition = BarSeries.LabelsOutsideEnd; + compare(labelsPositionSpy.count, 1, "onLabelsPositionChanged") + } + + 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" + } + SignalSpy { + id: labelsPositionSpy + target: barSeries + signalName: "labelsPositionChanged" + } + } + + 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 index 8fc72c9..c60391a 100644 --- a/tests/auto/qml-qtquicktest/tst_boxplotseries.qml +++ b/tests/auto/qml-qtquicktest/tst_boxplotseries.qml @@ -18,7 +18,7 @@ import QtQuick 2.0 import QtTest 1.0 -import QtCharts 2.0 +import QtCharts 2.1 Rectangle { width: 400 diff --git a/tests/auto/qml-qtquicktest/tst_boxplotseries_2_0.qml b/tests/auto/qml-qtquicktest/tst_boxplotseries_2_0.qml new file mode 100644 index 0000000..6fce3ae --- /dev/null +++ b/tests/auto/qml-qtquicktest/tst_boxplotseries_2_0.qml @@ -0,0 +1,98 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd +** All rights reserved. +** For any questions to The Qt Company, please use contact form at http://qt.io +** +** This file is part of the Qt Charts module. +** +** Licensees holding valid commercial license for Qt may use this file in +** accordance with the Qt License Agreement provided with the Software +** or, alternatively, in accordance with the terms contained in a written +** agreement between you and The Qt Company. +** +** If you have questions regarding the use of this file, please use +** contact form at http://qt.io +** +****************************************************************************/ + +import QtQuick 2.0 +import QtTest 1.0 +import QtCharts 2.0 + +Rectangle { + width: 400 + height: 300 + + TestCase { + id: tc1 + name: "tst_qml-qtquicktest BoxPlotSeries 2.0" + when: windowShown + + function test_properties() { + compare(boxPlotSeries.boxWidth, 0.5); + compare(boxPlotSeries.brushFilename, ""); + } + + function test_setproperties() { + var set = boxPlotSeries.append("boxplot", [1, 2, 5, 6, 8]); + compare(set.label, "boxplot"); + compare(set.count, 5); + compare(set.brushFilename, ""); + } + + function test_append() { + boxPlotSeries.clear(); + 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); + compare(boxPlotSeries.count, count) + boxPlotSeries.clear(); + } + + function test_remove() { + boxPlotSeries.clear(); + 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); + compare(boxPlotSeries.count, 0) + } + } + + 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_2_0.qml b/tests/auto/qml-qtquicktest/tst_categoryaxis_2_0.qml index 42d226b..d583fa9 100644 --- a/tests/auto/qml-qtquicktest/tst_categoryaxis_2_0.qml +++ b/tests/auto/qml-qtquicktest/tst_categoryaxis_2_0.qml @@ -26,7 +26,7 @@ Rectangle { TestCase { id: tc1 - name: "tst_qml-qtquicktest CategoryAxis" + name: "tst_qml-qtquicktest CategoryAxis 2.0" when: windowShown function test_minMax() { diff --git a/tests/auto/qml-qtquicktest/tst_chartview_2_0.qml b/tests/auto/qml-qtquicktest/tst_chartview_2_0.qml index 67b9155..a9e0774 100644 --- a/tests/auto/qml-qtquicktest/tst_chartview_2_0.qml +++ b/tests/auto/qml-qtquicktest/tst_chartview_2_0.qml @@ -26,7 +26,7 @@ Rectangle { TestCase { id: tc1 - name: "tst_qml-qtquicktest ChartView Properties" + name: "tst_qml-qtquicktest ChartView Properties 2.0" when: windowShown function test_chartViewProperties() { diff --git a/tests/auto/qml-qtquicktest/tst_chartviewfunctions_2_0.qml b/tests/auto/qml-qtquicktest/tst_chartviewfunctions_2_0.qml index 2c23bdd..7ea9c7d 100644 --- a/tests/auto/qml-qtquicktest/tst_chartviewfunctions_2_0.qml +++ b/tests/auto/qml-qtquicktest/tst_chartviewfunctions_2_0.qml @@ -26,7 +26,7 @@ Rectangle { TestCase { id: tc1 - name: "tst_qml-qtquicktest ChartView Functions" + name: "tst_qml-qtquicktest ChartView Functions 2.0" when: windowShown function test_chartViewSeriesAndAxes() { diff --git a/tests/auto/qml-qtquicktest/tst_chartviewsignals.qml b/tests/auto/qml-qtquicktest/tst_chartviewsignals.qml index 2e4580f..8dabfda 100644 --- a/tests/auto/qml-qtquicktest/tst_chartviewsignals.qml +++ b/tests/auto/qml-qtquicktest/tst_chartviewsignals.qml @@ -18,7 +18,7 @@ import QtQuick 2.0 import QtTest 1.0 -import QtCharts 2.0 +import QtCharts 2.1 Rectangle { width: 400 diff --git a/tests/auto/qml-qtquicktest/tst_chartviewsignals_2_0.qml b/tests/auto/qml-qtquicktest/tst_chartviewsignals_2_0.qml new file mode 100644 index 0000000..ab7570a --- /dev/null +++ b/tests/auto/qml-qtquicktest/tst_chartviewsignals_2_0.qml @@ -0,0 +1,71 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd +** All rights reserved. +** For any questions to The Qt Company, please use contact form at http://qt.io +** +** This file is part of the Qt Charts module. +** +** Licensees holding valid commercial license for Qt may use this file in +** accordance with the Qt License Agreement provided with the Software +** or, alternatively, in accordance with the terms contained in a written +** agreement between you and The Qt Company. +** +** If you have questions regarding the use of this file, please use +** contact form at http://qt.io +** +****************************************************************************/ + +import QtQuick 2.0 +import QtTest 1.0 +import QtCharts 2.0 + +Rectangle { + width: 400 + height: 300 + + TestCase { + id: tc1 + name: "tst_qml-qtquicktest ChartView Signals 2.0" + 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 617c1ea..c94a4f9 100644 --- a/tests/auto/qml-qtquicktest/tst_pieseries.qml +++ b/tests/auto/qml-qtquicktest/tst_pieseries.qml @@ -18,7 +18,7 @@ import QtQuick 2.0 import QtTest 1.0 -import QtCharts 2.0 +import QtCharts 2.1 Rectangle { width: 400 diff --git a/tests/auto/qml-qtquicktest/tst_pieseries_2_0.qml b/tests/auto/qml-qtquicktest/tst_pieseries_2_0.qml new file mode 100644 index 0000000..59dacf7 --- /dev/null +++ b/tests/auto/qml-qtquicktest/tst_pieseries_2_0.qml @@ -0,0 +1,133 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd +** All rights reserved. +** For any questions to The Qt Company, please use contact form at http://qt.io +** +** This file is part of the Qt Charts module. +** +** Licensees holding valid commercial license for Qt may use this file in +** accordance with the Qt License Agreement provided with the Software +** or, alternatively, in accordance with the terms contained in a written +** agreement between you and The Qt Company. +** +** If you have questions regarding the use of this file, please use +** contact form at http://qt.io +** +****************************************************************************/ + +import QtQuick 2.0 +import QtTest 1.0 +import QtCharts 2.0 + +Rectangle { + width: 400 + height: 300 + + TestCase { + id: tc1 + name: "tst_qml-qtquicktest PieSeries 2.0" + 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); + compare(slice.brushFilename, ""); + } + + 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_and_at() { + 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); + compare(pieSeries.find("slice" + j).brushFilename, ""); + } + compare(pieSeries.at(3).brushFilename,""); + 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_2_0.qml b/tests/auto/qml-qtquicktest/tst_valueaxis_2_0.qml index 34c2f9e..2268453 100644 --- a/tests/auto/qml-qtquicktest/tst_valueaxis_2_0.qml +++ b/tests/auto/qml-qtquicktest/tst_valueaxis_2_0.qml @@ -26,7 +26,7 @@ Rectangle { TestCase { id: tc1 - name: "tst_qml-qtquicktest ValueAxis" + name: "tst_qml-qtquicktest ValueAxis 2.0" when: windowShown // test functions are run in alphabetical order, the name has 'a' so that it diff --git a/tests/auto/qml-qtquicktest/tst_xyseries_2_0.qml b/tests/auto/qml-qtquicktest/tst_xyseries_2_0.qml index 21729ed..a05d548 100644 --- a/tests/auto/qml-qtquicktest/tst_xyseries_2_0.qml +++ b/tests/auto/qml-qtquicktest/tst_xyseries_2_0.qml @@ -26,7 +26,7 @@ Rectangle { TestCase { id: tc1 - name: "tst_qml-qtquicktest XY Series" + name: "tst_qml-qtquicktest XY Series 2.0" when: windowShown function test_properties() {