##// END OF EJS Templates
Updated qml-qtquicktest...
Titta Heikkala -
r2822:55ef22a60a4f
parent child
Show More
@@ -0,0 +1,116
1 /****************************************************************************
2 **
3 ** Copyright (C) 2015 The Qt Company Ltd
4 ** All rights reserved.
5 ** For any questions to The Qt Company, please use contact form at http://qt.io
6 **
7 ** This file is part of the Qt Charts module.
8 **
9 ** Licensees holding valid commercial license for Qt may use this file in
10 ** accordance with the Qt License Agreement provided with the Software
11 ** or, alternatively, in accordance with the terms contained in a written
12 ** agreement between you and The Qt Company.
13 **
14 ** If you have questions regarding the use of this file, please use
15 ** contact form at http://qt.io
16 **
17 ****************************************************************************/
18
19 import QtQuick 2.0
20 import QtTest 1.0
21 import QtCharts 2.0
22
23 Rectangle {
24 width: 400
25 height: 300
26
27 TestCase {
28 id: tc1
29 name: "tst_qml-qtquicktest BarCategoryAxis 2.0"
30 when: windowShown
31
32 function test_minMax() {
33 compare(barSeries1.axisX.min, "Jan", "AxisX min");
34 compare(barSeries1.axisX.max, "Jun", "AxisX max");
35 compare(barSeries1.axisY.min, 0, "AxisY min");
36 compare(barSeries1.axisY.max, 10, "AxisY max");
37 }
38
39 function test_categories() {
40 compare(barSeries1.axisX.count, 6, "AxisX count");
41 categoriesCountChangedSpy.clear();
42 categoriesChangedSpy.clear();
43
44 // Replace categories
45 barSeries1.axisX.categories = ["Tam", "Hel", "Maa", "Huh"];
46 compare(barSeries1.axisX.count, 4, "AxisX count");
47 compare(categoriesCountChangedSpy.count, 1, "onCountChanged");
48 compare(categoriesChangedSpy.count, 1, "onCategoriesChanged");
49
50 // Reset the original categories
51 barSeries1.axisX.categories = ["Jan", "Feb", "Mar", "Apr", "May", "Jun"]
52 compare(barSeries1.axisX.count, 6, "AxisX count");
53 compare(categoriesCountChangedSpy.count, 2, "onCountChanged");
54 compare(categoriesChangedSpy.count, 2, "onCategoriesChanged");
55 }
56
57 function test_minMaxChanged() {
58 axisY.min = -1;
59 compare(minChangedSpy.count, 1, "onMinChanged");
60 compare(maxChangedSpy.count, 0, "onMaxChanged");
61 axisY.max = 12;
62 compare(minChangedSpy.count, 1, "onMinChanged");
63 compare(maxChangedSpy.count, 1, "onMaxChanged");
64 }
65
66 function test_seriesAxisClear() {
67 verify(barSeries1.axisX.min !== "", "barSeries1.axisX.min");
68 verify(barSeries1.axisX.max !== "", "barSeries1.axisX.max");
69 verify(barSeries1.axisX.count !== 0, "barSeries1.axisX.count"); // category count
70 barSeries1.axisX.clear();
71 verify(barSeries1.axisX.min === "", "barSeries1.axisX.min");
72 verify(barSeries1.axisX.max === "", "barSeries1.axisX.max");
73 verify(barSeries1.axisX.count === 0);
74 }
75
76 }
77
78 ChartView {
79 id: chartView
80 anchors.fill: parent
81
82 BarSeries {
83 id: barSeries1
84 axisX: BarCategoryAxis {
85 id: axisX
86 categories: ["Jan", "Feb", "Mar", "Apr", "May", "Jun" ]
87 }
88 axisY: ValueAxis {
89 id: axisY
90 min: 0
91 max: 10
92 }
93 }
94
95 SignalSpy {
96 id: categoriesCountChangedSpy
97 target: axisX
98 signalName: "countChanged"
99 }
100 SignalSpy {
101 id: categoriesChangedSpy
102 target: axisX
103 signalName: "categoriesChanged"
104 }
105 SignalSpy {
106 id: minChangedSpy
107 target: axisY
108 signalName: "minChanged"
109 }
110 SignalSpy {
111 id: maxChangedSpy
112 target: axisY
113 signalName: "maxChanged"
114 }
115 }
116 }
@@ -0,0 +1,161
1 /****************************************************************************
2 **
3 ** Copyright (C) 2015 The Qt Company Ltd
4 ** All rights reserved.
5 ** For any questions to The Qt Company, please use contact form at http://qt.io
6 **
7 ** This file is part of the Qt Charts module.
8 **
9 ** Licensees holding valid commercial license for Qt may use this file in
10 ** accordance with the Qt License Agreement provided with the Software
11 ** or, alternatively, in accordance with the terms contained in a written
12 ** agreement between you and The Qt Company.
13 **
14 ** If you have questions regarding the use of this file, please use
15 ** contact form at http://qt.io
16 **
17 ****************************************************************************/
18
19 import QtQuick 2.0
20 import QtTest 1.0
21 import QtCharts 2.0
22
23 Rectangle {
24 width: 400
25 height: 300
26
27 TestCase {
28 id: tc1
29 name: "tst_qml-qtquicktest BarSeries 2.0"
30 when: windowShown
31
32 function test_properties() {
33 compare(barSeries.barWidth, 0.5);
34 compare(barSeries.labelsVisible, false);
35 compare(barSeries.labelsPosition, BarSeries.LabelsCenter);
36 }
37
38 function test_setproperties() {
39 var set = barSeries.append("property", [1, 2, 3])
40 compare(set.brushFilename, "");
41 }
42
43 function test_axes() {
44 verify(chartView.axisX() == barSeries.axisX);
45 verify(chartView.axisY() == barSeries.axisY);
46
47 compare(barSeries.axisX, stackedBarSeries.axisX);
48 compare(barSeries.axisY, stackedBarSeries.axisY);
49
50 compare(barSeries.axisX, percentBarSeries.axisX);
51 compare(barSeries.axisY, percentBarSeries.axisY);
52 }
53
54 function test_append() {
55 var setCount = 5;
56 var valueCount = 50;
57 addedSpy.clear();
58 append(setCount, valueCount);
59
60 compare(barSeries.count, setCount);
61 for (var k = 0; k < setCount; k++) {
62 compare(barSeries.at(k).count, valueCount);
63 compare(barSeries.at(k).label, "barset" + k);
64 }
65 compare(addedSpy.count, setCount);
66
67 barSeries.clear();
68 compare(barSeries.count, 0);
69 }
70
71 function test_insert() {
72 var setCount = 5;
73 var valueCount = 50;
74 addedSpy.clear();
75 append(setCount, valueCount);
76
77 for (var i = 0; i < setCount; i++) {
78 var values = [];
79 for (var j = 0; j < valueCount; j++)
80 values[j] = Math.random() * 10;
81 var set = barSeries.insert(i, "barset" + i, values);
82 compare(set.label, "barset" + i);
83 }
84
85 compare(barSeries.count, setCount * 2);
86 for (var k = 0; k < setCount * 2; k++)
87 compare(barSeries.at(k).count, valueCount);
88 compare(addedSpy.count, 2 * setCount);
89
90 barSeries.clear();
91 compare(barSeries.count, 0);
92 }
93
94 function test_signals() {
95 labelsPositionSpy.clear();
96 barSeries.labelsPosition = BarSeries.LabelsOutsideEnd;
97 compare(labelsPositionSpy.count, 1, "onLabelsPositionChanged")
98 }
99
100 function test_remove() {
101 var setCount = 5;
102 var valueCount = 50;
103 removedSpy.clear();
104 append(setCount, valueCount);
105
106 for (var k = 0; k < setCount; k++)
107 barSeries.remove(barSeries.at(0));
108
109 compare(barSeries.count, 0);
110 compare(removedSpy.count, setCount);
111 }
112
113 // Not a test function, used by one or more test functions
114 function append(setCount, valueCount) {
115 for (var i = 0; i < setCount; i++) {
116 var values = [];
117 for (var j = 0; j < valueCount; j++)
118 values[j] = Math.random() * 10;
119 barSeries.append("barset" + i, values);
120 }
121 }
122 }
123
124 ChartView {
125 id: chartView
126 anchors.fill: parent
127
128 BarSeries {
129 id: barSeries
130 name: "bar"
131 axisX: BarCategoryAxis {}
132 axisY: ValueAxis { min: 0; max: 10 }
133
134 SignalSpy {
135 id: addedSpy
136 target: barSeries
137 signalName: "barsetsAdded"
138 }
139 SignalSpy {
140 id: removedSpy
141 target: barSeries
142 signalName: "barsetsRemoved"
143 }
144 SignalSpy {
145 id: labelsPositionSpy
146 target: barSeries
147 signalName: "labelsPositionChanged"
148 }
149 }
150
151 StackedBarSeries {
152 id: stackedBarSeries
153 name: "stackedBar"
154 }
155
156 PercentBarSeries {
157 id: percentBarSeries
158 name: "percentBar"
159 }
160 }
161 }
@@ -0,0 +1,98
1 /****************************************************************************
2 **
3 ** Copyright (C) 2015 The Qt Company Ltd
4 ** All rights reserved.
5 ** For any questions to The Qt Company, please use contact form at http://qt.io
6 **
7 ** This file is part of the Qt Charts module.
8 **
9 ** Licensees holding valid commercial license for Qt may use this file in
10 ** accordance with the Qt License Agreement provided with the Software
11 ** or, alternatively, in accordance with the terms contained in a written
12 ** agreement between you and The Qt Company.
13 **
14 ** If you have questions regarding the use of this file, please use
15 ** contact form at http://qt.io
16 **
17 ****************************************************************************/
18
19 import QtQuick 2.0
20 import QtTest 1.0
21 import QtCharts 2.0
22
23 Rectangle {
24 width: 400
25 height: 300
26
27 TestCase {
28 id: tc1
29 name: "tst_qml-qtquicktest BoxPlotSeries 2.0"
30 when: windowShown
31
32 function test_properties() {
33 compare(boxPlotSeries.boxWidth, 0.5);
34 compare(boxPlotSeries.brushFilename, "");
35 }
36
37 function test_setproperties() {
38 var set = boxPlotSeries.append("boxplot", [1, 2, 5, 6, 8]);
39 compare(set.label, "boxplot");
40 compare(set.count, 5);
41 compare(set.brushFilename, "");
42 }
43
44 function test_append() {
45 boxPlotSeries.clear();
46 addedSpy.clear();
47 countChangedSpy.clear();
48 var count = 50;
49 for (var i = 0; i < count; i++)
50 boxPlotSeries.append("boxplot" + i, Math.random());
51 compare(addedSpy.count, count);
52 compare(countChangedSpy.count, count);
53 compare(boxPlotSeries.count, count)
54 boxPlotSeries.clear();
55 }
56
57 function test_remove() {
58 boxPlotSeries.clear();
59 removedSpy.clear();
60 countChangedSpy.clear();
61 var count = 50;
62 for (var i = 0; i < count; i++)
63 boxPlotSeries.append("boxplot" + i, Math.random());
64 for (var j = 0; j < count; j++)
65 boxPlotSeries.remove(boxPlotSeries.at(0));
66 compare(removedSpy.count, count);
67 compare(countChangedSpy.count, 2 * count);
68 compare(boxPlotSeries.count, 0)
69 }
70 }
71
72 ChartView {
73 id: chartView
74 anchors.fill: parent
75
76 BoxPlotSeries {
77 id: boxPlotSeries
78 name: "boxplot"
79 BoxSet { label: "Jan"; values: [3, 4, 5.1, 6.2, 8.5] }
80
81 SignalSpy {
82 id: addedSpy
83 target: boxPlotSeries
84 signalName: "boxsetsAdded"
85 }
86 SignalSpy {
87 id: removedSpy
88 target: boxPlotSeries
89 signalName: "boxsetsRemoved"
90 }
91 SignalSpy {
92 id: countChangedSpy
93 target: boxPlotSeries
94 signalName: "countChanged"
95 }
96 }
97 }
98 }
@@ -0,0 +1,71
1 /****************************************************************************
2 **
3 ** Copyright (C) 2015 The Qt Company Ltd
4 ** All rights reserved.
5 ** For any questions to The Qt Company, please use contact form at http://qt.io
6 **
7 ** This file is part of the Qt Charts module.
8 **
9 ** Licensees holding valid commercial license for Qt may use this file in
10 ** accordance with the Qt License Agreement provided with the Software
11 ** or, alternatively, in accordance with the terms contained in a written
12 ** agreement between you and The Qt Company.
13 **
14 ** If you have questions regarding the use of this file, please use
15 ** contact form at http://qt.io
16 **
17 ****************************************************************************/
18
19 import QtQuick 2.0
20 import QtTest 1.0
21 import QtCharts 2.0
22
23 Rectangle {
24 width: 400
25 height: 300
26
27 TestCase {
28 id: tc1
29 name: "tst_qml-qtquicktest ChartView Signals 2.0"
30 when: windowShown
31
32 // Verify onSeriesAdded and onSeriesRemoved signals
33 function test_chartView() {
34 var series = chartView.createSeries(ChartView.SeriesTypeLine, "line");
35 seriesAddedSpy.wait();
36 compare(seriesAddedSpy.count, 1, "ChartView.onSeriesAdded");
37
38 // Modifying layout triggers more than one plotAreaChanged signal
39 chartView.titleFont.pixelSize = 50;
40 verify(plotAreaChangedSpy.count > 0, "ChartView.onPlotAreaChanged");
41
42 chartView.removeSeries(series);
43 seriesRemovedSpy.wait();
44 compare(seriesRemovedSpy.count, 1, "ChartView.onSeriesAdded");
45 }
46 }
47
48 ChartView {
49 id: chartView
50 anchors.fill: parent
51 title: "Chart"
52
53 SignalSpy {
54 id: plotAreaChangedSpy
55 target: chartView
56 signalName: "plotAreaChanged"
57 }
58
59 SignalSpy {
60 id: seriesAddedSpy
61 target: chartView
62 signalName: "seriesAdded"
63 }
64
65 SignalSpy {
66 id: seriesRemovedSpy
67 target: chartView
68 signalName: "seriesRemoved"
69 }
70 }
71 }
@@ -0,0 +1,133
1 /****************************************************************************
2 **
3 ** Copyright (C) 2015 The Qt Company Ltd
4 ** All rights reserved.
5 ** For any questions to The Qt Company, please use contact form at http://qt.io
6 **
7 ** This file is part of the Qt Charts module.
8 **
9 ** Licensees holding valid commercial license for Qt may use this file in
10 ** accordance with the Qt License Agreement provided with the Software
11 ** or, alternatively, in accordance with the terms contained in a written
12 ** agreement between you and The Qt Company.
13 **
14 ** If you have questions regarding the use of this file, please use
15 ** contact form at http://qt.io
16 **
17 ****************************************************************************/
18
19 import QtQuick 2.0
20 import QtTest 1.0
21 import QtCharts 2.0
22
23 Rectangle {
24 width: 400
25 height: 300
26
27 TestCase {
28 id: tc1
29 name: "tst_qml-qtquicktest PieSeries 2.0"
30 when: windowShown
31
32 function test_properties() {
33 compare(pieSeries.endAngle, 360);
34 compare(pieSeries.holeSize, 0);
35 compare(pieSeries.horizontalPosition, 0.5);
36 compare(pieSeries.size, 0.7);
37 compare(pieSeries.startAngle, 0);
38 compare(pieSeries.sum, 0);
39 compare(pieSeries.verticalPosition, 0.5);
40 }
41
42 function test_sliceproperties() {
43 var slice = pieSeries.append("slice", 10);
44 compare(slice.angleSpan, 360.0);
45 verify(slice.borderColor != undefined);
46 compare(slice.borderWidth, 1);
47 verify(slice.color != undefined);
48 compare(slice.explodeDistanceFactor, 0.15);
49 compare(slice.exploded, false);
50 compare(slice.label, "slice");
51 compare(slice.labelArmLengthFactor, 0.15);
52 verify(slice.labelColor != undefined);
53 compare(slice.labelFont.bold, false);
54 compare(slice.labelPosition, PieSlice.LabelOutside);
55 compare(slice.labelVisible, false);
56 compare(slice.percentage, 1.0);
57 compare(slice.startAngle, 0.0);
58 compare(slice.value, 10.0);
59 compare(slice.brushFilename, "");
60 }
61
62 function test_append() {
63 addedSpy.clear();
64 countChangedSpy.clear();
65 sumChangedSpy.clear();
66 var count = 50;
67 for (var i = 0; i < count; i++)
68 pieSeries.append("slice" + i, Math.random());
69 compare(addedSpy.count, count);
70 compare(countChangedSpy.count, count);
71 compare(sumChangedSpy.count, count);
72 pieSeries.clear();
73 }
74
75 function test_remove() {
76 removedSpy.clear();
77 countChangedSpy.clear();
78 sumChangedSpy.clear();
79 var count = 50;
80 for (var i = 0; i < count; i++)
81 pieSeries.append("slice" + i, Math.random());
82 for (var j = 0; j < count; j++)
83 pieSeries.remove(pieSeries.at(0));
84 compare(removedSpy.count, count);
85 compare(countChangedSpy.count, 2 * count);
86 compare(sumChangedSpy.count, 2 * count);
87 compare(pieSeries.count, 0);
88 }
89
90 function test_find_and_at() {
91 var count = 50;
92 for (var i = 0; i < count; i++)
93 pieSeries.append("slice" + i, Math.random());
94 for (var j = 0; j < count; j++) {
95 compare(pieSeries.find("slice" + j).label, "slice" + j);
96 compare(pieSeries.find("slice" + j).brushFilename, "");
97 }
98 compare(pieSeries.at(3).brushFilename,"");
99 pieSeries.clear();
100 }
101 }
102
103 ChartView {
104 id: chartView
105 anchors.fill: parent
106
107 PieSeries {
108 id: pieSeries
109 name: "pie"
110
111 SignalSpy {
112 id: addedSpy
113 target: pieSeries
114 signalName: "added"
115 }
116 SignalSpy {
117 id: removedSpy
118 target: pieSeries
119 signalName: "removed"
120 }
121 SignalSpy {
122 id: sumChangedSpy
123 target: pieSeries
124 signalName: "sumChanged"
125 }
126 SignalSpy {
127 id: countChangedSpy
128 target: pieSeries
129 signalName: "countChanged"
130 }
131 }
132 }
133 }
@@ -18,7 +18,7
18
18
19 import QtQuick 2.0
19 import QtQuick 2.0
20 import QtTest 1.0
20 import QtTest 1.0
21 import QtCharts 2.0
21 import QtCharts 2.1
22
22
23 Rectangle {
23 Rectangle {
24 width: 400
24 width: 400
@@ -18,7 +18,7
18
18
19 import QtQuick 2.0
19 import QtQuick 2.0
20 import QtTest 1.0
20 import QtTest 1.0
21 import QtCharts 2.0
21 import QtCharts 2.1
22
22
23 Rectangle {
23 Rectangle {
24 width: 400
24 width: 400
@@ -18,7 +18,7
18
18
19 import QtQuick 2.0
19 import QtQuick 2.0
20 import QtTest 1.0
20 import QtTest 1.0
21 import QtCharts 2.0
21 import QtCharts 2.1
22
22
23 Rectangle {
23 Rectangle {
24 width: 400
24 width: 400
@@ -26,7 +26,7 Rectangle {
26
26
27 TestCase {
27 TestCase {
28 id: tc1
28 id: tc1
29 name: "tst_qml-qtquicktest CategoryAxis"
29 name: "tst_qml-qtquicktest CategoryAxis 2.0"
30 when: windowShown
30 when: windowShown
31
31
32 function test_minMax() {
32 function test_minMax() {
@@ -26,7 +26,7 Rectangle {
26
26
27 TestCase {
27 TestCase {
28 id: tc1
28 id: tc1
29 name: "tst_qml-qtquicktest ChartView Properties"
29 name: "tst_qml-qtquicktest ChartView Properties 2.0"
30 when: windowShown
30 when: windowShown
31
31
32 function test_chartViewProperties() {
32 function test_chartViewProperties() {
@@ -26,7 +26,7 Rectangle {
26
26
27 TestCase {
27 TestCase {
28 id: tc1
28 id: tc1
29 name: "tst_qml-qtquicktest ChartView Functions"
29 name: "tst_qml-qtquicktest ChartView Functions 2.0"
30 when: windowShown
30 when: windowShown
31
31
32 function test_chartViewSeriesAndAxes() {
32 function test_chartViewSeriesAndAxes() {
@@ -18,7 +18,7
18
18
19 import QtQuick 2.0
19 import QtQuick 2.0
20 import QtTest 1.0
20 import QtTest 1.0
21 import QtCharts 2.0
21 import QtCharts 2.1
22
22
23 Rectangle {
23 Rectangle {
24 width: 400
24 width: 400
@@ -18,7 +18,7
18
18
19 import QtQuick 2.0
19 import QtQuick 2.0
20 import QtTest 1.0
20 import QtTest 1.0
21 import QtCharts 2.0
21 import QtCharts 2.1
22
22
23 Rectangle {
23 Rectangle {
24 width: 400
24 width: 400
@@ -26,7 +26,7 Rectangle {
26
26
27 TestCase {
27 TestCase {
28 id: tc1
28 id: tc1
29 name: "tst_qml-qtquicktest ValueAxis"
29 name: "tst_qml-qtquicktest ValueAxis 2.0"
30 when: windowShown
30 when: windowShown
31
31
32 // test functions are run in alphabetical order, the name has 'a' so that it
32 // test functions are run in alphabetical order, the name has 'a' so that it
@@ -26,7 +26,7 Rectangle {
26
26
27 TestCase {
27 TestCase {
28 id: tc1
28 id: tc1
29 name: "tst_qml-qtquicktest XY Series"
29 name: "tst_qml-qtquicktest XY Series 2.0"
30 when: windowShown
30 when: windowShown
31
31
32 function test_properties() {
32 function test_properties() {
General Comments 0
You need to be logged in to leave comments. Login now