diff options
Diffstat (limited to 'tests')
5 files changed, 108 insertions, 22 deletions
diff --git a/tests/auto/qml/qqmlapplicationengine/tst_qqmlapplicationengine.cpp b/tests/auto/qml/qqmlapplicationengine/tst_qqmlapplicationengine.cpp index b261bb5191..9dcf68f50c 100644 --- a/tests/auto/qml/qqmlapplicationengine/tst_qqmlapplicationengine.cpp +++ b/tests/auto/qml/qqmlapplicationengine/tst_qqmlapplicationengine.cpp @@ -64,6 +64,7 @@ private: void tst_qqmlapplicationengine::initTestCase() { + qputenv("QT_MESSAGE_PATTERN", ""); // don't let it modify the debug output from testapp buildDir = QDir::currentPath(); QQmlDataTest::initTestCase(); //Changes current path to src dir srcDir = QDir::currentPath(); @@ -123,7 +124,7 @@ void tst_qqmlapplicationengine::application() test_stderr_target.replace('\n', QByteArray("\r\n")); #endif QCOMPARE(test_stdout, QByteArray("")); - QCOMPARE(test_stderr, test_stderr_target); + QCOMPARE(QString(test_stderr), QString(test_stderr_target)); delete testProcess; QDir::setCurrent(srcDir); #else // !QT_NO_PROCESS diff --git a/tests/auto/quick/qquickimage/tst_qquickimage.cpp b/tests/auto/quick/qquickimage/tst_qquickimage.cpp index 58acc19f42..a68a763887 100644 --- a/tests/auto/quick/qquickimage/tst_qquickimage.cpp +++ b/tests/auto/quick/qquickimage/tst_qquickimage.cpp @@ -263,8 +263,9 @@ void tst_qquickimage::resized() void tst_qquickimage::preserveAspectRatio() { - QQuickView *window = new QQuickView(0); + QScopedPointer<QQuickView> window(new QQuickView(0)); window->show(); + QVERIFY(QTest::qWaitForWindowExposed(window.data())); window->setSource(testFileUrl("aspectratio.qml")); QQuickImage *image = qobject_cast<QQuickImage*>(window->rootObject()); @@ -279,7 +280,6 @@ void tst_qquickimage::preserveAspectRatio() QVERIFY(image != 0); QCOMPARE(image->height(), 60.); QCOMPARE(image->width(), 60.); - delete window; } void tst_qquickimage::smooth() @@ -312,7 +312,7 @@ void tst_qquickimage::mirror() QWindow dummy; // On BlackBerry first window is always full screen, dummy.showFullScreen(); // so make test window a second window. #endif - QQuickView *window = new QQuickView; + QScopedPointer<QQuickView> window(new QQuickView); window->setSource(testFileUrl("mirror.qml")); QQuickImage *obj = window->rootObject()->findChild<QQuickImage*>("image"); @@ -321,11 +321,10 @@ void tst_qquickimage::mirror() obj->setFillMode(fillMode); obj->setProperty("mirror", true); window->showNormal(); - QVERIFY(QTest::qWaitForWindowExposed(window)); + QVERIFY(QTest::qWaitForWindowExposed(window.data())); QImage screenshot = window->grabWindow(); screenshots[fillMode] = screenshot; - delete window; } foreach (QQuickImage::FillMode fillMode, fillModes) { @@ -644,10 +643,10 @@ void tst_qquickimage::sourceSize_QTBUG_14303() void tst_qquickimage::sourceSize_QTBUG_16389() { - QQuickView *window = new QQuickView(0); + QScopedPointer<QQuickView> window(new QQuickView(0)); window->setSource(testFileUrl("qtbug_16389.qml")); window->show(); - qApp->processEvents(); + QVERIFY(QTest::qWaitForWindowExposed(window.data())); QQuickImage *image = findItem<QQuickImage>(window->rootObject(), "iconImage"); QQuickItem *handle = findItem<QQuickItem>(window->rootObject(), "blueHandle"); @@ -663,16 +662,15 @@ void tst_qquickimage::sourceSize_QTBUG_16389() QCOMPARE(image->sourceSize().height(), 200); QCOMPARE(image->paintedWidth(), 20.0); QCOMPARE(image->paintedHeight(), 20.0); - - delete window; } // QTBUG-15690 void tst_qquickimage::nullPixmapPaint() { - QQuickView *window = new QQuickView(0); + QScopedPointer<QQuickView> window(new QQuickView(0)); window->setSource(testFileUrl("nullpixmap.qml")); window->show(); + QVERIFY(QTest::qWaitForWindowExposed(window.data())); QQuickImage *image = qobject_cast<QQuickImage*>(window->rootObject()); QTRY_VERIFY(image != 0); @@ -681,11 +679,8 @@ void tst_qquickimage::nullPixmapPaint() QQmlTestMessageHandler messageHandler; // used to print "QTransform::translate with NaN called" QPixmap pm = QPixmap::fromImage(window->grabWindow()); - const QStringList glErrors = messageHandler.messages().filter(QLatin1String("QGLContext::makeCurrent(): Failed."), Qt::CaseInsensitive); - QVERIFY2(glErrors.size() == messageHandler.messages().size(), qPrintable(messageHandler.messageString())); + QVERIFY2(messageHandler.messages().size() == 0, qPrintable(messageHandler.messageString())); delete image; - - delete window; } void tst_qquickimage::imageCrash_QTBUG_22125() @@ -697,7 +692,7 @@ void tst_qquickimage::imageCrash_QTBUG_22125() { QQuickView view(testFileUrl("qtbug_22125.qml")); view.show(); - qApp->processEvents(); + QVERIFY(QTest::qWaitForWindowExposed(&view)); qApp->processEvents(); // shouldn't crash when the view drops out of scope due to // QQuickPixmapData attempting to dereference a pointer to @@ -739,14 +734,14 @@ void tst_qquickimage::sourceSize() QFETCH(qreal, implicitWidth); QFETCH(qreal, implicitHeight); - QQuickView *window = new QQuickView(0); + QScopedPointer<QQuickView> window(new QQuickView(0)); QQmlContext *ctxt = window->rootContext(); ctxt->setContextProperty("srcWidth", sourceWidth); ctxt->setContextProperty("srcHeight", sourceHeight); window->setSource(testFileUrl("sourceSize.qml")); window->show(); - qApp->processEvents(); + QVERIFY(QTest::qWaitForWindowExposed(window.data())); QQuickImage *image = qobject_cast<QQuickImage*>(window->rootObject()); QVERIFY(image); @@ -755,8 +750,6 @@ void tst_qquickimage::sourceSize() QCOMPARE(image->sourceSize().height(), sourceHeight); QCOMPARE(image->implicitWidth(), implicitWidth); QCOMPARE(image->implicitHeight(), implicitHeight); - - delete window; } void tst_qquickimage::sourceSizeChanges() diff --git a/tests/auto/quick/qquickitem/tst_qquickitem.cpp b/tests/auto/quick/qquickitem/tst_qquickitem.cpp index 40327b0666..5993008c4a 100644 --- a/tests/auto/quick/qquickitem/tst_qquickitem.cpp +++ b/tests/auto/quick/qquickitem/tst_qquickitem.cpp @@ -52,6 +52,7 @@ #include <QQmlEngine> #include "../../shared/util.h" #include "../shared/viewtestutil.h" +#include <QSignalSpy> class TestItem : public QQuickItem { @@ -172,6 +173,8 @@ private slots: void visualParentOwnership(); void visualParentOwnershipWindow(); + void testSGInitializeAndInvalidate(); + private: enum PaintOrderOp { @@ -1883,6 +1886,37 @@ void tst_qquickitem::visualParentOwnershipWindow() } } +void tst_qquickitem::testSGInitializeAndInvalidate() +{ + for (int i=0; i<2; ++i) { + QScopedPointer<QQuickView> view(new QQuickView()); + + QQuickItem *item = new QQuickItem(); + + int expected; + if (i == 0) { + // First iteration, item has contents and should get signals + expected = 1; + item->setFlag(QQuickItem::ItemHasContents, true); + } else { + // Second iteration, item does not have content and will not get signals + expected = 0; + } + + QSignalSpy initializeSpy(item, SIGNAL(sceneGraphInitialized())); + QSignalSpy invalidateSpy(item, SIGNAL(sceneGraphInvalidated())); + item->setParentItem(view->contentItem()); + view->show(); + + QVERIFY(QTest::qWaitForWindowExposed(view.data())); + QCOMPARE(initializeSpy.size(), expected); + + delete view.take(); + QCOMPARE(invalidateSpy.size(), expected); + } + +} + QTEST_MAIN(tst_qquickitem) #include "tst_qquickitem.moc" diff --git a/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp b/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp index 17773fcfc4..6c1d46b191 100644 --- a/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp +++ b/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp @@ -55,6 +55,7 @@ #include <qpa/qwindowsysteminterface.h> #include <private/qquickwindow_p.h> #include <private/qguiapplication_p.h> +#include <QRunnable> struct TouchEventData { QEvent::Type type; @@ -367,6 +368,8 @@ private slots: void defaultSurfaceFormat(); void glslVersion(); + void testRenderJob(); + private: QTouchDevice *touchDevice; QTouchDevice *touchDeviceWithVelocity; @@ -1971,6 +1974,58 @@ void tst_qquickwindow::glslVersion() } } +class RenderJob : public QRunnable +{ +public: + RenderJob(QQuickWindow::RenderStage s, QList<QQuickWindow::RenderStage> *l) : stage(s), list(l) { } + ~RenderJob() { ++deleted; } + QQuickWindow::RenderStage stage; + QList<QQuickWindow::RenderStage> *list; + void run() { + list->append(stage); + } + static int deleted; +}; + +int RenderJob::deleted = 0; + +void tst_qquickwindow::testRenderJob() +{ + QList<QQuickWindow::RenderStage> completedJobs; + + QQuickWindow window; + + QQuickWindow::RenderStage stages[] = { + QQuickWindow::BeforeSynchronizingStage, + QQuickWindow::AfterSynchronizingStage, + QQuickWindow::BeforeRenderingStage, + QQuickWindow::AfterRenderingStage, + QQuickWindow::AfterSwapStage + }; + // Schedule the jobs + for (int i=0; i<5; ++i) + window.scheduleRenderJob(new RenderJob(stages[i], &completedJobs), stages[i]); + window.show(); + + QTRY_COMPARE(completedJobs.size(), 5); + + for (int i=0; i<5; ++i) { + QCOMPARE(completedJobs.at(i), stages[i]); + } + + // Verify that jobs are deleted when window has not been rendered at all... + completedJobs.clear(); + RenderJob::deleted = 0; + { + QQuickWindow window2; + for (int i=0; i<5; ++i) { + window2.scheduleRenderJob(new RenderJob(stages[i], &completedJobs), stages[i]); + } + } + QCOMPARE(completedJobs.size(), 0); + QCOMPARE(RenderJob::deleted, 5); +} + QTEST_MAIN(tst_qquickwindow) #include "tst_qquickwindow.moc" diff --git a/tests/auto/quick/touchmouse/tst_touchmouse.cpp b/tests/auto/quick/touchmouse/tst_touchmouse.cpp index 1d947b4d8c..f39a22e131 100644 --- a/tests/auto/quick/touchmouse/tst_touchmouse.cpp +++ b/tests/auto/quick/touchmouse/tst_touchmouse.cpp @@ -661,6 +661,7 @@ void tst_TouchMouse::buttonOnDelayedPressFlickable() // but we'll get the delayed mouse press after a delay QTRY_COMPARE(eventItem1->eventList.size(), 1); QCOMPARE(eventItem1->eventList.at(0).type, QEvent::MouseButtonPress); + QCOMPARE(filteredEventList.count(), 1); // eventItem1 should have the mouse grab, and have moved the itemForTouchPointId // for the touchMouseId to the new grabber. @@ -690,8 +691,9 @@ void tst_TouchMouse::buttonOnDelayedPressFlickable() QTest::touchEvent(window, device).release(0, p3, window); QQuickTouchUtils::flush(window); - // We should not have received any synthesised mouse events from Qt gui. - QCOMPARE(filteredEventList.count(), 0); + // We should not have received any synthesised mouse events from Qt gui, + // just the delayed press. + QCOMPARE(filteredEventList.count(), 1); delete window; } @@ -916,6 +918,7 @@ void tst_TouchMouse::pinchOnFlickable() p1 -= QPoint(10, 0); p2 += QPoint(10, 0); pinchSequence.move(0, p1, window).move(1, p2, window).commit(); + QVERIFY(!flickable->isDragging()); QQuickTouchUtils::flush(window); pinchSequence.release(0, p1, window).release(1, p2, window).commit(); QQuickTouchUtils::flush(window); |