@@ -7,9 +7,9 QTCOMMERCIALCHART_USE_NAMESPACE | |||||
7 | Q_DECLARE_METATYPE(Domain*) |
|
7 | Q_DECLARE_METATYPE(Domain*) | |
8 | Q_DECLARE_METATYPE(QSizeF) |
|
8 | Q_DECLARE_METATYPE(QSizeF) | |
9 |
|
9 | |||
10 |
class tst_Domain |
|
10 | class tst_Domain: public QObject | |
11 | { |
|
11 | { | |
12 |
|
|
12 | Q_OBJECT | |
13 |
|
13 | |||
14 | public slots: |
|
14 | public slots: | |
15 | void initTestCase(); |
|
15 | void initTestCase(); | |
@@ -47,6 +47,12 private slots: | |||||
47 | void spanY(); |
|
47 | void spanY(); | |
48 | void zoom_data(); |
|
48 | void zoom_data(); | |
49 | void zoom(); |
|
49 | void zoom(); | |
|
50 | void move_data(); | |||
|
51 | void move(); | |||
|
52 | void handleAxisXChanged_data(); | |||
|
53 | void handleAxisXChanged(); | |||
|
54 | void handleAxisYChanged_data(); | |||
|
55 | void handleAxisYChanged(); | |||
50 | }; |
|
56 | }; | |
51 |
|
57 | |||
52 | void tst_Domain::initTestCase() |
|
58 | void tst_Domain::initTestCase() | |
@@ -93,8 +99,8 void tst_Domain::handleAxisRangeXChanged() | |||||
93 | Domain domain; |
|
99 | Domain domain; | |
94 |
|
100 | |||
95 | QSignalSpy spy0(&domain, SIGNAL(domainChanged(qreal, qreal, qreal, qreal))); |
|
101 | QSignalSpy spy0(&domain, SIGNAL(domainChanged(qreal, qreal, qreal, qreal))); | |
96 | QSignalSpy spy1(&domain, SIGNAL(rangeXChanged(qreal, qreal))); |
|
102 | QSignalSpy spy1(&domain, SIGNAL(rangeXChanged(qreal, qreal,int ))); | |
97 | QSignalSpy spy2(&domain, SIGNAL(rangeYChanged(qreal, qreal))); |
|
103 | QSignalSpy spy2(&domain, SIGNAL(rangeYChanged(qreal, qreal,int ))); | |
98 |
|
104 | |||
99 | domain.handleAxisXChanged(min, max); |
|
105 | domain.handleAxisXChanged(min, max); | |
100 |
|
106 | |||
@@ -121,7 +127,6 void tst_Domain::handleAxisRangeYChanged_data() | |||||
121 | QTest::newRow("-1 0") << -1.0 << 0.0; |
|
127 | QTest::newRow("-1 0") << -1.0 << 0.0; | |
122 | } |
|
128 | } | |
123 |
|
129 | |||
124 |
|
||||
125 | void tst_Domain::handleAxisRangeYChanged() |
|
130 | void tst_Domain::handleAxisRangeYChanged() | |
126 | { |
|
131 | { | |
127 | QFETCH(qreal, min); |
|
132 | QFETCH(qreal, min); | |
@@ -130,10 +135,10 void tst_Domain::handleAxisRangeYChanged() | |||||
130 | Domain domain; |
|
135 | Domain domain; | |
131 |
|
136 | |||
132 | QSignalSpy spy0(&domain, SIGNAL(domainChanged(qreal, qreal, qreal, qreal))); |
|
137 | QSignalSpy spy0(&domain, SIGNAL(domainChanged(qreal, qreal, qreal, qreal))); | |
133 | QSignalSpy spy1(&domain, SIGNAL(rangeXChanged(qreal, qreal))); |
|
138 | QSignalSpy spy1(&domain, SIGNAL(rangeXChanged(qreal, qreal,int ))); | |
134 | QSignalSpy spy2(&domain, SIGNAL(rangeYChanged(qreal, qreal))); |
|
139 | QSignalSpy spy2(&domain, SIGNAL(rangeYChanged(qreal, qreal,int ))); | |
135 |
|
140 | |||
136 | domain.handleAxisYChanged(min, max,5); |
|
141 | domain.handleAxisYChanged(min, max, 5); | |
137 |
|
142 | |||
138 | QList<QVariant> arg0 = spy0.first(); |
|
143 | QList<QVariant> arg0 = spy0.first(); | |
139 | QVERIFY(qFuzzyIsNull(arg0.at(2).toReal() - min)); |
|
144 | QVERIFY(qFuzzyIsNull(arg0.at(2).toReal() - min)); | |
@@ -163,14 +168,14 void tst_Domain::isEmpty_data() | |||||
163 |
|
168 | |||
164 | void tst_Domain::isEmpty() |
|
169 | void tst_Domain::isEmpty() | |
165 | { |
|
170 | { | |
166 |
|
|
171 | QFETCH(qreal, minX); | |
167 |
|
|
172 | QFETCH(qreal, maxX); | |
168 |
|
|
173 | QFETCH(qreal, minY); | |
169 |
|
|
174 | QFETCH(qreal, maxY); | |
170 | QFETCH(bool, isEmpty); |
|
175 | QFETCH(bool, isEmpty); | |
171 |
|
176 | |||
172 | Domain domain; |
|
177 | Domain domain; | |
173 | domain.setRange(minX,maxX,minY,maxY); |
|
178 | domain.setRange(minX, maxX, minY, maxY); | |
174 | QCOMPARE(domain.isEmpty(), isEmpty); |
|
179 | QCOMPARE(domain.isEmpty(), isEmpty); | |
175 | } |
|
180 | } | |
176 |
|
181 | |||
@@ -193,15 +198,14 void tst_Domain::maxX() | |||||
193 | Domain domain; |
|
198 | Domain domain; | |
194 |
|
199 | |||
195 | QSignalSpy spy0(&domain, SIGNAL(domainChanged(qreal, qreal, qreal, qreal))); |
|
200 | QSignalSpy spy0(&domain, SIGNAL(domainChanged(qreal, qreal, qreal, qreal))); | |
196 | QSignalSpy spy1(&domain, SIGNAL(rangeXChanged(qreal, qreal))); |
|
201 | QSignalSpy spy1(&domain, SIGNAL(rangeXChanged(qreal, qreal,int ))); | |
197 | QSignalSpy spy2(&domain, SIGNAL(rangeYChanged(qreal, qreal))); |
|
202 | QSignalSpy spy2(&domain, SIGNAL(rangeYChanged(qreal, qreal,int ))); | |
198 |
|
203 | |||
199 | domain.setMaxX(maxX1); |
|
204 | domain.setMaxX(maxX1); | |
200 | QCOMPARE(domain.maxX(), maxX1); |
|
205 | QCOMPARE(domain.maxX(), maxX1); | |
201 | domain.setMaxX(maxX2); |
|
206 | domain.setMaxX(maxX2); | |
202 | QCOMPARE(domain.maxX(), maxX2); |
|
207 | QCOMPARE(domain.maxX(), maxX2); | |
203 |
|
208 | |||
204 |
|
||||
205 | QCOMPARE(spy0.count(), count); |
|
209 | QCOMPARE(spy0.count(), count); | |
206 | QCOMPARE(spy1.count(), count); |
|
210 | QCOMPARE(spy1.count(), count); | |
207 | QCOMPARE(spy2.count(), 0); |
|
211 | QCOMPARE(spy2.count(), 0); | |
@@ -210,100 +214,98 void tst_Domain::maxX() | |||||
210 |
|
214 | |||
211 | void tst_Domain::maxY_data() |
|
215 | void tst_Domain::maxY_data() | |
212 | { |
|
216 | { | |
213 |
|
|
217 | QTest::addColumn<qreal>("maxY1"); | |
214 |
|
|
218 | QTest::addColumn<qreal>("maxY2"); | |
215 |
|
|
219 | QTest::addColumn<int>("count"); | |
216 |
|
|
220 | QTest::newRow("1") << 0.0 << 1.0 << 1; | |
217 |
|
|
221 | QTest::newRow("1.0") << 1.0 << 1.0 << 1; | |
218 |
|
|
222 | QTest::newRow("2.0") << 1.0 << 0.0 << 2; | |
219 | } |
|
223 | } | |
220 |
|
224 | |||
221 |
|
||||
222 | void tst_Domain::maxY() |
|
225 | void tst_Domain::maxY() | |
223 | { |
|
226 | { | |
224 |
|
|
227 | QFETCH(qreal, maxY1); | |
225 |
|
|
228 | QFETCH(qreal, maxY2); | |
226 |
|
|
229 | QFETCH(int, count); | |
227 |
|
230 | |||
228 |
|
|
231 | Domain domain; | |
229 |
|
232 | |||
230 |
|
|
233 | QSignalSpy spy0(&domain, SIGNAL(domainChanged(qreal, qreal, qreal, qreal))); | |
231 |
|
|
234 | QSignalSpy spy1(&domain, SIGNAL(rangeXChanged(qreal, qreal,int ))); | |
232 |
|
|
235 | QSignalSpy spy2(&domain, SIGNAL(rangeYChanged(qreal, qreal,int ))); | |
233 |
|
236 | |||
234 |
|
|
237 | domain.setMaxY(maxY1); | |
235 |
|
|
238 | QCOMPARE(domain.maxY(), maxY1); | |
236 |
|
|
239 | domain.setMaxY(maxY2); | |
237 |
|
|
240 | QCOMPARE(domain.maxY(), maxY2); | |
238 |
|
241 | |||
239 |
|
|
242 | QCOMPARE(spy0.count(), count); | |
240 |
|
|
243 | QCOMPARE(spy1.count(), 0); | |
241 |
|
|
244 | QCOMPARE(spy2.count(), count); | |
242 | } |
|
245 | } | |
243 |
|
246 | |||
244 | void tst_Domain::minX_data() |
|
247 | void tst_Domain::minX_data() | |
245 | { |
|
248 | { | |
246 |
|
|
249 | QTest::addColumn<qreal>("minX1"); | |
247 |
|
|
250 | QTest::addColumn<qreal>("minX2"); | |
248 |
|
|
251 | QTest::addColumn<int>("count"); | |
249 |
|
|
252 | QTest::newRow("1") << 0.0 << 1.0 << 1; | |
250 |
|
|
253 | QTest::newRow("1.0") << 1.0 << 1.0 << 1; | |
251 |
|
|
254 | QTest::newRow("2.0") << 1.0 << 0.0 << 2; | |
252 | } |
|
255 | } | |
253 |
|
256 | |||
254 |
|
||||
255 | void tst_Domain::minX() |
|
257 | void tst_Domain::minX() | |
256 | { |
|
258 | { | |
257 |
|
|
259 | QFETCH(qreal, minX1); | |
258 |
|
|
260 | QFETCH(qreal, minX2); | |
259 |
|
|
261 | QFETCH(int, count); | |
260 |
|
262 | |||
261 |
|
|
263 | Domain domain; | |
262 |
|
264 | |||
263 |
|
|
265 | QSignalSpy spy0(&domain, SIGNAL(domainChanged(qreal, qreal, qreal, qreal))); | |
264 |
|
|
266 | QSignalSpy spy1(&domain, SIGNAL(rangeXChanged(qreal, qreal,int ))); | |
265 |
|
|
267 | QSignalSpy spy2(&domain, SIGNAL(rangeYChanged(qreal, qreal,int ))); | |
266 |
|
268 | |||
267 |
|
|
269 | domain.setMinX(minX1); | |
268 |
|
|
270 | QCOMPARE(domain.minX(), minX1); | |
269 |
|
|
271 | domain.setMinX(minX2); | |
270 |
|
|
272 | QCOMPARE(domain.minX(), minX2); | |
271 |
|
273 | |||
272 |
|
|
274 | QCOMPARE(spy0.count(), count); | |
273 |
|
|
275 | QCOMPARE(spy1.count(), count); | |
274 |
|
|
276 | QCOMPARE(spy2.count(), 0); | |
275 | } |
|
277 | } | |
276 |
|
278 | |||
277 | void tst_Domain::minY_data() |
|
279 | void tst_Domain::minY_data() | |
278 | { |
|
280 | { | |
279 |
|
|
281 | QTest::addColumn<qreal>("minY1"); | |
280 |
|
|
282 | QTest::addColumn<qreal>("minY2"); | |
281 |
|
|
283 | QTest::addColumn<int>("count"); | |
282 |
|
|
284 | QTest::newRow("1") << 0.0 << 1.0 << 1; | |
283 |
|
|
285 | QTest::newRow("1.0") << 1.0 << 1.0 << 1; | |
284 |
|
|
286 | QTest::newRow("2.0") << 1.0 << 0.0 << 2; | |
285 | } |
|
287 | } | |
286 |
|
288 | |||
287 | void tst_Domain::minY() |
|
289 | void tst_Domain::minY() | |
288 | { |
|
290 | { | |
289 |
|
|
291 | QFETCH(qreal, minY1); | |
290 |
|
|
292 | QFETCH(qreal, minY2); | |
291 |
|
|
293 | QFETCH(int, count); | |
292 |
|
294 | |||
293 |
|
|
295 | Domain domain; | |
294 |
|
296 | |||
295 |
|
|
297 | QSignalSpy spy0(&domain, SIGNAL(domainChanged(qreal, qreal, qreal, qreal))); | |
296 |
|
|
298 | QSignalSpy spy1(&domain, SIGNAL(rangeXChanged(qreal, qreal,int ))); | |
297 |
|
|
299 | QSignalSpy spy2(&domain, SIGNAL(rangeYChanged(qreal, qreal,int ))); | |
298 |
|
300 | |||
299 |
|
|
301 | domain.setMinY(minY1); | |
300 |
|
|
302 | QCOMPARE(domain.minY(), minY1); | |
301 |
|
|
303 | domain.setMinY(minY2); | |
302 |
|
|
304 | QCOMPARE(domain.minY(), minY2); | |
303 |
|
305 | |||
304 |
|
|
306 | QCOMPARE(spy0.count(), count); | |
305 |
|
|
307 | QCOMPARE(spy1.count(), 0); | |
306 |
|
|
308 | QCOMPARE(spy2.count(), count); | |
307 | } |
|
309 | } | |
308 |
|
310 | |||
309 | void tst_Domain::operatorEquals_data() |
|
311 | void tst_Domain::operatorEquals_data() | |
@@ -316,19 +318,19 void tst_Domain::operatorEquals_data() | |||||
316 | Domain* a; |
|
318 | Domain* a; | |
317 | Domain* b; |
|
319 | Domain* b; | |
318 | a = new Domain(); |
|
320 | a = new Domain(); | |
319 | a->setRange(0,100,0,100); |
|
321 | a->setRange(0, 100, 0, 100); | |
320 | b = new Domain(); |
|
322 | b = new Domain(); | |
321 | b->setRange(0,100,0,100); |
|
323 | b->setRange(0, 100, 0, 100); | |
322 | QTest::newRow("equals") << a << b << true <<false; |
|
324 | QTest::newRow("equals") << a << b << true << false; | |
323 | a = new Domain(); |
|
325 | a = new Domain(); | |
324 | a->setRange(0,100,0,100); |
|
326 | a->setRange(0, 100, 0, 100); | |
325 | b = new Domain(); |
|
327 | b = new Domain(); | |
326 | b->setRange(0,100,0,1); |
|
328 | b->setRange(0, 100, 0, 1); | |
327 | QTest::newRow("equals") << a << b << false << true; |
|
329 | QTest::newRow("equals") << a << b << false << true; | |
328 | a = new Domain(); |
|
330 | a = new Domain(); | |
329 | a->setRange(0,100,0,100); |
|
331 | a->setRange(0, 100, 0, 100); | |
330 | b = new Domain(); |
|
332 | b = new Domain(); | |
331 | b->setRange(0,1,0,100); |
|
333 | b->setRange(0, 1, 0, 100); | |
332 | QTest::newRow("equals") << a << b << false << true; |
|
334 | QTest::newRow("equals") << a << b << false << true; | |
333 |
|
335 | |||
334 | } |
|
336 | } | |
@@ -343,8 +345,8 void tst_Domain::operatorEquals() | |||||
343 | Domain domain; |
|
345 | Domain domain; | |
344 |
|
346 | |||
345 | QSignalSpy spy0(&domain, SIGNAL(domainChanged(qreal, qreal, qreal, qreal))); |
|
347 | QSignalSpy spy0(&domain, SIGNAL(domainChanged(qreal, qreal, qreal, qreal))); | |
346 | QSignalSpy spy1(&domain, SIGNAL(rangeXChanged(qreal, qreal))); |
|
348 | QSignalSpy spy1(&domain, SIGNAL(rangeXChanged(qreal, qreal,int ))); | |
347 | QSignalSpy spy2(&domain, SIGNAL(rangeYChanged(qreal, qreal))); |
|
349 | QSignalSpy spy2(&domain, SIGNAL(rangeYChanged(qreal, qreal,int ))); | |
348 |
|
350 | |||
349 | QCOMPARE(*domain1==*domain2, equals); |
|
351 | QCOMPARE(*domain1==*domain2, equals); | |
350 | QCOMPARE(*domain1!=*domain2, notEquals); |
|
352 | QCOMPARE(*domain1!=*domain2, notEquals); | |
@@ -375,8 +377,8 void tst_Domain::setRange() | |||||
375 | Domain domain; |
|
377 | Domain domain; | |
376 |
|
378 | |||
377 | QSignalSpy spy0(&domain, SIGNAL(domainChanged(qreal, qreal, qreal, qreal))); |
|
379 | QSignalSpy spy0(&domain, SIGNAL(domainChanged(qreal, qreal, qreal, qreal))); | |
378 | QSignalSpy spy1(&domain, SIGNAL(rangeXChanged(qreal, qreal))); |
|
380 | QSignalSpy spy1(&domain, SIGNAL(rangeXChanged(qreal, qreal,int ))); | |
379 | QSignalSpy spy2(&domain, SIGNAL(rangeYChanged(qreal, qreal))); |
|
381 | QSignalSpy spy2(&domain, SIGNAL(rangeYChanged(qreal, qreal,int ))); | |
380 |
|
382 | |||
381 | domain.setRange(minX, maxX, minY, maxY); |
|
383 | domain.setRange(minX, maxX, minY, maxY); | |
382 |
|
384 | |||
@@ -389,83 +391,82 void tst_Domain::setRange() | |||||
389 | QCOMPARE(spy1.count(), 1); |
|
391 | QCOMPARE(spy1.count(), 1); | |
390 | QCOMPARE(spy2.count(), 1); |
|
392 | QCOMPARE(spy2.count(), 1); | |
391 |
|
393 | |||
392 |
|
||||
393 | } |
|
394 | } | |
394 |
|
395 | |||
395 | void tst_Domain::setRangeX_data() |
|
396 | void tst_Domain::setRangeX_data() | |
396 | { |
|
397 | { | |
397 |
|
|
398 | QTest::addColumn<qreal>("min"); | |
398 |
|
|
399 | QTest::addColumn<qreal>("max"); | |
399 |
|
|
400 | QTest::newRow("-1 1") << -1.0 << 1.0; | |
400 |
|
|
401 | QTest::newRow("0 1") << 0.0 << 1.0; | |
401 |
|
|
402 | QTest::newRow("-1 0") << -1.0 << 0.0; | |
402 | } |
|
403 | } | |
403 |
|
404 | |||
404 | void tst_Domain::setRangeX() |
|
405 | void tst_Domain::setRangeX() | |
405 | { |
|
406 | { | |
406 |
|
|
407 | QFETCH(qreal, min); | |
407 |
|
|
408 | QFETCH(qreal, max); | |
408 |
|
409 | |||
409 |
|
|
410 | Domain domain; | |
410 |
|
411 | |||
411 |
|
|
412 | QSignalSpy spy0(&domain, SIGNAL(domainChanged(qreal, qreal, qreal, qreal))); | |
412 |
|
|
413 | QSignalSpy spy1(&domain, SIGNAL(rangeXChanged(qreal, qreal,int ))); | |
413 |
|
|
414 | QSignalSpy spy2(&domain, SIGNAL(rangeYChanged(qreal, qreal,int ))); | |
414 |
|
415 | |||
415 |
|
|
416 | domain.setRangeX(min, max); | |
416 |
|
417 | |||
417 |
|
|
418 | QList<QVariant> arg0 = spy0.first(); | |
418 | QVERIFY(qFuzzyIsNull(arg0.at(0).toReal() - min)); |
|
419 | QVERIFY(qFuzzyIsNull(arg0.at(0).toReal() - min)); | |
419 | QVERIFY(qFuzzyIsNull(arg0.at(1).toReal() - max)); |
|
420 | QVERIFY(qFuzzyIsNull(arg0.at(1).toReal() - max)); | |
420 |
|
421 | |||
421 |
|
|
422 | QList<QVariant> arg1 = spy1.first(); | |
422 | QVERIFY(qFuzzyIsNull(arg1.at(0).toReal() - min)); |
|
423 | QVERIFY(qFuzzyIsNull(arg1.at(0).toReal() - min)); | |
423 | QVERIFY(qFuzzyIsNull(arg1.at(1).toReal() - max)); |
|
424 | QVERIFY(qFuzzyIsNull(arg1.at(1).toReal() - max)); | |
424 |
|
425 | |||
425 |
|
|
426 | QCOMPARE(spy0.count(), 1); | |
426 |
|
|
427 | QCOMPARE(spy1.count(), 1); | |
427 |
|
|
428 | QCOMPARE(spy2.count(), 0); | |
428 | } |
|
429 | } | |
429 |
|
430 | |||
430 | void tst_Domain::setRangeY_data() |
|
431 | void tst_Domain::setRangeY_data() | |
431 | { |
|
432 | { | |
432 |
|
|
433 | QTest::addColumn<qreal>("min"); | |
433 |
|
|
434 | QTest::addColumn<qreal>("max"); | |
434 |
|
|
435 | QTest::newRow("-1 1") << -1.0 << 1.0; | |
435 |
|
|
436 | QTest::newRow("0 1") << 0.0 << 1.0; | |
436 |
|
|
437 | QTest::newRow("-1 0") << -1.0 << 0.0; | |
437 | } |
|
438 | } | |
438 |
|
439 | |||
439 | void tst_Domain::setRangeY() |
|
440 | void tst_Domain::setRangeY() | |
440 | { |
|
441 | { | |
441 |
|
|
442 | QFETCH(qreal, min); | |
442 |
|
|
443 | QFETCH(qreal, max); | |
443 |
|
444 | |||
444 |
|
|
445 | Domain domain; | |
445 |
|
446 | |||
446 |
|
|
447 | QSignalSpy spy0(&domain, SIGNAL(domainChanged(qreal, qreal, qreal, qreal))); | |
447 |
|
|
448 | QSignalSpy spy1(&domain, SIGNAL(rangeXChanged(qreal, qreal,int ))); | |
448 |
|
|
449 | QSignalSpy spy2(&domain, SIGNAL(rangeYChanged(qreal, qreal,int ))); | |
449 |
|
450 | |||
450 |
|
|
451 | domain.setRangeY(min, max); | |
451 |
|
452 | |||
452 |
|
|
453 | QList<QVariant> arg0 = spy0.first(); | |
453 | QVERIFY(qFuzzyIsNull(arg0.at(2).toReal() - min)); |
|
454 | QVERIFY(qFuzzyIsNull(arg0.at(2).toReal() - min)); | |
454 | QVERIFY(qFuzzyIsNull(arg0.at(3).toReal() - max)); |
|
455 | QVERIFY(qFuzzyIsNull(arg0.at(3).toReal() - max)); | |
455 |
|
456 | |||
456 |
|
|
457 | QList<QVariant> arg1 = spy2.first(); | |
457 | QVERIFY(qFuzzyIsNull(arg1.at(0).toReal() - min)); |
|
458 | QVERIFY(qFuzzyIsNull(arg1.at(0).toReal() - min)); | |
458 | QVERIFY(qFuzzyIsNull(arg1.at(1).toReal() - max)); |
|
459 | QVERIFY(qFuzzyIsNull(arg1.at(1).toReal() - max)); | |
459 |
|
460 | |||
460 |
|
|
461 | QCOMPARE(spy0.count(), 1); | |
461 |
|
|
462 | QCOMPARE(spy1.count(), 0); | |
462 |
|
|
463 | QCOMPARE(spy2.count(), 1); | |
463 | } |
|
464 | } | |
464 |
|
465 | |||
465 | void tst_Domain::spanX_data() |
|
466 | void tst_Domain::spanX_data() | |
466 | { |
|
467 | { | |
467 |
|
|
468 | QTest::addColumn<qreal>("minX"); | |
468 |
|
|
469 | QTest::addColumn<qreal>("maxX"); | |
469 | QTest::addColumn<qreal>("spanX"); |
|
470 | QTest::addColumn<qreal>("spanX"); | |
470 | QTest::newRow("1 2 1") << 1.0 << 2.0 << 1.0; |
|
471 | QTest::newRow("1 2 1") << 1.0 << 2.0 << 1.0; | |
471 | QTest::newRow("0 2 2") << 1.0 << 2.0 << 1.0; |
|
472 | QTest::newRow("0 2 2") << 1.0 << 2.0 << 1.0; | |
@@ -479,11 +480,11 void tst_Domain::spanX() | |||||
479 |
|
480 | |||
480 | Domain domain; |
|
481 | Domain domain; | |
481 |
|
482 | |||
482 | domain.setRangeX(minX,maxX); |
|
483 | domain.setRangeX(minX, maxX); | |
483 |
|
484 | |||
484 | QSignalSpy spy0(&domain, SIGNAL(domainChanged(qreal, qreal, qreal, qreal))); |
|
485 | QSignalSpy spy0(&domain, SIGNAL(domainChanged(qreal, qreal, qreal, qreal))); | |
485 | QSignalSpy spy1(&domain, SIGNAL(rangeXChanged(qreal, qreal))); |
|
486 | QSignalSpy spy1(&domain, SIGNAL(rangeXChanged(qreal, qreal,int ))); | |
486 | QSignalSpy spy2(&domain, SIGNAL(rangeYChanged(qreal, qreal))); |
|
487 | QSignalSpy spy2(&domain, SIGNAL(rangeYChanged(qreal, qreal,int ))); | |
487 |
|
488 | |||
488 | QCOMPARE(domain.spanX(), spanX); |
|
489 | QCOMPARE(domain.spanX(), spanX); | |
489 |
|
490 | |||
@@ -494,35 +495,34 void tst_Domain::spanX() | |||||
494 |
|
495 | |||
495 | void tst_Domain::spanY_data() |
|
496 | void tst_Domain::spanY_data() | |
496 | { |
|
497 | { | |
497 |
|
|
498 | QTest::addColumn<qreal>("minY"); | |
498 |
|
|
499 | QTest::addColumn<qreal>("maxY"); | |
499 |
|
|
500 | QTest::addColumn<qreal>("spanY"); | |
500 |
|
|
501 | QTest::newRow("1 2 1") << 1.0 << 2.0 << 1.0; | |
501 |
|
|
502 | QTest::newRow("0 2 2") << 1.0 << 2.0 << 1.0; | |
502 | } |
|
503 | } | |
503 |
|
504 | |||
504 | void tst_Domain::spanY() |
|
505 | void tst_Domain::spanY() | |
505 | { |
|
506 | { | |
506 |
|
|
507 | QFETCH(qreal, minY); | |
507 |
|
|
508 | QFETCH(qreal, maxY); | |
508 |
|
|
509 | QFETCH(qreal, spanY); | |
509 |
|
510 | |||
510 |
|
|
511 | Domain domain; | |
511 |
|
512 | |||
512 |
|
|
513 | domain.setRangeY(minY, maxY); | |
513 |
|
514 | |||
514 |
|
|
515 | QSignalSpy spy0(&domain, SIGNAL(domainChanged(qreal, qreal, qreal, qreal))); | |
515 |
|
|
516 | QSignalSpy spy1(&domain, SIGNAL(rangeXChanged(qreal, qreal,int ))); | |
516 |
|
|
517 | QSignalSpy spy2(&domain, SIGNAL(rangeYChanged(qreal, qreal,int ))); | |
517 |
|
518 | |||
518 |
|
|
519 | QCOMPARE(domain.spanY(), spanY); | |
519 |
|
520 | |||
520 |
|
|
521 | QCOMPARE(spy0.count(), 0); | |
521 |
|
|
522 | QCOMPARE(spy1.count(), 0); | |
522 |
|
|
523 | QCOMPARE(spy2.count(), 0); | |
523 | } |
|
524 | } | |
524 |
|
525 | |||
525 |
|
||||
526 | void tst_Domain::zoom_data() |
|
526 | void tst_Domain::zoom_data() | |
527 | { |
|
527 | { | |
528 | QTest::addColumn<QRectF>("rect0"); |
|
528 | QTest::addColumn<QRectF>("rect0"); | |
@@ -531,9 +531,14 void tst_Domain::zoom_data() | |||||
531 | QTest::addColumn<QSizeF>("size1"); |
|
531 | QTest::addColumn<QSizeF>("size1"); | |
532 | QTest::addColumn<QRectF>("rect2"); |
|
532 | QTest::addColumn<QRectF>("rect2"); | |
533 | QTest::addColumn<QSizeF>("size2"); |
|
533 | QTest::addColumn<QSizeF>("size2"); | |
534 | QTest::newRow("first") << QRectF(10,10,100,100) << QSizeF(1000,1000) << QRectF(20,20,100,100) << QSizeF(1000,1000) << QRectF(50,50,100,100) << QSizeF(1000,1000); |
|
534 | QTest::newRow("first") << QRectF(10, 10, 100, 100) << QSizeF(1000, 1000) | |
535 |
|
|
535 | << QRectF(20, 20, 100, 100) << QSizeF(1000, 1000) << QRectF(50, 50, 100, 100) | |
536 | QTest::newRow("third") << QRectF(10,10,10,10) << QSizeF(100,100) << QRectF(20,20,20,20) << QSizeF(100,100) << QRectF(50,50,50,50) << QSizeF(100,100); |
|
536 | << QSizeF(1000, 1000); | |
|
537 | QTest::newRow("scound") << QRectF(10, 10, 50, 50) << QSizeF(1000, 1000) | |||
|
538 | << QRectF(20, 20, 100, 100) << QSizeF(1000, 1000) << QRectF(50, 50, 100, 100) | |||
|
539 | << QSizeF(1000, 1000); | |||
|
540 | QTest::newRow("third") << QRectF(10, 10, 10, 10) << QSizeF(100, 100) << QRectF(20, 20, 20, 20) | |||
|
541 | << QSizeF(100, 100) << QRectF(50, 50, 50, 50) << QSizeF(100, 100); | |||
537 | } |
|
542 | } | |
538 |
|
543 | |||
539 | void tst_Domain::zoom() |
|
544 | void tst_Domain::zoom() | |
@@ -547,33 +552,141 void tst_Domain::zoom() | |||||
547 |
|
552 | |||
548 | Domain domain; |
|
553 | Domain domain; | |
549 |
|
554 | |||
550 | domain.setRange(0,1000,0,1000); |
|
555 | domain.setRange(0, 1000, 0, 1000); | |
551 |
|
556 | |||
552 | QSignalSpy spy0(&domain, SIGNAL(domainChanged(qreal, qreal, qreal, qreal))); |
|
557 | QSignalSpy spy0(&domain, SIGNAL(domainChanged(qreal, qreal, qreal, qreal))); | |
553 | QSignalSpy spy1(&domain, SIGNAL(rangeXChanged(qreal, qreal))); |
|
558 | QSignalSpy spy1(&domain, SIGNAL(rangeXChanged(qreal, qreal,int ))); | |
554 | QSignalSpy spy2(&domain, SIGNAL(rangeYChanged(qreal, qreal))); |
|
559 | QSignalSpy spy2(&domain, SIGNAL(rangeYChanged(qreal, qreal,int ))); | |
555 |
|
560 | |||
556 | Domain domain0; |
|
561 | Domain domain0; | |
557 | domain0.setRange(domain.minX(),domain.maxX(),domain.minY(),domain.maxY()); |
|
562 | domain0.setRange(domain.minX(), domain.maxX(), domain.minY(), domain.maxY()); | |
558 | domain.zoomIn(rect0, size0); |
|
563 | domain.zoomIn(rect0, size0); | |
559 | Domain domain1; |
|
564 | Domain domain1; | |
560 | domain1.setRange(domain.minX(),domain.maxX(),domain.minY(),domain.maxY()); |
|
565 | domain1.setRange(domain.minX(), domain.maxX(), domain.minY(), domain.maxY()); | |
561 | domain.zoomIn(rect1, size1); |
|
566 | domain.zoomIn(rect1, size1); | |
562 | Domain domain2; |
|
567 | Domain domain2; | |
563 | domain2.setRange(domain.minX(),domain.maxX(),domain.minY(),domain.maxY()); |
|
568 | domain2.setRange(domain.minX(), domain.maxX(), domain.minY(), domain.maxY()); | |
564 | domain.zoomIn(rect2, size2); |
|
569 | domain.zoomIn(rect2, size2); | |
565 | domain.zoomOut(rect2, size2); |
|
570 | domain.zoomOut(rect2, size2); | |
566 | QCOMPARE(domain == domain2,true); |
|
571 | QCOMPARE(domain == domain2, true); | |
567 | domain.zoomOut(rect1, size1); |
|
572 | domain.zoomOut(rect1, size1); | |
568 | QCOMPARE(domain == domain1,true); |
|
573 | QCOMPARE(domain == domain1, true); | |
569 | domain.zoomOut(rect0, size0); |
|
574 | domain.zoomOut(rect0, size0); | |
570 | QCOMPARE(domain == domain0,true); |
|
575 | QCOMPARE(domain == domain0, true); | |
571 | QCOMPARE(spy0.count(), 6); |
|
576 | QCOMPARE(spy0.count(), 6); | |
572 | QCOMPARE(spy1.count(), 6); |
|
577 | QCOMPARE(spy1.count(), 6); | |
573 | QCOMPARE(spy2.count(), 6); |
|
578 | QCOMPARE(spy2.count(), 6); | |
574 |
|
579 | |||
575 | } |
|
580 | } | |
576 |
|
581 | |||
|
582 | void tst_Domain::move_data() | |||
|
583 | { | |||
|
584 | QTest::addColumn<int>("dx"); | |||
|
585 | QTest::addColumn<int>("dy"); | |||
|
586 | QTest::addColumn<QSizeF>("size"); | |||
|
587 | QTest::newRow("dx 100, dy 0, size 1000x1000") << 100 << 0 << QSizeF(1000, 1000); | |||
|
588 | QTest::newRow("dx 0, dy 100, size 1000x1000") << 0 << 100 << QSizeF(1000, 1000); | |||
|
589 | QTest::newRow("dx -100, dy 0, size 1000x1000") << -100 << 0 << QSizeF(1000, 1000); | |||
|
590 | QTest::newRow("dx 0, dy -100, size 1000x1000") << 0 << -100 << QSizeF(1000, 1000); | |||
|
591 | QTest::newRow("dx 100, dy 100, size 1000x1000") << 100 << 100 << QSizeF(1000, 1000); | |||
|
592 | QTest::newRow("dx 100, dy 50, size 1000x1000") << 100 << 50 << QSizeF(1000, 1000); | |||
|
593 | } | |||
|
594 | ||||
|
595 | void tst_Domain::move() | |||
|
596 | { | |||
|
597 | QFETCH(int, dx); | |||
|
598 | QFETCH(int, dy); | |||
|
599 | QFETCH(QSizeF, size); | |||
|
600 | Domain domain; | |||
|
601 | ||||
|
602 | domain.setRange(0, size.width(), 0, size.height()); | |||
|
603 | ||||
|
604 | QSignalSpy spy0(&domain, SIGNAL(domainChanged(qreal, qreal, qreal, qreal))); | |||
|
605 | QSignalSpy spy1(&domain, SIGNAL(rangeXChanged(qreal, qreal,int ))); | |||
|
606 | QSignalSpy spy2(&domain, SIGNAL(rangeYChanged(qreal, qreal,int ))); | |||
|
607 | ||||
|
608 | domain.move(dx, dy, size); | |||
|
609 | ||||
|
610 | Domain result; | |||
|
611 | result.setRange(dx, size.width() + dx, dy, size.height() + dy); | |||
|
612 | ||||
|
613 | QCOMPARE(domain == result, true); | |||
|
614 | QCOMPARE(spy0.count(), 1); | |||
|
615 | QCOMPARE(spy1.count(), dx!=0?1:0); | |||
|
616 | QCOMPARE(spy2.count(), dy!=0?1:0); | |||
|
617 | } | |||
|
618 | ||||
|
619 | void tst_Domain::handleAxisXChanged_data() | |||
|
620 | { | |||
|
621 | QTest::addColumn<qreal>("min"); | |||
|
622 | QTest::addColumn<qreal>("max"); | |||
|
623 | QTest::addColumn<int>("tickCount"); | |||
|
624 | QTest::addColumn<bool>("niceNumbers"); | |||
|
625 | QTest::addColumn<qreal>("resultMin"); | |||
|
626 | QTest::addColumn<qreal>("resultMax"); | |||
|
627 | QTest::addColumn<int>("resultTickCount"); | |||
|
628 | QTest::newRow("0,100,5,false") << 0.0 << 100.0 << 5 << false << 0.0 << 100.0 << 5; | |||
|
629 | QTest::newRow("0,100,5,true") << 0.0 << 100.0 << 5 << true << 0.0 << 100.0 << 6; | |||
|
630 | QTest::newRow("0.1,99,5,true") << 0.1 << 99.0 << 5 << true << 0.0 << 100.0 << 6; | |||
|
631 | QTest::newRow("5,93.5,true") << 5.0 << 93.5 << 5 << true << 0.0 << 100.0 << 6; | |||
|
632 | } | |||
|
633 | ||||
|
634 | void tst_Domain::handleAxisXChanged() | |||
|
635 | { | |||
|
636 | QFETCH(qreal, min); | |||
|
637 | QFETCH(qreal, max); | |||
|
638 | QFETCH(int, tickCount); | |||
|
639 | QFETCH(bool, niceNumbers); | |||
|
640 | QFETCH(qreal, resultMin); | |||
|
641 | QFETCH(qreal, resultMax); | |||
|
642 | QFETCH(int, resultTickCount); | |||
|
643 | ||||
|
644 | Domain domain; | |||
|
645 | QSignalSpy spy0(&domain, SIGNAL(domainChanged(qreal, qreal, qreal, qreal))); | |||
|
646 | QSignalSpy spy1(&domain, SIGNAL(rangeXChanged(qreal, qreal,int ))); | |||
|
647 | QSignalSpy spy2(&domain, SIGNAL(rangeYChanged(qreal, qreal,int ))); | |||
|
648 | ||||
|
649 | domain.handleAxisXChanged(min, max, tickCount, niceNumbers); | |||
|
650 | ||||
|
651 | QCOMPARE(resultMin, domain.minX()); | |||
|
652 | QCOMPARE(resultMax, domain.maxX()); | |||
|
653 | QCOMPARE(resultTickCount, domain.tickXCount()); | |||
|
654 | QCOMPARE(spy0.count(), 1); | |||
|
655 | QCOMPARE(spy1.count(), 1); | |||
|
656 | QCOMPARE(spy2.count(), 0); | |||
|
657 | ||||
|
658 | } | |||
|
659 | ||||
|
660 | void tst_Domain::handleAxisYChanged_data() | |||
|
661 | { | |||
|
662 | handleAxisXChanged_data(); | |||
|
663 | } | |||
|
664 | ||||
|
665 | void tst_Domain::handleAxisYChanged() | |||
|
666 | { | |||
|
667 | QFETCH(qreal, min); | |||
|
668 | QFETCH(qreal, max); | |||
|
669 | QFETCH(int, tickCount); | |||
|
670 | QFETCH(bool, niceNumbers); | |||
|
671 | QFETCH(qreal, resultMin); | |||
|
672 | QFETCH(qreal, resultMax); | |||
|
673 | QFETCH(int, resultTickCount); | |||
|
674 | ||||
|
675 | Domain domain; | |||
|
676 | QSignalSpy spy0(&domain, SIGNAL(domainChanged(qreal, qreal, qreal, qreal))); | |||
|
677 | QSignalSpy spy1(&domain, SIGNAL(rangeXChanged(qreal, qreal,int ))); | |||
|
678 | QSignalSpy spy2(&domain, SIGNAL(rangeYChanged(qreal, qreal,int ))); | |||
|
679 | ||||
|
680 | domain.handleAxisYChanged(min, max, tickCount, niceNumbers); | |||
|
681 | ||||
|
682 | QCOMPARE(resultMin, domain.minY()); | |||
|
683 | QCOMPARE(resultMax, domain.maxY()); | |||
|
684 | QCOMPARE(resultTickCount, domain.tickYCount()); | |||
|
685 | QCOMPARE(spy0.count(), 1); | |||
|
686 | QCOMPARE(spy1.count(), 0); | |||
|
687 | QCOMPARE(spy2.count(), 1); | |||
|
688 | } | |||
|
689 | ||||
577 | QTEST_MAIN(tst_Domain) |
|
690 | QTEST_MAIN(tst_Domain) | |
578 | #include "tst_domain.moc" |
|
691 | #include "tst_domain.moc" | |
579 |
|
692 |
General Comments 0
You need to be logged in to leave comments.
Login now