From 7171983e8c9ca106952ecc09e540da4aab8b8b0d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sami=20Meril=C3=A4?= Date: Wed, 30 Sep 2009 12:16:56 +0300 Subject: Ftp example application crashes (due to keypad navigation) Keypad navigation tries to calculate the minimal distance of next widget to the direction of pressed navigation key. This calculation in QWidgetPrivate::widgetInNavigationDirection dies not take into account that some widgets might have focusProxy setup. In the reported case, ignoring focus proxy means that QDialogButtonBox gets the focus and it hands it over to first button in its tab order. Unfortunately, this button is disabled 'Download' button. Now, when Select key is pressed, button action is triggered causing a crash. Solution is to skip widgets that have focus proxies in widgetInNavigationDirection. Task-number: QT-2177 Reviewed-by: Alessandro Portale --- src/gui/kernel/qwidget.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/gui/kernel/qwidget.cpp b/src/gui/kernel/qwidget.cpp index 08fe5b9..e2de148 100644 --- a/src/gui/kernel/qwidget.cpp +++ b/src/gui/kernel/qwidget.cpp @@ -11454,6 +11454,10 @@ QWidget *QWidgetPrivate::widgetInNavigationDirection(Direction direction) QWidget *targetWidget = 0; int shortestDistance = INT_MAX; foreach(QWidget *targetCandidate, QApplication::allWidgets()) { + + if (targetCandidate->focusProxy()) //skip if focus proxy set + continue; + const QRect targetCandidateRect = targetCandidate->rect().translated(targetCandidate->mapToGlobal(QPoint())); if ( targetCandidate != sourceWidget && targetCandidate->focusPolicy() & Qt::TabFocus -- cgit v0.12 From c33c3eab6fc510634f00eb001ce5c5860083ba82 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Tue, 29 Sep 2009 17:15:49 +0200 Subject: Stabilize listview test --- tests/auto/qlistview/tst_qlistview.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/auto/qlistview/tst_qlistview.cpp b/tests/auto/qlistview/tst_qlistview.cpp index b51434f..499fb0b 100644 --- a/tests/auto/qlistview/tst_qlistview.cpp +++ b/tests/auto/qlistview/tst_qlistview.cpp @@ -1630,7 +1630,9 @@ void tst_QListView::task254449_draggingItemToNegativeCoordinates() } delegate; list.setItemDelegate(&delegate); - QTest::qWait(200); //makes sure the layout is done + delegate.numPaints = 0; + QTest::qWaitForWindowShown(&list); //makes sure the layout is done + QTRY_VERIFY(delegate.numPaints > 0); const QPoint topLeft(-6, 0); list.setPositionForIndex(topLeft, index); -- cgit v0.12 From bc714d469487856c85a42ecb0ceb540420f3e7cc Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Tue, 29 Sep 2009 18:18:26 +0200 Subject: Fixed warning in public header: qcommonstyle.h:87: warning: virtual void QCommonStyle::polish(QPalette&) was hidden qs60style.h:77: warning: by QS60Style::polish Reviewed-by: Jeremy --- src/gui/styles/qs60style.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/gui/styles/qs60style.h b/src/gui/styles/qs60style.h index fd18bc3..6be3197 100644 --- a/src/gui/styles/qs60style.h +++ b/src/gui/styles/qs60style.h @@ -76,6 +76,9 @@ public: void unpolish(QWidget *widget); void polish(QApplication *application); void unpolish(QApplication *application); +#ifndef Q_NO_USING_KEYWORD + using QCommonStyle::polish; +#endif void setStyleProperty(const char *name, const QVariant &value); QVariant styleProperty(const char *name) const; -- cgit v0.12 From 85b4c2a9e4c62a836819baf0669b91a3f30c9a4e Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Wed, 30 Sep 2009 10:38:09 +0200 Subject: Stabilize and speedup QGraphicsItem and QGraphicsView and QGraphicsProxyWidget test --- tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp | 371 ++++++++++----------- .../tst_qgraphicsproxywidget.cpp | 208 +++++------- tests/auto/qgraphicsview/tst_qgraphicsview.cpp | 64 ++-- 3 files changed, 309 insertions(+), 334 deletions(-) diff --git a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp index d08e74b..ef9fe9e 100644 --- a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp +++ b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp @@ -1372,19 +1372,20 @@ void tst_QGraphicsItem::selected_textItem() QGraphicsView view(&scene); view.show(); - QTest::qWait(1000); + QTest::qWaitForWindowShown(&view); + QTest::qWait(20); - QVERIFY(!text->isSelected()); + QTRY_VERIFY(!text->isSelected()); QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, view.mapFromScene(text->mapToScene(0, 0))); - QVERIFY(text->isSelected()); + QTRY_VERIFY(text->isSelected()); text->setSelected(false); text->setTextInteractionFlags(Qt::TextEditorInteraction); QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, view.mapFromScene(text->mapToScene(0, 0))); - QVERIFY(text->isSelected()); + QTRY_VERIFY(text->isSelected()); } void tst_QGraphicsItem::selected_multi() @@ -1416,91 +1417,91 @@ void tst_QGraphicsItem::selected_multi() // Click on item1 QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, view.mapFromScene(item1->scenePos())); - QTest::qWait(200); + QTest::qWait(20); QVERIFY(item1->isSelected()); QVERIFY(!item2->isSelected()); // Click on item2 QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, view.mapFromScene(item2->scenePos())); - QTest::qWait(200); + QTest::qWait(20); QVERIFY(item2->isSelected()); QVERIFY(!item1->isSelected()); // Ctrl-click on item1 QTest::mouseClick(view.viewport(), Qt::LeftButton, Qt::ControlModifier, view.mapFromScene(item1->scenePos())); - QTest::qWait(200); + QTest::qWait(20); QVERIFY(item2->isSelected()); QVERIFY(item1->isSelected()); // Ctrl-click on item1 again QTest::mouseClick(view.viewport(), Qt::LeftButton, Qt::ControlModifier, view.mapFromScene(item1->scenePos())); - QTest::qWait(200); + QTest::qWait(20); QVERIFY(item2->isSelected()); QVERIFY(!item1->isSelected()); // Ctrl-click on item2 QTest::mouseClick(view.viewport(), Qt::LeftButton, Qt::ControlModifier, view.mapFromScene(item2->scenePos())); - QTest::qWait(200); + QTest::qWait(20); QVERIFY(!item2->isSelected()); QVERIFY(!item1->isSelected()); // Click on item1 QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, view.mapFromScene(item1->scenePos())); - QTest::qWait(200); + QTest::qWait(20); QVERIFY(item1->isSelected()); QVERIFY(!item2->isSelected()); // Click on scene QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, view.mapFromScene(0, 0)); - QTest::qWait(200); + QTest::qWait(20); QVERIFY(!item1->isSelected()); QVERIFY(!item2->isSelected()); // Click on item1 QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, view.mapFromScene(item1->scenePos())); - QTest::qWait(200); + QTest::qWait(20); QVERIFY(item1->isSelected()); QVERIFY(!item2->isSelected()); // Ctrl-click on scene QTest::mouseClick(view.viewport(), Qt::LeftButton, Qt::ControlModifier, view.mapFromScene(0, 0)); - QTest::qWait(200); + QTest::qWait(20); QVERIFY(!item1->isSelected()); QVERIFY(!item2->isSelected()); // Click on item1 QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, view.mapFromScene(item1->scenePos())); - QTest::qWait(200); + QTest::qWait(20); QVERIFY(item1->isSelected()); QVERIFY(!item2->isSelected()); // Press on item2 QTest::mousePress(view.viewport(), Qt::LeftButton, 0, view.mapFromScene(item2->scenePos())); - QTest::qWait(200); + QTest::qWait(20); QVERIFY(!item1->isSelected()); QVERIFY(item2->isSelected()); // Release on item2 QTest::mouseRelease(view.viewport(), Qt::LeftButton, 0, view.mapFromScene(item2->scenePos())); - QTest::qWait(200); + QTest::qWait(20); QVERIFY(!item1->isSelected()); QVERIFY(item2->isSelected()); // Click on item1 QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, view.mapFromScene(item1->scenePos())); - QTest::qWait(200); + QTest::qWait(20); QVERIFY(item1->isSelected()); QVERIFY(!item2->isSelected()); // Ctrl-click on item1 QTest::mouseClick(view.viewport(), Qt::LeftButton, Qt::ControlModifier, view.mapFromScene(item1->scenePos())); - QTest::qWait(200); + QTest::qWait(20); QVERIFY(!item1->isSelected()); QVERIFY(!item2->isSelected()); // Ctrl-press on item1 QTest::mousePress(view.viewport(), Qt::LeftButton, Qt::ControlModifier, view.mapFromScene(item1->scenePos())); - QTest::qWait(200); + QTest::qWait(20); QVERIFY(!item1->isSelected()); QVERIFY(!item2->isSelected()); @@ -1508,14 +1509,14 @@ void tst_QGraphicsItem::selected_multi() // Ctrl-move on item1 QMouseEvent event(QEvent::MouseMove, view.mapFromScene(item1->scenePos()) + QPoint(1, 0), Qt::LeftButton, Qt::LeftButton, Qt::ControlModifier); QApplication::sendEvent(view.viewport(), &event); - QTest::qWait(200); + QTest::qWait(20); QVERIFY(!item1->isSelected()); QVERIFY(!item2->isSelected()); } // Release on item1 QTest::mouseRelease(view.viewport(), Qt::LeftButton, Qt::ControlModifier, view.mapFromScene(item1->scenePos())); - QTest::qWait(200); + QTest::qWait(20); QVERIFY(item1->isSelected()); QVERIFY(!item2->isSelected()); @@ -1524,7 +1525,7 @@ void tst_QGraphicsItem::selected_multi() // Ctrl-press on item1 QTest::mousePress(view.viewport(), Qt::LeftButton, Qt::ControlModifier, view.mapFromScene(item1->scenePos())); - QTest::qWait(200); + QTest::qWait(20); QVERIFY(!item1->isSelected()); QVERIFY(!item2->isSelected()); @@ -1532,14 +1533,14 @@ void tst_QGraphicsItem::selected_multi() // Ctrl-move on item1 QMouseEvent event(QEvent::MouseMove, view.mapFromScene(item1->scenePos()) + QPoint(1, 0), Qt::LeftButton, Qt::LeftButton, Qt::ControlModifier); QApplication::sendEvent(view.viewport(), &event); - QTest::qWait(200); + QTest::qWait(20); QVERIFY(item1->isSelected()); QVERIFY(!item2->isSelected()); } // Release on item1 QTest::mouseRelease(view.viewport(), Qt::LeftButton, Qt::ControlModifier, view.mapFromScene(item1->scenePos())); - QTest::qWait(200); + QTest::qWait(20); QVERIFY(item1->isSelected()); QVERIFY(!item2->isSelected()); } @@ -2927,7 +2928,7 @@ void tst_QGraphicsItem::hoverEventsGenerateRepaints() #ifdef Q_WS_X11 qt_x11_wait_for_window_manager(&view); #endif - QTest::qWait(250); + QTest::qWait(20); EventTester *tester = new EventTester; scene.addItem(tester); @@ -3059,7 +3060,8 @@ void tst_QGraphicsItem::childrenBoundingRect() QGraphicsView view(&scene); view.show(); - QTest::qWait(5000); + QTest::qWaitForWindowShown(&view); + QTest::qWait(30); QCOMPARE(parent->childrenBoundingRect(), QRectF(-500, -100, 600, 800)); } @@ -3164,7 +3166,8 @@ void tst_QGraphicsItem::group() QGraphicsView view(&scene); view.show(); - QTest::qWait(250); + QTest::qWaitForWindowShown(&view); + QApplication::processEvents(); QGraphicsItemGroup *group = new QGraphicsItemGroup; group->setSelected(true); @@ -3180,7 +3183,7 @@ void tst_QGraphicsItem::group() QCOMPARE(scene.items().size(), 4); QCOMPARE(scene.items(group->sceneBoundingRect()).size(), 3); - QTest::qWait(250); + QTest::qWait(25); QRectF parent2SceneBoundingRect = parent2->sceneBoundingRect(); group->addToGroup(parent2); @@ -3192,7 +3195,7 @@ void tst_QGraphicsItem::group() QCOMPARE(scene.items().size(), 4); QCOMPARE(scene.items(group->sceneBoundingRect()).size(), 4); - QTest::qWait(250); + QTest::qWait(25); QList newItems; for (int i = 0; i < 100; ++i) { @@ -3372,8 +3375,8 @@ void tst_QGraphicsItem::handlesChildEvents() QGraphicsView view(&scene); view.show(); - - QTest::qWait(1000); + QTest::qWaitForWindowShown(&view); + QTest::qWait(20); // Pull out the items, closest item first QList items = scene.items(scene.itemsBoundingRect()); @@ -3496,14 +3499,14 @@ void tst_QGraphicsItem::handlesChildEvents2() QGraphicsView view(&scene); view.show(); - - QTestEventLoop::instance().enterLoop(1); + QTest::qWaitForWindowShown(&view); + QApplication::processEvents(); QMouseEvent event(QEvent::MouseButtonPress, view.mapFromScene(5, 5), view.viewport()->mapToGlobal(view.mapFromScene(5, 5)), Qt::LeftButton, 0, 0); QApplication::sendEvent(view.viewport(), &event); - QCOMPARE(root->counter, 1); + QTRY_COMPARE(root->counter, 1); } void tst_QGraphicsItem::handlesChildEvents3() @@ -3585,8 +3588,8 @@ void tst_QGraphicsItem::filtersChildEvents() QGraphicsView view(&scene); view.show(); - - QTest::qWait(1000); + QTest::qWaitForWindowShown(&view); + QTest::qWait(20); QGraphicsSceneMouseEvent pressEvent(QEvent::GraphicsSceneMousePress); QGraphicsSceneMouseEvent releaseEvent(QEvent::GraphicsSceneMouseRelease); @@ -3601,7 +3604,7 @@ void tst_QGraphicsItem::filtersChildEvents() QApplication::sendEvent(&scene, &pressEvent); QApplication::sendEvent(&scene, &releaseEvent); - QCOMPARE(child->counter, 1); // mouse release is not filtered + QTRY_COMPARE(child->counter, 1); // mouse release is not filtered QCOMPARE(filter->counter, 1); // mouse press is filtered QCOMPARE(root->counter, 0); @@ -3656,17 +3659,18 @@ void tst_QGraphicsItem::filtersChildEvents2() QGraphicsView view(&scene); view.show(); - QTestEventLoop::instance().enterLoop(1); + QTest::qWaitForWindowShown(&view); + QApplication::processEvents(); QMouseEvent event(QEvent::MouseButtonPress, view.mapFromScene(5, 5), view.viewport()->mapToGlobal(view.mapFromScene(5, 5)), Qt::LeftButton, 0, 0); QApplication::sendEvent(view.viewport(), &event); + QTRY_COMPARE(root->counter, 1); QCOMPARE(child->counter, 0); QCOMPARE(child2->counter, 0); QCOMPARE(child3->counter, 0); QCOMPARE(child4->counter, 0); - QCOMPARE(root->counter, 1); } class CustomItem : public QGraphicsItem @@ -3703,21 +3707,22 @@ void tst_QGraphicsItem::ensureVisible() QGraphicsView view(&scene); view.setFixedSize(300, 300); view.show(); + QTest::qWaitForWindowShown(&view); for (int i = 0; i < 25; ++i) { view.scale(qreal(1.06), qreal(1.06)); - QTest::qWait(25); + QApplication::processEvents(); } item->ensureVisible(-100, -100, 25, 25); - QTest::qWait(250); + QTest::qWait(25); for (int x = -100; x < 100; x += 25) { for (int y = -100; y < 100; y += 25) { int xmargin = rand() % 75; int ymargin = rand() % 75; item->ensureVisible(x, y, 25, 25, xmargin, ymargin); - QTest::qWait(25); + QApplication::processEvents(); QPolygonF viewScenePoly; viewScenePoly << view.mapToScene(view.rect().topLeft()) @@ -3744,7 +3749,7 @@ void tst_QGraphicsItem::ensureVisible() } item->ensureVisible(100, 100, 25, 25); - QTest::qWait(250); + QTest::qWait(25); } void tst_QGraphicsItem::cursor() @@ -3785,7 +3790,7 @@ void tst_QGraphicsItem::cursor() view.show(); QTest::mouseMove(&view, view.rect().center()); - QTest::qWait(250); + QTest::qWait(25); QCursor cursor = view.viewport()->cursor(); @@ -3794,7 +3799,7 @@ void tst_QGraphicsItem::cursor() QApplication::sendEvent(view.viewport(), &event); } - QTest::qWait(250); + QTest::qWait(25); QCOMPARE(view.viewport()->cursor().shape(), cursor.shape()); @@ -3819,7 +3824,7 @@ void tst_QGraphicsItem::cursor() QApplication::sendEvent(view.viewport(), &event); } - QTest::qWait(250); + QTest::qWait(25); QCOMPARE(view.viewport()->cursor().shape(), item2->cursor().shape()); @@ -3829,7 +3834,7 @@ void tst_QGraphicsItem::cursor() QApplication::sendEvent(view.viewport(), &event); } - QTest::qWait(250); + QTest::qWait(25); QCOMPARE(view.viewport()->cursor().shape(), cursor.shape()); #endif @@ -4488,10 +4493,9 @@ void tst_QGraphicsItem::sceneEventFilter() QGraphicsView view(&scene); view.show(); -#ifdef Q_WS_X11 - qt_x11_wait_for_window_manager(&view); -#endif - QTest::qWait(250); + QApplication::setActiveWindow(&view); + QTest::qWaitForWindowShown(&view); + QTest::qWait(25); QGraphicsTextItem *text1 = scene.addText(QLatin1String("Text1")); QGraphicsTextItem *text2 = scene.addText(QLatin1String("Text2")); @@ -4503,10 +4507,10 @@ void tst_QGraphicsItem::sceneEventFilter() EventFilterTesterItem *tester = new EventFilterTesterItem; scene.addItem(tester); - QVERIFY(!text1->hasFocus()); + QTRY_VERIFY(!text1->hasFocus()); text1->installSceneEventFilter(tester); text1->setFocus(); - QVERIFY(text1->hasFocus()); + QTRY_VERIFY(text1->hasFocus()); QCOMPARE(tester->filteredEvents.size(), 1); QCOMPARE(tester->filteredEvents.at(0), QEvent::FocusIn); @@ -4554,13 +4558,14 @@ void tst_QGraphicsItem::sceneEventFilter() QGraphicsTextItem *ti3 = anotherScene->addText("This is a test #3"); gv.setScene(anotherScene); gv.show(); - QTest::qWait(250); + QTest::qWaitForWindowShown(&gv); + QTest::qWait(25); ti->installSceneEventFilter(ti2); ti3->installSceneEventFilter(ti); delete ti2; //we souldn't crash QTest::mouseMove(gv.viewport(), gv.mapFromScene(ti->scenePos())); - QTest::qWait(250); + QTest::qWait(30); delete ti; } @@ -4608,10 +4613,8 @@ void tst_QGraphicsItem::paint() QGraphicsView view(&scene); view.show(); -#ifdef Q_WS_X11 - qt_x11_wait_for_window_manager(&view); -#endif - QTest::qWait(250); + QTest::qWaitForWindowShown(&view); + QApplication::processEvents(); #ifdef Q_OS_WIN32 //we try to switch the desktop: if it fails, we skip the test if (::SwitchDesktop( ::GetThreadDesktop( ::GetCurrentThreadId() ) ) == 0) { @@ -4619,14 +4622,15 @@ void tst_QGraphicsItem::paint() } #endif - QCOMPARE(paintTester.widget, view.viewport()); + QTRY_COMPARE(paintTester.widget, view.viewport()); view.hide(); QGraphicsScene scene2; QGraphicsView view2(&scene2); view2.show(); - QTest::qWait(250); + QTest::qWaitForWindowShown(&view2); + QTest::qWait(25); PaintTester tester2; scene2.addItem(&tester2); @@ -4638,22 +4642,19 @@ void tst_QGraphicsItem::paint() //nominal case, update call paint tester2.update(); qApp->processEvents(); - QTest::qWait(250); - QVERIFY(tester2.painted == 2); + QTRY_VERIFY(tester2.painted == 2); //we remove the item from the scene, number of updates is still the same tester2.update(); scene2.removeItem(&tester2); qApp->processEvents(); - QTest::qWait(250); - QVERIFY(tester2.painted == 2); + QTRY_VERIFY(tester2.painted == 2); //We re-add the item, the number of paint should increase scene2.addItem(&tester2); tester2.update(); qApp->processEvents(); - QTest::qWait(250); - QVERIFY(tester2.painted == 3); + QTRY_VERIFY(tester2.painted == 3); } class HarakiriItem : public QGraphicsRectItem @@ -5414,6 +5415,8 @@ void tst_QGraphicsItem::untransformable() view.setBackgroundBrush(QBrush(Qt::black, Qt::DiagCrossPattern)); #endif + QTest::qWaitForWindowShown(&view); + for (int i = 0; i < 10; ++i) { QPoint center = view.viewport()->rect().center(); QCOMPARE(view.itemAt(center), item1); @@ -5438,7 +5441,7 @@ void tst_QGraphicsItem::untransformable() view.rotate(13); view.shear(qreal(0.01), qreal(0.01)); view.translate(10, 10); - QTest::qWait(250); + QTest::qWait(25); } } @@ -5474,11 +5477,9 @@ void tst_QGraphicsItem::contextMenuEventPropagation() QGraphicsView view(&scene); view.setAlignment(Qt::AlignLeft | Qt::AlignTop); view.show(); -#ifdef Q_WS_X11 - qt_x11_wait_for_window_manager(&view); -#endif view.resize(200, 200); - QTest::qWait(250); + QTest::qWaitForWindowShown(&view); + QTest::qWait(20); QContextMenuEvent event(QContextMenuEvent::Mouse, QPoint(10, 10), view.viewport()->mapToGlobal(QPoint(10, 10))); @@ -5579,15 +5580,16 @@ void tst_QGraphicsItem::task141694_textItemEnsureVisible() QGraphicsView view(&scene); view.setFixedSize(200, 200); view.show(); + QTest::qWaitForWindowShown(&view); view.ensureVisible(-1000, -1000, 5, 5); int hscroll = view.horizontalScrollBar()->value(); int vscroll = view.verticalScrollBar()->value(); - QTestEventLoop::instance().enterLoop(1); + QTest::qWait(10); // This should not cause the view to scroll - QCOMPARE(view.horizontalScrollBar()->value(), hscroll); + QTRY_COMPARE(view.horizontalScrollBar()->value(), hscroll); QCOMPARE(view.verticalScrollBar()->value(), vscroll); } @@ -5752,16 +5754,17 @@ void tst_QGraphicsItem::ensureUpdateOnTextItem() QGraphicsScene scene; QGraphicsView view(&scene); view.show(); - QTest::qWait(250); + QTest::qWaitForWindowShown(&view); + QTest::qWait(25); TextItem *text1 = new TextItem(QLatin1String("123")); scene.addItem(text1); qApp->processEvents(); - QCOMPARE(text1->updates,1); + QTRY_COMPARE(text1->updates,1); //same bouding rect but we have to update text1->setText(QLatin1String("321")); - QTest::qWait(250); - QCOMPARE(text1->updates,2); + qApp->processEvents(); + QTRY_COMPARE(text1->updates,2); } void tst_QGraphicsItem::task243707_addChildBeforeParent() @@ -6049,10 +6052,8 @@ void tst_QGraphicsItem::opacity2() MyGraphicsView view(&scene); view.show(); -#ifdef Q_WS_X11 - qt_x11_wait_for_window_manager(&view); -#endif - QTest::qWait(250); + QTest::qWaitForWindowShown(&view); + QTRY_COMPARE(view.repaints, 1); #define RESET_REPAINT_COUNTERS \ parent->repaints = 0; \ @@ -6063,8 +6064,8 @@ void tst_QGraphicsItem::opacity2() RESET_REPAINT_COUNTERS child->setOpacity(0.0); - QTest::qWait(100); - QCOMPARE(view.repaints, 1); + QTest::qWait(10); + QTRY_COMPARE(view.repaints, 1); QCOMPARE(parent->repaints, 1); QCOMPARE(child->repaints, 0); QCOMPARE(grandChild->repaints, 0); @@ -6072,8 +6073,8 @@ void tst_QGraphicsItem::opacity2() RESET_REPAINT_COUNTERS child->setOpacity(1.0); - QTest::qWait(100); - QCOMPARE(view.repaints, 1); + QTest::qWait(10); + QTRY_COMPARE(view.repaints, 1); QCOMPARE(parent->repaints, 1); QCOMPARE(child->repaints, 1); QCOMPARE(grandChild->repaints, 1); @@ -6081,8 +6082,8 @@ void tst_QGraphicsItem::opacity2() RESET_REPAINT_COUNTERS parent->setOpacity(0.0); - QTest::qWait(100); - QCOMPARE(view.repaints, 1); + QTest::qWait(10); + QTRY_COMPARE(view.repaints, 1); QCOMPARE(parent->repaints, 0); QCOMPARE(child->repaints, 0); QCOMPARE(grandChild->repaints, 0); @@ -6090,8 +6091,8 @@ void tst_QGraphicsItem::opacity2() RESET_REPAINT_COUNTERS parent->setOpacity(1.0); - QTest::qWait(100); - QCOMPARE(view.repaints, 1); + QTest::qWait(10); + QTRY_COMPARE(view.repaints, 1); QCOMPARE(parent->repaints, 1); QCOMPARE(child->repaints, 1); QCOMPARE(grandChild->repaints, 1); @@ -6100,8 +6101,8 @@ void tst_QGraphicsItem::opacity2() RESET_REPAINT_COUNTERS child->setOpacity(0.0); - QTest::qWait(100); - QCOMPARE(view.repaints, 1); + QTest::qWait(10); + QTRY_COMPARE(view.repaints, 1); QCOMPARE(parent->repaints, 1); QCOMPARE(child->repaints, 0); QCOMPARE(grandChild->repaints, 1); @@ -6109,8 +6110,8 @@ void tst_QGraphicsItem::opacity2() RESET_REPAINT_COUNTERS child->setOpacity(0.0); // Already 0.0; no change. - QTest::qWait(100); - QCOMPARE(view.repaints, 0); + QTest::qWait(10); + QTRY_COMPARE(view.repaints, 0); QCOMPARE(parent->repaints, 0); QCOMPARE(child->repaints, 0); QCOMPARE(grandChild->repaints, 0); @@ -6142,15 +6143,13 @@ void tst_QGraphicsItem::opacityZeroUpdates() MyGraphicsView view(&scene); view.show(); -#ifdef Q_WS_X11 - qt_x11_wait_for_window_manager(&view); -#endif - QTest::qWait(250); + QTest::qWaitForWindowShown(&view); + QTRY_VERIFY(view.repaints > 0); view.reset(); parent->setOpacity(0.0); - QTest::qWait(200); + QTest::qWait(20); // transforming items bounding rect to view coordinates const QRect childDeviceBoundingRect = child->deviceTransform(view.viewportTransform()) @@ -6161,7 +6160,7 @@ void tst_QGraphicsItem::opacityZeroUpdates() QRegion expectedRegion = parentDeviceBoundingRect.adjusted(-2, -2, 2, 2); expectedRegion += childDeviceBoundingRect.adjusted(-2, -2, 2, 2); - QCOMPARE(view.paintedRegion, expectedRegion); + QTRY_COMPARE(view.paintedRegion, expectedRegion); } class StacksBehindParentHelper : public QGraphicsRectItem @@ -6217,15 +6216,12 @@ void tst_QGraphicsItem::itemStacksBehindParent() QGraphicsView view(&scene); view.show(); -#ifdef Q_WS_X11 - qt_x11_wait_for_window_manager(&view); -#endif - QTest::qWait(250); + QTest::qWaitForWindowShown(&view); + QTest::qWait(100); paintedItems.clear(); view.viewport()->update(); - QTest::qWait(100); - - QCOMPARE(scene.items(0, 0, 100, 100), (QList() + QApplication::processEvents(); + QTRY_COMPARE(scene.items(0, 0, 100, 100), (QList() << grandChild111 << child11 << grandChild121 << child12 << parent1 << grandChild211 << child21 @@ -6239,9 +6235,9 @@ void tst_QGraphicsItem::itemStacksBehindParent() child11->setFlag(QGraphicsItem::ItemStacksBehindParent); scene.update(); paintedItems.clear(); - QTest::qWait(250); + QApplication::processEvents(); - QCOMPARE(scene.items(0, 0, 100, 100), (QList() + QTRY_COMPARE(scene.items(0, 0, 100, 100), (QList() << grandChild121 << child12 << parent1 << grandChild111 << child11 << grandChild211 << child21 @@ -6255,9 +6251,9 @@ void tst_QGraphicsItem::itemStacksBehindParent() child12->setFlag(QGraphicsItem::ItemStacksBehindParent); paintedItems.clear(); scene.update(); - QTest::qWait(250); + QApplication::processEvents(); - QCOMPARE(scene.items(0, 0, 100, 100), (QList() + QTRY_COMPARE(scene.items(0, 0, 100, 100), (QList() << parent1 << grandChild111 << child11 << grandChild121 << child12 << grandChild211 << child21 @@ -6503,31 +6499,29 @@ void tst_QGraphicsItem::tabChangesFocus() QWidget widget; widget.setLayout(layout); widget.show(); -#ifdef Q_WS_X11 - qt_x11_wait_for_window_manager(&widget); -#endif - QTest::qWait(250); - QVERIFY(scene.isActive()); + QTest::qWaitForWindowShown(&widget); + + QTRY_VERIFY(scene.isActive()); dial1->setFocus(); - QTest::qWait(125); - QVERIFY(dial1->hasFocus()); + QTest::qWait(15); + QTRY_VERIFY(dial1->hasFocus()); QTest::keyPress(QApplication::focusWidget(), Qt::Key_Tab); - QTest::qWait(125); - QVERIFY(view->hasFocus()); - QVERIFY(item->hasFocus()); + QTest::qWait(15); + QTRY_VERIFY(view->hasFocus()); + QTRY_VERIFY(item->hasFocus()); QTest::keyPress(QApplication::focusWidget(), Qt::Key_Tab); - QTest::qWait(125); + QTest::qWait(15); if (tabChangesFocus) { - QVERIFY(!view->hasFocus()); - QVERIFY(!item->hasFocus()); - QVERIFY(dial2->hasFocus()); + QTRY_VERIFY(!view->hasFocus()); + QTRY_VERIFY(!item->hasFocus()); + QTRY_VERIFY(dial2->hasFocus()); } else { - QVERIFY(view->hasFocus()); - QVERIFY(item->hasFocus()); + QTRY_VERIFY(view->hasFocus()); + QTRY_VERIFY(item->hasFocus()); QCOMPARE(item->toPlainText(), QString("\tHello")); } } @@ -6538,12 +6532,12 @@ void tst_QGraphicsItem::cacheMode() QGraphicsView view(&scene); view.resize(150, 150); view.show(); -#ifdef Q_WS_X11 - qt_x11_wait_for_window_manager(&view); -#endif + QApplication::setActiveWindow(&view); + QTest::qWaitForWindowShown(&view); + // Increase the probability of window activation // not causing another repaint of test items. - QTest::qWait(250); + QTest::qWait(50); EventTester *tester = new EventTester; EventTester *testerChild = new EventTester; @@ -6553,24 +6547,24 @@ void tst_QGraphicsItem::cacheMode() testerChild2->setFlag(QGraphicsItem::ItemIgnoresTransformations); scene.addItem(tester); - QTest::qWait(250); + QTest::qWait(10); for (int i = 0; i < 2; ++i) { // No visual change. - QCOMPARE(tester->repaints, 1); + QTRY_COMPARE(tester->repaints, 1); QCOMPARE(testerChild->repaints, 1); QCOMPARE(testerChild2->repaints, 1); tester->setCacheMode(QGraphicsItem::NoCache); testerChild->setCacheMode(QGraphicsItem::NoCache); testerChild2->setCacheMode(QGraphicsItem::NoCache); - QTest::qWait(250); - QCOMPARE(tester->repaints, 1); + QTest::qWait(25); + QTRY_COMPARE(tester->repaints, 1); QCOMPARE(testerChild->repaints, 1); QCOMPARE(testerChild2->repaints, 1); tester->setCacheMode(QGraphicsItem::DeviceCoordinateCache); testerChild->setCacheMode(QGraphicsItem::DeviceCoordinateCache); testerChild2->setCacheMode(QGraphicsItem::DeviceCoordinateCache); - QTest::qWait(250); + QTest::qWait(25); } // The first move causes a repaint as the item is painted into its pixmap. @@ -6578,8 +6572,8 @@ void tst_QGraphicsItem::cacheMode() tester->setPos(10, 10); testerChild->setPos(10, 10); testerChild2->setPos(10, 10); - QTest::qWait(250); - QCOMPARE(tester->repaints, 2); + QTest::qWait(25); + QTRY_COMPARE(tester->repaints, 2); QCOMPARE(testerChild->repaints, 2); QCOMPARE(testerChild2->repaints, 2); @@ -6594,15 +6588,15 @@ void tst_QGraphicsItem::cacheMode() // Translating does not result in a repaint. tester->translate(10, 10); - QTest::qWait(250); - QCOMPARE(tester->repaints, 2); + QTest::qWait(25); + QTRY_COMPARE(tester->repaints, 2); QCOMPARE(testerChild->repaints, 2); QCOMPARE(testerChild2->repaints, 2); // Rotating results in a repaint. tester->rotate(45); - QTest::qWait(250); - QCOMPARE(tester->repaints, 3); + QTest::qWait(25); + QTRY_COMPARE(tester->repaints, 3); QCOMPARE(testerChild->repaints, 3); QCOMPARE(testerChild2->repaints, 2); @@ -6610,8 +6604,8 @@ void tst_QGraphicsItem::cacheMode() tester->setCacheMode(QGraphicsItem::ItemCoordinateCache); // autosize testerChild->setCacheMode(QGraphicsItem::ItemCoordinateCache); // autosize testerChild2->setCacheMode(QGraphicsItem::ItemCoordinateCache); // autosize - QTest::qWait(250); - QCOMPARE(tester->repaints, 4); + QTest::qWait(25); + QTRY_COMPARE(tester->repaints, 4); QCOMPARE(testerChild->repaints, 4); QCOMPARE(testerChild2->repaints, 3); @@ -6619,30 +6613,30 @@ void tst_QGraphicsItem::cacheMode() tester->rotate(22); testerChild->rotate(22); testerChild2->rotate(22); - QTest::qWait(250); - QCOMPARE(tester->repaints, 4); + QTest::qWait(25); + QTRY_COMPARE(tester->repaints, 4); QCOMPARE(testerChild->repaints, 4); QCOMPARE(testerChild2->repaints, 3); // Explicit update causes a repaint. tester->update(0, 0, 5, 5); - QTest::qWait(250); - QCOMPARE(tester->repaints, 5); + QTest::qWait(25); + QTRY_COMPARE(tester->repaints, 5); QCOMPARE(testerChild->repaints, 4); QCOMPARE(testerChild2->repaints, 3); // Updating outside the item's bounds does not cause a repaint. tester->update(10, 10, 5, 5); - QTest::qWait(250); - QCOMPARE(tester->repaints, 5); + QTest::qWait(25); + QTRY_COMPARE(tester->repaints, 5); QCOMPARE(testerChild->repaints, 4); QCOMPARE(testerChild2->repaints, 3); // Resizing an item should cause a repaint of that item. (because of // autosize). tester->setGeometry(QRectF(-15, -15, 30, 30)); - QTest::qWait(250); - QCOMPARE(tester->repaints, 6); + QTest::qWait(25); + QTRY_COMPARE(tester->repaints, 6); QCOMPARE(testerChild->repaints, 4); QCOMPARE(testerChild2->repaints, 3); @@ -6650,22 +6644,22 @@ void tst_QGraphicsItem::cacheMode() tester->setCacheMode(QGraphicsItem::ItemCoordinateCache, QSize(30, 30)); testerChild->setCacheMode(QGraphicsItem::ItemCoordinateCache, QSize(30, 30)); testerChild2->setCacheMode(QGraphicsItem::ItemCoordinateCache, QSize(30, 30)); - QTest::qWait(250); - QCOMPARE(tester->repaints, 7); + QTest::qWait(20); + QTRY_COMPARE(tester->repaints, 7); QCOMPARE(testerChild->repaints, 5); QCOMPARE(testerChild2->repaints, 4); // Resizing the item should cause a repaint. testerChild->setGeometry(QRectF(-15, -15, 30, 30)); - QTest::qWait(250); - QCOMPARE(tester->repaints, 7); + QTest::qWait(25); + QTRY_COMPARE(tester->repaints, 7); QCOMPARE(testerChild->repaints, 6); QCOMPARE(testerChild2->repaints, 4); // Scaling the view does not cause a repaint. view.scale(0.7, 0.7); - QTest::qWait(250); - QCOMPARE(tester->repaints, 7); + QTest::qWait(25); + QTRY_COMPARE(tester->repaints, 7); QCOMPARE(testerChild->repaints, 6); QCOMPARE(testerChild2->repaints, 4); @@ -6673,54 +6667,54 @@ void tst_QGraphicsItem::cacheMode() tester->setCacheMode(QGraphicsItem::DeviceCoordinateCache); testerChild->setCacheMode(QGraphicsItem::DeviceCoordinateCache); testerChild2->setCacheMode(QGraphicsItem::DeviceCoordinateCache); - QTest::qWait(250); - QCOMPARE(tester->repaints, 8); + QTest::qWait(25); + QTRY_COMPARE(tester->repaints, 8); QCOMPARE(testerChild->repaints, 7); QCOMPARE(testerChild2->repaints, 5); // Scaling the view back should cause repaints for two of the items. view.setTransform(QTransform()); - QTest::qWait(250); - QCOMPARE(tester->repaints, 9); + QTest::qWait(25); + QTRY_COMPARE(tester->repaints, 9); QCOMPARE(testerChild->repaints, 8); QCOMPARE(testerChild2->repaints, 5); // Rotating the base item (perspective) should repaint two items. tester->setTransform(QTransform().rotate(10, Qt::XAxis)); - QTest::qWait(250); - QCOMPARE(tester->repaints, 10); + QTest::qWait(25); + QTRY_COMPARE(tester->repaints, 10); QCOMPARE(testerChild->repaints, 9); QCOMPARE(testerChild2->repaints, 5); // Moving the middle item should case a repaint even if it's a move, // because the parent is rotated with a perspective. testerChild->setPos(1, 1); - QTest::qWait(250); - QCOMPARE(tester->repaints, 10); + QTest::qWait(25); + QTRY_COMPARE(tester->repaints, 10); QCOMPARE(testerChild->repaints, 10); QCOMPARE(testerChild2->repaints, 5); // Make a huge item tester->setGeometry(QRectF(-4000, -4000, 8000, 8000)); - QTest::qWait(250); - QCOMPARE(tester->repaints, 11); + QTest::qWait(25); + QTRY_COMPARE(tester->repaints, 11); QCOMPARE(testerChild->repaints, 10); QCOMPARE(testerChild2->repaints, 5); // Move the large item - will cause a repaint as the // cache is clipped. tester->setPos(5, 0); - QTest::qWait(250); - QCOMPARE(tester->repaints, 12); + QTest::qWait(25); + QTRY_COMPARE(tester->repaints, 12); QCOMPARE(testerChild->repaints, 10); QCOMPARE(testerChild2->repaints, 5); // Hiding and showing should invalidate the cache tester->hide(); - QTest::qWait(250); + QTest::qWait(25); tester->show(); - QTest::qWait(250); - QCOMPARE(tester->repaints, 13); + QTest::qWait(25); + QTRY_COMPARE(tester->repaints, 13); QCOMPARE(testerChild->repaints, 11); QCOMPARE(testerChild2->repaints, 6); } @@ -6739,30 +6733,30 @@ void tst_QGraphicsItem::updateCachedItemAfterMove() view.show(); QTest::qWaitForWindowShown(&view); - QTest::qWait(125); + QTest::qWait(12); QTRY_VERIFY(tester->repaints > 0); tester->repaints = 0; // Move the item, should not cause repaints tester->setPos(10, 0); - QTest::qWait(125); + QTest::qWait(12); QCOMPARE(tester->repaints, 0); // Move then update, should cause one repaint tester->setPos(20, 0); tester->update(); - QTest::qWait(125); + QTest::qWait(12); QCOMPARE(tester->repaints, 1); // Hiding the item doesn't cause a repaint tester->hide(); - QTest::qWait(125); + QTest::qWait(12); QCOMPARE(tester->repaints, 1); // Moving a hidden item doesn't cause a repaint tester->setPos(30, 0); tester->update(); - QTest::qWait(125); + QTest::qWait(12); QCOMPARE(tester->repaints, 1); } @@ -7177,17 +7171,17 @@ void tst_QGraphicsItem::itemUsesExtendedStyleOption() QGraphicsView view(&scene); rect->startTrack = false; view.show(); - QTest::qWait(500); + QTest::qWaitForWindowShown(&view); rect->startTrack = true; rect->update(10, 10, 10, 10); - QTest::qWait(125); + QTest::qWait(12); rect->startTrack = false; rect->setFlag(QGraphicsItem::ItemUsesExtendedStyleOption, true); QVERIFY((rect->flags() & QGraphicsItem::ItemUsesExtendedStyleOption)); - QTest::qWait(125); + QTest::qWait(12); rect->startTrack = true; rect->update(10, 10, 10, 10); - QTest::qWait(125); + QTest::qWait(12); } void tst_QGraphicsItem::itemSendsGeometryChanges() @@ -7379,10 +7373,8 @@ void tst_QGraphicsItem::itemHasNoContents() QGraphicsView view(&scene); view.show(); -#ifdef Q_WS_X11 - qt_x11_wait_for_window_manager(&view); -#endif - QTest::qWait(100); + QTest::qWaitForWindowShown(&view); + QTRY_VERIFY(!_paintedItems.isEmpty()); _paintedItems.clear(); @@ -7390,10 +7382,10 @@ void tst_QGraphicsItem::itemHasNoContents() #ifdef Q_WS_MAC // There's no difference between update() and repaint() on the Mac, // so we have to process events here to make sure we get the event. - QTest::qWait(100); + QTest::qWait(10); #endif - QCOMPARE(_paintedItems, QList() << item2); + QTRY_COMPARE(_paintedItems, QList() << item2); } void tst_QGraphicsItem::hitTestUntransformableItem() @@ -8474,9 +8466,10 @@ void tst_QGraphicsItem::QTBUG_4233_updateCachedWithSceneRect() QGraphicsView view(&scene); view.show(); + QTest::qWaitForWindowShown(&view); QTRY_COMPARE(QApplication::activeWindow(), (QWidget *)&view); - QCOMPARE(tester->repaints, 1); + QTRY_COMPARE(tester->repaints, 1); scene.update(); // triggers "updateAll" optimization qApp->processEvents(); diff --git a/tests/auto/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp b/tests/auto/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp index a289257..5c0073c 100644 --- a/tests/auto/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp +++ b/tests/auto/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp @@ -783,11 +783,9 @@ void tst_QGraphicsProxyWidget::focusNextPrevChild() QGraphicsScene scene; QGraphicsView view(&scene); view.show(); -#ifdef Q_WS_X11 - qt_x11_wait_for_window_manager(&view); -#endif QApplication::setActiveWindow(&view); - QTest::qWait(250); + QTest::qWaitForWindowShown(&view); + QApplication::processEvents(); QTRY_COMPARE(QApplication::activeWindow(), &view); if (hasScene) { scene.addItem(proxy); @@ -832,13 +830,11 @@ void tst_QGraphicsProxyWidget::focusOutEvent() SubQGraphicsProxyWidget *proxy = new SubQGraphicsProxyWidget; scene.addItem(proxy); view.show(); -#ifdef Q_WS_X11 - qt_x11_wait_for_window_manager(&view); -#endif QApplication::setActiveWindow(&view); view.activateWindow(); view.setFocus(); - QTest::qWait(125); + QTest::qWaitForWindowShown(&view); + QApplication::processEvents(); QTRY_VERIFY(view.isVisible()); QTRY_COMPARE(QApplication::activeWindow(), &view); @@ -856,11 +852,10 @@ void tst_QGraphicsProxyWidget::focusOutEvent() if (!call) { QWidget *other = new QLineEdit(&view); other->show(); - QTest::qWait(125); + QApplication::processEvents(); QTRY_VERIFY(other->isVisible()); other->setFocus(); QTRY_VERIFY(other->hasFocus()); - QTest::qWait(125); qApp->processEvents(); QTRY_COMPARE(proxy->hasFocus(), false); QVERIFY(proxy->focusOut); @@ -992,7 +987,7 @@ void tst_QGraphicsProxyWidget::hoverEnterLeaveEvent() // in QTest::mouseMove(&view, QPoint(50, 50)); - QTest::qWait(250); + QTest::qWait(25); QTRY_COMPARE(widget->testAttribute(Qt::WA_UnderMouse), hasWidget ? true : false); // ### this attribute isn't supported QCOMPARE(widget->enterCount, hasWidget ? 1 : 0); @@ -1002,7 +997,7 @@ void tst_QGraphicsProxyWidget::hoverEnterLeaveEvent() // out QTest::mouseMove(&view, QPoint(10, 10)); - QTest::qWait(250); + QTest::qWait(25); // QTRY_COMPARE(widget->testAttribute(Qt::WA_UnderMouse), false); // ### this attribute isn't supported QCOMPARE(widget->leaveCount, hasWidget ? 1 : 0); @@ -1067,14 +1062,14 @@ void tst_QGraphicsProxyWidget::hoverMoveEvent() // in QTest::mouseMove(&view, QPoint(50, 50)); - QTest::qWait(125); + QTest::qWait(12); if (mouseDown) QTest::mousePress(view.viewport(), Qt::LeftButton); // move a little bit QTest::mouseMove(&view, QPoint(60, 60)); - QTest::qWait(125); + QTest::qWait(12); QTRY_COMPARE(widget->hoverEnter, (hasWidget && hoverEnabled) ? 1 : 0); QCOMPARE(widget->moveCount, (hasWidget && mouseTracking) || (hasWidget && mouseDown) ? 1 : 0); @@ -1098,11 +1093,9 @@ void tst_QGraphicsProxyWidget::keyPressEvent() QGraphicsView view(&scene); view.show(); view.viewport()->setFocus(); -#ifdef Q_WS_X11 - qt_x11_wait_for_window_manager(&view); -#endif QApplication::setActiveWindow(&view); - QTest::qWait(250); + QTest::qWaitForWindowShown(&view); + QApplication::processEvents(); QTRY_COMPARE(QApplication::activeWindow(), &view); SubQGraphicsProxyWidget *proxy = new SubQGraphicsProxyWidget; @@ -1142,11 +1135,8 @@ void tst_QGraphicsProxyWidget::keyReleaseEvent() QGraphicsScene scene; QGraphicsView view(&scene); view.show(); -#ifdef Q_WS_X11 - qt_x11_wait_for_window_manager(&view); -#endif QApplication::setActiveWindow(&view); - QTest::qWait(250); + QTest::qWaitForWindowShown(&view); QTRY_COMPARE(QApplication::activeWindow(), &view); @@ -1190,7 +1180,7 @@ void tst_QGraphicsProxyWidget::mouseDoubleClickEvent() view.show(); QApplication::setActiveWindow(&view); - QTest::qWait(250); + QTest::qWaitForWindowShown(&view); QTRY_COMPARE(QApplication::activeWindow(), &view); SubQGraphicsProxyWidget *proxy = new SubQGraphicsProxyWidget; @@ -1234,7 +1224,7 @@ void tst_QGraphicsProxyWidget::mousePressReleaseEvent() QGraphicsScene scene; QGraphicsView view(&scene); view.show(); - QTest::qWait(125); + QTest::qWaitForWindowShown(&view); SubQGraphicsProxyWidget *proxy = new SubQGraphicsProxyWidget; proxy->setFlag(QGraphicsItem::ItemIsFocusable, true); // ### remove me!!! @@ -1305,19 +1295,18 @@ void tst_QGraphicsProxyWidget::paintEvent() w->show(); QTest::qWaitForWindowShown(w); - - QTest::qWait(100); + QApplication::processEvents(); proxy.setWidget(w); scene.addItem(&proxy); //make sure we flush all the paint events - QTest::qWait(250); + QApplication::processEvents(); QTRY_VERIFY(proxy.paintCount > 1); proxy.paintCount = 0; w->update(); - QTest::qWait(100); + QApplication::processEvents(); QTRY_COMPARE(proxy.paintCount, 1); //the widget should have been painted now } @@ -1711,24 +1700,21 @@ void tst_QGraphicsProxyWidget::tabFocus_simpleWidget() window.setLayout(layout); window.show(); -#ifdef Q_WS_X11 - qt_x11_wait_for_window_manager(&window); -#endif QApplication::setActiveWindow(&window); window.activateWindow(); - QTest::qWait(125); + QTest::qWaitForWindowShown(&window); leftDial->setFocus(); - QTest::qWait(125); + QApplication::processEvents(); QTRY_VERIFY(leftDial->hasFocus()); EventSpy eventSpy(edit); // Tab into line edit QTest::keyPress(QApplication::focusWidget(), Qt::Key_Tab); - QTest::qWait(125); - QVERIFY(!leftDial->hasFocus()); - QVERIFY(view->hasFocus()); + QApplication::processEvents(); + QTRY_VERIFY(!leftDial->hasFocus()); + QTRY_VERIFY(view->hasFocus()); QVERIFY(view->viewport()->hasFocus()); QVERIFY(scene.hasFocus()); QVERIFY(editProxy->hasFocus()); @@ -1738,22 +1724,22 @@ void tst_QGraphicsProxyWidget::tabFocus_simpleWidget() // Tab into right dial QTest::keyPress(QApplication::focusWidget(), Qt::Key_Tab); - QTest::qWait(125); - QVERIFY(!view->hasFocus()); + QApplication::processEvents(); + QTRY_VERIFY(!view->hasFocus()); QVERIFY(!view->viewport()->hasFocus()); QVERIFY(!scene.hasFocus()); QVERIFY(!editProxy->hasFocus()); QVERIFY(!edit->hasFocus()); - QVERIFY(rightDial->hasFocus()); + QTRY_VERIFY(rightDial->hasFocus()); QCOMPARE(eventSpy.counts[QEvent::FocusIn], 1); QCOMPARE(eventSpy.counts[QEvent::FocusOut], 1); // Backtab into line edit QTest::keyPress(QApplication::focusWidget(), Qt::Key_Backtab); - QTest::qWait(125); - QVERIFY(view->hasFocus()); + QApplication::processEvents(); + QTRY_VERIFY(view->hasFocus()); QVERIFY(view->viewport()->hasFocus()); - QVERIFY(scene.hasFocus()); + QTRY_VERIFY(scene.hasFocus()); QVERIFY(editProxy->hasFocus()); QVERIFY(edit->hasFocus()); QVERIFY(!rightDial->hasFocus()); @@ -1762,13 +1748,13 @@ void tst_QGraphicsProxyWidget::tabFocus_simpleWidget() // Backtab into left dial QTest::keyPress(QApplication::focusWidget(), Qt::Key_Backtab); - QTest::qWait(125); - QVERIFY(!view->hasFocus()); + QApplication::processEvents(); + QTRY_VERIFY(!view->hasFocus()); QVERIFY(!view->viewport()->hasFocus()); QVERIFY(!scene.hasFocus()); QVERIFY(!editProxy->hasFocus()); QVERIFY(!edit->hasFocus()); - QVERIFY(leftDial->hasFocus()); + QTRY_VERIFY(leftDial->hasFocus()); QCOMPARE(eventSpy.counts[QEvent::FocusIn], 2); QCOMPARE(eventSpy.counts[QEvent::FocusOut], 2); } @@ -1796,14 +1782,12 @@ void tst_QGraphicsProxyWidget::tabFocus_simpleTwoWidgets() window.setLayout(layout); window.show(); -#ifdef Q_WS_X11 - qt_x11_wait_for_window_manager(&window); -#endif QApplication::setActiveWindow(&window); window.activateWindow(); + QTest::qWaitForWindowShown(&window); leftDial->setFocus(); - QTest::qWait(125); + QApplication::processEvents(); QTRY_VERIFY(leftDial->hasFocus()); EventSpy eventSpy(edit); @@ -1811,7 +1795,7 @@ void tst_QGraphicsProxyWidget::tabFocus_simpleTwoWidgets() // Tab into line edit QTest::keyPress(QApplication::focusWidget(), Qt::Key_Tab); - QTest::qWait(125); + QApplication::processEvents(); QVERIFY(!leftDial->hasFocus()); QVERIFY(view->hasFocus()); QVERIFY(view->viewport()->hasFocus()); @@ -1823,7 +1807,7 @@ void tst_QGraphicsProxyWidget::tabFocus_simpleTwoWidgets() // Tab into second line edit QTest::keyPress(QApplication::focusWidget(), Qt::Key_Tab); - QTest::qWait(125); + QApplication::processEvents(); QVERIFY(view->hasFocus()); QVERIFY(view->viewport()->hasFocus()); QVERIFY(scene.hasFocus()); @@ -1838,7 +1822,7 @@ void tst_QGraphicsProxyWidget::tabFocus_simpleTwoWidgets() // Tab into right dial QTest::keyPress(QApplication::focusWidget(), Qt::Key_Tab); - QTest::qWait(125); + QApplication::processEvents(); QVERIFY(!view->hasFocus()); QVERIFY(!view->viewport()->hasFocus()); QVERIFY(!scene.hasFocus()); @@ -1854,7 +1838,7 @@ void tst_QGraphicsProxyWidget::tabFocus_simpleTwoWidgets() // Backtab into line edit 2 QTest::keyPress(QApplication::focusWidget(), Qt::Key_Backtab); - QTest::qWait(125); + QApplication::processEvents(); QVERIFY(view->hasFocus()); QVERIFY(view->viewport()->hasFocus()); QVERIFY(scene.hasFocus()); @@ -1870,7 +1854,7 @@ void tst_QGraphicsProxyWidget::tabFocus_simpleTwoWidgets() // Backtab into line edit 1 QTest::keyPress(QApplication::focusWidget(), Qt::Key_Backtab); - QTest::qWait(125); + QApplication::processEvents(); QVERIFY(view->hasFocus()); QVERIFY(view->viewport()->hasFocus()); QVERIFY(scene.hasFocus()); @@ -1886,7 +1870,7 @@ void tst_QGraphicsProxyWidget::tabFocus_simpleTwoWidgets() // Backtab into left dial QTest::keyPress(QApplication::focusWidget(), Qt::Key_Backtab); - QTest::qWait(125); + QApplication::processEvents(); QVERIFY(!view->hasFocus()); QVERIFY(!view->viewport()->hasFocus()); QVERIFY(!scene.hasFocus()); @@ -1929,15 +1913,12 @@ void tst_QGraphicsProxyWidget::tabFocus_complexWidget() window.setLayout(layout); window.show(); -#ifdef Q_WS_X11 - qt_x11_wait_for_window_manager(&window); -#endif QApplication::setActiveWindow(&window); window.activateWindow(); - QTest::qWait(125); + QTest::qWaitForWindowShown(&window); leftDial->setFocus(); - QTest::qWait(125); + QApplication::processEvents(); QTRY_VERIFY(leftDial->hasFocus()); EventSpy eventSpy(edit1); @@ -1946,7 +1927,7 @@ void tst_QGraphicsProxyWidget::tabFocus_complexWidget() // Tab into group box QTest::keyPress(QApplication::focusWidget(), Qt::Key_Tab); - QTest::qWait(125); + QApplication::processEvents(); QVERIFY(!leftDial->hasFocus()); QVERIFY(view->hasFocus()); QVERIFY(view->viewport()->hasFocus()); @@ -1956,7 +1937,7 @@ void tst_QGraphicsProxyWidget::tabFocus_complexWidget() // Tab into line edit QTest::keyPress(QApplication::focusWidget(), Qt::Key_Tab); - QTest::qWait(125); + QApplication::processEvents(); edit1->hasFocus(); QVERIFY(!box->hasFocus()); QCOMPARE(eventSpy.counts[QEvent::FocusIn], 1); @@ -1964,7 +1945,7 @@ void tst_QGraphicsProxyWidget::tabFocus_complexWidget() // Tab into line edit 2 QTest::keyPress(QApplication::focusWidget(), Qt::Key_Tab); - QTest::qWait(125); + QApplication::processEvents(); edit2->hasFocus(); QVERIFY(!edit1->hasFocus()); QCOMPARE(eventSpy.counts[QEvent::FocusIn], 1); @@ -1974,7 +1955,7 @@ void tst_QGraphicsProxyWidget::tabFocus_complexWidget() // Tab into right dial QTest::keyPress(QApplication::focusWidget(), Qt::Key_Tab); - QTest::qWait(125); + QApplication::processEvents(); QVERIFY(!edit2->hasFocus()); rightDial->hasFocus(); QCOMPARE(eventSpy2.counts[QEvent::FocusIn], 1); @@ -1982,7 +1963,7 @@ void tst_QGraphicsProxyWidget::tabFocus_complexWidget() // Backtab into line edit 2 QTest::keyPress(QApplication::focusWidget(), Qt::Key_Backtab); - QTest::qWait(125); + QApplication::processEvents(); QVERIFY(!rightDial->hasFocus()); edit2->hasFocus(); QCOMPARE(eventSpy2.counts[QEvent::FocusIn], 2); @@ -1990,7 +1971,7 @@ void tst_QGraphicsProxyWidget::tabFocus_complexWidget() // Backtab into line edit 1 QTest::keyPress(QApplication::focusWidget(), Qt::Key_Backtab); - QTest::qWait(125); + QApplication::processEvents(); QVERIFY(!edit2->hasFocus()); edit1->hasFocus(); QCOMPARE(eventSpy2.counts[QEvent::FocusOut], 2); @@ -1998,14 +1979,14 @@ void tst_QGraphicsProxyWidget::tabFocus_complexWidget() // Backtab into line box QTest::keyPress(QApplication::focusWidget(), Qt::Key_Backtab); - QTest::qWait(125); + QApplication::processEvents(); QVERIFY(!edit1->hasFocus()); box->hasFocus(); QCOMPARE(eventSpy.counts[QEvent::FocusOut], 2); // Backtab into left dial QTest::keyPress(QApplication::focusWidget(), Qt::Key_Backtab); - QTest::qWait(125); + QApplication::processEvents(); QVERIFY(!box->hasFocus()); leftDial->hasFocus(); } @@ -2063,16 +2044,13 @@ void tst_QGraphicsProxyWidget::tabFocus_complexTwoWidgets() window.setLayout(layout); window.show(); -#ifdef Q_WS_X11 - qt_x11_wait_for_window_manager(&window); -#endif QApplication::setActiveWindow(&window); window.activateWindow(); - QTest::qWait(125); + QTest::qWaitForWindowShown(&window); QTRY_COMPARE(QApplication::activeWindow(), &window); leftDial->setFocus(); - QTest::qWait(125); + QApplication::processEvents(); QTRY_VERIFY(leftDial->hasFocus()); EventSpy eventSpy(edit1); @@ -2083,7 +2061,7 @@ void tst_QGraphicsProxyWidget::tabFocus_complexTwoWidgets() // Tab into group box QTest::keyPress(QApplication::focusWidget(), Qt::Key_Tab); - QTest::qWait(125); + QApplication::processEvents(); QVERIFY(!leftDial->hasFocus()); QVERIFY(view->hasFocus()); QVERIFY(view->viewport()->hasFocus()); @@ -2093,7 +2071,7 @@ void tst_QGraphicsProxyWidget::tabFocus_complexTwoWidgets() // Tab into line edit QTest::keyPress(QApplication::focusWidget(), Qt::Key_Tab); - QTest::qWait(125); + QApplication::processEvents(); edit1->hasFocus(); QVERIFY(!box->hasFocus()); QCOMPARE(eventSpy.counts[QEvent::FocusIn], 1); @@ -2101,7 +2079,7 @@ void tst_QGraphicsProxyWidget::tabFocus_complexTwoWidgets() // Tab into line edit 2 QTest::keyPress(QApplication::focusWidget(), Qt::Key_Tab); - QTest::qWait(125); + QApplication::processEvents(); edit2->hasFocus(); QVERIFY(!edit1->hasFocus()); QCOMPARE(eventSpy.counts[QEvent::FocusIn], 1); @@ -2109,13 +2087,13 @@ void tst_QGraphicsProxyWidget::tabFocus_complexTwoWidgets() // Tab into right box QTest::keyPress(QApplication::focusWidget(), Qt::Key_Tab); - QTest::qWait(125); + QApplication::processEvents(); QVERIFY(!edit2->hasFocus()); box_2->hasFocus(); // Tab into right top line edit QTest::keyPress(QApplication::focusWidget(), Qt::Key_Tab); - QTest::qWait(125); + QApplication::processEvents(); QVERIFY(!box_2->hasFocus()); edit1_2->hasFocus(); QCOMPARE(eventSpy1_2.counts[QEvent::FocusIn], 1); @@ -2123,7 +2101,7 @@ void tst_QGraphicsProxyWidget::tabFocus_complexTwoWidgets() // Tab into right bottom line edit QTest::keyPress(QApplication::focusWidget(), Qt::Key_Tab); - QTest::qWait(125); + QApplication::processEvents(); QVERIFY(!edit1_2->hasFocus()); edit2_2->hasFocus(); QCOMPARE(eventSpy1_2.counts[QEvent::FocusIn], 1); @@ -2133,50 +2111,50 @@ void tst_QGraphicsProxyWidget::tabFocus_complexTwoWidgets() // Tab into right dial QTest::keyPress(QApplication::focusWidget(), Qt::Key_Tab); - QTest::qWait(125); + QApplication::processEvents(); QVERIFY(!edit2->hasFocus()); rightDial->hasFocus(); QCOMPARE(eventSpy2_2.counts[QEvent::FocusOut], 1); // Backtab into line edit 2 QTest::keyPress(QApplication::focusWidget(), Qt::Key_Backtab); - QTest::qWait(125); + QApplication::processEvents(); QVERIFY(!rightDial->hasFocus()); edit2_2->hasFocus(); // Backtab into line edit 1 QTest::keyPress(QApplication::focusWidget(), Qt::Key_Backtab); - QTest::qWait(125); + QApplication::processEvents(); QVERIFY(!edit2_2->hasFocus()); edit1_2->hasFocus(); // Backtab into line box QTest::keyPress(QApplication::focusWidget(), Qt::Key_Backtab); - QTest::qWait(125); + QApplication::processEvents(); QVERIFY(!edit1_2->hasFocus()); box_2->hasFocus(); // Backtab into line edit 2 QTest::keyPress(QApplication::focusWidget(), Qt::Key_Backtab); - QTest::qWait(125); + QApplication::processEvents(); QVERIFY(!rightDial->hasFocus()); edit2->hasFocus(); // Backtab into line edit 1 QTest::keyPress(QApplication::focusWidget(), Qt::Key_Backtab); - QTest::qWait(125); + QApplication::processEvents(); QVERIFY(!edit2->hasFocus()); edit1->hasFocus(); // Backtab into line box QTest::keyPress(QApplication::focusWidget(), Qt::Key_Backtab); - QTest::qWait(125); + QApplication::processEvents(); QVERIFY(!edit1->hasFocus()); box->hasFocus(); // Backtab into left dial QTest::keyPress(QApplication::focusWidget(), Qt::Key_Backtab); - QTest::qWait(125); + QApplication::processEvents(); QVERIFY(!box->hasFocus()); leftDial->hasFocus(); } @@ -2200,16 +2178,13 @@ void tst_QGraphicsProxyWidget::setFocus_simpleWidget() window.setLayout(layout); window.show(); -#ifdef Q_WS_X11 - qt_x11_wait_for_window_manager(&window); -#endif QApplication::setActiveWindow(&window); window.activateWindow(); - QTest::qWait(125); + QTest::qWaitForWindowShown(&window); QTRY_COMPARE(QApplication::activeWindow(), &window); leftDial->setFocus(); - QTest::qWait(125); + QApplication::processEvents(); QTRY_VERIFY(leftDial->hasFocus()); EventSpy eventSpy(edit); @@ -2273,16 +2248,13 @@ void tst_QGraphicsProxyWidget::setFocus_simpleTwoWidgets() window.setLayout(layout); window.show(); -#ifdef Q_WS_X11 - qt_x11_wait_for_window_manager(&window); -#endif QApplication::setActiveWindow(&window); window.activateWindow(); - QTest::qWait(125); + QTest::qWaitForWindowShown(&window); QTRY_COMPARE(QApplication::activeWindow(), &window); leftDial->setFocus(); - QTest::qWait(125); + QApplication::processEvents(); QTRY_VERIFY(leftDial->hasFocus()); EventSpy eventSpy(edit); @@ -2353,16 +2325,13 @@ void tst_QGraphicsProxyWidget::setFocus_complexTwoWidgets() window.setLayout(layout); window.show(); -#ifdef Q_WS_X11 - qt_x11_wait_for_window_manager(&window); -#endif QApplication::setActiveWindow(&window); window.activateWindow(); - QTest::qWait(125); + QTest::qWaitForWindowShown(&window); QTRY_COMPARE(QApplication::activeWindow(), &window); leftDial->setFocus(); - QTest::qWait(125); + QApplication::processEvents(); QTRY_VERIFY(leftDial->hasFocus()); EventSpy eventSpy(edit1); @@ -2377,7 +2346,7 @@ void tst_QGraphicsProxyWidget::setFocus_complexTwoWidgets() QCOMPARE(eventSpy.counts[QEvent::FocusIn], 0); edit1->setFocus(); - QTest::qWait(125); + QApplication::processEvents(); QVERIFY(scene.hasFocus()); QVERIFY(edit1->hasFocus()); QVERIFY(!box->hasFocus()); @@ -2385,7 +2354,7 @@ void tst_QGraphicsProxyWidget::setFocus_complexTwoWidgets() QCOMPARE(eventSpyBox.counts[QEvent::FocusIn], 0); edit2_2->setFocus(); - QTest::qWait(125); + QApplication::processEvents(); QVERIFY(!edit1->hasFocus()); QVERIFY(!box_2->hasFocus()); QVERIFY(edit2_2->hasFocus()); @@ -2396,7 +2365,7 @@ void tst_QGraphicsProxyWidget::setFocus_complexTwoWidgets() QCOMPARE(eventSpyBox_2.counts[QEvent::FocusIn], 0); box->setFocus(); - QTest::qWait(125); + QApplication::processEvents(); QVERIFY(!edit2_2->hasFocus()); QVERIFY(!edit1->hasFocus()); QVERIFY(box->hasFocus()); @@ -2410,7 +2379,7 @@ void tst_QGraphicsProxyWidget::setFocus_complexTwoWidgets() QCOMPARE(eventSpyBox_2.counts[QEvent::FocusOut], 0); edit2_2->setFocus(); - QTest::qWait(125); + QApplication::processEvents(); QVERIFY(edit2_2->hasFocus()); QVERIFY(!edit1->hasFocus()); QVERIFY(!box->hasFocus()); @@ -2447,12 +2416,14 @@ void tst_QGraphicsProxyWidget::popup_basic() QCOMPARE(box->pos(), QPoint()); QCOMPARE(proxy->pos(), QPointF()); + QTest::qWaitForWindowShown(&view); QTest::qWait(125); + QApplication::processEvents(); QTest::mousePress(view.viewport(), Qt::LeftButton, 0, view.mapFromScene(proxy->mapToScene(proxy->boundingRect().center()))); - QTest::qWait(125); + QTest::qWait(12); QCOMPARE(box->pos(), QPoint()); @@ -2467,8 +2438,8 @@ void tst_QGraphicsProxyWidget::popup_basic() QSKIP("Does not work due to SH_Combobox_Popup", SkipAll); QCOMPARE(child->widget()->parent(), static_cast(box)); - QTest::qWait(125); - QCOMPARE(proxy->pos(), QPointF(box->pos())); + QTest::qWait(12); + QTRY_COMPARE(proxy->pos(), QPointF(box->pos())); QCOMPARE(child->x(), qreal(box->x())); QCOMPARE(child->y(), qreal(box->rect().bottom())); #ifndef Q_OS_WIN @@ -2478,7 +2449,7 @@ void tst_QGraphicsProxyWidget::popup_basic() QCOMPARE(child->widget()->y(), box->rect().bottom()); QCOMPARE(child->geometry().toRect(), child->widget()->geometry()); #endif - QTest::qWait(125); + QTest::qWait(12); } void tst_QGraphicsProxyWidget::popup_subwidget() @@ -2544,7 +2515,8 @@ void tst_QGraphicsProxyWidget::changingCursor_basic() proxy->setWidget(widget); proxy->show(); scene.addItem(proxy); - QTest::qWait(125); + QTest::qWaitForWindowShown(&view); + QApplication::processEvents(); // in QTest::mouseMove(view.viewport(), view.mapFromScene(proxy->mapToScene(proxy->boundingRect().center()))); @@ -2653,7 +2625,8 @@ void tst_QGraphicsProxyWidget::childPos() for (int i = 0; i < 2; ++i) { box->showPopup(); - QTest::qWait(50); + QApplication::processEvents(); + QApplication::processEvents(); QWidget *menu = 0; foreach (QObject *child, box->children()) { @@ -2718,7 +2691,7 @@ void tst_QGraphicsProxyWidget::windowOpacity() view.show(); QTest::qWaitForWindowShown(&view); QApplication::sendPostedEvents(); - QTest::qWait(100); + QTest::qWait(50); qRegisterMetaType >("QList"); QSignalSpy signalSpy(&scene, SIGNAL(changed(const QList &))); @@ -2727,7 +2700,7 @@ void tst_QGraphicsProxyWidget::windowOpacity() QVERIFY(widget->isVisible()); widget->setWindowOpacity(0.5); - QTest::qWait(100); + QApplication::processEvents(); // Make sure setWindowOpacity triggers an update on the scene, // and not on the widget or the proxy itself. The entire proxy needs an update @@ -2738,8 +2711,8 @@ void tst_QGraphicsProxyWidget::windowOpacity() #ifdef Q_WS_X11 paints = !X11->use_xrender; #endif - QCOMPARE(eventSpy.counts[QEvent::UpdateRequest], 0); - QCOMPARE(eventSpy.counts[QEvent::Paint], paints); + QTRY_COMPARE(eventSpy.counts[QEvent::UpdateRequest], 0); + QTRY_COMPARE(eventSpy.counts[QEvent::Paint], paints); QCOMPARE(signalSpy.count(), 1); const QList arguments = signalSpy.takeFirst(); @@ -2920,7 +2893,8 @@ void tst_QGraphicsProxyWidget::dontCrashWhenDie() { MainWidget *w = new MainWidget(); w->show(); - QTest::qWait(200); + QTest::qWaitForWindowShown(w); + QTest::qWait(100); QTest::mouseMove(w->view->viewport(), w->view->mapFromScene(w->widget->mapToScene(w->widget->boundingRect().center()))); delete w->item; } diff --git a/tests/auto/qgraphicsview/tst_qgraphicsview.cpp b/tests/auto/qgraphicsview/tst_qgraphicsview.cpp index 95a038b..0c27079 100644 --- a/tests/auto/qgraphicsview/tst_qgraphicsview.cpp +++ b/tests/auto/qgraphicsview/tst_qgraphicsview.cpp @@ -363,7 +363,7 @@ void tst_QGraphicsView::alignment() for (int k = 0; k < 3; ++k) { view.resize(100 + k * 25, 100 + k * 25); - QTest::qWait(25); + QApplication::processEvents(); } } } @@ -455,7 +455,7 @@ void tst_QGraphicsView::setScene() view.setScene(0); - QTest::qWait(250); + QTest::qWait(25); QVERIFY(!view.horizontalScrollBar()->isVisible()); QVERIFY(!view.verticalScrollBar()->isVisible()); @@ -530,7 +530,7 @@ void tst_QGraphicsView::sceneRect_growing() size *= 2; scene.setSceneRect(-size, -size, size * 2, size * 2); - QTest::qWait(25); + QApplication::processEvents(); QCOMPARE(view.sceneRect(), scene.sceneRect()); QCOMPARE(view.mapToScene(0, 0), topLeft); @@ -614,7 +614,8 @@ void tst_QGraphicsView::dragMode_scrollHand() view.setFixedSize(100, 100); view.show(); - QTest::qWait(25); + QTest::qWaitForWindowShown(&view); + QApplication::processEvents(); view.setInteractive(j ? false : true); @@ -646,9 +647,9 @@ void tst_QGraphicsView::dragMode_scrollHand() QApplication::sendEvent(view.viewport(), &event); QVERIFY(event.isAccepted()); } - QTest::qWait(250); + QApplication::processEvents(); - QVERIFY(item->isSelected()); + QTRY_VERIFY(item->isSelected()); for (int k = 0; k < 4; ++k) { #ifndef QT_NO_CURSOR @@ -689,9 +690,9 @@ void tst_QGraphicsView::dragMode_scrollHand() QApplication::sendEvent(view.viewport(), &event); QVERIFY(event.isAccepted()); } - QTest::qWait(250); + QApplication::processEvents(); - QVERIFY(item->isSelected()); + QTRY_VERIFY(item->isSelected()); QCOMPARE(view.horizontalScrollBar()->value(), horizontalScrollBarValue - 10); QCOMPARE(view.verticalScrollBar()->value(), verticalScrollBarValue - 10); #ifndef QT_NO_CURSOR @@ -749,6 +750,9 @@ void tst_QGraphicsView::dragMode_rubberBand() view.setDragMode(QGraphicsView::RubberBandDrag); + QTest::qWaitForWindowShown(&view); + QApplication::processEvents(); + for (int i = 0; i < 2; ++i) { // RubberBandDrag #ifndef QT_NO_CURSOR @@ -769,7 +773,7 @@ void tst_QGraphicsView::dragMode_rubberBand() QCOMPARE(view.viewport()->cursor().shape(), cursorShape); #endif - QTest::qWait(25); + QApplication::processEvents(); { // Move @@ -1073,7 +1077,7 @@ void tst_QGraphicsView::centerOnPoint() QFAIL(qPrintable(error)); } - QTest::qWait(1); + QApplication::processEvents(); } } @@ -2095,7 +2099,7 @@ void tst_QGraphicsView::transformationAnchor() } view.centerOn(0, 0); view.horizontalScrollBar()->setValue(100); - QTest::qWait(100); + QApplication::processEvents(); QPointF center = view.mapToScene(view.viewport()->rect().center()); @@ -2125,6 +2129,8 @@ void tst_QGraphicsView::resizeAnchor() for (int i = 0; i < 2; ++i) { view.resize(100, 100); view.show(); + QTest::qWaitForWindowShown(&view); + QApplication::processEvents(); if (i == 0) { QCOMPARE(view.resizeAnchor(), QGraphicsView::NoAnchor); @@ -2132,12 +2138,12 @@ void tst_QGraphicsView::resizeAnchor() view.setResizeAnchor(QGraphicsView::AnchorViewCenter); } view.centerOn(0, 0); - QTest::qWait(250); + QTest::qWait(25); QPointF f = view.mapToScene(50, 50); QPointF center = view.mapToScene(view.viewport()->rect().center()); - QTest::qWait(250); + QApplication::processEvents(); for (int size = 200; size <= 400; size += 25) { view.resize(size, size); @@ -2152,7 +2158,7 @@ void tst_QGraphicsView::resizeAnchor() QVERIFY(qAbs(newCenter.x() - center.x()) < slack); QVERIFY(qAbs(newCenter.y() - center.y()) < slack); } - QTest::qWait(20); + QApplication::processEvents(); } } } @@ -2760,11 +2766,11 @@ void tst_QGraphicsView::task187791_setSceneCausesUpdate() QCOMPARE(updateSpy.count(), 0); view.setScene(0); - QTest::qWait(125); - QCOMPARE(updateSpy.count(), 1); + QApplication::processEvents(); + QTRY_COMPARE(updateSpy.count(), 1); view.setScene(&scene); - QTest::qWait(125); - QCOMPARE(updateSpy.count(), 2); + QApplication::processEvents(); + QTRY_COMPARE(updateSpy.count(), 2); } class MouseMoveCounter : public QGraphicsView @@ -2808,15 +2814,15 @@ void tst_QGraphicsView::task186827_deleteReplayedItem() QApplication::sendEvent(view.viewport(), &event); } QCOMPARE(view.mouseMoves, 1); - QTest::qWait(125); - QCOMPARE(view.mouseMoves, 1); - QTest::qWait(125); + QTest::qWait(25); + QTRY_COMPARE(view.mouseMoves, 1); + QTest::qWait(25); { QMouseEvent event(QEvent::MouseMove, view.mapFromScene(25, 25), Qt::NoButton, 0, 0); QApplication::sendEvent(view.viewport(), &event); } QCOMPARE(view.mouseMoves, 2); - QTest::qWait(125); + QTest::qWait(15); } void tst_QGraphicsView::task207546_focusCrash() @@ -3412,11 +3418,11 @@ void tst_QGraphicsView::exposeRegion() QRegion expectedExposeRegion = QRect(0, 0, 5, 5); expectedExposeRegion += QRect(viewport->rect().bottomRight() - QPoint(5, 5), QSize(5, 5)); viewport->update(expectedExposeRegion); - QTest::qWait(125); + QApplication::processEvents(); // Make sure it triggers correct repaint on the view. - QCOMPARE(view.lastUpdateRegions.size(), 1); - QCOMPARE(view.lastUpdateRegions.at(0), expectedExposeRegion); + QTRY_COMPARE(view.lastUpdateRegions.size(), 1); + QTRY_COMPARE(view.lastUpdateRegions.at(0), expectedExposeRegion); // Make sure the item didn't get any repaints. QCOMPARE(item->paints, 0); @@ -3473,7 +3479,7 @@ void tst_QGraphicsView::update() #if defined QT_BUILD_INTERNAL const bool intersects = updateRect.intersects(viewportRect); QGraphicsViewPrivate *viewPrivate = static_cast(qt_widget_private(&view)); - QCOMPARE(viewPrivate->updateRect(updateRect), intersects); + QTRY_COMPARE(viewPrivate->updateRect(updateRect), intersects); QCOMPARE(viewPrivate->updateRegion(updateRect), intersects); view.lastUpdateRegions.clear(); @@ -3631,13 +3637,13 @@ void tst_QGraphicsView::task253415_reconnectUpdateSceneOnSceneChanged() QObject::connect(&scene1, SIGNAL(changed(QList)), &dummyView, SLOT(updateScene(QList))); view.setScene(&scene1); - QTest::qWait(125); + QTest::qWait(12); QGraphicsScene scene2; QObject::connect(&scene2, SIGNAL(changed(QList)), &dummyView, SLOT(updateScene(QList))); view.setScene(&scene2); - QTest::qWait(125); + QTest::qWait(12); bool wasConnected2 = QObject::disconnect(&scene2, SIGNAL(changed(QList)), &view, 0); QVERIFY(wasConnected2); @@ -3661,8 +3667,10 @@ void tst_QGraphicsView::task255529_transformationAnchorMouseAndViewportMargins() }; VpGraphicsView view(&scene); + view.setWindowFlags(Qt::X11BypassWindowManagerHint); view.show(); QTest::qWaitForWindowShown(&view); + QTest::qWait(50); QPoint mouseViewPos(20, 20); sendMouseMove(view.viewport(), mouseViewPos); -- cgit v0.12 From f16330e8d7f0e15d79b17a162a77044da57bb748 Mon Sep 17 00:00:00 2001 From: Prasanth Ullattil Date: Wed, 30 Sep 2009 10:22:29 +0200 Subject: Fix tst_QFontDialog::task256466_wrongStyle() autotest failure in Cocoa. Some fonts contain only styles other than Normal (or Regualr). If we try to retrive the font sizes for such fonts by passing an empty style string, the QFontDatabase will return a null list. This was causing the autotest to fail. This patch will make sure that a style is always selected in the QFontDialog. Reviewed-by: Olivier --- src/gui/dialogs/qfontdialog.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/gui/dialogs/qfontdialog.cpp b/src/gui/dialogs/qfontdialog.cpp index ca882c5..60fae27 100644 --- a/src/gui/dialogs/qfontdialog.cpp +++ b/src/gui/dialogs/qfontdialog.cpp @@ -602,6 +602,8 @@ void QFontDialogPrivate::updateStyles() } if (!found) styleList->setCurrentItem(0); + } else { + styleList->setCurrentItem(0); } styleEdit->setText(styleList->currentText()); -- cgit v0.12 From 8d3d7d411491e50c1c6a62f473a1fa69a3ca2773 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Wed, 30 Sep 2009 11:26:04 +0200 Subject: Compile when one includes without putting explicitly all Qt subdirs in the include path --- src/gui/s60framework/qs60mainapplication.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/s60framework/qs60mainapplication.h b/src/gui/s60framework/qs60mainapplication.h index 457764c..5f621e0 100644 --- a/src/gui/s60framework/qs60mainapplication.h +++ b/src/gui/s60framework/qs60mainapplication.h @@ -42,7 +42,7 @@ #ifndef QS60MAINAPPLICATION_H #define QS60MAINAPPLICATION_H -#include +#include #ifdef Q_WS_S60 -- cgit v0.12 From 7250463b2b67eac69b5f56fdefdbf9727c6d53af Mon Sep 17 00:00:00 2001 From: Alexis Menard Date: Wed, 30 Sep 2009 11:33:30 +0200 Subject: Install sub-attaq in the correct place. Reviewed-by:TrustMe --- demos/sub-attaq/sub-attaq.pro | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/demos/sub-attaq/sub-attaq.pro b/demos/sub-attaq/sub-attaq.pro index ba2b54b..8677ff5 100644 --- a/demos/sub-attaq/sub-attaq.pro +++ b/demos/sub-attaq/sub-attaq.pro @@ -31,13 +31,13 @@ SOURCES += boat.cpp \ RESOURCES += subattaq.qrc # install -target.path = $$[QT_INSTALL_DEMOS]/animation/sub-attaq +target.path = $$[QT_INSTALL_DEMOS]/sub-attaq sources.files = $$SOURCES \ $$HEADERS \ $$RESOURCES \ $$FORMS \ sub-attaq.pro \ pics -sources.path = $$[QT_INSTALL_DEMOS]/animation/sub-attaq +sources.path = $$[QT_INSTALL_DEMOS]/sub-attaq INSTALLS += target \ sources -- cgit v0.12 From b0aca8ecf7ff70c83ade9009fb0e7c0c8137abf7 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Wed, 30 Sep 2009 11:48:36 +0200 Subject: Phonon/EffectFactory: Remove calls to QObject tr(). Replace them by calls to QCoreApplication::translate() to provide translators with context information. Reviewed-by: Frans Englich --- src/3rdparty/phonon/mmf/effectfactory.cpp | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/3rdparty/phonon/mmf/effectfactory.cpp b/src/3rdparty/phonon/mmf/effectfactory.cpp index 4acaaa4..9843a6c 100644 --- a/src/3rdparty/phonon/mmf/effectfactory.cpp +++ b/src/3rdparty/phonon/mmf/effectfactory.cpp @@ -17,6 +17,7 @@ along with this library. If not, see . */ #include +#include #include #include @@ -57,21 +58,21 @@ QHash EffectFactory::audioEffectDescriptions(AbstractAudio switch (type) { case AbstractAudioEffect::EffectAudioEqualizer: - return constructEffectDescription(QObject::tr("audio equalizer"), "Audio equalizer."); + return constructEffectDescription(QCoreApplication::translate("Phonon::MMF::EffectFactory", "audio equalizer"), "Audio equalizer."); case AbstractAudioEffect::EffectBassBoost: - return constructEffectDescription(QObject::tr("Bass boost"), "Bass boost."); + return constructEffectDescription(QCoreApplication::translate("Phonon::MMF::EffectFactory", "Bass boost"), "Bass boost."); case AbstractAudioEffect::EffectDistanceAttenuation: - return constructEffectDescription(QObject::tr("Distance Attenuation"), "Distance Attenuation."); + return constructEffectDescription(QCoreApplication::translate("Phonon::MMF::EffectFactory", "Distance Attenuation"), "Distance Attenuation."); case AbstractAudioEffect::EffectEnvironmentalReverb: - return constructEffectDescription(QObject::tr("Environmental Reverb"), "Environmental Reverb."); + return constructEffectDescription(QCoreApplication::translate("Phonon::MMF::EffectFactory", "Environmental Reverb"), "Environmental Reverb."); case AbstractAudioEffect::EffectListenerOrientation: - return constructEffectDescription(QObject::tr("Environmental Reverb"), "Environmental Reverb."); + return constructEffectDescription(QCoreApplication::translate("Phonon::MMF::EffectFactory", "Environmental Reverb"), "Environmental Reverb."); case AbstractAudioEffect::EffectLoudness: - return constructEffectDescription(QObject::tr("Loudness"), "Loudness."); + return constructEffectDescription(QCoreApplication::translate("Phonon::MMF::EffectFactory", "Loudness"), "Loudness."); case AbstractAudioEffect::EffectSourceOrientation: - return constructEffectDescription(QObject::tr("Source Orientation"), "Source Orientation."); + return constructEffectDescription(QCoreApplication::translate("Phonon::MMF::EffectFactory", "Source Orientation"), "Source Orientation."); case AbstractAudioEffect::EffectStereoWidening: - return constructEffectDescription(QObject::tr("Stereo Widening"), "Stereo Widening."); + return constructEffectDescription(QCoreApplication::translate("Phonon::MMF::EffectFactory", "Stereo Widening"), "Stereo Widening."); } Q_ASSERT_X(false, Q_FUNC_INFO, "Unknown effect type."); -- cgit v0.12 From 45d5832a504516219167f0205901c56035118944 Mon Sep 17 00:00:00 2001 From: Alexis Menard Date: Wed, 30 Sep 2009 11:58:31 +0200 Subject: Make the test more robust because pulse doesn't clean the temp dir. I clean the directory i will use to be sure it is clean. Reviewed-by:TrustMe --- tests/auto/qfilesystemmodel/tst_qfilesystemmodel.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tests/auto/qfilesystemmodel/tst_qfilesystemmodel.cpp b/tests/auto/qfilesystemmodel/tst_qfilesystemmodel.cpp index 63bc90c..ea9304d 100644 --- a/tests/auto/qfilesystemmodel/tst_qfilesystemmodel.cpp +++ b/tests/auto/qfilesystemmodel/tst_qfilesystemmodel.cpp @@ -806,6 +806,16 @@ void tst_QFileSystemModel::sort() QDir dir(QDir::tempPath()); dir.mkdir("sortTemp"); dir.cd("sortTemp"); + QDirIterator it(dir); + while(it.hasNext()) + { + it.next(); + QFileInfo info = it.fileInfo(); + if (info.isDir()) + dir.rmdir(info.fileName()); + else + QFile::remove(info.absoluteFilePath()); + } const QString dirPath = dir.absolutePath(); QVERIFY(dir.exists()); -- cgit v0.12 From 5170432e7cb2d0d1adf7ac2ec1ece627c75470f3 Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Wed, 30 Sep 2009 12:41:58 +0200 Subject: Fix floating point precision when using qreal with QDataStream A frequent bug when using QDataStream across platforms where the size of qreal is different (such as any desktop platform and an ARM device) is that you end up using different overloads for streaming the value in and out (e.g. operator>>(double) on desktop and operator<<(float) on ARM.) This can leads to crashes and data corruption. To avoid the problem, we define a single floating point precision for the entire data stream and allow this to be set by the user. The default is to use 64-bit precision for all floating point numbers. Reviewed-by: Samuel Reviewed-by: Thiago --- src/corelib/io/io.pri | 1 + src/corelib/io/qdatastream.cpp | 102 +++++++++++++++++++++++++++-- src/corelib/io/qdatastream.h | 13 +++- tests/auto/qdatastream/tst_qdatastream.cpp | 58 +++++++++++++++- 4 files changed, 164 insertions(+), 10 deletions(-) diff --git a/src/corelib/io/io.pri b/src/corelib/io/io.pri index bca9baa..02a1586 100644 --- a/src/corelib/io/io.pri +++ b/src/corelib/io/io.pri @@ -5,6 +5,7 @@ HEADERS += \ io/qabstractfileengine_p.h \ io/qbuffer.h \ io/qdatastream.h \ + io/qdatastream_p.h \ io/qdebug.h \ io/qdir.h \ io/qdiriterator.h \ diff --git a/src/corelib/io/qdatastream.cpp b/src/corelib/io/qdatastream.cpp index 9339b8e..cc62201 100644 --- a/src/corelib/io/qdatastream.cpp +++ b/src/corelib/io/qdatastream.cpp @@ -40,6 +40,7 @@ ****************************************************************************/ #include "qdatastream.h" +#include "qdatastream_p.h" #ifndef QT_NO_DATASTREAM #include "qbuffer.h" @@ -193,6 +194,21 @@ QT_BEGIN_NAMESPACE */ /*! + \enum QDataStream::FloatingPointPrecision + + The precision of floating point numbers used for reading/writing the data. This will only have + an effect if the version of the data stream is Qt_4_6 or higher. + + \warning The floating point precision must be set to the same value on the object that writes + and the object that reads the data stream. + + \value SinglePrecision All floating point numbers in the data stream have 32-bit precision. + \value DoublePrecision All floating point numbers in the data stream have 64-bit precision. + + \sa setFloatingPointPrecision(), floatingPointPrecision() +*/ + +/*! \enum QDataStream::Status This enum describes the current status of the data stream. @@ -222,7 +238,7 @@ QT_BEGIN_NAMESPACE #endif enum { - DefaultStreamVersion = QDataStream::Qt_4_5 + DefaultStreamVersion = QDataStream::Qt_4_6 }; // ### 5.0: when streaming invalid QVariants, just the type should @@ -414,6 +430,42 @@ bool QDataStream::atEnd() const } /*! + Returns the floating point precision of the data stream. + + \since 4.6 + + \sa FloatingPointPrecision setFloatingPointPrecision() +*/ +QDataStream::FloatingPointPrecision QDataStream::floatingPointPrecision() const +{ + return d == 0 ? QDataStream::DoublePrecision : d->floatingPointPrecision; +} + +/*! + Sets the floating point precision of the data stream. If the floating point precision is + DoublePrecision and the version of the data stream is Qt_4_6 or higher, all floating point + numbers will be written and read with 64-bit precision. If the floating point precision is + SinglePrecision and the version is Qt_4_6 or higher, all floating point numbers will be written + and read with 32-bit precision. + + For versions prior to Qt_4_6, the precision of floating point numbers in the data stream depends + on the stream operator called. + + The default is DoublePrecision. + + \warning This property must be set to the same value on the object that writes and the object + that reads the data stream. + + \since 4.6 +*/ +void QDataStream::setFloatingPointPrecision(QDataStream::FloatingPointPrecision precision) +{ + if (d == 0) + d.reset(new QDataStreamPrivate()); + d->floatingPointPrecision = precision; +} + +/*! Returns the status of the data stream. \sa Status setStatus() resetStatus() @@ -517,7 +569,7 @@ void QDataStream::setByteOrder(ByteOrder bo) \value Qt_4_3 Version 9 (Qt 4.3) \value Qt_4_4 Version 10 (Qt 4.4) \value Qt_4_5 Version 11 (Qt 4.5) - \omitvalue Qt_4_6 + \value Qt_4_6 Version 12 (Qt 4.6) \sa setVersion(), version() */ @@ -754,13 +806,23 @@ QDataStream &QDataStream::operator>>(bool &i) /*! \overload - Reads a 32-bit floating point number from the stream into \a f, + Reads a floating point number from the stream into \a f, using the standard IEEE 754 format. Returns a reference to the stream. + + \sa setFloatingPointPrecision() */ QDataStream &QDataStream::operator>>(float &f) -{ +{ + if (version() >= QDataStream::Qt_4_6 + && floatingPointPrecision() == QDataStream::DoublePrecision) { + double d; + *this >> d; + f = d; + return *this; + } + f = 0.0f; CHECK_STREAM_PRECOND(*this) if (noswap) { @@ -796,13 +858,23 @@ QDataStream &QDataStream::operator>>(float &f) /*! \overload - Reads a 64-bit floating point number from the stream into \a f, + Reads a floating point number from the stream into \a f, using the standard IEEE 754 format. Returns a reference to the stream. + + \sa setFloatingPointPrecision() */ QDataStream &QDataStream::operator>>(double &f) { + if (version() >= QDataStream::Qt_4_6 + && floatingPointPrecision() == QDataStream::SinglePrecision) { + float d; + *this >> d; + f = d; + return *this; + } + f = 0.0; CHECK_STREAM_PRECOND(*this) #ifndef Q_DOUBLE_FORMAT @@ -1115,12 +1187,20 @@ QDataStream &QDataStream::operator<<(bool i) /*! \overload - Writes a 32-bit floating point number, \a f, to the stream using + Writes a floating point number, \a f, to the stream using the standard IEEE 754 format. Returns a reference to the stream. + + \sa setFloatingPointPrecision() */ QDataStream &QDataStream::operator<<(float f) { + if (version() >= QDataStream::Qt_4_6 + && floatingPointPrecision() == QDataStream::DoublePrecision) { + *this << double(f); + return *this; + } + CHECK_STREAM_PRECOND(*this) float g = f; // fixes float-on-stack problem if (noswap) { // no conversion needed @@ -1146,12 +1226,20 @@ QDataStream &QDataStream::operator<<(float f) /*! \overload - Writes a 64-bit floating point number, \a f, to the stream using + Writes a floating point number, \a f, to the stream using the standard IEEE 754 format. Returns a reference to the stream. + + \sa setFloatingPointPrecision() */ QDataStream &QDataStream::operator<<(double f) { + if (version() >= QDataStream::Qt_4_6 + && floatingPointPrecision() == QDataStream::SinglePrecision) { + *this << float(f); + return *this; + } + CHECK_STREAM_PRECOND(*this) #ifndef Q_DOUBLE_FORMAT if (noswap) { diff --git a/src/corelib/io/qdatastream.h b/src/corelib/io/qdatastream.h index b376de6..6e83204 100644 --- a/src/corelib/io/qdatastream.h +++ b/src/corelib/io/qdatastream.h @@ -42,6 +42,7 @@ #ifndef QDATASTREAM_H #define QDATASTREAM_H +#include #include #include @@ -83,7 +84,7 @@ public: Qt_4_3 = 9, Qt_4_4 = 10, Qt_4_5 = 11, - Qt_4_6 = Qt_4_5 + Qt_4_6 = 12, #if QT_VERSION >= 0x040700 #error Add the datastream version for this Qt version Qt_4_7 = Qt_4_6 @@ -101,6 +102,11 @@ public: ReadCorruptData }; + enum FloatingPointPrecision { + SinglePrecision, + DoublePrecision + }; + QDataStream(); explicit QDataStream(QIODevice *); #ifdef QT3_SUPPORT @@ -123,6 +129,9 @@ public: void setStatus(Status status); void resetStatus(); + FloatingPointPrecision floatingPointPrecision() const; + void setFloatingPointPrecision(FloatingPointPrecision precision); + ByteOrder byteOrder() const; void setByteOrder(ByteOrder); @@ -176,7 +185,7 @@ public: private: Q_DISABLE_COPY(QDataStream) - QDataStreamPrivate *d; + QScopedPointer d; QIODevice *dev; bool owndev; diff --git a/tests/auto/qdatastream/tst_qdatastream.cpp b/tests/auto/qdatastream/tst_qdatastream.cpp index 4f7b34e..add0945 100644 --- a/tests/auto/qdatastream/tst_qdatastream.cpp +++ b/tests/auto/qdatastream/tst_qdatastream.cpp @@ -204,6 +204,8 @@ private slots: void streamRealDataTypes(); + void floatingPointPrecision(); + #ifdef QT3_SUPPORT void task_224283(); #endif @@ -288,7 +290,8 @@ static int NColorRoles[] = { QPalette::AlternateBase + 1, // Qt_4_3 QPalette::ToolTipText + 1, // Qt_4_4 QPalette::ToolTipText + 1, // Qt_4_5 - 0 // add the correct value for Qt_4_6 here later + QPalette::ToolTipText + 1, // Qt_4_6 + 0 // add the correct value for Qt_4_7 here later }; // Testing get/set functions @@ -2538,9 +2541,12 @@ void tst_QDataStream::skipRawData() QFETCH(QByteArray, littleEndianData); \ QFETCH(int, expectedStatus); \ QFETCH(double, expectedValue); \ + \ + QDataStream::FloatingPointPrecision prec = sizeof(T) == sizeof(double) ? QDataStream::DoublePrecision : QDataStream::SinglePrecision; \ \ { \ QDataStream stream(&bigEndianData, QIODevice::ReadOnly); \ + stream.setFloatingPointPrecision(prec); \ T i; \ stream >> i; \ QCOMPARE((int) stream.status(), expectedStatus); \ @@ -2549,6 +2555,7 @@ void tst_QDataStream::skipRawData() { \ QDataStream stream(&littleEndianData, QIODevice::ReadOnly); \ stream.setByteOrder(QDataStream::LittleEndian); \ + stream.setFloatingPointPrecision(prec); \ T i; \ stream >> i; \ QCOMPARE((int) stream.status(), expectedStatus); \ @@ -3359,6 +3366,55 @@ void tst_QDataStream::compatibility_Qt2() QVERIFY(in_palette.color(QPalette::Light) == Qt::green); } +void tst_QDataStream::floatingPointPrecision() +{ + QByteArray ba; + { + QDataStream stream(&ba, QIODevice::WriteOnly); + QCOMPARE(QDataStream::DoublePrecision, stream.floatingPointPrecision()); + + float f = 123.0f; + stream << f; + QCOMPARE(ba.size(), int(sizeof(double))); + + double d = 234.0; + stream << d; + QCOMPARE(ba.size(), int(sizeof(double)*2)); + + stream.setFloatingPointPrecision(QDataStream::SinglePrecision); + + f = 123.0f; + stream << f; + QCOMPARE(ba.size(), int(sizeof(double)*2 + sizeof(float))); + + d = 234.0; + stream << d; + QCOMPARE(ba.size(), int(sizeof(double)*2 + sizeof(float)*2)); + } + + { + QDataStream stream(ba); + + float f = 0.0f; + stream >> f; + QCOMPARE(123.0f, f); + + double d = 0.0; + stream >> d; + QCOMPARE(234.0, d); + + f = 0.0f; + stream.setFloatingPointPrecision(QDataStream::SinglePrecision); + stream >> f; + QCOMPARE(123.0f, f); + + d = 0.0; + stream >> d; + QCOMPARE(234.0, d); + } + +} + QTEST_MAIN(tst_QDataStream) #include "tst_qdatastream.moc" -- cgit v0.12 From bbdb460ef1778298908ae677684e5855c25d0ce5 Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Wed, 30 Sep 2009 12:23:16 +0200 Subject: Fix googlechat example when Qt is lacking SSL support. Don't build the googlechat example if QSslSocket isn't available. And even then also perform a run-time check and display an error page if SSL is not available. This is because the login into Google Chat works through an https website. Reviewed-by: Jesper --- examples/webkit/googlechat/googlechat.cpp | 6 ++++++ examples/webkit/webkit.pro | 5 +++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/examples/webkit/googlechat/googlechat.cpp b/examples/webkit/googlechat/googlechat.cpp index a4a19a4..af567d1 100644 --- a/examples/webkit/googlechat/googlechat.cpp +++ b/examples/webkit/googlechat/googlechat.cpp @@ -41,6 +41,7 @@ #include #include +#include #include "googlechat.h" @@ -118,6 +119,11 @@ void GoogleChat::doLogin() { void GoogleChat::initialPage(bool ok) { if (ok) { + if (!QSslSocket::supportsSsl()) { + showError("This example requires SSL support."); + return; + } + QString s1 = evalJS("document.getElementById('Email').name"); QString s2 = evalJS("document.getElementById('Passwd').name"); QString s3 = evalJS("document.getElementById('gaia_loginform').id"); diff --git a/examples/webkit/webkit.pro b/examples/webkit/webkit.pro index 9ad6789..0a1d6bd 100644 --- a/examples/webkit/webkit.pro +++ b/examples/webkit/webkit.pro @@ -1,8 +1,9 @@ TEMPLATE = subdirs SUBDIRS += formextractor \ previewer \ - fancybrowser \ - googlechat + fancybrowser + +contains(QT_CONFIG, openssl):SUBDIRS += googlechat # install target.path = $$[QT_INSTALL_EXAMPLES]/webkit -- cgit v0.12 From 3cbde9651eab58c56b62d65b6fa4d9269bde0844 Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Wed, 30 Sep 2009 13:01:45 +0200 Subject: Compile. Missed qdatastream_p.h in last commit. --- src/corelib/io/qdatastream_p.h | 72 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 src/corelib/io/qdatastream_p.h diff --git a/src/corelib/io/qdatastream_p.h b/src/corelib/io/qdatastream_p.h new file mode 100644 index 0000000..157fee9 --- /dev/null +++ b/src/corelib/io/qdatastream_p.h @@ -0,0 +1,72 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtCore module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QDATASTREAM_P_H +#define QDATASTREAM_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include + +QT_BEGIN_NAMESPACE + +#ifndef QT_NO_DATASTREAM +class QDataStreamPrivate +{ +public: + QDataStreamPrivate() : floatingPointPrecision(QDataStream::DoublePrecision) { } + + QDataStream::FloatingPointPrecision floatingPointPrecision; +}; +#endif + +QT_END_NAMESPACE + +#endif // QDATASTREAM_P_H -- cgit v0.12 From d6244e6e5f8bb769176e07e957ec5ce93be72b55 Mon Sep 17 00:00:00 2001 From: Kent Hansen Date: Wed, 30 Sep 2009 13:21:29 +0200 Subject: Compile on VS2003 The compiler complained about ambiguity in calls to make_pair because there is also a "using std::make_pair" in the WTF namespace (wtf/HashTraits.h). Reviewed-by: Simon Hausmann --- src/3rdparty/javascriptcore/JavaScriptCore/runtime/Structure.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/3rdparty/javascriptcore/JavaScriptCore/runtime/Structure.cpp b/src/3rdparty/javascriptcore/JavaScriptCore/runtime/Structure.cpp index 05e3d7b..f7bda9e 100644 --- a/src/3rdparty/javascriptcore/JavaScriptCore/runtime/Structure.cpp +++ b/src/3rdparty/javascriptcore/JavaScriptCore/runtime/Structure.cpp @@ -46,7 +46,6 @@ #define DO_PROPERTYMAP_CONSTENCY_CHECK 0 #endif -using namespace std; using namespace WTF; namespace JSC { -- cgit v0.12 From bdf7020103bc9698584005935f00cd874f841a49 Mon Sep 17 00:00:00 2001 From: Jan-Arve Date: Wed, 30 Sep 2009 13:39:49 +0200 Subject: Make the automaticReparenting autotest pass on Mac. On Mac, all autotests will use the release version of Qt, regardless of how the autotest was built --- tests/auto/qgraphicslayout/tst_qgraphicslayout.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/auto/qgraphicslayout/tst_qgraphicslayout.cpp b/tests/auto/qgraphicslayout/tst_qgraphicslayout.cpp index feaedd9..69a64ee 100644 --- a/tests/auto/qgraphicslayout/tst_qgraphicslayout.cpp +++ b/tests/auto/qgraphicslayout/tst_qgraphicslayout.cpp @@ -153,7 +153,7 @@ void tst_QGraphicsLayout::automaticReparenting() QGraphicsWidget *ww = new QGraphicsWidget(); QGraphicsLinearLayout *l1 = new QGraphicsLinearLayout(ww); -#ifdef QT_DEBUG +#if !defined(Q_OS_MAC) && defined(QT_DEBUG) QTest::ignoreMessage(QtWarningMsg, "QGraphicsLayout::addChildLayoutItem: QGraphicsWidget \"\"" " in wrong parent; moved to correct parent"); #endif -- cgit v0.12 From 849e46599f0751ba5994d036df140d10e76e223c Mon Sep 17 00:00:00 2001 From: Janne Anttila Date: Wed, 30 Sep 2009 14:48:48 +0300 Subject: Fixed qdoublespinbox undoRedo test case for Symbian. Symbian does not have keysequene associated to redo functionality. Changed the test so that it checks if key sequence is associated to needed functionality and if not test is skipped and warning printed. Reviewed-by: Aleksandar Sasha Babic --- tests/auto/qdoublespinbox/tst_qdoublespinbox.cpp | 30 ++++++++++++++++-------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/tests/auto/qdoublespinbox/tst_qdoublespinbox.cpp b/tests/auto/qdoublespinbox/tst_qdoublespinbox.cpp index f4ea985..3d2fa42 100644 --- a/tests/auto/qdoublespinbox/tst_qdoublespinbox.cpp +++ b/tests/auto/qdoublespinbox/tst_qdoublespinbox.cpp @@ -936,19 +936,29 @@ void tst_QDoubleSpinBox::undoRedo() //testing CTRL+Z (undo) int val = QKeySequence(QKeySequence::Undo)[0]; - Qt::KeyboardModifiers mods = (Qt::KeyboardModifiers)(val & Qt::KeyboardModifierMask); - QTest::keyClick(&spin, val & ~mods, mods); - QCOMPARE(spin.value(), 0.0); - QVERIFY(!spin.lineEdit()->isUndoAvailable()); - QVERIFY(spin.lineEdit()->isRedoAvailable()); + if (val != 0) { + Qt::KeyboardModifiers mods = (Qt::KeyboardModifiers)(val & Qt::KeyboardModifierMask); + QTest::keyClick(&spin, val & ~mods, mods); + QCOMPARE(spin.value(), 0.0); + QVERIFY(!spin.lineEdit()->isUndoAvailable()); + QVERIFY(spin.lineEdit()->isRedoAvailable()); + } else { + QWARN("Undo not tested because no key sequence associated to QKeySequence::Redo"); + } + //testing CTRL+Y (redo) val = QKeySequence(QKeySequence::Redo)[0]; - mods = (Qt::KeyboardModifiers)(val & Qt::KeyboardModifierMask); - QTest::keyClick(&spin, val & ~mods, mods); - QCOMPARE(spin.value(), 1.0); - QVERIFY(!spin.lineEdit()->isRedoAvailable()); - QVERIFY(spin.lineEdit()->isUndoAvailable()); + if (val != 0) { + Qt::KeyboardModifiers mods = (Qt::KeyboardModifiers)(val & Qt::KeyboardModifierMask); + QTest::keyClick(&spin, val & ~mods, mods); + QCOMPARE(spin.value(), 1.0); + QVERIFY(!spin.lineEdit()->isRedoAvailable()); + QVERIFY(spin.lineEdit()->isUndoAvailable()); + } else { + QWARN("Redo not tested because no key sequence associated to QKeySequence::Redo"); + } + spin.setValue(55.0); QVERIFY(!spin.lineEdit()->isUndoAvailable()); -- cgit v0.12 From decaf4fe6e5270efaec6c51c4bc28664b2dbb3be Mon Sep 17 00:00:00 2001 From: Kent Hansen Date: Wed, 30 Sep 2009 13:54:04 +0200 Subject: avoid JavaScriptCore C API functions being exported from QtScript library Reviewed-by: Simon Hausmann --- src/script/script.pro | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/script/script.pro b/src/script/script.pro index 6c6b701..659aa26 100644 --- a/src/script/script.pro +++ b/src/script/script.pro @@ -62,6 +62,9 @@ DEFINES += WTF_USE_JAVASCRIPTCORE_BINDINGS=1 WTF_CHANGES=1 DEFINES += NDEBUG +# Avoid JSC C API functions being exported. +DEFINES += JS_EXPORT="" JS_EXPORTDATA="" + INCLUDEPATH += $$PWD include(script.pri) -- cgit v0.12 From d48b960a20c125a4cd7f906a89046116e3c8b376 Mon Sep 17 00:00:00 2001 From: Alexis Menard Date: Wed, 30 Sep 2009 13:57:33 +0200 Subject: Fix auto-test build. Reviewed-by:jesper --- tests/auto/qlistview/tst_qlistview.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/auto/qlistview/tst_qlistview.cpp b/tests/auto/qlistview/tst_qlistview.cpp index 499fb0b..d9cab02 100644 --- a/tests/auto/qlistview/tst_qlistview.cpp +++ b/tests/auto/qlistview/tst_qlistview.cpp @@ -59,6 +59,8 @@ #include #endif +#include "../../shared/util.h" + //TESTED_CLASS= //TESTED_FILES= -- cgit v0.12 From 21cfe5bf6550ae359d6bfa937b1308891954e9bb Mon Sep 17 00:00:00 2001 From: Alexis Menard Date: Wed, 30 Sep 2009 14:03:45 +0200 Subject: Make the test fail, not crash for now. A task is already open to fix it. Reviewed-by:jesper --- tests/auto/qdom/tst_qdom.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/auto/qdom/tst_qdom.cpp b/tests/auto/qdom/tst_qdom.cpp index 6637202..6987186 100644 --- a/tests/auto/qdom/tst_qdom.cpp +++ b/tests/auto/qdom/tst_qdom.cpp @@ -1908,7 +1908,8 @@ void tst_QDom::taskQTBUG4595_dontAssertWhenDocumentSpecifiesUnknownEncoding() co QDomDocument d; QVERIFY(d.setContent(xmlWithUnknownEncoding)); - QString dontAssert = d.toString(); // this should not assert + //QString dontAssert = d.toString(); // this should not assert + QVERIFY2(false, "Line above crashes but we still want to run all tests."); QVERIFY(true); } -- cgit v0.12