summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSami Merilä <sami.merila@nokia.com>2009-09-30 09:24:26 (GMT)
committerSami Merilä <sami.merila@nokia.com>2009-09-30 09:24:26 (GMT)
commit256278b886252e1b455ea9faa697592cbedcd85d (patch)
tree3d9768c2e413da1f86d367641f5167d31dd1c36a
parent7171983e8c9ca106952ecc09e540da4aab8b8b0d (diff)
parentf16330e8d7f0e15d79b17a162a77044da57bb748 (diff)
downloadQt-256278b886252e1b455ea9faa697592cbedcd85d.zip
Qt-256278b886252e1b455ea9faa697592cbedcd85d.tar.gz
Qt-256278b886252e1b455ea9faa697592cbedcd85d.tar.bz2
Merge branch '4.6' of git@scm.dev.nokia.troll.no:qt/qt into 4.6
-rw-r--r--src/3rdparty/javascriptcore/JavaScriptCore/interpreter/Interpreter.cpp2
-rw-r--r--src/3rdparty/javascriptcore/JavaScriptCore/jit/JITStubs.cpp9
-rw-r--r--src/3rdparty/javascriptcore/VERSION4
-rw-r--r--src/gui/dialogs/qfontdialog.cpp2
-rw-r--r--src/gui/styles/qs60style.cpp19
-rw-r--r--src/gui/styles/qs60style.h3
-rw-r--r--src/gui/widgets/qcombobox.cpp10
-rw-r--r--src/script/api/qscriptengine.cpp4
-rw-r--r--tests/auto/qcombobox/tst_qcombobox.cpp4
-rw-r--r--tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp371
-rw-r--r--tests/auto/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp208
-rw-r--r--tests/auto/qgraphicsview/tst_qgraphicsview.cpp64
-rw-r--r--tests/auto/qlistview/tst_qlistview.cpp4
-rw-r--r--tests/auto/qscriptvalue/tst_qscriptvalue.cpp4
14 files changed, 345 insertions, 363 deletions
diff --git a/src/3rdparty/javascriptcore/JavaScriptCore/interpreter/Interpreter.cpp b/src/3rdparty/javascriptcore/JavaScriptCore/interpreter/Interpreter.cpp
index 4200023..76c8510 100644
--- a/src/3rdparty/javascriptcore/JavaScriptCore/interpreter/Interpreter.cpp
+++ b/src/3rdparty/javascriptcore/JavaScriptCore/interpreter/Interpreter.cpp
@@ -3084,6 +3084,7 @@ JSValue Interpreter::privateExecute(ExecutionFlag flag, RegisterFile* registerFi
#else
newCallFrame->init(0, vPC + 5, scopeChain, callFrame, dst, argCount, asObject(v));
#endif
+
Register* thisRegister = newCallFrame->registers() - RegisterFile::CallFrameHeaderSize - argCount;
ArgList args(thisRegister + 1, argCount - 1);
@@ -3242,7 +3243,6 @@ JSValue Interpreter::privateExecute(ExecutionFlag flag, RegisterFile* registerFi
newCallFrame->init(0, vPC + 5, scopeChain, callFrame, dst, argCount, asObject(v));
#endif
-
Register* thisRegister = newCallFrame->registers() - RegisterFile::CallFrameHeaderSize - argCount;
ArgList args(thisRegister + 1, argCount - 1);
diff --git a/src/3rdparty/javascriptcore/JavaScriptCore/jit/JITStubs.cpp b/src/3rdparty/javascriptcore/JavaScriptCore/jit/JITStubs.cpp
index 0b147df..08a4493 100644
--- a/src/3rdparty/javascriptcore/JavaScriptCore/jit/JITStubs.cpp
+++ b/src/3rdparty/javascriptcore/JavaScriptCore/jit/JITStubs.cpp
@@ -2429,8 +2429,13 @@ DEFINE_STUB_FUNCTION(int, op_eq)
goto start;
}
- if (src2.isObject())
- return asObject(cell1) == asObject(src2);
+ if (src2.isObject()) {
+ return asObject(cell1) == asObject(src2)
+#ifdef QT_BUILD_SCRIPT_LIB
+ || asObject(cell1)->compareToObject(stackFrame.callFrame, asObject(src2))
+#endif
+ ;
+ }
src1 = asObject(cell1)->toPrimitive(stackFrame.callFrame);
CHECK_FOR_EXCEPTION();
goto start;
diff --git a/src/3rdparty/javascriptcore/VERSION b/src/3rdparty/javascriptcore/VERSION
index ae70d26..edcf898 100644
--- a/src/3rdparty/javascriptcore/VERSION
+++ b/src/3rdparty/javascriptcore/VERSION
@@ -4,8 +4,8 @@ This is a snapshot of JavaScriptCore from
The commit imported was from the
- jsc-for-qtscript-4.6-staging-28092009 branch/tag
+ jsc-for-qtscript-4.6-staging-30092009 branch/tag
and has the sha1 checksum
- b98dec961e9389ddd5e10d7c4086de9a297cb984
+ e8f42cf0203bee0ba89a05e0e773d713782129b4
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());
diff --git a/src/gui/styles/qs60style.cpp b/src/gui/styles/qs60style.cpp
index 1e57167..6bdb79e 100644
--- a/src/gui/styles/qs60style.cpp
+++ b/src/gui/styles/qs60style.cpp
@@ -2397,8 +2397,6 @@ QRect QS60Style::subControlRect(ComplexControl control, const QStyleOptionComple
// lets use spinbox frame here as well, as no combobox specific value available.
const int frameThickness = cmb->frame ? pixelMetric(PM_SpinBoxFrameWidth, cmb, widget) : 0;
const int buttonWidth = QS60StylePrivate::pixelMetric(QStyle::PM_ButtonIconSize);
- const int xposMod = (cmb->rect.x()) + width - buttonMargin - buttonWidth;
- const int ypos = cmb->rect.y();
QSize buttonSize;
buttonSize.setHeight(qMax(8, (cmb->rect.height()>>1) - frameThickness)); //minimum of 8 pixels
@@ -2406,15 +2404,18 @@ QRect QS60Style::subControlRect(ComplexControl control, const QStyleOptionComple
buttonSize = buttonSize.expandedTo(QApplication::globalStrut());
switch (scontrol) {
case SC_ComboBoxArrow:
- ret.setRect(xposMod, ypos + buttonMargin, buttonWidth, height - 2*buttonMargin);
+ ret.setRect(
+ ret.x() + ret.width() - buttonMargin - buttonWidth,
+ ret.y() + buttonMargin,
+ buttonWidth,
+ height - 2*buttonMargin);
break;
case SC_ComboBoxEditField: {
- const int withFrameX = cmb->rect.x() + cmb->rect.width() - frameThickness - buttonSize.width();
- ret = QRect(
- frameThickness,
- frameThickness,
- withFrameX - frameThickness,
- cmb->rect.height() - 2*frameThickness);
+ ret.setRect(
+ ret.x() + frameThickness,
+ ret.y() + frameThickness,
+ ret.width() - 2*frameThickness - buttonSize.width(),
+ ret.height() - 2*frameThickness);
}
break;
default:
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;
diff --git a/src/gui/widgets/qcombobox.cpp b/src/gui/widgets/qcombobox.cpp
index 61532b9..95ff4c1 100644
--- a/src/gui/widgets/qcombobox.cpp
+++ b/src/gui/widgets/qcombobox.cpp
@@ -403,8 +403,8 @@ QComboBoxPrivateContainer::QComboBoxPrivateContainer(QAbstractItemView *itemView
layout->setMargin(0);
#ifdef QT_SOFTKEYS_ENABLED
- selectAction = QSoftKeyManager::createKeyedAction(QSoftKeyManager::SelectSoftKey, Qt::Key_Select, itemView);
- cancelAction = QSoftKeyManager::createKeyedAction(QSoftKeyManager::CancelSoftKey, Qt::Key_Escape, itemView);
+ selectAction = QSoftKeyManager::createKeyedAction(QSoftKeyManager::SelectSoftKey, Qt::Key_Select, this);
+ cancelAction = QSoftKeyManager::createKeyedAction(QSoftKeyManager::CancelSoftKey, Qt::Key_Escape, this);
addAction(selectAction);
addAction(cancelAction);
#endif
@@ -534,6 +534,7 @@ void QComboBoxPrivateContainer::setItemView(QAbstractItemView *itemView)
this, SLOT(setCurrentIndex(QModelIndex)));
disconnect(view, SIGNAL(destroyed()),
this, SLOT(viewDestroyed()));
+
delete view;
view = 0;
}
@@ -571,11 +572,6 @@ void QComboBoxPrivateContainer::setItemView(QAbstractItemView *itemView)
this, SLOT(setCurrentIndex(QModelIndex)));
connect(view, SIGNAL(destroyed()),
this, SLOT(viewDestroyed()));
-
-#ifdef QT_SOFTKEYS_ENABLED
- selectAction->setParent(itemView);
- cancelAction->setParent(itemView);
-#endif
}
/*!
diff --git a/src/script/api/qscriptengine.cpp b/src/script/api/qscriptengine.cpp
index ee25239..9604fff 100644
--- a/src/script/api/qscriptengine.cpp
+++ b/src/script/api/qscriptengine.cpp
@@ -1606,6 +1606,9 @@ QScriptValue QScriptEngine::newFunction(QScriptEngine::FunctionSignature fun,
}
#ifndef QT_NO_REGEXP
+
+extern QString qt_regexp_toCanonical(const QString &, QRegExp::PatternSyntax);
+
/*!
Creates a QtScript object of class RegExp with the given
\a regexp.
@@ -1620,7 +1623,6 @@ QScriptValue QScriptEngine::newRegExp(const QRegExp &regexp)
JSC::ArgList args(buf, sizeof(buf));
//convert the pattern to a ECMAScript pattern
- extern QString qt_regexp_toCanonical(const QString &, QRegExp::PatternSyntax);
QString pattern = qt_regexp_toCanonical(regexp.pattern(), regexp.patternSyntax());
if (regexp.isMinimal()) {
QString ecmaPattern;
diff --git a/tests/auto/qcombobox/tst_qcombobox.cpp b/tests/auto/qcombobox/tst_qcombobox.cpp
index 6984a88..e76f0f7 100644
--- a/tests/auto/qcombobox/tst_qcombobox.cpp
+++ b/tests/auto/qcombobox/tst_qcombobox.cpp
@@ -746,7 +746,7 @@ void tst_QComboBox::virtualAutocompletion()
// We need to set the keyboard input interval to a higher value
// as the processEvent() call takes too much time, so it restarts
// the keyboard search then
-#if defined(QT_ARCH_ARM) || defined(QT_ARCH_MIPS)
+#if defined(QT_ARCH_ARM) || defined(QT_ARCH_MIPS) || defined(QT_ARCH_SYMBIAN)
int oldInterval = QApplication::keyboardInputInterval();
QApplication::setKeyboardInputInterval(1500);
#endif
@@ -782,7 +782,7 @@ void tst_QComboBox::virtualAutocompletion()
QApplication::sendEvent(testWidget, &kr2);
qApp->processEvents(); // Process events to trigger autocompletion
QTRY_COMPARE(testWidget->currentIndex(), 3);
-#if defined(QT_ARCH_ARM) || defined(QT_ARCH_MIPS)
+#if defined(QT_ARCH_ARM) || defined(QT_ARCH_MIPS) || defined(QT_ARCH_SYMBIAN)
QApplication::setKeyboardInputInterval(oldInterval);
#endif
}
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<QGraphicsItem *> 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<QGraphicsItem *> 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<QGraphicsItem *>()
+ QApplication::processEvents();
+ QTRY_COMPARE(scene.items(0, 0, 100, 100), (QList<QGraphicsItem *>()
<< 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<QGraphicsItem *>()
+ QTRY_COMPARE(scene.items(0, 0, 100, 100), (QList<QGraphicsItem *>()
<< 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<QGraphicsItem *>()
+ QTRY_COMPARE(scene.items(0, 0, 100, 100), (QList<QGraphicsItem *>()
<< 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<QGraphicsItem *>() << item2);
+ QTRY_COMPARE(_paintedItems, QList<QGraphicsItem *>() << 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<QObject*>(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<QRectF> >("QList<QRectF>");
QSignalSpy signalSpy(&scene, SIGNAL(changed(const QList<QRectF> &)));
@@ -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<QVariant> 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<QGraphicsViewPrivate *>(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<QRectF>)), &dummyView, SLOT(updateScene(QList<QRectF>)));
view.setScene(&scene1);
- QTest::qWait(125);
+ QTest::qWait(12);
QGraphicsScene scene2;
QObject::connect(&scene2, SIGNAL(changed(QList<QRectF>)), &dummyView, SLOT(updateScene(QList<QRectF>)));
view.setScene(&scene2);
- QTest::qWait(125);
+ QTest::qWait(12);
bool wasConnected2 = QObject::disconnect(&scene2, SIGNAL(changed(QList<QRectF>)), &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);
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);
diff --git a/tests/auto/qscriptvalue/tst_qscriptvalue.cpp b/tests/auto/qscriptvalue/tst_qscriptvalue.cpp
index 2148980..6b64e76 100644
--- a/tests/auto/qscriptvalue/tst_qscriptvalue.cpp
+++ b/tests/auto/qscriptvalue/tst_qscriptvalue.cpp
@@ -2890,8 +2890,6 @@ void tst_QScriptValue::equals()
{
QScriptValue ret = compareFun.call(QScriptValue(), QScriptValueList() << qobj1 << qobj2);
QVERIFY(ret.isBool());
- if (QT_PREPEND_NAMESPACE(qt_script_isJITEnabled()))
- QEXPECT_FAIL("", "With JIT enabled, == on QObject wrappers doesn't work", Continue);
QVERIFY(ret.toBool());
ret = compareFun.call(QScriptValue(), QScriptValueList() << qobj1 << qobj3);
QVERIFY(ret.isBool());
@@ -2911,8 +2909,6 @@ void tst_QScriptValue::equals()
{
QScriptValue ret = compareFun.call(QScriptValue(), QScriptValueList() << var1 << var2);
QVERIFY(ret.isBool());
- if (QT_PREPEND_NAMESPACE(qt_script_isJITEnabled()))
- QEXPECT_FAIL("", "With JIT enabled, == on QVariant wrappers doesn't work", Continue);
QVERIFY(ret.toBool());
}
}