diff options
Diffstat (limited to 'tests/auto/widgets/graphicsview')
11 files changed, 183 insertions, 161 deletions
diff --git a/tests/auto/widgets/graphicsview/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp b/tests/auto/widgets/graphicsview/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp index 67e1f9ce30..2f5fc597dc 100644 --- a/tests/auto/widgets/graphicsview/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp +++ b/tests/auto/widgets/graphicsview/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp @@ -91,7 +91,7 @@ public: { Q_UNUSED(option); Q_UNUSED(widget); - painter->drawRoundRect(rect()); + painter->drawRoundedRect(rect(), 25, 25, Qt::RelativeSize); painter->drawLine(rect().topLeft(), rect().bottomRight()); painter->drawLine(rect().bottomLeft(), rect().topRight()); } diff --git a/tests/auto/widgets/graphicsview/qgraphicseffectsource/tst_qgraphicseffectsource.cpp b/tests/auto/widgets/graphicsview/qgraphicseffectsource/tst_qgraphicseffectsource.cpp index e7d26622c9..973a73a4a9 100644 --- a/tests/auto/widgets/graphicsview/qgraphicseffectsource/tst_qgraphicseffectsource.cpp +++ b/tests/auto/widgets/graphicsview/qgraphicseffectsource/tst_qgraphicseffectsource.cpp @@ -183,6 +183,7 @@ void tst_QGraphicsEffectSource::init() effect->storeDeviceDependentStuff = false; effect->doNothingInDraw = false; item->reset(); + QCoreApplication::processEvents(); // Process all queued paint events } void tst_QGraphicsEffectSource::graphicsItem() diff --git a/tests/auto/widgets/graphicsview/qgraphicsgridlayout/tst_qgraphicsgridlayout.cpp b/tests/auto/widgets/graphicsview/qgraphicsgridlayout/tst_qgraphicsgridlayout.cpp index 34646a9074..2f0c43552f 100644 --- a/tests/auto/widgets/graphicsview/qgraphicsgridlayout/tst_qgraphicsgridlayout.cpp +++ b/tests/auto/widgets/graphicsview/qgraphicsgridlayout/tst_qgraphicsgridlayout.cpp @@ -125,7 +125,7 @@ public: { Q_UNUSED(option); Q_UNUSED(widget); - painter->drawRoundRect(rect()); + painter->drawRoundedRect(rect(), 25, 25, Qt::RelativeSize); painter->drawLine(rect().topLeft(), rect().bottomRight()); painter->drawLine(rect().bottomLeft(), rect().topRight()); } diff --git a/tests/auto/widgets/graphicsview/qgraphicsitem/BLACKLIST b/tests/auto/widgets/graphicsview/qgraphicsitem/BLACKLIST new file mode 100644 index 0000000000..e760042def --- /dev/null +++ b/tests/auto/widgets/graphicsview/qgraphicsitem/BLACKLIST @@ -0,0 +1,3 @@ +# QTBUG-74760 +[sorting] +opensuse-42.3 diff --git a/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp b/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp index 27eac03880..bca664c05b 100644 --- a/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp +++ b/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp @@ -301,8 +301,8 @@ private slots: void pos(); void scenePos(); void matrix(); - void sceneMatrix(); - void setMatrix(); + void sceneTransform(); + void setTransform(); void zValue(); void shape(); void contains(); @@ -552,8 +552,8 @@ void tst_QGraphicsItem::construction() QVERIFY(!item->acceptHoverEvents()); QVERIFY(!item->hasFocus()); QCOMPARE(item->pos(), QPointF()); - QCOMPARE(item->matrix(), QMatrix()); - QCOMPARE(item->sceneMatrix(), QMatrix()); + QCOMPARE(item->transform(), QTransform()); + QCOMPARE(item->sceneTransform(), QTransform()); QCOMPARE(item->zValue(), qreal(0)); QCOMPARE(item->sceneBoundingRect(), QRectF()); QCOMPARE(item->shape(), QPainterPath()); @@ -2116,68 +2116,68 @@ void tst_QGraphicsItem::scenePos() void tst_QGraphicsItem::matrix() { QGraphicsLineItem line; - QCOMPARE(line.matrix(), QMatrix()); - line.setMatrix(QMatrix().rotate(90)); - QCOMPARE(line.matrix(), QMatrix().rotate(90)); - line.setMatrix(QMatrix().rotate(90)); - QCOMPARE(line.matrix(), QMatrix().rotate(90)); - line.setMatrix(QMatrix().rotate(90), true); - QCOMPARE(line.matrix(), QMatrix().rotate(180)); - line.setMatrix(QMatrix().rotate(-90), true); - QCOMPARE(line.matrix(), QMatrix().rotate(90)); - line.resetMatrix(); - QCOMPARE(line.matrix(), QMatrix()); + QCOMPARE(line.transform(), QTransform()); + line.setTransform(QTransform().rotate(90)); + QCOMPARE(line.transform(), QTransform().rotate(90)); + line.setTransform(QTransform().rotate(90)); + QCOMPARE(line.transform(), QTransform().rotate(90)); + line.setTransform(QTransform().rotate(90), true); + QCOMPARE(line.transform(), QTransform().rotate(180)); + line.setTransform(QTransform().rotate(-90), true); + QCOMPARE(line.transform(), QTransform().rotate(90)); + line.resetTransform(); + QCOMPARE(line.transform(), QTransform()); line.setTransform(QTransform().rotate(90), true); - QCOMPARE(line.matrix(), QMatrix().rotate(90)); + QCOMPARE(line.transform(), QTransform().rotate(90)); line.setTransform(QTransform().rotate(90), true); - QCOMPARE(line.matrix(), QMatrix().rotate(90).rotate(90)); - line.resetMatrix(); + QCOMPARE(line.transform(), QTransform().rotate(90).rotate(90)); + line.resetTransform(); line.setTransform(QTransform::fromScale(2, 4), true); - QCOMPARE(line.matrix(), QMatrix().scale(2, 4)); + QCOMPARE(line.transform(), QTransform::fromScale(2, 4)); line.setTransform(QTransform::fromScale(2, 4), true); - QCOMPARE(line.matrix(), QMatrix().scale(2, 4).scale(2, 4)); - line.resetMatrix(); + QCOMPARE(line.transform(), QTransform::fromScale(2, 4).scale(2, 4)); + line.resetTransform(); line.setTransform(QTransform().shear(2, 4), true); - QCOMPARE(line.matrix(), QMatrix().shear(2, 4)); + QCOMPARE(line.transform(), QTransform().shear(2, 4)); line.setTransform(QTransform().shear(2, 4), true); - QCOMPARE(line.matrix(), QMatrix().shear(2, 4).shear(2, 4)); - line.resetMatrix(); + QCOMPARE(line.transform(), QTransform().shear(2, 4).shear(2, 4)); + line.resetTransform(); line.setTransform(QTransform::fromTranslate(10, 10), true); - QCOMPARE(line.matrix(), QMatrix().translate(10, 10)); + QCOMPARE(line.transform(), QTransform::fromTranslate(10, 10)); line.setTransform(QTransform::fromTranslate(10, 10), true); - QCOMPARE(line.matrix(), QMatrix().translate(10, 10).translate(10, 10)); - line.resetMatrix(); + QCOMPARE(line.transform(), QTransform::fromTranslate(10, 10).translate(10, 10)); + line.resetTransform(); } -void tst_QGraphicsItem::sceneMatrix() +void tst_QGraphicsItem::sceneTransform() { QGraphicsLineItem *parent = new QGraphicsLineItem; QGraphicsLineItem *child = new QGraphicsLineItem(QLineF(), parent); - QCOMPARE(parent->sceneMatrix(), QMatrix()); - QCOMPARE(child->sceneMatrix(), QMatrix()); + QCOMPARE(parent->sceneTransform(), QTransform()); + QCOMPARE(child->sceneTransform(), QTransform()); parent->setTransform(QTransform::fromTranslate(10, 10), true); - QCOMPARE(parent->sceneMatrix(), QMatrix().translate(10, 10)); - QCOMPARE(child->sceneMatrix(), QMatrix().translate(10, 10)); + QCOMPARE(parent->sceneTransform(), QTransform().translate(10, 10)); + QCOMPARE(child->sceneTransform(), QTransform().translate(10, 10)); child->setTransform(QTransform::fromTranslate(10, 10), true); - QCOMPARE(parent->sceneMatrix(), QMatrix().translate(10, 10)); - QCOMPARE(child->sceneMatrix(), QMatrix().translate(20, 20)); + QCOMPARE(parent->sceneTransform(), QTransform().translate(10, 10)); + QCOMPARE(child->sceneTransform(), QTransform().translate(20, 20)); parent->setTransform(QTransform().rotate(90), true); - QCOMPARE(parent->sceneMatrix(), QMatrix().translate(10, 10).rotate(90)); - QCOMPARE(child->sceneMatrix(), QMatrix().translate(10, 10).rotate(90).translate(10, 10)); + QCOMPARE(parent->sceneTransform(), QTransform().translate(10, 10).rotate(90)); + QCOMPARE(child->sceneTransform(), QTransform().translate(10, 10).rotate(90).translate(10, 10)); delete child; delete parent; } -void tst_QGraphicsItem::setMatrix() +void tst_QGraphicsItem::setTransform() { QGraphicsScene scene; QSignalSpy spy(&scene, SIGNAL(changed(QList<QRectF>))); @@ -2190,7 +2190,7 @@ void tst_QGraphicsItem::setMatrix() QCOMPARE(spy.count(), 1); - item.setMatrix(QMatrix().rotate(qreal(12.34))); + item.setTransform(QTransform().rotate(qreal(12.34))); QRectF rotatedRect = scene.sceneRect(); QVERIFY(unrotatedRect != rotatedRect); scene.update(scene.sceneRect()); @@ -2198,7 +2198,7 @@ void tst_QGraphicsItem::setMatrix() QCOMPARE(spy.count(), 2); - item.setMatrix(QMatrix()); + item.setTransform(QTransform()); scene.update(scene.sceneRect()); QApplication::instance()->processEvents(); @@ -2485,25 +2485,25 @@ void tst_QGraphicsItem::collidesWith_item() void tst_QGraphicsItem::collidesWith_path_data() { QTest::addColumn<QPointF>("pos"); - QTest::addColumn<QMatrix>("matrix"); + QTest::addColumn<QTransform>("transform"); QTest::addColumn<QPainterPath>("shape"); QTest::addColumn<bool>("rectCollides"); QTest::addColumn<bool>("ellipseCollides"); - QTest::newRow("nothing") << QPointF(0, 0) << QMatrix() << QPainterPath() << false << false; + QTest::newRow("nothing") << QPointF(0, 0) << QTransform() << QPainterPath() << false << false; QPainterPath rect; rect.addRect(0, 0, 20, 20); - QTest::newRow("rect1") << QPointF(0, 0) << QMatrix() << rect << true << true; - QTest::newRow("rect2") << QPointF(0, 0) << QMatrix().translate(21, 21) << rect << false << false; - QTest::newRow("rect3") << QPointF(21, 21) << QMatrix() << rect << false << false; + QTest::newRow("rect1") << QPointF(0, 0) << QTransform() << rect << true << true; + QTest::newRow("rect2") << QPointF(0, 0) << QTransform::fromTranslate(21, 21) << rect << false << false; + QTest::newRow("rect3") << QPointF(21, 21) << QTransform() << rect << false << false; } void tst_QGraphicsItem::collidesWith_path() { QFETCH(QPointF, pos); - QFETCH(QMatrix, matrix); + QFETCH(QTransform, transform); QFETCH(QPainterPath, shape); QFETCH(bool, rectCollides); QFETCH(bool, ellipseCollides); @@ -2512,12 +2512,12 @@ void tst_QGraphicsItem::collidesWith_path() QGraphicsEllipseItem ellipse(QRectF(0, 0, 20, 20)); rect.setPos(pos); - rect.setMatrix(matrix); + rect.setTransform(transform); ellipse.setPos(pos); - ellipse.setMatrix(matrix); + ellipse.setTransform(transform); - QPainterPath mappedShape = rect.sceneMatrix().inverted().map(shape); + QPainterPath mappedShape = rect.sceneTransform().inverted().map(shape); if (rectCollides) QVERIFY(rect.collidesWithPath(mappedShape)); @@ -2742,35 +2742,35 @@ void tst_QGraphicsItem::mapFromToParent() item4->setPos(10, 10); for (int i = 0; i < 4; ++i) { - QMatrix matrix; - matrix.rotate(i * 90); - matrix.translate(i * 100, -i * 100); - matrix.scale(2, 4); - item1->setMatrix(matrix); + QTransform transform; + transform.rotate(i * 90); + transform.translate(i * 100, -i * 100); + transform.scale(2, 4); + item1->setTransform(transform); - QCOMPARE(item1->mapToParent(QPointF(0, 0)), item1->pos() + matrix.map(QPointF(0, 0))); + QCOMPARE(item1->mapToParent(QPointF(0, 0)), item1->pos() + transform.map(QPointF(0, 0))); QCOMPARE(item2->mapToParent(QPointF(0, 0)), item2->pos()); QCOMPARE(item3->mapToParent(QPointF(0, 0)), item3->pos()); QCOMPARE(item4->mapToParent(QPointF(0, 0)), item4->pos()); - QCOMPARE(item1->mapToParent(QPointF(10, -10)), item1->pos() + matrix.map(QPointF(10, -10))); + QCOMPARE(item1->mapToParent(QPointF(10, -10)), item1->pos() + transform.map(QPointF(10, -10))); QCOMPARE(item2->mapToParent(QPointF(10, -10)), item2->pos() + QPointF(10, -10)); QCOMPARE(item3->mapToParent(QPointF(10, -10)), item3->pos() + QPointF(10, -10)); QCOMPARE(item4->mapToParent(QPointF(10, -10)), item4->pos() + QPointF(10, -10)); - QCOMPARE(item1->mapToParent(QPointF(-10, 10)), item1->pos() + matrix.map(QPointF(-10, 10))); + QCOMPARE(item1->mapToParent(QPointF(-10, 10)), item1->pos() + transform.map(QPointF(-10, 10))); QCOMPARE(item2->mapToParent(QPointF(-10, 10)), item2->pos() + QPointF(-10, 10)); QCOMPARE(item3->mapToParent(QPointF(-10, 10)), item3->pos() + QPointF(-10, 10)); QCOMPARE(item4->mapToParent(QPointF(-10, 10)), item4->pos() + QPointF(-10, 10)); - QCOMPARE(item1->mapFromParent(item1->pos()), matrix.inverted().map(QPointF(0, 0))); + QCOMPARE(item1->mapFromParent(item1->pos()), transform.inverted().map(QPointF(0, 0))); QCOMPARE(item2->mapFromParent(item2->pos()), QPointF(0, 0)); QCOMPARE(item3->mapFromParent(item3->pos()), QPointF(0, 0)); QCOMPARE(item4->mapFromParent(item4->pos()), QPointF(0, 0)); QCOMPARE(item1->mapFromParent(item1->pos() + QPointF(10, -10)), - matrix.inverted().map(QPointF(10, -10))); + transform.inverted().map(QPointF(10, -10))); QCOMPARE(item2->mapFromParent(item2->pos() + QPointF(10, -10)), QPointF(10, -10)); QCOMPARE(item3->mapFromParent(item3->pos() + QPointF(10, -10)), QPointF(10, -10)); QCOMPARE(item4->mapFromParent(item4->pos() + QPointF(10, -10)), QPointF(10, -10)); QCOMPARE(item1->mapFromParent(item1->pos() + QPointF(-10, 10)), - matrix.inverted().map(QPointF(-10, 10))); + transform.inverted().map(QPointF(-10, 10))); QCOMPARE(item2->mapFromParent(item2->pos() + QPointF(-10, 10)), QPointF(-10, 10)); QCOMPARE(item3->mapFromParent(item3->pos() + QPointF(-10, 10)), QPointF(-10, 10)); QCOMPARE(item4->mapFromParent(item4->pos() + QPointF(-10, 10)), QPointF(-10, 10)); @@ -2820,8 +2820,8 @@ void tst_QGraphicsItem::mapFromToScene() QCOMPARE(item4->mapFromScene(410, 400), QPointF(10, 0)); // Rotate item1 90 degrees clockwise - QMatrix matrix; matrix.rotate(90); - item1->setMatrix(matrix); + QTransform transform; transform.rotate(90); + item1->setTransform(transform); QCOMPARE(item1->pos(), item1->mapToParent(0, 0)); QCOMPARE(item2->pos(), item2->mapToParent(0, 0)); QCOMPARE(item3->pos(), item3->mapToParent(0, 0)); @@ -2848,7 +2848,7 @@ void tst_QGraphicsItem::mapFromToScene() QCOMPARE(item4->mapFromScene(-200, 410), QPointF(10, 0)); // Rotate item2 90 degrees clockwise - item2->setMatrix(matrix); + item2->setTransform(transform); QCOMPARE(item1->pos(), item1->mapToParent(0, 0)); QCOMPARE(item2->pos(), item2->mapToParent(0, 0)); QCOMPARE(item3->pos(), item3->mapToParent(0, 0)); @@ -2875,10 +2875,10 @@ void tst_QGraphicsItem::mapFromToScene() QCOMPARE(item4->mapFromScene(-210, 0), QPointF(10, 0)); // Translate item3 50 points, then rotate 90 degrees counterclockwise - QMatrix matrix2; - matrix2.translate(50, 0); - matrix2.rotate(-90); - item3->setMatrix(matrix2); + QTransform transform2; + transform2.translate(50, 0); + transform2.rotate(-90); + item3->setTransform(transform2); QCOMPARE(item1->pos(), item1->mapToParent(0, 0)); QCOMPARE(item2->pos(), item2->mapToParent(0, 0)); QCOMPARE(item3->pos(), item3->mapToParent(0, 0) - QPointF(50, 0)); @@ -2928,9 +2928,9 @@ void tst_QGraphicsItem::mapFromToItem() QCOMPARE(item3->mapFromItem(item2, 0, 0), QPointF(0, -200)); QCOMPARE(item4->mapFromItem(item3, 0, 0), QPointF(200, 0)); - QMatrix matrix; - matrix.translate(100, 100); - item1->setMatrix(matrix); + QTransform transform; + transform.translate(100, 100); + item1->setTransform(transform); QCOMPARE(item1->mapFromItem(item2, 0, 0), QPointF(100, -100)); QCOMPARE(item2->mapFromItem(item3, 0, 0), QPointF(0, 200)); @@ -2941,11 +2941,11 @@ void tst_QGraphicsItem::mapFromToItem() QCOMPARE(item3->mapFromItem(item2, 0, 0), QPointF(0, -200)); QCOMPARE(item4->mapFromItem(item3, 0, 0), QPointF(200, 0)); - matrix.rotate(90); - item1->setMatrix(matrix); - item2->setMatrix(matrix); - item3->setMatrix(matrix); - item4->setMatrix(matrix); + transform.rotate(90); + item1->setTransform(transform); + item2->setTransform(transform); + item3->setTransform(transform); + item4->setTransform(transform); QCOMPARE(item1->mapFromItem(item2, 0, 0), QPointF(0, -200)); QCOMPARE(item2->mapFromItem(item3, 0, 0), QPointF(200, 0)); @@ -3231,6 +3231,7 @@ void tst_QGraphicsItem::hoverEventsGenerateRepaints() view.show(); QVERIFY(QTest::qWaitForWindowExposed(&view)); QVERIFY(QTest::qWaitForWindowActive(&view)); + QCoreApplication::processEvents(); // Process all queued paint events EventTester *tester = new EventTester; scene.addItem(tester); @@ -4147,11 +4148,9 @@ void tst_QGraphicsItem::ensureVisible() void tst_QGraphicsItem::cursor() { QGraphicsScene scene; - QWidget topLevel; - QGraphicsView view(&scene,&topLevel); - topLevel.showMaximized(); - QVERIFY(QTest::qWaitForWindowExposed(&topLevel)); - view.setFixedSize(topLevel.size()); + QGraphicsView view(&scene); + view.showFullScreen(); + QVERIFY(QTest::qWaitForWindowExposed(&view)); QGraphicsRectItem *item1 = scene.addRect(QRectF(-100, 0, 50, 50)); QGraphicsRectItem *item2 = scene.addRect(QRectF(50, 0, 50, 50)); @@ -4434,9 +4433,12 @@ protected: case QGraphicsItem::ItemPositionHasChanged: break; case QGraphicsItem::ItemMatrixChange: { +QT_WARNING_PUSH +QT_WARNING_DISABLE_DEPRECATED QVariant variant; variant.setValue<QMatrix>(matrix()); oldValues << variant; +QT_WARNING_POP } break; case QGraphicsItem::ItemTransformChange: { @@ -4557,6 +4559,8 @@ void tst_QGraphicsItem::itemChange() QCOMPARE(tester.isEnabled(), true); } { +QT_WARNING_PUSH +QT_WARNING_DISABLE_DEPRECATED // QDesktopWidget::screen() // ItemMatrixChange / ItemTransformHasChanged tester.itemChangeReturnValue.setValue<QMatrix>(QMatrix().rotate(90)); tester.setMatrix(QMatrix().translate(50, 0), true); @@ -4571,6 +4575,7 @@ void tst_QGraphicsItem::itemChange() variant.setValue<QMatrix>(QMatrix()); QCOMPARE(tester.oldValues.last(), variant); QCOMPARE(tester.matrix(), QMatrix().rotate(90)); +QT_WARNING_POP } { tester.resetTransform(); @@ -5074,13 +5079,11 @@ void tst_QGraphicsItem::paint() QGraphicsView view2(&scene2); view2.show(); QVERIFY(QTest::qWaitForWindowExposed(&view2)); + QCoreApplication::processEvents(); // Process all queued paint events PaintTester tester2; scene2.addItem(&tester2); -#ifdef Q_OS_WINRT - QEXPECT_FAIL("", "Fails on WinRT. Figure out why - QTBUG-68297", Abort); -#endif //First show one paint QTRY_COMPARE(tester2.painted, 1); @@ -6534,11 +6537,9 @@ void tst_QGraphicsItem::ensureUpdateOnTextItem() QGraphicsView view(&scene); view.show(); QVERIFY(QTest::qWaitForWindowExposed(&view)); + QCoreApplication::processEvents(); // Process all queued paint events TextItem *text1 = new TextItem(QLatin1String("123")); scene.addItem(text1); -#ifdef Q_OS_WINRT - QEXPECT_FAIL("", "Fails on WinRT. Figure out why - QTBUG-68297", Abort); -#endif QTRY_COMPARE(text1->updates,1); //same bouding rect but we have to update @@ -6810,6 +6811,7 @@ void tst_QGraphicsItem::opacity2() view.show(); QVERIFY(QTest::qWaitForWindowExposed(&view)); QVERIFY(QTest::qWaitForWindowActive(&view)); + QCoreApplication::processEvents(); // Process all queued paint events QTRY_VERIFY(view.repaints >= 1); #define RESET_REPAINT_COUNTERS \ @@ -6883,6 +6885,7 @@ void tst_QGraphicsItem::opacityZeroUpdates() view.show(); QVERIFY(QTest::qWaitForWindowExposed(&view)); QVERIFY(QTest::qWaitForWindowActive(&view)); + QCoreApplication::processEvents(); // Process all queued paint events QTRY_VERIFY(view.repaints > 0); view.reset(); @@ -7275,6 +7278,7 @@ void tst_QGraphicsItem::cacheMode() QApplication::setActiveWindow(&view); QVERIFY(QTest::qWaitForWindowExposed(&view)); QVERIFY(QTest::qWaitForWindowActive(&view)); + QCoreApplication::processEvents(); // Process all queued paint events EventTester *tester = new EventTester; EventTester *testerChild = new EventTester; @@ -7454,6 +7458,7 @@ void tst_QGraphicsItem::cacheMode2() QApplication::setActiveWindow(&view); QVERIFY(QTest::qWaitForWindowExposed(&view)); QVERIFY(QTest::qWaitForWindowActive(&view)); + QCoreApplication::processEvents(); // Process all queued paint events EventTester *tester = new EventTester; scene.addItem(tester); @@ -7944,6 +7949,7 @@ void tst_QGraphicsItem::itemUsesExtendedStyleOption() rect->startTrack = false; topLevel.show(); QVERIFY(QTest::qWaitForWindowExposed(&topLevel)); + QCoreApplication::processEvents(); // Process all queued paint events QTRY_VERIFY(rect->repaints > 0); rect->repaints = 0; rect->startTrack = true; @@ -8030,6 +8036,7 @@ void tst_QGraphicsItem::moveItem() MyGraphicsView view(&scene); view.show(); QVERIFY(QTest::qWaitForWindowExposed(&view)); + QCoreApplication::processEvents(); // Process all queued paint events EventTester *parent = new EventTester; EventTester *child = new EventTester(parent); @@ -8108,6 +8115,7 @@ void tst_QGraphicsItem::moveLineItem() view.show(); QVERIFY(QTest::qWaitForWindowExposed(&view)); QVERIFY(QTest::qWaitForWindowActive(&view)); + QCoreApplication::processEvents(); // Process all queued paint events view.reset(); QRectF brect = item->boundingRect(); @@ -8288,6 +8296,7 @@ void tst_QGraphicsItem::hitTestGraphicsEffectItem() toplevel.resize(300, 300); toplevel.show(); QVERIFY(QTest::qWaitForWindowExposed(&toplevel)); + QCoreApplication::processEvents(); // Process all queued paint events // Confuse the BSP with dummy items. QGraphicsRectItem *dummy = new QGraphicsRectItem(0, 0, 20, 20); @@ -11266,6 +11275,7 @@ void tst_QGraphicsItem::QTBUG_6738_missingUpdateWithSetParent() qApp->setActiveWindow(&view); QVERIFY(QTest::qWaitForWindowExposed(&view)); QVERIFY(QTest::qWaitForWindowActive(&view)); + QCoreApplication::processEvents(); // Process all queued paint events QTRY_VERIFY(view.repaints > 0); // test case #1 @@ -11315,6 +11325,7 @@ void tst_QGraphicsItem::QT_2653_fullUpdateDiscardingOpacityUpdate() view.show(); QVERIFY(QTest::qWaitForWindowExposed(&view)); QVERIFY(QTest::qWaitForWindowActive(&view)); + QCoreApplication::processEvents(); // Process all queued paint events view.reset(); parentGreen->setOpacity(1.0); @@ -11348,7 +11359,9 @@ void tst_QGraphicsItem::QTBUG_7714_fullUpdateDiscardingOpacityUpdate2() origView.show(); QVERIFY(QTest::qWaitForWindowActive(&origView)); - origView.setGeometry(origView.width() + 20, 20, + QCoreApplication::processEvents(); // Process all queued paint events + + origView.setGeometry(origView.x() + origView.width() + 20, origView.y() + 20, origView.width(), origView.height()); parentGreen->setFlag(QGraphicsItem::ItemIgnoresTransformations); @@ -11356,9 +11369,6 @@ void tst_QGraphicsItem::QTBUG_7714_fullUpdateDiscardingOpacityUpdate2() origView.reset(); childYellow->setOpacity(0.0); -#ifdef Q_OS_WINRT - QEXPECT_FAIL("", "Fails on WinRT. Figure out why - QTBUG-68297", Abort); -#endif QTRY_COMPARE(origView.repaints, 1); view.show(); @@ -11370,6 +11380,10 @@ void tst_QGraphicsItem::QTBUG_7714_fullUpdateDiscardingOpacityUpdate2() childYellow->setOpacity(1.0); +#ifdef Q_OS_WINRT + QEXPECT_FAIL("", "Fails on WinRT. Figure out why - QTBUG-68297", Abort); +#endif + QTRY_COMPARE(origView.repaints, 1); QTRY_COMPARE(view.repaints, 1); } @@ -11505,6 +11519,7 @@ void tst_QGraphicsItem::doNotMarkFullUpdateIfNotInScene() view.show(); QVERIFY(QTest::qWaitForWindowExposed(view.windowHandle())); QVERIFY(QTest::qWaitForWindowActive(view.windowHandle())); + QCoreApplication::processEvents(); // Process all queued paint events view.activateWindow(); QTRY_VERIFY(view.isActiveWindow()); QTRY_VERIFY(view.repaints >= 1); diff --git a/tests/auto/widgets/graphicsview/qgraphicsitemanimation/tst_qgraphicsitemanimation.cpp b/tests/auto/widgets/graphicsview/qgraphicsitemanimation/tst_qgraphicsitemanimation.cpp index dfb2752ee0..ed79904ed8 100644 --- a/tests/auto/widgets/graphicsview/qgraphicsitemanimation/tst_qgraphicsitemanimation.cpp +++ b/tests/auto/widgets/graphicsview/qgraphicsitemanimation/tst_qgraphicsitemanimation.cpp @@ -54,9 +54,9 @@ void tst_QGraphicsItemAnimation::construction() QCOMPARE(animation.posAt(0), QPointF()); QCOMPARE(animation.posAt(0.5), QPointF()); QCOMPARE(animation.posAt(1), QPointF()); - QCOMPARE(animation.matrixAt(0), QMatrix()); - QCOMPARE(animation.matrixAt(0.5), QMatrix()); - QCOMPARE(animation.matrixAt(1), QMatrix()); + QCOMPARE(animation.transformAt(0), QTransform()); + QCOMPARE(animation.transformAt(0.5), QTransform()); + QCOMPARE(animation.transformAt(1), QTransform()); QCOMPARE(animation.rotationAt(0), qreal(0.0)); QCOMPARE(animation.rotationAt(0.5), qreal(0.0)); QCOMPARE(animation.rotationAt(1), qreal(0.0)); diff --git a/tests/auto/widgets/graphicsview/qgraphicslinearlayout/tst_qgraphicslinearlayout.cpp b/tests/auto/widgets/graphicsview/qgraphicslinearlayout/tst_qgraphicslinearlayout.cpp index f9b6fe3ebd..9369470ce5 100644 --- a/tests/auto/widgets/graphicsview/qgraphicslinearlayout/tst_qgraphicslinearlayout.cpp +++ b/tests/auto/widgets/graphicsview/qgraphicslinearlayout/tst_qgraphicslinearlayout.cpp @@ -150,7 +150,7 @@ public: Q_UNUSED(option); Q_UNUSED(widget); painter->setBrush(m_brush); - painter->drawRoundRect(rect()); + painter->drawRoundedRect(rect(), 25, 25, Qt::RelativeSize); } void setSizeHint(Qt::SizeHint which, const QSizeF &size) { diff --git a/tests/auto/widgets/graphicsview/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp b/tests/auto/widgets/graphicsview/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp index 49afc5f369..4a301337ef 100644 --- a/tests/auto/widgets/graphicsview/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp +++ b/tests/auto/widgets/graphicsview/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp @@ -140,6 +140,7 @@ private slots: void palettePropagation(); void fontPropagation(); void dontCrashWhenDie(); + void dontCrashNoParent(); void createProxyForChildWidget(); #ifndef QT_NO_CONTEXTMENU void actionsContextMenu(); @@ -2964,6 +2965,20 @@ void tst_QGraphicsProxyWidget::dontCrashWhenDie() qDeleteAll(QApplication::topLevelWidgets()); } +void tst_QGraphicsProxyWidget::dontCrashNoParent() // QTBUG-15442 +{ + QGraphicsProxyWidget *parent(new QGraphicsProxyWidget); + QGraphicsProxyWidget *child(new QGraphicsProxyWidget); + QScopedPointer<QLabel> label0(new QLabel); + QScopedPointer<QLabel> label1(new QLabel); + + child->setParentItem(parent); + // Set the first label as the proxied widget. + parent->setWidget(label0.data()); + // If we attempt to change the proxied widget we get a crash. + parent->setWidget(label1.data()); +} + void tst_QGraphicsProxyWidget::createProxyForChildWidget() { QGraphicsScene scene; diff --git a/tests/auto/widgets/graphicsview/qgraphicsscene/BLACKLIST b/tests/auto/widgets/graphicsview/qgraphicsscene/BLACKLIST index 0e7a1b451f..b8b427b3dd 100644 --- a/tests/auto/widgets/graphicsview/qgraphicsscene/BLACKLIST +++ b/tests/auto/widgets/graphicsview/qgraphicsscene/BLACKLIST @@ -1,10 +1,6 @@ -[removeItem] -# QTBUG-60754, QTest::mouseMove is not always respected, or the CI moves the cursor -osx-10.11 ci [isActive] opensuse-42.3 ci [removeFullyTransparentItem] -osx-10.11 osx-10.12 [tabFocus_sceneWithNestedFocusWidgets] opensuse diff --git a/tests/auto/widgets/graphicsview/qgraphicsscene/tst_qgraphicsscene.cpp b/tests/auto/widgets/graphicsview/qgraphicsscene/tst_qgraphicsscene.cpp index 838b1f4be6..46f1d5df5c 100644 --- a/tests/auto/widgets/graphicsview/qgraphicsscene/tst_qgraphicsscene.cpp +++ b/tests/auto/widgets/graphicsview/qgraphicsscene/tst_qgraphicsscene.cpp @@ -112,14 +112,14 @@ protected: painter->setOpacity(0.75); painter->setPen(Qt::NoPen); painter->setBrush(Qt::darkGray); - painter->drawRoundRect(boundingRect().adjusted(3, 3, -3, -3), Qt::darkGray); + painter->drawRoundedRect(boundingRect().adjusted(3, 3, -3, -3), 25, 25, Qt::RelativeSize); painter->setPen(Qt::black); if (isHovered) { - painter->setBrush(QColor(Qt::blue).light(120)); + painter->setBrush(QColor(Qt::blue).lighter(120)); } else { painter->setBrush(Qt::gray); } - painter->drawRoundRect(boundingRect().adjusted(0, 0, -5, -5)); + painter->drawRoundedRect(boundingRect().adjusted(0, 0, -5, -5), 25, 25, Qt::RelativeSize); } }; @@ -233,7 +233,6 @@ private slots: void tabFocus_sceneWithFocusWidgets(); void tabFocus_sceneWithNestedFocusWidgets(); void style(); - void sorting_data(); void sorting(); void insertionOrder(); void changedSignal_data(); @@ -459,41 +458,41 @@ void tst_QGraphicsScene::items() void tst_QGraphicsScene::itemsBoundingRect_data() { QTest::addColumn<QList<QRectF> >("rects"); - QTest::addColumn<QMatrix>("matrix"); + QTest::addColumn<QTransform>("transform"); QTest::addColumn<QRectF>("boundingRect"); - QMatrix transformationMatrix; - transformationMatrix.translate(50, -50); - transformationMatrix.scale(2, 2); - transformationMatrix.rotate(90); + QTransform transformation; + transformation.translate(50, -50); + transformation.scale(2, 2); + transformation.rotate(90); QTest::newRow("none") << QList<QRectF>() - << QMatrix() + << QTransform() << QRectF(); QTest::newRow("{{0, 0, 10, 10}}") << (QList<QRectF>() << QRectF(0, 0, 10, 10)) - << QMatrix() + << QTransform() << QRectF(0, 0, 10, 10); QTest::newRow("{{-10, -10, 10, 10}}") << (QList<QRectF>() << QRectF(-10, -10, 10, 10)) - << QMatrix() + << QTransform() << QRectF(-10, -10, 10, 10); QTest::newRow("{{-1000, -1000, 1, 1}, {-10, -10, 10, 10}}") << (QList<QRectF>() << QRectF(-1000, -1000, 1, 1) << QRectF(-10, -10, 10, 10)) - << QMatrix() + << QTransform() << QRectF(-1000, -1000, 1000, 1000); QTest::newRow("transformed {{0, 0, 10, 10}}") << (QList<QRectF>() << QRectF(0, 0, 10, 10)) - << transformationMatrix + << transformation << QRectF(30, -50, 20, 20); QTest::newRow("transformed {{-10, -10, 10, 10}}") << (QList<QRectF>() << QRectF(-10, -10, 10, 10)) - << transformationMatrix + << transformation << QRectF(50, -70, 20, 20); QTest::newRow("transformed {{-1000, -1000, 1, 1}, {-10, -10, 10, 10}}") << (QList<QRectF>() << QRectF(-1000, -1000, 1, 1) << QRectF(-10, -10, 10, 10)) - << transformationMatrix + << transformation << QRectF(50, -2050, 2000, 2000); QList<QRectF> all; @@ -501,18 +500,18 @@ void tst_QGraphicsScene::itemsBoundingRect_data() all << QRectF(randomX[i], randomY[i], 10, 10); QTest::newRow("all") << all - << QMatrix() + << QTransform() << QRectF(-980, -994, 1988, 1983); QTest::newRow("transformed all") << all - << transformationMatrix + << transformation << QRectF(-1928, -2010, 3966, 3976); } void tst_QGraphicsScene::itemsBoundingRect() { QFETCH(QList<QRectF>, rects); - QFETCH(QMatrix, matrix); + QFETCH(QTransform, transform); QFETCH(QRectF, boundingRect); QGraphicsScene scene; @@ -522,7 +521,7 @@ void tst_QGraphicsScene::itemsBoundingRect() path.addRect(rect); QGraphicsPathItem *item = scene.addPath(path); item->setPen(QPen(Qt::black, 0)); - item->setMatrix(matrix); + item->setTransform(transform); } QCOMPARE(scene.itemsBoundingRect(), boundingRect); @@ -2502,7 +2501,7 @@ void tst_QGraphicsScene::render_data() QTest::addColumn<QRectF>("targetRect"); QTest::addColumn<QRectF>("sourceRect"); QTest::addColumn<Qt::AspectRatioMode>("aspectRatioMode"); - QTest::addColumn<QMatrix>("matrix"); + QTest::addColumn<QTransform>("transform"); QTest::addColumn<QPainterPath>("clip"); QPainterPath clip_rect; @@ -2512,61 +2511,61 @@ void tst_QGraphicsScene::render_data() clip_ellipse.addEllipse(100,50,150,200); QTest::newRow("all-all-untransformed") << QRectF() << QRectF() - << Qt::IgnoreAspectRatio << QMatrix() << QPainterPath(); + << Qt::IgnoreAspectRatio << QTransform() << QPainterPath(); QTest::newRow("all-topleft-untransformed") << QRectF(0, 0, 150, 150) - << QRectF() << Qt::IgnoreAspectRatio << QMatrix() << QPainterPath(); + << QRectF() << Qt::IgnoreAspectRatio << QTransform() << QPainterPath(); QTest::newRow("all-topright-untransformed") << QRectF(150, 0, 150, 150) - << QRectF() << Qt::IgnoreAspectRatio << QMatrix() << QPainterPath(); + << QRectF() << Qt::IgnoreAspectRatio << QTransform() << QPainterPath(); QTest::newRow("all-bottomleft-untransformed") << QRectF(0, 150, 150, 150) - << QRectF() << Qt::IgnoreAspectRatio << QMatrix() << QPainterPath(); + << QRectF() << Qt::IgnoreAspectRatio << QTransform() << QPainterPath(); QTest::newRow("all-bottomright-untransformed") << QRectF(150, 150, 150, 150) - << QRectF() << Qt::IgnoreAspectRatio << QMatrix() << QPainterPath(); + << QRectF() << Qt::IgnoreAspectRatio << QTransform() << QPainterPath(); QTest::newRow("topleft-all-untransformed") << QRectF() << QRectF(-10, -10, 10, 10) - << Qt::IgnoreAspectRatio << QMatrix() << QPainterPath(); + << Qt::IgnoreAspectRatio << QTransform() << QPainterPath(); QTest::newRow("topright-all-untransformed") << QRectF() << QRectF(0, -10, 10, 10) - << Qt::IgnoreAspectRatio << QMatrix() << QPainterPath(); + << Qt::IgnoreAspectRatio << QTransform() << QPainterPath(); QTest::newRow("bottomleft-all-untransformed") << QRectF() << QRectF(-10, 0, 10, 10) - << Qt::IgnoreAspectRatio << QMatrix() << QPainterPath(); + << Qt::IgnoreAspectRatio << QTransform() << QPainterPath(); QTest::newRow("bottomright-all-untransformed") << QRectF() << QRectF(0, 0, 10, 10) - << Qt::IgnoreAspectRatio << QMatrix() << QPainterPath(); + << Qt::IgnoreAspectRatio << QTransform() << QPainterPath(); QTest::newRow("topleft-topleft-untransformed") << QRectF(0, 0, 150, 150) << QRectF(-10, -10, 10, 10) - << Qt::IgnoreAspectRatio << QMatrix() << QPainterPath(); + << Qt::IgnoreAspectRatio << QTransform() << QPainterPath(); QTest::newRow("topright-topleft-untransformed") << QRectF(150, 0, 150, 150) << QRectF(-10, -10, 10, 10) - << Qt::IgnoreAspectRatio << QMatrix() << QPainterPath(); + << Qt::IgnoreAspectRatio << QTransform() << QPainterPath(); QTest::newRow("bottomleft-topleft-untransformed") << QRectF(0, 150, 150, 150) << QRectF(-10, -10, 10, 10) - << Qt::IgnoreAspectRatio << QMatrix() << QPainterPath(); + << Qt::IgnoreAspectRatio << QTransform() << QPainterPath(); QTest::newRow("bottomright-topleft-untransformed") << QRectF(150, 150, 150, 150) << QRectF(-10, -10, 10, 10) - << Qt::IgnoreAspectRatio << QMatrix() << QPainterPath(); + << Qt::IgnoreAspectRatio << QTransform() << QPainterPath(); QTest::newRow("top-topleft-untransformed") << QRectF(0, 0, 300, 150) << QRectF(-10, -10, 10, 10) - << Qt::IgnoreAspectRatio << QMatrix() << QPainterPath(); + << Qt::IgnoreAspectRatio << QTransform() << QPainterPath(); QTest::newRow("bottom-topleft-untransformed") << QRectF(0, 150, 300, 150) << QRectF(-10, -10, 10, 10) - << Qt::IgnoreAspectRatio << QMatrix() << QPainterPath(); + << Qt::IgnoreAspectRatio << QTransform() << QPainterPath(); QTest::newRow("left-topleft-untransformed") << QRectF(0, 0, 150, 300) << QRectF(-10, -10, 10, 10) - << Qt::IgnoreAspectRatio << QMatrix() << QPainterPath(); + << Qt::IgnoreAspectRatio << QTransform() << QPainterPath(); QTest::newRow("right-topleft-untransformed") << QRectF(150, 0, 150, 300) << QRectF(-10, -10, 10, 10) - << Qt::IgnoreAspectRatio << QMatrix() << QPainterPath(); + << Qt::IgnoreAspectRatio << QTransform() << QPainterPath(); QTest::newRow("top-bottomright-untransformed") << QRectF(0, 0, 300, 150) << QRectF(0, 0, 10, 10) - << Qt::IgnoreAspectRatio << QMatrix() << QPainterPath(); + << Qt::IgnoreAspectRatio << QTransform() << QPainterPath(); QTest::newRow("bottom-bottomright-untransformed") << QRectF(0, 150, 300, 150) << QRectF(0, 0, 10, 10) - << Qt::IgnoreAspectRatio << QMatrix() << QPainterPath(); + << Qt::IgnoreAspectRatio << QTransform() << QPainterPath(); QTest::newRow("left-bottomright-untransformed") << QRectF(0, 0, 150, 300) << QRectF(0, 0, 10, 10) - << Qt::IgnoreAspectRatio << QMatrix() << QPainterPath(); + << Qt::IgnoreAspectRatio << QTransform() << QPainterPath(); QTest::newRow("right-bottomright-untransformed") << QRectF(150, 0, 150, 300) << QRectF(0, 0, 10, 10) - << Qt::IgnoreAspectRatio << QMatrix() << QPainterPath(); + << Qt::IgnoreAspectRatio << QTransform() << QPainterPath(); QTest::newRow("all-all-45-deg-right") << QRectF() << QRectF() - << Qt::IgnoreAspectRatio << QMatrix().rotate(-45) << QPainterPath(); + << Qt::IgnoreAspectRatio << QTransform().rotate(-45) << QPainterPath(); QTest::newRow("all-all-45-deg-left") << QRectF() << QRectF() - << Qt::IgnoreAspectRatio << QMatrix().rotate(45) << QPainterPath(); + << Qt::IgnoreAspectRatio << QTransform().rotate(45) << QPainterPath(); QTest::newRow("all-all-scale-2x") << QRectF() << QRectF() - << Qt::IgnoreAspectRatio << QMatrix().scale(2, 2) << QPainterPath(); + << Qt::IgnoreAspectRatio << QTransform::fromScale(2, 2) << QPainterPath(); QTest::newRow("all-all-translate-50-0") << QRectF() << QRectF() - << Qt::IgnoreAspectRatio << QMatrix().translate(50, 0) << QPainterPath(); + << Qt::IgnoreAspectRatio << QTransform::fromTranslate(50, 0) << QPainterPath(); QTest::newRow("all-all-translate-0-50") << QRectF() << QRectF() - << Qt::IgnoreAspectRatio << QMatrix().translate(0, 50) << QPainterPath(); + << Qt::IgnoreAspectRatio << QTransform::fromTranslate(0, 50) << QPainterPath(); QTest::newRow("all-all-untransformed-clip-rect") << QRectF() << QRectF() - << Qt::IgnoreAspectRatio << QMatrix() << clip_rect; + << Qt::IgnoreAspectRatio << QTransform() << clip_rect; QTest::newRow("all-all-untransformed-clip-ellipse") << QRectF() << QRectF() - << Qt::IgnoreAspectRatio << QMatrix() << clip_ellipse; + << Qt::IgnoreAspectRatio << QTransform() << clip_ellipse; } void tst_QGraphicsScene::render() @@ -2574,7 +2573,7 @@ void tst_QGraphicsScene::render() QFETCH(QRectF, targetRect); QFETCH(QRectF, sourceRect); QFETCH(Qt::AspectRatioMode, aspectRatioMode); - QFETCH(QMatrix, matrix); + QFETCH(QTransform, transform); QFETCH(QPainterPath, clip); QPixmap pix(30, 30); @@ -2602,7 +2601,7 @@ void tst_QGraphicsScene::render() painter.setPen(QPen(Qt::darkGray, 2)); painter.drawLine(0, 150, 300, 150); painter.drawLine(150, 0, 150, 300); - painter.setMatrix(matrix); + painter.setTransform(transform); if (!clip.isEmpty()) painter.setClipPath(clip); scene.render(&painter, targetRect, sourceRect, aspectRatioMode); painter.end(); @@ -3519,20 +3518,9 @@ void tst_QGraphicsScene::task250680_childClip() QCOMPARE(scene.items(QRectF(320, 240, 5, 5)).size(), 2); } -void tst_QGraphicsScene::sorting_data() -{ - QTest::addColumn<bool>("cache"); - - QTest::newRow("Normal sorting") << false; - QTest::newRow("Cached sorting") << true; -} - void tst_QGraphicsScene::sorting() { - QFETCH(bool, cache); - QGraphicsScene scene; - scene.setSortCacheEnabled(cache); QGraphicsRectItem *t_1 = new QGraphicsRectItem(0, 0, 50, 50); QGraphicsRectItem *c_1 = new QGraphicsRectItem(0, 0, 40, 40, t_1); @@ -4318,6 +4306,7 @@ void tst_QGraphicsScene::removeFullyTransparentItem() view.show(); qApp->setActiveWindow(&view); QVERIFY(QTest::qWaitForWindowActive(&view)); + QCoreApplication::processEvents(); // Process all queued paint events // NB! The parent has the ItemHasNoContents flag set, which means // the parent itself doesn't generate any update requests, only the diff --git a/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp b/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp index 3dc110298a..28df3a3c38 100644 --- a/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp +++ b/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp @@ -1650,6 +1650,7 @@ void tst_QGraphicsView::itemsInRect_cosmeticAdjust() QVERIFY(QTest::qWaitForWindowActive(&view)); QTRY_VERIFY(rect->numPaints > 0); + QCoreApplication::processEvents(); // Process all queued paint events rect->numPaints = 0; if (updateRect.isNull()) view.viewport()->update(); @@ -4074,6 +4075,8 @@ void tst_QGraphicsView::update() QTRY_COMPARE(view.lastUpdateRegions.at(0), QRegion(updateRect) & viewportRect); } QTRY_VERIFY(!viewPrivate->fullUpdatePending); +#else + Q_UNUSED(updateRect); #endif } |