diff options
author | Thiago Macieira <thiago.macieira@nokia.com> | 2009-10-05 11:04:24 (GMT) |
---|---|---|
committer | Thiago Macieira <thiago.macieira@nokia.com> | 2009-10-05 11:04:24 (GMT) |
commit | 4d33c51bf00be826b8036f58cd9aea0c1f44f8ce (patch) | |
tree | 99339183e160058b996580157d8ed89bd6809562 /tests | |
parent | badcaa75b4a5e5dfbb85f5abf856abcfcfa20533 (diff) | |
parent | b0e6c5ca48c76fb17dca986e9e07adebde390e29 (diff) | |
download | Qt-4d33c51bf00be826b8036f58cd9aea0c1f44f8ce.zip Qt-4d33c51bf00be826b8036f58cd9aea0c1f44f8ce.tar.gz Qt-4d33c51bf00be826b8036f58cd9aea0c1f44f8ce.tar.bz2 |
Merge branch '4.6'
Conflicts:
src/corelib/io/qdatastream.h
tools/assistant/translations/translations_adp.pro
tools/qdoc3/test/qt-build-docs.qdocconf
tools/qdoc3/test/qt-inc.qdocconf
tools/qdoc3/test/qt.qdocconf
translations/assistant_adp_de.ts
Diffstat (limited to 'tests')
42 files changed, 1833 insertions, 124 deletions
diff --git a/tests/auto/auto.pro b/tests/auto/auto.pro index 9321e19..f3ecdae 100644 --- a/tests/auto/auto.pro +++ b/tests/auto/auto.pro @@ -203,6 +203,7 @@ SUBDIRS += \ qmainwindow \ qmake \ qmap \ + qmath \ qmatrixnxn \ qmdiarea \ qmdisubwindow \ diff --git a/tests/auto/compilerwarnings/tst_compilerwarnings.cpp b/tests/auto/compilerwarnings/tst_compilerwarnings.cpp index 907aade..0be5cb0 100644 --- a/tests/auto/compilerwarnings/tst_compilerwarnings.cpp +++ b/tests/auto/compilerwarnings/tst_compilerwarnings.cpp @@ -179,7 +179,6 @@ void tst_CompilerWarnings::warnings() << "-Wno-long-long" << "-Wshadow" << "-Wpacked" << "-Wunreachable-code" << "-Wundef" << "-Wchar-subscripts" << "-Wformat-nonliteral" << "-Wformat-security" << "-Wcast-align" - << "-Wfloat-equal" << "-o" << tmpFile << tmpSourceFile; #elif defined(Q_CC_XLC) diff --git a/tests/auto/network-settings.h b/tests/auto/network-settings.h index 059d7b8..cd48360 100644 --- a/tests/auto/network-settings.h +++ b/tests/auto/network-settings.h @@ -334,31 +334,39 @@ QByteArray QtNetworkSettings::imapExpectedReplySsl; class QtNetworkSettingsInitializerCode { public: QtNetworkSettingsInitializerCode() { -#ifdef Q_OS_SYMBIAN - // We have a non-trivial constructor in global static. +#ifdef Q_OS_SYMBIAN +#ifdef Q_CC_NOKIAX86 + // We have a non-trivial constructor in global static. // The QtNetworkSettings::serverName() uses native API which assumes // Cleanup-stack to exist. That's why we create it here and install // top level TRAP harness. CTrapCleanup *cleanupStack = q_check_ptr(CTrapCleanup::New()); - TRAPD(err, + TRAPD(err, QHostInfo testServerResult = QHostInfo::fromName(QtNetworkSettings::serverName()); if (testServerResult.error() != QHostInfo::NoError) { qWarning() << "Could not lookup" << QtNetworkSettings::serverName(); qWarning() << "Please configure the test environment!"; qWarning() << "See /etc/hosts or network-settings.h"; qFatal("Exiting"); - } - ) + } + ) delete cleanupStack; -#else +//#else + // In Symbian HW there is no sense to run this check since global statics are + // initialized before QTestLib initializes the output channel for QWarnigns. + // So if there is problem network setup, also all QtCore etc tests whcih have + // QtNetwork dependency will crash with panic "0 - Exiciting" +#endif + +#else QHostInfo testServerResult = QHostInfo::fromName(QtNetworkSettings::serverName()); if (testServerResult.error() != QHostInfo::NoError) { qWarning() << "Could not lookup" << QtNetworkSettings::serverName(); qWarning() << "Please configure the test environment!"; qWarning() << "See /etc/hosts or network-settings.h"; qFatal("Exiting"); - } -#endif + } +#endif } }; QtNetworkSettingsInitializerCode qtNetworkSettingsInitializer; diff --git a/tests/auto/q3table/tst_q3table.cpp b/tests/auto/q3table/tst_q3table.cpp index 770bf4d..bffb118 100644 --- a/tests/auto/q3table/tst_q3table.cpp +++ b/tests/auto/q3table/tst_q3table.cpp @@ -1200,7 +1200,7 @@ protected: void tst_Q3Table::editCheck() { // Test for task 28086 -#if 0 +#if 1 QSKIP("This test currently fails on all versions", SkipAll); #endif diff --git a/tests/auto/qaudioinput/tst_qaudioinput.cpp b/tests/auto/qaudioinput/tst_qaudioinput.cpp index 69b507d..3945364 100644 --- a/tests/auto/qaudioinput/tst_qaudioinput.cpp +++ b/tests/auto/qaudioinput/tst_qaudioinput.cpp @@ -139,12 +139,14 @@ void tst_QAudioInput::pullFile() // Always have default states, before start QVERIFY(audio->state() == QAudio::StopState); QVERIFY(audio->error() == QAudio::NoError); + QVERIFY(audio->clock() == 0); audio->start(&filename); QTest::qWait(20); // Check state and periodSize() are valid non-zero values. QVERIFY(audio->state() == QAudio::ActiveState); QVERIFY(audio->error() == QAudio::NoError); + QVERIFY(audio->clock() > 0); QVERIFY(audio->periodSize() > 0); QVERIFY(stateSignal.count() == 1); // State changed to QAudio::ActiveState @@ -157,6 +159,7 @@ void tst_QAudioInput::pullFile() audio->stop(); QTest::qWait(20); QVERIFY(audio->state() == QAudio::StopState); + QVERIFY(audio->clock() == 0); // Can only check to make sure we got at least 1 more signal, but can be more. QVERIFY(stateSignal.count() > 1); diff --git a/tests/auto/qaudiooutput/tst_qaudiooutput.cpp b/tests/auto/qaudiooutput/tst_qaudiooutput.cpp index f1c75dc..b90873e 100644 --- a/tests/auto/qaudiooutput/tst_qaudiooutput.cpp +++ b/tests/auto/qaudiooutput/tst_qaudiooutput.cpp @@ -142,6 +142,7 @@ void tst_QAudioOutput::pullFile() // Always have default states, before start QVERIFY(audio->state() == QAudio::StopState); QVERIFY(audio->error() == QAudio::NoError); + QVERIFY(audio->clock() == 0); audio->start(&file); QTest::qWait(20); // wait 20ms @@ -149,6 +150,7 @@ void tst_QAudioOutput::pullFile() QVERIFY(audio->state() == QAudio::ActiveState); QVERIFY(audio->error() == QAudio::NoError); QVERIFY(audio->periodSize() > 0); + QVERIFY(audio->clock() > 0); QVERIFY(stateSignal.count() == 1); // State changed to QAudio::ActiveState // Wait until finished... @@ -160,6 +162,7 @@ void tst_QAudioOutput::pullFile() audio->stop(); QTest::qWait(20); // wait 20ms QVERIFY(audio->state() == QAudio::StopState); + QVERIFY(audio->clock() == 0); // Can only check to make sure we got at least 1 more signal, but can be more. QVERIFY(stateSignal.count() > 1); diff --git a/tests/auto/qfilesystemmodel/tst_qfilesystemmodel.cpp b/tests/auto/qfilesystemmodel/tst_qfilesystemmodel.cpp index ea9304d..2cc2558 100644 --- a/tests/auto/qfilesystemmodel/tst_qfilesystemmodel.cpp +++ b/tests/auto/qfilesystemmodel/tst_qfilesystemmodel.cpp @@ -806,7 +806,10 @@ void tst_QFileSystemModel::sort() QDir dir(QDir::tempPath()); dir.mkdir("sortTemp"); dir.cd("sortTemp"); - QDirIterator it(dir); + QTRY_VERIFY(dir.exists()); + + //To be sure we clean the dir if it was there before + QDirIterator it(dir.absolutePath(), QDir::NoDotAndDotDot); while(it.hasNext()) { it.next(); diff --git a/tests/auto/qgl/tst_qgl.cpp b/tests/auto/qgl/tst_qgl.cpp index 999d119..e036e4b 100644 --- a/tests/auto/qgl/tst_qgl.cpp +++ b/tests/auto/qgl/tst_qgl.cpp @@ -54,6 +54,10 @@ #include <QGraphicsProxyWidget> #include <QVBoxLayout> +#ifdef QT_BUILD_INTERNAL +#include <QtOpenGL/private/qgl_p.h> +#endif + //TESTED_CLASS= //TESTED_FILES= @@ -84,6 +88,8 @@ private slots: void testDontCrashOnDanglingResources(); void replaceClipping(); void clipTest(); + void destroyFBOAfterContext(); + void shareRegister(); }; tst_QGL::tst_QGL() @@ -1720,6 +1726,198 @@ void tst_QGL::clipTest() QCOMPARE(widgetFB, reference); } +void tst_QGL::destroyFBOAfterContext() +{ + if (!QGLFramebufferObject::hasOpenGLFramebufferObjects()) + QSKIP("QGLFramebufferObject not supported on this platform", SkipSingle); + + QGLWidget *glw = new QGLWidget(); + glw->makeCurrent(); + + // No multisample with combined depth/stencil attachment: + QGLFramebufferObjectFormat fboFormat; + fboFormat.setAttachment(QGLFramebufferObject::CombinedDepthStencil); + + // Don't complicate things by using NPOT: + QGLFramebufferObject *fbo = new QGLFramebufferObject(256, 128, fboFormat); + + // The handle should be valid until the context is destroyed. + QVERIFY(fbo->handle() != 0); + QVERIFY(fbo->isValid()); + + delete glw; + + // The handle should now be zero. + QVERIFY(fbo->handle() == 0); + QVERIFY(!fbo->isValid()); + + delete fbo; +} + +#ifdef QT_BUILD_INTERNAL + +class tst_QGLResource : public QObject +{ + Q_OBJECT +public: + tst_QGLResource(QObject *parent = 0) : QObject(parent) {} + ~tst_QGLResource() { ++deletions; } + + static int deletions; +}; + +int tst_QGLResource::deletions = 0; + +static void qt_shared_test_free(void *data) +{ + delete reinterpret_cast<tst_QGLResource *>(data); +} + +Q_GLOBAL_STATIC_WITH_ARGS(QGLContextResource, qt_shared_test, (qt_shared_test_free)) + +#endif + +void tst_QGL::shareRegister() +{ +#ifdef QT_BUILD_INTERNAL + QGLShareRegister *shareReg = qgl_share_reg(); + QVERIFY(shareReg != 0); + + // Create a context. + QGLWidget *glw1 = new QGLWidget(); + glw1->makeCurrent(); + + // Nothing should be sharing with glw1's context yet. + QList<const QGLContext *> list; + list = shareReg->shares(glw1->context()); + QCOMPARE(list.size(), 0); + + // Create a guard for the first context. + QGLSharedResourceGuard guard(glw1->context()); + QVERIFY(guard.id() == 0); + guard.setId(3); + QVERIFY(guard.id() == 3); + + // Add a resource to the first context. + tst_QGLResource *res1 = new tst_QGLResource(); + QVERIFY(!qt_shared_test()->value(glw1->context())); + qt_shared_test()->insert(glw1->context(), res1); + QVERIFY(qt_shared_test()->value(glw1->context()) == res1); + + // Create another context that shares with the first. + QGLWidget *glw2 = new QGLWidget(0, glw1); + if (!glw2->isSharing()) { + delete glw2; + delete glw1; + QSKIP("Context sharing is not supported", SkipSingle); + } + QVERIFY(glw1->context() != glw2->context()); + + // Check that the first context's resource is also on the second. + QVERIFY(qt_shared_test()->value(glw1->context()) == res1); + QVERIFY(qt_shared_test()->value(glw2->context()) == res1); + + // Guard should still be the same. + QVERIFY(guard.context() == glw1->context()); + QVERIFY(guard.id() == 3); + + // Now there are two items in the share lists. + list = shareReg->shares(glw1->context()); + QCOMPARE(list.size(), 2); + QVERIFY(list.contains(glw1->context())); + QVERIFY(list.contains(glw2->context())); + list = shareReg->shares(glw2->context()); + QCOMPARE(list.size(), 2); + QVERIFY(list.contains(glw1->context())); + QVERIFY(list.contains(glw2->context())); + + // Check the sharing relationships. + QVERIFY(QGLContext::areSharing(glw1->context(), glw1->context())); + QVERIFY(QGLContext::areSharing(glw2->context(), glw2->context())); + QVERIFY(QGLContext::areSharing(glw1->context(), glw2->context())); + QVERIFY(QGLContext::areSharing(glw2->context(), glw1->context())); + QVERIFY(!QGLContext::areSharing(0, glw2->context())); + QVERIFY(!QGLContext::areSharing(glw1->context(), 0)); + QVERIFY(!QGLContext::areSharing(0, 0)); + + // Create a third context, not sharing with the others. + QGLWidget *glw3 = new QGLWidget(); + + // Create a guard on the standalone context. + QGLSharedResourceGuard guard3(glw3->context()); + guard3.setId(5); + + // Add a resource to the third context. + tst_QGLResource *res3 = new tst_QGLResource(); + QVERIFY(!qt_shared_test()->value(glw3->context())); + qt_shared_test()->insert(glw3->context(), res3); + QVERIFY(qt_shared_test()->value(glw1->context()) == res1); + QVERIFY(qt_shared_test()->value(glw2->context()) == res1); + QVERIFY(qt_shared_test()->value(glw3->context()) == res3); + + // First two should still be sharing, but third is in its own list. + list = shareReg->shares(glw1->context()); + QCOMPARE(list.size(), 2); + QVERIFY(list.contains(glw1->context())); + QVERIFY(list.contains(glw2->context())); + list = shareReg->shares(glw2->context()); + QCOMPARE(list.size(), 2); + QVERIFY(list.contains(glw1->context())); + QVERIFY(list.contains(glw2->context())); + list = shareReg->shares(glw3->context()); + QCOMPARE(list.size(), 0); + + // Check the sharing relationships again. + QVERIFY(QGLContext::areSharing(glw1->context(), glw1->context())); + QVERIFY(QGLContext::areSharing(glw2->context(), glw2->context())); + QVERIFY(QGLContext::areSharing(glw1->context(), glw2->context())); + QVERIFY(QGLContext::areSharing(glw2->context(), glw1->context())); + QVERIFY(!QGLContext::areSharing(glw1->context(), glw3->context())); + QVERIFY(!QGLContext::areSharing(glw2->context(), glw3->context())); + QVERIFY(!QGLContext::areSharing(glw3->context(), glw1->context())); + QVERIFY(!QGLContext::areSharing(glw3->context(), glw2->context())); + QVERIFY(QGLContext::areSharing(glw3->context(), glw3->context())); + QVERIFY(!QGLContext::areSharing(0, glw2->context())); + QVERIFY(!QGLContext::areSharing(glw1->context(), 0)); + QVERIFY(!QGLContext::areSharing(0, glw3->context())); + QVERIFY(!QGLContext::areSharing(glw3->context(), 0)); + QVERIFY(!QGLContext::areSharing(0, 0)); + + // Shared guard should still be the same. + QVERIFY(guard.context() == glw1->context()); + QVERIFY(guard.id() == 3); + + // Delete the first context. + delete glw1; + + // The first context's resource should transfer to the second context. + QCOMPARE(tst_QGLResource::deletions, 0); + QVERIFY(qt_shared_test()->value(glw2->context()) == res1); + QVERIFY(qt_shared_test()->value(glw3->context()) == res3); + + // Shared guard should now be the second context, with the id the same. + QVERIFY(guard.context() == glw2->context()); + QVERIFY(guard.id() == 3); + QVERIFY(guard3.context() == glw3->context()); + QVERIFY(guard3.id() == 5); + + // Re-check the share list for the second context (should be empty now). + list = shareReg->shares(glw2->context()); + QCOMPARE(list.size(), 0); + + // Clean up and check that the resources are properly deleted. + delete glw2; + QCOMPARE(tst_QGLResource::deletions, 1); + delete glw3; + QCOMPARE(tst_QGLResource::deletions, 2); + + // Guards should now be null and the id zero. + QVERIFY(guard.context() == 0); + QVERIFY(guard.id() == 0); + QVERIFY(guard3.context() == 0); + QVERIFY(guard3.id() == 0); +#endif +} QTEST_MAIN(tst_QGL) #include "tst_qgl.moc" diff --git a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp index bbf19f2..e2e8c5f 100644 --- a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp +++ b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp @@ -49,12 +49,14 @@ #include <QAbstractTextDocumentLayout> #include <QBitmap> #include <QCursor> +#include <QLabel> #include <QDial> #include <QGraphicsItem> #include <QGraphicsScene> #include <QGraphicsSceneEvent> #include <QGraphicsView> #include <QGraphicsWidget> +#include <QGraphicsProxyWidget> #include <QPainter> #include <QScrollBar> #include <QVBoxLayout> @@ -80,6 +82,57 @@ Q_DECLARE_METATYPE(QRectF) #define Q_CHECK_PAINTEVENTS #endif +static void sendMousePress(QGraphicsScene *scene, const QPointF &point, Qt::MouseButton button = Qt::LeftButton) +{ + QGraphicsSceneMouseEvent event(QEvent::GraphicsSceneMousePress); + event.setScenePos(point); + event.setButton(button); + event.setButtons(button); + QApplication::sendEvent(scene, &event); +} + +static void sendMouseMove(QGraphicsScene *scene, const QPointF &point, + Qt::MouseButton button = Qt::NoButton, Qt::MouseButtons buttons = 0) +{ + QGraphicsSceneMouseEvent event(QEvent::GraphicsSceneMouseMove); + event.setScenePos(point); + event.setButton(button); + event.setButtons(button); + QApplication::sendEvent(scene, &event); +} + +static void sendMouseRelease(QGraphicsScene *scene, const QPointF &point, Qt::MouseButton button = Qt::LeftButton) +{ + QGraphicsSceneMouseEvent event(QEvent::GraphicsSceneMouseRelease); + event.setScenePos(point); + event.setButton(button); + QApplication::sendEvent(scene, &event); +} + +static void sendMouseClick(QGraphicsScene *scene, const QPointF &point, Qt::MouseButton button = Qt::LeftButton) +{ + sendMousePress(scene, point, button); + sendMouseRelease(scene, point, button); +} + +static void sendKeyPress(QGraphicsScene *scene, Qt::Key key) +{ + QKeyEvent keyEvent(QEvent::KeyPress, key, Qt::NoModifier); + QApplication::sendEvent(scene, &keyEvent); +} + +static void sendKeyRelease(QGraphicsScene *scene, Qt::Key key) +{ + QKeyEvent keyEvent(QEvent::KeyRelease, key, Qt::NoModifier); + QApplication::sendEvent(scene, &keyEvent); +} + +static void sendKeyClick(QGraphicsScene *scene, Qt::Key key) +{ + sendKeyPress(scene, key); + sendKeyRelease(scene, key); +} + class EventSpy : public QGraphicsWidget { Q_OBJECT @@ -120,6 +173,39 @@ protected: QEvent::Type spied; }; +class EventSpy2 : public QGraphicsWidget +{ + Q_OBJECT +public: + EventSpy2(QObject *watched) + { + watched->installEventFilter(this); + } + + EventSpy2(QGraphicsScene *scene, QGraphicsItem *watched) + { + scene->addItem(this); + watched->installSceneEventFilter(this); + } + + QMap<QEvent::Type, int> counts; + +protected: + bool eventFilter(QObject *watched, QEvent *event) + { + Q_UNUSED(watched); + ++counts[event->type()]; + return false; + } + + bool sceneEventFilter(QGraphicsItem *watched, QEvent *event) + { + Q_UNUSED(watched); + ++counts[event->type()]; + return false; + } +}; + class EventTester : public QGraphicsItem { public: @@ -246,6 +332,7 @@ private slots: void itemClipsChildrenToShape(); void itemClipsChildrenToShape2(); void itemClipsChildrenToShape3(); + void itemClipsChildrenToShape4(); void itemClipsTextChildToShape(); void itemClippingDiscovery(); void ancestorFlags(); @@ -296,6 +383,13 @@ private slots: void ensureDirtySceneTransform(); void focusScope(); void stackBefore(); + void sceneModality(); + void panelModality(); + void mixedModality(); + void modality_hover(); + void modality_mouseGrabber(); + void modality_clickFocus(); + void modality_keyEvents(); // task specific tests below me void task141694_textItemEnsureVisible(); @@ -2926,7 +3020,7 @@ void tst_QGraphicsItem::hoverEventsGenerateRepaints() QGraphicsView view(&scene); view.show(); QTest::qWaitForWindowShown(&view); - QTest::qWait(100); + QTest::qWait(150); EventTester *tester = new EventTester; scene.addItem(tester); @@ -4668,11 +4762,11 @@ public: { QGraphicsRectItem::paint(painter, option, widget); if (harakiri == 0) { - // delete unsupported since 4.5 - /* + // delete unsupported since 4.5 + /* dead = 1; - delete this; - */ + delete this; + */ } } @@ -5079,6 +5173,44 @@ void tst_QGraphicsItem::itemClipsChildrenToShape3() QCOMPARE(scene.itemAt(175,175), (QGraphicsItem *)0); } +class MyProxyWidget : public QGraphicsProxyWidget +{ +public: + MyProxyWidget(QGraphicsItem *parent) : QGraphicsProxyWidget(parent) + { + painted = false; + } + + void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) + { + QGraphicsProxyWidget::paint(painter, option, widget); + painted = true; + } + bool painted; +}; + +void tst_QGraphicsItem::itemClipsChildrenToShape4() +{ + QGraphicsScene scene; + QGraphicsView view(&scene); + + QGraphicsWidget * outerWidget = new QGraphicsWidget(); + outerWidget->setFlag(QGraphicsItem::ItemClipsChildrenToShape, true); + MyProxyWidget * innerWidget = new MyProxyWidget(outerWidget); + QLabel * label = new QLabel(); + label->setText("Welcome back my friends to the show that never ends..."); + innerWidget->setWidget(label); + view.resize(300, 300); + scene.addItem(outerWidget); + outerWidget->resize( 200, 100 ); + scene.addEllipse( 100, 100, 100, 50 ); // <-- this is important to trigger the right codepath* + //now the label is shown + outerWidget->setFlag(QGraphicsItem::ItemClipsChildrenToShape, false ); + QApplication::setActiveWindow(&view); + view.show(); + QTRY_COMPARE(QApplication::activeWindow(), (QWidget *)&view); + QTRY_COMPARE(innerWidget->painted, true); +} void tst_QGraphicsItem::itemClipsTextChildToShape() { @@ -6215,6 +6347,7 @@ void tst_QGraphicsItem::itemStacksBehindParent() QGraphicsView view(&scene); view.show(); QTest::qWaitForWindowShown(&view); + QTRY_VERIFY(!paintedItems.isEmpty()); QTest::qWait(100); paintedItems.clear(); view.viewport()->update(); @@ -6224,7 +6357,7 @@ void tst_QGraphicsItem::itemStacksBehindParent() << grandChild121 << child12 << parent1 << grandChild211 << child21 << grandChild221 << child22 << parent2)); - QCOMPARE(paintedItems, QList<QGraphicsItem *>() + QTRY_COMPARE(paintedItems, QList<QGraphicsItem *>() << parent2 << child22 << grandChild221 << child21 << grandChild211 << parent1 << child12 << grandChild121 @@ -7498,7 +7631,7 @@ void tst_QGraphicsItem::hitTestGraphicsEffectItem() QVERIFY(items.isEmpty()); items = scene.items(QPointF(80, 80)); QCOMPARE(items.size(), 1); - QCOMPARE(items.at(0), static_cast<EventTester *>(item3)); + QCOMPARE(items.at(0), static_cast<QGraphicsItem *>(item3)); item1->repaints = 0; item2->repaints = 0; @@ -7521,7 +7654,7 @@ void tst_QGraphicsItem::hitTestGraphicsEffectItem() QVERIFY(items.isEmpty()); items = scene.items(QPointF(80, 80)); QCOMPARE(items.size(), 1); - QCOMPARE(items.at(0), static_cast<EventTester *>(item3)); + QCOMPARE(items.at(0), static_cast<QGraphicsItem *>(item3)); } void tst_QGraphicsItem::focusProxy() @@ -8251,7 +8384,7 @@ void tst_QGraphicsItem::ensureDirtySceneTransform() QGraphicsView view(&scene); view.show(); QTest::qWaitForWindowShown(&view); - QTRY_COMPARE(QApplication::activeWindow(), &view); + QTRY_COMPARE(QApplication::activeWindow(), static_cast<QWidget *>(&view)); //We move the parent parent->move(); @@ -8483,5 +8616,923 @@ void tst_QGraphicsItem::QTBUG_4233_updateCachedWithSceneRect() QCOMPARE(tester->repaints, 2); } +void tst_QGraphicsItem::sceneModality() +{ + // 1) Test mouse events (delivery/propagation/redirection) + // 2) Test hover events (incl. leave on block, enter on unblock) + // 3) Test cursor stuff (incl. unset on block, set on unblock) + // 4) Test clickfocus + // 5) Test grab/ungrab events (possibly ungrab on block, regrab on unblock) + // 6) ### modality for non-panels is unsupported for now + QGraphicsScene scene; + + QGraphicsRectItem *bottomItem = scene.addRect(-150, -100, 300, 200); + bottomItem->setFlag(QGraphicsItem::ItemIsFocusable); + bottomItem->setBrush(Qt::yellow); + + QGraphicsRectItem *leftParent = scene.addRect(-50, -50, 100, 100); + leftParent->setFlag(QGraphicsItem::ItemIsPanel); + leftParent->setBrush(Qt::blue); + + QGraphicsRectItem *leftChild = scene.addRect(-25, -25, 50, 50); + leftChild->setFlag(QGraphicsItem::ItemIsPanel); + leftChild->setBrush(Qt::green); + leftChild->setParentItem(leftParent); + + QGraphicsRectItem *rightParent = scene.addRect(-50, -50, 100, 100); + rightParent->setFlag(QGraphicsItem::ItemIsPanel); + rightParent->setBrush(Qt::red); + QGraphicsRectItem *rightChild = scene.addRect(-25, -25, 50, 50); + rightChild->setFlag(QGraphicsItem::ItemIsPanel); + rightChild->setBrush(Qt::gray); + rightChild->setParentItem(rightParent); + + leftParent->setPos(-75, 0); + rightParent->setPos(75, 0); + + bottomItem->setData(0, "bottomItem"); + leftParent->setData(0, "leftParent"); + leftChild->setData(0, "leftChild"); + rightParent->setData(0, "rightParent"); + rightChild->setData(0, "rightChild"); + + scene.setSceneRect(scene.itemsBoundingRect().adjusted(-50, -50, 50, 50)); + + EventSpy2 leftParentSpy(&scene, leftParent); + EventSpy2 leftChildSpy(&scene, leftChild); + EventSpy2 rightParentSpy(&scene, rightParent); + EventSpy2 rightChildSpy(&scene, rightChild); + EventSpy2 bottomItemSpy(&scene, bottomItem); + + // Scene modality, also test multiple scene modal items + leftChild->setPanelModality(QGraphicsItem::SceneModal); + QCOMPARE(leftChildSpy.counts[QEvent::WindowBlocked], 0); + QCOMPARE(leftParentSpy.counts[QEvent::WindowBlocked], 1); + QCOMPARE(rightParentSpy.counts[QEvent::WindowBlocked], 1); + QCOMPARE(rightChildSpy.counts[QEvent::WindowBlocked], 1); + QCOMPARE(bottomItemSpy.counts[QEvent::WindowBlocked], 0); // not a panel + + // Click inside left child + sendMouseClick(&scene, leftChild->scenePos(), Qt::LeftButton); + QCOMPARE(leftChildSpy.counts[QEvent::GraphicsSceneMousePress], 1); + QCOMPARE(leftChildSpy.counts[QEvent::GraphicsSceneMouseRelease], 0); // no grab + QCOMPARE(leftParentSpy.counts[QEvent::GraphicsSceneMousePress], 0); // blocked + QCOMPARE(rightParentSpy.counts[QEvent::GraphicsSceneMousePress], 0); // blocked + QCOMPARE(rightChildSpy.counts[QEvent::GraphicsSceneMousePress], 0); // blocked + QCOMPARE(bottomItemSpy.counts[QEvent::GraphicsSceneMousePress], 0); // blocked + + // Click on left parent, event goes to modal child + sendMouseClick(&scene, leftParent->sceneBoundingRect().topLeft() + QPointF(5, 5), Qt::LeftButton); + QCOMPARE(leftChildSpy.counts[QEvent::GraphicsSceneMousePress], 2); + QCOMPARE(leftChildSpy.counts[QEvent::GraphicsSceneMouseRelease], 0); // no grab + QCOMPARE(leftParentSpy.counts[QEvent::GraphicsSceneMousePress], 0); // blocked + QCOMPARE(rightParentSpy.counts[QEvent::GraphicsSceneMousePress], 0); // blocked + QCOMPARE(rightChildSpy.counts[QEvent::GraphicsSceneMousePress], 0); // blocked + QCOMPARE(bottomItemSpy.counts[QEvent::GraphicsSceneMousePress], 0); // blocked + + // Click on all other items and outside the items + sendMouseClick(&scene, rightParent->sceneBoundingRect().topLeft() + QPointF(5, 5), Qt::LeftButton); + QCOMPARE(leftChildSpy.counts[QEvent::GraphicsSceneMousePress], 3); + sendMouseClick(&scene, rightChild->scenePos(), Qt::LeftButton); + QCOMPARE(leftChildSpy.counts[QEvent::GraphicsSceneMousePress], 4); + sendMouseClick(&scene, bottomItem->scenePos(), Qt::LeftButton); + QCOMPARE(leftChildSpy.counts[QEvent::GraphicsSceneMousePress], 5); + sendMouseClick(&scene, QPointF(10000, 10000), Qt::LeftButton); + QCOMPARE(leftChildSpy.counts[QEvent::GraphicsSceneMousePress], 6); + QCOMPARE(leftChildSpy.counts[QEvent::GraphicsSceneMouseRelease], 0); // no grab + QCOMPARE(leftParentSpy.counts[QEvent::GraphicsSceneMousePress], 0); // blocked + QCOMPARE(rightParentSpy.counts[QEvent::GraphicsSceneMousePress], 0); // blocked + QCOMPARE(rightChildSpy.counts[QEvent::GraphicsSceneMousePress], 0); // blocked + QCOMPARE(bottomItemSpy.counts[QEvent::GraphicsSceneMousePress], 0); // blocked + + leftChildSpy.counts.clear(); + rightChildSpy.counts.clear(); + leftParentSpy.counts.clear(); + rightParentSpy.counts.clear(); + bottomItemSpy.counts.clear(); + + leftChild->setPanelModality(QGraphicsItem::NonModal); + QCOMPARE(leftChildSpy.counts[QEvent::WindowUnblocked], 0); + QCOMPARE(rightChildSpy.counts[QEvent::WindowUnblocked], 1); + QCOMPARE(leftParentSpy.counts[QEvent::WindowUnblocked], 1); + QCOMPARE(rightParentSpy.counts[QEvent::WindowUnblocked], 1); + QCOMPARE(bottomItemSpy.counts[QEvent::WindowUnblocked], 0); + + // Left parent enters scene modality. + leftParent->setPanelModality(QGraphicsItem::SceneModal); + QCOMPARE(leftChildSpy.counts[QEvent::WindowBlocked], 0); + QCOMPARE(rightChildSpy.counts[QEvent::WindowBlocked], 1); + QCOMPARE(leftParentSpy.counts[QEvent::WindowBlocked], 0); + QCOMPARE(rightParentSpy.counts[QEvent::WindowBlocked], 1); + QCOMPARE(bottomItemSpy.counts[QEvent::WindowBlocked], 0); + + // Click inside left child. + sendMouseClick(&scene, leftChild->scenePos(), Qt::LeftButton); + QCOMPARE(leftChildSpy.counts[QEvent::GraphicsSceneMousePress], 1); + QCOMPARE(leftChildSpy.counts[QEvent::GraphicsSceneMouseRelease], 0); + QCOMPARE(leftParentSpy.counts[QEvent::GraphicsSceneMousePress], 0); // panel stops propagation + QCOMPARE(rightParentSpy.counts[QEvent::GraphicsSceneMousePress], 0); + QCOMPARE(rightChildSpy.counts[QEvent::GraphicsSceneMousePress], 0); // blocked + QCOMPARE(bottomItemSpy.counts[QEvent::GraphicsSceneMousePress], 0); // blocked + + // Click on left parent. + sendMouseClick(&scene, leftParent->sceneBoundingRect().topLeft() + QPointF(5, 5), Qt::LeftButton); + QCOMPARE(leftChildSpy.counts[QEvent::GraphicsSceneMousePress], 1); + QCOMPARE(leftChildSpy.counts[QEvent::GraphicsSceneMouseRelease], 0); + QCOMPARE(leftParentSpy.counts[QEvent::GraphicsSceneMousePress], 1); + QCOMPARE(rightParentSpy.counts[QEvent::GraphicsSceneMousePress], 0); + QCOMPARE(rightChildSpy.counts[QEvent::GraphicsSceneMousePress], 0); + QCOMPARE(bottomItemSpy.counts[QEvent::GraphicsSceneMousePress], 0); + + // Click on all other items and outside the items + sendMouseClick(&scene, rightParent->sceneBoundingRect().topLeft() + QPointF(5, 5), Qt::LeftButton); + QCOMPARE(leftParentSpy.counts[QEvent::GraphicsSceneMousePress], 2); + sendMouseClick(&scene, rightChild->scenePos(), Qt::LeftButton); + QCOMPARE(leftParentSpy.counts[QEvent::GraphicsSceneMousePress], 3); + sendMouseClick(&scene, bottomItem->scenePos(), Qt::LeftButton); + QCOMPARE(leftParentSpy.counts[QEvent::GraphicsSceneMousePress], 4); + sendMouseClick(&scene, QPointF(10000, 10000), Qt::LeftButton); + QCOMPARE(leftParentSpy.counts[QEvent::GraphicsSceneMousePress], 5); + QCOMPARE(leftParentSpy.counts[QEvent::GraphicsSceneMouseRelease], 0); + QCOMPARE(leftChildSpy.counts[QEvent::GraphicsSceneMousePress], 1); + QCOMPARE(rightParentSpy.counts[QEvent::GraphicsSceneMousePress], 0); + QCOMPARE(rightChildSpy.counts[QEvent::GraphicsSceneMousePress], 0); + QCOMPARE(bottomItemSpy.counts[QEvent::GraphicsSceneMousePress], 0); + + leftChildSpy.counts.clear(); + rightChildSpy.counts.clear(); + leftParentSpy.counts.clear(); + rightParentSpy.counts.clear(); + bottomItemSpy.counts.clear(); + + // Now both left parent and child are scene modal. Left parent is blocked. + leftChild->setPanelModality(QGraphicsItem::SceneModal); + QCOMPARE(leftChildSpy.counts[QEvent::WindowBlocked], 0); + QCOMPARE(rightChildSpy.counts[QEvent::WindowBlocked], 0); + QCOMPARE(leftParentSpy.counts[QEvent::WindowBlocked], 1); + QCOMPARE(rightParentSpy.counts[QEvent::WindowBlocked], 0); + QCOMPARE(bottomItemSpy.counts[QEvent::WindowBlocked], 0); + + // Click inside left child + sendMouseClick(&scene, leftChild->scenePos(), Qt::LeftButton); + QCOMPARE(leftChildSpy.counts[QEvent::GraphicsSceneMousePress], 1); + QCOMPARE(leftChildSpy.counts[QEvent::GraphicsSceneMouseRelease], 0); // no grab + QCOMPARE(leftParentSpy.counts[QEvent::GraphicsSceneMousePress], 0); // blocked + QCOMPARE(rightParentSpy.counts[QEvent::GraphicsSceneMousePress], 0); // blocked + QCOMPARE(rightChildSpy.counts[QEvent::GraphicsSceneMousePress], 0); // blocked + QCOMPARE(bottomItemSpy.counts[QEvent::GraphicsSceneMousePress], 0); // blocked + + // Click on left parent, event goes to modal child + sendMouseClick(&scene, leftParent->sceneBoundingRect().topLeft() + QPointF(5, 5), Qt::LeftButton); + QCOMPARE(leftChildSpy.counts[QEvent::GraphicsSceneMousePress], 2); + QCOMPARE(leftChildSpy.counts[QEvent::GraphicsSceneMouseRelease], 0); // no grab + QCOMPARE(leftParentSpy.counts[QEvent::GraphicsSceneMousePress], 0); // blocked + QCOMPARE(rightParentSpy.counts[QEvent::GraphicsSceneMousePress], 0); // blocked + QCOMPARE(rightChildSpy.counts[QEvent::GraphicsSceneMousePress], 0); // blocked + QCOMPARE(bottomItemSpy.counts[QEvent::GraphicsSceneMousePress], 0); // blocked + + // Click on all other items and outside the items + sendMouseClick(&scene, rightParent->sceneBoundingRect().topLeft() + QPointF(5, 5), Qt::LeftButton); + QCOMPARE(leftChildSpy.counts[QEvent::GraphicsSceneMousePress], 3); + sendMouseClick(&scene, rightChild->scenePos(), Qt::LeftButton); + QCOMPARE(leftChildSpy.counts[QEvent::GraphicsSceneMousePress], 4); + sendMouseClick(&scene, bottomItem->scenePos(), Qt::LeftButton); + QCOMPARE(leftChildSpy.counts[QEvent::GraphicsSceneMousePress], 5); + sendMouseClick(&scene, QPointF(10000, 10000), Qt::LeftButton); + QCOMPARE(leftChildSpy.counts[QEvent::GraphicsSceneMousePress], 6); + QCOMPARE(leftChildSpy.counts[QEvent::GraphicsSceneMouseRelease], 0); // no grab + QCOMPARE(leftParentSpy.counts[QEvent::GraphicsSceneMousePress], 0); // blocked + QCOMPARE(rightParentSpy.counts[QEvent::GraphicsSceneMousePress], 0); // blocked + QCOMPARE(rightChildSpy.counts[QEvent::GraphicsSceneMousePress], 0); // blocked + QCOMPARE(bottomItemSpy.counts[QEvent::GraphicsSceneMousePress], 0); // blocked + + leftChildSpy.counts.clear(); + rightChildSpy.counts.clear(); + leftParentSpy.counts.clear(); + rightParentSpy.counts.clear(); + bottomItemSpy.counts.clear(); + + // Right child enters scene modality, only left child is blocked. + rightChild->setPanelModality(QGraphicsItem::SceneModal); + QCOMPARE(leftChildSpy.counts[QEvent::WindowBlocked], 1); + QCOMPARE(rightChildSpy.counts[QEvent::WindowBlocked], 0); + QCOMPARE(leftParentSpy.counts[QEvent::WindowBlocked], 0); + QCOMPARE(rightParentSpy.counts[QEvent::WindowBlocked], 0); + QCOMPARE(bottomItemSpy.counts[QEvent::WindowBlocked], 0); +} + +void tst_QGraphicsItem::panelModality() +{ + // 1) Test mouse events (delivery/propagation/redirection) + // 2) Test hover events (incl. leave on block, enter on unblock) + // 3) Test cursor stuff (incl. unset on block, set on unblock) + // 4) Test clickfocus + // 5) Test grab/ungrab events (possibly ungrab on block, regrab on unblock) + // 6) ### modality for non-panels is unsupported for now + QGraphicsScene scene; + + QGraphicsRectItem *bottomItem = scene.addRect(-150, -100, 300, 200); + bottomItem->setFlag(QGraphicsItem::ItemIsFocusable); + bottomItem->setBrush(Qt::yellow); + + QGraphicsRectItem *leftParent = scene.addRect(-50, -50, 100, 100); + leftParent->setFlag(QGraphicsItem::ItemIsPanel); + leftParent->setBrush(Qt::blue); + + QGraphicsRectItem *leftChild = scene.addRect(-25, -25, 50, 50); + leftChild->setFlag(QGraphicsItem::ItemIsPanel); + leftChild->setBrush(Qt::green); + leftChild->setParentItem(leftParent); + + QGraphicsRectItem *rightParent = scene.addRect(-50, -50, 100, 100); + rightParent->setFlag(QGraphicsItem::ItemIsPanel); + rightParent->setBrush(Qt::red); + QGraphicsRectItem *rightChild = scene.addRect(-25, -25, 50, 50); + rightChild->setFlag(QGraphicsItem::ItemIsPanel); + rightChild->setBrush(Qt::gray); + rightChild->setParentItem(rightParent); + + leftParent->setPos(-75, 0); + rightParent->setPos(75, 0); + + bottomItem->setData(0, "bottomItem"); + leftParent->setData(0, "leftParent"); + leftChild->setData(0, "leftChild"); + rightParent->setData(0, "rightParent"); + rightChild->setData(0, "rightChild"); + + scene.setSceneRect(scene.itemsBoundingRect().adjusted(-50, -50, 50, 50)); + + EventSpy2 leftParentSpy(&scene, leftParent); + EventSpy2 leftChildSpy(&scene, leftChild); + EventSpy2 rightParentSpy(&scene, rightParent); + EventSpy2 rightChildSpy(&scene, rightChild); + EventSpy2 bottomItemSpy(&scene, bottomItem); + + // Left Child enters panel modality, only left parent is blocked. + leftChild->setPanelModality(QGraphicsItem::PanelModal); + QCOMPARE(leftChildSpy.counts[QEvent::WindowBlocked], 0); + QCOMPARE(rightChildSpy.counts[QEvent::WindowBlocked], 0); + QCOMPARE(leftParentSpy.counts[QEvent::WindowBlocked], 1); + QCOMPARE(rightParentSpy.counts[QEvent::WindowBlocked], 0); + QCOMPARE(bottomItemSpy.counts[QEvent::WindowBlocked], 0); + + leftChild->setPanelModality(QGraphicsItem::NonModal); + leftChildSpy.counts.clear(); + rightChildSpy.counts.clear(); + leftParentSpy.counts.clear(); + rightParentSpy.counts.clear(); + bottomItemSpy.counts.clear(); + + // Left parent enter panel modality, nothing is blocked. + leftParent->setPanelModality(QGraphicsItem::PanelModal); + QCOMPARE(leftChildSpy.counts[QEvent::WindowBlocked], 0); + QCOMPARE(rightChildSpy.counts[QEvent::WindowBlocked], 0); + QCOMPARE(leftParentSpy.counts[QEvent::WindowBlocked], 0); + QCOMPARE(rightParentSpy.counts[QEvent::WindowBlocked], 0); + QCOMPARE(bottomItemSpy.counts[QEvent::WindowBlocked], 0); + + // Left child enters panel modality, left parent is blocked again. + leftChild->setPanelModality(QGraphicsItem::PanelModal); + QCOMPARE(leftChildSpy.counts[QEvent::WindowBlocked], 0); + QCOMPARE(rightChildSpy.counts[QEvent::WindowBlocked], 0); + QCOMPARE(leftParentSpy.counts[QEvent::WindowBlocked], 1); + QCOMPARE(rightParentSpy.counts[QEvent::WindowBlocked], 0); + QCOMPARE(bottomItemSpy.counts[QEvent::WindowBlocked], 0); + + leftChildSpy.counts.clear(); + rightChildSpy.counts.clear(); + leftParentSpy.counts.clear(); + rightParentSpy.counts.clear(); + bottomItemSpy.counts.clear(); + + leftChild->setPanelModality(QGraphicsItem::NonModal); + QCOMPARE(leftParentSpy.counts[QEvent::WindowUnblocked], 1); + leftParent->setPanelModality(QGraphicsItem::NonModal); + QCOMPARE(leftChildSpy.counts[QEvent::WindowUnblocked], 0); + QCOMPARE(rightChildSpy.counts[QEvent::WindowUnblocked], 0); + QCOMPARE(leftParentSpy.counts[QEvent::WindowUnblocked], 1); + QCOMPARE(rightParentSpy.counts[QEvent::WindowUnblocked], 0); + QCOMPARE(bottomItemSpy.counts[QEvent::WindowUnblocked], 0); + + leftChildSpy.counts.clear(); + rightChildSpy.counts.clear(); + leftParentSpy.counts.clear(); + rightParentSpy.counts.clear(); + bottomItemSpy.counts.clear(); + + // Left and right child enter panel modality, both parents are blocked. + rightChild->setPanelModality(QGraphicsItem::PanelModal); + QCOMPARE(leftParentSpy.counts[QEvent::WindowBlocked], 0); + QCOMPARE(rightParentSpy.counts[QEvent::WindowBlocked], 1); + leftChild->setPanelModality(QGraphicsItem::PanelModal); + QCOMPARE(leftParentSpy.counts[QEvent::WindowBlocked], 1); + QCOMPARE(rightParentSpy.counts[QEvent::WindowBlocked], 1); +} + +void tst_QGraphicsItem::mixedModality() +{ + // 1) Test mouse events (delivery/propagation/redirection) + // 2) Test hover events (incl. leave on block, enter on unblock) + // 3) Test cursor stuff (incl. unset on block, set on unblock) + // 4) Test clickfocus + // 5) Test grab/ungrab events (possibly ungrab on block, regrab on unblock) + // 6) ### modality for non-panels is unsupported for now + QGraphicsScene scene; + + QGraphicsRectItem *bottomItem = scene.addRect(-150, -100, 300, 200); + bottomItem->setFlag(QGraphicsItem::ItemIsFocusable); + bottomItem->setBrush(Qt::yellow); + + QGraphicsRectItem *leftParent = scene.addRect(-50, -50, 100, 100); + leftParent->setFlag(QGraphicsItem::ItemIsPanel); + leftParent->setBrush(Qt::blue); + + QGraphicsRectItem *leftChild = scene.addRect(-25, -25, 50, 50); + leftChild->setFlag(QGraphicsItem::ItemIsPanel); + leftChild->setBrush(Qt::green); + leftChild->setParentItem(leftParent); + + QGraphicsRectItem *rightParent = scene.addRect(-50, -50, 100, 100); + rightParent->setFlag(QGraphicsItem::ItemIsPanel); + rightParent->setBrush(Qt::red); + QGraphicsRectItem *rightChild = scene.addRect(-25, -25, 50, 50); + rightChild->setFlag(QGraphicsItem::ItemIsPanel); + rightChild->setBrush(Qt::gray); + rightChild->setParentItem(rightParent); + + leftParent->setPos(-75, 0); + rightParent->setPos(75, 0); + + bottomItem->setData(0, "bottomItem"); + leftParent->setData(0, "leftParent"); + leftChild->setData(0, "leftChild"); + rightParent->setData(0, "rightParent"); + rightChild->setData(0, "rightChild"); + + scene.setSceneRect(scene.itemsBoundingRect().adjusted(-50, -50, 50, 50)); + + EventSpy2 leftParentSpy(&scene, leftParent); + EventSpy2 leftChildSpy(&scene, leftChild); + EventSpy2 rightParentSpy(&scene, rightParent); + EventSpy2 rightChildSpy(&scene, rightChild); + EventSpy2 bottomItemSpy(&scene, bottomItem); + + // Left Child enters panel modality, only left parent is blocked. + leftChild->setPanelModality(QGraphicsItem::PanelModal); + QCOMPARE(leftChildSpy.counts[QEvent::WindowBlocked], 0); + QCOMPARE(rightChildSpy.counts[QEvent::WindowBlocked], 0); + QCOMPARE(leftParentSpy.counts[QEvent::WindowBlocked], 1); + QCOMPARE(rightParentSpy.counts[QEvent::WindowBlocked], 0); + + // Left parent enters scene modality, which blocks everything except the child. + leftParent->setPanelModality(QGraphicsItem::SceneModal); + QCOMPARE(leftChildSpy.counts[QEvent::WindowBlocked], 0); + QCOMPARE(leftChildSpy.counts[QEvent::WindowUnblocked], 0); + QCOMPARE(rightChildSpy.counts[QEvent::WindowBlocked], 1); + QCOMPARE(rightChildSpy.counts[QEvent::WindowUnblocked], 0); + QCOMPARE(leftParentSpy.counts[QEvent::WindowBlocked], 1); + QCOMPARE(leftParentSpy.counts[QEvent::WindowUnblocked], 0); + QCOMPARE(rightParentSpy.counts[QEvent::WindowBlocked], 1); + QCOMPARE(rightParentSpy.counts[QEvent::WindowUnblocked], 0); + + // Right child enters panel modality (changes nothing). + rightChild->setPanelModality(QGraphicsItem::PanelModal); + QCOMPARE(leftChildSpy.counts[QEvent::WindowBlocked], 0); + QCOMPARE(leftChildSpy.counts[QEvent::WindowUnblocked], 0); + QCOMPARE(rightChildSpy.counts[QEvent::WindowBlocked], 1); + QCOMPARE(rightChildSpy.counts[QEvent::WindowUnblocked], 0); + QCOMPARE(leftParentSpy.counts[QEvent::WindowBlocked], 1); + QCOMPARE(leftParentSpy.counts[QEvent::WindowUnblocked], 0); + QCOMPARE(rightParentSpy.counts[QEvent::WindowBlocked], 1); + QCOMPARE(rightParentSpy.counts[QEvent::WindowUnblocked], 0); + + // Left parent leaves modality. Right child is unblocked. + leftParent->setPanelModality(QGraphicsItem::NonModal); + QCOMPARE(leftChildSpy.counts[QEvent::WindowBlocked], 0); + QCOMPARE(leftChildSpy.counts[QEvent::WindowUnblocked], 0); + QCOMPARE(rightChildSpy.counts[QEvent::WindowBlocked], 1); + QCOMPARE(rightChildSpy.counts[QEvent::WindowUnblocked], 1); + QCOMPARE(leftParentSpy.counts[QEvent::WindowBlocked], 1); + QCOMPARE(leftParentSpy.counts[QEvent::WindowUnblocked], 0); + QCOMPARE(rightParentSpy.counts[QEvent::WindowBlocked], 1); + QCOMPARE(rightParentSpy.counts[QEvent::WindowUnblocked], 0); + + // Right child "upgrades" its modality to scene modal. Left child is blocked. + // Right parent is unaffected. + rightChild->setPanelModality(QGraphicsItem::SceneModal); + QCOMPARE(leftChildSpy.counts[QEvent::WindowBlocked], 1); + QCOMPARE(leftChildSpy.counts[QEvent::WindowUnblocked], 0); + QCOMPARE(rightChildSpy.counts[QEvent::WindowBlocked], 1); + QCOMPARE(rightChildSpy.counts[QEvent::WindowUnblocked], 1); + QCOMPARE(leftParentSpy.counts[QEvent::WindowBlocked], 1); + QCOMPARE(leftParentSpy.counts[QEvent::WindowUnblocked], 0); + QCOMPARE(rightParentSpy.counts[QEvent::WindowBlocked], 1); + QCOMPARE(rightParentSpy.counts[QEvent::WindowUnblocked], 0); + + // "downgrade" right child back to panel modal, left child is unblocked + rightChild->setPanelModality(QGraphicsItem::PanelModal); + QCOMPARE(leftChildSpy.counts[QEvent::WindowBlocked], 1); + QCOMPARE(leftChildSpy.counts[QEvent::WindowUnblocked], 1); + QCOMPARE(rightChildSpy.counts[QEvent::WindowBlocked], 1); + QCOMPARE(rightChildSpy.counts[QEvent::WindowUnblocked], 1); + QCOMPARE(leftParentSpy.counts[QEvent::WindowBlocked], 1); + QCOMPARE(leftParentSpy.counts[QEvent::WindowUnblocked], 0); + QCOMPARE(rightParentSpy.counts[QEvent::WindowBlocked], 1); + QCOMPARE(rightParentSpy.counts[QEvent::WindowUnblocked], 0); +} + +void tst_QGraphicsItem::modality_hover() +{ + QGraphicsScene scene; + QGraphicsRectItem *rect1 = scene.addRect(-50, -50, 100, 100); + rect1->setFlag(QGraphicsItem::ItemIsPanel); + rect1->setAcceptHoverEvents(true); + rect1->setData(0, "rect1"); + + QGraphicsRectItem *rect2 = scene.addRect(-50, -50, 100, 100); + rect2->setParentItem(rect1); + rect2->setFlag(QGraphicsItem::ItemIsPanel); + rect2->setAcceptHoverEvents(true); + rect2->setPos(50, 50); + rect2->setPanelModality(QGraphicsItem::SceneModal); + rect2->setData(0, "rect2"); + + EventSpy2 rect1Spy(&scene, rect1); + EventSpy2 rect2Spy(&scene, rect2); + + sendMouseMove(&scene, QPointF(-25, -25)); + + QCOMPARE(rect1Spy.counts[QEvent::GraphicsSceneHoverEnter], 0); + QCOMPARE(rect1Spy.counts[QEvent::GraphicsSceneHoverMove], 0); + QCOMPARE(rect1Spy.counts[QEvent::GraphicsSceneHoverLeave], 0); + + sendMouseMove(&scene, QPointF(75, 75)); + + QCOMPARE(rect1Spy.counts[QEvent::GraphicsSceneHoverEnter], 0); + QCOMPARE(rect1Spy.counts[QEvent::GraphicsSceneHoverMove], 0); + QCOMPARE(rect1Spy.counts[QEvent::GraphicsSceneHoverLeave], 0); + QCOMPARE(rect2Spy.counts[QEvent::GraphicsSceneHoverEnter], 1); + QCOMPARE(rect2Spy.counts[QEvent::GraphicsSceneHoverMove], 1); + QCOMPARE(rect2Spy.counts[QEvent::GraphicsSceneHoverLeave], 0); + + sendMouseMove(&scene, QPointF(-25, -25)); + + QCOMPARE(rect2Spy.counts[QEvent::GraphicsSceneHoverLeave], 1); + QCOMPARE(rect1Spy.counts[QEvent::GraphicsSceneHoverEnter], 0); + QCOMPARE(rect1Spy.counts[QEvent::GraphicsSceneHoverMove], 0); + QCOMPARE(rect1Spy.counts[QEvent::GraphicsSceneHoverLeave], 0); + + rect2->setPanelModality(QGraphicsItem::NonModal); + + QCOMPARE(rect1Spy.counts[QEvent::GraphicsSceneHoverEnter], 1); + QCOMPARE(rect1Spy.counts[QEvent::GraphicsSceneHoverMove], 1); + + sendMouseMove(&scene, QPointF(75, 75)); + + QCOMPARE(rect2Spy.counts[QEvent::GraphicsSceneHoverEnter], 2); + QCOMPARE(rect2Spy.counts[QEvent::GraphicsSceneHoverMove], 2); + + rect2->setPanelModality(QGraphicsItem::SceneModal); + + QCOMPARE(rect1Spy.counts[QEvent::GraphicsSceneHoverLeave], 1); + QCOMPARE(rect2Spy.counts[QEvent::GraphicsSceneHoverEnter], 2); + // changing modality causes a spurious GraphicsSceneHoveMove, even though the mouse didn't + // actually move + QCOMPARE(rect2Spy.counts[QEvent::GraphicsSceneHoverMove], 3); + + sendMouseMove(&scene, QPointF(-25, -25)); + + QCOMPARE(rect2Spy.counts[QEvent::GraphicsSceneHoverLeave], 2); + QCOMPARE(rect1Spy.counts[QEvent::GraphicsSceneHoverEnter], 1); + QCOMPARE(rect1Spy.counts[QEvent::GraphicsSceneHoverMove], 1); + QCOMPARE(rect1Spy.counts[QEvent::GraphicsSceneHoverLeave], 1); + + rect2->setPanelModality(QGraphicsItem::PanelModal); + + QCOMPARE(rect1Spy.counts[QEvent::GraphicsSceneHoverEnter], 1); + QCOMPARE(rect1Spy.counts[QEvent::GraphicsSceneHoverMove], 1); + QCOMPARE(rect1Spy.counts[QEvent::GraphicsSceneHoverLeave], 1); + QCOMPARE(rect2Spy.counts[QEvent::GraphicsSceneHoverEnter], 2); + QCOMPARE(rect2Spy.counts[QEvent::GraphicsSceneHoverMove], 3); + QCOMPARE(rect2Spy.counts[QEvent::GraphicsSceneHoverLeave], 2); + + rect2->setPanelModality(QGraphicsItem::NonModal); + + QCOMPARE(rect1Spy.counts[QEvent::GraphicsSceneHoverEnter], 2); + QCOMPARE(rect1Spy.counts[QEvent::GraphicsSceneHoverMove], 2); + QCOMPARE(rect2Spy.counts[QEvent::GraphicsSceneHoverEnter], 2); + QCOMPARE(rect2Spy.counts[QEvent::GraphicsSceneHoverMove], 3); + QCOMPARE(rect2Spy.counts[QEvent::GraphicsSceneHoverLeave], 2); +} + +void tst_QGraphicsItem::modality_mouseGrabber() +{ + QGraphicsScene scene; + QGraphicsRectItem *rect1 = scene.addRect(-50, -50, 100, 100); + rect1->setFlag(QGraphicsItem::ItemIsPanel); + rect1->setFlag(QGraphicsItem::ItemIsMovable); + rect1->setData(0, "rect1"); + + QGraphicsRectItem *rect2 = scene.addRect(-50, -50, 100, 100); + rect2->setParentItem(rect1); + rect2->setFlag(QGraphicsItem::ItemIsPanel); + rect2->setFlag(QGraphicsItem::ItemIsMovable); + rect2->setPos(50, 50); + rect2->setData(0, "rect2"); + + EventSpy2 rect1Spy(&scene, rect1); + EventSpy2 rect2Spy(&scene, rect2); + + { + // pressing mouse on rect1 starts implicit grab + sendMousePress(&scene, QPoint(-25, -25)); + QCOMPARE(rect1Spy.counts[QEvent::GrabMouse], 1); + QCOMPARE(rect1Spy.counts[QEvent::GraphicsSceneMousePress], 1); + QCOMPARE(rect1Spy.counts[QEvent::UngrabMouse], 0); + QCOMPARE(rect2Spy.counts[QEvent::GrabMouse], 0); + QCOMPARE(rect2Spy.counts[QEvent::UngrabMouse], 0); + QCOMPARE(scene.mouseGrabberItem(), (QGraphicsItem *) rect1); + + // grab lost when rect1 is modally shadowed + rect2->setPanelModality(QGraphicsItem::SceneModal); + QCOMPARE(rect1Spy.counts[QEvent::GrabMouse], 1); + QCOMPARE(rect1Spy.counts[QEvent::UngrabMouse], 1); + QCOMPARE(rect2Spy.counts[QEvent::GrabMouse], 0); + QCOMPARE(rect2Spy.counts[QEvent::UngrabMouse], 0); + QCOMPARE(scene.mouseGrabberItem(), (QGraphicsItem *) 0); + + // releasing goes nowhere + sendMouseRelease(&scene, QPoint(-25, -25)); + QCOMPARE(rect1Spy.counts[QEvent::GrabMouse], 1); + QCOMPARE(rect1Spy.counts[QEvent::GraphicsSceneMouseRelease], 0); + QCOMPARE(rect1Spy.counts[QEvent::UngrabMouse], 1); + QCOMPARE(rect2Spy.counts[QEvent::GrabMouse], 0); + QCOMPARE(rect2Spy.counts[QEvent::GraphicsSceneMouseRelease], 0); + QCOMPARE(rect2Spy.counts[QEvent::UngrabMouse], 0); + QCOMPARE(scene.mouseGrabberItem(), (QGraphicsItem *) 0); + + // pressing mouse on rect1 starts implicit grab on rect2 (since it is modal) + sendMouseClick(&scene, QPoint(-25, -25)); + QCOMPARE(rect1Spy.counts[QEvent::GrabMouse], 1); + QCOMPARE(rect1Spy.counts[QEvent::GraphicsSceneMousePress], 1); + QCOMPARE(rect1Spy.counts[QEvent::GraphicsSceneMouseRelease], 0); + QCOMPARE(rect1Spy.counts[QEvent::UngrabMouse], 1); + QCOMPARE(rect2Spy.counts[QEvent::GrabMouse], 1); + QCOMPARE(rect2Spy.counts[QEvent::GraphicsSceneMousePress], 1); + QCOMPARE(rect2Spy.counts[QEvent::GraphicsSceneMouseRelease], 1); + QCOMPARE(rect2Spy.counts[QEvent::UngrabMouse], 1); + + rect2->setPanelModality(QGraphicsItem::NonModal); + + // pressing mouse on rect1 starts implicit grab + sendMousePress(&scene, QPoint(-25, -25)); + QCOMPARE(rect1Spy.counts[QEvent::GrabMouse], 2); + QCOMPARE(rect1Spy.counts[QEvent::GraphicsSceneMousePress], 2); + QCOMPARE(rect1Spy.counts[QEvent::UngrabMouse], 1); + QCOMPARE(rect2Spy.counts[QEvent::GrabMouse], 1); + QCOMPARE(rect2Spy.counts[QEvent::UngrabMouse], 1); + QCOMPARE(scene.mouseGrabberItem(), (QGraphicsItem *) rect1); + + // grab lost to rect2 when rect1 is modally shadowed + rect2->setPanelModality(QGraphicsItem::SceneModal); + QCOMPARE(rect1Spy.counts[QEvent::GrabMouse], 2); + QCOMPARE(rect1Spy.counts[QEvent::UngrabMouse], 2); + QCOMPARE(rect2Spy.counts[QEvent::GrabMouse], 1); + QCOMPARE(rect2Spy.counts[QEvent::UngrabMouse], 1); + QCOMPARE(scene.mouseGrabberItem(), (QGraphicsItem *) 0); + + // rect1 does *not* re-grab when rect2 is no longer modal + rect2->setPanelModality(QGraphicsItem::NonModal); + QCOMPARE(rect1Spy.counts[QEvent::GrabMouse], 2); + QCOMPARE(rect1Spy.counts[QEvent::UngrabMouse], 2); + QCOMPARE(rect2Spy.counts[QEvent::GrabMouse], 1); + QCOMPARE(rect2Spy.counts[QEvent::UngrabMouse], 1); + QCOMPARE(scene.mouseGrabberItem(), (QGraphicsItem *) 0); + + // release goes nowhere + sendMouseRelease(&scene, QPoint(-25, -25)); + QCOMPARE(rect1Spy.counts[QEvent::GrabMouse], 2); + QCOMPARE(rect1Spy.counts[QEvent::GraphicsSceneMouseRelease], 0); + QCOMPARE(rect1Spy.counts[QEvent::UngrabMouse], 2); + QCOMPARE(rect2Spy.counts[QEvent::GrabMouse], 1); + QCOMPARE(rect2Spy.counts[QEvent::UngrabMouse], 1); + QCOMPARE(scene.mouseGrabberItem(), (QGraphicsItem *) 0); + } + { + // repeat the test using PanelModal + rect2->setPanelModality(QGraphicsItem::NonModal); + rect1Spy.counts.clear(); + rect2Spy.counts.clear(); + + // pressing mouse on rect1 starts implicit grab + sendMousePress(&scene, QPoint(-25, -25)); + QCOMPARE(rect1Spy.counts[QEvent::GrabMouse], 1); + QCOMPARE(rect1Spy.counts[QEvent::GraphicsSceneMousePress], 1); + QCOMPARE(rect1Spy.counts[QEvent::UngrabMouse], 0); + QCOMPARE(rect2Spy.counts[QEvent::GrabMouse], 0); + QCOMPARE(rect2Spy.counts[QEvent::UngrabMouse], 0); + QCOMPARE(scene.mouseGrabberItem(), (QGraphicsItem *) rect1); + + // grab lost when rect1 is modally shadowed + rect2->setPanelModality(QGraphicsItem::PanelModal); + QCOMPARE(rect1Spy.counts[QEvent::GrabMouse], 1); + QCOMPARE(rect1Spy.counts[QEvent::UngrabMouse], 1); + QCOMPARE(rect2Spy.counts[QEvent::GrabMouse], 0); + QCOMPARE(rect2Spy.counts[QEvent::UngrabMouse], 0); + QCOMPARE(scene.mouseGrabberItem(), (QGraphicsItem *) 0); + + // releasing goes nowhere + sendMouseRelease(&scene, QPoint(-25, -25)); + QCOMPARE(rect1Spy.counts[QEvent::GrabMouse], 1); + QCOMPARE(rect1Spy.counts[QEvent::GraphicsSceneMouseRelease], 0); + QCOMPARE(rect1Spy.counts[QEvent::UngrabMouse], 1); + QCOMPARE(rect2Spy.counts[QEvent::GrabMouse], 0); + QCOMPARE(rect2Spy.counts[QEvent::GraphicsSceneMouseRelease], 0); + QCOMPARE(rect2Spy.counts[QEvent::UngrabMouse], 0); + QCOMPARE(scene.mouseGrabberItem(), (QGraphicsItem *) 0); + + // pressing mouse on rect1 starts implicit grab on rect2 (since it is modal) + sendMouseClick(&scene, QPoint(-25, -25)); + QCOMPARE(rect1Spy.counts[QEvent::GrabMouse], 1); + QCOMPARE(rect1Spy.counts[QEvent::GraphicsSceneMousePress], 1); + QCOMPARE(rect1Spy.counts[QEvent::GraphicsSceneMouseRelease], 0); + QCOMPARE(rect1Spy.counts[QEvent::UngrabMouse], 1); + QCOMPARE(rect2Spy.counts[QEvent::GrabMouse], 1); + QCOMPARE(rect2Spy.counts[QEvent::GraphicsSceneMousePress], 1); + QCOMPARE(rect2Spy.counts[QEvent::GraphicsSceneMouseRelease], 1); + QCOMPARE(rect2Spy.counts[QEvent::UngrabMouse], 1); + + rect2->setPanelModality(QGraphicsItem::NonModal); + + // pressing mouse on rect1 starts implicit grab + sendMousePress(&scene, QPoint(-25, -25)); + QCOMPARE(rect1Spy.counts[QEvent::GrabMouse], 2); + QCOMPARE(rect1Spy.counts[QEvent::GraphicsSceneMousePress], 2); + QCOMPARE(rect1Spy.counts[QEvent::UngrabMouse], 1); + QCOMPARE(rect2Spy.counts[QEvent::GrabMouse], 1); + QCOMPARE(rect2Spy.counts[QEvent::UngrabMouse], 1); + QCOMPARE(scene.mouseGrabberItem(), (QGraphicsItem *) rect1); + + // grab lost to rect2 when rect1 is modally shadowed + rect2->setPanelModality(QGraphicsItem::PanelModal); + QCOMPARE(rect1Spy.counts[QEvent::GrabMouse], 2); + QCOMPARE(rect1Spy.counts[QEvent::UngrabMouse], 2); + QCOMPARE(rect2Spy.counts[QEvent::GrabMouse], 1); + QCOMPARE(rect2Spy.counts[QEvent::UngrabMouse], 1); + QCOMPARE(scene.mouseGrabberItem(), (QGraphicsItem *) 0); + + // rect1 does *not* re-grab when rect2 is no longer modal + rect2->setPanelModality(QGraphicsItem::NonModal); + QCOMPARE(rect1Spy.counts[QEvent::GrabMouse], 2); + QCOMPARE(rect1Spy.counts[QEvent::UngrabMouse], 2); + QCOMPARE(rect2Spy.counts[QEvent::GrabMouse], 1); + QCOMPARE(rect2Spy.counts[QEvent::UngrabMouse], 1); + QCOMPARE(scene.mouseGrabberItem(), (QGraphicsItem *) 0); + + // release goes nowhere + sendMouseRelease(&scene, QPoint(-25, -25)); + QCOMPARE(rect1Spy.counts[QEvent::GrabMouse], 2); + QCOMPARE(rect1Spy.counts[QEvent::GraphicsSceneMouseRelease], 0); + QCOMPARE(rect1Spy.counts[QEvent::UngrabMouse], 2); + QCOMPARE(rect2Spy.counts[QEvent::GrabMouse], 1); + QCOMPARE(rect2Spy.counts[QEvent::UngrabMouse], 1); + QCOMPARE(scene.mouseGrabberItem(), (QGraphicsItem *) 0); + } + + { + // repeat the PanelModal tests, but this time the mouse events will be on a non-modal item, + // meaning normal grabbing should work + rect2->setPanelModality(QGraphicsItem::NonModal); + rect1Spy.counts.clear(); + rect2Spy.counts.clear(); + + QGraphicsRectItem *rect3 = scene.addRect(-50, -50, 100, 100); + rect3->setFlag(QGraphicsItem::ItemIsPanel); + rect3->setFlag(QGraphicsItem::ItemIsMovable); + rect3->setPos(150, 50); + rect3->setData(0, "rect3"); + + EventSpy2 rect3Spy(&scene, rect3); + + // pressing mouse on rect3 starts implicit grab + sendMousePress(&scene, QPoint(150, 50)); + QCOMPARE(rect1Spy.counts[QEvent::GrabMouse], 0); + QCOMPARE(rect1Spy.counts[QEvent::UngrabMouse], 0); + QCOMPARE(rect2Spy.counts[QEvent::GrabMouse], 0); + QCOMPARE(rect2Spy.counts[QEvent::UngrabMouse], 0); + QCOMPARE(rect3Spy.counts[QEvent::GrabMouse], 1); + QCOMPARE(rect3Spy.counts[QEvent::GraphicsSceneMousePress], 1); + QCOMPARE(rect3Spy.counts[QEvent::UngrabMouse], 0); + QCOMPARE(scene.mouseGrabberItem(), (QGraphicsItem *) rect3); + + // grab is *not* lost when rect1 is modally shadowed by rect2 + rect2->setPanelModality(QGraphicsItem::PanelModal); + QCOMPARE(rect1Spy.counts[QEvent::GrabMouse], 0); + QCOMPARE(rect1Spy.counts[QEvent::UngrabMouse], 0); + QCOMPARE(rect2Spy.counts[QEvent::GrabMouse], 0); + QCOMPARE(rect2Spy.counts[QEvent::UngrabMouse], 0); + QCOMPARE(rect3Spy.counts[QEvent::GrabMouse], 1); + QCOMPARE(rect3Spy.counts[QEvent::UngrabMouse], 0); + QCOMPARE(scene.mouseGrabberItem(), (QGraphicsItem *) rect3); + + // releasing goes to rect3 + sendMouseRelease(&scene, QPoint(150, 50)); + QCOMPARE(rect1Spy.counts[QEvent::GrabMouse], 0); + QCOMPARE(rect1Spy.counts[QEvent::UngrabMouse], 0); + QCOMPARE(rect2Spy.counts[QEvent::GrabMouse], 0); + QCOMPARE(rect2Spy.counts[QEvent::UngrabMouse], 0); + QCOMPARE(rect3Spy.counts[QEvent::GrabMouse], 1); + QCOMPARE(rect3Spy.counts[QEvent::GraphicsSceneMouseRelease], 1); + QCOMPARE(rect3Spy.counts[QEvent::UngrabMouse], 1); + QCOMPARE(scene.mouseGrabberItem(), (QGraphicsItem *) 0); + + rect2->setPanelModality(QGraphicsItem::NonModal); + + // pressing mouse on rect3 starts implicit grab + sendMousePress(&scene, QPoint(150, 50)); + QCOMPARE(rect1Spy.counts[QEvent::GrabMouse], 0); + QCOMPARE(rect1Spy.counts[QEvent::UngrabMouse], 0); + QCOMPARE(rect2Spy.counts[QEvent::GrabMouse], 0); + QCOMPARE(rect2Spy.counts[QEvent::UngrabMouse], 0); + QCOMPARE(rect3Spy.counts[QEvent::GrabMouse], 2); + QCOMPARE(rect3Spy.counts[QEvent::UngrabMouse], 1); + QCOMPARE(scene.mouseGrabberItem(), (QGraphicsItem *) rect3); + + // grab is not lost + rect2->setPanelModality(QGraphicsItem::PanelModal); + QCOMPARE(rect1Spy.counts[QEvent::GrabMouse], 0); + QCOMPARE(rect1Spy.counts[QEvent::UngrabMouse], 0); + QCOMPARE(rect2Spy.counts[QEvent::GrabMouse], 0); + QCOMPARE(rect2Spy.counts[QEvent::UngrabMouse], 0); + QCOMPARE(rect3Spy.counts[QEvent::GrabMouse], 2); + QCOMPARE(rect3Spy.counts[QEvent::UngrabMouse], 1); + QCOMPARE(scene.mouseGrabberItem(), (QGraphicsItem *) rect3); + + // grab stays on rect3 + rect2->setPanelModality(QGraphicsItem::NonModal); + QCOMPARE(rect1Spy.counts[QEvent::GrabMouse], 0); + QCOMPARE(rect1Spy.counts[QEvent::UngrabMouse], 0); + QCOMPARE(rect2Spy.counts[QEvent::GrabMouse], 0); + QCOMPARE(rect2Spy.counts[QEvent::UngrabMouse], 0); + QCOMPARE(rect3Spy.counts[QEvent::GrabMouse], 2); + QCOMPARE(rect3Spy.counts[QEvent::UngrabMouse], 1); + QCOMPARE(scene.mouseGrabberItem(), (QGraphicsItem *) rect3); + + // release goes to rect3 + sendMouseRelease(&scene, QPoint(150, 50)); + QCOMPARE(rect1Spy.counts[QEvent::GrabMouse], 0); + QCOMPARE(rect1Spy.counts[QEvent::UngrabMouse], 0); + QCOMPARE(rect2Spy.counts[QEvent::GrabMouse], 0); + QCOMPARE(rect2Spy.counts[QEvent::UngrabMouse], 0); + QCOMPARE(rect3Spy.counts[QEvent::GrabMouse], 2); + QCOMPARE(rect3Spy.counts[QEvent::UngrabMouse], 2); + QCOMPARE(scene.mouseGrabberItem(), (QGraphicsItem *) 0); + } +} + +void tst_QGraphicsItem::modality_clickFocus() +{ + QGraphicsScene scene; + QGraphicsRectItem *rect1 = scene.addRect(-50, -50, 100, 100); + rect1->setFlag(QGraphicsItem::ItemIsPanel); + rect1->setFlag(QGraphicsItem::ItemIsFocusable); + rect1->setData(0, "rect1"); + + QGraphicsRectItem *rect2 = scene.addRect(-50, -50, 100, 100); + rect2->setParentItem(rect1); + rect2->setFlag(QGraphicsItem::ItemIsPanel); + rect2->setFlag(QGraphicsItem::ItemIsFocusable); + rect2->setPos(50, 50); + rect2->setData(0, "rect2"); + + QEvent windowActivateEvent(QEvent::WindowActivate); + QApplication::sendEvent(&scene, &windowActivateEvent); + + EventSpy2 rect1Spy(&scene, rect1); + EventSpy2 rect2Spy(&scene, rect2); + + // activate rect1, it should not get focus + rect1->setActive(true); + QCOMPARE(scene.focusItem(), (QGraphicsItem *) 0); + + // focus stays unset when rect2 becomes modal + rect2->setPanelModality(QGraphicsItem::SceneModal); + QCOMPARE(scene.focusItem(), (QGraphicsItem *) 0); + QCOMPARE(rect1Spy.counts[QEvent::FocusIn], 0); + QCOMPARE(rect1Spy.counts[QEvent::FocusOut], 0); + QCOMPARE(rect2Spy.counts[QEvent::FocusIn], 0); + QCOMPARE(rect2Spy.counts[QEvent::FocusOut], 0); + + // clicking on rect1 should not set it's focus item + sendMouseClick(&scene, QPointF(-25, -25)); + QCOMPARE(rect1->focusItem(), (QGraphicsItem *) 0); + QCOMPARE(rect1Spy.counts[QEvent::FocusIn], 0); + QCOMPARE(rect1Spy.counts[QEvent::FocusOut], 0); + QCOMPARE(rect2Spy.counts[QEvent::FocusIn], 0); + QCOMPARE(rect2Spy.counts[QEvent::FocusOut], 0); + + // clicking on rect2 gives it focus + rect2->setActive(true); + sendMouseClick(&scene, QPointF(75, 75)); + QCOMPARE(scene.focusItem(), (QGraphicsItem *) rect2); + QCOMPARE(rect1Spy.counts[QEvent::FocusIn], 0); + QCOMPARE(rect1Spy.counts[QEvent::FocusOut], 0); + QCOMPARE(rect2Spy.counts[QEvent::FocusIn], 1); + QCOMPARE(rect2Spy.counts[QEvent::FocusOut], 0); + + // clicking on rect1 does *not* give it focus + rect1->setActive(true); + sendMouseClick(&scene, QPointF(-25, -25)); + QCOMPARE(scene.focusItem(), (QGraphicsItem *) 0); + QCOMPARE(rect1Spy.counts[QEvent::FocusIn], 0); + QCOMPARE(rect1Spy.counts[QEvent::FocusOut], 0); + QCOMPARE(rect2Spy.counts[QEvent::FocusIn], 1); + QCOMPARE(rect2Spy.counts[QEvent::FocusOut], 1); + + // focus doesn't change when leaving modality either + rect2->setPanelModality(QGraphicsItem::NonModal); + QCOMPARE(scene.focusItem(), (QGraphicsItem *) 0); + QCOMPARE(rect1Spy.counts[QEvent::FocusIn], 0); + QCOMPARE(rect1Spy.counts[QEvent::FocusOut], 0); + QCOMPARE(rect2Spy.counts[QEvent::FocusIn], 1); + QCOMPARE(rect2Spy.counts[QEvent::FocusOut], 1); + + // click on rect1, it should get focus now + sendMouseClick(&scene, QPointF(-25, -25)); + QCOMPARE(scene.focusItem(), (QGraphicsItem *) rect1); + QCOMPARE(rect1Spy.counts[QEvent::FocusIn], 1); + QCOMPARE(rect1Spy.counts[QEvent::FocusOut], 0); + QCOMPARE(rect2Spy.counts[QEvent::FocusIn], 1); + QCOMPARE(rect2Spy.counts[QEvent::FocusOut], 1); +} + +void tst_QGraphicsItem::modality_keyEvents() +{ + QGraphicsScene scene; + QGraphicsRectItem *rect1 = scene.addRect(-50, -50, 100, 100); + rect1->setFlag(QGraphicsItem::ItemIsPanel); + rect1->setFlag(QGraphicsItem::ItemIsFocusable); + rect1->setData(0, "rect1"); + + QGraphicsRectItem *rect1child = scene.addRect(-10, -10, 20, 20); + rect1child->setParentItem(rect1); + rect1child->setFlag(QGraphicsItem::ItemIsFocusable); + rect1child->setData(0, "rect1child1"); + + QGraphicsRectItem *rect2 = scene.addRect(-50, -50, 100, 100); + rect2->setParentItem(rect1); + rect2->setFlag(QGraphicsItem::ItemIsPanel); + rect2->setFlag(QGraphicsItem::ItemIsFocusable); + rect2->setPos(50, 50); + rect2->setData(0, "rect2"); + + QGraphicsRectItem *rect2child = scene.addRect(-10, -10, 20, 20); + rect2child->setParentItem(rect2); + rect2child->setFlag(QGraphicsItem::ItemIsFocusable); + rect2child->setData(0, "rect2child1"); + + QEvent windowActivateEvent(QEvent::WindowActivate); + QApplication::sendEvent(&scene, &windowActivateEvent); + + EventSpy2 rect1Spy(&scene, rect1); + EventSpy2 rect1childSpy(&scene, rect1child); + EventSpy2 rect2Spy(&scene, rect2); + EventSpy2 rect2childSpy(&scene, rect2child); + + // activate rect1 and give it rect1child focus + rect1->setActive(true); + rect1child->setFocus(); + QCOMPARE(scene.focusItem(), (QGraphicsItem *) rect1child); + + // focus stays on rect1child when rect2 becomes modal + rect2->setPanelModality(QGraphicsItem::SceneModal); + QCOMPARE(scene.focusItem(), (QGraphicsItem *) rect1child); + + // but key events to rect1child should be neither delivered nor propagated + sendKeyClick(&scene, Qt::Key_A); + sendKeyClick(&scene, Qt::Key_S); + sendKeyClick(&scene, Qt::Key_D); + sendKeyClick(&scene, Qt::Key_F); + QCOMPARE(rect1childSpy.counts[QEvent::KeyPress], 0); + QCOMPARE(rect1childSpy.counts[QEvent::KeyRelease], 0); + QCOMPARE(rect1Spy.counts[QEvent::KeyPress], 0); + QCOMPARE(rect1Spy.counts[QEvent::KeyRelease], 0); + + // change to panel modality, rect1child1 keeps focus + rect2->setPanelModality(QGraphicsItem::PanelModal); + QCOMPARE(scene.focusItem(), (QGraphicsItem *) rect1child); + + // still no key events + sendKeyClick(&scene, Qt::Key_J); + sendKeyClick(&scene, Qt::Key_K); + sendKeyClick(&scene, Qt::Key_L); + sendKeyClick(&scene, Qt::Key_Semicolon); + QCOMPARE(rect1childSpy.counts[QEvent::KeyPress], 0); + QCOMPARE(rect1childSpy.counts[QEvent::KeyRelease], 0); + QCOMPARE(rect1Spy.counts[QEvent::KeyPress], 0); + QCOMPARE(rect1Spy.counts[QEvent::KeyRelease], 0); +} + QTEST_MAIN(tst_QGraphicsItem) #include "tst_qgraphicsitem.moc" diff --git a/tests/auto/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp b/tests/auto/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp index 6e60516..76e7202 100644 --- a/tests/auto/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp +++ b/tests/auto/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp @@ -1296,17 +1296,18 @@ void tst_QGraphicsProxyWidget::paintEvent() w->show(); QTest::qWaitForWindowShown(w); QApplication::processEvents(); - + QTest::qWait(50); proxy.setWidget(w); scene.addItem(&proxy); //make sure we flush all the paint events - QApplication::processEvents(); + QTest::qWait(70); QTRY_VERIFY(proxy.paintCount > 1); + QTest::qWait(70); proxy.paintCount = 0; w->update(); - QApplication::processEvents(); + QTest::qWait(30); QTRY_COMPARE(proxy.paintCount, 1); //the widget should have been painted now } @@ -3059,6 +3060,8 @@ void tst_QGraphicsProxyWidget::deleteProxyForChildWidget() proxy->setWidget(0); //just don't crash + QApplication::processEvents(); + delete combo; } void tst_QGraphicsProxyWidget::bypassGraphicsProxyWidget_data() @@ -3090,11 +3093,17 @@ void tst_QGraphicsProxyWidget::bypassGraphicsProxyWidget() if (bypass) flags |= Qt::BypassGraphicsProxyWidget; QFileDialog *dialog = new QFileDialog(widget, flags); + dialog->setOption(QFileDialog::DontUseNativeDialog, true); dialog->show(); QCOMPARE(proxy->childItems().size(), bypass ? 0 : 1); if (!bypass) QCOMPARE(((QGraphicsProxyWidget *)proxy->childItems().first())->widget(), (QWidget *)dialog); + + dialog->hide(); + QApplication::processEvents(); + delete dialog; + delete widget; } static void makeDndEvent(QGraphicsSceneDragDropEvent *event, QGraphicsView *view, const QPointF &pos) diff --git a/tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp b/tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp index 864076f..e55dc9aa 100644 --- a/tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp +++ b/tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp @@ -1357,8 +1357,9 @@ void tst_QGraphicsScene::removeItem() QVERIFY(!hoverItem->isHovered); { - QTest::mouseMove(view.viewport(), view.mapFromScene(hoverItem->scenePos()), Qt::NoButton); QTest::qWait(250); + QTest::mouseMove(view.viewport(), view.mapFromScene(hoverItem->scenePos()), Qt::NoButton); + QTest::qWait(10); QMouseEvent moveEvent(QEvent::MouseMove, view.mapFromScene(hoverItem->scenePos()), Qt::NoButton, 0, 0); QApplication::sendEvent(view.viewport(), &moveEvent); } @@ -1632,6 +1633,7 @@ void tst_QGraphicsScene::hoverEvents_siblings() #endif qApp->setActiveWindow(&view); view.activateWindow(); + QTest::qWait(70); QCursor::setPos(view.mapToGlobal(QPoint(-5, -5))); @@ -1655,7 +1657,7 @@ void tst_QGraphicsScene::hoverEvents_siblings() qApp->processEvents(); // this posts updates from the scene to the view qApp->processEvents(); // which trigger a repaint here - QVERIFY(items.at(i)->isHovered); + QTRY_VERIFY(items.at(i)->isHovered); if (j && i > 0) QVERIFY(!items.at(i - 1)->isHovered); if (!j && i < 14) diff --git a/tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp b/tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp index b6750ea..0b73733 100644 --- a/tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp +++ b/tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp @@ -1456,7 +1456,7 @@ void tst_QGraphicsWidget::verifyFocusChain() scene.addItem(w1_4); QTRY_VERIFY(w1_3->hasFocus()); QTest::qWait(25); - QVERIFY(compareFocusChain(view, QList<QGraphicsItem*>() << w1_3 << w1_4)); + QTRY_VERIFY(compareFocusChain(view, QList<QGraphicsItem*>() << w1_3 << w1_4)); QTest::keyPress(QApplication::focusWidget(), Qt::Key_Backtab); QTest::qWait(25); QTRY_VERIFY(lineEdit->hasFocus()); diff --git a/tests/auto/qgridlayout/tst_qgridlayout.cpp b/tests/auto/qgridlayout/tst_qgridlayout.cpp index 4a5a341..7c320be 100644 --- a/tests/auto/qgridlayout/tst_qgridlayout.cpp +++ b/tests/auto/qgridlayout/tst_qgridlayout.cpp @@ -884,6 +884,7 @@ void tst_QGridLayout::minMaxSize() for (int pass = 0; pass < 2; ++pass) { m_toplevel->hide(); QApplication::processEvents(); + QTest::qWait(20); // Test if removeItem uninitializes data properly while (m_grid->count()) { QLayoutItem *item = m_grid->itemAt(0); @@ -921,7 +922,7 @@ void tst_QGridLayout::minMaxSize() #endif QTest::qWait(20); m_toplevel->adjustSize(); - QTest::qWait(20); // wait for the implicit adjustSize + QTest::qWait(120); // wait for the implicit adjustSize // If the following fails we might have to wait longer. // If that does not help there is likely a problem with the implicit adjustSize in show() if (!fixedSize.isValid()) { diff --git a/tests/auto/qhttpnetworkconnection/tst_qhttpnetworkconnection.cpp b/tests/auto/qhttpnetworkconnection/tst_qhttpnetworkconnection.cpp index 470e57f..6036a14 100644 --- a/tests/auto/qhttpnetworkconnection/tst_qhttpnetworkconnection.cpp +++ b/tests/auto/qhttpnetworkconnection/tst_qhttpnetworkconnection.cpp @@ -106,6 +106,7 @@ private Q_SLOTS: void getMultiple_data(); void getMultiple(); void getMultipleWithPipeliningAndMultiplePriorities(); + void getMultipleWithPriorities(); }; tst_QHttpNetworkConnection::tst_QHttpNetworkConnection() @@ -908,5 +909,63 @@ void tst_QHttpNetworkConnection::getMultipleWithPipeliningAndMultiplePriorities( qDeleteAll(replies); } +class GetMultipleWithPrioritiesReceiver : public QObject +{ + Q_OBJECT +public: + int highPrioReceived; + int lowPrioReceived; + int requestCount; + GetMultipleWithPrioritiesReceiver(int rq) : highPrioReceived(0), lowPrioReceived(0), requestCount(rq) { } +public Q_SLOTS: + void finishedSlot() { + QHttpNetworkReply *reply = (QHttpNetworkReply*) sender(); + if (reply->request().priority() == QHttpNetworkRequest::HighPriority) + highPrioReceived++; + else if (reply->request().priority() == QHttpNetworkRequest::LowPriority) + lowPrioReceived++; + else + QFAIL("Wrong priority!?"); + + QVERIFY(highPrioReceived >= lowPrioReceived); + + if (highPrioReceived + lowPrioReceived == requestCount) + QTestEventLoop::instance().exitLoop(); + } +}; + +void tst_QHttpNetworkConnection::getMultipleWithPriorities() +{ + quint16 requestCount = 100; + // use 2 connections. + QHttpNetworkConnection connection(2, QtNetworkSettings::serverName()); + GetMultipleWithPrioritiesReceiver receiver(requestCount); + QUrl url("http://" + QtNetworkSettings::serverName() + "/qtest/rfc3252.txt"); + QList<QHttpNetworkRequest*> requests; + QList<QHttpNetworkReply*> replies; + + for (int i = 0; i < requestCount; i++) { + QHttpNetworkRequest *request = new QHttpNetworkRequest(url);; + + if (i % 2) + request->setPriority(QHttpNetworkRequest::HighPriority); + else + request->setPriority(QHttpNetworkRequest::LowPriority); + + requests.append(request); + QHttpNetworkReply *reply = connection.sendRequest(*request); + connect(reply, SIGNAL(finished()), &receiver, SLOT(finishedSlot())); + replies.append(reply); + } + + QTestEventLoop::instance().enterLoop(40); + QVERIFY(!QTestEventLoop::instance().timeout()); + + qDeleteAll(requests); + qDeleteAll(replies); +} + + + QTEST_MAIN(tst_QHttpNetworkConnection) #include "tst_qhttpnetworkconnection.moc" diff --git a/tests/auto/qicon/image.tga b/tests/auto/qicon/image.tga Binary files differdeleted file mode 100644 index 0cd507d..0000000 --- a/tests/auto/qicon/image.tga +++ /dev/null diff --git a/tests/auto/qicon/qicon.pro b/tests/auto/qicon/qicon.pro index 0c9c7e9..8ae252f 100644 --- a/tests/auto/qicon/qicon.pro +++ b/tests/auto/qicon/qicon.pro @@ -6,9 +6,9 @@ RESOURCES = tst_qicon.qrc wince* { QT += xml svg addFiles.sources += $$_PRO_FILE_PWD_/*.png - addFiles.sources += $$_PRO_FILE_PWD_/*.tga addFiles.sources += $$_PRO_FILE_PWD_/*.svg addFiles.sources += $$_PRO_FILE_PWD_/*.svgz + addFiles.sources += $$_PRO_FILE_PWD_/tst_qicon.cpp addFiles.path = . DEPLOYMENT += addFiles @@ -16,7 +16,7 @@ wince* { DEFINES += SRCDIR=\\\".\\\" } else:symbian { QT += xml svg - addFiles.sources = *.png *.tga *.svg *.svgz + addFiles.sources = *.png tst_qicon.cpp *.svg *.svgz addFiles.path = . plugins.sources = qsvgicon.dll plugins.path = iconengines diff --git a/tests/auto/qicon/tst_qicon.cpp b/tests/auto/qicon/tst_qicon.cpp index 96d1d6c..f5baeaa 100644 --- a/tests/auto/qicon/tst_qicon.cpp +++ b/tests/auto/qicon/tst_qicon.cpp @@ -242,7 +242,7 @@ void tst_QIcon::isNull() { const QString prefix = QLatin1String(SRCDIR) + QLatin1String("/"); // test string constructor with existing file but unsupported format - QIcon iconUnsupportedFormat = QIcon(prefix + "image.tga"); + QIcon iconUnsupportedFormat = QIcon(prefix + "tst_qicon.cpp"); QVERIFY(!iconUnsupportedFormat.isNull()); QVERIFY(!iconUnsupportedFormat.actualSize(QSize(32, 32)).isValid()); diff --git a/tests/auto/qitemdelegate/tst_qitemdelegate.cpp b/tests/auto/qitemdelegate/tst_qitemdelegate.cpp index 5d1034a..426887d 100644 --- a/tests/auto/qitemdelegate/tst_qitemdelegate.cpp +++ b/tests/auto/qitemdelegate/tst_qitemdelegate.cpp @@ -865,7 +865,7 @@ void tst_QItemDelegate::decoration() qt_x11_wait_for_window_manager(&table); #endif QApplication::setActiveWindow(&table); - QTRY_COMPARE(QApplication::activeWindow(), &table); + QTRY_COMPARE(QApplication::activeWindow(), static_cast<QWidget*>(&table)); QVariant value; switch ((QVariant::Type)type) { diff --git a/tests/auto/qmath/qmath.pro b/tests/auto/qmath/qmath.pro new file mode 100644 index 0000000..03134ee --- /dev/null +++ b/tests/auto/qmath/qmath.pro @@ -0,0 +1,6 @@ +load(qttest_p4) + +QT = core + +SOURCES += tst_qmath.cpp +QT = core diff --git a/tests/auto/qmath/tst_qmath.cpp b/tests/auto/qmath/tst_qmath.cpp new file mode 100644 index 0000000..efc7cfa --- /dev/null +++ b/tests/auto/qmath/tst_qmath.cpp @@ -0,0 +1,67 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <QtTest/QtTest> +#include <qmath.h> + +static const qreal PI = 3.14159265358979323846264338327950288; + +class tst_QMath : public QObject +{ + Q_OBJECT +private slots: + void fastSinCos(); +}; + +void tst_QMath::fastSinCos() +{ + // Test evenly spaced angles from 0 to 2pi radians. + const int LOOP_COUNT = 100000; + for (int i = 0; i < LOOP_COUNT; ++i) { + qreal angle = i * 2 * PI / (LOOP_COUNT - 1); + QVERIFY(qAbs(qSin(angle) - qFastSin(angle)) < 1e-5); + QVERIFY(qAbs(qCos(angle) - qFastCos(angle)) < 1e-5); + } +} + +QTEST_APPLESS_MAIN(tst_QMath) + +#include "tst_qmath.moc" diff --git a/tests/auto/qmdiarea/tst_qmdiarea.cpp b/tests/auto/qmdiarea/tst_qmdiarea.cpp index b110114..a5b3848 100644 --- a/tests/auto/qmdiarea/tst_qmdiarea.cpp +++ b/tests/auto/qmdiarea/tst_qmdiarea.cpp @@ -468,6 +468,7 @@ void tst_QMdiArea::subWindowActivated2() #ifdef Q_WS_X11 qt_x11_wait_for_window_manager(&mdiArea); #endif + QTest::qWait(100); QTRY_COMPARE(spy.count(), 5); QCOMPARE(mdiArea.activeSubWindow(), mdiArea.subWindowList().back()); @@ -1775,9 +1776,9 @@ void tst_QMdiArea::tileSubWindows() #endif qApp->processEvents(); - QVERIFY(workspace.size() != QSize(150, 150)); - QVERIFY(!vBar->isVisible()); - QVERIFY(!hBar->isVisible()); + QTRY_VERIFY(workspace.size() != QSize(150, 150)); + QTRY_VERIFY(!vBar->isVisible()); + QTRY_VERIFY(!hBar->isVisible()); } void tst_QMdiArea::cascadeAndTileSubWindows() @@ -1852,6 +1853,7 @@ void tst_QMdiArea::resizeMaximizedChildWindows() #if defined(Q_WS_X11) qt_x11_wait_for_window_manager(&workspace); #endif + QTest::qWait(100); workspace.resize(startSize, startSize); workspace.setOption(QMdiArea::DontMaximizeSubWindowOnActivation); QSize workspaceSize = workspace.size(); @@ -1864,6 +1866,7 @@ void tst_QMdiArea::resizeMaximizedChildWindows() windows.append(window); qApp->processEvents(); window->showMaximized(); + QTest::qWait(100); QVERIFY(window->isMaximized()); QSize windowSize = window->size(); QVERIFY(windowSize.isValid()); @@ -1873,7 +1876,7 @@ void tst_QMdiArea::resizeMaximizedChildWindows() QTest::qWait(100); qApp->processEvents(); QTRY_COMPARE(workspace.size(), workspaceSize + QSize(increment, increment)); - QCOMPARE(window->size(), windowSize + QSize(increment, increment)); + QTRY_COMPARE(window->size(), windowSize + QSize(increment, increment)); workspaceSize = workspace.size(); } diff --git a/tests/auto/qmdisubwindow/tst_qmdisubwindow.cpp b/tests/auto/qmdisubwindow/tst_qmdisubwindow.cpp index b897d8f..2d70bef 100644 --- a/tests/auto/qmdisubwindow/tst_qmdisubwindow.cpp +++ b/tests/auto/qmdisubwindow/tst_qmdisubwindow.cpp @@ -1065,6 +1065,7 @@ void tst_QMdiSubWindow::setSystemMenu() qApp->setLayoutDirection(Qt::RightToLeft); qApp->processEvents(); mainWindow.updateGeometry(); + QTest::qWait(150); subWindow->showSystemMenu(); QTest::qWait(250); diff --git a/tests/auto/qmessagebox/tst_qmessagebox.cpp b/tests/auto/qmessagebox/tst_qmessagebox.cpp index 5607fbd..1f8e925 100644 --- a/tests/auto/qmessagebox/tst_qmessagebox.cpp +++ b/tests/auto/qmessagebox/tst_qmessagebox.cpp @@ -714,7 +714,8 @@ void tst_QMessageBox::setInformativeText() msgbox.setInformativeText(itext); msgbox.show(); QCOMPARE(msgbox.informativeText(), itext); - QVERIFY(msgbox.width() > 200); //verify it's big enough (task181688) + QVERIFY2(msgbox.width() > 190, //verify it's big enough (task181688) + qPrintable(QString("%1 > 190").arg(msgbox.width()))); } void tst_QMessageBox::iconPixmap() diff --git a/tests/auto/qnetworkreply/certs/aspiriniks.ca.crt b/tests/auto/qnetworkreply/certs/aspiriniks.ca.crt new file mode 100644 index 0000000..36436b6 --- /dev/null +++ b/tests/auto/qnetworkreply/certs/aspiriniks.ca.crt @@ -0,0 +1,22 @@ +-----BEGIN CERTIFICATE----- +MIIDnDCCAoQCCQDV3otC4hs2KTANBgkqhkiG9w0BAQUFADCBjzELMAkGA1UEBhMC +Tk8xDTALBgNVBAgTBE9zbG8xDTALBgNVBAcTBE9zbG8xDzANBgNVBAoTBlRUIEFT +QTEOMAwGA1UECxMFUVQgU1cxHDAaBgNVBAMTE2FzcGlyaW5pa3MudHJvbGwubm8x +IzAhBgkqhkiG9w0BCQEWFGFiYWJpY0B0cm9sbHRlY2guY29tMB4XDTA4MTEwMTA4 +NTcyOFoXDTA5MTEwMTA4NTcyOFowgY8xCzAJBgNVBAYTAk5PMQ0wCwYDVQQIEwRP +c2xvMQ0wCwYDVQQHEwRPc2xvMQ8wDQYDVQQKEwZUVCBBU0ExDjAMBgNVBAsTBVFU +IFNXMRwwGgYDVQQDExNhc3BpcmluaWtzLnRyb2xsLm5vMSMwIQYJKoZIhvcNAQkB +FhRhYmFiaWNAdHJvbGx0ZWNoLmNvbTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCC +AQoCggEBAMV2bMD1DN3DMgbxU3DXw2i7EWGDXcWjTDtdHvqgIb+9nHqo3MJSrzJy +qgEPoOsXqswMla9wDPZAsWv5gVAmVSqpy2lfEgfY7LaSHiGD75seF7zIy+CxREHW +DofHXpJGGJpBCZEKQt2HfHu3+yAYNPucN78tWNZAcPbUg5tfxMZeepRimAZNIxBI +93SDrl/f9Ka7hvPSzUQsnp8hfdpHlFPFznKfD6yPrjxgz2mT9efavJ4DhtyIa4m+ +paiX515CidDz4A8CFxKZbYvuqq1ilibF/si2so9VhALC77ZcAJP1IMuT8T+WUCxq +skJqiSCncl0Hgr+ba8MDGF9UQYowgjMCAwEAATANBgkqhkiG9w0BAQUFAAOCAQEA +KcJuNUHvjB8ok3cnTmQEeF0LPPkgj28Tqb5TFB8xpVfRI+wvTYsHsmGdOKCgYJ3a +7VflIsr63ojG8/rXK8H/cx2o2f2Hr3liJdi1UnoLDDRjBqGGz7JNuMreYokPvIbm +eP01mVyK4PO2iYRwHUIAw5eeB1vMWKX2z95MupD+HRLtmGyaLALg8aQxj5N84Ewl +eU2PQfhv8A1wj7aL17kfEUxDerQ1kUzlThJMV1J8Dl0l4C9N8evQkelROJU00i46 +oJikA8BW6EpgbnGyNyyj5Loy4wLPKew9nTS8MCJ5xPMQc0urbY/VzuOeUK7WQof7 +xOFSsRAVyQv+yqgmcZMCtg== +-----END CERTIFICATE----- diff --git a/tests/auto/qnetworkreply/certs/fluke.cert b/tests/auto/qnetworkreply/certs/fluke.cert new file mode 100644 index 0000000..069fa6b --- /dev/null +++ b/tests/auto/qnetworkreply/certs/fluke.cert @@ -0,0 +1,75 @@ +Certificate: + Data: + Version: 3 (0x2) + Serial Number: 0 (0x0) + Signature Algorithm: sha1WithRSAEncryption + Issuer: C=NO, ST=Oslo, L=Nydalen, O=Nokia Corporation and/or its subsidiary(-ies), OU=Development, CN=fluke.troll.no/emailAddress=ahanssen@trolltech.com + Validity + Not Before: Dec 4 01:10:32 2007 GMT + Not After : Apr 21 01:10:32 2035 GMT + Subject: C=NO, ST=Oslo, O=Nokia Corporation and/or its subsidiary(-ies), OU=Development, CN=fluke.troll.no + Subject Public Key Info: + Public Key Algorithm: rsaEncryption + RSA Public Key: (1024 bit) + Modulus (1024 bit): + 00:a7:c8:a0:4a:c4:19:05:1b:66:ba:32:e2:d2:f1: + 1c:6f:17:82:e4:39:2e:01:51:90:db:04:34:32:11: + 21:c2:0d:6f:59:d8:53:90:54:3f:83:8f:a9:d3:b3: + d5:ee:1a:9b:80:ae:c3:25:c9:5e:a5:af:4b:60:05: + aa:a0:d1:91:01:1f:ca:04:83:e3:58:1c:99:32:45: + 84:70:72:58:03:98:4a:63:8b:41:f5:08:49:d2:91: + 02:60:6b:e4:64:fe:dd:a0:aa:74:08:e9:34:4c:91: + 5f:12:3d:37:4d:54:2c:ad:7f:5b:98:60:36:02:8c: + 3b:f6:45:f3:27:6a:9b:94:9d + Exponent: 65537 (0x10001) + X509v3 extensions: + X509v3 Basic Constraints: + CA:FALSE + Netscape Comment: + OpenSSL Generated Certificate + X509v3 Subject Key Identifier: + 21:85:04:3D:23:01:66:E5:F7:9F:1A:84:24:8A:AF:0A:79:F4:E5:AC + X509v3 Authority Key Identifier: + DirName:/C=NO/ST=Oslo/L=Nydalen/O=Nokia Corporation and/or its subsidiary(-ies)/OU=Development/CN=fluke.troll.no/emailAddress=ahanssen@trolltech.com + serial:8E:A8:B4:E8:91:B7:54:2E + + Signature Algorithm: sha1WithRSAEncryption + 6d:57:5f:d1:05:43:f0:62:05:ec:2a:71:a5:dc:19:08:f2:c4: + a6:bd:bb:25:d9:ca:89:01:0e:e4:cf:1f:c1:8c:c8:24:18:35: + 53:59:7b:c0:43:b4:32:e6:98:b2:a6:ef:15:05:0b:48:5f:e1: + a0:0c:97:a9:a1:77:d8:35:18:30:bc:a9:8f:d3:b7:54:c7:f1: + a9:9e:5d:e6:19:bf:f6:3c:5b:2b:d8:e4:3e:62:18:88:8b:d3: + 24:e1:40:9b:0c:e6:29:16:62:ab:ea:05:24:70:36:aa:55:93: + ef:02:81:1b:23:10:a2:04:eb:56:95:75:fc:f8:94:b1:5d:42: + c5:3f:36:44:85:5d:3a:2e:90:46:8a:a2:b9:6f:87:ae:0c:15: + 40:19:31:90:fc:3b:25:bb:ae:f1:66:13:0d:85:90:d9:49:34: + 8f:f2:5d:f9:7a:db:4d:5d:27:f6:76:9d:35:8c:06:a6:4c:a3: + b1:b2:b6:6f:1d:d7:a3:00:fd:72:eb:9e:ea:44:a1:af:21:34: + 7d:c7:42:e2:49:91:19:8b:c0:ad:ba:82:80:a8:71:70:f4:35: + 31:91:63:84:20:95:e9:60:af:64:8b:cc:ff:3d:8a:76:74:3d: + c8:55:6d:e4:8e:c3:2b:1c:e8:42:18:ae:9f:e6:6b:9c:34:06: + ec:6a:f2:c3 +-----BEGIN CERTIFICATE----- +MIIEEzCCAvugAwIBAgIBADANBgkqhkiG9w0BAQUFADCBnDELMAkGA1UEBhMCTk8x +DTALBgNVBAgTBE9zbG8xEDAOBgNVBAcTB055ZGFsZW4xFjAUBgNVBAoTDVRyb2xs +dGVjaCBBU0ExFDASBgNVBAsTC0RldmVsb3BtZW50MRcwFQYDVQQDEw5mbHVrZS50 +cm9sbC5ubzElMCMGCSqGSIb3DQEJARYWYWhhbnNzZW5AdHJvbGx0ZWNoLmNvbTAe +Fw0wNzEyMDQwMTEwMzJaFw0zNTA0MjEwMTEwMzJaMGMxCzAJBgNVBAYTAk5PMQ0w +CwYDVQQIEwRPc2xvMRYwFAYDVQQKEw1Ucm9sbHRlY2ggQVNBMRQwEgYDVQQLEwtE +ZXZlbG9wbWVudDEXMBUGA1UEAxMOZmx1a2UudHJvbGwubm8wgZ8wDQYJKoZIhvcN +AQEBBQADgY0AMIGJAoGBAKfIoErEGQUbZroy4tLxHG8XguQ5LgFRkNsENDIRIcIN +b1nYU5BUP4OPqdOz1e4am4CuwyXJXqWvS2AFqqDRkQEfygSD41gcmTJFhHByWAOY +SmOLQfUISdKRAmBr5GT+3aCqdAjpNEyRXxI9N01ULK1/W5hgNgKMO/ZF8ydqm5Sd +AgMBAAGjggEaMIIBFjAJBgNVHRMEAjAAMCwGCWCGSAGG+EIBDQQfFh1PcGVuU1NM +IEdlbmVyYXRlZCBDZXJ0aWZpY2F0ZTAdBgNVHQ4EFgQUIYUEPSMBZuX3nxqEJIqv +Cnn05awwgbsGA1UdIwSBszCBsKGBoqSBnzCBnDELMAkGA1UEBhMCTk8xDTALBgNV +BAgTBE9zbG8xEDAOBgNVBAcTB055ZGFsZW4xFjAUBgNVBAoTDVRyb2xsdGVjaCBB +U0ExFDASBgNVBAsTC0RldmVsb3BtZW50MRcwFQYDVQQDEw5mbHVrZS50cm9sbC5u +bzElMCMGCSqGSIb3DQEJARYWYWhhbnNzZW5AdHJvbGx0ZWNoLmNvbYIJAI6otOiR +t1QuMA0GCSqGSIb3DQEBBQUAA4IBAQBtV1/RBUPwYgXsKnGl3BkI8sSmvbsl2cqJ +AQ7kzx/BjMgkGDVTWXvAQ7Qy5piypu8VBQtIX+GgDJepoXfYNRgwvKmP07dUx/Gp +nl3mGb/2PFsr2OQ+YhiIi9Mk4UCbDOYpFmKr6gUkcDaqVZPvAoEbIxCiBOtWlXX8 ++JSxXULFPzZEhV06LpBGiqK5b4euDBVAGTGQ/Dslu67xZhMNhZDZSTSP8l35ettN +XSf2dp01jAamTKOxsrZvHdejAP1y657qRKGvITR9x0LiSZEZi8CtuoKAqHFw9DUx +kWOEIJXpYK9ki8z/PYp2dD3IVW3kjsMrHOhCGK6f5mucNAbsavLD +-----END CERTIFICATE----- diff --git a/tests/auto/qnetworkreply/certs/fluke.key b/tests/auto/qnetworkreply/certs/fluke.key new file mode 100644 index 0000000..9d1664d --- /dev/null +++ b/tests/auto/qnetworkreply/certs/fluke.key @@ -0,0 +1,15 @@ +-----BEGIN RSA PRIVATE KEY----- +MIICXAIBAAKBgQCnyKBKxBkFG2a6MuLS8RxvF4LkOS4BUZDbBDQyESHCDW9Z2FOQ +VD+Dj6nTs9XuGpuArsMlyV6lr0tgBaqg0ZEBH8oEg+NYHJkyRYRwclgDmEpji0H1 +CEnSkQJga+Rk/t2gqnQI6TRMkV8SPTdNVCytf1uYYDYCjDv2RfMnapuUnQIDAQAB +AoGANFzLkanTeSGNFM0uttBipFT9F4a00dqHz6JnO7zXAT26I5r8sU1pqQBb6uLz +/+Qz5Zwk8RUAQcsMRgJetuPQUb0JZjF6Duv24hNazqXBCu7AZzUenjafwmKC/8ri +KpX3fTwqzfzi//FKGgbXQ80yykSSliDL3kn/drATxsLCgQECQQDXhEFWLJ0vVZ1s +1Ekf+3NITE+DR16X+LQ4W6vyEHAjTbaNWtcTKdAWLA2l6N4WAAPYSi6awm+zMxx4 +VomVTsjdAkEAx0z+e7natLeFcrrq8pbU+wa6SAP1VfhQWKitxL1e7u/QO90NCpxE +oQYKzMkmmpOOFjQwEMAy1dvFMbm4LHlewQJAC/ksDBaUcQHHqjktCtrUb8rVjAyW +A8lscckeB2fEYyG5J6dJVaY4ClNOOs5yMDS2Afk1F6H/xKvtQ/5CzInA/QJATDub +K+BPU8jO9q+gpuIi3VIZdupssVGmCgObVCHLakG4uO04y9IyPhV9lA9tALtoIf4c +VIvv5fWGXBrZ48kZAQJBAJmVCdzQxd9LZI5vxijUCj5EI4e+x5DRqVUvyP8KCZrC +AiNyoDP85T+hBZaSXK3aYGpVwelyj3bvo1GrTNwNWLw= +-----END RSA PRIVATE KEY----- diff --git a/tests/auto/qnetworkreply/certs/qt-test-server-cacert.pem b/tests/auto/qnetworkreply/certs/qt-test-server-cacert.pem new file mode 100644 index 0000000..25bd404 --- /dev/null +++ b/tests/auto/qnetworkreply/certs/qt-test-server-cacert.pem @@ -0,0 +1,17 @@ +-----BEGIN CERTIFICATE----- +MIICrTCCAhYCCQCdDn5rci6VDjANBgkqhkiG9w0BAQQFADCBmjEOMAwGA1UEChMF +Tm9raWExFDASBgNVBAsTC1F0IFNvZnR3YXJlMSIwIAYJKoZIhvcNAQkBFhNub2Jv +ZHlAbm9kb21haW4ub3JnMQ0wCwYDVQQHEwRPc2xvMQ0wCwYDVQQIEwRPc2xvMQsw +CQYDVQQGEwJOTzEjMCEGA1UEAxMacXQtdGVzdC1zZXJ2ZXIucXQtdGVzdC1uZXQw +HhcNMDkwNzEwMDc0MTIzWhcNMTkwNzA4MDc0MTIzWjCBmjEOMAwGA1UEChMFTm9r +aWExFDASBgNVBAsTC1F0IFNvZnR3YXJlMSIwIAYJKoZIhvcNAQkBFhNub2JvZHlA +bm9kb21haW4ub3JnMQ0wCwYDVQQHEwRPc2xvMQ0wCwYDVQQIEwRPc2xvMQswCQYD +VQQGEwJOTzEjMCEGA1UEAxMacXQtdGVzdC1zZXJ2ZXIucXQtdGVzdC1uZXQwgZ8w +DQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBAM2q22/WNMmn8cC+5EEYGeICySLmp9W6 +Ay6eKHr0Xxp3X3epETuPfvAuxp7rOtkS18EMUegkUj8jw0IMEcbyHKFC/rTCaYOt +93CxGBXMIChiMPAsFeYzGa/D6xzAkfcRaJRQ+Ek3CDLXPnXfo7xpABXezYcPXAJr +gsgBfWrwHdxzAgMBAAEwDQYJKoZIhvcNAQEEBQADgYEAy7YOLCZABQy2Ygkchq1I ++TUpvMn+gLwAyW8TNErM1V4lNY2+K78RawzKx3SqM97ymCy4TD45EA3A2gmi32NI +xSKBNjFyzngUqsXBdcSasALiowlZCiJrGwlGX5qCkBlxXvJeUEbuJLPYVl5FBjXZ +6o00K4cSPCqtqUez7WSmDZU= +-----END CERTIFICATE----- diff --git a/tests/auto/qnetworkreply/test/test.pro b/tests/auto/qnetworkreply/test/test.pro index e0df503..7bf3852 100644 --- a/tests/auto/qnetworkreply/test/test.pro +++ b/tests/auto/qnetworkreply/test/test.pro @@ -26,6 +26,10 @@ symbian:{ addFiles.path = . DEPLOYMENT += addFiles + certFiles.sources = ../certs + certFiles.path = . + DEPLOYMENT += certFiles + # Symbian toolchain does not support correct include semantics INCPATH+=..\..\..\..\include\QtNetwork\private # bigfile test case requires more heap diff --git a/tests/auto/qnetworkreply/tst_qnetworkreply.cpp b/tests/auto/qnetworkreply/tst_qnetworkreply.cpp index 5441b09..578ab29 100644 --- a/tests/auto/qnetworkreply/tst_qnetworkreply.cpp +++ b/tests/auto/qnetworkreply/tst_qnetworkreply.cpp @@ -69,9 +69,6 @@ #include "private/qnetworkaccessmanager_p.h" #ifdef Q_OS_SYMBIAN -// In Symbian OS test data is located in applications private dir -// Current path (C:\private\<UID>) contains only ascii chars -//#define SRCDIR QDir::currentPath() #define SRCDIR "." #endif @@ -3902,7 +3899,13 @@ void tst_QNetworkReply::httpConnectionCount() break; } +#ifdef Q_OS_SYMBIAN + // see in qhttpnetworkconnection.cpp + // hardcoded defaultChannelCount = 3 + QCOMPARE(pendingConnectionCount, 3); +#else QCOMPARE(pendingConnectionCount, 6); +#endif } #ifndef QT_NO_OPENSSL @@ -3914,7 +3917,7 @@ void tst_QNetworkReply::ignoreSslErrorsList_data() QList<QSslError> expectedSslErrors; // apparently, because of some weird behaviour of SRCDIR, the file name below needs to start with a slash - QList<QSslCertificate> certs = QSslCertificate::fromPath(QLatin1String(SRCDIR "/../qsslsocket/certs/qt-test-server-cacert.pem")); + QList<QSslCertificate> certs = QSslCertificate::fromPath(QLatin1String(SRCDIR "/certs/qt-test-server-cacert.pem")); QSslError rightError(QSslError::SelfSignedCertificate, certs.at(0)); QSslError wrongError(QSslError::SelfSignedCertificate); diff --git a/tests/auto/qpixmap/qpixmap.pro b/tests/auto/qpixmap/qpixmap.pro index 31d6eaa..a3577bd 100644 --- a/tests/auto/qpixmap/qpixmap.pro +++ b/tests/auto/qpixmap/qpixmap.pro @@ -2,16 +2,23 @@ load(qttest_p4) SOURCES += tst_qpixmap.cpp contains(QT_CONFIG, qt3support): QT += qt3support wince*|symbian*: { - task31722_0.sources = convertFromImage/task31722_0/* + + task31722_0.sources = convertFromImage/task31722_0/*.png task31722_0.path = convertFromImage/task31722_0 - task31722_1.sources = convertFromImage/task31722_1/* + + task31722_1.sources = convertFromImage/task31722_1/*.png task31722_1.path = convertFromImage/task31722_1 - DEPLOYMENT += task31722_0 task31722_1 + + icons.sources = convertFromToHICON/* + icons.path = convertFromToHICON + + DEPLOYMENT += task31722_0 task31722_1 icons + DEPLOYMENT_PLUGIN += qico } wince*: { DEFINES += SRCDIR=\\\".\\\" -} symbian*: { +} else:symbian* { DEPLOYMENT_PLUGIN += qmng LIBS += -lfbscli.dll -lbitgdi.dll -lgdi.dll contains(QT_CONFIG, openvg) { diff --git a/tests/auto/qpixmap/tst_qpixmap.cpp b/tests/auto/qpixmap/tst_qpixmap.cpp index 1bfddc1..2568b94 100644 --- a/tests/auto/qpixmap/tst_qpixmap.cpp +++ b/tests/auto/qpixmap/tst_qpixmap.cpp @@ -67,6 +67,9 @@ #include <bitdev.h> #endif +#ifdef Q_WS_X11 +#include <QX11Info> +#endif //TESTED_CLASS= //TESTED_FILES= @@ -175,6 +178,12 @@ static bool lenientCompare(const QPixmap &actual, const QPixmap &expected) int size = actual.width() * actual.height(); + int threshold = 2; +#ifdef Q_WS_X11 + if (QX11Info::appDepth() == 16) + threshold = 10; +#endif + QRgb *a = (QRgb *)actualImage.bits(); QRgb *e = (QRgb *)expectedImage.bits(); for (int i = 0; i < size; ++i) { @@ -183,11 +192,11 @@ static bool lenientCompare(const QPixmap &actual, const QPixmap &expected) bool result = true; - if (qAbs(ca.red() - ce.red()) > 2) + if (qAbs(ca.red() - ce.red()) > threshold) result = false; - if (qAbs(ca.green() - ce.green()) > 2) + if (qAbs(ca.green() - ce.green()) > threshold) result = false; - if (qAbs(ca.blue() - ce.blue()) > 2) + if (qAbs(ca.blue() - ce.blue()) > threshold) result = false; if (!result) @@ -293,15 +302,23 @@ void tst_QPixmap::setAlphaChannel() void tst_QPixmap::fromImage_data() { + bool is16bit = false; +#ifdef Q_WS_X11 + if (QX11Info::appDepth() == 16) + is16bit = true; +#endif + QTest::addColumn<QImage::Format>("format"); QTest::newRow("Format_Mono") << QImage::Format_Mono; QTest::newRow("Format_MonoLSB") << QImage::Format_MonoLSB; // QTest::newRow("Format_Indexed8") << QImage::Format_Indexed8; - QTest::newRow("Format_RGB32") << QImage::Format_RGB32; + if (!is16bit) + QTest::newRow("Format_RGB32") << QImage::Format_RGB32; QTest::newRow("Format_ARGB32") << QImage::Format_ARGB32; QTest::newRow("Format_ARGB32_Premultiplied") << QImage::Format_ARGB32_Premultiplied; - QTest::newRow("Format_RGB16") << QImage::Format_RGB16; + if (!is16bit) + QTest::newRow("Format_RGB16") << QImage::Format_RGB16; } void tst_QPixmap::fromImage() @@ -986,7 +1003,7 @@ static void compareImages(const QImage &image1, const QImage &image2) QRgb p1 = image1.pixel(x, y); QRgb p2 = image2.pixel(x, y); - bool pixelMatches = + bool pixelMatches = qAbs(qRed(p1) - qRed(p2)) <= fuzz && qAbs(qGreen(p1) - qGreen(p2)) <= fuzz && qAbs(qBlue(p1) - qBlue(p2)) <= fuzz @@ -1017,6 +1034,10 @@ void tst_QPixmap::toWinHICON_data() void tst_QPixmap::toWinHICON() { +#ifdef Q_OS_WINCE + QSKIP("Test shall be enabled for Windows CE shortly.", SkipAll); +#endif + QFETCH(int, width); QFETCH(int, height); QFETCH(QString, image); @@ -1057,6 +1078,10 @@ void tst_QPixmap::fromWinHICON_data() void tst_QPixmap::fromWinHICON() { +#ifdef Q_OS_WINCE + QSKIP("Test shall be enabled for Windows CE shortly.", SkipAll); + +#else QFETCH(int, width); QFETCH(int, height); QFETCH(QString, image); @@ -1073,6 +1098,7 @@ void tst_QPixmap::fromWinHICON() // QVERIFY(imageFromHICON == imageFromFile); compareImages(imageFromHICON, imageFromFile); +#endif } #endif // Q_WS_WIN diff --git a/tests/auto/qprinterinfo/tst_qprinterinfo.cpp b/tests/auto/qprinterinfo/tst_qprinterinfo.cpp index 2fa7515..7352524 100644 --- a/tests/auto/qprinterinfo/tst_qprinterinfo.cpp +++ b/tests/auto/qprinterinfo/tst_qprinterinfo.cpp @@ -134,7 +134,7 @@ QStringList tst_QPrinterInfo::getPrintersFromSystem() QString output = getOutputFromCommand(command); QStringList list = output.split(QChar::fromLatin1('\n')); - QRegExp reg("^[Pp]rinter ([a-zA-Z0-9_]+)"); + QRegExp reg("^[Pp]rinter ([.a-zA-Z0-9_-]+)"); for (int c = 0; c < list.size(); ++c) { if (reg.indexIn(list[c]) >= 0) { QString printer = reg.cap(1); diff --git a/tests/auto/qscriptengine/tst_qscriptengine.cpp b/tests/auto/qscriptengine/tst_qscriptengine.cpp index 183aa3f..25ee00f 100644 --- a/tests/auto/qscriptengine/tst_qscriptengine.cpp +++ b/tests/auto/qscriptengine/tst_qscriptengine.cpp @@ -48,6 +48,7 @@ #include <qgraphicsitem.h> #include <qstandarditemmodel.h> #include <QtCore/qnumeric.h> +#include <stdlib.h> Q_DECLARE_METATYPE(QList<int>) Q_DECLARE_METATYPE(QObjectList) @@ -60,6 +61,22 @@ Q_DECLARE_METATYPE(QObjectList) # define TOSTRING(x) STRINGIFY(x) # define SRCDIR "C:/Private/" TOSTRING(SYMBIAN_SRCDIR_UID) #endif + +// The JavaScriptCore GC marks the C stack. To try to ensure that there is +// no JSObject* left in stack memory by the compiler, we call this function +// to zap some bytes of memory before calling collectGarbage(). +static void zapSomeStack() +{ + char buf[4096]; + memset(buf, 0, sizeof(buf)); +} + +static void collectGarbage_helper(QScriptEngine &eng) +{ + zapSomeStack(); + eng.collectGarbage(); +} + class tst_QScriptEngine : public QObject { Q_OBJECT @@ -825,7 +842,7 @@ void tst_QScriptEngine::newQMetaObject() // verify that AutoOwnership is in effect instance = QScriptValue(); - eng.collectGarbage(); + collectGarbage_helper(eng); QVERIFY(!qpointer1); QVERIFY(qpointer2); @@ -835,7 +852,7 @@ void tst_QScriptEngine::newQMetaObject() QVERIFY(instance3.toQObject() == 0); // was child of instance QVERIFY(instance2.toQObject() != 0); instance2 = QScriptValue(); - eng.collectGarbage(); + collectGarbage_helper(eng); QVERIFY(instance2.toQObject() == 0); // with custom constructor @@ -922,14 +939,14 @@ void tst_QScriptEngine::getSetGlobalObject() QCOMPARE(eng.globalObject().toString(), QString::fromLatin1("[object Object]")); glob = QScriptValue(); // kill reference to old global object - eng.collectGarbage(); + collectGarbage_helper(eng); obj = eng.newObject(); eng.setGlobalObject(obj); QVERIFY(eng.globalObject().strictlyEquals(obj)); QVERIFY(eng.currentContext()->thisObject().strictlyEquals(obj)); QVERIFY(eng.currentContext()->activationObject().strictlyEquals(obj)); - eng.collectGarbage(); + collectGarbage_helper(eng); QVERIFY(eng.globalObject().strictlyEquals(obj)); QVERIFY(eng.currentContext()->thisObject().strictlyEquals(obj)); QVERIFY(eng.currentContext()->activationObject().strictlyEquals(obj)); @@ -1632,7 +1649,6 @@ void tst_QScriptEngine::errorMessage_QT679() engine.globalObject().setProperty("foo", 15); QScriptValue error = engine.evaluate("'hello world';\nfoo.bar.blah"); QVERIFY(error.isError()); - QEXPECT_FAIL("", "Task QT-679: the error message always contains the first line of the script, even if the error was on a different line", Continue); QCOMPARE(error.toString(), QString::fromLatin1("TypeError: Result of expression 'foo.bar' [undefined] is not an object.")); } @@ -2342,11 +2358,8 @@ void tst_QScriptEngine::collectGarbage() a = eng.newObject(); QPointer<QObject> ptr = new QObject(); QVERIFY(ptr != 0); - { - QScriptValue v = eng.newQObject(ptr, QScriptEngine::ScriptOwnership); - } - eng.collectGarbage(); - QEXPECT_FAIL("","collectGarbage not working", Continue); + (void)eng.newQObject(ptr, QScriptEngine::ScriptOwnership); + collectGarbage_helper(eng); QVERIFY(ptr == 0); } diff --git a/tests/auto/qscriptengineagent/tst_qscriptengineagent.cpp b/tests/auto/qscriptengineagent/tst_qscriptengineagent.cpp index 82bca8f..283e489 100644 --- a/tests/auto/qscriptengineagent/tst_qscriptengineagent.cpp +++ b/tests/auto/qscriptengineagent/tst_qscriptengineagent.cpp @@ -1193,10 +1193,15 @@ void tst_QScriptEngineAgent::positionChange_1() QCOMPARE(spy->at(0).columnNumber, 1); } - { + QStringList lineTerminators; + lineTerminators << "\n" << "\r" << "\n\r" << "\r\n"; + for (int i = 0; i < lineTerminators.size(); ++i) { spy->clear(); int lineNumber = 456; - eng.evaluate("1 + 2; 3 + 4;\n5 + 6", "foo.qs", lineNumber); + QString code = "1 + 2; 3 + 4;"; + code.append(lineTerminators.at(i)); + code.append("5 + 6"); + eng.evaluate(code, "foo.qs", lineNumber); QCOMPARE(spy->count(), 3); // 1 + 2 diff --git a/tests/auto/qscriptjstestsuite/tst_qscriptjstestsuite.cpp b/tests/auto/qscriptjstestsuite/tst_qscriptjstestsuite.cpp index 94f08d9..4f4c547 100644 --- a/tests/auto/qscriptjstestsuite/tst_qscriptjstestsuite.cpp +++ b/tests/auto/qscriptjstestsuite/tst_qscriptjstestsuite.cpp @@ -649,6 +649,8 @@ tst_Suite::tst_Suite() addFileExclusion("regress-322135-04.js", "takes forever"); addFileExclusion("ecma_3/RegExp/regress-375715-04.js", "bug"); + addFileExclusion("ecma_3/RegExp/regress-289669.js", "Can fail due to relying on wall-clock time"); + // Failures due to switch to JSC as back-end addExpectedFailure("ecma/Array/15.4.3.1-2.js", "var props = ''; for ( p in Array ) { props += p } props", willFixInNextReleaseMessage); addExpectedFailure("ecma/Boolean/15.6.3.1-1.js", "var str='';for ( p in Boolean ) { str += p } str;", willFixInNextReleaseMessage); diff --git a/tests/auto/qsharedmemory/tst_qsharedmemory.cpp b/tests/auto/qsharedmemory/tst_qsharedmemory.cpp index c4ff76c..db86c06 100644 --- a/tests/auto/qsharedmemory/tst_qsharedmemory.cpp +++ b/tests/auto/qsharedmemory/tst_qsharedmemory.cpp @@ -773,7 +773,7 @@ void tst_QSharedMemory::simpleProcessProducerConsumer() delete consumers.takeFirst(); } QCOMPARE(consumerFailed, false); - QCOMPARE(failedProcesses, unsigned int (0)); + QCOMPARE(failedProcesses, (unsigned int)(0)); } QTEST_MAIN(tst_QSharedMemory) diff --git a/tests/auto/qsharedpointer/tst_qsharedpointer.cpp b/tests/auto/qsharedpointer/tst_qsharedpointer.cpp index fa63c4b..58eaacb 100644 --- a/tests/auto/qsharedpointer/tst_qsharedpointer.cpp +++ b/tests/auto/qsharedpointer/tst_qsharedpointer.cpp @@ -308,7 +308,7 @@ extern int forwardDeclaredDestructorRunCount; void tst_QSharedPointer::forwardDeclaration1() { -#if defined(Q_CC_SUN) +#if defined(Q_CC_SUN) || defined(Q_CC_WINSCW) || defined(Q_CC_RVCT) QSKIP("This type of forward declaration is not valid with this compiler", SkipAll); #else externalForwardDeclaration(); @@ -1448,10 +1448,11 @@ void tst_QSharedPointer::threadStressTest_data() QTest::newRow("1+1") << 1 << 1; QTest::newRow("2+10") << 2 << 10; +#ifndef Q_OS_WINCE + // Windows CE cannot run this many threads QTest::newRow("5+10") << 5 << 10; QTest::newRow("5+30") << 5 << 30; -#ifndef Q_OS_WINCE QTest::newRow("100+100") << 100 << 100; #endif } diff --git a/tests/auto/qtableview/tst_qtableview.cpp b/tests/auto/qtableview/tst_qtableview.cpp index 71218a3..09e1e87 100644 --- a/tests/auto/qtableview/tst_qtableview.cpp +++ b/tests/auto/qtableview/tst_qtableview.cpp @@ -378,7 +378,6 @@ public: } bool checkSignalOrder; - using QTableView::wheelEvent; public slots: void currentChanged(QModelIndex , QModelIndex ) { hasCurrentChanged++; @@ -3202,9 +3201,17 @@ void tst_QTableView::mouseWheel_data() QTest::newRow("scroll down per item") << int(QAbstractItemView::ScrollPerItem) << -120 << 10 + qApp->wheelScrollLines() << 10 + qApp->wheelScrollLines(); +#ifdef Q_WS_MAC + // On Mac, we always scroll one pixel per 120 delta (rather than multiplying with + // singleStep) since wheel events are accelerated by the OS. + QTest::newRow("scroll down per pixel") + << int(QAbstractItemView::ScrollPerPixel) << -120 + << 10 + qApp->wheelScrollLines() << 10 + qApp->wheelScrollLines(); +#else QTest::newRow("scroll down per pixel") << int(QAbstractItemView::ScrollPerPixel) << -120 << 10 + qApp->wheelScrollLines() * 89 << 10 + qApp->wheelScrollLines() * 28; +#endif } void tst_QTableView::mouseWheel() @@ -3222,6 +3229,7 @@ void tst_QTableView::mouseWheel() for (int c = 0; c < 100; ++c) view.setColumnWidth(c, 100); view.show(); + QTest::qWaitForWindowShown(&view); view.setModel(&model); @@ -3230,12 +3238,12 @@ void tst_QTableView::mouseWheel() view.horizontalScrollBar()->setValue(10); view.verticalScrollBar()->setValue(10); - QPoint pos(100,100); + QPoint pos = view.viewport()->geometry().center(); QWheelEvent verticalEvent(pos, delta, 0, 0, Qt::Vertical); QWheelEvent horizontalEvent(pos, delta, 0, 0, Qt::Horizontal); - view.wheelEvent(&horizontalEvent); + QApplication::sendEvent(view.viewport(), &horizontalEvent); QVERIFY(qAbs(view.horizontalScrollBar()->value() - horizontalPositon) < 10); - view.wheelEvent(&verticalEvent); + QApplication::sendEvent(view.viewport(), &verticalEvent); QVERIFY(qAbs(view.verticalScrollBar()->value() - verticalPosition) < 10); } diff --git a/tests/auto/qtreeview/tst_qtreeview.cpp b/tests/auto/qtreeview/tst_qtreeview.cpp index 112bcc8..91b2cc5 100644 --- a/tests/auto/qtreeview/tst_qtreeview.cpp +++ b/tests/auto/qtreeview/tst_qtreeview.cpp @@ -3113,7 +3113,7 @@ void tst_QTreeView::task224091_appendColumns() treeView->show(); treeView->resize(50,50); - QTest::qWait(50); + QTest::qWaitForWindowShown(treeView); qApp->processEvents(); QList<QStandardItem *> projlist; @@ -3125,7 +3125,7 @@ void tst_QTreeView::task224091_appendColumns() QTest::qWait(50); qApp->processEvents(); - QVERIFY(treeView->verticalScrollBar()->isVisible()); + QTRY_VERIFY(treeView->verticalScrollBar()->isVisible()); delete treeView; delete model; diff --git a/tests/auto/qwidget/qwidget.pro b/tests/auto/qwidget/qwidget.pro index def28f5..61db2ee 100644 --- a/tests/auto/qwidget/qwidget.pro +++ b/tests/auto/qwidget/qwidget.pro @@ -10,8 +10,8 @@ aix-g++*:QMAKE_CXXFLAGS+=-fpermissive CONFIG += x11inc mac { -LIBS += -framework Security -framework AppKit -OBJECTIVE_SOURCES += tst_qwidget_mac_helpers.mm + LIBS += -framework Security -framework AppKit -framework Carbon + OBJECTIVE_SOURCES += tst_qwidget_mac_helpers.mm } symbian { diff --git a/tests/auto/qwidget/tst_qwidget.cpp b/tests/auto/qwidget/tst_qwidget.cpp index 019887d..b0a26c2 100644 --- a/tests/auto/qwidget/tst_qwidget.cpp +++ b/tests/auto/qwidget/tst_qwidget.cpp @@ -355,6 +355,7 @@ private slots: void maskedUpdate(); #if defined(Q_WS_WIN) || defined(Q_WS_X11) || defined(Q_WS_QWS) void syntheticEnterLeave(); + void taskQTBUG_4055_sendSyntheticEnterLeave(); #endif void windowFlags(); void initialPosForDontShowOnScreenWidgets(); @@ -3117,7 +3118,7 @@ void tst_QWidget::saveRestoreGeometry() widget.resize(size); widget.show(); QTest::qWaitForWindowShown(&widget); - QTest::qWait(200); + QTest::qWait(500); QTRY_COMPARE(widget.geometry().size(), size); QRect geom; @@ -3127,7 +3128,7 @@ void tst_QWidget::saveRestoreGeometry() geom = widget.geometry(); widget.setWindowState(widget.windowState() | Qt::WindowFullScreen); QTRY_VERIFY((widget.windowState() & Qt::WindowFullScreen)); - QTest::qWait(200); + QTest::qWait(500); QVERIFY(widget.restoreGeometry(savedGeometry)); QTest::qWait(120); QTRY_VERIFY(!(widget.windowState() & Qt::WindowFullScreen)); @@ -3137,55 +3138,55 @@ void tst_QWidget::saveRestoreGeometry() widget.setWindowState(widget.windowState() | Qt::WindowFullScreen); QTest::qWait(120); QTRY_VERIFY((widget.windowState() & Qt::WindowFullScreen)); - QTest::qWait(200); + QTest::qWait(500); savedGeometry = widget.saveGeometry(); geom = widget.geometry(); widget.setWindowState(widget.windowState() ^ Qt::WindowFullScreen); - QTest::qWait(20); + QTest::qWait(120); QTRY_VERIFY(!(widget.windowState() & Qt::WindowFullScreen)); - QTest::qWait(200); + QTest::qWait(400); QVERIFY(widget.restoreGeometry(savedGeometry)); - QTest::qWait(20); + QTest::qWait(120); QTRY_VERIFY((widget.windowState() & Qt::WindowFullScreen)); QTRY_COMPARE(widget.geometry(), geom); QVERIFY((widget.windowState() & Qt::WindowFullScreen)); widget.setWindowState(widget.windowState() ^ Qt::WindowFullScreen); - QTest::qWait(20); + QTest::qWait(120); QTRY_VERIFY(!(widget.windowState() & Qt::WindowFullScreen)); - QTest::qWait(20); + QTest::qWait(120); //Restore from Maximised widget.move(position); widget.resize(size); - QTest::qWait(20); + QTest::qWait(10); QTRY_COMPARE(widget.size(), size); - QTest::qWait(200); + QTest::qWait(500); savedGeometry = widget.saveGeometry(); geom = widget.geometry(); widget.setWindowState(widget.windowState() | Qt::WindowMaximized); - QTest::qWait(20); + QTest::qWait(120); QTRY_VERIFY((widget.windowState() & Qt::WindowMaximized)); QTRY_VERIFY(widget.geometry() != geom); - QTest::qWait(200); + QTest::qWait(500); QVERIFY(widget.restoreGeometry(savedGeometry)); - QTest::qWait(20); + QTest::qWait(120); QTRY_COMPARE(widget.geometry(), geom); QVERIFY(!(widget.windowState() & Qt::WindowMaximized)); //Restore to maximised widget.setWindowState(widget.windowState() | Qt::WindowMaximized); - QTest::qWait(20); + QTest::qWait(120); QTRY_VERIFY((widget.windowState() & Qt::WindowMaximized)); - QTest::qWait(200); + QTest::qWait(500); geom = widget.geometry(); savedGeometry = widget.saveGeometry(); widget.setWindowState(widget.windowState() ^ Qt::WindowMaximized); - QTest::qWait(20); + QTest::qWait(120); QTRY_VERIFY(!(widget.windowState() & Qt::WindowMaximized)); - QTest::qWait(200); + QTest::qWait(500); QVERIFY(widget.restoreGeometry(savedGeometry)); - QTest::qWait(20); + QTest::qWait(120); QTRY_VERIFY((widget.windowState() & Qt::WindowMaximized)); QTRY_COMPARE(widget.geometry(), geom); } @@ -5497,10 +5498,11 @@ void tst_QWidget::multipleToplevelFocusCheck() QTest::qWait(100); - w1.activateWindow(); QApplication::setActiveWindow(&w1); + w1.activateWindow(); QApplication::processEvents(); QTRY_COMPARE(QApplication::activeWindow(), static_cast<QWidget *>(&w1)); + QTest::qWait(50); QTest::mouseDClick(&w1, Qt::LeftButton); QTRY_COMPARE(QApplication::focusWidget(), static_cast<QWidget *>(w1.edit)); @@ -6506,7 +6508,7 @@ void tst_QWidget::renderInvisible() dummyFocusWidget.show(); QTest::qWaitForWindowShown(&dummyFocusWidget); qApp->processEvents(); - QTest::qWait(100); + QTest::qWait(120); // Create normal reference image. const QSize calendarSize = calendar->size(); @@ -6521,6 +6523,7 @@ void tst_QWidget::renderInvisible() const QSize calendarSizeResized = calendar->size() + QSize(50, 50); calendar->resize(calendarSizeResized); qApp->processEvents(); + QTest::qWait(30); QImage referenceImageResized(calendarSizeResized, QImage::Format_ARGB32); calendar->render(&referenceImageResized); #ifdef RENDER_DEBUG @@ -6531,6 +6534,7 @@ void tst_QWidget::renderInvisible() // Explicitly hide the calendar. calendar->hide(); qApp->processEvents(); + QTest::qWait(30); workaroundPaletteIssue(calendar); { // Make sure we get the same image when the calendar is explicitly hidden. @@ -6561,6 +6565,7 @@ void tst_QWidget::renderInvisible() calendar->hide(); qApp->processEvents(); + QTest::qWait(30); { // Calendar explicitly hidden. QImage testImage(calendarSize, QImage::Format_ARGB32); @@ -6628,6 +6633,7 @@ void tst_QWidget::renderInvisible() // Navigation bar isn't explicitly hidden anymore. navigationBar->show(); qApp->processEvents(); + QTest::qWait(30); QVERIFY(!calendar->isVisible()); // Now, completely mess up the layout. This will trigger an update on the layout @@ -7465,10 +7471,11 @@ void tst_QWidget::updateWhileMinimized() QTest::qWaitForWindowShown(&widget); QApplication::processEvents(); QTRY_VERIFY(widget.numPaintEvents > 0); + QTest::qWait(50); // Minimize window. widget.showMinimized(); - QTest::qWait(30); + QTest::qWait(70); widget.reset(); @@ -8046,13 +8053,8 @@ void tst_QWidget::doubleRepaint() QTRY_COMPARE(widget.numPaintEvents, expectedRepaints); widget.numPaintEvents = 0; -#ifndef Q_OS_WINCE //still no proper minimizing // Minmize: Should not trigger a repaint. widget.showMinimized(); -#else - // Hide: Should not trigger a repaint. - widget.hide(); -#endif QTest::qWait(10); QCOMPARE(widget.numPaintEvents, 0); widget.numPaintEvents = 0; @@ -8061,12 +8063,7 @@ void tst_QWidget::doubleRepaint() widget.showNormal(); QTest::qWaitForWindowShown(&widget); QTest::qWait(10); -#ifndef Q_OS_WINCE QCOMPARE(widget.numPaintEvents, 0); -#else - // We called hide(), and then it'll get repainted once it's shown again. - QCOMPARE(widget.numPaintEvents, 1); -#endif } #ifndef Q_WS_MAC @@ -8179,7 +8176,7 @@ public: static bool firstTime = true; if (firstTime) - QTimer::singleShot(100, this, SLOT(resizeMe())); + QTimer::singleShot(70, this, SLOT(resizeMe())); firstTime = false; } @@ -8196,7 +8193,7 @@ void tst_QWidget::moveInResizeEvent() testWidget.setGeometry(50, 50, 200, 200); testWidget.show(); QTest::qWaitForWindowShown(&testWidget); - QTest::qWait(10); + QTest::qWait(120); QRect expectedGeometry(100,100, 100, 100); QTRY_COMPARE(testWidget.geometry(), expectedGeometry); @@ -8683,7 +8680,7 @@ void tst_QWidget::setClearAndResizeMask() QTRY_COMPARE(child.numPaintEvents, 1); #else // and ensure that we don't get any updates at all. - QCOMPARE(child.numPaintEvents, 0); + QTRY_COMPARE(child.numPaintEvents, 0); #endif QCOMPARE(topLevel.numPaintEvents, 0); @@ -8714,15 +8711,16 @@ void tst_QWidget::setClearAndResizeMask() // Disable the size grip on the Mac; otherwise it'll be included when grabbing the window. resizeParent.setFixedSize(resizeParent.size()); resizeChild.show(); + QTest::qWait(30); resizeChild.paintedRegion = QRegion(); QTimer::singleShot(100, &resizeChild, SLOT(shrinkMask())); QTest::qWait(200); #ifdef Q_WS_MAC // Mac always issues a full update when calling setMask, and we cannot force it to not do so. - QCOMPARE(resizeChild.paintedRegion, resizeChild.mask()); + QTRY_COMPARE(resizeChild.paintedRegion, resizeChild.mask()); #else - QCOMPARE(resizeChild.paintedRegion, QRegion()); + QTRY_COMPARE(resizeChild.paintedRegion, QRegion()); #endif resizeChild.paintedRegion = QRegion(); @@ -8731,9 +8729,9 @@ void tst_QWidget::setClearAndResizeMask() QTest::qWait(100); #ifdef Q_WS_MAC // Mac always issues a full update when calling setMask, and we cannot force it to not do so. - QCOMPARE(resizeChild.paintedRegion, resizeChild.mask()); + QTRY_COMPARE(resizeChild.paintedRegion, resizeChild.mask()); #else - QCOMPARE(resizeChild.paintedRegion, resizeChild.mask() - oldMask); + QTRY_COMPARE(resizeChild.paintedRegion, resizeChild.mask() - oldMask); #endif } @@ -8897,6 +8895,8 @@ void tst_QWidget::syntheticEnterLeave() int numLeaveEvents; }; + QCursor::setPos(QPoint(0,0)); + MyWidget window; window.setWindowFlags(Qt::WindowStaysOnTopHint); window.resize(200, 200); @@ -8987,6 +8987,89 @@ void tst_QWidget::syntheticEnterLeave() QCOMPARE(window.numEnterEvents, 0); QCOMPARE(child1->numEnterEvents, 1); } + +void tst_QWidget::taskQTBUG_4055_sendSyntheticEnterLeave() +{ + class SELParent : public QWidget + { + public: + SELParent(QWidget *parent = 0): QWidget(parent) { } + + void mousePressEvent(QMouseEvent *) { child->show(); } + QWidget *child; + }; + + class SELChild : public QWidget + { + public: + SELChild(QWidget *parent = 0) : QWidget(parent), numEnterEvents(0), numMouseMoveEvents(0) {} + void enterEvent(QEvent *) { ++numEnterEvents; } + void mouseMoveEvent(QMouseEvent *event) + { + QCOMPARE(event->button(), Qt::NoButton); + QCOMPARE(event->buttons(), Qt::MouseButtons(Qt::NoButton)); + ++numMouseMoveEvents; + } + void reset() { numEnterEvents = numMouseMoveEvents = 0; } + int numEnterEvents, numMouseMoveEvents; + }; + + QCursor::setPos(QPoint(0,0)); + + SELParent parent; + parent.resize(200, 200); + SELChild child(&parent); + child.resize(200, 200); + parent.show(); + #ifdef Q_WS_X11 + qt_x11_wait_for_window_manager(&parent); + #endif + QTest::qWait(100); + + QCursor::setPos(child.mapToGlobal(QPoint(100, 100))); + QTest::qWait(100); + // Make sure the cursor has entered the child. + QVERIFY(child.numEnterEvents > 0); + + child.hide(); + child.reset(); + child.show(); + + // Make sure the child gets enter event and no mouse move event. + QCOMPARE(child.numEnterEvents, 1); + QCOMPARE(child.numMouseMoveEvents, 0); + + child.hide(); + child.reset(); + child.setMouseTracking(true); + child.show(); + + // Make sure the child gets enter event and mouse move event. + // Note that we verify event->button() and event->buttons() + // in SELChild::mouseMoveEvent(). + QCOMPARE(child.numEnterEvents, 1); + QCOMPARE(child.numMouseMoveEvents, 1); + + // Sending synthetic enter/leave trough the parent's mousePressEvent handler. + parent.child = &child; + + child.hide(); + child.reset(); + QTest::mouseClick(&parent, Qt::LeftButton); + + // Make sure the child gets enter event and one mouse move event. + QCOMPARE(child.numEnterEvents, 1); + QCOMPARE(child.numMouseMoveEvents, 1); + + child.hide(); + child.reset(); + child.setMouseTracking(false); + QTest::mouseClick(&parent, Qt::LeftButton); + + // Make sure the child gets enter event and no mouse move event. + QCOMPARE(child.numEnterEvents, 1); + QCOMPARE(child.numMouseMoveEvents, 0); + } #endif void tst_QWidget::windowFlags() @@ -9118,6 +9201,7 @@ void tst_QWidget::focusWidget_task254563() void tst_QWidget::destroyBackingStore() { +#ifdef QT_BUILD_INTERNAL UpdateWidget w; w.reset(); w.show(); @@ -9142,10 +9226,14 @@ void tst_QWidget::destroyBackingStore() w.update(); QApplication::processEvents(); QCOMPARE(w.numPaintEvents, 2); +#endif } void tst_QWidget::rectOutsideCoordinatesLimit_task144779() { +#ifdef Q_OS_WINCE_WM + QSKIP( "Tables of 5000 elements do not make sense on Windows Mobile.", SkipAll); +#endif QApplication::setOverrideCursor(Qt::BlankCursor); //keep the cursor out of screen grabs QWidget main(0,Qt::FramelessWindowHint); //don't get confused by the size of the window frame QPalette palette; diff --git a/tests/auto/qwindowsurface/tst_qwindowsurface.cpp b/tests/auto/qwindowsurface/tst_qwindowsurface.cpp index e96bcf9..2490a65 100644 --- a/tests/auto/qwindowsurface/tst_qwindowsurface.cpp +++ b/tests/auto/qwindowsurface/tst_qwindowsurface.cpp @@ -106,18 +106,26 @@ public: QRegion r; }; -#define VERIFY_COLOR(region, color) { \ - const QRegion r = QRegion(region); \ - for (int i = 0; i < r.rects().size(); ++i) { \ - const QRect rect = r.rects().at(i); \ - const QPixmap pixmap = QPixmap::grabWindow(QDesktopWidget().winId(), \ - rect.left(), rect.top(), \ - rect.width(), rect.height()); \ - QCOMPARE(pixmap.size(), rect.size()); \ - QPixmap expectedPixmap(pixmap); /* ensure equal formats */ \ - expectedPixmap.fill(color); \ - QCOMPARE(pixmap, expectedPixmap); \ - } \ +//from tst_qwidget.cpp +static void VERIFY_COLOR(const QRegion ®ion, const QColor &color) +{ + const QRegion r = QRegion(region); + for (int i = 0; i < r.rects().size(); ++i) { + const QRect rect = r.rects().at(i); + for (int t = 0; t < 5; t++) { + const QPixmap pixmap = QPixmap::grabWindow(QDesktopWidget().winId(), + rect.left(), rect.top(), + rect.width(), rect.height()); + QCOMPARE(pixmap.size(), rect.size()); + QPixmap expectedPixmap(pixmap); /* ensure equal formats */ + expectedPixmap.fill(color); + if (pixmap.toImage().pixel(0,0) != QColor(color).rgb() && t < 4 ) + { QTest::qWait(200); continue; } + QCOMPARE(pixmap.toImage().pixel(0,0), QColor(color).rgb()); + QCOMPARE(pixmap, expectedPixmap); + break; + } + } } void tst_QWindowSurface::getSetWindowSurface() |