218 // Trigger an update and check that the style option in QGraphicsEffect::draw |
220 // Trigger an update and check that the style option in QGraphicsEffect::draw |
219 // was the same as the one in QGraphicsItem::paint. |
221 // was the same as the one in QGraphicsItem::paint. |
220 QCOMPARE(item->numRepaints, 0); |
222 QCOMPARE(item->numRepaints, 0); |
221 QCOMPARE(effect->numRepaints, 0); |
223 QCOMPARE(effect->numRepaints, 0); |
222 item->update(); |
224 item->update(); |
223 QTest::qWait(50); |
225 QTRY_COMPARE(item->numRepaints, 1); |
224 QCOMPARE(item->numRepaints, 1); |
226 QTRY_COMPARE(effect->numRepaints, 1); |
225 QCOMPARE(effect->numRepaints, 1); |
|
226 } |
227 } |
227 |
228 |
228 void tst_QGraphicsEffectSource::isPixmap() |
229 void tst_QGraphicsEffectSource::isPixmap() |
229 { |
230 { |
230 // Current source is a CustomItem (which is not a pixmap item). |
231 // Current source is a CustomItem (which is not a pixmap item). |
253 { |
254 { |
254 QCOMPARE(item->numRepaints, 0); |
255 QCOMPARE(item->numRepaints, 0); |
255 QCOMPARE(effect->numRepaints, 0); |
256 QCOMPARE(effect->numRepaints, 0); |
256 |
257 |
257 effect->source()->update(); |
258 effect->source()->update(); |
258 QTest::qWait(50); |
259 |
259 |
260 QTRY_COMPARE(item->numRepaints, 1); |
260 QCOMPARE(item->numRepaints, 1); |
261 QTRY_COMPARE(effect->numRepaints, 1); |
261 QCOMPARE(effect->numRepaints, 1); |
|
262 } |
262 } |
263 |
263 |
264 void tst_QGraphicsEffectSource::boundingRect() |
264 void tst_QGraphicsEffectSource::boundingRect() |
265 { |
265 { |
266 QTest::ignoreMessage(QtWarningMsg, "QGraphicsEffectSource::boundingRect: Not yet implemented, lacking device context"); |
266 QTest::ignoreMessage(QtWarningMsg, "QGraphicsEffectSource::boundingRect: Not yet implemented, lacking device context"); |
271 itemBoundingRect |= item->childrenBoundingRect(); |
271 itemBoundingRect |= item->childrenBoundingRect(); |
272 |
272 |
273 // We can at least check that the device bounding rect was correct in QGraphicsEffect::draw. |
273 // We can at least check that the device bounding rect was correct in QGraphicsEffect::draw. |
274 effect->storeDeviceDependentStuff = true; |
274 effect->storeDeviceDependentStuff = true; |
275 effect->source()->update(); |
275 effect->source()->update(); |
276 QTest::qWait(50); |
|
277 const QTransform deviceTransform = item->deviceTransform(view->viewportTransform()); |
276 const QTransform deviceTransform = item->deviceTransform(view->viewportTransform()); |
278 QCOMPARE(effect->sourceDeviceBoundingRect, deviceTransform.mapRect(itemBoundingRect)); |
277 QTRY_COMPARE(effect->sourceDeviceBoundingRect, deviceTransform.mapRect(itemBoundingRect)); |
279 |
278 |
280 // Bounding rect in logical coordinates is of course fine. |
279 // Bounding rect in logical coordinates is of course fine. |
281 QCOMPARE(effect->source()->boundingRect(Qt::LogicalCoordinates), itemBoundingRect); |
280 QTRY_COMPARE(effect->source()->boundingRect(Qt::LogicalCoordinates), itemBoundingRect); |
282 // Make sure default value is Qt::LogicalCoordinates. |
281 // Make sure default value is Qt::LogicalCoordinates. |
283 QCOMPARE(effect->source()->boundingRect(), itemBoundingRect); |
282 QTRY_COMPARE(effect->source()->boundingRect(), itemBoundingRect); |
284 } |
283 } |
285 |
284 |
286 void tst_QGraphicsEffectSource::deviceRect() |
285 void tst_QGraphicsEffectSource::deviceRect() |
287 { |
286 { |
288 effect->storeDeviceDependentStuff = true; |
287 effect->storeDeviceDependentStuff = true; |
289 effect->source()->update(); |
288 effect->source()->update(); |
290 QTest::qWait(50); |
289 QTRY_COMPARE(effect->deviceRect, view->viewport()->rect()); |
291 QCOMPARE(effect->deviceRect, view->viewport()->rect()); |
|
292 } |
290 } |
293 |
291 |
294 void tst_QGraphicsEffectSource::pixmap() |
292 void tst_QGraphicsEffectSource::pixmap() |
295 { |
293 { |
296 QTest::ignoreMessage(QtWarningMsg, "QGraphicsEffectSource::pixmap: Not yet implemented, lacking device context"); |
294 QTest::ignoreMessage(QtWarningMsg, "QGraphicsEffectSource::pixmap: Not yet implemented, lacking device context"); |
297 QCOMPARE(effect->source()->pixmap(Qt::DeviceCoordinates), QPixmap()); |
295 QCOMPARE(effect->source()->pixmap(Qt::DeviceCoordinates), QPixmap()); |
298 |
296 |
299 // We can at least verify a valid pixmap from QGraphicsEffect::draw. |
297 // We can at least verify a valid pixmap from QGraphicsEffect::draw. |
300 effect->storeDeviceDependentStuff = true; |
298 effect->storeDeviceDependentStuff = true; |
301 effect->source()->update(); |
299 effect->source()->update(); |
302 QTest::qWait(50); |
300 QTRY_VERIFY(!effect->deviceCoordinatesPixmap.isNull()); |
303 QVERIFY(!effect->deviceCoordinatesPixmap.isNull()); |
|
304 |
301 |
305 // Pixmaps in logical coordinates we can do fine. |
302 // Pixmaps in logical coordinates we can do fine. |
306 QPixmap pixmap1 = effect->source()->pixmap(Qt::LogicalCoordinates); |
303 QPixmap pixmap1 = effect->source()->pixmap(Qt::LogicalCoordinates); |
307 QVERIFY(!pixmap1.isNull()); |
304 QVERIFY(!pixmap1.isNull()); |
308 |
305 |