216 void exposeRegion(); |
216 void exposeRegion(); |
217 void update_data(); |
217 void update_data(); |
218 void update(); |
218 void update(); |
219 void inputMethodSensitivity(); |
219 void inputMethodSensitivity(); |
220 void inputContextReset(); |
220 void inputContextReset(); |
|
221 void indirectPainting(); |
|
222 void compositionModeInDrawBackground(); |
221 |
223 |
222 // task specific tests below me |
224 // task specific tests below me |
223 void task172231_untransformableItems(); |
225 void task172231_untransformableItems(); |
224 void task180429_mouseReleaseDragMode(); |
226 void task180429_mouseReleaseDragMode(); |
225 void task187791_setSceneCausesUpdate(); |
227 void task187791_setSceneCausesUpdate(); |
3797 inputContext.resets = 0; |
3799 inputContext.resets = 0; |
3798 scene.setFocusItem(item1); |
3800 scene.setFocusItem(item1); |
3799 QCOMPARE(inputContext.resets, 0); |
3801 QCOMPARE(inputContext.resets, 0); |
3800 } |
3802 } |
3801 |
3803 |
|
3804 void tst_QGraphicsView::indirectPainting() |
|
3805 { |
|
3806 class MyScene : public QGraphicsScene |
|
3807 { public: |
|
3808 MyScene() : QGraphicsScene(), drawCount(0) {} |
|
3809 void drawItems(QPainter *, int, QGraphicsItem **, const QStyleOptionGraphicsItem *, QWidget *) |
|
3810 { ++drawCount; } |
|
3811 int drawCount; |
|
3812 }; |
|
3813 |
|
3814 MyScene scene; |
|
3815 QGraphicsItem *item = scene.addRect(0, 0, 50, 50); |
|
3816 |
|
3817 QGraphicsView view(&scene); |
|
3818 view.setOptimizationFlag(QGraphicsView::IndirectPainting); |
|
3819 view.show(); |
|
3820 QTest::qWaitForWindowShown(&view); |
|
3821 QTest::qWait(100); |
|
3822 |
|
3823 scene.drawCount = 0; |
|
3824 item->setPos(20, 20); |
|
3825 QApplication::processEvents(); |
|
3826 QTRY_VERIFY(scene.drawCount > 0); |
|
3827 } |
|
3828 |
|
3829 void tst_QGraphicsView::compositionModeInDrawBackground() |
|
3830 { |
|
3831 class MyView : public QGraphicsView |
|
3832 { public: |
|
3833 MyView(QGraphicsScene *scene) : QGraphicsView(scene), |
|
3834 painted(false), compositionMode(QPainter::CompositionMode_SourceOver) {} |
|
3835 bool painted; |
|
3836 QPainter::CompositionMode compositionMode; |
|
3837 void drawBackground(QPainter *painter, const QRectF &) |
|
3838 { |
|
3839 compositionMode = painter->compositionMode(); |
|
3840 painted = true; |
|
3841 } |
|
3842 }; |
|
3843 |
|
3844 QGraphicsScene dummy; |
|
3845 MyView view(&dummy); |
|
3846 view.show(); |
|
3847 QTest::qWaitForWindowShown(&view); |
|
3848 |
|
3849 // Make sure the painter's composition mode is SourceOver in drawBackground. |
|
3850 QTRY_VERIFY(view.painted); |
|
3851 QCOMPARE(view.compositionMode, QPainter::CompositionMode_SourceOver); |
|
3852 |
|
3853 view.painted = false; |
|
3854 view.setCacheMode(QGraphicsView::CacheBackground); |
|
3855 view.viewport()->update(); |
|
3856 |
|
3857 // Make sure the painter's composition mode is SourceOver in drawBackground |
|
3858 // with background cache enabled. |
|
3859 QTRY_VERIFY(view.painted); |
|
3860 QCOMPARE(view.compositionMode, QPainter::CompositionMode_SourceOver); |
|
3861 } |
3802 void tst_QGraphicsView::task253415_reconnectUpdateSceneOnSceneChanged() |
3862 void tst_QGraphicsView::task253415_reconnectUpdateSceneOnSceneChanged() |
3803 { |
3863 { |
3804 QGraphicsView view; |
3864 QGraphicsView view; |
3805 QGraphicsView dummyView; |
3865 QGraphicsView dummyView; |
3806 view.setWindowFlags(view.windowFlags() | Qt::WindowStaysOnTopHint); |
3866 view.setWindowFlags(view.windowFlags() | Qt::WindowStaysOnTopHint); |