author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Fri, 12 Mar 2010 15:46:37 +0200 | |
branch | RCL_3 |
changeset 5 | d3bac044e0f0 |
parent 4 | 3b1da2848fc7 |
child 7 | 3f74d0d4af4c |
permissions | -rw-r--r-- |
0 | 1 |
/**************************************************************************** |
2 |
** |
|
4
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3 |
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). |
0 | 4 |
** All rights reserved. |
5 |
** Contact: Nokia Corporation (qt-info@nokia.com) |
|
6 |
** |
|
7 |
** This file is part of the test suite of the Qt Toolkit. |
|
8 |
** |
|
9 |
** $QT_BEGIN_LICENSE:LGPL$ |
|
10 |
** No Commercial Usage |
|
11 |
** This file contains pre-release code and may not be distributed. |
|
12 |
** You may use this file in accordance with the terms and conditions |
|
13 |
** contained in the Technology Preview License Agreement accompanying |
|
14 |
** this package. |
|
15 |
** |
|
16 |
** GNU Lesser General Public License Usage |
|
17 |
** Alternatively, this file may be used under the terms of the GNU Lesser |
|
18 |
** General Public License version 2.1 as published by the Free Software |
|
19 |
** Foundation and appearing in the file LICENSE.LGPL included in the |
|
20 |
** packaging of this file. Please review the following information to |
|
21 |
** ensure the GNU Lesser General Public License version 2.1 requirements |
|
22 |
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. |
|
23 |
** |
|
24 |
** In addition, as a special exception, Nokia gives you certain additional |
|
25 |
** rights. These rights are described in the Nokia Qt LGPL Exception |
|
26 |
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. |
|
27 |
** |
|
28 |
** If you have questions regarding the use of this file, please contact |
|
29 |
** Nokia at qt-info@nokia.com. |
|
30 |
** |
|
31 |
** |
|
32 |
** |
|
33 |
** |
|
34 |
** |
|
35 |
** |
|
36 |
** |
|
37 |
** |
|
38 |
** $QT_END_LICENSE$ |
|
39 |
** |
|
40 |
****************************************************************************/ |
|
41 |
||
42 |
||
43 |
#include <QtTest/QtTest> |
|
44 |
#include <QtGui/qdesktopwidget.h> |
|
45 |
#include <QtGui/qgraphicseffect.h> |
|
46 |
#include <QtGui/qgraphicsview.h> |
|
47 |
#include <QtGui/qgraphicsscene.h> |
|
48 |
#include <QtGui/qgraphicsitem.h> |
|
49 |
#include <QtGui/qstyleoption.h> |
|
50 |
||
51 |
#include "../../shared/util.h" |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
52 |
#include <private/qgraphicseffect_p.h> |
0 | 53 |
|
54 |
//TESTED_CLASS= |
|
55 |
//TESTED_FILES= |
|
56 |
||
57 |
class tst_QGraphicsEffect : public QObject |
|
58 |
{ |
|
59 |
Q_OBJECT |
|
60 |
public slots: |
|
61 |
void initTestCase(); |
|
62 |
||
63 |
private slots: |
|
64 |
void setEnabled(); |
|
65 |
void source(); |
|
66 |
void boundingRectFor(); |
|
67 |
void boundingRect(); |
|
68 |
void draw(); |
|
69 |
void opacity(); |
|
70 |
void grayscale(); |
|
71 |
void colorize(); |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
72 |
void drawPixmapItem(); |
4
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
73 |
void deviceCoordinateTranslateCaching(); |
5
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
74 |
void inheritOpacity(); |
0 | 75 |
}; |
76 |
||
77 |
void tst_QGraphicsEffect::initTestCase() |
|
78 |
{} |
|
79 |
||
80 |
class CustomItem : public QGraphicsRectItem |
|
81 |
{ |
|
82 |
public: |
|
5
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
83 |
CustomItem(qreal x, qreal y, qreal width, qreal height, QGraphicsItem *parent = 0) |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
84 |
: QGraphicsRectItem(x, y, width, height, parent), numRepaints(0), |
0 | 85 |
m_painter(0), m_styleOption(0) |
86 |
{} |
|
87 |
||
88 |
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) |
|
89 |
{ |
|
90 |
m_painter = painter; |
|
91 |
m_styleOption = option; |
|
92 |
++numRepaints; |
|
93 |
QGraphicsRectItem::paint(painter, option, widget); |
|
94 |
} |
|
95 |
||
96 |
void reset() |
|
97 |
{ |
|
98 |
numRepaints = 0; |
|
99 |
m_painter = 0; |
|
100 |
m_styleOption = 0; |
|
101 |
} |
|
102 |
||
103 |
int numRepaints; |
|
104 |
QPainter *m_painter; |
|
105 |
const QStyleOption *m_styleOption; |
|
106 |
}; |
|
107 |
||
108 |
class CustomEffect : public QGraphicsEffect |
|
109 |
{ |
|
110 |
public: |
|
111 |
CustomEffect() |
|
112 |
: QGraphicsEffect(), numRepaints(0), m_margin(10), |
|
113 |
doNothingInDraw(false), m_painter(0), m_styleOption(0), m_source(0), m_opacity(1.0) |
|
114 |
{} |
|
115 |
||
116 |
QRectF boundingRectFor(const QRectF &rect) const |
|
117 |
{ return rect.adjusted(-m_margin, -m_margin, m_margin, m_margin); } |
|
118 |
||
119 |
void reset() |
|
120 |
{ |
|
121 |
numRepaints = 0; |
|
122 |
m_sourceChangedFlags = QGraphicsEffect::ChangeFlags(); |
|
123 |
m_painter = 0; |
|
124 |
m_styleOption = 0; |
|
125 |
m_source = 0; |
|
126 |
m_opacity = 1.0; |
|
127 |
} |
|
128 |
||
129 |
void setMargin(int margin) |
|
130 |
{ |
|
131 |
m_margin = margin; |
|
132 |
updateBoundingRect(); |
|
133 |
} |
|
134 |
||
135 |
int margin() const |
|
136 |
{ return m_margin; } |
|
137 |
||
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
138 |
void draw(QPainter *painter) |
0 | 139 |
{ |
140 |
++numRepaints; |
|
141 |
if (doNothingInDraw) |
|
142 |
return; |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
143 |
m_source = source(); |
0 | 144 |
m_painter = painter; |
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
145 |
m_styleOption = source()->styleOption(); |
0 | 146 |
m_opacity = painter->opacity(); |
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
147 |
drawSource(painter); |
0 | 148 |
} |
149 |
||
150 |
void sourceChanged(QGraphicsEffect::ChangeFlags flags) |
|
151 |
{ m_sourceChangedFlags |= flags; } |
|
152 |
||
153 |
int numRepaints; |
|
154 |
int m_margin; |
|
155 |
QGraphicsEffect::ChangeFlags m_sourceChangedFlags; |
|
156 |
bool doNothingInDraw; |
|
157 |
QPainter *m_painter; |
|
158 |
const QStyleOption *m_styleOption; |
|
159 |
QGraphicsEffectSource *m_source; |
|
160 |
qreal m_opacity; |
|
161 |
}; |
|
162 |
||
163 |
void tst_QGraphicsEffect::setEnabled() |
|
164 |
{ |
|
165 |
CustomEffect effect; |
|
166 |
QVERIFY(effect.isEnabled()); |
|
167 |
||
168 |
effect.setEnabled(false); |
|
169 |
QVERIFY(!effect.isEnabled()); |
|
170 |
} |
|
171 |
||
172 |
void tst_QGraphicsEffect::source() |
|
173 |
{ |
|
174 |
QPointer<CustomEffect> effect = new CustomEffect; |
|
175 |
QVERIFY(!effect->source()); |
|
176 |
QVERIFY(!effect->m_sourceChangedFlags); |
|
177 |
||
178 |
// Install effect on QGraphicsItem. |
|
179 |
QGraphicsItem *item = new QGraphicsRectItem(0, 0, 10, 10); |
|
180 |
item->setGraphicsEffect(effect); |
|
181 |
QVERIFY(effect->source()); |
|
182 |
QCOMPARE(effect->source()->graphicsItem(), item); |
|
183 |
QVERIFY(effect->m_sourceChangedFlags & QGraphicsEffect::SourceAttached); |
|
184 |
effect->reset(); |
|
185 |
||
186 |
// Make sure disabling/enabling the effect doesn't change the source. |
|
187 |
effect->setEnabled(false); |
|
188 |
QVERIFY(effect->source()); |
|
189 |
QCOMPARE(effect->source()->graphicsItem(), item); |
|
190 |
QVERIFY(!effect->m_sourceChangedFlags); |
|
191 |
effect->reset(); |
|
192 |
||
193 |
effect->setEnabled(true); |
|
194 |
QVERIFY(effect->source()); |
|
195 |
QCOMPARE(effect->source()->graphicsItem(), item); |
|
196 |
QVERIFY(!effect->m_sourceChangedFlags); |
|
197 |
effect->reset(); |
|
198 |
||
199 |
// Uninstall effect on QGraphicsItem. |
|
200 |
effect->reset(); |
|
201 |
item->setGraphicsEffect(0); |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
202 |
QVERIFY(!effect); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
203 |
effect = new CustomEffect; |
0 | 204 |
|
205 |
// The item takes ownership and should delete the effect when destroyed. |
|
206 |
item->setGraphicsEffect(effect); |
|
207 |
QPointer<QGraphicsEffectSource> source = effect->source(); |
|
208 |
QVERIFY(source); |
|
209 |
QCOMPARE(source->graphicsItem(), item); |
|
210 |
delete item; |
|
211 |
QVERIFY(!effect); |
|
212 |
QVERIFY(!source); |
|
213 |
} |
|
214 |
||
215 |
void tst_QGraphicsEffect::boundingRectFor() |
|
216 |
{ |
|
217 |
CustomEffect effect; |
|
218 |
int margin = effect.margin(); |
|
219 |
const QRectF source(0, 0, 100, 100); |
|
220 |
QCOMPARE(effect.boundingRectFor(source), source.adjusted(-margin, -margin, margin, margin)); |
|
221 |
||
222 |
effect.setMargin(margin = 20); |
|
223 |
QCOMPARE(effect.boundingRectFor(source), source.adjusted(-margin, -margin, margin, margin)); |
|
224 |
} |
|
225 |
||
226 |
void tst_QGraphicsEffect::boundingRect() |
|
227 |
{ |
|
228 |
// No source; empty bounding rect. |
|
229 |
CustomEffect *effect = new CustomEffect; |
|
230 |
QCOMPARE(effect->boundingRect(), QRectF()); |
|
231 |
||
232 |
// Install effect on QGraphicsItem. |
|
233 |
QRectF itemRect(0, 0, 100, 100); |
|
234 |
QGraphicsRectItem *item = new QGraphicsRectItem; |
|
235 |
item->setRect(itemRect); |
|
236 |
item->setGraphicsEffect(effect); |
|
237 |
int margin = effect->margin(); |
|
238 |
QCOMPARE(effect->boundingRect(), itemRect.adjusted(-margin, -margin, margin, margin)); |
|
239 |
QCOMPARE(effect->boundingRect(), effect->boundingRectFor(itemRect)); |
|
240 |
||
241 |
// Make sure disabling/enabling the effect doesn't change the bounding rect. |
|
242 |
effect->setEnabled(false); |
|
243 |
QCOMPARE(effect->boundingRect(), itemRect.adjusted(-margin, -margin, margin, margin)); |
|
244 |
QCOMPARE(effect->boundingRect(), effect->boundingRectFor(itemRect)); |
|
245 |
effect->setEnabled(true); |
|
246 |
QCOMPARE(effect->boundingRect(), itemRect.adjusted(-margin, -margin, margin, margin)); |
|
247 |
QCOMPARE(effect->boundingRect(), effect->boundingRectFor(itemRect)); |
|
248 |
||
249 |
// Change effect margins. |
|
250 |
effect->setMargin(margin = 20); |
|
251 |
QCOMPARE(effect->boundingRect(), itemRect.adjusted(-margin, -margin, margin, margin)); |
|
252 |
QCOMPARE(effect->boundingRect(), effect->boundingRectFor(itemRect)); |
|
253 |
||
254 |
// Uninstall effect on QGraphicsItem. |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
255 |
QPointer<CustomEffect> ptr = effect; |
0 | 256 |
item->setGraphicsEffect(0); |
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
257 |
QVERIFY(!ptr); |
0 | 258 |
|
259 |
delete item; |
|
260 |
} |
|
261 |
||
262 |
void tst_QGraphicsEffect::draw() |
|
263 |
{ |
|
264 |
QGraphicsScene scene; |
|
265 |
CustomItem *item = new CustomItem(0, 0, 100, 100); |
|
266 |
scene.addItem(item); |
|
267 |
||
268 |
QGraphicsView view(&scene); |
|
269 |
view.show(); |
|
270 |
QTest::qWaitForWindowShown(&view); |
|
271 |
QTRY_VERIFY(item->numRepaints > 0); |
|
272 |
item->reset(); |
|
273 |
||
274 |
// Make sure installing the effect triggers a repaint. |
|
275 |
CustomEffect *effect = new CustomEffect; |
|
276 |
item->setGraphicsEffect(effect); |
|
277 |
QTest::qWait(50); |
|
278 |
QCOMPARE(effect->numRepaints, 1); |
|
279 |
QCOMPARE(item->numRepaints, 1); |
|
280 |
||
281 |
// Make sure QPainter* and QStyleOptionGraphicsItem* stays persistent |
|
282 |
// during QGraphicsEffect::draw/QGraphicsItem::paint. |
|
283 |
QVERIFY(effect->m_painter); |
|
284 |
QCOMPARE(effect->m_painter, item->m_painter); |
|
285 |
QCOMPARE(effect->m_styleOption, item->m_styleOption); |
|
286 |
// Make sure QGraphicsEffect::source is persistent. |
|
287 |
QCOMPARE(effect->m_source, effect->source()); |
|
288 |
effect->reset(); |
|
289 |
item->reset(); |
|
290 |
||
291 |
// Make sure updating the source triggers a repaint. |
|
292 |
item->update(); |
|
293 |
QTest::qWait(50); |
|
294 |
QCOMPARE(effect->numRepaints, 1); |
|
295 |
QCOMPARE(item->numRepaints, 1); |
|
296 |
QVERIFY(effect->m_sourceChangedFlags & QGraphicsEffect::SourceInvalidated); |
|
297 |
effect->reset(); |
|
298 |
item->reset(); |
|
299 |
||
300 |
// Make sure changing the effect's bounding rect triggers a repaint. |
|
301 |
effect->setMargin(20); |
|
302 |
QTest::qWait(50); |
|
303 |
QCOMPARE(effect->numRepaints, 1); |
|
304 |
QCOMPARE(item->numRepaints, 1); |
|
305 |
effect->reset(); |
|
306 |
item->reset(); |
|
307 |
||
308 |
// Make sure change the item's bounding rect triggers a repaint. |
|
309 |
item->setRect(0, 0, 50, 50); |
|
310 |
QTest::qWait(50); |
|
311 |
QCOMPARE(effect->numRepaints, 1); |
|
312 |
QCOMPARE(item->numRepaints, 1); |
|
313 |
QVERIFY(effect->m_sourceChangedFlags & QGraphicsEffect::SourceBoundingRectChanged); |
|
314 |
effect->reset(); |
|
315 |
item->reset(); |
|
316 |
||
317 |
// Make sure the effect is the one to issue a repaint of the item. |
|
318 |
effect->doNothingInDraw = true; |
|
319 |
item->update(); |
|
320 |
QTest::qWait(50); |
|
321 |
QCOMPARE(effect->numRepaints, 1); |
|
322 |
QCOMPARE(item->numRepaints, 0); |
|
323 |
effect->doNothingInDraw = false; |
|
324 |
effect->reset(); |
|
325 |
item->reset(); |
|
326 |
||
327 |
// Make sure we update the source when disabling/enabling the effect. |
|
328 |
effect->setEnabled(false); |
|
329 |
QTest::qWait(50); |
|
330 |
QCOMPARE(effect->numRepaints, 0); |
|
331 |
QCOMPARE(item->numRepaints, 1); |
|
332 |
effect->reset(); |
|
333 |
item->reset(); |
|
334 |
||
335 |
effect->setEnabled(true); |
|
336 |
QTest::qWait(50); |
|
337 |
QCOMPARE(effect->numRepaints, 1); |
|
338 |
QCOMPARE(item->numRepaints, 1); |
|
339 |
effect->reset(); |
|
340 |
item->reset(); |
|
341 |
||
342 |
// Effect is already enabled; nothing should happen. |
|
343 |
effect->setEnabled(true); |
|
344 |
QTest::qWait(50); |
|
345 |
QCOMPARE(effect->numRepaints, 0); |
|
346 |
QCOMPARE(item->numRepaints, 0); |
|
347 |
||
348 |
// Make sure uninstalling an effect triggers a repaint. |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
349 |
QPointer<CustomEffect> ptr = effect; |
0 | 350 |
item->setGraphicsEffect(0); |
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
351 |
QVERIFY(!ptr); |
0 | 352 |
QTest::qWait(50); |
353 |
QCOMPARE(item->numRepaints, 1); |
|
354 |
} |
|
355 |
||
356 |
void tst_QGraphicsEffect::opacity() |
|
357 |
{ |
|
358 |
// Make sure the painter's opacity is correct in QGraphicsEffect::draw. |
|
359 |
QGraphicsScene scene; |
|
360 |
CustomItem *item = new CustomItem(0, 0, 100, 100); |
|
361 |
item->setOpacity(0.5); |
|
362 |
CustomEffect *effect = new CustomEffect; |
|
363 |
item->setGraphicsEffect(effect); |
|
364 |
scene.addItem(item); |
|
365 |
||
366 |
QGraphicsView view(&scene); |
|
367 |
view.show(); |
|
368 |
QTest::qWaitForWindowShown(&view); |
|
369 |
QTRY_VERIFY(effect->numRepaints > 0); |
|
370 |
QCOMPARE(effect->m_opacity, qreal(0.5)); |
|
371 |
} |
|
372 |
||
373 |
void tst_QGraphicsEffect::grayscale() |
|
374 |
{ |
|
375 |
if (qApp->desktop()->depth() < 24) { |
|
376 |
QSKIP("Test only works on 32 bit displays", SkipAll); |
|
377 |
return; |
|
378 |
} |
|
379 |
||
380 |
QGraphicsScene scene(0, 0, 100, 100); |
|
381 |
||
382 |
QGraphicsRectItem *item = scene.addRect(0, 0, 50, 50); |
|
383 |
item->setPen(Qt::NoPen); |
|
384 |
item->setBrush(QColor(122, 193, 66)); // Qt light green |
|
385 |
||
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
386 |
QGraphicsColorizeEffect *effect = new QGraphicsColorizeEffect; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
387 |
effect->setColor(Qt::black); |
0 | 388 |
item->setGraphicsEffect(effect); |
389 |
||
390 |
QPainter painter; |
|
391 |
QImage image(100, 100, QImage::Format_ARGB32_Premultiplied); |
|
392 |
||
393 |
image.fill(0); |
|
394 |
painter.begin(&image); |
|
395 |
painter.setRenderHint(QPainter::Antialiasing); |
|
396 |
scene.render(&painter); |
|
397 |
painter.end(); |
|
398 |
||
399 |
QCOMPARE(image.pixel(10, 10), qRgb(148, 148, 148)); |
|
400 |
||
401 |
effect->setStrength(0.5); |
|
402 |
||
403 |
image.fill(0); |
|
404 |
painter.begin(&image); |
|
405 |
painter.setRenderHint(QPainter::Antialiasing); |
|
406 |
scene.render(&painter); |
|
407 |
painter.end(); |
|
408 |
||
409 |
QCOMPARE(image.pixel(10, 10), qRgb(135, 171, 107)); |
|
410 |
||
411 |
effect->setStrength(0.0); |
|
412 |
||
413 |
image.fill(0); |
|
414 |
painter.begin(&image); |
|
415 |
painter.setRenderHint(QPainter::Antialiasing); |
|
416 |
scene.render(&painter); |
|
417 |
painter.end(); |
|
418 |
||
419 |
QCOMPARE(image.pixel(10, 10), qRgb(122, 193, 66)); |
|
420 |
} |
|
421 |
||
422 |
void tst_QGraphicsEffect::colorize() |
|
423 |
{ |
|
424 |
if (qApp->desktop()->depth() < 24) { |
|
425 |
QSKIP("Test only works on 32 bit displays", SkipAll); |
|
426 |
return; |
|
427 |
} |
|
428 |
||
429 |
QGraphicsScene scene(0, 0, 100, 100); |
|
430 |
||
431 |
QGraphicsRectItem *item = scene.addRect(0, 0, 50, 50); |
|
432 |
item->setPen(Qt::NoPen); |
|
433 |
item->setBrush(QColor(122, 193, 66)); // Qt light green |
|
434 |
||
435 |
QGraphicsColorizeEffect *effect = new QGraphicsColorizeEffect; |
|
436 |
effect->setColor(QColor(102, 153, 51)); // Qt dark green |
|
437 |
item->setGraphicsEffect(effect); |
|
438 |
||
439 |
QPainter painter; |
|
440 |
QImage image(100, 100, QImage::Format_ARGB32_Premultiplied); |
|
441 |
||
442 |
image.fill(0); |
|
443 |
painter.begin(&image); |
|
444 |
painter.setRenderHint(QPainter::Antialiasing); |
|
445 |
scene.render(&painter); |
|
446 |
painter.end(); |
|
447 |
||
448 |
QCOMPARE(image.pixel(10, 10), qRgb(191, 212, 169)); |
|
449 |
||
450 |
effect->setStrength(0.5); |
|
451 |
||
452 |
image.fill(0); |
|
453 |
painter.begin(&image); |
|
454 |
painter.setRenderHint(QPainter::Antialiasing); |
|
455 |
scene.render(&painter); |
|
456 |
painter.end(); |
|
457 |
||
458 |
QCOMPARE(image.pixel(10, 10), qRgb(156, 203, 117)); |
|
459 |
||
460 |
effect->setStrength(0.0); |
|
461 |
||
462 |
image.fill(0); |
|
463 |
painter.begin(&image); |
|
464 |
painter.setRenderHint(QPainter::Antialiasing); |
|
465 |
scene.render(&painter); |
|
466 |
painter.end(); |
|
467 |
||
468 |
QCOMPARE(image.pixel(10, 10), qRgb(122, 193, 66)); |
|
469 |
} |
|
470 |
||
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
471 |
class PixmapItemEffect : public QGraphicsEffect |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
472 |
{ |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
473 |
public: |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
474 |
PixmapItemEffect(const QPixmap &source) |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
475 |
: QGraphicsEffect() |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
476 |
, pixmap(source) |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
477 |
, repaints(0) |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
478 |
{} |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
479 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
480 |
QRectF boundingRectFor(const QRectF &rect) const |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
481 |
{ return rect; } |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
482 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
483 |
void draw(QPainter *painter) |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
484 |
{ |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
485 |
QVERIFY(sourcePixmap(Qt::LogicalCoordinates).pixmapData() == pixmap.pixmapData()); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
486 |
QVERIFY((painter->worldTransform().type() <= QTransform::TxTranslate) == (sourcePixmap(Qt::DeviceCoordinates).pixmapData() == pixmap.pixmapData())); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
487 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
488 |
++repaints; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
489 |
} |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
490 |
QPixmap pixmap; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
491 |
int repaints; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
492 |
}; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
493 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
494 |
void tst_QGraphicsEffect::drawPixmapItem() |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
495 |
{ |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
496 |
QImage image(32, 32, QImage::Format_RGB32); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
497 |
QPainter p(&image); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
498 |
p.fillRect(0, 0, 32, 16, Qt::blue); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
499 |
p.fillRect(0, 16, 32, 16, Qt::red); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
500 |
p.end(); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
501 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
502 |
QGraphicsScene scene; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
503 |
QGraphicsPixmapItem *item = new QGraphicsPixmapItem(QPixmap::fromImage(image)); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
504 |
scene.addItem(item); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
505 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
506 |
PixmapItemEffect *effect = new PixmapItemEffect(item->pixmap()); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
507 |
item->setGraphicsEffect(effect); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
508 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
509 |
QGraphicsView view(&scene); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
510 |
view.show(); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
511 |
QTest::qWaitForWindowShown(&view); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
512 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
513 |
item->rotate(180); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
514 |
QTest::qWait(50); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
515 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
516 |
QTRY_VERIFY(effect->repaints >= 2); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
517 |
} |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
518 |
|
4
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
519 |
class DeviceEffect : public QGraphicsEffect |
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
520 |
{ |
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
521 |
public: |
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
522 |
QRectF boundingRectFor(const QRectF &rect) const |
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
523 |
{ return rect; } |
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
524 |
|
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
525 |
void draw(QPainter *painter) |
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
526 |
{ |
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
527 |
QPoint offset; |
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
528 |
QPixmap pixmap = sourcePixmap(Qt::DeviceCoordinates, &offset, QGraphicsEffect::NoPad); |
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
529 |
|
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
530 |
if (pixmap.isNull()) |
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
531 |
return; |
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
532 |
|
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
533 |
painter->save(); |
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
534 |
painter->setWorldTransform(QTransform()); |
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
535 |
painter->drawPixmap(offset, pixmap); |
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
536 |
painter->restore(); |
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
537 |
} |
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
538 |
}; |
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
539 |
|
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
540 |
void tst_QGraphicsEffect::deviceCoordinateTranslateCaching() |
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
541 |
{ |
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
542 |
QGraphicsScene scene; |
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
543 |
CustomItem *item = new CustomItem(0, 0, 10, 10); |
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
544 |
scene.addItem(item); |
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
545 |
scene.setSceneRect(0, 0, 50, 0); |
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
546 |
|
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
547 |
item->setGraphicsEffect(new DeviceEffect); |
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
548 |
item->setPen(Qt::NoPen); |
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
549 |
item->setBrush(Qt::red); |
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
550 |
|
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
551 |
QGraphicsView view(&scene); |
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
552 |
view.show(); |
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
553 |
QTest::qWaitForWindowShown(&view); |
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
554 |
|
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
555 |
QTRY_VERIFY(item->numRepaints >= 1); |
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
556 |
int numRepaints = item->numRepaints; |
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
557 |
|
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
558 |
item->translate(10, 0); |
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
559 |
QTest::qWait(50); |
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
560 |
|
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
561 |
QVERIFY(item->numRepaints == numRepaints); |
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
562 |
} |
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
563 |
|
5
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
564 |
void tst_QGraphicsEffect::inheritOpacity() |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
565 |
{ |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
566 |
QGraphicsScene scene; |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
567 |
QGraphicsRectItem *rectItem = new QGraphicsRectItem(0, 0, 10, 10); |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
568 |
CustomItem *item = new CustomItem(0, 0, 10, 10, rectItem); |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
569 |
|
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
570 |
scene.addItem(rectItem); |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
571 |
|
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
572 |
item->setGraphicsEffect(new DeviceEffect); |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
573 |
item->setPen(Qt::NoPen); |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
574 |
item->setBrush(Qt::red); |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
575 |
|
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
576 |
rectItem->setOpacity(0.5); |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
577 |
|
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
578 |
QGraphicsView view(&scene); |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
579 |
view.show(); |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
580 |
QTest::qWaitForWindowShown(&view); |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
581 |
|
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
582 |
QTRY_VERIFY(item->numRepaints >= 1); |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
583 |
|
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
584 |
int numRepaints = item->numRepaints; |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
585 |
|
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
586 |
rectItem->setOpacity(1); |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
587 |
QTest::qWait(50); |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
588 |
|
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
589 |
// item should have been rerendered due to opacity changing |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
590 |
QTRY_VERIFY(item->numRepaints > numRepaints); |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
591 |
} |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
592 |
|
0 | 593 |
QTEST_MAIN(tst_QGraphicsEffect) |
594 |
#include "tst_qgraphicseffect.moc" |
|
595 |