##// END OF EJS Templates
Adds niceNmber test case to tst_domain
Michal Klocek -
r773:621cf63ac719
parent child
Show More
@@ -1,579 +1,692
1 #include <QtTest/QtTest>
1 #include <QtTest/QtTest>
2 #include <private/domain_p.h>
2 #include <private/domain_p.h>
3 #include <qchartaxis.h>
3 #include <qchartaxis.h>
4
4
5 QTCOMMERCIALCHART_USE_NAMESPACE
5 QTCOMMERCIALCHART_USE_NAMESPACE
6
6
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 : public QObject
10 class tst_Domain: public QObject
11 {
11 {
12 Q_OBJECT
12 Q_OBJECT
13
13
14 public slots:
14 public slots:
15 void initTestCase();
15 void initTestCase();
16 void cleanupTestCase();
16 void cleanupTestCase();
17 void init();
17 void init();
18 void cleanup();
18 void cleanup();
19
19
20 private slots:
20 private slots:
21 void domain();
21 void domain();
22 void handleAxisRangeXChanged_data();
22 void handleAxisRangeXChanged_data();
23 void handleAxisRangeXChanged();
23 void handleAxisRangeXChanged();
24 void handleAxisRangeYChanged_data();
24 void handleAxisRangeYChanged_data();
25 void handleAxisRangeYChanged();
25 void handleAxisRangeYChanged();
26 void isEmpty_data();
26 void isEmpty_data();
27 void isEmpty();
27 void isEmpty();
28 void maxX_data();
28 void maxX_data();
29 void maxX();
29 void maxX();
30 void maxY_data();
30 void maxY_data();
31 void maxY();
31 void maxY();
32 void minX_data();
32 void minX_data();
33 void minX();
33 void minX();
34 void minY_data();
34 void minY_data();
35 void minY();
35 void minY();
36 void operatorEquals_data();
36 void operatorEquals_data();
37 void operatorEquals();
37 void operatorEquals();
38 void setRange_data();
38 void setRange_data();
39 void setRange();
39 void setRange();
40 void setRangeX_data();
40 void setRangeX_data();
41 void setRangeX();
41 void setRangeX();
42 void setRangeY_data();
42 void setRangeY_data();
43 void setRangeY();
43 void setRangeY();
44 void spanX_data();
44 void spanX_data();
45 void spanX();
45 void spanX();
46 void spanY_data();
46 void spanY_data();
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()
53 {
59 {
54 }
60 }
55
61
56 void tst_Domain::cleanupTestCase()
62 void tst_Domain::cleanupTestCase()
57 {
63 {
58 }
64 }
59
65
60 void tst_Domain::init()
66 void tst_Domain::init()
61 {
67 {
62 }
68 }
63
69
64 void tst_Domain::cleanup()
70 void tst_Domain::cleanup()
65 {
71 {
66 }
72 }
67
73
68 void tst_Domain::domain()
74 void tst_Domain::domain()
69 {
75 {
70 Domain domain;
76 Domain domain;
71
77
72 QCOMPARE(domain.isEmpty(), true);
78 QCOMPARE(domain.isEmpty(), true);
73 QCOMPARE(domain.maxX(), 0.0);
79 QCOMPARE(domain.maxX(), 0.0);
74 QCOMPARE(domain.maxY(), 0.0);
80 QCOMPARE(domain.maxY(), 0.0);
75 QCOMPARE(domain.minX(), 0.0);
81 QCOMPARE(domain.minX(), 0.0);
76 QCOMPARE(domain.minY(), 0.0);
82 QCOMPARE(domain.minY(), 0.0);
77 }
83 }
78
84
79 void tst_Domain::handleAxisRangeXChanged_data()
85 void tst_Domain::handleAxisRangeXChanged_data()
80 {
86 {
81 QTest::addColumn<qreal>("min");
87 QTest::addColumn<qreal>("min");
82 QTest::addColumn<qreal>("max");
88 QTest::addColumn<qreal>("max");
83 QTest::newRow("-1 1") << -1.0 << 1.0;
89 QTest::newRow("-1 1") << -1.0 << 1.0;
84 QTest::newRow("0 1") << 0.0 << 1.0;
90 QTest::newRow("0 1") << 0.0 << 1.0;
85 QTest::newRow("-1 0") << -1.0 << 0.0;
91 QTest::newRow("-1 0") << -1.0 << 0.0;
86 }
92 }
87
93
88 void tst_Domain::handleAxisRangeXChanged()
94 void tst_Domain::handleAxisRangeXChanged()
89 {
95 {
90 QFETCH(qreal, min);
96 QFETCH(qreal, min);
91 QFETCH(qreal, max);
97 QFETCH(qreal, max);
92
98
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
101 QList<QVariant> arg0 = spy0.first();
107 QList<QVariant> arg0 = spy0.first();
102 QVERIFY(qFuzzyIsNull(arg0.at(0).toReal() - min));
108 QVERIFY(qFuzzyIsNull(arg0.at(0).toReal() - min));
103 QVERIFY(qFuzzyIsNull(arg0.at(1).toReal() - max));
109 QVERIFY(qFuzzyIsNull(arg0.at(1).toReal() - max));
104
110
105 QList<QVariant> arg1 = spy1.first();
111 QList<QVariant> arg1 = spy1.first();
106 QVERIFY(qFuzzyIsNull(arg1.at(0).toReal() - min));
112 QVERIFY(qFuzzyIsNull(arg1.at(0).toReal() - min));
107 QVERIFY(qFuzzyIsNull(arg1.at(1).toReal() - max));
113 QVERIFY(qFuzzyIsNull(arg1.at(1).toReal() - max));
108
114
109 QCOMPARE(spy0.count(), 1);
115 QCOMPARE(spy0.count(), 1);
110 QCOMPARE(spy1.count(), 1);
116 QCOMPARE(spy1.count(), 1);
111 QCOMPARE(spy2.count(), 0);
117 QCOMPARE(spy2.count(), 0);
112
118
113 }
119 }
114
120
115 void tst_Domain::handleAxisRangeYChanged_data()
121 void tst_Domain::handleAxisRangeYChanged_data()
116 {
122 {
117 QTest::addColumn<qreal>("min");
123 QTest::addColumn<qreal>("min");
118 QTest::addColumn<qreal>("max");
124 QTest::addColumn<qreal>("max");
119 QTest::newRow("-1 1") << -1.0 << 1.0;
125 QTest::newRow("-1 1") << -1.0 << 1.0;
120 QTest::newRow("0 1") << 0.0 << 1.0;
126 QTest::newRow("0 1") << 0.0 << 1.0;
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);
128 QFETCH(qreal, max);
133 QFETCH(qreal, max);
129
134
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));
140 QVERIFY(qFuzzyIsNull(arg0.at(3).toReal() - max));
145 QVERIFY(qFuzzyIsNull(arg0.at(3).toReal() - max));
141
146
142 QList<QVariant> arg1 = spy2.first();
147 QList<QVariant> arg1 = spy2.first();
143 QVERIFY(qFuzzyIsNull(arg1.at(0).toReal() - min));
148 QVERIFY(qFuzzyIsNull(arg1.at(0).toReal() - min));
144 QVERIFY(qFuzzyIsNull(arg1.at(1).toReal() - max));
149 QVERIFY(qFuzzyIsNull(arg1.at(1).toReal() - max));
145
150
146 QCOMPARE(spy0.count(), 1);
151 QCOMPARE(spy0.count(), 1);
147 QCOMPARE(spy1.count(), 0);
152 QCOMPARE(spy1.count(), 0);
148 QCOMPARE(spy2.count(), 1);
153 QCOMPARE(spy2.count(), 1);
149 }
154 }
150
155
151 void tst_Domain::isEmpty_data()
156 void tst_Domain::isEmpty_data()
152 {
157 {
153 QTest::addColumn<qreal>("minX");
158 QTest::addColumn<qreal>("minX");
154 QTest::addColumn<qreal>("maxX");
159 QTest::addColumn<qreal>("maxX");
155 QTest::addColumn<qreal>("minY");
160 QTest::addColumn<qreal>("minY");
156 QTest::addColumn<qreal>("maxY");
161 QTest::addColumn<qreal>("maxY");
157 QTest::addColumn<bool>("isEmpty");
162 QTest::addColumn<bool>("isEmpty");
158 QTest::newRow("0 0 0 0") << 0.0 << 0.0 << 0.0 << 0.0 << true;
163 QTest::newRow("0 0 0 0") << 0.0 << 0.0 << 0.0 << 0.0 << true;
159 QTest::newRow("0 1 0 0") << 0.0 << 1.0 << 0.0 << 0.0 << true;
164 QTest::newRow("0 1 0 0") << 0.0 << 1.0 << 0.0 << 0.0 << true;
160 QTest::newRow("0 0 0 1") << 0.0 << 1.0 << 0.0 << 0.0 << true;
165 QTest::newRow("0 0 0 1") << 0.0 << 1.0 << 0.0 << 0.0 << true;
161 QTest::newRow("0 1 0 1") << 0.0 << 1.0 << 0.0 << 1.0 << false;
166 QTest::newRow("0 1 0 1") << 0.0 << 1.0 << 0.0 << 1.0 << false;
162 }
167 }
163
168
164 void tst_Domain::isEmpty()
169 void tst_Domain::isEmpty()
165 {
170 {
166 QFETCH(qreal, minX);
171 QFETCH(qreal, minX);
167 QFETCH(qreal, maxX);
172 QFETCH(qreal, maxX);
168 QFETCH(qreal, minY);
173 QFETCH(qreal, minY);
169 QFETCH(qreal, maxY);
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
177 void tst_Domain::maxX_data()
182 void tst_Domain::maxX_data()
178 {
183 {
179 QTest::addColumn<qreal>("maxX1");
184 QTest::addColumn<qreal>("maxX1");
180 QTest::addColumn<qreal>("maxX2");
185 QTest::addColumn<qreal>("maxX2");
181 QTest::addColumn<int>("count");
186 QTest::addColumn<int>("count");
182 QTest::newRow("1") << 0.0 << 1.0 << 1;
187 QTest::newRow("1") << 0.0 << 1.0 << 1;
183 QTest::newRow("1.0") << 1.0 << 1.0 << 1;
188 QTest::newRow("1.0") << 1.0 << 1.0 << 1;
184 QTest::newRow("2.0") << 1.0 << 0.0 << 2;
189 QTest::newRow("2.0") << 1.0 << 0.0 << 2;
185 }
190 }
186
191
187 void tst_Domain::maxX()
192 void tst_Domain::maxX()
188 {
193 {
189 QFETCH(qreal, maxX1);
194 QFETCH(qreal, maxX1);
190 QFETCH(qreal, maxX2);
195 QFETCH(qreal, maxX2);
191 QFETCH(int, count);
196 QFETCH(int, count);
192
197
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);
208
212
209 }
213 }
210
214
211 void tst_Domain::maxY_data()
215 void tst_Domain::maxY_data()
212 {
216 {
213 QTest::addColumn<qreal>("maxY1");
217 QTest::addColumn<qreal>("maxY1");
214 QTest::addColumn<qreal>("maxY2");
218 QTest::addColumn<qreal>("maxY2");
215 QTest::addColumn<int>("count");
219 QTest::addColumn<int>("count");
216 QTest::newRow("1") << 0.0 << 1.0 << 1;
220 QTest::newRow("1") << 0.0 << 1.0 << 1;
217 QTest::newRow("1.0") << 1.0 << 1.0 << 1;
221 QTest::newRow("1.0") << 1.0 << 1.0 << 1;
218 QTest::newRow("2.0") << 1.0 << 0.0 << 2;
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 QFETCH(qreal, maxY1);
227 QFETCH(qreal, maxY1);
225 QFETCH(qreal, maxY2);
228 QFETCH(qreal, maxY2);
226 QFETCH(int, count);
229 QFETCH(int, count);
227
230
228 Domain domain;
231 Domain domain;
229
232
230 QSignalSpy spy0(&domain, SIGNAL(domainChanged(qreal, qreal, qreal, qreal)));
233 QSignalSpy spy0(&domain, SIGNAL(domainChanged(qreal, qreal, qreal, qreal)));
231 QSignalSpy spy1(&domain, SIGNAL(rangeXChanged(qreal, qreal)));
234 QSignalSpy spy1(&domain, SIGNAL(rangeXChanged(qreal, qreal,int )));
232 QSignalSpy spy2(&domain, SIGNAL(rangeYChanged(qreal, qreal)));
235 QSignalSpy spy2(&domain, SIGNAL(rangeYChanged(qreal, qreal,int )));
233
236
234 domain.setMaxY(maxY1);
237 domain.setMaxY(maxY1);
235 QCOMPARE(domain.maxY(), maxY1);
238 QCOMPARE(domain.maxY(), maxY1);
236 domain.setMaxY(maxY2);
239 domain.setMaxY(maxY2);
237 QCOMPARE(domain.maxY(), maxY2);
240 QCOMPARE(domain.maxY(), maxY2);
238
241
239 QCOMPARE(spy0.count(), count);
242 QCOMPARE(spy0.count(), count);
240 QCOMPARE(spy1.count(), 0);
243 QCOMPARE(spy1.count(), 0);
241 QCOMPARE(spy2.count(), count);
244 QCOMPARE(spy2.count(), count);
242 }
245 }
243
246
244 void tst_Domain::minX_data()
247 void tst_Domain::minX_data()
245 {
248 {
246 QTest::addColumn<qreal>("minX1");
249 QTest::addColumn<qreal>("minX1");
247 QTest::addColumn<qreal>("minX2");
250 QTest::addColumn<qreal>("minX2");
248 QTest::addColumn<int>("count");
251 QTest::addColumn<int>("count");
249 QTest::newRow("1") << 0.0 << 1.0 << 1;
252 QTest::newRow("1") << 0.0 << 1.0 << 1;
250 QTest::newRow("1.0") << 1.0 << 1.0 << 1;
253 QTest::newRow("1.0") << 1.0 << 1.0 << 1;
251 QTest::newRow("2.0") << 1.0 << 0.0 << 2;
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 QFETCH(qreal, minX1);
259 QFETCH(qreal, minX1);
258 QFETCH(qreal, minX2);
260 QFETCH(qreal, minX2);
259 QFETCH(int, count);
261 QFETCH(int, count);
260
262
261 Domain domain;
263 Domain domain;
262
264
263 QSignalSpy spy0(&domain, SIGNAL(domainChanged(qreal, qreal, qreal, qreal)));
265 QSignalSpy spy0(&domain, SIGNAL(domainChanged(qreal, qreal, qreal, qreal)));
264 QSignalSpy spy1(&domain, SIGNAL(rangeXChanged(qreal, qreal)));
266 QSignalSpy spy1(&domain, SIGNAL(rangeXChanged(qreal, qreal,int )));
265 QSignalSpy spy2(&domain, SIGNAL(rangeYChanged(qreal, qreal)));
267 QSignalSpy spy2(&domain, SIGNAL(rangeYChanged(qreal, qreal,int )));
266
268
267 domain.setMinX(minX1);
269 domain.setMinX(minX1);
268 QCOMPARE(domain.minX(), minX1);
270 QCOMPARE(domain.minX(), minX1);
269 domain.setMinX(minX2);
271 domain.setMinX(minX2);
270 QCOMPARE(domain.minX(), minX2);
272 QCOMPARE(domain.minX(), minX2);
271
273
272 QCOMPARE(spy0.count(), count);
274 QCOMPARE(spy0.count(), count);
273 QCOMPARE(spy1.count(), count);
275 QCOMPARE(spy1.count(), count);
274 QCOMPARE(spy2.count(), 0);
276 QCOMPARE(spy2.count(), 0);
275 }
277 }
276
278
277 void tst_Domain::minY_data()
279 void tst_Domain::minY_data()
278 {
280 {
279 QTest::addColumn<qreal>("minY1");
281 QTest::addColumn<qreal>("minY1");
280 QTest::addColumn<qreal>("minY2");
282 QTest::addColumn<qreal>("minY2");
281 QTest::addColumn<int>("count");
283 QTest::addColumn<int>("count");
282 QTest::newRow("1") << 0.0 << 1.0 << 1;
284 QTest::newRow("1") << 0.0 << 1.0 << 1;
283 QTest::newRow("1.0") << 1.0 << 1.0 << 1;
285 QTest::newRow("1.0") << 1.0 << 1.0 << 1;
284 QTest::newRow("2.0") << 1.0 << 0.0 << 2;
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 QFETCH(qreal, minY1);
291 QFETCH(qreal, minY1);
290 QFETCH(qreal, minY2);
292 QFETCH(qreal, minY2);
291 QFETCH(int, count);
293 QFETCH(int, count);
292
294
293 Domain domain;
295 Domain domain;
294
296
295 QSignalSpy spy0(&domain, SIGNAL(domainChanged(qreal, qreal, qreal, qreal)));
297 QSignalSpy spy0(&domain, SIGNAL(domainChanged(qreal, qreal, qreal, qreal)));
296 QSignalSpy spy1(&domain, SIGNAL(rangeXChanged(qreal, qreal)));
298 QSignalSpy spy1(&domain, SIGNAL(rangeXChanged(qreal, qreal,int )));
297 QSignalSpy spy2(&domain, SIGNAL(rangeYChanged(qreal, qreal)));
299 QSignalSpy spy2(&domain, SIGNAL(rangeYChanged(qreal, qreal,int )));
298
300
299 domain.setMinY(minY1);
301 domain.setMinY(minY1);
300 QCOMPARE(domain.minY(), minY1);
302 QCOMPARE(domain.minY(), minY1);
301 domain.setMinY(minY2);
303 domain.setMinY(minY2);
302 QCOMPARE(domain.minY(), minY2);
304 QCOMPARE(domain.minY(), minY2);
303
305
304 QCOMPARE(spy0.count(), count);
306 QCOMPARE(spy0.count(), count);
305 QCOMPARE(spy1.count(), 0);
307 QCOMPARE(spy1.count(), 0);
306 QCOMPARE(spy2.count(), count);
308 QCOMPARE(spy2.count(), count);
307 }
309 }
308
310
309 void tst_Domain::operatorEquals_data()
311 void tst_Domain::operatorEquals_data()
310 {
312 {
311
313
312 QTest::addColumn<Domain*>("domain1");
314 QTest::addColumn<Domain*>("domain1");
313 QTest::addColumn<Domain*>("domain2");
315 QTest::addColumn<Domain*>("domain2");
314 QTest::addColumn<bool>("equals");
316 QTest::addColumn<bool>("equals");
315 QTest::addColumn<bool>("notEquals");
317 QTest::addColumn<bool>("notEquals");
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 }
335
337
336 void tst_Domain::operatorEquals()
338 void tst_Domain::operatorEquals()
337 {
339 {
338 QFETCH(Domain*, domain1);
340 QFETCH(Domain*, domain1);
339 QFETCH(Domain*, domain2);
341 QFETCH(Domain*, domain2);
340 QFETCH(bool, equals);
342 QFETCH(bool, equals);
341 QFETCH(bool, notEquals);
343 QFETCH(bool, notEquals);
342
344
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);
351
353
352 QCOMPARE(spy0.count(), 0);
354 QCOMPARE(spy0.count(), 0);
353 QCOMPARE(spy1.count(), 0);
355 QCOMPARE(spy1.count(), 0);
354 QCOMPARE(spy2.count(), 0);
356 QCOMPARE(spy2.count(), 0);
355 }
357 }
356
358
357 void tst_Domain::setRange_data()
359 void tst_Domain::setRange_data()
358 {
360 {
359 QTest::addColumn<qreal>("minX");
361 QTest::addColumn<qreal>("minX");
360 QTest::addColumn<qreal>("maxX");
362 QTest::addColumn<qreal>("maxX");
361 QTest::addColumn<qreal>("minY");
363 QTest::addColumn<qreal>("minY");
362 QTest::addColumn<qreal>("maxY");
364 QTest::addColumn<qreal>("maxY");
363 QTest::newRow("1,2,1,2") << 1.0 << 2.0 << 1.0 << 2.0;
365 QTest::newRow("1,2,1,2") << 1.0 << 2.0 << 1.0 << 2.0;
364 QTest::newRow("1,3,1,3") << 1.0 << 3.0 << 1.0 << 3.0;
366 QTest::newRow("1,3,1,3") << 1.0 << 3.0 << 1.0 << 3.0;
365 QTest::newRow("-1,5,-2,-1") << -1.0 << 5.0 << -2.0 << -1.0;
367 QTest::newRow("-1,5,-2,-1") << -1.0 << 5.0 << -2.0 << -1.0;
366 }
368 }
367
369
368 void tst_Domain::setRange()
370 void tst_Domain::setRange()
369 {
371 {
370 QFETCH(qreal, minX);
372 QFETCH(qreal, minX);
371 QFETCH(qreal, maxX);
373 QFETCH(qreal, maxX);
372 QFETCH(qreal, minY);
374 QFETCH(qreal, minY);
373 QFETCH(qreal, maxY);
375 QFETCH(qreal, maxY);
374
376
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
383 QCOMPARE(domain.minX(), minX);
385 QCOMPARE(domain.minX(), minX);
384 QCOMPARE(domain.maxX(), maxX);
386 QCOMPARE(domain.maxX(), maxX);
385 QCOMPARE(domain.minY(), minY);
387 QCOMPARE(domain.minY(), minY);
386 QCOMPARE(domain.maxY(), maxY);
388 QCOMPARE(domain.maxY(), maxY);
387
389
388 QCOMPARE(spy0.count(), 1);
390 QCOMPARE(spy0.count(), 1);
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 QTest::addColumn<qreal>("min");
398 QTest::addColumn<qreal>("min");
398 QTest::addColumn<qreal>("max");
399 QTest::addColumn<qreal>("max");
399 QTest::newRow("-1 1") << -1.0 << 1.0;
400 QTest::newRow("-1 1") << -1.0 << 1.0;
400 QTest::newRow("0 1") << 0.0 << 1.0;
401 QTest::newRow("0 1") << 0.0 << 1.0;
401 QTest::newRow("-1 0") << -1.0 << 0.0;
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 QFETCH(qreal, min);
407 QFETCH(qreal, min);
407 QFETCH(qreal, max);
408 QFETCH(qreal, max);
408
409
409 Domain domain;
410 Domain domain;
410
411
411 QSignalSpy spy0(&domain, SIGNAL(domainChanged(qreal, qreal, qreal, qreal)));
412 QSignalSpy spy0(&domain, SIGNAL(domainChanged(qreal, qreal, qreal, qreal)));
412 QSignalSpy spy1(&domain, SIGNAL(rangeXChanged(qreal, qreal)));
413 QSignalSpy spy1(&domain, SIGNAL(rangeXChanged(qreal, qreal,int )));
413 QSignalSpy spy2(&domain, SIGNAL(rangeYChanged(qreal, qreal)));
414 QSignalSpy spy2(&domain, SIGNAL(rangeYChanged(qreal, qreal,int )));
414
415
415 domain.setRangeX(min, max);
416 domain.setRangeX(min, max);
416
417
417 QList<QVariant> arg0 = spy0.first();
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 QList<QVariant> arg1 = spy1.first();
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 QCOMPARE(spy0.count(), 1);
426 QCOMPARE(spy0.count(), 1);
426 QCOMPARE(spy1.count(), 1);
427 QCOMPARE(spy1.count(), 1);
427 QCOMPARE(spy2.count(), 0);
428 QCOMPARE(spy2.count(), 0);
428 }
429 }
429
430
430 void tst_Domain::setRangeY_data()
431 void tst_Domain::setRangeY_data()
431 {
432 {
432 QTest::addColumn<qreal>("min");
433 QTest::addColumn<qreal>("min");
433 QTest::addColumn<qreal>("max");
434 QTest::addColumn<qreal>("max");
434 QTest::newRow("-1 1") << -1.0 << 1.0;
435 QTest::newRow("-1 1") << -1.0 << 1.0;
435 QTest::newRow("0 1") << 0.0 << 1.0;
436 QTest::newRow("0 1") << 0.0 << 1.0;
436 QTest::newRow("-1 0") << -1.0 << 0.0;
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 QFETCH(qreal, min);
442 QFETCH(qreal, min);
442 QFETCH(qreal, max);
443 QFETCH(qreal, max);
443
444
444 Domain domain;
445 Domain domain;
445
446
446 QSignalSpy spy0(&domain, SIGNAL(domainChanged(qreal, qreal, qreal, qreal)));
447 QSignalSpy spy0(&domain, SIGNAL(domainChanged(qreal, qreal, qreal, qreal)));
447 QSignalSpy spy1(&domain, SIGNAL(rangeXChanged(qreal, qreal)));
448 QSignalSpy spy1(&domain, SIGNAL(rangeXChanged(qreal, qreal,int )));
448 QSignalSpy spy2(&domain, SIGNAL(rangeYChanged(qreal, qreal)));
449 QSignalSpy spy2(&domain, SIGNAL(rangeYChanged(qreal, qreal,int )));
449
450
450 domain.setRangeY(min, max);
451 domain.setRangeY(min, max);
451
452
452 QList<QVariant> arg0 = spy0.first();
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 QList<QVariant> arg1 = spy2.first();
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 QCOMPARE(spy0.count(), 1);
461 QCOMPARE(spy0.count(), 1);
461 QCOMPARE(spy1.count(), 0);
462 QCOMPARE(spy1.count(), 0);
462 QCOMPARE(spy2.count(), 1);
463 QCOMPARE(spy2.count(), 1);
463 }
464 }
464
465
465 void tst_Domain::spanX_data()
466 void tst_Domain::spanX_data()
466 {
467 {
467 QTest::addColumn<qreal>("minX");
468 QTest::addColumn<qreal>("minX");
468 QTest::addColumn<qreal>("maxX");
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;
472 }
473 }
473
474
474 void tst_Domain::spanX()
475 void tst_Domain::spanX()
475 {
476 {
476 QFETCH(qreal, minX);
477 QFETCH(qreal, minX);
477 QFETCH(qreal, maxX);
478 QFETCH(qreal, maxX);
478 QFETCH(qreal, spanX);
479 QFETCH(qreal, 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
490 QCOMPARE(spy0.count(), 0);
491 QCOMPARE(spy0.count(), 0);
491 QCOMPARE(spy1.count(), 0);
492 QCOMPARE(spy1.count(), 0);
492 QCOMPARE(spy2.count(), 0);
493 QCOMPARE(spy2.count(), 0);
493 }
494 }
494
495
495 void tst_Domain::spanY_data()
496 void tst_Domain::spanY_data()
496 {
497 {
497 QTest::addColumn<qreal>("minY");
498 QTest::addColumn<qreal>("minY");
498 QTest::addColumn<qreal>("maxY");
499 QTest::addColumn<qreal>("maxY");
499 QTest::addColumn<qreal>("spanY");
500 QTest::addColumn<qreal>("spanY");
500 QTest::newRow("1 2 1") << 1.0 << 2.0 << 1.0;
501 QTest::newRow("1 2 1") << 1.0 << 2.0 << 1.0;
501 QTest::newRow("0 2 2") << 1.0 << 2.0 << 1.0;
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 QFETCH(qreal, minY);
507 QFETCH(qreal, minY);
507 QFETCH(qreal, maxY);
508 QFETCH(qreal, maxY);
508 QFETCH(qreal, spanY);
509 QFETCH(qreal, spanY);
509
510
510 Domain domain;
511 Domain domain;
511
512
512 domain.setRangeY(minY,maxY);
513 domain.setRangeY(minY, maxY);
513
514
514 QSignalSpy spy0(&domain, SIGNAL(domainChanged(qreal, qreal, qreal, qreal)));
515 QSignalSpy spy0(&domain, SIGNAL(domainChanged(qreal, qreal, qreal, qreal)));
515 QSignalSpy spy1(&domain, SIGNAL(rangeXChanged(qreal, qreal)));
516 QSignalSpy spy1(&domain, SIGNAL(rangeXChanged(qreal, qreal,int )));
516 QSignalSpy spy2(&domain, SIGNAL(rangeYChanged(qreal, qreal)));
517 QSignalSpy spy2(&domain, SIGNAL(rangeYChanged(qreal, qreal,int )));
517
518
518 QCOMPARE(domain.spanY(), spanY);
519 QCOMPARE(domain.spanY(), spanY);
519
520
520 QCOMPARE(spy0.count(), 0);
521 QCOMPARE(spy0.count(), 0);
521 QCOMPARE(spy1.count(), 0);
522 QCOMPARE(spy1.count(), 0);
522 QCOMPARE(spy2.count(), 0);
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");
529 QTest::addColumn<QSizeF>("size0");
529 QTest::addColumn<QSizeF>("size0");
530 QTest::addColumn<QRectF>("rect1");
530 QTest::addColumn<QRectF>("rect1");
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 QTest::newRow("scound") << QRectF(10,10,50,50) << QSizeF(1000,1000) << QRectF(20,20,100,100) << QSizeF(1000,1000) << QRectF(50,50,100,100) << QSizeF(1000,1000);
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()
540 {
545 {
541 QFETCH(QRectF, rect0);
546 QFETCH(QRectF, rect0);
542 QFETCH(QSizeF, size0);
547 QFETCH(QSizeF, size0);
543 QFETCH(QRectF, rect1);
548 QFETCH(QRectF, rect1);
544 QFETCH(QSizeF, size1);
549 QFETCH(QSizeF, size1);
545 QFETCH(QRectF, rect2);
550 QFETCH(QRectF, rect2);
546 QFETCH(QSizeF, size2);
551 QFETCH(QSizeF, size2);
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