##// END OF EJS Templates
Fix Charts QML api auto test...
Titta Heikkala -
r2638:c98d8af1763d
parent child
Show More
@@ -0,0 +1,107
1 /****************************************************************************
2 **
3 ** Copyright (C) 2013 Digia Plc
4 ** All rights reserved.
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 **
7 ** This file is part of the Qt Enterprise Charts Add-on.
8 **
9 ** $QT_BEGIN_LICENSE$
10 ** Licensees holding valid Qt Enterprise licenses may use this file in
11 ** accordance with the Qt Enterprise License Agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia.
14 **
15 ** If you have questions regarding the use of this file, please use
16 ** contact form at http://qt.digia.com
17 ** $QT_END_LICENSE$
18 **
19 ****************************************************************************/
20
21 import QtQuick 2.0
22 import QtTest 1.0
23 import QtCommercial.Chart 1.2
24
25 Rectangle {
26 width: 400
27 height: 300
28
29 TestCase {
30 id: tc1
31 name: "tst_qml-qtquicktest BarCategoryAxis 1.2"
32 when: windowShown
33
34 function test_minMax() {
35 compare(barSeries1.axisX.min, "Jan", "AxisX min");
36 compare(barSeries1.axisX.max, "Jun", "AxisX max");
37 compare(barSeries1.axisY.min, 0, "AxisY min");
38 compare(barSeries1.axisY.max, 10, "AxisY max");
39 }
40
41 function test_categories() {
42 compare(barSeries1.axisX.count, 6, "AxisX count");
43 categoriesCountChangedSpy.clear();
44 categoriesChangedSpy.clear();
45
46 // Replace categories
47 barSeries1.axisX.categories = ["Tam", "Hel", "Maa", "Huh"];
48 compare(barSeries1.axisX.count, 4, "AxisX count");
49 compare(categoriesCountChangedSpy.count, 1, "onCountChanged");
50 compare(categoriesChangedSpy.count, 1, "onCategoriesChanged");
51
52 // Reset the original categories
53 barSeries1.axisX.categories = ["Jan", "Feb", "Mar", "Apr", "May", "Jun"]
54 compare(barSeries1.axisX.count, 6, "AxisX count");
55 compare(categoriesCountChangedSpy.count, 2, "onCountChanged");
56 compare(categoriesChangedSpy.count, 2, "onCategoriesChanged");
57 }
58
59 function test_minMaxChanged() {
60 axisY.min = -1;
61 compare(minChangedSpy.count, 1, "onMinChanged");
62 compare(maxChangedSpy.count, 0, "onMaxChanged");
63 axisY.max = 12;
64 compare(minChangedSpy.count, 1, "onMinChanged");
65 compare(maxChangedSpy.count, 1, "onMaxChanged");
66 }
67 }
68
69 ChartView {
70 id: chartView
71 anchors.fill: parent
72
73 BarSeries {
74 id: barSeries1
75 axisX: BarCategoryAxis {
76 id: axisX
77 categories: ["Jan", "Feb", "Mar", "Apr", "May", "Jun" ]
78 }
79 axisY: ValuesAxis {
80 id: axisY
81 min: 0
82 max: 10
83 }
84 }
85
86 SignalSpy {
87 id: categoriesCountChangedSpy
88 target: axisX
89 signalName: "countChanged"
90 }
91 SignalSpy {
92 id: categoriesChangedSpy
93 target: axisX
94 signalName: "categoriesChanged"
95 }
96 SignalSpy {
97 id: minChangedSpy
98 target: axisY
99 signalName: "minChanged"
100 }
101 SignalSpy {
102 id: maxChangedSpy
103 target: axisY
104 signalName: "maxChanged"
105 }
106 }
107 }
@@ -0,0 +1,146
1 /****************************************************************************
2 **
3 ** Copyright (C) 2013 Digia Plc
4 ** All rights reserved.
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 **
7 ** This file is part of the Qt Enterprise Charts Add-on.
8 **
9 ** $QT_BEGIN_LICENSE$
10 ** Licensees holding valid Qt Enterprise licenses may use this file in
11 ** accordance with the Qt Enterprise License Agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia.
14 **
15 ** If you have questions regarding the use of this file, please use
16 ** contact form at http://qt.digia.com
17 ** $QT_END_LICENSE$
18 **
19 ****************************************************************************/
20
21 import QtQuick 2.0
22 import QtTest 1.0
23 import QtCommercial.Chart 1.2
24
25 Rectangle {
26 width: 400
27 height: 300
28
29 TestCase {
30 id: tc1
31 name: "tst_qml-qtquicktest BarSeries 1.2"
32 when: windowShown
33
34 function test_properties() {
35 compare(barSeries.barWidth, 0.5);
36 compare(barSeries.labelsVisible, false);
37 }
38
39 function test_axes() {
40 verify(chartView.axisX() == barSeries.axisX);
41 verify(chartView.axisY() == barSeries.axisY);
42
43 compare(barSeries.axisX, stackedBarSeries.axisX);
44 compare(barSeries.axisY, stackedBarSeries.axisY);
45
46 compare(barSeries.axisX, percentBarSeries.axisX);
47 compare(barSeries.axisY, percentBarSeries.axisY);
48 }
49
50 function test_append() {
51 var setCount = 5;
52 var valueCount = 50;
53 addedSpy.clear();
54 append(setCount, valueCount);
55
56 compare(barSeries.count, setCount);
57 for (var k = 0; k < setCount; k++) {
58 compare(barSeries.at(k).count, valueCount);
59 compare(barSeries.at(k).label, "barset" + k);
60 }
61 compare(addedSpy.count, setCount);
62
63 barSeries.clear();
64 compare(barSeries.count, 0);
65 }
66
67 function test_insert() {
68 var setCount = 5;
69 var valueCount = 50;
70 addedSpy.clear();
71 append(setCount, valueCount);
72
73 for (var i = 0; i < setCount; i++) {
74 var values = [];
75 for (var j = 0; j < valueCount; j++)
76 values[j] = Math.random() * 10;
77 var set = barSeries.insert(i, "barset" + i, values);
78 compare(set.label, "barset" + i);
79 }
80
81 compare(barSeries.count, setCount * 2);
82 for (var k = 0; k < setCount * 2; k++)
83 compare(barSeries.at(k).count, valueCount);
84 compare(addedSpy.count, 2 * setCount);
85
86 barSeries.clear();
87 compare(barSeries.count, 0);
88 }
89
90 function test_remove() {
91 var setCount = 5;
92 var valueCount = 50;
93 removedSpy.clear();
94 append(setCount, valueCount);
95
96 for (var k = 0; k < setCount; k++)
97 barSeries.remove(barSeries.at(0));
98
99 compare(barSeries.count, 0);
100 compare(removedSpy.count, setCount);
101 }
102
103 // Not a test function, used by one or more test functions
104 function append(setCount, valueCount) {
105 for (var i = 0; i < setCount; i++) {
106 var values = [];
107 for (var j = 0; j < valueCount; j++)
108 values[j] = Math.random() * 10;
109 barSeries.append("barset" + i, values);
110 }
111 }
112 }
113
114 ChartView {
115 id: chartView
116 anchors.fill: parent
117
118 BarSeries {
119 id: barSeries
120 name: "bar"
121 axisX: BarCategoryAxis {}
122 axisY: ValueAxis { min: 0; max: 10 }
123
124 SignalSpy {
125 id: addedSpy
126 target: barSeries
127 signalName: "barsetsAdded"
128 }
129 SignalSpy {
130 id: removedSpy
131 target: barSeries
132 signalName: "barsetsRemoved"
133 }
134 }
135
136 StackedBarSeries {
137 id: stackedBarSeries
138 name: "stackedBar"
139 }
140
141 PercentBarSeries {
142 id: percentBarSeries
143 name: "percentBar"
144 }
145 }
146 }
@@ -0,0 +1,96
1 /****************************************************************************
2 **
3 ** Copyright (C) 2013 Digia Plc
4 ** All rights reserved.
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 **
7 ** This file is part of the Qt Enterprise Charts Add-on.
8 **
9 ** $QT_BEGIN_LICENSE$
10 ** Licensees holding valid Qt Enterprise licenses may use this file in
11 ** accordance with the Qt Enterprise License Agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia.
14 **
15 ** If you have questions regarding the use of this file, please use
16 ** contact form at http://qt.digia.com
17 ** $QT_END_LICENSE$
18 **
19 ****************************************************************************/
20
21 import QtQuick 2.0
22 import QtTest 1.0
23 import QtCommercial.Chart 1.3
24
25 Rectangle {
26 width: 400
27 height: 300
28
29 TestCase {
30 id: tc1
31 name: "tst_qml-qtquicktest BoxPlotSeries"
32 when: windowShown
33
34 function test_properties() {
35 compare(boxPlotSeries.boxWidth, 0.5);
36 }
37
38 function test_setproperties() {
39 var set = boxPlotSeries.append("boxplot", [1, 2, 5, 6, 8]);
40 compare(set.label, "boxplot");
41 compare(set.count, 5);
42 }
43
44 function test_append() {
45 addedSpy.clear();
46 countChangedSpy.clear();
47 var count = 50;
48 for (var i = 0; i < count; i++)
49 boxPlotSeries.append("boxplot" + i, Math.random());
50 compare(addedSpy.count, count);
51 compare(countChangedSpy.count, count);
52 console.log("Check the series count once QTRD-2504 is implemented");
53 boxPlotSeries.clear();
54 }
55
56 function test_remove() {
57 removedSpy.clear();
58 countChangedSpy.clear();
59 var count = 50;
60 for (var i = 0; i < count; i++)
61 boxPlotSeries.append("boxplot" + i, Math.random());
62 for (var j = 0; j < count; j++)
63 boxPlotSeries.remove(boxPlotSeries.at(0));
64 compare(removedSpy.count, count);
65 compare(countChangedSpy.count, 2 * count);
66 console.log("Check the series count once QTRD-2504 is implemented");
67 }
68 }
69
70 ChartView {
71 id: chartView
72 anchors.fill: parent
73
74 BoxPlotSeries {
75 id: boxPlotSeries
76 name: "boxplot"
77 BoxSet { label: "Jan"; values: [3, 4, 5.1, 6.2, 8.5] }
78
79 SignalSpy {
80 id: addedSpy
81 target: boxPlotSeries
82 signalName: "boxsetsAdded"
83 }
84 SignalSpy {
85 id: removedSpy
86 target: boxPlotSeries
87 signalName: "boxsetsRemoved"
88 }
89 SignalSpy {
90 id: countChangedSpy
91 target: boxPlotSeries
92 signalName: "countChanged"
93 }
94 }
95 }
96 }
@@ -0,0 +1,84
1 /****************************************************************************
2 **
3 ** Copyright (C) 2013 Digia Plc
4 ** All rights reserved.
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 **
7 ** This file is part of the Qt Enterprise Charts Add-on.
8 **
9 ** $QT_BEGIN_LICENSE$
10 ** Licensees holding valid Qt Enterprise licenses may use this file in
11 ** accordance with the Qt Enterprise License Agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia.
14 **
15 ** If you have questions regarding the use of this file, please use
16 ** contact form at http://qt.digia.com
17 ** $QT_END_LICENSE$
18 **
19 ****************************************************************************/
20
21 import QtQuick 2.0
22 import QtTest 1.0
23 import QtCommercial.Chart 1.2
24
25 Rectangle {
26 width: 400
27 height: 300
28
29 TestCase {
30 id: tc1
31 name: "tst_qml-qtquicktest CategoryAxis 1.2"
32 when: windowShown
33
34 function test_minMax() {
35 compare(lineSeries1.axisX.min, 0, "AxisX min");
36 compare(lineSeries1.axisX.max, 10, "AxisX max");
37 compare(lineSeries1.axisY.min, 0, "AxisY min");
38 compare(lineSeries1.axisY.max, 10, "AxisY max");
39 }
40
41 function test_categories() {
42 compare(lineSeries1.axisY.startValue, 0, "AxisY start value");
43 compare(lineSeries1.axisY.count, 3, "AxisY count");
44 compare(lineSeries1.axisY.categoriesLabels[0], "label0", "AxisY categories labels");
45 compare(lineSeries1.axisY.categoriesLabels[1], "label1", "AxisY categories labels");
46 compare(lineSeries1.axisY.categoriesLabels[2], "label2", "AxisY categories labels");
47 }
48 }
49
50 ChartView {
51 id: chartView
52 anchors.fill: parent
53
54 LineSeries {
55 id: lineSeries1
56 axisX: ValuesAxis {
57 id: axisX
58 min: 0
59 max: 10
60 }
61 axisY: CategoryAxis {
62 id: axisY
63 min: 0
64 max: 10
65 startValue: 0
66 CategoryRange {
67 label: "label0"
68 endValue: 1
69 }
70 CategoryRange {
71 label: "label1"
72 endValue: 3
73 }
74 CategoryRange {
75 label: "label2"
76 endValue: 10
77 }
78 }
79 XYPoint { x: -1; y: -1 }
80 XYPoint { x: 0; y: 0 }
81 XYPoint { x: 5; y: 5 }
82 }
83 }
84 }
@@ -0,0 +1,79
1 /****************************************************************************
2 **
3 ** Copyright (C) 2013 Digia Plc
4 ** All rights reserved.
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 **
7 ** This file is part of the Qt Enterprise Charts Add-on.
8 **
9 ** $QT_BEGIN_LICENSE$
10 ** Licensees holding valid Qt Enterprise licenses may use this file in
11 ** accordance with the Qt Enterprise License Agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia.
14 **
15 ** If you have questions regarding the use of this file, please use
16 ** contact form at http://qt.digia.com
17 ** $QT_END_LICENSE$
18 **
19 ****************************************************************************/
20
21 import QtQuick 2.0
22 import QtTest 1.0
23 import QtCommercial.Chart 1.2
24
25 Rectangle {
26 width: 400
27 height: 300
28
29 TestCase {
30 id: tc1
31 name: "tst_qml-qtquicktest ChartView Properties 1.2"
32 when: windowShown
33
34 function test_chartViewProperties() {
35 compare(chartView.animationOptions, ChartView.NoAnimation, "ChartView.animationOptions");
36 verify(chartView.backgroundColor != undefined);
37 verify(chartView.margins.bottom > 0, "ChartView.margins.bottom");
38 verify(chartView.margins.top > 0, "ChartView.margins.top");
39 verify(chartView.margins.left > 0, "ChartView.margins.left");
40 verify(chartView.margins.right > 0, "ChartView.margins.right");
41 compare(chartView.count, 0, "ChartView.count");
42 compare(chartView.dropShadowEnabled, false, "ChartView.dropShadowEnabled");
43 verify(chartView.plotArea.height > 0, "ChartView.plotArea.height");
44 verify(chartView.plotArea.width > 0, "ChartView.plotArea.width");
45 verify(chartView.plotArea.x > 0, "ChartView.plotArea.x");
46 verify(chartView.plotArea.y > 0, "ChartView.plotArea.y");
47 compare(chartView.theme, ChartView.ChartThemeLight, "ChartView.theme");
48 compare(chartView.title, "", "ChartView.title");
49 compare(chartView.title, "", "ChartView.title");
50 verify(chartView.titleColor != undefined, "ChartView.titleColor");
51 compare(chartView.titleFont.bold, false, "ChartView.titleFont.bold");
52 // Legend
53 compare(chartView.legend.visible, true, "ChartView.legend.visible");
54 compare(chartView.legend.alignment, Qt.AlignTop, "ChartView.legend.alignment");
55 compare(chartView.legend.backgroundVisible, false, "ChartView.legend.backgroundVisible");
56 verify(chartView.legend.borderColor != undefined, "ChartView.legend.borderColor");
57 verify(chartView.legend.color != undefined, "ChartView.legend.color");
58 // Legend font
59 compare(chartView.legend.font.bold, false, "ChartView.legend.font.bold");
60 compare(chartView.legend.font.capitalization, Font.MixedCase, "ChartView.legend.font.capitalization");
61 verify(chartView.legend.font.family != "", "ChartView.legend.font.family");
62 compare(chartView.legend.font.italic, false, "ChartView.legend.font.italic");
63 compare(chartView.legend.font.letterSpacing, 0.0, "ChartView.legend.font.letterSpacing");
64 verify(chartView.legend.font.pixelSize > 0
65 && chartView.legend.font.pixelSize < 50, "ChartView.legend.font.pixelSize");
66 verify(chartView.legend.font.pointSize > 0
67 && chartView.legend.font.pointSize < 50, "ChartView.legend.font.pointSize");
68 compare(chartView.legend.font.strikeout, false, "ChartView.legend.font.strikeout");
69 compare(chartView.legend.font.underline, false, "ChartView.legend.font.underline");
70 compare(chartView.legend.font.weight, Font.Normal, "ChartView.legend.font.weight");
71 compare(chartView.legend.font.wordSpacing, 0.0, "ChartView.legend.font.wordSpacing");
72 }
73 }
74
75 ChartView {
76 id: chartView
77 anchors.fill: parent
78 }
79 }
@@ -0,0 +1,160
1 /****************************************************************************
2 **
3 ** Copyright (C) 2013 Digia Plc
4 ** All rights reserved.
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 **
7 ** This file is part of the Qt Enterprise Charts Add-on.
8 **
9 ** $QT_BEGIN_LICENSE$
10 ** Licensees holding valid Qt Enterprise licenses may use this file in
11 ** accordance with the Qt Enterprise License Agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia.
14 **
15 ** If you have questions regarding the use of this file, please use
16 ** contact form at http://qt.digia.com
17 ** $QT_END_LICENSE$
18 **
19 ****************************************************************************/
20
21 import QtQuick 2.0
22 import QtTest 1.0
23 import QtCommercial.Chart 1.2
24
25 Rectangle {
26 width: 400
27 height: 300
28
29 TestCase {
30 id: tc1
31 name: "tst_qml-qtquicktest ChartView Functions 1.2"
32 when: windowShown
33
34 function test_chartViewSeriesAndAxes() {
35 // Create XY series
36 var line = chartView.createSeries(ChartView.SeriesTypeLine, "line");
37 verify(line != null && line != undefined);
38 var spline = chartView.createSeries(ChartView.SeriesTypeSpline, "spline");
39 verify(spline != null && spline != undefined);
40 var scatter = chartView.createSeries(ChartView.SeriesTypeScatter, "scatter");
41 verify(scatter != null && scatter != undefined);
42
43 // Create a series with specific axes
44 var line2 = chartView.createSeries(ChartView.SeriesTypeLine, "line2", chartView.axisX(line), chartView.axisY(line));
45
46 // Check that all the XY series use the same axes
47 verify(chartView.axisX(line) != null);
48 verify(chartView.axisY(line) != null);
49 compare(chartView.axisX(line), chartView.axisX(line2));
50 compare(chartView.axisY(line), chartView.axisY(line2));
51 compare(chartView.axisX(line), chartView.axisX(spline));
52 compare(chartView.axisY(line), chartView.axisY(spline));
53 compare(chartView.axisX(line), chartView.axisX(scatter));
54 compare(chartView.axisY(line), chartView.axisY(scatter));
55
56 var bar = chartView.createSeries(ChartView.SeriesTypeBar, "bar");
57 verify(bar != null && bar != undefined);
58 var stackedbar = chartView.createSeries(ChartView.SeriesTypeStackedBar, "stackedbar");
59 verify(stackedbar != null && stackedbar != undefined);
60 var percentbar = chartView.createSeries(ChartView.SeriesTypePercentBar, "percentbar");
61 verify(percentbar != null && percentbar != undefined);
62 var horizontalbar = chartView.createSeries(ChartView.SeriesTypeHorizontalBar, "horizontalbar");
63 verify(horizontalbar != null && horizontalbar != undefined);
64 var horizontalstackedbar = chartView.createSeries(ChartView.SeriesTypeHorizontalStackedBar, "horizontalstackedbar");
65 verify(horizontalstackedbar != null && horizontalstackedbar != undefined);
66 var horizontalpercentbar = chartView.createSeries(ChartView.SeriesTypeHorizontalPercentBar, "horizontalpercentbar");
67 verify(horizontalpercentbar != null && horizontalpercentbar != undefined);
68 var area = chartView.createSeries(ChartView.SeriesTypeArea, "area");
69 verify(area != null && area != undefined);
70
71 // Remove all series
72 chartView.removeAllSeries();
73 compare(chartView.count, 0);
74 }
75
76 function test_chartViewRange() {
77 // Set initial values
78 chartView.createSeries(ChartView.SeriesTypeLine, "line");
79 verify(chartView.axisX() != null);
80 verify(chartView.axisY() != null);
81 chartView.axisX().min = 1.0;
82 chartView.axisX().max = 2.0;
83 chartView.axisY().min = 1.0;
84 chartView.axisY().max = 2.0;
85
86 var xMax = chartView.axisX().max;
87 var xMin = chartView.axisX().min;
88 var yMax = chartView.axisY().max;
89 var yMin = chartView.axisY().min;
90
91 // zoom x 2.5
92 chartView.zoom(1.5);
93 verify(chartView.axisX().max < xMax);
94 verify(chartView.axisX().min > xMin);
95 verify(chartView.axisY().max < yMax);
96 verify(chartView.axisY().min > yMin);
97 xMax = chartView.axisX().max;
98 xMin = chartView.axisX().min;
99 yMax = chartView.axisY().max;
100 yMin = chartView.axisY().min;
101
102 // zoom x 0.5
103 chartView.zoom(0.5);
104 verify(chartView.axisX().max > xMax);
105 verify(chartView.axisX().min < xMin);
106 verify(chartView.axisY().max > yMax);
107 verify(chartView.axisY().min < yMin);
108 xMax = chartView.axisX().max;
109 xMin = chartView.axisX().min;
110 yMax = chartView.axisY().max;
111 yMin = chartView.axisY().min;
112
113 // Scroll up
114 chartView.scrollUp(10);
115 compare(chartView.axisX().max, xMax);
116 compare(chartView.axisX().min, xMin);
117 verify(chartView.axisY().max > yMax);
118 verify(chartView.axisY().min > yMin);
119 xMax = chartView.axisX().max;
120 xMin = chartView.axisX().min;
121 yMax = chartView.axisY().max;
122 yMin = chartView.axisY().min;
123
124 // Scroll down
125 chartView.scrollDown(10);
126 compare(chartView.axisX().max, xMax);
127 compare(chartView.axisX().min, xMin);
128 verify(chartView.axisY().max < yMax);
129 verify(chartView.axisY().min < yMin);
130 xMax = chartView.axisX().max;
131 xMin = chartView.axisX().min;
132 yMax = chartView.axisY().max;
133 yMin = chartView.axisY().min;
134
135 // Scroll left
136 chartView.scrollLeft(10);
137 verify(chartView.axisX().max < xMax);
138 verify(chartView.axisX().min < xMin);
139 compare(chartView.axisY().max, yMax);
140 compare(chartView.axisY().min, yMin);
141 xMax = chartView.axisX().max;
142 xMin = chartView.axisX().min;
143 yMax = chartView.axisY().max;
144 yMin = chartView.axisY().min;
145
146 // Scroll right
147 chartView.scrollRight(10);
148 verify(chartView.axisX().max > xMax);
149 verify(chartView.axisX().min > xMin);
150 compare(chartView.axisY().max, yMax);
151 compare(chartView.axisY().min, yMin);
152 }
153 }
154
155 ChartView {
156 id: chartView
157 anchors.fill: parent
158 title: "Chart"
159 }
160 }
@@ -0,0 +1,73
1 /****************************************************************************
2 **
3 ** Copyright (C) 2013 Digia Plc
4 ** All rights reserved.
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 **
7 ** This file is part of the Qt Enterprise Charts Add-on.
8 **
9 ** $QT_BEGIN_LICENSE$
10 ** Licensees holding valid Qt Enterprise licenses may use this file in
11 ** accordance with the Qt Enterprise License Agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia.
14 **
15 ** If you have questions regarding the use of this file, please use
16 ** contact form at http://qt.digia.com
17 ** $QT_END_LICENSE$
18 **
19 ****************************************************************************/
20
21 import QtQuick 2.0
22 import QtTest 1.0
23 import QtCommercial.Chart 1.2
24
25 Rectangle {
26 width: 400
27 height: 300
28
29 TestCase {
30 id: tc1
31 name: "tst_qml-qtquicktest ChartView Signals 1.2"
32 when: windowShown
33
34 // Verify onSeriesAdded and onSeriesRemoved signals
35 function test_chartView() {
36 var series = chartView.createSeries(ChartView.SeriesTypeLine, "line");
37 seriesAddedSpy.wait();
38 compare(seriesAddedSpy.count, 1, "ChartView.onSeriesAdded");
39
40 // Modifying layout triggers more than one plotAreaChanged signal
41 chartView.titleFont.pixelSize = 50;
42 verify(plotAreaChangedSpy.count > 0, "ChartView.onPlotAreaChanged");
43
44 chartView.removeSeries(series);
45 seriesRemovedSpy.wait();
46 compare(seriesRemovedSpy.count, 1, "ChartView.onSeriesAdded");
47 }
48 }
49
50 ChartView {
51 id: chartView
52 anchors.fill: parent
53 title: "Chart"
54
55 SignalSpy {
56 id: plotAreaChangedSpy
57 target: chartView
58 signalName: "plotAreaChanged"
59 }
60
61 SignalSpy {
62 id: seriesAddedSpy
63 target: chartView
64 signalName: "seriesAdded"
65 }
66
67 SignalSpy {
68 id: seriesRemovedSpy
69 target: chartView
70 signalName: "seriesRemoved"
71 }
72 }
73 }
@@ -0,0 +1,131
1 /****************************************************************************
2 **
3 ** Copyright (C) 2013 Digia Plc
4 ** All rights reserved.
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 **
7 ** This file is part of the Qt Enterprise Charts Add-on.
8 **
9 ** $QT_BEGIN_LICENSE$
10 ** Licensees holding valid Qt Enterprise licenses may use this file in
11 ** accordance with the Qt Enterprise License Agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia.
14 **
15 ** If you have questions regarding the use of this file, please use
16 ** contact form at http://qt.digia.com
17 ** $QT_END_LICENSE$
18 **
19 ****************************************************************************/
20
21 import QtQuick 2.0
22 import QtTest 1.0
23 import QtCommercial.Chart 1.2
24
25 Rectangle {
26 width: 400
27 height: 300
28
29 TestCase {
30 id: tc1
31 name: "tst_qml-qtquicktest PieSeries 1.2"
32 when: windowShown
33
34 function test_properties() {
35 compare(pieSeries.endAngle, 360);
36 compare(pieSeries.holeSize, 0);
37 compare(pieSeries.horizontalPosition, 0.5);
38 compare(pieSeries.size, 0.7);
39 compare(pieSeries.startAngle, 0);
40 compare(pieSeries.sum, 0);
41 compare(pieSeries.verticalPosition, 0.5);
42 }
43
44 function test_sliceproperties() {
45 var slice = pieSeries.append("slice", 10);
46 compare(slice.angleSpan, 360.0);
47 verify(slice.borderColor != undefined);
48 compare(slice.borderWidth, 1);
49 verify(slice.color != undefined);
50 compare(slice.explodeDistanceFactor, 0.15);
51 compare(slice.exploded, false);
52 compare(slice.label, "slice");
53 compare(slice.labelArmLengthFactor, 0.15);
54 verify(slice.labelColor != undefined);
55 compare(slice.labelFont.bold, false);
56 compare(slice.labelPosition, PieSlice.LabelOutside);
57 compare(slice.labelVisible, false);
58 compare(slice.percentage, 1.0);
59 compare(slice.startAngle, 0.0);
60 compare(slice.value, 10.0);
61 }
62
63 function test_append() {
64 addedSpy.clear();
65 countChangedSpy.clear();
66 sumChangedSpy.clear();
67 var count = 50;
68 for (var i = 0; i < count; i++)
69 pieSeries.append("slice" + i, Math.random());
70 compare(addedSpy.count, count);
71 compare(countChangedSpy.count, count);
72 compare(sumChangedSpy.count, count);
73 pieSeries.clear();
74 }
75
76 function test_remove() {
77 removedSpy.clear();
78 countChangedSpy.clear();
79 sumChangedSpy.clear();
80 var count = 50;
81 for (var i = 0; i < count; i++)
82 pieSeries.append("slice" + i, Math.random());
83 for (var j = 0; j < count; j++)
84 pieSeries.remove(pieSeries.at(0));
85 compare(removedSpy.count, count);
86 compare(countChangedSpy.count, 2 * count);
87 compare(sumChangedSpy.count, 2 * count);
88 compare(pieSeries.count, 0);
89 }
90
91 function test_find() {
92 var count = 50;
93 for (var i = 0; i < count; i++)
94 pieSeries.append("slice" + i, Math.random());
95 for (var j = 0; j < count; j++)
96 compare(pieSeries.find("slice" + j).label, "slice" + j);
97 pieSeries.clear();
98 }
99 }
100
101 ChartView {
102 id: chartView
103 anchors.fill: parent
104
105 PieSeries {
106 id: pieSeries
107 name: "pie"
108
109 SignalSpy {
110 id: addedSpy
111 target: pieSeries
112 signalName: "added"
113 }
114 SignalSpy {
115 id: removedSpy
116 target: pieSeries
117 signalName: "removed"
118 }
119 SignalSpy {
120 id: sumChangedSpy
121 target: pieSeries
122 signalName: "sumChanged"
123 }
124 SignalSpy {
125 id: countChangedSpy
126 target: pieSeries
127 signalName: "countChanged"
128 }
129 }
130 }
131 }
@@ -0,0 +1,116
1 /****************************************************************************
2 **
3 ** Copyright (C) 2013 Digia Plc
4 ** All rights reserved.
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 **
7 ** This file is part of the Qt Enterprise Charts Add-on.
8 **
9 ** $QT_BEGIN_LICENSE$
10 ** Licensees holding valid Qt Enterprise licenses may use this file in
11 ** accordance with the Qt Enterprise License Agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia.
14 **
15 ** If you have questions regarding the use of this file, please use
16 ** contact form at http://qt.digia.com
17 ** $QT_END_LICENSE$
18 **
19 ****************************************************************************/
20
21 import QtQuick 2.0
22 import QtTest 1.0
23 import QtCommercial.Chart 1.2
24
25 Rectangle {
26 width: 400
27 height: 300
28
29 TestCase {
30 id: tc1
31 name: "tst_qml-qtquicktest ValueAxis 1.2"
32 when: windowShown
33
34 // test functions are run in alphabetical order, the name has 'a' so that it
35 // will be the first function to execute.
36 function test_a_properties() {
37 // Default properties
38 verify(axisX.min < 0, "AxisX min");
39 verify(axisX.max > 0, "AxisX max");
40 verify(axisY.min < 0, "AxisY min");
41 verify(axisY.max > 0, "AxisY max");
42 verify(axisX.tickCount == 5, "AxisX tick count");
43 verify(axisY.tickCount == 5, "AxisY tick count");
44 verify(axisX.labelFormat == "", "label format");
45
46 // Modify properties
47 axisX.tickCount = 3;
48 verify(axisX.tickCount == 3, "set tick count");
49 }
50
51 function test_functions() {
52 // Set the axis ranges to not "nice" ones...
53 var min = 0.032456456;
54 var max = 10.67845634;
55 axisX.min = min;
56 axisX.max = max;
57 axisY.min = min;
58 axisY.max = max;
59
60 // ...And then apply nice numbers and verify the range was changed
61 axisX.applyNiceNumbers();
62 axisY.applyNiceNumbers();
63 verify(axisX.min != min);
64 verify(axisX.max != max);
65 verify(axisY.min != min);
66 verify(axisY.max != max);
67 }
68
69 function test_signals() {
70 minChangedSpy.clear();
71 maxChangedSpy.clear();
72 axisX.min = 2;
73 compare(minChangedSpy.count, 1, "onMinChanged");
74 compare(maxChangedSpy.count, 0, "onMaxChanged");
75
76 axisX.max = 8;
77 compare(minChangedSpy.count, 1, "onMinChanged");
78 compare(maxChangedSpy.count, 1, "onMaxChanged");
79
80 // restore original values
81 axisX.min = 0;
82 axisX.max = 10;
83 compare(minChangedSpy.count, 2, "onMinChanged");
84 compare(maxChangedSpy.count, 2, "onMaxChanged");
85 }
86 }
87
88 ChartView {
89 id: chartView
90 anchors.fill: parent
91
92 LineSeries {
93 id: lineSeries1
94 axisX: ValueAxis {
95 id: axisX
96 }
97 axisY: ValueAxis {
98 id: axisY
99 }
100 XYPoint { x: -1; y: -1 }
101 XYPoint { x: 0; y: 0 }
102 XYPoint { x: 5; y: 5 }
103 }
104
105 SignalSpy {
106 id: minChangedSpy
107 target: axisX
108 signalName: "minChanged"
109 }
110 SignalSpy {
111 id: maxChangedSpy
112 target: axisX
113 signalName: "maxChanged"
114 }
115 }
116 }
@@ -0,0 +1,260
1 /****************************************************************************
2 **
3 ** Copyright (C) 2013 Digia Plc
4 ** All rights reserved.
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 **
7 ** This file is part of the Qt Enterprise Charts Add-on.
8 **
9 ** $QT_BEGIN_LICENSE$
10 ** Licensees holding valid Qt Enterprise licenses may use this file in
11 ** accordance with the Qt Enterprise License Agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia.
14 **
15 ** If you have questions regarding the use of this file, please use
16 ** contact form at http://qt.digia.com
17 ** $QT_END_LICENSE$
18 **
19 ****************************************************************************/
20
21 import QtQuick 2.0
22 import QtTest 1.0
23 import QtCommercial.Chart 1.2
24
25 Rectangle {
26 width: 400
27 height: 300
28
29 TestCase {
30 id: tc1
31 name: "tst_qml-qtquicktest XY Series 1.2"
32 when: windowShown
33
34 function test_properties() {
35 verify(lineSeries.color != undefined);
36 compare(lineSeries.pointsVisible, false);
37 compare(lineSeries.capStyle, Qt.SquareCap);
38 compare(lineSeries.style, Qt.SolidLine);
39 compare(lineSeries.width, 2.0);
40
41 verify(splineSeries.color != undefined);
42 compare(splineSeries.pointsVisible, false);
43 compare(splineSeries.capStyle, Qt.SquareCap);
44 compare(splineSeries.style, Qt.SolidLine);
45 compare(splineSeries.width, 2.0);
46
47 verify(scatterSeries.color != undefined);
48 verify(scatterSeries.borderColor != undefined);
49 compare(scatterSeries.borderWidth, 2.0);
50 compare(scatterSeries.markerShape, ScatterSeries.MarkerShapeCircle);
51 compare(scatterSeries.markerSize, 15.0);
52
53 verify(areaSeries.color != undefined);
54 verify(areaSeries.borderColor != undefined);
55 compare(areaSeries.borderWidth, 2.0);
56 }
57
58 function test_axes() {
59 // Axis initialization
60 compare(chartView.axisX(), lineSeries.axisX);
61 compare(chartView.axisY(), lineSeries.axisY);
62 compare(lineSeries.axisX, splineSeries.axisX);
63 compare(lineSeries.axisY, splineSeries.axisY);
64 compare(lineSeries.axisX, areaSeries.axisX);
65 compare(lineSeries.axisY, areaSeries.axisY);
66 }
67
68 function test_append() {
69 lineSeriesPointAddedSpy.clear();
70 splineSeriesPointAddedSpy.clear();
71 scatterSeriesPointAddedSpy.clear();
72 var count = append();
73 compare(lineSeries.count, count);
74 compare(splineSeries.count, count);
75 compare(scatterSeries.count, count);
76 compare(lineSeriesPointAddedSpy.count, count);
77 compare(splineSeriesPointAddedSpy.count, count);
78 compare(scatterSeriesPointAddedSpy.count, count);
79 clear();
80 compare(lineSeries.count, 0);
81 compare(splineSeries.count, 0);
82 compare(scatterSeries.count, 0);
83 }
84
85 function test_replace() {
86 var count = append();
87 for (var i = 0; i < count; i++) {
88 lineSeries.replace(lineSeries.at(i).x, lineSeries.at(i).y, i, Math.random());
89 splineSeries.replace(splineSeries.at(i).x, splineSeries.at(i).y, i, Math.random());
90 scatterSeries.replace(scatterSeries.at(i).x, scatterSeries.at(i).y, i, Math.random());
91 }
92 compare(lineSeries.count, count);
93 compare(splineSeries.count, count);
94 compare(scatterSeries.count, count);
95 compare(lineSeriesPointReplacedSpy.count, count);
96 compare(splineSeriesPointReplacedSpy.count, count);
97 compare(scatterSeriesPointReplacedSpy.count, count);
98 clear();
99 }
100
101 function test_insert() {
102 var count = append();
103 lineSeriesPointAddedSpy.clear();
104 splineSeriesPointAddedSpy.clear();
105 scatterSeriesPointAddedSpy.clear();
106 for (var i = 0; i < count; i++) {
107 lineSeries.insert(i * 2, i, Math.random());
108 splineSeries.insert(i * 2, i, Math.random());
109 scatterSeries.insert(i * 2, i, Math.random());
110 }
111 compare(lineSeries.count, count * 2);
112 compare(splineSeries.count, count * 2);
113 compare(scatterSeries.count, count * 2);
114 compare(lineSeriesPointAddedSpy.count, count);
115 compare(splineSeriesPointAddedSpy.count, count);
116 compare(scatterSeriesPointAddedSpy.count, count);
117 clear();
118 }
119
120 function test_remove() {
121 lineSeriesPointRemovedSpy.clear();
122 splineSeriesPointRemovedSpy.clear();
123 scatterSeriesPointRemovedSpy.clear();
124 var count = append();
125 for (var i = 0; i < count; i++) {
126 lineSeries.remove(lineSeries.at(0).x, lineSeries.at(0).y);
127 splineSeries.remove(splineSeries.at(0).x, splineSeries.at(0).y);
128 scatterSeries.remove(scatterSeries.at(0).x, scatterSeries.at(0).y);
129 }
130 compare(lineSeries.count, 0);
131 compare(splineSeries.count, 0);
132 compare(scatterSeries.count, 0);
133 compare(lineSeriesPointRemovedSpy.count, count);
134 compare(splineSeriesPointRemovedSpy.count, count);
135 compare(scatterSeriesPointRemovedSpy.count, count);
136 }
137
138 // Not a test function, called from test functions
139 function append() {
140 var count = 100;
141 chartView.axisX().min = 0;
142 chartView.axisX().max = 100;
143 chartView.axisY().min = 0;
144 chartView.axisY().max = 1;
145
146 for (var i = 0; i < count; i++) {
147 lineSeries.append(i, Math.random());
148 splineSeries.append(i, Math.random());
149 scatterSeries.append(i, Math.random());
150 }
151
152 return count;
153 }
154
155 // Not a test function, called from test functions
156 function clear() {
157 lineSeries.clear();
158 splineSeries.clear();
159 scatterSeries.clear();
160 }
161 }
162
163 ChartView {
164 id: chartView
165 anchors.fill: parent
166
167 LineSeries {
168 id: lineSeries
169 name: "line"
170
171 SignalSpy {
172 id: lineSeriesPointAddedSpy
173 target: lineSeries
174 signalName: "pointAdded"
175 }
176
177 SignalSpy {
178 id: lineSeriesPointReplacedSpy
179 target: lineSeries
180 signalName: "pointReplaced"
181 }
182
183 SignalSpy {
184 id: lineSeriesPointsReplacedSpy
185 target: lineSeries
186 signalName: "pointsReplaced"
187 }
188
189 SignalSpy {
190 id: lineSeriesPointRemovedSpy
191 target: lineSeries
192 signalName: "pointRemoved"
193 }
194 }
195
196 AreaSeries {
197 id: areaSeries
198 name: "area"
199 upperSeries: lineSeries
200 }
201
202 SplineSeries {
203 id: splineSeries
204 name: "spline"
205
206 SignalSpy {
207 id: splineSeriesPointAddedSpy
208 target: splineSeries
209 signalName: "pointAdded"
210 }
211
212 SignalSpy {
213 id: splineSeriesPointReplacedSpy
214 target: splineSeries
215 signalName: "pointReplaced"
216 }
217
218 SignalSpy {
219 id: splineSeriesPointsReplacedSpy
220 target: splineSeries
221 signalName: "pointsReplaced"
222 }
223
224 SignalSpy {
225 id: splineSeriesPointRemovedSpy
226 target: splineSeries
227 signalName: "pointRemoved"
228 }
229 }
230
231 ScatterSeries {
232 id: scatterSeries
233 name: "scatter"
234
235 SignalSpy {
236 id: scatterSeriesPointAddedSpy
237 target: scatterSeries
238 signalName: "pointAdded"
239 }
240
241 SignalSpy {
242 id: scatterSeriesPointReplacedSpy
243 target: scatterSeries
244 signalName: "pointReplaced"
245 }
246
247 SignalSpy {
248 id: scatterSeriesPointsReplacedSpy
249 target: scatterSeries
250 signalName: "pointsReplaced"
251 }
252
253 SignalSpy {
254 id: scatterSeriesPointRemovedSpy
255 target: scatterSeries
256 signalName: "pointRemoved"
257 }
258 }
259 }
260 }
@@ -19,4 +19,10
19 ****************************************************************************/
19 ****************************************************************************/
20
20
21 #include <QtQuickTest/quicktest.h>
21 #include <QtQuickTest/quicktest.h>
22 QUICK_TEST_MAIN(example)
22 #include <QtWidgets/QApplication>
23
24 int main(int argc, char *argv[])
25 {
26 QApplication app(argc, argv);
27 return quick_test_main(argc, argv, "example", QUICK_TEST_SOURCE_DIR);
28 }
@@ -2,7 +2,12
2 error( "Couldn't find the auto.pri file!" )
2 error( "Couldn't find the auto.pri file!" )
3 }
3 }
4
4
5 TEMPLATE = app
5 greaterThan(QT_MAJOR_VERSION, 4) {
6 CONFIG += warn_on qmltestcase
6 TEMPLATE = app
7 SOURCES += main.cpp
7 CONFIG += warn_on qmltestcase
8 DEFINES += QUICK_TEST_SOURCE_DIR=\"\\\"$$PWD\\\"\"
8 SOURCES += main.cpp
9 OTHER_FILES += tst_*.qml
10 DEFINES += QUICK_TEST_SOURCE_DIR=\"\\\"$$PWD\\\"\"
11 } else {
12 error("These auto tests are designed for Qt5 / QtQuick 2.0")
13 }
@@ -18,9 +18,9
18 **
18 **
19 ****************************************************************************/
19 ****************************************************************************/
20
20
21 import QtQuick 1.0
21 import QtQuick 2.0
22 import QtQuickTest 1.0
22 import QtTest 1.0
23 import QtCommercial.Chart 1.2
23 import QtCommercial.Chart 1.3
24
24
25 Rectangle {
25 Rectangle {
26 width: 400
26 width: 400
@@ -40,20 +40,30 Rectangle {
40
40
41 function test_categories() {
41 function test_categories() {
42 compare(barSeries1.axisX.count, 6, "AxisX count");
42 compare(barSeries1.axisX.count, 6, "AxisX count");
43 categoriesCountChangedSpy.clear();
44 categoriesChangedSpy.clear();
43
45
44 // Replace categories
46 // Replace categories
45 var cat = barSeries1.axisX.categories;
46 barSeries1.axisX.categories = ["Tam", "Hel", "Maa", "Huh"];
47 barSeries1.axisX.categories = ["Tam", "Hel", "Maa", "Huh"];
47 compare(barSeries1.axisX.count, 4, "AxisX count");
48 compare(barSeries1.axisX.count, 4, "AxisX count");
48 compare(categoriesCountChangedSpy.count, 1, "onCountChanged");
49 compare(categoriesCountChangedSpy.count, 1, "onCountChanged");
49 compare(categoriesChangedSpy.count, 1, "onCategoriesChanged");
50 compare(categoriesChangedSpy.count, 1, "onCategoriesChanged");
50
51
51 // Reset the original categories
52 // Reset the original categories
52 barSeries1.axisX.categories = cat;
53 barSeries1.axisX.categories = ["Jan", "Feb", "Mar", "Apr", "May", "Jun"]
53 compare(barSeries1.axisX.count, 6, "AxisX count");
54 compare(barSeries1.axisX.count, 6, "AxisX count");
54 compare(categoriesCountChangedSpy.count, 2, "onCountChanged");
55 compare(categoriesCountChangedSpy.count, 2, "onCountChanged");
55 compare(categoriesChangedSpy.count, 2, "onCategoriesChanged");
56 compare(categoriesChangedSpy.count, 2, "onCategoriesChanged");
56 }
57 }
58
59 function test_minMaxChanged() {
60 axisY.min = -1;
61 compare(minChangedSpy.count, 1, "onMinChanged");
62 compare(maxChangedSpy.count, 0, "onMaxChanged");
63 axisY.max = 12;
64 compare(minChangedSpy.count, 1, "onMinChanged");
65 compare(maxChangedSpy.count, 1, "onMaxChanged");
66 }
57 }
67 }
58
68
59 ChartView {
69 ChartView {
@@ -83,5 +93,15 Rectangle {
83 target: axisX
93 target: axisX
84 signalName: "categoriesChanged"
94 signalName: "categoriesChanged"
85 }
95 }
96 SignalSpy {
97 id: minChangedSpy
98 target: axisY
99 signalName: "minChanged"
100 }
101 SignalSpy {
102 id: maxChangedSpy
103 target: axisY
104 signalName: "maxChanged"
105 }
86 }
106 }
87 }
107 }
@@ -18,8 +18,8
18 **
18 **
19 ****************************************************************************/
19 ****************************************************************************/
20
20
21 import QtQuick 1.0
21 import QtQuick 2.0
22 import QtQuickTest 1.0
22 import QtTest 1.0
23 import QtCommercial.Chart 1.1
23 import QtCommercial.Chart 1.1
24
24
25 Rectangle {
25 Rectangle {
@@ -40,20 +40,30 Rectangle {
40
40
41 function test_categories() {
41 function test_categories() {
42 compare(barSeries1.axisX.count, 6, "AxisX count");
42 compare(barSeries1.axisX.count, 6, "AxisX count");
43 categoriesCountChangedSpy.clear();
44 categoriesChangedSpy.clear();
43
45
44 // Replace categories
46 // Replace categories
45 var cat = barSeries1.axisX.categories;
46 barSeries1.axisX.categories = ["Tam", "Hel", "Maa", "Huh"];
47 barSeries1.axisX.categories = ["Tam", "Hel", "Maa", "Huh"];
47 compare(barSeries1.axisX.count, 4, "AxisX count");
48 compare(barSeries1.axisX.count, 4, "AxisX count");
48 compare(categoriesCountChangedSpy.count, 1, "onCountChanged");
49 compare(categoriesCountChangedSpy.count, 1, "onCountChanged");
49 compare(categoriesChangedSpy.count, 1, "onCategoriesChanged");
50 compare(categoriesChangedSpy.count, 1, "onCategoriesChanged");
50
51
51 // Reset the original categories
52 // Reset the original categories
52 barSeries1.axisX.categories = cat;
53 barSeries1.axisX.categories = ["Jan", "Feb", "Mar", "Apr", "May", "Jun"]
53 compare(barSeries1.axisX.count, 6, "AxisX count");
54 compare(barSeries1.axisX.count, 6, "AxisX count");
54 compare(categoriesCountChangedSpy.count, 2, "onCountChanged");
55 compare(categoriesCountChangedSpy.count, 2, "onCountChanged");
55 compare(categoriesChangedSpy.count, 2, "onCategoriesChanged");
56 compare(categoriesChangedSpy.count, 2, "onCategoriesChanged");
56 }
57 }
58
59 function test_minMaxChanged() {
60 axisY.min = -1;
61 compare(minChangedSpy.count, 1, "onMinChanged");
62 compare(maxChangedSpy.count, 0, "onMaxChanged");
63 axisY.max = 12;
64 compare(minChangedSpy.count, 1, "onMinChanged");
65 compare(maxChangedSpy.count, 1, "onMaxChanged");
66 }
57 }
67 }
58
68
59 ChartView {
69 ChartView {
@@ -83,5 +93,15 Rectangle {
83 target: axisX
93 target: axisX
84 signalName: "categoriesChanged"
94 signalName: "categoriesChanged"
85 }
95 }
96 SignalSpy {
97 id: minChangedSpy
98 target: axisY
99 signalName: "minChanged"
100 }
101 SignalSpy {
102 id: maxChangedSpy
103 target: axisY
104 signalName: "maxChanged"
105 }
86 }
106 }
87 }
107 }
@@ -18,9 +18,9
18 **
18 **
19 ****************************************************************************/
19 ****************************************************************************/
20
20
21 import QtQuick 1.0
21 import QtQuick 2.0
22 import QtQuickTest 1.0
22 import QtTest 1.0
23 import QtCommercial.Chart 1.2
23 import QtCommercial.Chart 1.3
24
24
25 Rectangle {
25 Rectangle {
26 width: 400
26 width: 400
@@ -37,9 +37,8 Rectangle {
37 }
37 }
38
38
39 function test_axes() {
39 function test_axes() {
40 compare(chartView.axes.length, 2);
40 verify(chartView.axisX() == barSeries.axisX);
41 verify(chartView.axes[0] == barSeries.axisX || chartView.axes[1] == barSeries.axisX);
41 verify(chartView.axisY() == barSeries.axisY);
42 verify(chartView.axes[0] == barSeries.axisY || chartView.axes[1] == barSeries.axisY);
43
42
44 compare(barSeries.axisX, stackedBarSeries.axisX);
43 compare(barSeries.axisX, stackedBarSeries.axisX);
45 compare(barSeries.axisY, stackedBarSeries.axisY);
44 compare(barSeries.axisY, stackedBarSeries.axisY);
@@ -18,8 +18,8
18 **
18 **
19 ****************************************************************************/
19 ****************************************************************************/
20
20
21 import QtQuick 1.0
21 import QtQuick 2.0
22 import QtQuickTest 1.0
22 import QtTest 1.0
23 import QtCommercial.Chart 1.1
23 import QtCommercial.Chart 1.1
24
24
25 Rectangle {
25 Rectangle {
@@ -18,9 +18,9
18 **
18 **
19 ****************************************************************************/
19 ****************************************************************************/
20
20
21 import QtQuick 1.0
21 import QtQuick 2.0
22 import QtQuickTest 1.0
22 import QtTest 1.0
23 import QtCommercial.Chart 1.2
23 import QtCommercial.Chart 1.3
24
24
25 Rectangle {
25 Rectangle {
26 width: 400
26 width: 400
@@ -18,8 +18,8
18 **
18 **
19 ****************************************************************************/
19 ****************************************************************************/
20
20
21 import QtQuick 1.0
21 import QtQuick 2.0
22 import QtQuickTest 1.0
22 import QtTest 1.0
23 import QtCommercial.Chart 1.1
23 import QtCommercial.Chart 1.1
24
24
25 Rectangle {
25 Rectangle {
@@ -18,9 +18,9
18 **
18 **
19 ****************************************************************************/
19 ****************************************************************************/
20
20
21 import QtQuick 1.0
21 import QtQuick 2.0
22 import QtQuickTest 1.0
22 import QtTest 1.0
23 import QtCommercial.Chart 1.2
23 import QtCommercial.Chart 1.3
24
24
25 Rectangle {
25 Rectangle {
26 width: 400
26 width: 400
@@ -34,10 +34,6 Rectangle {
34 function test_chartViewProperties() {
34 function test_chartViewProperties() {
35 compare(chartView.animationOptions, ChartView.NoAnimation, "ChartView.animationOptions");
35 compare(chartView.animationOptions, ChartView.NoAnimation, "ChartView.animationOptions");
36 verify(chartView.backgroundColor != undefined);
36 verify(chartView.backgroundColor != undefined);
37 verify(chartView.bottomMargin > 0, "ChartView.bottomMargin");
38 verify(chartView.topMargin > 0, "ChartView.topMargin");
39 verify(chartView.leftMargin > 0, "ChartView.leftMargin");
40 verify(chartView.rightMargin > 0, "ChartView.rightMargin");
41 verify(chartView.margins.bottom > 0, "ChartView.margins.bottom");
37 verify(chartView.margins.bottom > 0, "ChartView.margins.bottom");
42 verify(chartView.margins.top > 0, "ChartView.margins.top");
38 verify(chartView.margins.top > 0, "ChartView.margins.top");
43 verify(chartView.margins.left > 0, "ChartView.margins.left");
39 verify(chartView.margins.left > 0, "ChartView.margins.left");
@@ -73,7 +69,6 Rectangle {
73 compare(chartView.legend.font.underline, false, "ChartView.legend.font.underline");
69 compare(chartView.legend.font.underline, false, "ChartView.legend.font.underline");
74 compare(chartView.legend.font.weight, Font.Normal, "ChartView.legend.font.weight");
70 compare(chartView.legend.font.weight, Font.Normal, "ChartView.legend.font.weight");
75 compare(chartView.legend.font.wordSpacing, 0.0, "ChartView.legend.font.wordSpacing");
71 compare(chartView.legend.font.wordSpacing, 0.0, "ChartView.legend.font.wordSpacing");
76 compare(chartView.axes.length, 0, "ChartView.axes.length");
77 }
72 }
78 }
73 }
79
74
@@ -18,8 +18,8
18 **
18 **
19 ****************************************************************************/
19 ****************************************************************************/
20
20
21 import QtQuick 1.0
21 import QtQuick 2.0
22 import QtQuickTest 1.0
22 import QtTest 1.0
23 import QtCommercial.Chart 1.1
23 import QtCommercial.Chart 1.1
24
24
25 Rectangle {
25 Rectangle {
@@ -18,9 +18,9
18 **
18 **
19 ****************************************************************************/
19 ****************************************************************************/
20
20
21 import QtQuick 1.0
21 import QtQuick 2.0
22 import QtQuickTest 1.0
22 import QtTest 1.0
23 import QtCommercial.Chart 1.2
23 import QtCommercial.Chart 1.3
24
24
25 Rectangle {
25 Rectangle {
26 width: 400
26 width: 400
@@ -18,8 +18,8
18 **
18 **
19 ****************************************************************************/
19 ****************************************************************************/
20
20
21 import QtQuick 1.0
21 import QtQuick 2.0
22 import QtQuickTest 1.0
22 import QtTest 1.0
23 import QtCommercial.Chart 1.1
23 import QtCommercial.Chart 1.1
24
24
25 Rectangle {
25 Rectangle {
@@ -132,6 +132,7 Rectangle {
132 yMax = chartView.axisY().max;
132 yMax = chartView.axisY().max;
133 yMin = chartView.axisY().min;
133 yMin = chartView.axisY().min;
134
134
135 // Scroll left
135 chartView.scrollLeft(10);
136 chartView.scrollLeft(10);
136 verify(chartView.axisX().max < xMax);
137 verify(chartView.axisX().max < xMax);
137 verify(chartView.axisX().min < xMin);
138 verify(chartView.axisX().min < xMin);
@@ -142,6 +143,7 Rectangle {
142 yMax = chartView.axisY().max;
143 yMax = chartView.axisY().max;
143 yMin = chartView.axisY().min;
144 yMin = chartView.axisY().min;
144
145
146 // Scroll right
145 chartView.scrollRight(10);
147 chartView.scrollRight(10);
146 verify(chartView.axisX().max > xMax);
148 verify(chartView.axisX().max > xMax);
147 verify(chartView.axisX().min > xMin);
149 verify(chartView.axisX().min > xMin);
@@ -18,9 +18,9
18 **
18 **
19 ****************************************************************************/
19 ****************************************************************************/
20
20
21 import QtQuick 1.0
21 import QtQuick 2.0
22 import QtQuickTest 1.0
22 import QtTest 1.0
23 import QtCommercial.Chart 1.2
23 import QtCommercial.Chart 1.3
24
24
25 Rectangle {
25 Rectangle {
26 width: 400
26 width: 400
@@ -18,8 +18,8
18 **
18 **
19 ****************************************************************************/
19 ****************************************************************************/
20
20
21 import QtQuick 1.0
21 import QtQuick 2.0
22 import QtQuickTest 1.0
22 import QtTest 1.0
23 import QtCommercial.Chart 1.1
23 import QtCommercial.Chart 1.1
24
24
25 Rectangle {
25 Rectangle {
@@ -18,9 +18,9
18 **
18 **
19 ****************************************************************************/
19 ****************************************************************************/
20
20
21 import QtQuick 1.0
21 import QtQuick 2.0
22 import QtQuickTest 1.0
22 import QtTest 1.0
23 import QtCommercial.Chart 1.2
23 import QtCommercial.Chart 1.3
24
24
25 Rectangle {
25 Rectangle {
26 width: 400
26 width: 400
@@ -45,7 +45,7 Rectangle {
45 var slice = pieSeries.append("slice", 10);
45 var slice = pieSeries.append("slice", 10);
46 compare(slice.angleSpan, 360.0);
46 compare(slice.angleSpan, 360.0);
47 verify(slice.borderColor != undefined);
47 verify(slice.borderColor != undefined);
48 compare(slice.borderWidth, 0);
48 compare(slice.borderWidth, 1);
49 verify(slice.color != undefined);
49 verify(slice.color != undefined);
50 compare(slice.explodeDistanceFactor, 0.15);
50 compare(slice.explodeDistanceFactor, 0.15);
51 compare(slice.exploded, false);
51 compare(slice.exploded, false);
@@ -18,8 +18,8
18 **
18 **
19 ****************************************************************************/
19 ****************************************************************************/
20
20
21 import QtQuick 1.0
21 import QtQuick 2.0
22 import QtQuickTest 1.0
22 import QtTest 1.0
23 import QtCommercial.Chart 1.1
23 import QtCommercial.Chart 1.1
24
24
25 Rectangle {
25 Rectangle {
@@ -45,7 +45,7 Rectangle {
45 var slice = pieSeries.append("slice", 10);
45 var slice = pieSeries.append("slice", 10);
46 compare(slice.angleSpan, 360.0);
46 compare(slice.angleSpan, 360.0);
47 verify(slice.borderColor != undefined);
47 verify(slice.borderColor != undefined);
48 compare(slice.borderWidth, 0);
48 compare(slice.borderWidth, 1);
49 verify(slice.color != undefined);
49 verify(slice.color != undefined);
50 compare(slice.explodeDistanceFactor, 0.15);
50 compare(slice.explodeDistanceFactor, 0.15);
51 compare(slice.exploded, false);
51 compare(slice.exploded, false);
@@ -18,9 +18,9
18 **
18 **
19 ****************************************************************************/
19 ****************************************************************************/
20
20
21 import QtQuick 1.0
21 import QtQuick 2.0
22 import QtQuickTest 1.0
22 import QtTest 1.0
23 import QtCommercial.Chart 1.2
23 import QtCommercial.Chart 1.3
24
24
25 Rectangle {
25 Rectangle {
26 width: 400
26 width: 400
@@ -31,31 +31,30 Rectangle {
31 name: "tst_qml-qtquicktest ValueAxis"
31 name: "tst_qml-qtquicktest ValueAxis"
32 when: windowShown
32 when: windowShown
33
33
34 function test_properties() {
34 // test functions are run in alphabetical order, the name has 'a' so that it
35 // will be the first function to execute.
36 function test_a_properties() {
35 // Default properties
37 // Default properties
36 verify(axisX.min < 0, "AxisX min");
38 verify(axisX.min < 0, "AxisX min");
37 verify(axisX.max > 0, "AxisX max");
39 verify(axisX.max > 0, "AxisX max");
38 verify(axisY.min < 0, "AxisY min");
40 verify(axisY.min < 0, "AxisY min");
39 verify(axisY.max > 0, "AxisY max");
41 verify(axisY.max > 0, "AxisY max");
40 verify(axisX.tickCount > 0, "AxisX tick count");
42 verify(axisX.tickCount == 5, "AxisX tick count");
41 verify(axisY.tickCount > 0, "AxisX tick count");
43 verify(axisY.tickCount == 5, "AxisY tick count");
42 compare(axisX.niceNumbersEnabled, false, "nice numbers");
44 verify(axisX.labelFormat == "", "label format");
43 compare(axisX.labelFormat, "", "label format");
44
45
45 // Modify properties
46 // Modify properties
46 axisX.tickCount = 3;
47 axisX.tickCount = 3;
47 compare(axisX.tickCount, 3, "set tick count");
48 verify(axisX.tickCount == 3, "set tick count");
48 axisX.niceNumbersEnabled = true;
49 compare(axisX.niceNumbersEnabled, true, "nice numbers");
50 }
49 }
51
50
52 function test_functions() {
51 function test_functions() {
53 // Set the axis ranges to not "nice" ones...
52 // Set the axis ranges to not "nice" ones...
54 var min = 0.032456456;
53 var min = 0.032456456;
55 var max = 10.67845634;
54 var max = 10.67845634;
56 axisX.max = min;
55 axisX.min = min;
57 axisX.max = max;
56 axisX.max = max;
58 axisY.max = min;
57 axisY.min = min;
59 axisY.max = max;
58 axisY.max = max;
60
59
61 // ...And then apply nice numbers and verify the range was changed
60 // ...And then apply nice numbers and verify the range was changed
@@ -18,8 +18,8
18 **
18 **
19 ****************************************************************************/
19 ****************************************************************************/
20
20
21 import QtQuick 1.0
21 import QtQuick 2.0
22 import QtQuickTest 1.0
22 import QtTest 1.0
23 import QtCommercial.Chart 1.1
23 import QtCommercial.Chart 1.1
24
24
25 Rectangle {
25 Rectangle {
@@ -18,9 +18,9
18 **
18 **
19 ****************************************************************************/
19 ****************************************************************************/
20
20
21 import QtQuick 1.0
21 import QtQuick 2.0
22 import QtQuickTest 1.0
22 import QtTest 1.0
23 import QtCommercial.Chart 1.2
23 import QtCommercial.Chart 1.3
24
24
25 Rectangle {
25 Rectangle {
26 width: 400
26 width: 400
@@ -57,23 +57,12 Rectangle {
57
57
58 function test_axes() {
58 function test_axes() {
59 // Axis initialization
59 // Axis initialization
60 compare(chartView.axes.length, 2);
60 compare(chartView.axisX(), lineSeries.axisX);
61 verify(chartView.axes[0] == lineSeries.axisX || chartView.axes[1] == lineSeries.axisX);
61 compare(chartView.axisY(), lineSeries.axisY);
62 verify(chartView.axes[0] == lineSeries.axisY || chartView.axes[1] == lineSeries.axisY);
63 compare(lineSeries.axisX, splineSeries.axisX);
62 compare(lineSeries.axisX, splineSeries.axisX);
64 compare(lineSeries.axisY, splineSeries.axisY);
63 compare(lineSeries.axisY, splineSeries.axisY);
65 compare(lineSeries.axisX, areaSeries.axisX);
64 compare(lineSeries.axisX, areaSeries.axisX);
66 compare(lineSeries.axisY, areaSeries.axisY);
65 compare(lineSeries.axisY, areaSeries.axisY);
67
68 // Set illegal axes
69 lineSeries.axisX = lineSeries.axisY;
70 compare(lineSeries.axisX, splineSeries.axisX);
71 lineSeries.axisXTop = lineSeries.axisX;
72 compare(lineSeries.axisX, splineSeries.axisX);
73 lineSeries.axisY = lineSeries.axisX;
74 compare(lineSeries.axisY, splineSeries.axisY);
75 lineSeries.axisYRight = lineSeries.axisY;
76 compare(lineSeries.axisY, splineSeries.axisY);
77 }
66 }
78
67
79 function test_append() {
68 function test_append() {
@@ -84,9 +73,9 Rectangle {
84 compare(lineSeries.count, count);
73 compare(lineSeries.count, count);
85 compare(splineSeries.count, count);
74 compare(splineSeries.count, count);
86 compare(scatterSeries.count, count);
75 compare(scatterSeries.count, count);
87 tryCompare(lineSeriesPointAddedSpy.count, count);
76 compare(lineSeriesPointAddedSpy.count, count);
88 tryCompare(splineSeriesPointAddedSpy.count, count);
77 compare(splineSeriesPointAddedSpy.count, count);
89 tryCompare(scatterSeriesPointAddedSpy.count, count);
78 compare(scatterSeriesPointAddedSpy.count, count);
90 clear();
79 clear();
91 compare(lineSeries.count, 0);
80 compare(lineSeries.count, 0);
92 compare(splineSeries.count, 0);
81 compare(splineSeries.count, 0);
@@ -103,9 +92,9 Rectangle {
103 compare(lineSeries.count, count);
92 compare(lineSeries.count, count);
104 compare(splineSeries.count, count);
93 compare(splineSeries.count, count);
105 compare(scatterSeries.count, count);
94 compare(scatterSeries.count, count);
106 tryCompare(lineSeriesPointReplacedSpy.count, count);
95 compare(lineSeriesPointReplacedSpy.count, count);
107 tryCompare(splineSeriesPointReplacedSpy.count, count);
96 compare(splineSeriesPointReplacedSpy.count, count);
108 tryCompare(scatterSeriesPointReplacedSpy.count, count);
97 compare(scatterSeriesPointReplacedSpy.count, count);
109 clear();
98 clear();
110 }
99 }
111
100
@@ -122,9 +111,9 Rectangle {
122 compare(lineSeries.count, count * 2);
111 compare(lineSeries.count, count * 2);
123 compare(splineSeries.count, count * 2);
112 compare(splineSeries.count, count * 2);
124 compare(scatterSeries.count, count * 2);
113 compare(scatterSeries.count, count * 2);
125 tryCompare(lineSeriesPointAddedSpy.count, count);
114 compare(lineSeriesPointAddedSpy.count, count);
126 tryCompare(splineSeriesPointAddedSpy.count, count);
115 compare(splineSeriesPointAddedSpy.count, count);
127 tryCompare(scatterSeriesPointAddedSpy.count, count);
116 compare(scatterSeriesPointAddedSpy.count, count);
128 clear();
117 clear();
129 }
118 }
130
119
@@ -141,9 +130,9 Rectangle {
141 compare(lineSeries.count, 0);
130 compare(lineSeries.count, 0);
142 compare(splineSeries.count, 0);
131 compare(splineSeries.count, 0);
143 compare(scatterSeries.count, 0);
132 compare(scatterSeries.count, 0);
144 tryCompare(lineSeriesPointRemovedSpy.count, count);
133 compare(lineSeriesPointRemovedSpy.count, count);
145 tryCompare(splineSeriesPointRemovedSpy.count, count);
134 compare(splineSeriesPointRemovedSpy.count, count);
146 tryCompare(scatterSeriesPointRemovedSpy.count, count);
135 compare(scatterSeriesPointRemovedSpy.count, count);
147 }
136 }
148
137
149 // Not a test function, called from test functions
138 // Not a test function, called from test functions
@@ -18,8 +18,8
18 **
18 **
19 ****************************************************************************/
19 ****************************************************************************/
20
20
21 import QtQuick 1.0
21 import QtQuick 2.0
22 import QtQuickTest 1.0
22 import QtTest 1.0
23 import QtCommercial.Chart 1.1
23 import QtCommercial.Chart 1.1
24
24
25 Rectangle {
25 Rectangle {
@@ -63,9 +63,9 Rectangle {
63 compare(lineSeries.count, count);
63 compare(lineSeries.count, count);
64 compare(splineSeries.count, count);
64 compare(splineSeries.count, count);
65 compare(scatterSeries.count, count);
65 compare(scatterSeries.count, count);
66 tryCompare(lineSeriesPointAddedSpy.count, count);
66 compare(lineSeriesPointAddedSpy.count, count);
67 tryCompare(splineSeriesPointAddedSpy.count, count);
67 compare(splineSeriesPointAddedSpy.count, count);
68 tryCompare(scatterSeriesPointAddedSpy.count, count);
68 compare(scatterSeriesPointAddedSpy.count, count);
69 clear();
69 clear();
70 compare(lineSeries.count, 0);
70 compare(lineSeries.count, 0);
71 compare(splineSeries.count, 0);
71 compare(splineSeries.count, 0);
@@ -82,9 +82,9 Rectangle {
82 compare(lineSeries.count, count);
82 compare(lineSeries.count, count);
83 compare(splineSeries.count, count);
83 compare(splineSeries.count, count);
84 compare(scatterSeries.count, count);
84 compare(scatterSeries.count, count);
85 tryCompare(lineSeriesPointReplacedSpy.count, count);
85 compare(lineSeriesPointReplacedSpy.count, count);
86 tryCompare(splineSeriesPointReplacedSpy.count, count);
86 compare(splineSeriesPointReplacedSpy.count, count);
87 tryCompare(scatterSeriesPointReplacedSpy.count, count);
87 compare(scatterSeriesPointReplacedSpy.count, count);
88 clear();
88 clear();
89 }
89 }
90
90
@@ -101,9 +101,9 Rectangle {
101 compare(lineSeries.count, count * 2);
101 compare(lineSeries.count, count * 2);
102 compare(splineSeries.count, count * 2);
102 compare(splineSeries.count, count * 2);
103 compare(scatterSeries.count, count * 2);
103 compare(scatterSeries.count, count * 2);
104 tryCompare(lineSeriesPointAddedSpy.count, count);
104 compare(lineSeriesPointAddedSpy.count, count);
105 tryCompare(splineSeriesPointAddedSpy.count, count);
105 compare(splineSeriesPointAddedSpy.count, count);
106 tryCompare(scatterSeriesPointAddedSpy.count, count);
106 compare(scatterSeriesPointAddedSpy.count, count);
107 clear();
107 clear();
108 }
108 }
109
109
@@ -120,9 +120,9 Rectangle {
120 compare(lineSeries.count, 0);
120 compare(lineSeries.count, 0);
121 compare(splineSeries.count, 0);
121 compare(splineSeries.count, 0);
122 compare(scatterSeries.count, 0);
122 compare(scatterSeries.count, 0);
123 tryCompare(lineSeriesPointRemovedSpy.count, count);
123 compare(lineSeriesPointRemovedSpy.count, count);
124 tryCompare(splineSeriesPointRemovedSpy.count, count);
124 compare(splineSeriesPointRemovedSpy.count, count);
125 tryCompare(scatterSeriesPointRemovedSpy.count, count);
125 compare(scatterSeriesPointRemovedSpy.count, count);
126 }
126 }
127
127
128 // Not a test function, called from test functions
128 // Not a test function, called from test functions
General Comments 0
You need to be logged in to leave comments. Login now