diff options
author | Janne Anttila <janne.anttila@digia.com> | 2009-09-09 08:16:25 (GMT) |
---|---|---|
committer | Janne Anttila <janne.anttila@digia.com> | 2009-09-09 08:16:25 (GMT) |
commit | 22105c9952630b45fd6b50b0e3349880940a83f5 (patch) | |
tree | fa2231279cc2c4a5a79d206861cd7fbac285c1c7 /tests/auto | |
parent | 8e3e60b9ea7e4bccbc6d1a7fa90778e847e64190 (diff) | |
parent | 2cbc5ee1bc89be2f174566f35eb89b493ba75c69 (diff) | |
download | Qt-22105c9952630b45fd6b50b0e3349880940a83f5.zip Qt-22105c9952630b45fd6b50b0e3349880940a83f5.tar.gz Qt-22105c9952630b45fd6b50b0e3349880940a83f5.tar.bz2 |
Merge branch '4.6' of git@scm.dev.troll.no:qt/qt into 4.6
Diffstat (limited to 'tests/auto')
-rw-r--r-- | tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp | 8 | ||||
-rw-r--r-- | tests/auto/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp | 11 | ||||
-rw-r--r-- | tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp | 12 | ||||
-rw-r--r-- | tests/auto/qgraphicsview/tst_qgraphicsview.cpp | 35 |
4 files changed, 41 insertions, 25 deletions
diff --git a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp index cbb0802..b8061da 100644 --- a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp +++ b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp @@ -60,6 +60,9 @@ #include <QVBoxLayout> #include <QGraphicsEffect> +#include "../../shared/util.h" + + //TESTED_CLASS= //TESTED_FILES= @@ -1933,7 +1936,7 @@ void tst_QGraphicsItem::zValue() QApplication::sendPostedEvents(); //glib workaround #endif - QVERIFY(!_paintedItems.isEmpty()); + QTRY_VERIFY(!_paintedItems.isEmpty()); QVERIFY((_paintedItems.size() % 4) == 0); for (int i = 0; i < 3; ++i) QVERIFY(_paintedItems.at(i)->zValue() < _paintedItems.at(i + 1)->zValue()); @@ -2917,6 +2920,7 @@ void tst_QGraphicsItem::hoverEventsGenerateRepaints() qApp->processEvents(); qApp->processEvents(); + QTRY_COMPARE(tester->repaints, 1); // Send a hover enter event QGraphicsSceneHoverEvent hoverEnterEvent(QEvent::GraphicsSceneHoverEnter); @@ -7823,7 +7827,7 @@ void tst_QGraphicsItem::panel() QEvent activate(QEvent::WindowActivate); QEvent deactivate(QEvent::WindowDeactivate); - + QApplication::sendEvent(&scene, &activate); // No previous activation, so the scene is active. diff --git a/tests/auto/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp b/tests/auto/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp index 8bac29d..9249f6d 100644 --- a/tests/auto/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp +++ b/tests/auto/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp @@ -51,7 +51,6 @@ #include <private/qt_x11_p.h> #endif - static void sendMouseMove(QWidget *widget, const QPoint &point, Qt::MouseButton button = Qt::NoButton) { QMouseEvent event(QEvent::MouseMove, point, widget->mapToGlobal(point), button, button, 0); @@ -953,6 +952,8 @@ void tst_QGraphicsProxyWidget::hoverEnterLeaveEvent() QGraphicsScene scene; QGraphicsView view(&scene); + //do not let the window manager move the window while we are moving the mouse on it + view.setWindowFlags(Qt::X11BypassWindowManagerHint); view.show(); #ifdef Q_WS_X11 qt_x11_wait_for_window_manager(&view); @@ -975,7 +976,7 @@ void tst_QGraphicsProxyWidget::hoverEnterLeaveEvent() // in QTest::mouseMove(&view, QPoint(50, 50)); QTest::qWait(250); - // QTRY_COMPARE(widget->testAttribute(Qt::WA_UnderMouse), hasWidget ? true : false); + QTRY_COMPARE(widget->testAttribute(Qt::WA_UnderMouse), hasWidget ? true : false); // ### this attribute isn't supported QCOMPARE(widget->enterCount, hasWidget ? 1 : 0); QCOMPARE(widget->hoverEnter, (hasWidget && hoverEnabled) ? 1 : 0); @@ -1288,7 +1289,7 @@ void tst_QGraphicsProxyWidget::paintEvent() w->update(); QTest::qWait(100); - QCOMPARE(proxy.paintCount, 1); //the widget should have been painted now + QTRY_COMPARE(proxy.paintCount, 1); //the widget should have been painted now } @@ -1481,8 +1482,8 @@ void tst_QGraphicsProxyWidget::scrollUpdate() view.paintEventRegion = QRegion(); view.npaints = 0; QTimer::singleShot(0, widget, SLOT(updateScroll())); - QTest::qWait(500); - QCOMPARE(view.npaints, 2); + QTest::qWait(50); + QTRY_COMPARE(view.npaints, 2); // QRect(0, 0, 200, 12) is the first update, expanded (-2, -2, 2, 2) // QRect(0, 12, 102, 10) is the scroll update, expanded (-2, -2, 2, 2), // intersected with the above update. diff --git a/tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp b/tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp index 66a91f3..f78c59e 100644 --- a/tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp +++ b/tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp @@ -1627,7 +1627,7 @@ void tst_QGraphicsScene::hoverEvents_siblings() QGraphicsSceneMouseEvent mouseEvent(QEvent::GraphicsSceneMouseMove); mouseEvent.setScenePos(QPointF(-1000, -1000)); QApplication::sendEvent(&scene, &mouseEvent); - + QTest::qWait(50); for (int j = 1; j >= 0; --j) { @@ -2465,7 +2465,7 @@ void tst_QGraphicsScene::dragAndDrop_propagate() QCOMPARE(item1->eventList.at(0), QEvent::GraphicsSceneDragEnter); QCOMPARE(item1->eventList.at(1), QEvent::GraphicsSceneDragMove); } - + { // Move into the intersection item1-item2 QDragMoveEvent dragMove(view.mapFromScene(5, 5), Qt::CopyAction, &mimeData, Qt::LeftButton, 0); @@ -2875,7 +2875,7 @@ public: QList<QEvent::Type> receivedSceneEvents; QList<QEvent::Type> receivedSceneEventFilters; - + protected: bool sceneEventFilter(QGraphicsItem *watched, QEvent *event) { @@ -2961,10 +2961,10 @@ void tst_QGraphicsScene::exposedRect() scene.addItem(item); QCOMPARE(item->exposed, QRectF()); - + QImage image(100, 100, QImage::Format_ARGB32_Premultiplied); QPainter painter(&image); - + scene.render(&painter); QCOMPARE(item->exposed, item->boundingRect()); @@ -3269,7 +3269,7 @@ void tst_QGraphicsScene::tabFocus_sceneWithNestedFocusWidgets() EventSpy focusOutSpy_1_2(widget1_2, QEvent::FocusOut); EventSpy focusInSpy_2(widget2, QEvent::FocusIn); EventSpy focusOutSpy_2(widget2, QEvent::FocusOut); - + QTest::keyPress(QApplication::focusWidget(), Qt::Key_Tab); QTest::qWait(125); QVERIFY(widget1->hasFocus()); diff --git a/tests/auto/qgraphicsview/tst_qgraphicsview.cpp b/tests/auto/qgraphicsview/tst_qgraphicsview.cpp index 0115d95..b52cb7d 100644 --- a/tests/auto/qgraphicsview/tst_qgraphicsview.cpp +++ b/tests/auto/qgraphicsview/tst_qgraphicsview.cpp @@ -66,6 +66,8 @@ #include <QtGui/QInputContext> #include <private/qgraphicsview_p.h> +#include "../../shared/util.h" + //TESTED_CLASS= //TESTED_FILES= @@ -1383,7 +1385,7 @@ void tst_QGraphicsView::itemsInRect_cosmeticAdjust() else view.viewport()->update(updateRect); qApp->processEvents(); - QCOMPARE(rect->numPaints, numPaints); + QTRY_COMPARE(rect->numPaints, numPaints); } void tst_QGraphicsView::itemsInPoly() @@ -2182,7 +2184,7 @@ void tst_QGraphicsView::viewportUpdateMode() QTest::qWait(50); // The view gets two updates for the update scene updates. - QVERIFY(!view.lastUpdateRegions.isEmpty()); + QTRY_VERIFY(!view.lastUpdateRegions.isEmpty()); QCOMPARE(view.lastUpdateRegions.last().rects().size(), 2); QCOMPARE(view.lastUpdateRegions.last().rects().at(0).size(), QSize(15, 15)); QCOMPARE(view.lastUpdateRegions.last().rects().at(1).size(), QSize(15, 15)); @@ -2433,7 +2435,7 @@ void tst_QGraphicsView::optimizationFlags_dontSavePainterState() class LodItem : public QGraphicsRectItem { public: - LodItem(const QRectF &rect) : QGraphicsRectItem(rect), lastLod(1) + LodItem(const QRectF &rect) : QGraphicsRectItem(rect), lastLod(-42) { } void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *viewport) @@ -2485,7 +2487,7 @@ void tst_QGraphicsView::levelOfDetail() #endif QTest::qWait(50); - QCOMPARE(item->lastLod, qreal(1)); + QTRY_COMPARE(item->lastLod, qreal(1)); view.setTransform(transform); @@ -2494,7 +2496,7 @@ void tst_QGraphicsView::levelOfDetail() #endif QTest::qWait(50); - QCOMPARE(item->lastLod, lod); + QTRY_COMPARE(item->lastLod, lod); } // Moved to tst_qgraphicsview_2.cpp @@ -2695,10 +2697,13 @@ void tst_QGraphicsView::task172231_untransformableItems() view.scale(2, 1); view.show(); -#ifdef Q_WS_X11 + QApplication::setActiveWindow(&view); +#if defined(Q_WS_X11) qt_x11_wait_for_window_manager(&view); #endif QTest::qWait(50); + QTRY_COMPARE(QApplication::activeWindow(), &view); + QRectF origExposedRect = text->exposedRect; view.resize(int(0.75 * view.width()), view.height()); @@ -2840,14 +2845,14 @@ void tst_QGraphicsView::task207546_focusCrash() widget.layout()->addWidget(gr1); widget.layout()->addWidget(gr2); widget.show(); -#if defined(Q_OS_IRIX) - QTest::qWait(200); + QTest::qWait(20); widget.activateWindow(); - QTest::qWait(200); -#elif defined(Q_WS_X11) + QApplication::setActiveWindow(&widget); +#if defined(Q_WS_X11) qt_x11_wait_for_window_manager(&widget); #endif QTest::qWait(50); + QTRY_COMPARE(QApplication::activeWindow(), static_cast<QWidget *>(&widget)); widget.focusNextPrevChild(true); QCOMPARE(static_cast<QWidget *>(gr2), widget.focusWidget()); } @@ -3187,7 +3192,8 @@ void tst_QGraphicsView::centerOnDirtyItem() #endif QTest::qWait(50); - QPixmap before = QPixmap::grabWindow(view.viewport()->winId()); + QImage before(view.viewport()->size(), QImage::Format_ARGB32); + view.viewport()->render(&before); item->setPos(20, 0); view.centerOn(item); @@ -3197,7 +3203,8 @@ void tst_QGraphicsView::centerOnDirtyItem() #endif QTest::qWait(50); - QPixmap after = QPixmap::grabWindow(view.viewport()->winId()); + QImage after(view.viewport()->size(), QImage::Format_ARGB32); + view.viewport()->render(&after); QCOMPARE(before, after); } @@ -3470,6 +3477,10 @@ void tst_QGraphicsView::update() QCOMPARE(viewportRect, QRect(0, 0, 200, 200)); #if defined QT_BUILD_INTERNAL + QApplication::setActiveWindow(&view); + QTest::qWait(50); + QTRY_COMPARE(QApplication::activeWindow(), &view); + const bool intersects = updateRect.intersects(viewportRect); QGraphicsViewPrivate *viewPrivate = static_cast<QGraphicsViewPrivate *>(qt_widget_private(&view)); QCOMPARE(viewPrivate->updateRect(updateRect), intersects); |