Debian Codegraph @

tests/auto/qml-qtquicktest/data/tst_xyseries_1_3.qml

raw
1 // Copyright (C) 2016 The Qt Company Ltd.
2 // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
3
4 import QtQuick 2.0
5 import QtTest 1.0
6 import QtCharts 1.3
7
8 Rectangle {
9 width: 400
10 height: 300
11
12 TestCase {
13 id: tc1
14 name: "tst_qml-qtquicktest XY Series 1.3"
15 when: windowShown
16
17 function test_properties() {
18 verify(lineSeries.color != undefined);
19 compare(lineSeries.pointsVisible, false);
20 compare(lineSeries.capStyle, Qt.SquareCap);
21 compare(lineSeries.style, Qt.SolidLine);
22 compare(lineSeries.width, 2.0);
23
24 verify(splineSeries.color != undefined);
25 compare(splineSeries.pointsVisible, false);
26 compare(splineSeries.capStyle, Qt.SquareCap);
27 compare(splineSeries.style, Qt.SolidLine);
28 compare(splineSeries.width, 2.0);
29
30 verify(scatterSeries.color != undefined);
31 verify(scatterSeries.borderColor != undefined);
32 compare(scatterSeries.borderWidth, 2.0);
33 compare(scatterSeries.markerShape, ScatterSeries.MarkerShapeCircle);
34 compare(scatterSeries.markerSize, 15.0);
35
36 verify(areaSeries.color != undefined);
37 verify(areaSeries.borderColor != undefined);
38 compare(areaSeries.borderWidth, 2.0);
39 }
40
41 function test_axes() {
42 // Axis initialization
43 compare(chartView.axisX(), lineSeries.axisX);
44 compare(chartView.axisY(), lineSeries.axisY);
45 compare(lineSeries.axisX, splineSeries.axisX);
46 compare(lineSeries.axisY, splineSeries.axisY);
47 compare(lineSeries.axisX, areaSeries.axisX);
48 compare(lineSeries.axisY, areaSeries.axisY);
49 }
50
51 function test_append() {
52 lineSeriesPointAddedSpy.clear();
53 splineSeriesPointAddedSpy.clear();
54 scatterSeriesPointAddedSpy.clear();
55 var count = append();
56 compare(lineSeries.count, count);
57 compare(splineSeries.count, count);
58 compare(scatterSeries.count, count);
59 compare(lineSeriesPointAddedSpy.count, count);
60 compare(splineSeriesPointAddedSpy.count, count);
61 compare(scatterSeriesPointAddedSpy.count, count);
62 clear();
63 compare(lineSeries.count, 0);
64 compare(splineSeries.count, 0);
65 compare(scatterSeries.count, 0);
66 }
67
68 function test_replace() {
69 var count = append();
70 for (var i = 0; i < count; i++) {
71 lineSeries.replace(lineSeries.at(i).x, lineSeries.at(i).y, i, Math.random());
72 splineSeries.replace(splineSeries.at(i).x, splineSeries.at(i).y, i, Math.random());
73 scatterSeries.replace(scatterSeries.at(i).x, scatterSeries.at(i).y, i, Math.random());
74 }
75 compare(lineSeries.count, count);
76 compare(splineSeries.count, count);
77 compare(scatterSeries.count, count);
78 compare(lineSeriesPointReplacedSpy.count, count);
79 compare(splineSeriesPointReplacedSpy.count, count);
80 compare(scatterSeriesPointReplacedSpy.count, count);
81 clear();
82 }
83
84 function test_insert() {
85 var count = append();
86 lineSeriesPointAddedSpy.clear();
87 splineSeriesPointAddedSpy.clear();
88 scatterSeriesPointAddedSpy.clear();
89 for (var i = 0; i < count; i++) {
90 lineSeries.insert(i * 2, i, Math.random());
91 splineSeries.insert(i * 2, i, Math.random());
92 scatterSeries.insert(i * 2, i, Math.random());
93 }
94 compare(lineSeries.count, count * 2);
95 compare(splineSeries.count, count * 2);
96 compare(scatterSeries.count, count * 2);
97 compare(lineSeriesPointAddedSpy.count, count);
98 compare(splineSeriesPointAddedSpy.count, count);
99 compare(scatterSeriesPointAddedSpy.count, count);
100 clear();
101 }
102
103 function test_remove() {
104 lineSeriesPointRemovedSpy.clear();
105 splineSeriesPointRemovedSpy.clear();
106 scatterSeriesPointRemovedSpy.clear();
107 var count = append();
108 for (var i = 0; i < count; i++) {
109 lineSeries.remove(lineSeries.at(0).x, lineSeries.at(0).y);
110 splineSeries.remove(splineSeries.at(0).x, splineSeries.at(0).y);
111 scatterSeries.remove(scatterSeries.at(0).x, scatterSeries.at(0).y);
112 }
113 compare(lineSeries.count, 0);
114 compare(splineSeries.count, 0);
115 compare(scatterSeries.count, 0);
116 compare(lineSeriesPointRemovedSpy.count, count);
117 compare(splineSeriesPointRemovedSpy.count, count);
118 compare(scatterSeriesPointRemovedSpy.count, count);
119 }
120
121 // Not a test function, called from test functions
122 function append() {
123 var count = 100;
124 chartView.axisX().min = 0;
125 chartView.axisX().max = 100;
126 chartView.axisY().min = 0;
127 chartView.axisY().max = 1;
128
129 for (var i = 0; i < count; i++) {
130 lineSeries.append(i, Math.random());
131 splineSeries.append(i, Math.random());
132 scatterSeries.append(i, Math.random());
133 }
134
135 return count;
136 }
137
138 // Not a test function, called from test functions
139 function clear() {
140 lineSeries.clear();
141 splineSeries.clear();
142 scatterSeries.clear();
143 }
144 }
145
146 ChartView {
147 id: chartView
148 anchors.fill: parent
149
150 LineSeries {
151 id: lineSeries
152 name: "line"
153
154 SignalSpy {
155 id: lineSeriesPointAddedSpy
156 target: lineSeries
157 signalName: "pointAdded"
158 }
159
160 SignalSpy {
161 id: lineSeriesPointReplacedSpy
162 target: lineSeries
163 signalName: "pointReplaced"
164 }
165
166 SignalSpy {
167 id: lineSeriesPointsReplacedSpy
168 target: lineSeries
169 signalName: "pointsReplaced"
170 }
171
172 SignalSpy {
173 id: lineSeriesPointRemovedSpy
174 target: lineSeries
175 signalName: "pointRemoved"
176 }
177 }
178
179 AreaSeries {
180 id: areaSeries
181 name: "area"
182 upperSeries: lineSeries
183 }
184
185 SplineSeries {
186 id: splineSeries
187 name: "spline"
188
189 SignalSpy {
190 id: splineSeriesPointAddedSpy
191 target: splineSeries
192 signalName: "pointAdded"
193 }
194
195 SignalSpy {
196 id: splineSeriesPointReplacedSpy
197 target: splineSeries
198 signalName: "pointReplaced"
199 }
200
201 SignalSpy {
202 id: splineSeriesPointsReplacedSpy
203 target: splineSeries
204 signalName: "pointsReplaced"
205 }
206
207 SignalSpy {
208 id: splineSeriesPointRemovedSpy
209 target: splineSeries
210 signalName: "pointRemoved"
211 }
212 }
213
214 ScatterSeries {
215 id: scatterSeries
216 name: "scatter"
217
218 SignalSpy {
219 id: scatterSeriesPointAddedSpy
220 target: scatterSeries
221 signalName: "pointAdded"
222 }
223
224 SignalSpy {
225 id: scatterSeriesPointReplacedSpy
226 target: scatterSeries
227 signalName: "pointReplaced"
228 }
229
230 SignalSpy {
231 id: scatterSeriesPointsReplacedSpy
232 target: scatterSeries
233 signalName: "pointsReplaced"
234 }
235
236 SignalSpy {
237 id: scatterSeriesPointRemovedSpy
238 target: scatterSeries
239 signalName: "pointRemoved"
240 }
241 }
242 }
243 }