diff options
Diffstat (limited to 'tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp')
-rw-r--r-- | tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp | 67 |
1 files changed, 49 insertions, 18 deletions
diff --git a/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp b/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp index 6c1abaedb3..bd08461544 100644 --- a/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp +++ b/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp @@ -477,7 +477,7 @@ private: void tst_QGraphicsItem::construction() { for (int i = 0; i < 7; ++i) { - QGraphicsItem *item; + QGraphicsItem *item = nullptr; switch (i) { case 0: item = new QGraphicsEllipseItem; @@ -986,6 +986,7 @@ void tst_QGraphicsItem::inputMethodHints() QGraphicsView view(&scene); QApplication::setActiveWindow(&view); view.show(); + QVERIFY(QTest::qWaitForWindowExposed(&view)); QVERIFY(QTest::qWaitForWindowActive(&view)); item->setFocus(); QTRY_VERIFY(item->hasFocus()); @@ -1036,6 +1037,7 @@ void tst_QGraphicsItem::toolTip() view.setFixedSize(200, 200); view.show(); QApplication::setActiveWindow(&view); + QVERIFY(QTest::qWaitForWindowExposed(&view)); QVERIFY(QTest::qWaitForWindowActive(&view)); { QHelpEvent helpEvent(QEvent::ToolTip, view.viewport()->rect().topLeft(), @@ -2204,10 +2206,11 @@ void tst_QGraphicsItem::setMatrix() QCOMPARE(spy.count(), 3); QList<QRectF> rlist = qvariant_cast<QList<QRectF> >(spy.last().at(0)); - QCOMPARE(rlist.size(), 3); - QCOMPARE(rlist.at(0), rotatedRect); // From item.setMatrix() (clearing rotated rect) - QCOMPARE(rlist.at(1), rotatedRect); // From scene.update() (updating scene rect) - QCOMPARE(rlist.at(2), unrotatedRect); // From post-update (update current state) + QCOMPARE(rlist.size(), 2); + // From item.setMatrix() (clearing rotated rect), from scene.update() (updating scene rect), + // squashed into one + QCOMPARE(rlist.at(0), rotatedRect); + QCOMPARE(rlist.at(1), unrotatedRect); // From post-update (update current state) } static QList<QGraphicsItem *> _paintedItems; @@ -3226,6 +3229,7 @@ void tst_QGraphicsItem::hoverEventsGenerateRepaints() QGraphicsScene scene; QGraphicsView view(&scene); view.show(); + QVERIFY(QTest::qWaitForWindowExposed(&view)); QVERIFY(QTest::qWaitForWindowActive(&view)); EventTester *tester = new EventTester; @@ -4143,10 +4147,13 @@ void tst_QGraphicsItem::ensureVisible() void tst_QGraphicsItem::cursor() { QGraphicsScene scene; - QGraphicsRectItem *item1 = scene.addRect(QRectF(0, 0, 50, 50)); - QGraphicsRectItem *item2 = scene.addRect(QRectF(0, 0, 50, 50)); - item1->setPos(-100, 0); - item2->setPos(50, 0); + QWidget topLevel; + QGraphicsView view(&scene,&topLevel); + topLevel.showMaximized(); + QVERIFY(QTest::qWaitForWindowExposed(&topLevel)); + view.setFixedSize(topLevel.size()); + QGraphicsRectItem *item1 = scene.addRect(QRectF(-100, 0, 50, 50)); + QGraphicsRectItem *item2 = scene.addRect(QRectF(50, 0, 50, 50)); QVERIFY(!item1->hasCursor()); QVERIFY(!item2->hasCursor()); @@ -4172,14 +4179,6 @@ void tst_QGraphicsItem::cursor() item1->setCursor(Qt::IBeamCursor); item2->setCursor(Qt::PointingHandCursor); - QWidget topLevel; - topLevel.resize(250, 150); - QTestPrivate::centerOnScreen(&topLevel); - QGraphicsView view(&scene,&topLevel); - view.setFixedSize(200, 100); - topLevel.show(); - QVERIFY(QTest::qWaitForWindowExposed(&topLevel)); - QTest::mouseMove(&view, view.rect().center()); const Qt::CursorShape viewportShape = view.viewport()->cursor().shape(); @@ -4938,6 +4937,7 @@ void tst_QGraphicsItem::sceneEventFilter() QGraphicsView view(&scene); view.show(); QApplication::setActiveWindow(&view); + QVERIFY(QTest::qWaitForWindowExposed(&view)); QVERIFY(QTest::qWaitForWindowActive(&view)); QGraphicsTextItem *text1 = scene.addText(QLatin1String("Text1")); @@ -5078,6 +5078,9 @@ void tst_QGraphicsItem::paint() 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); @@ -6533,6 +6536,9 @@ void tst_QGraphicsItem::ensureUpdateOnTextItem() QVERIFY(QTest::qWaitForWindowExposed(&view)); 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 @@ -6802,6 +6808,7 @@ void tst_QGraphicsItem::opacity2() MyGraphicsView view(&scene); view.show(); + QVERIFY(QTest::qWaitForWindowExposed(&view)); QVERIFY(QTest::qWaitForWindowActive(&view)); QTRY_VERIFY(view.repaints >= 1); @@ -6874,6 +6881,7 @@ void tst_QGraphicsItem::opacityZeroUpdates() MyGraphicsView view(&scene); view.show(); + QVERIFY(QTest::qWaitForWindowExposed(&view)); QVERIFY(QTest::qWaitForWindowActive(&view)); QTRY_VERIFY(view.repaints > 0); @@ -6891,6 +6899,9 @@ void tst_QGraphicsItem::opacityZeroUpdates() QRegion expectedRegion = parentDeviceBoundingRect.adjusted(-2, -2, 2, 2); expectedRegion += childDeviceBoundingRect.adjusted(-2, -2, 2, 2); +#ifdef Q_OS_WINRT + QEXPECT_FAIL("", "Fails on WinRT. Figure out why - QTBUG-68297", Abort); +#endif COMPARE_REGIONS(view.paintedRegion, expectedRegion); } @@ -7262,6 +7273,7 @@ void tst_QGraphicsItem::cacheMode() view.resize(150, 150); view.show(); QApplication::setActiveWindow(&view); + QVERIFY(QTest::qWaitForWindowExposed(&view)); QVERIFY(QTest::qWaitForWindowActive(&view)); EventTester *tester = new EventTester; @@ -7440,6 +7452,7 @@ void tst_QGraphicsItem::cacheMode2() view.resize(150, 150); view.show(); QApplication::setActiveWindow(&view); + QVERIFY(QTest::qWaitForWindowExposed(&view)); QVERIFY(QTest::qWaitForWindowActive(&view)); EventTester *tester = new EventTester; @@ -8093,6 +8106,7 @@ void tst_QGraphicsItem::moveLineItem() MyGraphicsView view(&scene); view.show(); + QVERIFY(QTest::qWaitForWindowExposed(&view)); QVERIFY(QTest::qWaitForWindowActive(&view)); view.reset(); @@ -8108,6 +8122,9 @@ void tst_QGraphicsItem::moveLineItem() // Make sure the calculated region is correct. item->update(); +#ifdef Q_OS_WINRT + QEXPECT_FAIL("", "Fails on WinRT. Figure out why - QTBUG-68297", Abort); +#endif QTRY_COMPARE(view.paintedRegion, expectedRegion); view.reset(); @@ -8161,6 +8178,7 @@ void tst_QGraphicsItem::sorting() view.setFrameStyle(0); view.show(); qApp->setActiveWindow(&view); + QVERIFY(QTest::qWaitForWindowExposed(&view)); QVERIFY(QTest::qWaitForWindowActive(&view)); QTRY_VERIFY(_paintedItems.count() > 0); @@ -8197,6 +8215,7 @@ void tst_QGraphicsItem::itemHasNoContents() QGraphicsView view(&scene); view.show(); qApp->setActiveWindow(&view); + QVERIFY(QTest::qWaitForWindowExposed(&view)); QVERIFY(QTest::qWaitForWindowActive(&view)); QTRY_VERIFY(!_paintedItems.isEmpty()); @@ -9204,6 +9223,7 @@ void tst_QGraphicsItem::ensureDirtySceneTransform() QGraphicsView view(&scene); view.show(); QApplication::setActiveWindow(&view); + QVERIFY(QTest::qWaitForWindowExposed(&view)); QVERIFY(QTest::qWaitForWindowActive(&view)); QCOMPARE(QApplication::activeWindow(), static_cast<QWidget *>(&view)); @@ -9590,6 +9610,7 @@ void tst_QGraphicsItem::QTBUG_4233_updateCachedWithSceneRect() QGraphicsView view(&scene); view.show(); QApplication::setActiveWindow(&view); + QVERIFY(QTest::qWaitForWindowExposed(&view)); QVERIFY(QTest::qWaitForWindowActive(&view)); QCOMPARE(QApplication::activeWindow(), (QWidget *)&view); @@ -10720,6 +10741,7 @@ void tst_QGraphicsItem::scroll() MyGraphicsView view(&scene); view.setFrameStyle(0); view.show(); + QVERIFY(QTest::qWaitForWindowExposed(&view)); QVERIFY(QTest::qWaitForWindowActive(&view)); QTRY_VERIFY(view.repaints > 0); @@ -11242,6 +11264,7 @@ void tst_QGraphicsItem::QTBUG_6738_missingUpdateWithSetParent() MyGraphicsView view(&scene); view.show(); qApp->setActiveWindow(&view); + QVERIFY(QTest::qWaitForWindowExposed(&view)); QVERIFY(QTest::qWaitForWindowActive(&view)); QTRY_VERIFY(view.repaints > 0); @@ -11290,6 +11313,7 @@ void tst_QGraphicsItem::QT_2653_fullUpdateDiscardingOpacityUpdate() parentGreen->setFlag(QGraphicsItem::ItemIgnoresTransformations); view.show(); + QVERIFY(QTest::qWaitForWindowExposed(&view)); QVERIFY(QTest::qWaitForWindowActive(&view)); view.reset(); @@ -11324,7 +11348,7 @@ void tst_QGraphicsItem::QTBUG_7714_fullUpdateDiscardingOpacityUpdate2() origView.show(); QVERIFY(QTest::qWaitForWindowActive(&origView)); - origView.setGeometry(origView.width() + 20, 20, + origView.setGeometry(origView.x() + origView.width() + 20, origView.y() + 20, origView.width(), origView.height()); parentGreen->setFlag(QGraphicsItem::ItemIgnoresTransformations); @@ -11332,10 +11356,14 @@ 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(); qApp->setActiveWindow(&view); + QVERIFY(QTest::qWaitForWindowExposed(&view)); QVERIFY(QTest::qWaitForWindowActive(&view)); view.reset(); origView.reset(); @@ -11475,6 +11503,7 @@ void tst_QGraphicsItem::doNotMarkFullUpdateIfNotInScene() item2->setParentItem(item); scene.addItem(item); view.show(); + QVERIFY(QTest::qWaitForWindowExposed(view.windowHandle())); QVERIFY(QTest::qWaitForWindowActive(view.windowHandle())); view.activateWindow(); QTRY_VERIFY(view.isActiveWindow()); @@ -11506,6 +11535,7 @@ void tst_QGraphicsItem::itemDiesDuringDraggingOperation() scene.addItem(item); view.show(); QApplication::setActiveWindow(&view); + QVERIFY(QTest::qWaitForWindowExposed(&view)); QVERIFY(QTest::qWaitForWindowActive(&view)); QCOMPARE(QApplication::activeWindow(), (QWidget *)&view); QGraphicsSceneDragDropEvent dragEnter(QEvent::GraphicsSceneDragEnter); @@ -11533,6 +11563,7 @@ void tst_QGraphicsItem::QTBUG_12112_focusItem() view.show(); QApplication::setActiveWindow(&view); + QVERIFY(QTest::qWaitForWindowExposed(&view)); QVERIFY(QTest::qWaitForWindowActive(&view)); QCOMPARE(QApplication::activeWindow(), (QWidget *)&view); |