3200 } |
3203 } |
3201 |
3204 |
3202 void tst_QGraphicsView::moveItemWhileScrolling_data() |
3205 void tst_QGraphicsView::moveItemWhileScrolling_data() |
3203 { |
3206 { |
3204 QTest::addColumn<bool>("adjustForAntialiasing"); |
3207 QTest::addColumn<bool>("adjustForAntialiasing"); |
3205 |
3208 QTest::addColumn<bool>("changedConnected"); |
3206 QTest::newRow("no adjust") << false; |
3209 |
3207 QTest::newRow("adjust") << true; |
3210 QTest::newRow("no adjust") << false << false; |
|
3211 QTest::newRow("adjust") << true << false; |
|
3212 QTest::newRow("no adjust changedConnected") << false << true; |
|
3213 QTest::newRow("adjust changedConnected") << true << true; |
3208 } |
3214 } |
3209 |
3215 |
3210 void tst_QGraphicsView::moveItemWhileScrolling() |
3216 void tst_QGraphicsView::moveItemWhileScrolling() |
3211 { |
3217 { |
3212 QFETCH(bool, adjustForAntialiasing); |
3218 QFETCH(bool, adjustForAntialiasing); |
|
3219 QFETCH(bool, changedConnected); |
3213 |
3220 |
3214 class MoveItemScrollView : public QGraphicsView |
3221 class MoveItemScrollView : public QGraphicsView |
3215 { |
3222 { |
3216 public: |
3223 public: |
3217 MoveItemScrollView() |
3224 MoveItemScrollView() |
3251 if (!adjustForAntialiasing) |
3258 if (!adjustForAntialiasing) |
3252 view.setOptimizationFlag(QGraphicsView::DontAdjustForAntialiasing); |
3259 view.setOptimizationFlag(QGraphicsView::DontAdjustForAntialiasing); |
3253 view.resize(200, 200); |
3260 view.resize(200, 200); |
3254 view.painted = false; |
3261 view.painted = false; |
3255 view.show(); |
3262 view.show(); |
|
3263 if (changedConnected) |
|
3264 QObject::connect(view.scene(), SIGNAL(changed(QList<QRectF>)), this, SLOT(dummySlot())); |
3256 QTest::qWaitForWindowShown(&view); |
3265 QTest::qWaitForWindowShown(&view); |
3257 QApplication::processEvents(); |
3266 QApplication::processEvents(); |
3258 QTRY_VERIFY(view.painted); |
3267 QTRY_VERIFY(view.painted); |
3259 view.painted = false; |
3268 view.painted = false; |
3260 view.lastPaintedRegion = QRegion(); |
3269 view.lastPaintedRegion = QRegion(); |
3689 |
3698 |
3690 void tst_QGraphicsView::update2_data() |
3699 void tst_QGraphicsView::update2_data() |
3691 { |
3700 { |
3692 QTest::addColumn<qreal>("penWidth"); |
3701 QTest::addColumn<qreal>("penWidth"); |
3693 QTest::addColumn<bool>("antialiasing"); |
3702 QTest::addColumn<bool>("antialiasing"); |
|
3703 QTest::addColumn<bool>("changedConnected"); |
3694 |
3704 |
3695 // Anti-aliased. |
3705 // Anti-aliased. |
3696 QTest::newRow("pen width: 0.0, antialiasing: true") << 0.0 << true; |
3706 QTest::newRow("pen width: 0.0, antialiasing: true") << 0.0 << true << false; |
3697 QTest::newRow("pen width: 1.5, antialiasing: true") << 1.5 << true; |
3707 QTest::newRow("pen width: 1.5, antialiasing: true") << 1.5 << true << false; |
3698 QTest::newRow("pen width: 2.0, antialiasing: true") << 2.0 << true; |
3708 QTest::newRow("pen width: 2.0, antialiasing: true") << 2.0 << true << false; |
3699 QTest::newRow("pen width: 3.0, antialiasing: true") << 3.0 << true; |
3709 QTest::newRow("pen width: 3.0, antialiasing: true") << 3.0 << true << false; |
3700 |
3710 |
3701 // Aliased. |
3711 // Aliased. |
3702 QTest::newRow("pen width: 0.0, antialiasing: false") << 0.0 << false; |
3712 QTest::newRow("pen width: 0.0, antialiasing: false") << 0.0 << false << false; |
3703 QTest::newRow("pen width: 1.5, antialiasing: false") << 1.5 << false; |
3713 QTest::newRow("pen width: 1.5, antialiasing: false") << 1.5 << false << false; |
3704 QTest::newRow("pen width: 2.0, antialiasing: false") << 2.0 << false; |
3714 QTest::newRow("pen width: 2.0, antialiasing: false") << 2.0 << false << false; |
3705 QTest::newRow("pen width: 3.0, antialiasing: false") << 3.0 << false; |
3715 QTest::newRow("pen width: 3.0, antialiasing: false") << 3.0 << false << false; |
|
3716 |
|
3717 // changed() connected |
|
3718 QTest::newRow("pen width: 0.0, antialiasing: false, changed") << 0.0 << false << true; |
|
3719 QTest::newRow("pen width: 1.5, antialiasing: true, changed") << 1.5 << true << true; |
|
3720 QTest::newRow("pen width: 2.0, antialiasing: false, changed") << 2.0 << false << true; |
|
3721 QTest::newRow("pen width: 3.0, antialiasing: true, changed") << 3.0 << true << true; |
3706 } |
3722 } |
3707 |
3723 |
3708 void tst_QGraphicsView::update2() |
3724 void tst_QGraphicsView::update2() |
3709 { |
3725 { |
3710 QFETCH(qreal, penWidth); |
3726 QFETCH(qreal, penWidth); |
3711 QFETCH(bool, antialiasing); |
3727 QFETCH(bool, antialiasing); |
|
3728 QFETCH(bool, changedConnected); |
3712 |
3729 |
3713 // Create a rect item. |
3730 // Create a rect item. |
3714 const QRectF rawItemRect(-50.4, -50.3, 100.2, 100.1); |
3731 const QRectF rawItemRect(-50.4, -50.3, 100.2, 100.1); |
3715 CountPaintItem *rect = new CountPaintItem(rawItemRect); |
3732 CountPaintItem *rect = new CountPaintItem(rawItemRect); |
3716 QPen pen; |
3733 QPen pen; |
3717 pen.setWidthF(penWidth); |
3734 pen.setWidthF(penWidth); |
3718 rect->setPen(pen); |
3735 rect->setPen(pen); |
3719 |
3736 |
3720 // Add item to a scene. |
3737 // Add item to a scene. |
3721 QGraphicsScene scene(-100, -100, 200, 200); |
3738 QGraphicsScene scene(-100, -100, 200, 200); |
|
3739 if (changedConnected) |
|
3740 QObject::connect(&scene, SIGNAL(changed(QList<QRectF>)), this, SLOT(dummySlot())); |
|
3741 |
3722 scene.addItem(rect); |
3742 scene.addItem(rect); |
3723 |
3743 |
3724 // Create a view on the scene. |
3744 // Create a view on the scene. |
3725 CustomView view(&scene); |
3745 CustomView view(&scene); |
3726 view.setOptimizationFlag(QGraphicsView::DontAdjustForAntialiasing, !antialiasing); |
3746 view.setOptimizationFlag(QGraphicsView::DontAdjustForAntialiasing, !antialiasing); |