diff options
author | Frans Englich <frans.englich@nokia.com> | 2009-09-30 13:11:39 (GMT) |
---|---|---|
committer | Frans Englich <frans.englich@nokia.com> | 2009-09-30 13:11:39 (GMT) |
commit | 7c33e0f95789af1f6c091db89581f8a26b10682d (patch) | |
tree | cb8faa2ab6ce19c85a8c0c90dc852db08375868e /tests/auto | |
parent | da935e9df4c63490a7d2a716236f1e781c2d75a6 (diff) | |
parent | c3ef2d3a6d9a6e35b05cbd8f370630d5dd85415e (diff) | |
download | Qt-7c33e0f95789af1f6c091db89581f8a26b10682d.zip Qt-7c33e0f95789af1f6c091db89581f8a26b10682d.tar.gz Qt-7c33e0f95789af1f6c091db89581f8a26b10682d.tar.bz2 |
Merge commit 'origin/4.6' into mmfphonon
Diffstat (limited to 'tests/auto')
28 files changed, 873 insertions, 471 deletions
diff --git a/tests/auto/qactiongroup/tst_qactiongroup.cpp b/tests/auto/qactiongroup/tst_qactiongroup.cpp index c290941..2d215a0 100644 --- a/tests/auto/qactiongroup/tst_qactiongroup.cpp +++ b/tests/auto/qactiongroup/tst_qactiongroup.cpp @@ -226,6 +226,14 @@ void tst_QActionGroup::separators() mw.show(); +#ifdef QT_SOFTKEYS_ENABLED + // Softkeys add extra "Select" and "Back" actions to menu by default. + // Two first actions will be Select and Back when softkeys are enabled + int numSoftkeyActions = 2; +#else + int numSoftkeyActions = 0; +#endif + QAction *action = new QAction(&actGroup); action->setText("test one"); @@ -237,13 +245,13 @@ void tst_QActionGroup::separators() while (it.hasNext()) menu.addAction(it.next()); - QCOMPARE((int)menu.actions().size(), 2); + QCOMPARE((int)menu.actions().size(), 2 + numSoftkeyActions); it = QListIterator<QAction*>(actGroup.actions()); while (it.hasNext()) menu.removeAction(it.next()); - QCOMPARE((int)menu.actions().size(), 0); + QCOMPARE((int)menu.actions().size(), 0 + numSoftkeyActions); action = new QAction(&actGroup); action->setText("test two"); @@ -252,7 +260,7 @@ void tst_QActionGroup::separators() while (it.hasNext()) menu.addAction(it.next()); - QCOMPARE((int)menu.actions().size(), 3); + QCOMPARE((int)menu.actions().size(), 3 + numSoftkeyActions); } void tst_QActionGroup::testActionInTwoQActionGroup() 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/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" 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); } 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()); diff --git a/tests/auto/qfiledialog/tst_qfiledialog.cpp b/tests/auto/qfiledialog/tst_qfiledialog.cpp index 1aa5ee1..f6b082f 100644 --- a/tests/auto/qfiledialog/tst_qfiledialog.cpp +++ b/tests/auto/qfiledialog/tst_qfiledialog.cpp @@ -169,6 +169,8 @@ private slots: void task257579_sideBarWithNonCleanUrls(); void task259105_filtersCornerCases(); + void QTBUG4419_lineEditSelectAll(); + private: QByteArray userSettings; }; @@ -2153,5 +2155,32 @@ void tst_QFiledialog::task259105_filtersCornerCases() filters->setCurrentIndex(1); QCOMPARE(filters->currentText(), QLatin1String("Text Files")); } + +void tst_QFiledialog::QTBUG4419_lineEditSelectAll() +{ + QString tempPath = QDir::tempPath(); + QTemporaryFile *t; + t = new QTemporaryFile; + t->open(); + QNonNativeFileDialog fd(0, "TestFileDialog", t->fileName()); + + fd.setDirectory(tempPath); + fd.setViewMode(QFileDialog::List); + fd.setAcceptMode(QFileDialog::AcceptSave); + fd.setFileMode(QFileDialog::AnyFile); + + fd.show(); + QApplication::setActiveWindow(&fd); + QTest::qWaitForWindowShown(&fd); + QTRY_COMPARE(fd.isVisible(), true); + QTRY_COMPARE(QApplication::activeWindow(), static_cast<QWidget*>(&fd)); + + QTest::qWait(250); + QLineEdit *lineEdit = qFindChild<QLineEdit*>(&fd, "fileNameEdit"); + + QCOMPARE(tempPath + QChar('/') + lineEdit->text(), t->fileName()); + QCOMPARE(tempPath + QChar('/') + lineEdit->selectedText(), t->fileName()); +} + QTEST_MAIN(tst_QFiledialog) #include "tst_qfiledialog.moc" diff --git a/tests/auto/qfilesystemmodel/tst_qfilesystemmodel.cpp b/tests/auto/qfilesystemmodel/tst_qfilesystemmodel.cpp index a388f0a..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()); @@ -823,7 +833,7 @@ void tst_QFileSystemModel::sort() out2 << "The magic number is : " << 49 << " but i write some stuff in the file \n"; tempFile2.close(); - myModel->setRootPath(QDir::rootPath()); + myModel->setRootPath(""); myModel->setFilter(QDir::AllEntries | QDir::System | QDir::Hidden); tree->setSortingEnabled(true); tree->setModel(myModel); @@ -846,11 +856,22 @@ void tst_QFileSystemModel::sort() tree->expand(myModel->index(dirPath, 0)); QTest::qWait(500); QModelIndex parent = myModel->index(dirPath, 0); + QList<QString> expectedOrder; + expectedOrder << tempFile2.fileName() << tempFile.fileName() << dirPath + QChar('/') + "." << dirPath + QChar('/') + ".."; //File dialog Mode means sub trees are not sorted, only the current root - if (fileDialogMode) - QVERIFY(dirPath + QChar('/') + myModel->index(0, 1, parent).data(QFileSystemModel::FileNameRole).toString() != tempFile2.fileName()); - else - QCOMPARE(dirPath + QChar('/') + myModel->index(0, 1, parent).data(QFileSystemModel::FileNameRole).toString(), tempFile2.fileName()); + if (fileDialogMode) { + QList<QString> actualRows; + for(int i = 0; i < myModel->rowCount(parent); ++i) + { + actualRows << dirPath + QChar('/') + myModel->index(i, 1, parent).data(QFileSystemModel::FileNameRole).toString(); + } + QVERIFY(actualRows != expectedOrder); + } else { + for(int i = 0; i < myModel->rowCount(parent); ++i) + { + QVERIFY(dirPath + QChar('/') + myModel->index(i, 1, parent).data(QFileSystemModel::FileNameRole).toString() == expectedOrder.at(i)); + } + } delete tree; delete myModel; diff --git a/tests/auto/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp b/tests/auto/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp index 2fee98d..9f13aca 100644 --- a/tests/auto/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp +++ b/tests/auto/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp @@ -40,9 +40,10 @@ ****************************************************************************/ #include <QtTest/QtTest> -#include <qgraphicsanchorlayout.h> -#include <qgraphicswidget.h> -#include <qgraphicsproxywidget.h> +#include <QtGui/qgraphicsanchorlayout.h> +#include <private/qgraphicsanchorlayout_p.h> +#include <QtGui/qgraphicswidget.h> +#include <QtGui/qgraphicsproxywidget.h> #include <QtGui/qgraphicsview.h> class tst_QGraphicsAnchorLayout : public QObject { @@ -142,6 +143,11 @@ static bool checkReverseDirection(QGraphicsWidget *w) return true; } +static bool layoutHasConflict(QGraphicsAnchorLayout *l) +{ + return QGraphicsAnchorLayoutPrivate::get(l)->hasConflicts(); +} + void tst_QGraphicsAnchorLayout::simple() { QGraphicsWidget *w1 = createItem(); @@ -154,8 +160,6 @@ void tst_QGraphicsAnchorLayout::simple() QGraphicsWidget p; p.setLayout(l); - QVERIFY(l->hasConflicts() == false); - QCOMPARE(l->count(), 2); } @@ -185,8 +189,6 @@ void tst_QGraphicsAnchorLayout::simple_center() setAnchor(l, b, Qt::AnchorBottom, c, Qt::AnchorTop, 0); setAnchor(l, c, Qt::AnchorBottom, l, Qt::AnchorBottom, 0); - QVERIFY(l->hasConflicts() == false); - QCOMPARE(l->count(), 3); QGraphicsWidget *p = new QGraphicsWidget(0, Qt::Window); @@ -234,8 +236,6 @@ void tst_QGraphicsAnchorLayout::simple_semifloat() setAnchor(l, a, Qt::AnchorBottom, l, Qt::AnchorBottom, 0); setAnchor(l, b, Qt::AnchorBottom, l, Qt::AnchorBottom, 0); - QVERIFY(l->hasConflicts() == false); - QCOMPARE(l->count(), 4); QGraphicsWidget *p = new QGraphicsWidget(0, Qt::Window); @@ -296,7 +296,6 @@ void tst_QGraphicsAnchorLayout::layoutDirection() view->show(); QCOMPARE(checkReverseDirection(p), true); - QVERIFY(l->hasConflicts() == false); delete p; delete view; @@ -340,8 +339,6 @@ void tst_QGraphicsAnchorLayout::diagonal() l->addAnchor(e, Qt::AnchorRight, l, Qt::AnchorRight); l->addAnchor(d, Qt::AnchorRight, e, Qt::AnchorLeft); - QVERIFY(l->hasConflicts() == false); - QCOMPARE(l->count(), 5); QGraphicsWidget p; @@ -391,7 +388,7 @@ void tst_QGraphicsAnchorLayout::diagonal() QCOMPARE(checkReverseDirection(&p), true); c->setMinimumWidth(300); - QVERIFY(l->hasConflicts()); + QVERIFY(layoutHasConflict(l)); } void tst_QGraphicsAnchorLayout::parallel() @@ -484,8 +481,6 @@ void tst_QGraphicsAnchorLayout::parallel() QCOMPARE(e->geometry(), QRectF(375, 400, 175, 100)); QCOMPARE(f->geometry(), QRectF(550, 500, 200, 100)); QCOMPARE(p.size(), layoutMaximumSize); - - QVERIFY(l->hasConflicts() == false); } void tst_QGraphicsAnchorLayout::parallel2() @@ -510,7 +505,6 @@ void tst_QGraphicsAnchorLayout::parallel2() l->addAnchor(l, Qt::AnchorLeft, b, Qt::AnchorLeft); l->addAnchor(b, Qt::AnchorRight, a, Qt::AnchorRight); - QVERIFY(l->hasConflicts() == false); QCOMPARE(l->count(), 2); QGraphicsWidget p; @@ -592,8 +586,6 @@ void tst_QGraphicsAnchorLayout::snake() QCOMPARE(b->geometry(), QRectF(90.0, 100.0, 10.0, 100.0)); QCOMPARE(c->geometry(), QRectF(90.0, 200.0, 100.0, 100.0)); QCOMPARE(p.size(), layoutMaximumSize); - - QVERIFY(l->hasConflicts() == false); } void tst_QGraphicsAnchorLayout::snakeOppositeDirections() @@ -627,7 +619,6 @@ void tst_QGraphicsAnchorLayout::snakeOppositeDirections() l->addAnchor(c, Qt::AnchorRight, l, Qt::AnchorRight); - QVERIFY(l->hasConflicts() == false); QCOMPARE(l->count(), 3); QGraphicsWidget p; @@ -731,8 +722,6 @@ void tst_QGraphicsAnchorLayout::fairDistribution() QCOMPARE(c->geometry(), QRectF(200.0, 200.0, 100.0, 100.0)); QCOMPARE(d->geometry(), QRectF(0.0, 300.0, 300.0, 100.0)); QCOMPARE(p.size(), layoutMaximumSize); - - QVERIFY(l->hasConflicts() == false); } void tst_QGraphicsAnchorLayout::fairDistributionOppositeDirections() @@ -809,8 +798,6 @@ void tst_QGraphicsAnchorLayout::fairDistributionOppositeDirections() QCOMPARE(a->size(), d->size()); QCOMPARE(e->size().width(), 4 * a->size().width()); QCOMPARE(p.size(), layoutMaximumSize); - - QVERIFY(l->hasConflicts() == false); } void tst_QGraphicsAnchorLayout::proportionalPreferred() @@ -873,8 +860,6 @@ void tst_QGraphicsAnchorLayout::proportionalPreferred() QCOMPARE(a->size().width(), 10 * factor); QCOMPARE(c->size().width(), 14 * factor); QCOMPARE(p.size(), QSizeF(12, 400)); - - QVERIFY(l->hasConflicts() == false); } void tst_QGraphicsAnchorLayout::example() @@ -928,7 +913,6 @@ void tst_QGraphicsAnchorLayout::example() l->addAnchor(l, Qt::AnchorLeft, g, Qt::AnchorLeft); l->addAnchor(f, Qt::AnchorRight, g, Qt::AnchorRight); - QVERIFY(l->hasConflicts() == false); QCOMPARE(l->count(), 7); QGraphicsWidget p; @@ -1017,8 +1001,6 @@ void tst_QGraphicsAnchorLayout::setSpacing() QCOMPARE(b->geometry(), QRectF(24, 0, 20, 20)); QCOMPARE(c->geometry(), QRectF(0, 20, 44, 20)); - QVERIFY(l->hasConflicts() == false); - delete p; delete view; } @@ -1103,7 +1085,6 @@ void tst_QGraphicsAnchorLayout::hardComplexS60() QSizeF layoutMaximumSize = l->effectiveSizeHint(Qt::MaximumSize); QCOMPARE(layoutMaximumSize, QSizeF(240, 40)); - QVERIFY(l->hasConflicts() == false); delete p; } @@ -1166,7 +1147,6 @@ void tst_QGraphicsAnchorLayout::delete_anchor() QGraphicsWidget *p = new QGraphicsWidget; p->setLayout(l); - QVERIFY(l->hasConflicts() == false); QCOMPARE(l->count(), 3); scene.addItem(p); @@ -1281,6 +1261,12 @@ void tst_QGraphicsAnchorLayout::sizePolicy() delete view; } +/*! + \internal + + Uses private API. (We have decided to pull hasConflicts() out of the API). However, it also + tests some tight conditions (almost-in-conflict) that we really want to test. +*/ void tst_QGraphicsAnchorLayout::conflicts() { QGraphicsWidget *a = createItem(QSizeF(80,10), QSizeF(90,10), QSizeF(100,10), "a"); @@ -1311,13 +1297,13 @@ void tst_QGraphicsAnchorLayout::conflicts() p->setLayout(l); - QCOMPARE(l->hasConflicts(), true); + QCOMPARE(layoutHasConflict(l), true); a->setMinimumSize(QSizeF(29,10)); - QCOMPARE(l->hasConflicts(), false); + QCOMPARE(layoutHasConflict(l), false); a->setMinimumSize(QSizeF(30,10)); - QCOMPARE(l->hasConflicts(), false); + QCOMPARE(layoutHasConflict(l), false); delete p; } diff --git a/tests/auto/qgraphicsanchorlayout1/tst_qgraphicsanchorlayout1.cpp b/tests/auto/qgraphicsanchorlayout1/tst_qgraphicsanchorlayout1.cpp index a6746db..a521b78 100644 --- a/tests/auto/qgraphicsanchorlayout1/tst_qgraphicsanchorlayout1.cpp +++ b/tests/auto/qgraphicsanchorlayout1/tst_qgraphicsanchorlayout1.cpp @@ -43,7 +43,8 @@ #include <QtTest/QtTest> #include <QTest> #include <QMetaType> -#include <QGraphicsAnchorLayout> +#include <QtGui/qgraphicsanchorlayout.h> +#include <private/qgraphicsanchorlayout_p.h> #define TEST_COMPLEX_CASES @@ -60,7 +61,7 @@ public: bool isValid() { - return !hasConflicts(); + return !QGraphicsAnchorLayoutPrivate::get(this)->hasConflicts(); } void setAnchor( diff --git a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp index 956faa1..ef9fe9e 100644 --- a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp +++ b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp @@ -62,7 +62,6 @@ #include "../../shared/util.h" - //TESTED_CLASS= //TESTED_FILES= @@ -307,6 +306,7 @@ private slots: void task240400_clickOnTextItem(); void task243707_addChildBeforeParent(); void task197802_childrenVisibility(); + void QTBUG_4233_updateCachedWithSceneRect(); private: QList<QGraphicsItem *> paintedItems; @@ -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() @@ -8463,5 +8455,35 @@ void tst_QGraphicsItem::stackBefore() QCOMPARE(scene.items(QPointF(2, 2), Qt::IntersectsItemBoundingRect, Qt::AscendingOrder), (QList<QGraphicsItem *>() << child2 << child4 << child3 << child1)); } +void tst_QGraphicsItem::QTBUG_4233_updateCachedWithSceneRect() +{ + EventTester *tester = new EventTester; + tester->setCacheMode(QGraphicsItem::ItemCoordinateCache); + + QGraphicsScene scene; + scene.addItem(tester); + scene.setSceneRect(-100, -100, 200, 200); // contains the tester item + + QGraphicsView view(&scene); + view.show(); + QTest::qWaitForWindowShown(&view); + QTRY_COMPARE(QApplication::activeWindow(), (QWidget *)&view); + + QTRY_COMPARE(tester->repaints, 1); + + scene.update(); // triggers "updateAll" optimization + qApp->processEvents(); + qApp->processEvents(); // in 4.6 only one processEvents is necessary + + QCOMPARE(tester->repaints, 1); + + scene.update(); // triggers "updateAll" optimization + tester->update(); + qApp->processEvents(); + qApp->processEvents(); // in 4.6 only one processEvents is necessary + + QCOMPARE(tester->repaints, 2); +} + QTEST_MAIN(tst_QGraphicsItem) #include "tst_qgraphicsitem.moc" 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 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/qgraphicswidget/tst_qgraphicswidget.cpp b/tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp index 9045acf..b6750ea 100644 --- a/tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp +++ b/tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp @@ -824,7 +824,8 @@ void tst_QGraphicsWidget::initStyleOption() if (underMouse) { view.resize(300, 300); view.show(); - QTest::qWait(125); + QTest::qWaitForWindowShown(&view); + QTest::qWait(20); sendMouseMove(view.viewport(), view.mapFromScene(widget->mapToScene(widget->boundingRect().center()))); } @@ -877,7 +878,7 @@ void tst_QGraphicsWidget::layout() } widget.setLayout(layout); - QTest::qWait(250); + QTest::qWait(25); QCOMPARE(widget.layout(), static_cast<QGraphicsLayout*>(layout)); for (int i = 0; i < children.count(); ++i) { @@ -917,13 +918,13 @@ void tst_QGraphicsWidget::layoutDirection() widget.setLayoutDirection(layoutDirection); QCOMPARE(widget.testAttribute(Qt::WA_SetLayoutDirection), true); view->show(); - QTest::qWait(100); + QTest::qWaitForWindowShown(view); for (int i = 0; i < children.count(); ++i) { QCOMPARE(children[i]->layoutDirection(), layoutDirection); QCOMPARE(children[i]->testAttribute(Qt::WA_SetLayoutDirection), false); view->repaint(); - QTest::qWait(200); - QCOMPARE(children[i]->m_painterLayoutDirection, layoutDirection); + QApplication::processEvents(); + QTRY_COMPARE(children[i]->m_painterLayoutDirection, layoutDirection); } delete view; } @@ -1156,8 +1157,8 @@ void tst_QGraphicsWidget::setTabOrder() if (!children.isEmpty()) { QGraphicsWidget *first = children.first(); view.viewport()->setFocus(); - QTest::qWait(250); - QVERIFY(view.viewport()->hasFocus()); + QApplication::processEvents(); + QTRY_VERIFY(view.viewport()->hasFocus()); first->setFocus(); QVERIFY(first->hasFocus()); QVERIFY(scene.hasFocus()); @@ -1198,11 +1199,8 @@ void tst_QGraphicsWidget::setTabOrderAndReparent() QGraphicsScene scene; QGraphicsView view(&scene); view.show(); -#ifdef Q_WS_X11 - qt_x11_wait_for_window_manager(&view); -#endif QApplication::setActiveWindow(&view); - QTest::qWait(25); + QTest::qWaitForWindowShown(&view); QTRY_COMPARE(QApplication::activeWindow(), &view); int i; @@ -1341,11 +1339,8 @@ void tst_QGraphicsWidget::verifyFocusChain() QGraphicsScene scene; QGraphicsView view(&scene); view.show(); -#ifdef Q_WS_X11 - qt_x11_wait_for_window_manager(&view); -#endif QApplication::setActiveWindow(&view); - QTest::qWait(25); + QTest::qWaitForWindowShown(&view); QTRY_COMPARE(QApplication::activeWindow(), &view); { @@ -1419,39 +1414,38 @@ void tst_QGraphicsWidget::verifyFocusChain() w1_2->setFocusPolicy(Qt::StrongFocus); scene.addItem(w1_2); window->show(); -#ifdef Q_WS_X11 - qt_x11_wait_for_window_manager(window); -#endif + QApplication::setActiveWindow(window); + QTest::qWaitForWindowShown(window); lineEdit->setFocus(); - QTest::qWait(250); - QVERIFY(lineEdit->hasFocus()); + QTest::qWait(25); + QTRY_VERIFY(lineEdit->hasFocus()); QTest::keyPress(QApplication::focusWidget(), Qt::Key_Tab); - QTest::qWait(250); - QVERIFY(w1_1->hasFocus()); + QTest::qWait(25); + QTRY_VERIFY(w1_1->hasFocus()); QTest::keyPress(QApplication::focusWidget(), Qt::Key_Tab); - QTest::qWait(250); - QVERIFY(w1_2->hasFocus()); + QTest::qWait(25); + QTRY_VERIFY(w1_2->hasFocus()); // remove the tabFocusFirst and insert new item delete w1_1; // calls _q_removeItemLater - QTest::qWait(250); + QTest::qWait(25); SubQGraphicsWidget *w1_3 = new SubQGraphicsWidget; w1_3->setFocusPolicy(Qt::StrongFocus); w1_3->setData(0, "w1_3"); w1_3->setGeometry(50,0,25, 25); scene.addItem(w1_3); - QVERIFY(w1_2->hasFocus()); + QTRY_VERIFY(w1_2->hasFocus()); QTest::keyPress(QApplication::focusWidget(), Qt::Key_Backtab); - QTest::qWait(250); - QVERIFY(lineEdit->hasFocus()); + QTest::qWait(25); + QTRY_VERIFY(lineEdit->hasFocus()); // tabFocusFirst should now point to w1_2 QTest::keyPress(QApplication::focusWidget(), Qt::Key_Tab); - QTest::qWait(250); - QVERIFY(w1_2->hasFocus()); + QTest::qWait(25); + QTRY_VERIFY(w1_2->hasFocus()); QTest::keyPress(QApplication::focusWidget(), Qt::Key_Tab); - QTest::qWait(250); - QVERIFY(w1_3->hasFocus()); + QTest::qWait(25); + QTRY_VERIFY(w1_3->hasFocus()); scene.removeItem(w1_2); // does not call _q_removeItemLater delete w1_2; // calls _q_removeItemLater @@ -1460,18 +1454,18 @@ void tst_QGraphicsWidget::verifyFocusChain() w1_4->setData(0, "w1_4"); w1_4->setGeometry(75,0,25, 25); scene.addItem(w1_4); - QVERIFY(w1_3->hasFocus()); - QTest::qWait(250); + QTRY_VERIFY(w1_3->hasFocus()); + QTest::qWait(25); QVERIFY(compareFocusChain(view, QList<QGraphicsItem*>() << w1_3 << w1_4)); QTest::keyPress(QApplication::focusWidget(), Qt::Key_Backtab); - QTest::qWait(250); - QVERIFY(lineEdit->hasFocus()); + QTest::qWait(25); + QTRY_VERIFY(lineEdit->hasFocus()); // tabFocusFirst should now point to w1_3 QTest::keyPress(QApplication::focusWidget(), Qt::Key_Tab); - QTest::qWait(250); - QVERIFY(w1_3->hasFocus()); - QTest::qWait(250); - QVERIFY(compareFocusChain(view, QList<QGraphicsItem*>() << w1_3 << w1_4)); + QTest::qWait(25); + QTRY_VERIFY(w1_3->hasFocus()); + QTest::qWait(25); + QTRY_VERIFY(compareFocusChain(view, QList<QGraphicsItem*>() << w1_3 << w1_4)); delete window; } } @@ -2353,9 +2347,7 @@ void tst_QGraphicsWidget::painterStateProtectionOnWindowFrame() QGraphicsView view(&scene); scene.addItem(widget); view.show(); -#ifdef Q_WS_X11 - qt_x11_wait_for_window_manager(&view); -#endif + QTest::qWaitForWindowShown(&view); QTest::qWait(500); } @@ -2561,14 +2553,11 @@ void tst_QGraphicsWidget::ensureClipping() QGraphicsView view(&scene); view.setOptimizationFlag(QGraphicsView::IndirectPainting); view.show(); -#ifdef Q_WS_X11 - qt_x11_wait_for_window_manager(&view); -#endif - QTest::qWait(250); + QTest::qWaitForWindowShown(&view); QList<QGraphicsItem *> expected; expected << clipWidget << childWidget << childitem; - QVERIFY(scene.drawnItems.contains(clipWidget)); + QTRY_VERIFY(scene.drawnItems.contains(clipWidget)); QVERIFY(scene.drawnItems.contains(childWidget)); QVERIFY(scene.drawnItems.contains(childitem)); } @@ -2630,11 +2619,12 @@ void tst_QGraphicsWidget::respectHFW() view->show(); window->setGeometry(0, 0, 70, 70); + QTest::qWaitForWindowShown(view); { // here we go - simulate a interactive resize of the window - QTest::qWait(200); + QTest::qWait(100); QTest::mouseMove(view, view->mapFromScene(71, 71)); // bottom right corner - QTest::qWait(200); + QTest::qWait(100); QTest::mousePress(view->viewport(), Qt::LeftButton, 0, view->mapFromScene(71, 71), 200); view->grabMouse(); @@ -2648,7 +2638,7 @@ void tst_QGraphicsWidget::respectHFW() QApplication::sendEvent(view->viewport(), &e); view->releaseMouse(); } - QTest::qWait(200); + QTest::qWait(100); const QSizeF winSize = window->size(); qreal minHFW = window->effectiveSizeHint(Qt::MinimumSize, QSizeF(winSize.width(), -1)).height(); QVERIFY(qAbs(minHFW - winSize.height()) < 1); diff --git a/tests/auto/qlistview/tst_qlistview.cpp b/tests/auto/qlistview/tst_qlistview.cpp index b51434f..d9cab02 100644 --- a/tests/auto/qlistview/tst_qlistview.cpp +++ b/tests/auto/qlistview/tst_qlistview.cpp @@ -59,6 +59,8 @@ #include <windows.h> #endif +#include "../../shared/util.h" + //TESTED_CLASS= //TESTED_FILES= @@ -1630,7 +1632,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/qlistwidget/tst_qlistwidget.cpp b/tests/auto/qlistwidget/tst_qlistwidget.cpp index d31b07f..e825c8f 100644 --- a/tests/auto/qlistwidget/tst_qlistwidget.cpp +++ b/tests/auto/qlistwidget/tst_qlistwidget.cpp @@ -302,6 +302,11 @@ void tst_QListWidget::openPersistentEditor() void tst_QListWidget::closePersistentEditor() { +#if defined(Q_OS_SYMBIAN) + //give the Symbian app start event queue time to clear + QTest::qWait(1000); +#endif + // Boundry checking int childCount = testWidget->viewport()->children().count(); testWidget->closePersistentEditor(0); diff --git a/tests/auto/qlocalsocket/lackey/lackey.pro b/tests/auto/qlocalsocket/lackey/lackey.pro index efb2f52..8182394 100644 --- a/tests/auto/qlocalsocket/lackey/lackey.pro +++ b/tests/auto/qlocalsocket/lackey/lackey.pro @@ -1,4 +1,4 @@ -include(../src/src.pri) +#include(../src/src.pri) QT = core script network diff --git a/tests/auto/qlocalsocket/tst_qlocalsocket.cpp b/tests/auto/qlocalsocket/tst_qlocalsocket.cpp index 1180d4d..be39d00 100644 --- a/tests/auto/qlocalsocket/tst_qlocalsocket.cpp +++ b/tests/auto/qlocalsocket/tst_qlocalsocket.cpp @@ -87,6 +87,8 @@ private slots: void sendData_data(); void sendData(); + void readBufferOverflow(); + void fullPath(); void hitMaximumConnections_data(); @@ -102,13 +104,15 @@ private slots: void longPath(); void waitForDisconnect(); + void waitForDisconnectByServer(); void removeServer(); void recycleServer(); + void multiConnect(); + void writeOnlySocket(); void writeToClientAndDisconnect(); - void debug(); void bytesWrittenSignal(); @@ -151,7 +155,13 @@ public: LocalServer() : QLocalServer() { connect(this, SIGNAL(newConnection()), this, SLOT(slotNewConnection())); - }; + } + + bool listen(const QString &name) + { + removeServer(name); + return QLocalServer::listen(name); + } QList<int> hits; @@ -553,6 +563,40 @@ void tst_QLocalSocket::sendData() QCOMPARE(spy.count(), (canListen ? 1 : 0)); } +void tst_QLocalSocket::readBufferOverflow() +{ + const int readBufferSize = 128; + const int dataBufferSize = readBufferSize * 2; + const QString serverName = QLatin1String("myPreciousTestServer"); + LocalServer server; + server.listen(serverName); + QVERIFY(server.isListening()); + + LocalSocket client; + client.setReadBufferSize(readBufferSize); + client.connectToServer(serverName); + + bool timedOut = true; + QVERIFY(server.waitForNewConnection(3000, &timedOut)); + QVERIFY(!timedOut); + + QCOMPARE(client.state(), QLocalSocket::ConnectedState); + QVERIFY(server.hasPendingConnections()); + + QLocalSocket* serverSocket = server.nextPendingConnection(); + char buffer[dataBufferSize]; + memset(buffer, 0, dataBufferSize); + serverSocket->write(buffer, dataBufferSize); + serverSocket->flush(); + + QVERIFY(client.waitForReadyRead()); + QCOMPARE(client.read(buffer, readBufferSize), qint64(readBufferSize)); +#if defined(QT_LOCALSOCKET_TCP) || defined(Q_OS_SYMBIAN) + QTest::qWait(250); +#endif + QCOMPARE(client.read(buffer, readBufferSize), qint64(readBufferSize)); +} + // QLocalSocket/Server can take a name or path, check that it works as expected void tst_QLocalSocket::fullPath() { @@ -833,6 +877,25 @@ void tst_QLocalSocket::waitForDisconnect() QVERIFY(timer.elapsed() < 2000); } +void tst_QLocalSocket::waitForDisconnectByServer() +{ + QString name = "tst_localsocket"; + LocalServer server; + QVERIFY(server.listen(name)); + LocalSocket socket; + QSignalSpy spy(&socket, SIGNAL(disconnected())); + QVERIFY(spy.isValid()); + socket.connectToServer(name); + QVERIFY(socket.waitForConnected(3000)); + QVERIFY(server.waitForNewConnection(3000)); + QLocalSocket *serverSocket = server.nextPendingConnection(); + QVERIFY(serverSocket); + serverSocket->close(); + QVERIFY(serverSocket->state() == QLocalSocket::UnconnectedState); + QVERIFY(socket.waitForDisconnected(3000)); + QCOMPARE(spy.count(), 1); +} + void tst_QLocalSocket::removeServer() { // this is a hostile takeover, but recovering from a crash results in the same @@ -874,6 +937,53 @@ void tst_QLocalSocket::recycleServer() QVERIFY(server.nextPendingConnection() != 0); } +void tst_QLocalSocket::multiConnect() +{ + QLocalServer server; + QLocalSocket client1; + QLocalSocket client2; + QLocalSocket client3; + + QVERIFY(server.listen("multiconnect")); + + client1.connectToServer("multiconnect"); + client2.connectToServer("multiconnect"); + client3.connectToServer("multiconnect"); + + QVERIFY(client1.waitForConnected(201)); + QVERIFY(client2.waitForConnected(202)); + QVERIFY(client3.waitForConnected(203)); + + QVERIFY(server.waitForNewConnection(201)); + QVERIFY(server.nextPendingConnection() != 0); + QVERIFY(server.waitForNewConnection(202)); + QVERIFY(server.nextPendingConnection() != 0); + QVERIFY(server.waitForNewConnection(203)); + QVERIFY(server.nextPendingConnection() != 0); +} + +void tst_QLocalSocket::writeOnlySocket() +{ + QLocalServer server; +#ifdef Q_OS_SYMBIAN + unlink("writeOnlySocket"); +#endif + QVERIFY(server.listen("writeOnlySocket")); + + QLocalSocket client; + client.connectToServer("writeOnlySocket", QIODevice::WriteOnly); + QVERIFY(client.waitForConnected()); +#if defined(Q_OS_SYMBIAN) + QTest::qWait(250); +#endif + QVERIFY(server.waitForNewConnection()); + QLocalSocket* serverSocket = server.nextPendingConnection(); + QVERIFY(serverSocket); + + QCOMPARE(client.bytesAvailable(), qint64(0)); + QCOMPARE(client.state(), QLocalSocket::ConnectedState); +} + void tst_QLocalSocket::writeToClientAndDisconnect() { #ifdef Q_OS_SYMBIAN diff --git a/tests/auto/qmainwindow/tst_qmainwindow.cpp b/tests/auto/qmainwindow/tst_qmainwindow.cpp index 38d23b6..9615c63 100644 --- a/tests/auto/qmainwindow/tst_qmainwindow.cpp +++ b/tests/auto/qmainwindow/tst_qmainwindow.cpp @@ -1297,18 +1297,27 @@ void tst_QMainWindow::createPopupMenu() mainwindow.addDockWidget(Qt::LeftDockWidgetArea, &dockwidget3); mainwindow.addDockWidget(Qt::LeftDockWidgetArea, &dockwidget4); + +#ifdef QT_SOFTKEYS_ENABLED + // Softkeys add extra "Select" and "Back" actions to menu by default. + // Two first actions will be Select and Back when softkeys are enabled + int numSoftkeyActions = 2; +#else + int numSoftkeyActions = 0; +#endif + QMenu *menu = mainwindow.createPopupMenu(); QVERIFY(menu != 0); QList<QAction *> actions = menu->actions(); - QCOMPARE(actions.size(), 7); + QCOMPARE(actions.size(), 7 + numSoftkeyActions); - QCOMPARE(actions.at(0), dockwidget1.toggleViewAction()); - QCOMPARE(actions.at(1), dockwidget2.toggleViewAction()); - QCOMPARE(actions.at(2), dockwidget3.toggleViewAction()); - QCOMPARE(actions.at(3), dockwidget4.toggleViewAction()); - QVERIFY(actions.at(4)->isSeparator()); - QCOMPARE(actions.at(5), toolbar1.toggleViewAction()); - QCOMPARE(actions.at(6), toolbar2.toggleViewAction()); + QCOMPARE(actions.at(0 + numSoftkeyActions), dockwidget1.toggleViewAction()); + QCOMPARE(actions.at(1 + numSoftkeyActions), dockwidget2.toggleViewAction()); + QCOMPARE(actions.at(2 + numSoftkeyActions), dockwidget3.toggleViewAction()); + QCOMPARE(actions.at(3 + numSoftkeyActions), dockwidget4.toggleViewAction()); + QVERIFY(actions.at(4 + numSoftkeyActions)->isSeparator()); + QCOMPARE(actions.at(5 + numSoftkeyActions), toolbar1.toggleViewAction()); + QCOMPARE(actions.at(6 + numSoftkeyActions), toolbar2.toggleViewAction()); delete menu; @@ -1319,12 +1328,12 @@ void tst_QMainWindow::createPopupMenu() menu = mainwindow.createPopupMenu(); QVERIFY(menu != 0); actions = menu->actions(); - QCOMPARE(actions.size(), 4); + QCOMPARE(actions.size(), 4 + numSoftkeyActions); - QCOMPARE(actions.at(0), dockwidget2.toggleViewAction()); - QCOMPARE(actions.at(1), dockwidget3.toggleViewAction()); - QVERIFY(actions.at(2)->isSeparator()); - QCOMPARE(actions.at(3), toolbar2.toggleViewAction()); + QCOMPARE(actions.at(0 + numSoftkeyActions), dockwidget2.toggleViewAction()); + QCOMPARE(actions.at(1 + numSoftkeyActions), dockwidget3.toggleViewAction()); + QVERIFY(actions.at(2 + numSoftkeyActions)->isSeparator()); + QCOMPARE(actions.at(3 + numSoftkeyActions), toolbar2.toggleViewAction()); delete menu; } diff --git a/tests/auto/qmake/testdata/prompt/prompt.pro b/tests/auto/qmake/testdata/prompt/prompt.pro index 02db4fe..238022c 100644 --- a/tests/auto/qmake/testdata/prompt/prompt.pro +++ b/tests/auto/qmake/testdata/prompt/prompt.pro @@ -1,2 +1,2 @@ -a = $$prompt(Prompteroo) +# a = $$prompt(Prompteroo) diff --git a/tests/auto/qmenu/tst_qmenu.cpp b/tests/auto/qmenu/tst_qmenu.cpp index e467229..726ca55 100644 --- a/tests/auto/qmenu/tst_qmenu.cpp +++ b/tests/auto/qmenu/tst_qmenu.cpp @@ -260,9 +260,17 @@ void tst_QMenu::onStatusMessageChanged(const QString &s) void tst_QMenu::addActionsAndClear() { - QCOMPARE(menus[0]->actions().count(), 0); +#ifdef QT_SOFTKEYS_ENABLED + // Softkeys add extra "Select" and "Back" actions to menu by default. + // Two first actions will be Select and Back when softkeys are enabled + int numSoftkeyActions = 2; +#else + int numSoftkeyActions = 0; +#endif + + QCOMPARE(menus[0]->actions().count(), 0 + numSoftkeyActions); createActions(); - QCOMPARE(menus[0]->actions().count(), 8); + QCOMPARE(menus[0]->actions().count(), 8 + numSoftkeyActions); menus[0]->clear(); QCOMPARE(menus[0]->actions().count(), 0); } diff --git a/tests/auto/qnetworkdiskcache/tst_qnetworkdiskcache.cpp b/tests/auto/qnetworkdiskcache/tst_qnetworkdiskcache.cpp index 86a04d0..cc5104a 100644 --- a/tests/auto/qnetworkdiskcache/tst_qnetworkdiskcache.cpp +++ b/tests/auto/qnetworkdiskcache/tst_qnetworkdiskcache.cpp @@ -259,6 +259,9 @@ void tst_QNetworkDiskCache::data_data() // public QIODevice* data(QUrl const& url) void tst_QNetworkDiskCache::data() { +#ifdef Q_OS_SYMBIAN + QSKIP("Due to mmap(...) bug in Open C [Temtrack DEF142242]", SkipAll); +#endif QFETCH(QNetworkCacheMetaData, data); SubQNetworkDiskCache cache; QUrl url(EXAMPLE_URL); @@ -335,6 +338,9 @@ void tst_QNetworkDiskCache::setCacheDirectory() // public void updateMetaData(QNetworkCacheMetaData const& metaData) void tst_QNetworkDiskCache::updateMetaData() { +#ifdef Q_OS_SYMBIAN + QSKIP("Due to mmap(...) bug in Open C [Temtrack DEF142242]", SkipAll); +#endif QUrl url(EXAMPLE_URL); SubQNetworkDiskCache cache; cache.setupWithOne(url); diff --git a/tests/auto/qprogressbar/tst_qprogressbar.cpp b/tests/auto/qprogressbar/tst_qprogressbar.cpp index d86094d..bc4583e 100644 --- a/tests/auto/qprogressbar/tst_qprogressbar.cpp +++ b/tests/auto/qprogressbar/tst_qprogressbar.cpp @@ -175,7 +175,7 @@ void tst_QProgressBar::format() bar.repainted = false; bar.setFormat("%v of %m (%p%)"); QTest::qWait(20); - QVERIFY(bar.repainted); + QTRY_VERIFY(bar.repainted); bar.repainted = false; bar.setFormat("%v of %m (%p%)"); qApp->processEvents(); diff --git a/tests/auto/qscriptjstestsuite/tst_qscriptjstestsuite.cpp b/tests/auto/qscriptjstestsuite/tst_qscriptjstestsuite.cpp index c305221..94f08d9 100644 --- a/tests/auto/qscriptjstestsuite/tst_qscriptjstestsuite.cpp +++ b/tests/auto/qscriptjstestsuite/tst_qscriptjstestsuite.cpp @@ -640,6 +640,7 @@ tst_Suite::tst_Suite() addExpectedFailure("ecma_3/Unicode/regress-352044-01.js", "issues with Unicode escape sequences in JavaScript source code", willFixInNextReleaseMessage); addExpectedFailure("ecma_3/Unicode/uc-001.js", "Unicode format-control character test (Category Cf.)", willFixInNextReleaseMessage); + addFileExclusion(".+/15\\.9\\.2\\..+", "unstable on slow machines"); addFileExclusion(".+/15\\.9\\.5\\..+", "too slooow"); addFileExclusion("regress-130451.js", "asserts"); addFileExclusion("regress-322135-01.js", "asserts"); diff --git a/tests/auto/qscriptvalue/tst_qscriptvalue.cpp b/tests/auto/qscriptvalue/tst_qscriptvalue.cpp index 6792ebf..6b64e76 100644 --- a/tests/auto/qscriptvalue/tst_qscriptvalue.cpp +++ b/tests/auto/qscriptvalue/tst_qscriptvalue.cpp @@ -51,6 +51,10 @@ //TESTED_CLASS= //TESTED_FILES= +QT_BEGIN_NAMESPACE +extern bool qt_script_isJITEnabled(); +QT_END_NAMESPACE + class tst_QScriptValue : public QObject { Q_OBJECT @@ -2886,7 +2890,6 @@ void tst_QScriptValue::equals() { QScriptValue ret = compareFun.call(QScriptValue(), QScriptValueList() << qobj1 << qobj2); QVERIFY(ret.isBool()); - QEXPECT_FAIL("", "In JSC back-end, == on QObject wrappers doesn't work", Continue); QVERIFY(ret.toBool()); ret = compareFun.call(QScriptValue(), QScriptValueList() << qobj1 << qobj3); QVERIFY(ret.isBool()); @@ -2906,7 +2909,6 @@ void tst_QScriptValue::equals() { QScriptValue ret = compareFun.call(QScriptValue(), QScriptValueList() << var1 << var2); QVERIFY(ret.isBool()); - QEXPECT_FAIL("", "In JSC back-end, == on QVariant wrappers doesn't work", Continue); QVERIFY(ret.toBool()); } } diff --git a/tests/auto/qsqldriver/qsqldriver.pro b/tests/auto/qsqldriver/qsqldriver.pro index 84f1cb2..7f289a6 100644 --- a/tests/auto/qsqldriver/qsqldriver.pro +++ b/tests/auto/qsqldriver/qsqldriver.pro @@ -15,3 +15,11 @@ wince*: { LIBS += ws2_32.lib } } + +symbian { + contains(S60_VERSION, 3.1)|contains(S60_VERSION, 3.2)|contains(S60_VERSION, 5.0) { + sqlite.path = /sys/bin + sqlite.sources = sqlite3.dll + DEPLOYMENT += sqlite + } +} diff --git a/tests/auto/qstatemachine/tst_qstatemachine.cpp b/tests/auto/qstatemachine/tst_qstatemachine.cpp index 37b34bf..b808f7f 100644 --- a/tests/auto/qstatemachine/tst_qstatemachine.cpp +++ b/tests/auto/qstatemachine/tst_qstatemachine.cpp @@ -119,6 +119,8 @@ private slots: void assignProperty(); void assignPropertyWithAnimation(); void postEvent(); + void cancelDelayedEvent(); + void postDelayedEventAndStop(); void stateFinished(); void parallelStates(); void parallelRootState(); @@ -1543,8 +1545,8 @@ private: class StringEventPoster : public QState { public: - StringEventPoster(QStateMachine *machine, const QString &value, QState *parent = 0) - : QState(parent), m_machine(machine), m_value(value), m_delay(0) {} + StringEventPoster(const QString &value, QState *parent = 0) + : QState(parent), m_value(value), m_delay(-1) {} void setString(const QString &value) { m_value = value; } @@ -1554,12 +1556,14 @@ public: protected: virtual void onEntry(QEvent *) { - m_machine->postEvent(new StringEvent(m_value), m_delay); + if (m_delay == -1) + machine()->postEvent(new StringEvent(m_value)); + else + machine()->postDelayedEvent(new StringEvent(m_value), m_delay); } virtual void onExit(QEvent *) {} private: - QStateMachine *m_machine; QString m_value; int m_delay; }; @@ -1573,7 +1577,7 @@ void tst_QStateMachine::postEvent() QTest::ignoreMessage(QtWarningMsg, "QStateMachine::postEvent: cannot post event when the state machine is not running"); machine.postEvent(&e); } - StringEventPoster *s1 = new StringEventPoster(&machine, "a"); + StringEventPoster *s1 = new StringEventPoster("a"); if (x == 1) s1->setDelay(100); QFinalState *s2 = new QFinalState; @@ -1599,6 +1603,80 @@ void tst_QStateMachine::postEvent() } } +void tst_QStateMachine::cancelDelayedEvent() +{ + QStateMachine machine; + QTest::ignoreMessage(QtWarningMsg, "QStateMachine::cancelDelayedEvent: the machine is not running"); + QVERIFY(!machine.cancelDelayedEvent(-1)); + + QState *s1 = new QState(&machine); + QFinalState *s2 = new QFinalState(&machine); + s1->addTransition(new StringTransition("a", s2)); + machine.setInitialState(s1); + + QSignalSpy startedSpy(&machine, SIGNAL(started())); + machine.start(); + QTRY_COMPARE(startedSpy.count(), 1); + QCOMPARE(machine.configuration().size(), 1); + QVERIFY(machine.configuration().contains(s1)); + + int id1 = machine.postDelayedEvent(new StringEvent("c"), 50000); + QVERIFY(id1 != -1); + int id2 = machine.postDelayedEvent(new StringEvent("b"), 25000); + QVERIFY(id2 != -1); + QVERIFY(id2 != id1); + int id3 = machine.postDelayedEvent(new StringEvent("a"), 100); + QVERIFY(id3 != -1); + QVERIFY(id3 != id2); + QVERIFY(machine.cancelDelayedEvent(id1)); + QVERIFY(!machine.cancelDelayedEvent(id1)); + QVERIFY(machine.cancelDelayedEvent(id2)); + QVERIFY(!machine.cancelDelayedEvent(id2)); + + QSignalSpy finishedSpy(&machine, SIGNAL(finished())); + QTRY_COMPARE(finishedSpy.count(), 1); + QCOMPARE(machine.configuration().size(), 1); + QVERIFY(machine.configuration().contains(s2)); +} + +void tst_QStateMachine::postDelayedEventAndStop() +{ + QStateMachine machine; + QState *s1 = new QState(&machine); + QFinalState *s2 = new QFinalState(&machine); + s1->addTransition(new StringTransition("a", s2)); + machine.setInitialState(s1); + + QSignalSpy startedSpy(&machine, SIGNAL(started())); + machine.start(); + QTRY_COMPARE(startedSpy.count(), 1); + QCOMPARE(machine.configuration().size(), 1); + QVERIFY(machine.configuration().contains(s1)); + + int id1 = machine.postDelayedEvent(new StringEvent("a"), 0); + QVERIFY(id1 != -1); + QSignalSpy stoppedSpy(&machine, SIGNAL(stopped())); + machine.stop(); + QTRY_COMPARE(stoppedSpy.count(), 1); + QCOMPARE(machine.configuration().size(), 1); + QVERIFY(machine.configuration().contains(s1)); + + machine.start(); + QTRY_COMPARE(startedSpy.count(), 2); + QCOMPARE(machine.configuration().size(), 1); + QVERIFY(machine.configuration().contains(s1)); + + int id2 = machine.postDelayedEvent(new StringEvent("a"), 1000); + QVERIFY(id2 != -1); + machine.stop(); + QTRY_COMPARE(stoppedSpy.count(), 2); + machine.start(); + QTRY_COMPARE(startedSpy.count(), 3); + QTestEventLoop::instance().enterLoop(2); + QCOMPARE(machine.configuration().size(), 1); + QVERIFY(machine.configuration().contains(s1)); +} + void tst_QStateMachine::stateFinished() { QStateMachine machine; diff --git a/tests/auto/qurl/tst_qurl.cpp b/tests/auto/qurl/tst_qurl.cpp index 8899176..fb3cf0e 100644 --- a/tests/auto/qurl/tst_qurl.cpp +++ b/tests/auto/qurl/tst_qurl.cpp @@ -186,6 +186,8 @@ private slots: void resolvedWithAbsoluteSchemes_data() const; void binaryData_data(); void binaryData(); + void fromUserInput_data(); + void fromUserInput(); void task_199967(); void task_240612(); @@ -3637,6 +3639,69 @@ void tst_QUrl::binaryData() QCOMPARE(url2, url); } +void tst_QUrl::fromUserInput_data() +{ + QTest::addColumn<QString>("string"); + QTest::addColumn<QUrl>("url"); + + // Null + QTest::newRow("null") << QString() << QUrl(); + + // File + QDirIterator it(QDir::homePath()); + QString fileString; + int c = 0; + while (it.hasNext()) { + it.next(); + QTest::newRow(QString("file-%1").arg(c++).toLatin1()) << it.filePath() << QUrl::fromLocalFile(it.filePath()); + } + + // basic latin1 + QTest::newRow("unicode-0") << QString::fromUtf8("\xC3\xA5.com/") << QUrl::fromEncoded(QString::fromUtf8("http://\xC3\xA5.com/").toUtf8(), QUrl::TolerantMode); + // unicode + QTest::newRow("unicode-1") << QString::fromUtf8("\xCE\xBB.com/") << QUrl::fromEncoded(QString::fromUtf8("http://\xCE\xBB.com/").toUtf8(), QUrl::TolerantMode); + + // no scheme + QTest::newRow("add scheme-0") << "webkit.org" << QUrl("http://webkit.org"); + QTest::newRow("add scheme-1") << "www.webkit.org" << QUrl("http://www.webkit.org"); + QTest::newRow("add scheme-2") << "ftp.webkit.org" << QUrl("ftp://ftp.webkit.org"); + QTest::newRow("add scheme-3") << "webkit" << QUrl("webkit"); + + // QUrl's tolerant parser should already handle this + QTest::newRow("not-encoded-0") << "http://webkit.org/test page.html" << QUrl("http://webkit.org/test%20page.html"); + + // Make sure the :80, i.e. port doesn't screw anything up + QUrl portUrl("http://webkit.org"); + portUrl.setPort(80); + QTest::newRow("port-0") << "webkit.org:80" << portUrl; + QTest::newRow("port-1") << "http://webkit.org:80" << portUrl; + + // mailto doesn't have a ://, but is valid + QUrl mailto("somebody@somewhere.net"); + mailto.setScheme("mailto"); + QTest::newRow("mailto") << "mailto:somebody@somewhere.net" << mailto; + + // misc + QTest::newRow("localhost-0") << "localhost" << QUrl("http://localhost"); + QTest::newRow("localhost-1") << "localhost:80" << QUrl("http://localhost:80"); + QTest::newRow("spaces-0") << " http://webkit.org/test page.html " << QUrl("http://webkit.org/test%20page.html"); + QTest::newRow("trash-0") << "webkit.org/test?someData=42%&someOtherData=abcde#anchor" << QUrl::fromEncoded("http://webkit.org/test?someData=42%25&someOtherData=abcde#anchor"); + + // FYI: The scheme in the resulting url user + QUrl authUrl("user:pass@domain.com"); + QTest::newRow("misc-1") << "user:pass@domain.com" << authUrl; +} + +// public static QUrl guessUrlFromString(QString const& string) +void tst_QUrl::fromUserInput() +{ + QFETCH(QString, string); + QFETCH(QUrl, url); + + QUrl guessedUrl = QUrl::fromUserInput(string); + QCOMPARE(guessedUrl, url); +} + void tst_QUrl::task_199967() { { |