Debian Codegraph @

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