##// END OF EJS Templates
Enabled more tests in qdatetimeaxis
Marek Rosa -
r1737:dac9b6290737
parent child
Show More
@@ -1,332 +1,334
1 1 /****************************************************************************
2 2 **
3 3 ** Copyright (C) 2012 Digia Plc
4 4 ** All rights reserved.
5 5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 6 **
7 7 ** This file is part of the Qt Commercial Charts Add-on.
8 8 **
9 9 ** $QT_BEGIN_LICENSE$
10 10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 11 ** accordance with the Qt Commercial License Agreement provided with the
12 12 ** Software or, alternatively, in accordance with the terms contained in
13 13 ** a written agreement between you and Digia.
14 14 **
15 15 ** If you have questions regarding the use of this file, please use
16 16 ** contact form at http://qt.digia.com
17 17 ** $QT_END_LICENSE$
18 18 **
19 19 ****************************************************************************/
20 20
21 21 #include "qdatetimeaxis.h"
22 22 #include "qdatetimeaxis_p.h"
23 23 #include "chartdatetimeaxisx_p.h"
24 24 #include "chartdatetimeaxisy_p.h"
25 25 #include "domain_p.h"
26 26 #include <cmath>
27 27 #include <QDebug>
28 28
29 29 QTCOMMERCIALCHART_BEGIN_NAMESPACE
30 30 /*!
31 31 \class QDateTimeAxis
32 32 \brief The QDateTimeAxis class is used for manipulating chart's axis.
33 33 \mainclass
34 34
35 Note that any date before 4800 BCE or after about 1.4 million CE may not be accurately stored.
36
35 37 ValuesAxis can be setup to show axis line with tick marks, grid lines and shades.
36 38 Values of axis are drawn to position of ticks
37 39 */
38 40
39 41 /*!
40 42 \qmlclass ValuesAxis QDateTimeAxis
41 43 \brief The ValuesAxis element is used for manipulating chart's axes
42 44
43 45 ValueAxis can be setup to show axis line with tick marks, grid lines and shades.
44 46 Values of axis are drawn to position of ticks
45 47
46 48 To access Axes you can use ChartView API. For example:
47 49 \code
48 50 ChartView {
49 51 ValuesAxis {
50 52 id: xAxis
51 53 min: 0
52 54 max: 10
53 55 }
54 56 // Add a few series...
55 57 }
56 58 \endcode
57 59 */
58 60
59 61 /*!
60 62 \property QDateTimeAxis::min
61 63 Defines the minimum value on the axis.
62 64 When setting this property the max is adjusted if necessary, to ensure that the range remains valid.
63 65 */
64 66 /*!
65 67 \qmlproperty real ValuesAxis::min
66 68 Defines the minimum value on the axis.
67 69 When setting this property the max is adjusted if necessary, to ensure that the range remains valid.
68 70 */
69 71
70 72 /*!
71 73 \property QDateTimeAxis::max
72 74 Defines the maximum value on the axis.
73 75 When setting this property the min is adjusted if necessary, to ensure that the range remains valid.
74 76 */
75 77 /*!
76 78 \qmlproperty real ValuesAxis::max
77 79 Defines the maximum value on the axis.
78 80 When setting this property the min is adjusted if necessary, to ensure that the range remains valid.
79 81 */
80 82
81 83 /*!
82 84 \fn void QDateTimeAxis::minChanged(QDateTime min)
83 85 Axis emits signal when \a min of axis has changed.
84 86 */
85 87 /*!
86 88 \qmlsignal ValuesAxis::onMinChanged(QDateTime min)
87 89 Axis emits signal when \a min of axis has changed.
88 90 */
89 91
90 92 /*!
91 93 \fn void QDateTimeAxis::maxChanged(QDateTime max)
92 94 Axis emits signal when \a max of axis has changed.
93 95 */
94 96 /*!
95 97 \qmlsignal ValuesAxis::onMaxChanged(QDateTime max)
96 98 Axis emits signal when \a max of axis has changed.
97 99 */
98 100
99 101 /*!
100 102 \fn void QDateTimeAxis::rangeChanged(QDateTime min, QDateTime max)
101 103 Axis emits signal when \a min or \a max of axis has changed.
102 104 */
103 105
104 106 /*!
105 107 \property QDateTimeAxis::ticksCount
106 108 The number of tick marks for the axis.
107 109 */
108 110
109 111 /*!
110 112 \qmlproperty int ValuesAxis::ticksCount
111 113 The number of tick marks for the axis.
112 114 */
113 115
114 116 /*!
115 117 Constructs an axis object which is a child of \a parent.
116 118 */
117 119 QDateTimeAxis::QDateTimeAxis(QObject *parent) :
118 120 QAbstractAxis(*new QDateTimeAxisPrivate(this),parent)
119 121 {
120 122
121 123 }
122 124
123 125 /*!
124 126 \internal
125 127 */
126 128 QDateTimeAxis::QDateTimeAxis(QDateTimeAxisPrivate &d,QObject *parent) : QAbstractAxis(d,parent)
127 129 {
128 130
129 131 }
130 132
131 133 /*!
132 134 Destroys the object
133 135 */
134 136 QDateTimeAxis::~QDateTimeAxis()
135 137 {
136 138
137 139 }
138 140
139 141 void QDateTimeAxis::setMin(QDateTime min)
140 142 {
141 143 Q_D(QDateTimeAxis);
142 144 if (min.isValid())
143 145 setRange(min, qMax(d->m_max, min));
144 146 }
145 147
146 148 QDateTime QDateTimeAxis::min() const
147 149 {
148 150 Q_D(const QDateTimeAxis);
149 151 return d->m_min;
150 152 }
151 153
152 154 void QDateTimeAxis::setMax(QDateTime max)
153 155 {
154 156 Q_D(QDateTimeAxis);
155 157 if (max.isValid())
156 158 setRange(qMin(d->m_min, max), max);
157 159 }
158 160
159 161 QDateTime QDateTimeAxis::max() const
160 162 {
161 163 Q_D(const QDateTimeAxis);
162 164 return d->m_max;
163 165 }
164 166
165 167 /*!
166 168 Sets range from \a min to \a max on the axis.
167 169 If min is greater than max then this function returns without making any changes.
168 170 */
169 171 void QDateTimeAxis::setRange(QDateTime min, QDateTime max)
170 172 {
171 173 Q_D(QDateTimeAxis);
172 174 if (!min.isValid() || !max.isValid() || min > max)
173 175 return;
174 176
175 177 bool changed = false;
176 178 if (d->m_min != min) {
177 179 d->m_min = min;
178 180 changed = true;
179 181 emit minChanged(min);
180 182 }
181 183
182 184 if (d->m_max != max) {
183 185 d->m_max = max;
184 186 changed = true;
185 187 emit maxChanged(max);
186 188 }
187 189
188 190 // if(d->m_niceNumbers) d->looseNiceNumbers(d->m_min, d->m_max, d->m_tickCount);
189 191
190 192 if (changed) {
191 193 emit rangeChanged(d->m_min,d->m_max);
192 194 d->emitUpdated();
193 195 }
194 196 }
195 197
196 198 /*!
197 199 Sets \a format string that is used when creating label for the axis out of the QDateTime object.
198 200 Check QDateTime documentation for information on how the string should be defined.
199 201 \sa formatString()
200 202 */
201 203 void QDateTimeAxis::setFormatString(QString format)
202 204 {
203 205 Q_D(QDateTimeAxis);
204 206 d->m_format = format;
205 207 }
206 208
207 209 /*!
208 210 Returns the format string that is used when creating label for the axis out of the QDateTime object.
209 211 Check QDateTime documentation for information on how the string should be defined.
210 212 \sa setFormatString()
211 213 */
212 214 QString QDateTimeAxis::formatString() const
213 215 {
214 216 Q_D(const QDateTimeAxis);
215 217 return d->m_format;
216 218 }
217 219
218 220 /*!
219 221 Sets \a count for ticks on the axis.
220 222 */
221 223 void QDateTimeAxis::setTicksCount(int count)
222 224 {
223 225 Q_D(QDateTimeAxis);
224 226 if (d->m_tickCount != count && count >=2) {
225 227 d->m_tickCount = count;
226 228 d->emitUpdated();
227 229 }
228 230 }
229 231
230 232 /*!
231 233 \fn int QDateTimeAxis::ticksCount() const
232 234 Return number of ticks on the axis
233 235 */
234 236 int QDateTimeAxis::ticksCount() const
235 237 {
236 238 Q_D(const QDateTimeAxis);
237 239 return d->m_tickCount;
238 240 }
239 241
240 242 /*!
241 243 Returns the type of the axis
242 244 */
243 245 QAbstractAxis::AxisType QDateTimeAxis::type() const
244 246 {
245 247 return AxisTypeDateTime;
246 248 }
247 249
248 250 /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
249 251
250 252 QDateTimeAxisPrivate::QDateTimeAxisPrivate(QDateTimeAxis* q):
251 253 QAbstractAxisPrivate(q),
252 254 m_tickCount(5)
253 255 {
254 256 m_min = QDateTime::fromMSecsSinceEpoch(0);
255 257 m_max = QDateTime::fromMSecsSinceEpoch(0);
256 258 m_format = "hh:mm:ss\ndd-mm-yyyy";
257 259 }
258 260
259 261 QDateTimeAxisPrivate::~QDateTimeAxisPrivate()
260 262 {
261 263
262 264 }
263 265
264 266 void QDateTimeAxisPrivate::handleDomainUpdated()
265 267 {
266 268 Q_Q(QDateTimeAxis);
267 269 Domain* domain = qobject_cast<Domain*>(sender());
268 270 Q_ASSERT(domain);
269 271
270 272 if(orientation()==Qt::Horizontal){
271 273 q->setRange(QDateTime::fromMSecsSinceEpoch(domain->minX()), QDateTime::fromMSecsSinceEpoch(domain->maxX()));
272 274 }else if(orientation()==Qt::Vertical){
273 275 q->setRange(QDateTime::fromMSecsSinceEpoch(domain->minY()), QDateTime::fromMSecsSinceEpoch(domain->maxY()));
274 276 }
275 277 }
276 278
277 279
278 280 void QDateTimeAxisPrivate::setMin(const QVariant &min)
279 281 {
280 282 Q_Q(QDateTimeAxis);
281 283 if (min.canConvert(QVariant::DateTime))
282 284 q->setMin(min.toDateTime());
283 285 }
284 286
285 287 void QDateTimeAxisPrivate::setMax(const QVariant &max)
286 288 {
287 289
288 290 Q_Q(QDateTimeAxis);
289 291 if (max.canConvert(QVariant::DateTime))
290 292 q->setMax(max.toDateTime());
291 293 }
292 294
293 295 void QDateTimeAxisPrivate::setRange(const QVariant &min, const QVariant &max)
294 296 {
295 297 Q_Q(QDateTimeAxis);
296 298 if (min.canConvert(QVariant::DateTime) && max.canConvert(QVariant::DateTime))
297 299 q->setRange(min.toDateTime(), max.toDateTime());
298 300 }
299 301
300 302 ChartAxis* QDateTimeAxisPrivate::createGraphics(ChartPresenter* presenter)
301 303 {
302 304 Q_Q(QDateTimeAxis);
303 305 if(m_orientation == Qt::Vertical){
304 306 return new ChartDateTimeAxisY(q,presenter);
305 307 }else{
306 308 return new ChartDateTimeAxisX(q,presenter);
307 309 }
308 310
309 311 }
310 312
311 313 void QDateTimeAxisPrivate::intializeDomain(Domain* domain)
312 314 {
313 315 Q_Q(QDateTimeAxis);
314 316 if(m_max == m_min) {
315 317 if(m_orientation==Qt::Vertical){
316 318 q->setRange(QDateTime::fromMSecsSinceEpoch(domain->minY()), QDateTime::fromMSecsSinceEpoch(domain->maxY()));
317 319 }else{
318 320 q->setRange(QDateTime::fromMSecsSinceEpoch(domain->minX()), QDateTime::fromMSecsSinceEpoch(domain->maxX()));
319 321 }
320 322 } else {
321 323 if(m_orientation==Qt::Vertical){
322 324 domain->setRangeY(m_min.toMSecsSinceEpoch(), m_max.toMSecsSinceEpoch());
323 325 }else{
324 326 domain->setRangeX(m_min.toMSecsSinceEpoch(), m_max.toMSecsSinceEpoch());
325 327 }
326 328 }
327 329 }
328 330
329 331 #include "moc_qdatetimeaxis.cpp"
330 332 #include "moc_qdatetimeaxis_p.cpp"
331 333
332 334 QTCOMMERCIALCHART_END_NAMESPACE
@@ -1,317 +1,313
1 1 /****************************************************************************
2 2 **
3 3 ** Copyright (C) 2012 Digia Plc
4 4 ** All rights reserved.
5 5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 6 **
7 7 ** This file is part of the Qt Commercial Charts Add-on.
8 8 **
9 9 ** $QT_BEGIN_LICENSE$
10 10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 11 ** accordance with the Qt Commercial License Agreement provided with the
12 12 ** Software or, alternatively, in accordance with the terms contained in
13 13 ** a written agreement between you and Digia.
14 14 **
15 15 ** If you have questions regarding the use of this file, please use
16 16 ** contact form at http://qt.digia.com
17 17 ** $QT_END_LICENSE$
18 18 **
19 19 ****************************************************************************/
20 20
21 21 #include "../qabstractaxis/tst_qabstractaxis.h"
22 22 #include <qdatetimeaxis.h>
23 23 #include <qlineseries.h>
24 24
25 25 class tst_QDateTimeAxis : public QObject//: public tst_QAbstractAxis
26 26 {
27 27 Q_OBJECT
28 28
29 29 public slots:
30 30 void initTestCase();
31 31 void cleanupTestCase();
32 32 void init();
33 33 void cleanup();
34 34
35 35 private slots:
36 36 void qdatetimeaxis_data();
37 37 void qdatetimeaxis();
38 38
39 39 void max_raw_data();
40 40 void max_raw();
41 41 void max_data();
42 42 void max();
43 // void max_animation_data();
44 // void max_animation();
43 void max_animation_data();
44 void max_animation();
45 45 void min_raw_data();
46 46 void min_raw();
47 47 void min_data();
48 48 void min();
49 // void min_animation_data();
50 // void min_animation();
49 void min_animation_data();
50 void min_animation();
51 51 void range_raw_data();
52 52 void range_raw();
53 53 void range_data();
54 54 void range();
55 // void range_animation_data();
56 // void range_animation();
55 void range_animation_data();
56 void range_animation();
57 57
58 58 private:
59 59 QDateTimeAxis *m_dateTimeAxisX;
60 60 QDateTimeAxis *m_dateTimeAxisY;
61 61 QLineSeries* m_series;
62 62 QChartView* m_view;
63 63 QChart* m_chart;
64 64 };
65 65
66 66 void tst_QDateTimeAxis::initTestCase()
67 67 {
68 68 }
69 69
70 70 void tst_QDateTimeAxis::cleanupTestCase()
71 71 {
72 72 }
73 73
74 74 void tst_QDateTimeAxis::init()
75 75 {
76 76 m_dateTimeAxisX = new QDateTimeAxis();
77 77 m_dateTimeAxisY = new QDateTimeAxis();
78 78 m_series = new QLineSeries();
79 79 *m_series << QPointF(-100, -100) << QPointF(0, 0) << QPointF(100, 100);
80 80 // tst_QAbstractAxis::init(m_datetimeaxis, m_series);
81 81
82 82 m_view = new QChartView(new QChart());
83 83 m_chart = m_view->chart();
84 84 m_chart->addSeries(m_series);
85 85 m_chart->setAxisY(m_dateTimeAxisY, m_series);
86 86 m_chart->setAxisX(m_dateTimeAxisX, m_series);
87 87 }
88 88
89 89 void tst_QDateTimeAxis::cleanup()
90 90 {
91 91 delete m_series;
92 92 delete m_dateTimeAxisX;
93 93 delete m_dateTimeAxisY;
94 94 m_series = 0;
95 95 m_dateTimeAxisX = 0;
96 96 m_dateTimeAxisY = 0;
97 97 delete m_view;
98 98 m_view = 0;
99 99 m_chart = 0;
100 100 // tst_QAbstractAxis::cleanup();
101 101 }
102 102
103 103 void tst_QDateTimeAxis::qdatetimeaxis_data()
104 104 {
105 105 }
106 106
107 107 void tst_QDateTimeAxis::qdatetimeaxis()
108 108 {
109 109 // qabstractaxis();
110
111 // QVERIFY(m_datetimeaxis->max().toMSecsSinceEpoch() == 0);
112 // QVERIFY(m_datetimeaxis->min().toMSecsSinceEpoch() == 0);
113 110 QCOMPARE(m_dateTimeAxisX->type(), QAbstractAxis::AxisTypeDateTime);
114 111
115 112 m_view->show();
116 113 QTest::qWaitForWindowShown(m_view);
117 114
118 115 QVERIFY(m_dateTimeAxisX->max().toMSecsSinceEpoch() != 0);
119 116 QVERIFY(m_dateTimeAxisX->min().toMSecsSinceEpoch() != 0);
120 117 }
121 118
122 119 void tst_QDateTimeAxis::max_raw_data()
123 120 {
124 121 QTest::addColumn<QDateTime>("max");
125 122 QTest::addColumn<bool>("valid");
126 123 QDateTime dateTime;
127 124 dateTime.setDate(QDate(2012, 7, 19));
128 125 QTest::newRow("19.7.2012 - Valid") << dateTime << true;
129 126 dateTime.setDate(QDate(2012, 17, 32));
130 127 QTest::newRow("32.17.2012 - Invalid") << dateTime << false;
131 128 }
132 129
133 130 void tst_QDateTimeAxis::max_raw()
134 131 {
135 132 QFETCH(QDateTime, max);
136 133 QFETCH(bool, valid);
137 134
138 135 QSignalSpy spy0(m_dateTimeAxisX, SIGNAL(maxChanged(QDateTime)));
139 136 QSignalSpy spy1(m_dateTimeAxisX, SIGNAL(minChanged(QDateTime)));
140 137 QSignalSpy spy2(m_dateTimeAxisX, SIGNAL(rangeChanged(QDateTime, QDateTime)));
141 138
142 139 m_dateTimeAxisX->setMax(max);
143 140
144
145 141 if (valid) {
146 142 QVERIFY2(m_dateTimeAxisX->max() == max, "Not equal");
147 143 QCOMPARE(spy0.count(), 1);
148 144 QCOMPARE(spy1.count(), 0);
149 145 QCOMPARE(spy2.count(), 1);
150 146 } else {
151 147 QVERIFY2(m_dateTimeAxisX->max() != max, "Date is invalid and should not be set");
152 148 QCOMPARE(spy0.count(), 0);
153 149 QCOMPARE(spy1.count(), 0);
154 150 QCOMPARE(spy2.count(), 0);
155 151 }
156 152 }
157 153
158 154 void tst_QDateTimeAxis::max_data()
159 155 {
160 156 max_raw_data();
161 157 }
162 158
163 159 void tst_QDateTimeAxis::max()
164 160 {
165 161 m_chart->setAxisX(m_dateTimeAxisX, m_series);
166 162 m_view->show();
167 163 QTest::qWaitForWindowShown(m_view);
168 164 max_raw();
169 165 }
170 166
171 //void tst_QDateTimeAxis::max_animation_data()
172 //{
173 // max_data();
174 //}
167 void tst_QDateTimeAxis::max_animation_data()
168 {
169 max_data();
170 }
175 171
176 //void tst_QDateTimeAxis::max_animation()
177 //{
178 // m_chart->setAnimationOptions(QChart::GridAxisAnimations);
179 // max();
180 //}
172 void tst_QDateTimeAxis::max_animation()
173 {
174 m_chart->setAnimationOptions(QChart::GridAxisAnimations);
175 max();
176 }
181 177
182 178 void tst_QDateTimeAxis::min_raw_data()
183 179 {
184 180 QTest::addColumn<QDateTime>("min");
185 181 QTest::addColumn<bool>("valid");
186 182 QDateTime dateTime;
187 183 dateTime.setDate(QDate(1908, 1, 11));
188 184 QTest::newRow("11.1.1908 - Valid") << dateTime << true; // negative MSecs from Epoch
189 185 dateTime.setDate(QDate(2012, 17, 32));
190 186 QTest::newRow("32.17.2012 - Invalid") << dateTime << false;
191 187 }
192 188
193 189 void tst_QDateTimeAxis::min_raw()
194 190 {
195 191 QFETCH(QDateTime, min);
196 192 QFETCH(bool, valid);
197 193
198 194 QSignalSpy spy0(m_dateTimeAxisX, SIGNAL(maxChanged(QDateTime)));
199 195 QSignalSpy spy1(m_dateTimeAxisX, SIGNAL(minChanged(QDateTime)));
200 196 QSignalSpy spy2(m_dateTimeAxisX, SIGNAL(rangeChanged(QDateTime, QDateTime)));
201 197
202 198 m_dateTimeAxisX->setMin(min);
203 199
204 200 if (valid) {
205 201 QVERIFY2(m_dateTimeAxisX->min() == min, "Not equal");
206 202 QCOMPARE(spy0.count(), 0);
207 203 QCOMPARE(spy1.count(), 1);
208 204 QCOMPARE(spy2.count(), 1);
209 205 } else {
210 206 QVERIFY2(m_dateTimeAxisX->min() != min, "Date is invalid and should not be set");
211 207 QCOMPARE(spy0.count(), 0);
212 208 QCOMPARE(spy1.count(), 0);
213 209 QCOMPARE(spy2.count(), 0);
214 210 }
215 211 }
216 212
217 213 void tst_QDateTimeAxis::min_data()
218 214 {
219 215 min_raw_data();
220 216 }
221 217
222 218 void tst_QDateTimeAxis::min()
223 219 {
224 220 m_chart->setAxisX(m_dateTimeAxisX, m_series);
225 221 m_view->show();
226 222 QTest::qWaitForWindowShown(m_view);
227 223 min_raw();
228 224 }
229 225
230 //void tst_QDateTimeAxis::min_animation_data()
231 //{
232 // min_data();
233 //}
226 void tst_QDateTimeAxis::min_animation_data()
227 {
228 min_data();
229 }
234 230
235 //void tst_QDateTimeAxis::min_animation()
236 //{
237 // m_chart->setAnimationOptions(QChart::GridAxisAnimations);
238 // min();
239 //}
231 void tst_QDateTimeAxis::min_animation()
232 {
233 m_chart->setAnimationOptions(QChart::GridAxisAnimations);
234 min();
235 }
240 236
241 237 void tst_QDateTimeAxis::range_raw_data()
242 238 {
243 239 QTest::addColumn<QDateTime>("min");
244 240 QTest::addColumn<bool>("minValid");
245 241 QTest::addColumn<QDateTime>("max");
246 242 QTest::addColumn<bool>("maxValid");
247 243
248 244 QDateTime minDateTime;
249 245 QDateTime maxDateTime;
250 246 minDateTime.setDate(QDate(1908, 1, 11));
251 247 maxDateTime.setDate(QDate(1958, 11, 21));
252 248 QTest::newRow("11.1.1908 - min valid, 21.12.1958 - max valid") << minDateTime << true << maxDateTime << true; // negative MSecs from Epoch, min < max
253 249
254 250 minDateTime.setDate(QDate(2012, 17, 32));
255 251 QTest::newRow("32.17.2012 - min invalid, 21.12.1958 - max valid") << minDateTime << false << maxDateTime << true;
256 252
257 253 maxDateTime.setDate(QDate(2017, 0, 1));
258 254 QTest::newRow("32.17.2012 - min invalid, 1.0.2017 - max invalid") << minDateTime << false << maxDateTime << false;
259 255
260 256 minDateTime.setDate(QDate(2012, 1, 1));
261 257 QTest::newRow("1.1.2012 - min valid, 1.0.2017 - max invalid") << minDateTime << true << maxDateTime << false;
262 258
263 259 maxDateTime.setDate(QDate(2005, 2, 5));
264 260 QTest::newRow("1.1.2012 - min valid, 5.2.2005 - max valid") << minDateTime << true << maxDateTime << true; // min > max
265 261 }
266 262
267 263 void tst_QDateTimeAxis::range_raw()
268 264 {
269 265 QFETCH(QDateTime, min);
270 266 QFETCH(bool, minValid);
271 267 QFETCH(QDateTime, max);
272 268 QFETCH(bool, maxValid);
273 269
274 270 QSignalSpy spy0(m_dateTimeAxisX, SIGNAL(maxChanged(QDateTime)));
275 271 QSignalSpy spy1(m_dateTimeAxisX, SIGNAL(minChanged(QDateTime)));
276 272 QSignalSpy spy2(m_dateTimeAxisX, SIGNAL(rangeChanged(QDateTime, QDateTime)));
277 273
278 274 m_dateTimeAxisX->setRange(min, max);
279 275
280 276 if (minValid && maxValid && min < max) {
281 277 QCOMPARE(spy0.count(), 1);
282 278 QCOMPARE(spy1.count(), 1);
283 279 QCOMPARE(spy2.count(), 1);
284 280 } else {
285 281 QCOMPARE(spy0.count(), 0);
286 282 QCOMPARE(spy1.count(), 0);
287 283 QCOMPARE(spy2.count(), 0);
288 284 }
289 285 }
290 286
291 287 void tst_QDateTimeAxis::range_data()
292 288 {
293 289 range_raw_data();
294 290 }
295 291
296 292 void tst_QDateTimeAxis::range()
297 293 {
298 294 m_chart->setAxisX(m_dateTimeAxisX, m_series);
299 295 m_view->show();
300 296 QTest::qWaitForWindowShown(m_view);
301 297 range_raw();
302 298 }
303 299
304 //void tst_QDateTimeAxis::range_animation_data()
305 //{
306 // range_data();
307 //}
300 void tst_QDateTimeAxis::range_animation_data()
301 {
302 range_data();
303 }
308 304
309 //void tst_QDateTimeAxis::range_animation()
310 //{
311 // m_chart->setAnimationOptions(QChart::GridAxisAnimations);
312 // range();
313 //}
305 void tst_QDateTimeAxis::range_animation()
306 {
307 m_chart->setAnimationOptions(QChart::GridAxisAnimations);
308 range();
309 }
314 310
315 311 QTEST_MAIN(tst_QDateTimeAxis)
316 312 #include "tst_qdatetimeaxis.moc"
317 313
General Comments 0
You need to be logged in to leave comments. Login now