@@ -1,571 +1,570 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2012 Digia Plc |
|
3 | ** Copyright (C) 2012 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | #include <QtTest/QtTest> |
|
21 | #include <QtTest/QtTest> | |
22 | #include <qhorizontalbarseries.h> |
|
22 | #include <qhorizontalbarseries.h> | |
23 | #include <qbarset.h> |
|
23 | #include <qbarset.h> | |
24 | #include <qchartview.h> |
|
24 | #include <qchartview.h> | |
25 | #include <qchart.h> |
|
25 | #include <qchart.h> | |
26 | #include "tst_definitions.h" |
|
26 | #include "tst_definitions.h" | |
27 |
|
27 | |||
28 | QTCOMMERCIALCHART_USE_NAMESPACE |
|
28 | QTCOMMERCIALCHART_USE_NAMESPACE | |
29 |
|
29 | |||
30 | Q_DECLARE_METATYPE(QBarSet*) |
|
30 | Q_DECLARE_METATYPE(QBarSet*) | |
31 |
|
31 | |||
32 | class tst_QHorizontalBarSeries : public QObject |
|
32 | class tst_QHorizontalBarSeries : public QObject | |
33 | { |
|
33 | { | |
34 | Q_OBJECT |
|
34 | Q_OBJECT | |
35 |
|
35 | |||
36 | public slots: |
|
36 | public slots: | |
37 | void initTestCase(); |
|
37 | void initTestCase(); | |
38 | void cleanupTestCase(); |
|
38 | void cleanupTestCase(); | |
39 | void init(); |
|
39 | void init(); | |
40 | void cleanup(); |
|
40 | void cleanup(); | |
41 |
|
41 | |||
42 | private slots: |
|
42 | private slots: | |
43 | void qhorizontalbarseries_data(); |
|
43 | void qhorizontalbarseries_data(); | |
44 | void qhorizontalbarseries(); |
|
44 | void qhorizontalbarseries(); | |
45 | void type_data(); |
|
45 | void type_data(); | |
46 | void type(); |
|
46 | void type(); | |
47 | void append_data(); |
|
47 | void append_data(); | |
48 | void append(); |
|
48 | void append(); | |
49 | void remove_data(); |
|
49 | void remove_data(); | |
50 | void remove(); |
|
50 | void remove(); | |
51 | void appendList_data(); |
|
51 | void appendList_data(); | |
52 | void appendList(); |
|
52 | void appendList(); | |
53 | void count_data(); |
|
53 | void count_data(); | |
54 | void count(); |
|
54 | void count(); | |
55 | void barSets_data(); |
|
55 | void barSets_data(); | |
56 | void barSets(); |
|
56 | void barSets(); | |
57 | void setLabelsVisible_data(); |
|
57 | void setLabelsVisible_data(); | |
58 | void setLabelsVisible(); |
|
58 | void setLabelsVisible(); | |
59 | void mouseclicked_data(); |
|
59 | void mouseclicked_data(); | |
60 | void mouseclicked(); |
|
60 | void mouseclicked(); | |
61 | void mousehovered_data(); |
|
61 | void mousehovered_data(); | |
62 | void mousehovered(); |
|
62 | void mousehovered(); | |
63 | void clearWithAnimations(); |
|
63 | void clearWithAnimations(); | |
64 |
|
64 | |||
65 | private: |
|
65 | private: | |
66 | QHorizontalBarSeries* m_barseries; |
|
66 | QHorizontalBarSeries* m_barseries; | |
67 | QHorizontalBarSeries* m_barseries_with_sets; |
|
67 | QHorizontalBarSeries* m_barseries_with_sets; | |
68 |
|
68 | |||
69 | QList<QBarSet*> m_testSets; |
|
69 | QList<QBarSet*> m_testSets; | |
70 |
|
70 | |||
71 | }; |
|
71 | }; | |
72 |
|
72 | |||
73 | void tst_QHorizontalBarSeries::initTestCase() |
|
73 | void tst_QHorizontalBarSeries::initTestCase() | |
74 | { |
|
74 | { | |
75 | qRegisterMetaType<QBarSet*>("QBarSet*"); |
|
75 | qRegisterMetaType<QBarSet*>("QBarSet*"); | |
76 | } |
|
76 | } | |
77 |
|
77 | |||
78 | void tst_QHorizontalBarSeries::cleanupTestCase() |
|
78 | void tst_QHorizontalBarSeries::cleanupTestCase() | |
79 | { |
|
79 | { | |
80 | } |
|
80 | } | |
81 |
|
81 | |||
82 | void tst_QHorizontalBarSeries::init() |
|
82 | void tst_QHorizontalBarSeries::init() | |
83 | { |
|
83 | { | |
84 | m_barseries = new QHorizontalBarSeries(); |
|
84 | m_barseries = new QHorizontalBarSeries(); | |
85 | m_barseries_with_sets = new QHorizontalBarSeries(); |
|
85 | m_barseries_with_sets = new QHorizontalBarSeries(); | |
86 |
|
86 | |||
87 | for (int i=0; i<5; i++) { |
|
87 | for (int i=0; i<5; i++) { | |
88 | m_testSets.append(new QBarSet("testset")); |
|
88 | m_testSets.append(new QBarSet("testset")); | |
89 | m_barseries_with_sets->append(m_testSets.at(i)); |
|
89 | m_barseries_with_sets->append(m_testSets.at(i)); | |
90 | } |
|
90 | } | |
91 | } |
|
91 | } | |
92 |
|
92 | |||
93 | void tst_QHorizontalBarSeries::cleanup() |
|
93 | void tst_QHorizontalBarSeries::cleanup() | |
94 | { |
|
94 | { | |
95 | foreach(QBarSet* s, m_testSets) { |
|
95 | foreach(QBarSet* s, m_testSets) { | |
96 | m_barseries_with_sets->remove(s); |
|
96 | m_barseries_with_sets->remove(s); | |
97 | delete s; |
|
|||
98 | } |
|
97 | } | |
99 | m_testSets.clear(); |
|
98 | m_testSets.clear(); | |
100 |
|
99 | |||
101 | delete m_barseries; |
|
100 | delete m_barseries; | |
102 | m_barseries = 0; |
|
101 | m_barseries = 0; | |
103 | delete m_barseries_with_sets; |
|
102 | delete m_barseries_with_sets; | |
104 | m_barseries_with_sets = 0; |
|
103 | m_barseries_with_sets = 0; | |
105 | } |
|
104 | } | |
106 |
|
105 | |||
107 | void tst_QHorizontalBarSeries::qhorizontalbarseries_data() |
|
106 | void tst_QHorizontalBarSeries::qhorizontalbarseries_data() | |
108 | { |
|
107 | { | |
109 | } |
|
108 | } | |
110 |
|
109 | |||
111 | void tst_QHorizontalBarSeries::qhorizontalbarseries() |
|
110 | void tst_QHorizontalBarSeries::qhorizontalbarseries() | |
112 | { |
|
111 | { | |
113 | QHorizontalBarSeries *barseries = new QHorizontalBarSeries(); |
|
112 | QHorizontalBarSeries *barseries = new QHorizontalBarSeries(); | |
114 | QVERIFY(barseries != 0); |
|
113 | QVERIFY(barseries != 0); | |
115 | } |
|
114 | } | |
116 |
|
115 | |||
117 | void tst_QHorizontalBarSeries::type_data() |
|
116 | void tst_QHorizontalBarSeries::type_data() | |
118 | { |
|
117 | { | |
119 |
|
118 | |||
120 | } |
|
119 | } | |
121 |
|
120 | |||
122 | void tst_QHorizontalBarSeries::type() |
|
121 | void tst_QHorizontalBarSeries::type() | |
123 | { |
|
122 | { | |
124 | QVERIFY(m_barseries->type() == QAbstractSeries::SeriesTypeHorizontalBar); |
|
123 | QVERIFY(m_barseries->type() == QAbstractSeries::SeriesTypeHorizontalBar); | |
125 | } |
|
124 | } | |
126 |
|
125 | |||
127 | void tst_QHorizontalBarSeries::append_data() |
|
126 | void tst_QHorizontalBarSeries::append_data() | |
128 | { |
|
127 | { | |
129 | } |
|
128 | } | |
130 |
|
129 | |||
131 | void tst_QHorizontalBarSeries::append() |
|
130 | void tst_QHorizontalBarSeries::append() | |
132 | { |
|
131 | { | |
133 | QVERIFY(m_barseries->count() == 0); |
|
132 | QVERIFY(m_barseries->count() == 0); | |
134 |
|
133 | |||
135 | bool ret = false; |
|
134 | bool ret = false; | |
136 |
|
135 | |||
137 | // Try adding barset |
|
136 | // Try adding barset | |
138 | QBarSet *barset = new QBarSet("testset"); |
|
137 | QBarSet *barset = new QBarSet("testset"); | |
139 | ret = m_barseries->append(barset); |
|
138 | ret = m_barseries->append(barset); | |
140 |
|
139 | |||
141 | QVERIFY(ret == true); |
|
140 | QVERIFY(ret == true); | |
142 | QVERIFY(m_barseries->count() == 1); |
|
141 | QVERIFY(m_barseries->count() == 1); | |
143 |
|
142 | |||
144 | // Try adding another set |
|
143 | // Try adding another set | |
145 | QBarSet *barset2 = new QBarSet("testset2"); |
|
144 | QBarSet *barset2 = new QBarSet("testset2"); | |
146 | ret = m_barseries->append(barset2); |
|
145 | ret = m_barseries->append(barset2); | |
147 |
|
146 | |||
148 | QVERIFY(ret == true); |
|
147 | QVERIFY(ret == true); | |
149 | QVERIFY(m_barseries->count() == 2); |
|
148 | QVERIFY(m_barseries->count() == 2); | |
150 |
|
149 | |||
151 | // Try adding same set again |
|
150 | // Try adding same set again | |
152 | ret = m_barseries->append(barset2); |
|
151 | ret = m_barseries->append(barset2); | |
153 | QVERIFY(ret == false); |
|
152 | QVERIFY(ret == false); | |
154 | QVERIFY(m_barseries->count() == 2); |
|
153 | QVERIFY(m_barseries->count() == 2); | |
155 |
|
154 | |||
156 | // Try adding null set |
|
155 | // Try adding null set | |
157 | ret = m_barseries->append(0); |
|
156 | ret = m_barseries->append(0); | |
158 | QVERIFY(ret == false); |
|
157 | QVERIFY(ret == false); | |
159 | QVERIFY(m_barseries->count() == 2); |
|
158 | QVERIFY(m_barseries->count() == 2); | |
160 |
|
159 | |||
161 | } |
|
160 | } | |
162 |
|
161 | |||
163 | void tst_QHorizontalBarSeries::remove_data() |
|
162 | void tst_QHorizontalBarSeries::remove_data() | |
164 | { |
|
163 | { | |
165 | } |
|
164 | } | |
166 |
|
165 | |||
167 | void tst_QHorizontalBarSeries::remove() |
|
166 | void tst_QHorizontalBarSeries::remove() | |
168 | { |
|
167 | { | |
169 | int count = m_testSets.count(); |
|
168 | int count = m_testSets.count(); | |
170 | QVERIFY(m_barseries_with_sets->count() == count); |
|
169 | QVERIFY(m_barseries_with_sets->count() == count); | |
171 |
|
170 | |||
172 | // Try to remove null pointer (should not remove, should not crash) |
|
171 | // Try to remove null pointer (should not remove, should not crash) | |
173 | bool ret = false; |
|
172 | bool ret = false; | |
174 | ret = m_barseries_with_sets->remove(0); |
|
173 | ret = m_barseries_with_sets->remove(0); | |
175 | QVERIFY(ret == false); |
|
174 | QVERIFY(ret == false); | |
176 | QVERIFY(m_barseries_with_sets->count() == count); |
|
175 | QVERIFY(m_barseries_with_sets->count() == count); | |
177 |
|
176 | |||
178 | // Try to remove invalid pointer (should not remove, should not crash) |
|
177 | // Try to remove invalid pointer (should not remove, should not crash) | |
179 | ret = m_barseries_with_sets->remove((QBarSet*) (m_testSets.at(0) + 1) ); |
|
178 | ret = m_barseries_with_sets->remove((QBarSet*) (m_testSets.at(0) + 1) ); | |
180 | QVERIFY(ret == false); |
|
179 | QVERIFY(ret == false); | |
181 | QVERIFY(m_barseries_with_sets->count() == count); |
|
180 | QVERIFY(m_barseries_with_sets->count() == count); | |
182 |
|
181 | |||
183 | // remove some sets |
|
182 | // remove some sets | |
184 | ret = m_barseries_with_sets->remove(m_testSets.at(2)); |
|
183 | ret = m_barseries_with_sets->remove(m_testSets.at(2)); | |
185 | QVERIFY(ret == true); |
|
184 | QVERIFY(ret == true); | |
186 | ret = m_barseries_with_sets->remove(m_testSets.at(3)); |
|
185 | ret = m_barseries_with_sets->remove(m_testSets.at(3)); | |
187 | QVERIFY(ret == true); |
|
186 | QVERIFY(ret == true); | |
188 | ret = m_barseries_with_sets->remove(m_testSets.at(4)); |
|
187 | ret = m_barseries_with_sets->remove(m_testSets.at(4)); | |
189 | QVERIFY(ret == true); |
|
188 | QVERIFY(ret == true); | |
190 |
|
189 | |||
191 | QVERIFY(m_barseries_with_sets->count() == 2); |
|
190 | QVERIFY(m_barseries_with_sets->count() == 2); | |
192 |
|
191 | |||
193 | QList<QBarSet*> verifysets = m_barseries_with_sets->barSets(); |
|
192 | QList<QBarSet*> verifysets = m_barseries_with_sets->barSets(); | |
194 |
|
193 | |||
195 | QVERIFY(verifysets.at(0) == m_testSets.at(0)); |
|
194 | QVERIFY(verifysets.at(0) == m_testSets.at(0)); | |
196 | QVERIFY(verifysets.at(1) == m_testSets.at(1)); |
|
195 | QVERIFY(verifysets.at(1) == m_testSets.at(1)); | |
197 |
|
196 | |||
198 | // Try removing all sets again (should be ok, even if some sets have already been removed) |
|
197 | // Try removing all sets again (should be ok, even if some sets have already been removed) | |
199 | ret = false; |
|
198 | ret = false; | |
200 | for (int i=0; i<count; i++) { |
|
199 | for (int i=0; i<count; i++) { | |
201 | ret |= m_barseries_with_sets->remove(m_testSets.at(i)); |
|
200 | ret |= m_barseries_with_sets->remove(m_testSets.at(i)); | |
202 | } |
|
201 | } | |
203 |
|
202 | |||
204 | QVERIFY(ret == true); |
|
203 | QVERIFY(ret == true); | |
205 | QVERIFY(m_barseries_with_sets->count() == 0); |
|
204 | QVERIFY(m_barseries_with_sets->count() == 0); | |
206 | } |
|
205 | } | |
207 |
|
206 | |||
208 | void tst_QHorizontalBarSeries::appendList_data() |
|
207 | void tst_QHorizontalBarSeries::appendList_data() | |
209 | { |
|
208 | { | |
210 |
|
209 | |||
211 | } |
|
210 | } | |
212 |
|
211 | |||
213 | void tst_QHorizontalBarSeries::appendList() |
|
212 | void tst_QHorizontalBarSeries::appendList() | |
214 | { |
|
213 | { | |
215 | int count = 5; |
|
214 | int count = 5; | |
216 | QVERIFY(m_barseries->count() == 0); |
|
215 | QVERIFY(m_barseries->count() == 0); | |
217 |
|
216 | |||
218 | QList<QBarSet*> sets; |
|
217 | QList<QBarSet*> sets; | |
219 | for (int i=0; i<count; i++) { |
|
218 | for (int i=0; i<count; i++) { | |
220 | sets.append(new QBarSet("testset")); |
|
219 | sets.append(new QBarSet("testset")); | |
221 | } |
|
220 | } | |
222 |
|
221 | |||
223 | // Append new sets (should succeed, count should match the count of sets) |
|
222 | // Append new sets (should succeed, count should match the count of sets) | |
224 | bool ret = false; |
|
223 | bool ret = false; | |
225 | ret = m_barseries->append(sets); |
|
224 | ret = m_barseries->append(sets); | |
226 | QVERIFY(ret == true); |
|
225 | QVERIFY(ret == true); | |
227 | QVERIFY(m_barseries->count() == count); |
|
226 | QVERIFY(m_barseries->count() == count); | |
228 |
|
227 | |||
229 | // Append same sets again (should fail, count should remain same) |
|
228 | // Append same sets again (should fail, count should remain same) | |
230 | ret = m_barseries->append(sets); |
|
229 | ret = m_barseries->append(sets); | |
231 | QVERIFY(ret == false); |
|
230 | QVERIFY(ret == false); | |
232 | QVERIFY(m_barseries->count() == count); |
|
231 | QVERIFY(m_barseries->count() == count); | |
233 |
|
232 | |||
234 | // Try append empty list (should succeed, but count should remain same) |
|
233 | // Try append empty list (should succeed, but count should remain same) | |
235 | QList<QBarSet*> invalidList; |
|
234 | QList<QBarSet*> invalidList; | |
236 | ret = m_barseries->append(invalidList); |
|
235 | ret = m_barseries->append(invalidList); | |
237 | QVERIFY(ret == true); |
|
236 | QVERIFY(ret == true); | |
238 | QVERIFY(m_barseries->count() == count); |
|
237 | QVERIFY(m_barseries->count() == count); | |
239 |
|
238 | |||
240 | // Try append list with one new and one existing set (should fail, count remains same) |
|
239 | // Try append list with one new and one existing set (should fail, count remains same) | |
241 | invalidList.append(new QBarSet("ok set")); |
|
240 | invalidList.append(new QBarSet("ok set")); | |
242 | invalidList.append(sets.at(0)); |
|
241 | invalidList.append(sets.at(0)); | |
243 | ret = m_barseries->append(invalidList); |
|
242 | ret = m_barseries->append(invalidList); | |
244 | QVERIFY(ret == false); |
|
243 | QVERIFY(ret == false); | |
245 | QVERIFY(m_barseries->count() == count); |
|
244 | QVERIFY(m_barseries->count() == count); | |
246 |
|
245 | |||
247 | // Try append list with null pointers (should fail, count remains same) |
|
246 | // Try append list with null pointers (should fail, count remains same) | |
248 | QList<QBarSet*> invalidList2; |
|
247 | QList<QBarSet*> invalidList2; | |
249 | invalidList2.append(0); |
|
248 | invalidList2.append(0); | |
250 | invalidList2.append(0); |
|
249 | invalidList2.append(0); | |
251 | invalidList2.append(0); |
|
250 | invalidList2.append(0); | |
252 | ret = m_barseries->append(invalidList2); |
|
251 | ret = m_barseries->append(invalidList2); | |
253 | QVERIFY(ret == false); |
|
252 | QVERIFY(ret == false); | |
254 | QVERIFY(m_barseries->count() == count); |
|
253 | QVERIFY(m_barseries->count() == count); | |
255 | } |
|
254 | } | |
256 |
|
255 | |||
257 | void tst_QHorizontalBarSeries::count_data() |
|
256 | void tst_QHorizontalBarSeries::count_data() | |
258 | { |
|
257 | { | |
259 |
|
258 | |||
260 | } |
|
259 | } | |
261 |
|
260 | |||
262 | void tst_QHorizontalBarSeries::count() |
|
261 | void tst_QHorizontalBarSeries::count() | |
263 | { |
|
262 | { | |
264 | QVERIFY(m_barseries->count() == 0); |
|
263 | QVERIFY(m_barseries->count() == 0); | |
265 | QVERIFY(m_barseries_with_sets->count() == m_testSets.count()); |
|
264 | QVERIFY(m_barseries_with_sets->count() == m_testSets.count()); | |
266 | } |
|
265 | } | |
267 |
|
266 | |||
268 | void tst_QHorizontalBarSeries::barSets_data() |
|
267 | void tst_QHorizontalBarSeries::barSets_data() | |
269 | { |
|
268 | { | |
270 |
|
269 | |||
271 | } |
|
270 | } | |
272 |
|
271 | |||
273 | void tst_QHorizontalBarSeries::barSets() |
|
272 | void tst_QHorizontalBarSeries::barSets() | |
274 | { |
|
273 | { | |
275 | QVERIFY(m_barseries->barSets().count() == 0); |
|
274 | QVERIFY(m_barseries->barSets().count() == 0); | |
276 |
|
275 | |||
277 | QList<QBarSet*> sets = m_barseries_with_sets->barSets(); |
|
276 | QList<QBarSet*> sets = m_barseries_with_sets->barSets(); | |
278 | QVERIFY(sets.count() == m_testSets.count()); |
|
277 | QVERIFY(sets.count() == m_testSets.count()); | |
279 |
|
278 | |||
280 | for (int i=0; i<m_testSets.count(); i++) { |
|
279 | for (int i=0; i<m_testSets.count(); i++) { | |
281 | QVERIFY(sets.at(i) == m_testSets.at(i)); |
|
280 | QVERIFY(sets.at(i) == m_testSets.at(i)); | |
282 | } |
|
281 | } | |
283 | } |
|
282 | } | |
284 |
|
283 | |||
285 | void tst_QHorizontalBarSeries::setLabelsVisible_data() |
|
284 | void tst_QHorizontalBarSeries::setLabelsVisible_data() | |
286 | { |
|
285 | { | |
287 |
|
286 | |||
288 | } |
|
287 | } | |
289 |
|
288 | |||
290 | void tst_QHorizontalBarSeries::setLabelsVisible() |
|
289 | void tst_QHorizontalBarSeries::setLabelsVisible() | |
291 | { |
|
290 | { | |
292 | // labels should be invisible by default |
|
291 | // labels should be invisible by default | |
293 | QVERIFY(m_barseries->isLabelsVisible() == false); |
|
292 | QVERIFY(m_barseries->isLabelsVisible() == false); | |
294 | QVERIFY(m_barseries_with_sets->isLabelsVisible() == false); |
|
293 | QVERIFY(m_barseries_with_sets->isLabelsVisible() == false); | |
295 |
|
294 | |||
296 | // turn labels to visible |
|
295 | // turn labels to visible | |
297 | m_barseries_with_sets->setLabelsVisible(true); |
|
296 | m_barseries_with_sets->setLabelsVisible(true); | |
298 | // TODO: test the signal |
|
297 | // TODO: test the signal | |
299 | QVERIFY(m_barseries_with_sets->isLabelsVisible() == true); |
|
298 | QVERIFY(m_barseries_with_sets->isLabelsVisible() == true); | |
300 |
|
299 | |||
301 | // turn labels to invisible |
|
300 | // turn labels to invisible | |
302 | m_barseries_with_sets->setLabelsVisible(false); |
|
301 | m_barseries_with_sets->setLabelsVisible(false); | |
303 | // TODO: test the signal |
|
302 | // TODO: test the signal | |
304 | QVERIFY(m_barseries_with_sets->isLabelsVisible() == false); |
|
303 | QVERIFY(m_barseries_with_sets->isLabelsVisible() == false); | |
305 |
|
304 | |||
306 | // without parameter, should turn labels to visible |
|
305 | // without parameter, should turn labels to visible | |
307 | m_barseries_with_sets->setLabelsVisible(); |
|
306 | m_barseries_with_sets->setLabelsVisible(); | |
308 | // TODO: test the signal |
|
307 | // TODO: test the signal | |
309 | QVERIFY(m_barseries_with_sets->isLabelsVisible() == true); |
|
308 | QVERIFY(m_barseries_with_sets->isLabelsVisible() == true); | |
310 | } |
|
309 | } | |
311 |
|
310 | |||
312 | void tst_QHorizontalBarSeries::mouseclicked_data() |
|
311 | void tst_QHorizontalBarSeries::mouseclicked_data() | |
313 | { |
|
312 | { | |
314 |
|
313 | |||
315 | } |
|
314 | } | |
316 |
|
315 | |||
317 | void tst_QHorizontalBarSeries::mouseclicked() |
|
316 | void tst_QHorizontalBarSeries::mouseclicked() | |
318 | { |
|
317 | { | |
319 | QHorizontalBarSeries* series = new QHorizontalBarSeries(); |
|
318 | QHorizontalBarSeries* series = new QHorizontalBarSeries(); | |
320 |
|
319 | |||
321 | QBarSet* set1 = new QBarSet(QString("set 1")); |
|
320 | QBarSet* set1 = new QBarSet(QString("set 1")); | |
322 | *set1 << 10 << 10 << 10; |
|
321 | *set1 << 10 << 10 << 10; | |
323 | series->append(set1); |
|
322 | series->append(set1); | |
324 |
|
323 | |||
325 | QBarSet* set2 = new QBarSet(QString("set 2")); |
|
324 | QBarSet* set2 = new QBarSet(QString("set 2")); | |
326 | *set2 << 10 << 10 << 10; |
|
325 | *set2 << 10 << 10 << 10; | |
327 | series->append(set2); |
|
326 | series->append(set2); | |
328 |
|
327 | |||
329 | QSignalSpy seriesSpy(series,SIGNAL(clicked(int,QBarSet*))); |
|
328 | QSignalSpy seriesSpy(series,SIGNAL(clicked(int,QBarSet*))); | |
330 | QSignalSpy setSpy1(set1, SIGNAL(clicked(int))); |
|
329 | QSignalSpy setSpy1(set1, SIGNAL(clicked(int))); | |
331 | QSignalSpy setSpy2(set2, SIGNAL(clicked(int))); |
|
330 | QSignalSpy setSpy2(set2, SIGNAL(clicked(int))); | |
332 |
|
331 | |||
333 | QChartView view(new QChart()); |
|
332 | QChartView view(new QChart()); | |
334 | view.resize(400,300); |
|
333 | view.resize(400,300); | |
335 | view.chart()->addSeries(series); |
|
334 | view.chart()->addSeries(series); | |
336 | view.show(); |
|
335 | view.show(); | |
337 | QTest::qWaitForWindowShown(&view); |
|
336 | QTest::qWaitForWindowShown(&view); | |
338 |
|
337 | |||
339 | //==================================================================================== |
|
338 | //==================================================================================== | |
340 | // barset 1, bar 0 |
|
339 | // barset 1, bar 0 | |
341 | QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(200,218)); |
|
340 | QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(200,218)); | |
342 | QCoreApplication::processEvents(QEventLoop::AllEvents, 1000); |
|
341 | QCoreApplication::processEvents(QEventLoop::AllEvents, 1000); | |
343 |
|
342 | |||
344 | QCOMPARE(seriesSpy.count(), 1); |
|
343 | QCOMPARE(seriesSpy.count(), 1); | |
345 | QCOMPARE(setSpy1.count(), 1); |
|
344 | QCOMPARE(setSpy1.count(), 1); | |
346 | QCOMPARE(setSpy2.count(), 0); |
|
345 | QCOMPARE(setSpy2.count(), 0); | |
347 |
|
346 | |||
348 | QList<QVariant> seriesSpyArg = seriesSpy.takeFirst(); |
|
347 | QList<QVariant> seriesSpyArg = seriesSpy.takeFirst(); | |
349 | QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(1)), set1); |
|
348 | QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(1)), set1); | |
350 | QVERIFY(seriesSpyArg.at(0).type() == QVariant::Int); |
|
349 | QVERIFY(seriesSpyArg.at(0).type() == QVariant::Int); | |
351 | QVERIFY(seriesSpyArg.at(0).toInt() == 0); |
|
350 | QVERIFY(seriesSpyArg.at(0).toInt() == 0); | |
352 |
|
351 | |||
353 | QList<QVariant> setSpyArg = setSpy1.takeFirst(); |
|
352 | QList<QVariant> setSpyArg = setSpy1.takeFirst(); | |
354 | QVERIFY(setSpyArg.at(0).type() == QVariant::Int); |
|
353 | QVERIFY(setSpyArg.at(0).type() == QVariant::Int); | |
355 | QVERIFY(setSpyArg.at(0).toInt() == 0); |
|
354 | QVERIFY(setSpyArg.at(0).toInt() == 0); | |
356 |
|
355 | |||
357 | //==================================================================================== |
|
356 | //==================================================================================== | |
358 | // barset 1, bar 1 |
|
357 | // barset 1, bar 1 | |
359 | QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(200,161)); |
|
358 | QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(200,161)); | |
360 | QCoreApplication::processEvents(QEventLoop::AllEvents, 1000); |
|
359 | QCoreApplication::processEvents(QEventLoop::AllEvents, 1000); | |
361 |
|
360 | |||
362 | QCOMPARE(seriesSpy.count(), 1); |
|
361 | QCOMPARE(seriesSpy.count(), 1); | |
363 | QCOMPARE(setSpy1.count(), 1); |
|
362 | QCOMPARE(setSpy1.count(), 1); | |
364 | QCOMPARE(setSpy2.count(), 0); |
|
363 | QCOMPARE(setSpy2.count(), 0); | |
365 |
|
364 | |||
366 | seriesSpyArg = seriesSpy.takeFirst(); |
|
365 | seriesSpyArg = seriesSpy.takeFirst(); | |
367 | QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(1)), set1); |
|
366 | QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(1)), set1); | |
368 | QVERIFY(seriesSpyArg.at(0).type() == QVariant::Int); |
|
367 | QVERIFY(seriesSpyArg.at(0).type() == QVariant::Int); | |
369 | QVERIFY(seriesSpyArg.at(0).toInt() == 1); |
|
368 | QVERIFY(seriesSpyArg.at(0).toInt() == 1); | |
370 |
|
369 | |||
371 | setSpyArg = setSpy1.takeFirst(); |
|
370 | setSpyArg = setSpy1.takeFirst(); | |
372 | QVERIFY(setSpyArg.at(0).type() == QVariant::Int); |
|
371 | QVERIFY(setSpyArg.at(0).type() == QVariant::Int); | |
373 | QVERIFY(setSpyArg.at(0).toInt() == 1); |
|
372 | QVERIFY(setSpyArg.at(0).toInt() == 1); | |
374 |
|
373 | |||
375 | //==================================================================================== |
|
374 | //==================================================================================== | |
376 | // barset 1, bar 2 |
|
375 | // barset 1, bar 2 | |
377 | QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(200,104)); |
|
376 | QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(200,104)); | |
378 | QCoreApplication::processEvents(QEventLoop::AllEvents, 1000); |
|
377 | QCoreApplication::processEvents(QEventLoop::AllEvents, 1000); | |
379 |
|
378 | |||
380 | QCOMPARE(seriesSpy.count(), 1); |
|
379 | QCOMPARE(seriesSpy.count(), 1); | |
381 | QCOMPARE(setSpy1.count(), 1); |
|
380 | QCOMPARE(setSpy1.count(), 1); | |
382 | QCOMPARE(setSpy2.count(), 0); |
|
381 | QCOMPARE(setSpy2.count(), 0); | |
383 |
|
382 | |||
384 | seriesSpyArg = seriesSpy.takeFirst(); |
|
383 | seriesSpyArg = seriesSpy.takeFirst(); | |
385 | QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(1)), set1); |
|
384 | QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(1)), set1); | |
386 | QVERIFY(seriesSpyArg.at(0).type() == QVariant::Int); |
|
385 | QVERIFY(seriesSpyArg.at(0).type() == QVariant::Int); | |
387 | QVERIFY(seriesSpyArg.at(0).toInt() == 2); |
|
386 | QVERIFY(seriesSpyArg.at(0).toInt() == 2); | |
388 |
|
387 | |||
389 | setSpyArg = setSpy1.takeFirst(); |
|
388 | setSpyArg = setSpy1.takeFirst(); | |
390 | QVERIFY(setSpyArg.at(0).type() == QVariant::Int); |
|
389 | QVERIFY(setSpyArg.at(0).type() == QVariant::Int); | |
391 | QVERIFY(setSpyArg.at(0).toInt() == 2); |
|
390 | QVERIFY(setSpyArg.at(0).toInt() == 2); | |
392 |
|
391 | |||
393 | //==================================================================================== |
|
392 | //==================================================================================== | |
394 | // barset 2, bar 0 |
|
393 | // barset 2, bar 0 | |
395 | QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(200,203)); |
|
394 | QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(200,203)); | |
396 | QCoreApplication::processEvents(QEventLoop::AllEvents, 1000); |
|
395 | QCoreApplication::processEvents(QEventLoop::AllEvents, 1000); | |
397 |
|
396 | |||
398 | QCOMPARE(seriesSpy.count(), 1); |
|
397 | QCOMPARE(seriesSpy.count(), 1); | |
399 | QCOMPARE(setSpy1.count(), 0); |
|
398 | QCOMPARE(setSpy1.count(), 0); | |
400 | QCOMPARE(setSpy2.count(), 1); |
|
399 | QCOMPARE(setSpy2.count(), 1); | |
401 |
|
400 | |||
402 | seriesSpyArg = seriesSpy.takeFirst(); |
|
401 | seriesSpyArg = seriesSpy.takeFirst(); | |
403 | QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(1)), set2); |
|
402 | QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(1)), set2); | |
404 | QVERIFY(seriesSpyArg.at(0).type() == QVariant::Int); |
|
403 | QVERIFY(seriesSpyArg.at(0).type() == QVariant::Int); | |
405 | QVERIFY(seriesSpyArg.at(0).toInt() == 0); |
|
404 | QVERIFY(seriesSpyArg.at(0).toInt() == 0); | |
406 |
|
405 | |||
407 | setSpyArg = setSpy2.takeFirst(); |
|
406 | setSpyArg = setSpy2.takeFirst(); | |
408 | QVERIFY(setSpyArg.at(0).type() == QVariant::Int); |
|
407 | QVERIFY(setSpyArg.at(0).type() == QVariant::Int); | |
409 | QVERIFY(setSpyArg.at(0).toInt() == 0); |
|
408 | QVERIFY(setSpyArg.at(0).toInt() == 0); | |
410 |
|
409 | |||
411 | //==================================================================================== |
|
410 | //==================================================================================== | |
412 | // barset 2, bar 1 |
|
411 | // barset 2, bar 1 | |
413 | QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(200,146)); |
|
412 | QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(200,146)); | |
414 | QCoreApplication::processEvents(QEventLoop::AllEvents, 1000); |
|
413 | QCoreApplication::processEvents(QEventLoop::AllEvents, 1000); | |
415 |
|
414 | |||
416 | QCOMPARE(seriesSpy.count(), 1); |
|
415 | QCOMPARE(seriesSpy.count(), 1); | |
417 | QCOMPARE(setSpy1.count(), 0); |
|
416 | QCOMPARE(setSpy1.count(), 0); | |
418 | QCOMPARE(setSpy2.count(), 1); |
|
417 | QCOMPARE(setSpy2.count(), 1); | |
419 |
|
418 | |||
420 | seriesSpyArg = seriesSpy.takeFirst(); |
|
419 | seriesSpyArg = seriesSpy.takeFirst(); | |
421 | QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(1)), set2); |
|
420 | QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(1)), set2); | |
422 | QVERIFY(seriesSpyArg.at(0).type() == QVariant::Int); |
|
421 | QVERIFY(seriesSpyArg.at(0).type() == QVariant::Int); | |
423 | QVERIFY(seriesSpyArg.at(0).toInt() == 1); |
|
422 | QVERIFY(seriesSpyArg.at(0).toInt() == 1); | |
424 |
|
423 | |||
425 | setSpyArg = setSpy2.takeFirst(); |
|
424 | setSpyArg = setSpy2.takeFirst(); | |
426 | QVERIFY(setSpyArg.at(0).type() == QVariant::Int); |
|
425 | QVERIFY(setSpyArg.at(0).type() == QVariant::Int); | |
427 | QVERIFY(setSpyArg.at(0).toInt() == 1); |
|
426 | QVERIFY(setSpyArg.at(0).toInt() == 1); | |
428 |
|
427 | |||
429 | //==================================================================================== |
|
428 | //==================================================================================== | |
430 | // barset 2, bar 2 |
|
429 | // barset 2, bar 2 | |
431 | QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(200,89)); |
|
430 | QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(200,89)); | |
432 | QCoreApplication::processEvents(QEventLoop::AllEvents, 1000); |
|
431 | QCoreApplication::processEvents(QEventLoop::AllEvents, 1000); | |
433 |
|
432 | |||
434 | QCOMPARE(seriesSpy.count(), 1); |
|
433 | QCOMPARE(seriesSpy.count(), 1); | |
435 | QCOMPARE(setSpy1.count(), 0); |
|
434 | QCOMPARE(setSpy1.count(), 0); | |
436 | QCOMPARE(setSpy2.count(), 1); |
|
435 | QCOMPARE(setSpy2.count(), 1); | |
437 |
|
436 | |||
438 | seriesSpyArg = seriesSpy.takeFirst(); |
|
437 | seriesSpyArg = seriesSpy.takeFirst(); | |
439 | QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(1)), set2); |
|
438 | QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(1)), set2); | |
440 | QVERIFY(seriesSpyArg.at(0).type() == QVariant::Int); |
|
439 | QVERIFY(seriesSpyArg.at(0).type() == QVariant::Int); | |
441 | QVERIFY(seriesSpyArg.at(0).toInt() == 2); |
|
440 | QVERIFY(seriesSpyArg.at(0).toInt() == 2); | |
442 |
|
441 | |||
443 | setSpyArg = setSpy2.takeFirst(); |
|
442 | setSpyArg = setSpy2.takeFirst(); | |
444 | QVERIFY(setSpyArg.at(0).type() == QVariant::Int); |
|
443 | QVERIFY(setSpyArg.at(0).type() == QVariant::Int); | |
445 | QVERIFY(setSpyArg.at(0).toInt() == 2); |
|
444 | QVERIFY(setSpyArg.at(0).toInt() == 2); | |
446 | } |
|
445 | } | |
447 |
|
446 | |||
448 | void tst_QHorizontalBarSeries::mousehovered_data() |
|
447 | void tst_QHorizontalBarSeries::mousehovered_data() | |
449 | { |
|
448 | { | |
450 |
|
449 | |||
451 | } |
|
450 | } | |
452 |
|
451 | |||
453 | void tst_QHorizontalBarSeries::mousehovered() |
|
452 | void tst_QHorizontalBarSeries::mousehovered() | |
454 | { |
|
453 | { | |
455 | QHorizontalBarSeries* series = new QHorizontalBarSeries(); |
|
454 | QHorizontalBarSeries* series = new QHorizontalBarSeries(); | |
456 |
|
455 | |||
457 | QBarSet* set1 = new QBarSet(QString("set 1")); |
|
456 | QBarSet* set1 = new QBarSet(QString("set 1")); | |
458 | *set1 << 10 << 10 << 10; |
|
457 | *set1 << 10 << 10 << 10; | |
459 | series->append(set1); |
|
458 | series->append(set1); | |
460 |
|
459 | |||
461 | QBarSet* set2 = new QBarSet(QString("set 2")); |
|
460 | QBarSet* set2 = new QBarSet(QString("set 2")); | |
462 | *set2 << 10 << 10 << 10; |
|
461 | *set2 << 10 << 10 << 10; | |
463 | series->append(set2); |
|
462 | series->append(set2); | |
464 |
|
463 | |||
465 | QSignalSpy seriesSpy(series,SIGNAL(hovered(bool,QBarSet*))); |
|
464 | QSignalSpy seriesSpy(series,SIGNAL(hovered(bool,QBarSet*))); | |
466 | QSignalSpy setSpy1(set1, SIGNAL(hovered(bool))); |
|
465 | QSignalSpy setSpy1(set1, SIGNAL(hovered(bool))); | |
467 | QSignalSpy setSpy2(set2, SIGNAL(hovered(bool))); |
|
466 | QSignalSpy setSpy2(set2, SIGNAL(hovered(bool))); | |
468 |
|
467 | |||
469 | QChartView view(new QChart()); |
|
468 | QChartView view(new QChart()); | |
470 | view.resize(400,300); |
|
469 | view.resize(400,300); | |
471 | view.chart()->addSeries(series); |
|
470 | view.chart()->addSeries(series); | |
472 | view.show(); |
|
471 | view.show(); | |
473 | QTest::qWaitForWindowShown(&view); |
|
472 | QTest::qWaitForWindowShown(&view); | |
474 |
|
473 | |||
475 | //this is hack since view does not get events otherwise |
|
474 | //this is hack since view does not get events otherwise | |
476 | view.setMouseTracking(true); |
|
475 | view.setMouseTracking(true); | |
477 |
|
476 | |||
478 | //======================================================================= |
|
477 | //======================================================================= | |
479 | // move mouse to bottom border |
|
478 | // move mouse to bottom border | |
480 | QTest::mouseMove(view.viewport(), QPoint(200, 300)); |
|
479 | QTest::mouseMove(view.viewport(), QPoint(200, 300)); | |
481 | QCoreApplication::processEvents(QEventLoop::AllEvents, 10000); |
|
480 | QCoreApplication::processEvents(QEventLoop::AllEvents, 10000); | |
482 | TRY_COMPARE(seriesSpy.count(), 0); |
|
481 | TRY_COMPARE(seriesSpy.count(), 0); | |
483 | TRY_COMPARE(setSpy1.count(), 0); |
|
482 | TRY_COMPARE(setSpy1.count(), 0); | |
484 | TRY_COMPARE(setSpy2.count(), 0); |
|
483 | TRY_COMPARE(setSpy2.count(), 0); | |
485 |
|
484 | |||
486 | //======================================================================= |
|
485 | //======================================================================= | |
487 | // move mouse on top of set1 |
|
486 | // move mouse on top of set1 | |
488 | QTest::mouseMove(view.viewport(), QPoint(200,218)); |
|
487 | QTest::mouseMove(view.viewport(), QPoint(200,218)); | |
489 | TRY_COMPARE(seriesSpy.count(), 1); |
|
488 | TRY_COMPARE(seriesSpy.count(), 1); | |
490 | TRY_COMPARE(setSpy1.count(), 1); |
|
489 | TRY_COMPARE(setSpy1.count(), 1); | |
491 | TRY_COMPARE(setSpy2.count(), 0); |
|
490 | TRY_COMPARE(setSpy2.count(), 0); | |
492 |
|
491 | |||
493 | QList<QVariant> seriesSpyArg = seriesSpy.takeFirst(); |
|
492 | QList<QVariant> seriesSpyArg = seriesSpy.takeFirst(); | |
494 | QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(1)), set1); |
|
493 | QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(1)), set1); | |
495 | QVERIFY(seriesSpyArg.at(0).type() == QVariant::Bool); |
|
494 | QVERIFY(seriesSpyArg.at(0).type() == QVariant::Bool); | |
496 | QVERIFY(seriesSpyArg.at(0).toBool() == true); |
|
495 | QVERIFY(seriesSpyArg.at(0).toBool() == true); | |
497 |
|
496 | |||
498 | QList<QVariant> setSpyArg = setSpy1.takeFirst(); |
|
497 | QList<QVariant> setSpyArg = setSpy1.takeFirst(); | |
499 | QVERIFY(setSpyArg.at(0).type() == QVariant::Bool); |
|
498 | QVERIFY(setSpyArg.at(0).type() == QVariant::Bool); | |
500 | QVERIFY(setSpyArg.at(0).toBool() == true); |
|
499 | QVERIFY(setSpyArg.at(0).toBool() == true); | |
501 |
|
500 | |||
502 | //======================================================================= |
|
501 | //======================================================================= | |
503 | // move mouse from top of set1 to top of set2 |
|
502 | // move mouse from top of set1 to top of set2 | |
504 | QTest::mouseMove(view.viewport(), QPoint(200,203)); |
|
503 | QTest::mouseMove(view.viewport(), QPoint(200,203)); | |
505 | TRY_COMPARE(seriesSpy.count(), 2); |
|
504 | TRY_COMPARE(seriesSpy.count(), 2); | |
506 | TRY_COMPARE(setSpy1.count(), 1); |
|
505 | TRY_COMPARE(setSpy1.count(), 1); | |
507 | TRY_COMPARE(setSpy2.count(), 1); |
|
506 | TRY_COMPARE(setSpy2.count(), 1); | |
508 |
|
507 | |||
509 | // should leave set1 |
|
508 | // should leave set1 | |
510 | seriesSpyArg = seriesSpy.takeFirst(); |
|
509 | seriesSpyArg = seriesSpy.takeFirst(); | |
511 | QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(1)), set1); |
|
510 | QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(1)), set1); | |
512 | QVERIFY(seriesSpyArg.at(0).type() == QVariant::Bool); |
|
511 | QVERIFY(seriesSpyArg.at(0).type() == QVariant::Bool); | |
513 | QVERIFY(seriesSpyArg.at(0).toBool() == false); |
|
512 | QVERIFY(seriesSpyArg.at(0).toBool() == false); | |
514 |
|
513 | |||
515 | setSpyArg = setSpy1.takeFirst(); |
|
514 | setSpyArg = setSpy1.takeFirst(); | |
516 | QVERIFY(setSpyArg.at(0).type() == QVariant::Bool); |
|
515 | QVERIFY(setSpyArg.at(0).type() == QVariant::Bool); | |
517 | QVERIFY(setSpyArg.at(0).toBool() == false); |
|
516 | QVERIFY(setSpyArg.at(0).toBool() == false); | |
518 |
|
517 | |||
519 | // should enter set2 |
|
518 | // should enter set2 | |
520 | seriesSpyArg = seriesSpy.takeFirst(); |
|
519 | seriesSpyArg = seriesSpy.takeFirst(); | |
521 | QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(1)), set2); |
|
520 | QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(1)), set2); | |
522 | QVERIFY(seriesSpyArg.at(0).type() == QVariant::Bool); |
|
521 | QVERIFY(seriesSpyArg.at(0).type() == QVariant::Bool); | |
523 | QVERIFY(seriesSpyArg.at(0).toBool() == true); |
|
522 | QVERIFY(seriesSpyArg.at(0).toBool() == true); | |
524 |
|
523 | |||
525 | setSpyArg = setSpy2.takeFirst(); |
|
524 | setSpyArg = setSpy2.takeFirst(); | |
526 | QVERIFY(setSpyArg.at(0).type() == QVariant::Bool); |
|
525 | QVERIFY(setSpyArg.at(0).type() == QVariant::Bool); | |
527 | QVERIFY(setSpyArg.at(0).toBool() == true); |
|
526 | QVERIFY(setSpyArg.at(0).toBool() == true); | |
528 |
|
527 | |||
529 | //======================================================================= |
|
528 | //======================================================================= | |
530 | // move mouse from top of set2 to background |
|
529 | // move mouse from top of set2 to background | |
531 | QTest::mouseMove(view.viewport(), QPoint(0,203)); |
|
530 | QTest::mouseMove(view.viewport(), QPoint(0,203)); | |
532 | TRY_COMPARE(seriesSpy.count(), 1); |
|
531 | TRY_COMPARE(seriesSpy.count(), 1); | |
533 | TRY_COMPARE(setSpy1.count(), 0); |
|
532 | TRY_COMPARE(setSpy1.count(), 0); | |
534 | TRY_COMPARE(setSpy2.count(), 1); |
|
533 | TRY_COMPARE(setSpy2.count(), 1); | |
535 |
|
534 | |||
536 | // should leave set2 |
|
535 | // should leave set2 | |
537 | seriesSpyArg = seriesSpy.takeFirst(); |
|
536 | seriesSpyArg = seriesSpy.takeFirst(); | |
538 | QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(1)), set2); |
|
537 | QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(1)), set2); | |
539 | QVERIFY(seriesSpyArg.at(0).type() == QVariant::Bool); |
|
538 | QVERIFY(seriesSpyArg.at(0).type() == QVariant::Bool); | |
540 | QVERIFY(seriesSpyArg.at(0).toBool() == false); |
|
539 | QVERIFY(seriesSpyArg.at(0).toBool() == false); | |
541 |
|
540 | |||
542 | setSpyArg = setSpy2.takeFirst(); |
|
541 | setSpyArg = setSpy2.takeFirst(); | |
543 | QVERIFY(setSpyArg.at(0).type() == QVariant::Bool); |
|
542 | QVERIFY(setSpyArg.at(0).type() == QVariant::Bool); | |
544 | QVERIFY(setSpyArg.at(0).toBool() == false); |
|
543 | QVERIFY(setSpyArg.at(0).toBool() == false); | |
545 | } |
|
544 | } | |
546 |
|
545 | |||
547 | void tst_QHorizontalBarSeries::clearWithAnimations() |
|
546 | void tst_QHorizontalBarSeries::clearWithAnimations() | |
548 | { |
|
547 | { | |
549 | QHorizontalBarSeries* series = new QHorizontalBarSeries(); |
|
548 | QHorizontalBarSeries* series = new QHorizontalBarSeries(); | |
550 |
|
549 | |||
551 | QBarSet* set1 = new QBarSet(QString("set 1")); |
|
550 | QBarSet* set1 = new QBarSet(QString("set 1")); | |
552 | *set1 << 10 << 10 << 10; |
|
551 | *set1 << 10 << 10 << 10; | |
553 | series->append(set1); |
|
552 | series->append(set1); | |
554 |
|
553 | |||
555 | QBarSet* set2 = new QBarSet(QString("set 2")); |
|
554 | QBarSet* set2 = new QBarSet(QString("set 2")); | |
556 | *set2 << 10 << 10 << 10; |
|
555 | *set2 << 10 << 10 << 10; | |
557 | series->append(set2); |
|
556 | series->append(set2); | |
558 |
|
557 | |||
559 | QChartView view(new QChart()); |
|
558 | QChartView view(new QChart()); | |
560 | view.resize(400,300); |
|
559 | view.resize(400,300); | |
561 | view.chart()->setAnimationOptions(QChart::SeriesAnimations); |
|
560 | view.chart()->setAnimationOptions(QChart::SeriesAnimations); | |
562 | view.chart()->addSeries(series); |
|
561 | view.chart()->addSeries(series); | |
563 | view.show(); |
|
562 | view.show(); | |
564 |
|
563 | |||
565 | series->clear(); |
|
564 | series->clear(); | |
566 | } |
|
565 | } | |
567 |
|
566 | |||
568 | QTEST_MAIN(tst_QHorizontalBarSeries) |
|
567 | QTEST_MAIN(tst_QHorizontalBarSeries) | |
569 |
|
568 | |||
570 | #include "tst_qhorizontalbarseries.moc" |
|
569 | #include "tst_qhorizontalbarseries.moc" | |
571 |
|
570 |
General Comments 0
You need to be logged in to leave comments.
Login now