diff options
Diffstat (limited to 'tests/auto')
14 files changed, 399 insertions, 84 deletions
diff --git a/tests/auto/qml/debugger/qqmldebuggingenabler/qqmldebuggingenabler.pro b/tests/auto/qml/debugger/qqmldebuggingenabler/qqmldebuggingenabler.pro index eb41f759c9..4bcbc2a97e 100644 --- a/tests/auto/qml/debugger/qqmldebuggingenabler/qqmldebuggingenabler.pro +++ b/tests/auto/qml/debugger/qqmldebuggingenabler/qqmldebuggingenabler.pro @@ -1,13 +1,4 @@ -CONFIG += testcase -TARGET = tst_qqmldebuggingenabler -QT += qml testlib gui-private core-private -osx:CONFIG -= app_bundle +TEMPLATE = subdirs +SUBDIRS = qqmldebuggingenabler qqmldebuggingenablerserver -SOURCES += tst_qqmldebuggingenabler.cpp - -INCLUDEPATH += ../shared -include(../../../shared/util.pri) -include(../shared/debugutil.pri) - -OTHER_FILES += data/test.qml -DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 QT_QML_DEBUG_NO_WARNING +qqmldebuggingenabler.depends = qqmldebuggingenablerserver diff --git a/tests/auto/qml/debugger/qqmldebuggingenabler/data/test.qml b/tests/auto/qml/debugger/qqmldebuggingenabler/qqmldebuggingenabler/data/test.qml index 5a7fa718f2..5a7fa718f2 100644 --- a/tests/auto/qml/debugger/qqmldebuggingenabler/data/test.qml +++ b/tests/auto/qml/debugger/qqmldebuggingenabler/qqmldebuggingenabler/data/test.qml diff --git a/tests/auto/qml/debugger/qqmldebuggingenabler/qqmldebuggingenabler/qqmldebuggingenabler.pro b/tests/auto/qml/debugger/qqmldebuggingenabler/qqmldebuggingenabler/qqmldebuggingenabler.pro new file mode 100644 index 0000000000..f8014f04f4 --- /dev/null +++ b/tests/auto/qml/debugger/qqmldebuggingenabler/qqmldebuggingenabler/qqmldebuggingenabler.pro @@ -0,0 +1,13 @@ +CONFIG += testcase +TARGET = tst_qqmldebuggingenabler +QT += qml testlib gui-private core-private +CONFIG -= debug_and_release_target +osx:CONFIG -= app_bundle + +SOURCES += tst_qqmldebuggingenabler.cpp + +INCLUDEPATH += ../../shared +include(../../../../shared/util.pri) +include(../../shared/debugutil.pri) + +OTHER_FILES += data/test.qml diff --git a/tests/auto/qml/debugger/qqmldebuggingenabler/tst_qqmldebuggingenabler.cpp b/tests/auto/qml/debugger/qqmldebuggingenabler/qqmldebuggingenabler/tst_qqmldebuggingenabler.cpp index 73abc03e28..4ab1ac0a4c 100644 --- a/tests/auto/qml/debugger/qqmldebuggingenabler/tst_qqmldebuggingenabler.cpp +++ b/tests/auto/qml/debugger/qqmldebuggingenabler/qqmldebuggingenabler/tst_qqmldebuggingenabler.cpp @@ -92,7 +92,7 @@ bool tst_QQmlDebuggingEnabler::init(bool blockMode, bool qmlscene, int portFrom, process = new QQmlDebugProcess(QLibraryInfo::location(QLibraryInfo::BinariesPath) + "/qmlscene", this); process->setMaximumBindErrors(1); } else { - process = new QQmlDebugProcess(QCoreApplication::applicationFilePath(), this); + process = new QQmlDebugProcess(QCoreApplication::applicationDirPath() + QLatin1String("/qqmldebuggingenablerserver"), this); process->setMaximumBindErrors(portTo - portFrom); } @@ -103,7 +103,6 @@ bool tst_QQmlDebuggingEnabler::init(bool blockMode, bool qmlscene, int portFrom, testFile(QLatin1String("test.qml"))); } else { QStringList args; - args << QLatin1String("-server"); if (blockMode) args << QLatin1String("-block"); args << QString::number(portFrom) << QString::number(portTo); @@ -163,27 +162,7 @@ void tst_QQmlDebuggingEnabler::customBlock() QVERIFY(init(true, false, 5555, 5565)); } -namespace QQmlDebuggingEnablerTest { - QTEST_MAIN(tst_QQmlDebuggingEnabler) -} - -int main(int argc, char *argv[]) -{ - if (argc > 1 && QLatin1String(argv[1]) == QLatin1String("-server")) { - int one = 1; - QCoreApplication app(one, argv); - bool block = argc > 2 && QLatin1String(argv[2]) == QLatin1String("-block"); - int portFrom = QString(QLatin1String(argv[argc - 2])).toInt(); - int portTo = QString(QLatin1String(argv[argc - 1])).toInt(); - while (portFrom <= portTo) - QQmlDebuggingEnabler::startTcpDebugServer(portFrom++, block); - QQmlEngine engine; - Q_UNUSED(engine); - app.exec(); - } else { - QQmlDebuggingEnablerTest::main(argc, argv); - } -} +QTEST_MAIN(tst_QQmlDebuggingEnabler) #include "tst_qqmldebuggingenabler.moc" diff --git a/tests/auto/qml/debugger/qqmldebuggingenabler/qqmldebuggingenablerserver/qqmldebuggingenablerserver.cpp b/tests/auto/qml/debugger/qqmldebuggingenabler/qqmldebuggingenablerserver/qqmldebuggingenablerserver.cpp new file mode 100644 index 0000000000..68279413e0 --- /dev/null +++ b/tests/auto/qml/debugger/qqmldebuggingenabler/qqmldebuggingenablerserver/qqmldebuggingenablerserver.cpp @@ -0,0 +1,66 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL21$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** 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 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** As a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "debugutil_p.h" +#include <QtCore/QCoreApplication> + +int main(int argc, char *argv[]) +{ + bool block = false; + int portFrom = 0; + int portTo = 0; + + QCoreApplication app(argc, argv); + QStringList arguments = app.arguments(); + arguments.removeFirst(); + + if (arguments.size() && arguments.first() == QLatin1String("-block")) { + block = true; + arguments.removeFirst(); + } + + if (arguments.size() >= 2) { + portFrom = arguments.takeFirst().toInt(); + portTo = arguments.takeFirst().toInt(); + } + + if (!portFrom || !portTo) + qFatal("Port range has to be specified."); + + while (portFrom <= portTo) + QQmlDebuggingEnabler::startTcpDebugServer(portFrom++, block); + QQmlEngine engine; + Q_UNUSED(engine); + return app.exec(); +} + diff --git a/tests/auto/qml/debugger/qqmldebuggingenabler/qqmldebuggingenablerserver/qqmldebuggingenablerserver.pro b/tests/auto/qml/debugger/qqmldebuggingenabler/qqmldebuggingenablerserver/qqmldebuggingenablerserver.pro new file mode 100644 index 0000000000..fdd9ce8f11 --- /dev/null +++ b/tests/auto/qml/debugger/qqmldebuggingenabler/qqmldebuggingenablerserver/qqmldebuggingenablerserver.pro @@ -0,0 +1,11 @@ +QT += qml testlib +osx:CONFIG -= app_bundle +CONFIG -= debug_and_release_target +INCLUDEPATH += ../../shared +SOURCES += qqmldebuggingenablerserver.cpp +DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 QT_QML_DEBUG_NO_WARNING + +DESTDIR = ../qqmldebuggingenabler + +target.path = $$[QT_INSTALL_TESTS]/tst_qqmldebuggingenabler +INSTALLS += target diff --git a/tests/auto/qml/qjsengine/tst_qjsengine.cpp b/tests/auto/qml/qjsengine/tst_qjsengine.cpp index 61816b6cc0..5a9d6d20eb 100644 --- a/tests/auto/qml/qjsengine/tst_qjsengine.cpp +++ b/tests/auto/qml/qjsengine/tst_qjsengine.cpp @@ -178,6 +178,8 @@ private slots: void intConversion_QTBUG43309(); void toFixed(); + void argumentEvaluationOrder(); + signals: void testSignal(); }; @@ -3665,6 +3667,25 @@ void tst_QJSEngine::toFixed() QCOMPARE(result.toString(), QStringLiteral("12.1")); } +void tst_QJSEngine::argumentEvaluationOrder() +{ + QJSEngine engine; + QJSValue ok = engine.evaluate( + "function record(arg1, arg2) {\n" + " parameters = [arg1, arg2]\n" + "}\n" + "function test() {\n" + " var i = 2;\n" + " record(i, i += 2);\n" + "}\n" + "test()\n" + "parameters[0] == 2 && parameters[1] == 4"); + qDebug() << ok.toString(); + QVERIFY(ok.isBool()); + QVERIFY(ok.toBool()); + +} + QTEST_MAIN(tst_QJSEngine) #include "tst_qjsengine.moc" diff --git a/tests/auto/qml/qqmlxmlhttprequest/data/statusText.qml b/tests/auto/qml/qqmlxmlhttprequest/data/statusText.qml index bf59a1e9f9..b47a0f1af0 100644 --- a/tests/auto/qml/qqmlxmlhttprequest/data/statusText.qml +++ b/tests/auto/qml/qqmlxmlhttprequest/data/statusText.qml @@ -48,7 +48,7 @@ QtObject { if (x.statusText == expectedStatus) done = true; - dataOK = (x.responseText == "QML Rocks!\n"); + dataOK = (x.responseText == "QML Rocks!\n") && (x.response == "QML Rocks!\n"); x.open("GET", url); x.setRequestHeader("Accept-Language", "en-US"); diff --git a/tests/auto/quick/qquickdroparea/tst_qquickdroparea.cpp b/tests/auto/quick/qquickdroparea/tst_qquickdroparea.cpp index ece439d01a..67ee1a3714 100644 --- a/tests/auto/quick/qquickdroparea/tst_qquickdroparea.cpp +++ b/tests/auto/quick/qquickdroparea/tst_qquickdroparea.cpp @@ -78,6 +78,7 @@ private slots: // void drop_external(); void competingDrags(); void simultaneousDrags(); + void dropStuff(); private: QQmlEngine engine; @@ -1157,6 +1158,34 @@ void tst_QQuickDropArea::simultaneousDrags() QWindowSystemInterface::handleDrop(&alternateWindow, &data, QPoint(50, 50), Qt::CopyAction); } +void tst_QQuickDropArea::dropStuff() +{ + QQuickWindow window; + QQmlComponent component(&engine); + component.setData( + "import QtQuick 2.3\n" + "DropArea {\n" + "width: 100; height: 100\n" + "property var array\n" + "onDropped: { array = drop.getDataAsArrayBuffer('text/x-red'); }\n" + "}", QUrl()); + + QScopedPointer<QObject> object(component.create()); + QQuickItem *dropArea = qobject_cast<QQuickItem *>(object.data()); + QVERIFY(dropArea); + dropArea->setParentItem(window.contentItem()); + + QMimeData data; + data.setData("text/x-red", "red"); + + QCOMPARE(evaluate<QVariant>(dropArea, "array"), QVariant()); + + QWindowSystemInterface::handleDrag(&window, &data, QPoint(50, 50), Qt::CopyAction); + QWindowSystemInterface::handleDrop(&window, &data, QPoint(50, 50), Qt::CopyAction); + QCOMPARE(evaluate<int>(dropArea, "array.byteLength"), 3); + QCOMPARE(evaluate<QByteArray>(dropArea, "array"), QByteArray("red")); +} + QTEST_MAIN(tst_QQuickDropArea) #include "tst_qquickdroparea.moc" diff --git a/tests/auto/quick/qquicktext/data/implicitSizes.qml b/tests/auto/quick/qquicktext/data/implicitSizes.qml new file mode 100644 index 0000000000..fae67c0273 --- /dev/null +++ b/tests/auto/quick/qquicktext/data/implicitSizes.qml @@ -0,0 +1,99 @@ +import QtQuick 2.0 + +Rectangle { + width: 200 + height: column.height + + Column { + id: column + Text { + id: reference + objectName: "reference" + + wrapMode: Text.Wrap + elide: Text.ElideRight + + text: "Lorem ipsum dolor sit amet, consectetur adipiscing elit. +Integer at ante dui Curabitur ante est, pulvinar quis adipiscing a, iaculis id ipsum. Nunc blandit +condimentum odio vel egestas. in ipsum lacinia sit amet +mattis orci interdum. Quisque vitae accumsan lectus. Ut nisi turpis, +sollicitudin ut dignissim id, fermentum ac est. Maecenas nec libero leo. Sed ac +mattis orci interdum. Quisque vitae accumsan lectus. Ut nisi turpis, +sollicitudin ut dignissim id, fermentum ac est. Maecenas nec libero leo. Sed ac +leo eget ipsum ultricies viverra sit amet eu orci. Praesent et tortor risus, +viverra accumsan sapien. Sed faucibus eleifend lectus, sed euismod urna porta +eu. Quisque vitae accumsan lectus." + } + Text { + id: fixedWidthAndHeight + objectName: "fixedWidthAndHeight" + + width: 100 + height: 100 + + wrapMode: Text.Wrap + elide: Text.ElideRight + + text: reference.text + } + + Text { + id: implicitWidthFixedHeight + objectName: "implicitWidthFixedHeight" + + height: 100 + + wrapMode: Text.Wrap + elide: Text.ElideRight + + text: reference.text + } + Text { + id: fixedWidthImplicitHeight + objectName: "fixedWidthImplicitHeight" + + width: 100 + + wrapMode: Text.Wrap + elide: Text.ElideRight + + text: reference.text + } + Text { + id: cappedWidthAndHeight + objectName: "cappedWidthAndHeight" + + width: Math.min(100, implicitWidth) + height: Math.min(100, implicitHeight) + + wrapMode: Text.Wrap + elide: Text.ElideRight + + text: reference.text + } + Text { + id: cappedWidthFixedHeight + objectName: "cappedWidthFixedHeight" + + width: Math.min(100, implicitWidth) + height: 100 + + wrapMode: Text.Wrap + elide: Text.ElideRight + + text: reference.text + } + Text { + id: fixedWidthCappedHeight + objectName: "fixedWidthCappedHeight" + + width: 100 + height: Math.min(100, implicitHeight) + + wrapMode: Text.Wrap + elide: Text.ElideRight + + text: reference.text + } + } +} diff --git a/tests/auto/quick/qquicktext/tst_qquicktext.cpp b/tests/auto/quick/qquicktext/tst_qquicktext.cpp index 00c3957bad..c1d454e5df 100644 --- a/tests/auto/quick/qquicktext/tst_qquicktext.cpp +++ b/tests/auto/quick/qquicktext/tst_qquicktext.cpp @@ -106,6 +106,7 @@ private slots: void implicitSize_data(); void implicitSize(); + void dependentImplicitSizes(); void contentSize(); void implicitSizeBinding_data(); void implicitSizeBinding(); @@ -2216,6 +2217,62 @@ void tst_qquicktext::implicitSize() delete textObject; } +void tst_qquicktext::dependentImplicitSizes() +{ + QQmlComponent component(&engine, testFile("implicitSizes.qml")); + QScopedPointer<QObject> object(component.create()); + QVERIFY(object.data()); + + QQuickText *reference = object->findChild<QQuickText *>("reference"); + QQuickText *fixedWidthAndHeight = object->findChild<QQuickText *>("fixedWidthAndHeight"); + QQuickText *implicitWidthFixedHeight = object->findChild<QQuickText *>("implicitWidthFixedHeight"); + QQuickText *fixedWidthImplicitHeight = object->findChild<QQuickText *>("fixedWidthImplicitHeight"); + QQuickText *cappedWidthAndHeight = object->findChild<QQuickText *>("cappedWidthAndHeight"); + QQuickText *cappedWidthFixedHeight = object->findChild<QQuickText *>("cappedWidthFixedHeight"); + QQuickText *fixedWidthCappedHeight = object->findChild<QQuickText *>("fixedWidthCappedHeight"); + + QVERIFY(reference); + QVERIFY(fixedWidthAndHeight); + QVERIFY(implicitWidthFixedHeight); + QVERIFY(fixedWidthImplicitHeight); + QVERIFY(cappedWidthAndHeight); + QVERIFY(cappedWidthFixedHeight); + QVERIFY(fixedWidthCappedHeight); + + QCOMPARE(reference->width(), reference->implicitWidth()); + QCOMPARE(reference->height(), reference->implicitHeight()); + + QVERIFY(fixedWidthAndHeight->width() < fixedWidthAndHeight->implicitWidth()); + QVERIFY(fixedWidthAndHeight->height() < fixedWidthAndHeight->implicitHeight()); + QCOMPARE(fixedWidthAndHeight->implicitWidth(), reference->implicitWidth()); + QVERIFY(fixedWidthAndHeight->implicitHeight() > reference->implicitHeight()); + + QCOMPARE(implicitWidthFixedHeight->width(), implicitWidthFixedHeight->implicitWidth()); + QVERIFY(implicitWidthFixedHeight->height() < implicitWidthFixedHeight->implicitHeight()); + QCOMPARE(implicitWidthFixedHeight->implicitWidth(), reference->implicitWidth()); + QCOMPARE(implicitWidthFixedHeight->implicitHeight(), reference->implicitHeight()); + + QVERIFY(fixedWidthImplicitHeight->width() < fixedWidthImplicitHeight->implicitWidth()); + QCOMPARE(fixedWidthImplicitHeight->height(), fixedWidthImplicitHeight->implicitHeight()); + QCOMPARE(fixedWidthImplicitHeight->implicitWidth(), reference->implicitWidth()); + QCOMPARE(fixedWidthImplicitHeight->implicitHeight(), fixedWidthAndHeight->implicitHeight()); + + QVERIFY(cappedWidthAndHeight->width() < cappedWidthAndHeight->implicitWidth()); + QVERIFY(cappedWidthAndHeight->height() < cappedWidthAndHeight->implicitHeight()); + QCOMPARE(cappedWidthAndHeight->implicitWidth(), reference->implicitWidth()); + QCOMPARE(cappedWidthAndHeight->implicitHeight(), fixedWidthAndHeight->implicitHeight()); + + QVERIFY(cappedWidthFixedHeight->width() < cappedWidthAndHeight->implicitWidth()); + QVERIFY(cappedWidthFixedHeight->height() < cappedWidthFixedHeight->implicitHeight()); + QCOMPARE(cappedWidthFixedHeight->implicitWidth(), reference->implicitWidth()); + QCOMPARE(cappedWidthFixedHeight->implicitHeight(), fixedWidthAndHeight->implicitHeight()); + + QVERIFY(fixedWidthCappedHeight->width() < fixedWidthCappedHeight->implicitWidth()); + QVERIFY(fixedWidthCappedHeight->height() < fixedWidthCappedHeight->implicitHeight()); + QCOMPARE(fixedWidthCappedHeight->implicitWidth(), reference->implicitWidth()); + QCOMPARE(fixedWidthCappedHeight->implicitHeight(), fixedWidthAndHeight->implicitHeight()); +} + void tst_qquicktext::contentSize() { QString componentStr = "import QtQuick 2.0\nText { width: 75; height: 16; font.pixelSize: 10 }"; diff --git a/tests/auto/quick/qquicktextinput/tst_qquicktextinput.cpp b/tests/auto/quick/qquicktextinput/tst_qquicktextinput.cpp index bc5e6031cb..586a92f4dc 100644 --- a/tests/auto/quick/qquicktextinput/tst_qquicktextinput.cpp +++ b/tests/auto/quick/qquicktextinput/tst_qquicktextinput.cpp @@ -3194,6 +3194,7 @@ void tst_qquicktextinput::readOnly() QVERIFY(input != 0); QTRY_VERIFY(input->hasActiveFocus() == true); QVERIFY(input->isReadOnly() == true); + QVERIFY(input->isCursorVisible() == false); QString initial = input->text(); for (int k=Qt::Key_0; k<=Qt::Key_Z; k++) simulateKey(&window, k); @@ -3206,6 +3207,7 @@ void tst_qquicktextinput::readOnly() input->setReadOnly(false); QCOMPARE(input->isReadOnly(), false); QCOMPARE(input->cursorPosition(), input->text().length()); + QVERIFY(input->isCursorVisible() == true); } void tst_qquicktextinput::echoMode() diff --git a/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp b/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp index 09c582ee91..7d7027dc0d 100644 --- a/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp +++ b/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp @@ -290,6 +290,7 @@ private slots: touchDeviceWithVelocity->setCapabilities(QTouchDevice::Position | QTouchDevice::Velocity); QWindowSystemInterface::registerTouchDevice(touchDeviceWithVelocity); } + void cleanup(); void openglContextCreatedSignal(); void aboutToStopSignal(); @@ -373,6 +374,11 @@ private: Q_DECLARE_METATYPE(QOpenGLContext *); +void tst_qquickwindow::cleanup() +{ + QVERIFY(QGuiApplication::topLevelWindows().isEmpty()); +} + void tst_qquickwindow::openglContextCreatedSignal() { qRegisterMetaType<QOpenGLContext *>(); @@ -380,6 +386,7 @@ void tst_qquickwindow::openglContextCreatedSignal() QQuickWindow window; QSignalSpy spy(&window, SIGNAL(openglContextCreated(QOpenGLContext*))); + window.setTitle(QTest::currentTestFunction()); window.show(); QTest::qWaitForWindowExposed(&window); @@ -392,6 +399,7 @@ void tst_qquickwindow::openglContextCreatedSignal() void tst_qquickwindow::aboutToStopSignal() { QQuickWindow window; + window.setTitle(QTest::currentTestFunction()); window.show(); QTest::qWaitForWindowExposed(&window); @@ -408,6 +416,7 @@ void tst_qquickwindow::constantUpdates() QQuickWindow window; window.resize(250, 250); ConstantUpdateItem item(window.contentItem()); + window.setTitle(QTest::currentTestFunction()); window.show(); QSignalSpy beforeSpy(&window, SIGNAL(beforeSynchronizing())); @@ -424,6 +433,7 @@ void tst_qquickwindow::constantUpdatesOnWindow_data() QTest::addColumn<QByteArray>("signal"); QQuickWindow window; + window.setTitle(QTest::currentTestFunction()); window.setGeometry(100, 100, 300, 200); window.show(); QTest::qWaitForWindowExposed(&window); @@ -458,6 +468,7 @@ void tst_qquickwindow::constantUpdatesOnWindow() QFETCH(QByteArray, signal); QQuickWindow window; + window.setTitle(QTest::currentTestFunction()); window.setGeometry(100, 100, 300, 200); bool ok = connect(&window, signal.constData(), &window, SLOT(update()), Qt::DirectConnection); @@ -488,6 +499,7 @@ void tst_qquickwindow::touchEvent_basic() QQuickWindow *window = new QQuickWindow; QScopedPointer<QQuickWindow> cleanup(window); + window->setTitle(QTest::currentTestFunction()); window->resize(250, 250); window->setPosition(100, 100); @@ -621,6 +633,7 @@ void tst_qquickwindow::touchEvent_propagation() window->resize(250, 250); window->setPosition(100, 100); + window->setTitle(QTest::currentTestFunction()); window->show(); QVERIFY(QTest::qWaitForWindowActive(window)); @@ -754,6 +767,7 @@ void tst_qquickwindow::touchEvent_cancel() window->resize(250, 250); window->setPosition(100, 100); + window->setTitle(QTest::currentTestFunction()); window->show(); QVERIFY(QTest::qWaitForWindowActive(window)); @@ -787,6 +801,7 @@ void tst_qquickwindow::touchEvent_reentrant() window->resize(250, 250); window->setPosition(100, 100); + window->setTitle(QTest::currentTestFunction()); window->show(); QVERIFY(QTest::qWaitForWindowActive(window)); @@ -824,6 +839,7 @@ void tst_qquickwindow::touchEvent_velocity() QScopedPointer<QQuickWindow> cleanup(window); window->resize(250, 250); window->setPosition(100, 100); + window->setTitle(QTest::currentTestFunction()); window->show(); QVERIFY(QTest::qWaitForWindowExposed(window)); QTest::qWait(10); @@ -885,6 +901,7 @@ void tst_qquickwindow::mouseFromTouch_basic() QScopedPointer<QQuickWindow> cleanup(window); window->resize(250, 250); window->setPosition(100, 100); + window->setTitle(QTest::currentTestFunction()); window->show(); QVERIFY(QTest::qWaitForWindowExposed(window)); QTest::qWait(10); @@ -953,10 +970,11 @@ void tst_qquickwindow::mouseFromTouch_basic() void tst_qquickwindow::clearWindow() { QQuickWindow *window = new QQuickWindow; + window->setTitle(QTest::currentTestFunction()); QQuickItem *item = new QQuickItem; item->setParentItem(window->contentItem()); - QVERIFY(item->window() == window); + QCOMPARE(item->window(), window); delete window; @@ -973,6 +991,7 @@ void tst_qquickwindow::mouseFiltering() QScopedPointer<QQuickWindow> cleanup(window); window->resize(250, 250); window->setPosition(100, 100); + window->setTitle(QTest::currentTestFunction()); window->show(); QVERIFY(QTest::qWaitForWindowActive(window)); @@ -1033,6 +1052,7 @@ void tst_qquickwindow::clearColor() window->resize(250, 250); window->setPosition(100, 100); window->setColor(Qt::blue); + window->setTitle(QTest::currentTestFunction()); window->show(); QVERIFY(QTest::qWaitForWindowExposed(window)); QCOMPARE(window->color(), QColor(Qt::blue)); @@ -1049,6 +1069,7 @@ void tst_qquickwindow::defaultState() QQuickWindow *qmlWindow = qobject_cast<QQuickWindow*>(created); QVERIFY(qmlWindow); + qmlWindow->setTitle(QTest::currentTestFunction()); QQuickWindow cppWindow; cppWindow.show(); @@ -1069,6 +1090,7 @@ void tst_qquickwindow::grab() QFETCH(bool, visible); QQuickWindow window; + window.setTitle(QLatin1String(QTest::currentTestFunction()) + QLatin1Char(' ') + QLatin1String(QTest::currentDataTag())); window.setColor(Qt::red); window.resize(250, 250); @@ -1093,6 +1115,7 @@ void tst_qquickwindow::multipleWindows() for (int i=0; i<6; ++i) { QQuickWindow *c = new QQuickWindow(); + c->setTitle(QLatin1String(QTest::currentTestFunction()) + QString::number(i)); c->setColor(Qt::GlobalColor(Qt::red + i)); c->resize(300, 200); c->setPosition(100 + i * 30, 100 + i * 20); @@ -1125,6 +1148,7 @@ void tst_qquickwindow::animationsWhileHidden() QQuickWindow *window = qobject_cast<QQuickWindow*>(created); QVERIFY(window); + window->setTitle(QTest::currentTestFunction()); QVERIFY(window->isVisible()); // Now hide the window and verify that it went off screen @@ -1186,6 +1210,7 @@ void tst_qquickwindow::headless() window->setPersistentOpenGLContext(false); window->setPersistentSceneGraph(false); QVERIFY(window); + window->setTitle(QTest::currentTestFunction()); window->show(); QVERIFY(QTest::qWaitForWindowExposed(window)); @@ -1235,6 +1260,7 @@ void tst_qquickwindow::headless() void tst_qquickwindow::noUpdateWhenNothingChanges() { QQuickWindow window; + window.setTitle(QTest::currentTestFunction()); window.setGeometry(100, 100, 300, 200); QQuickRectangle rect(window.contentItem()); @@ -1271,6 +1297,7 @@ void tst_qquickwindow::focusObject() QQuickWindow *window = qobject_cast<QQuickWindow*>(created); QVERIFY(window); + window->setTitle(QTest::currentTestFunction()); QSignalSpy focusObjectSpy(window, SIGNAL(focusObjectChanged(QObject*))); @@ -1309,6 +1336,7 @@ void tst_qquickwindow::focusReason() QScopedPointer<QQuickWindow> cleanup(window); window->resize(200, 200); window->show(); + window->setTitle(QTest::currentTestFunction()); QVERIFY(QTest::qWaitForWindowExposed(window)); QQuickItem *firstItem = new QQuickItem; @@ -1334,6 +1362,7 @@ void tst_qquickwindow::ignoreUnhandledMouseEvents() { QQuickWindow *window = new QQuickWindow; QScopedPointer<QQuickWindow> cleanup(window); + window->setTitle(QTest::currentTestFunction()); window->resize(100, 100); window->show(); QVERIFY(QTest::qWaitForWindowExposed(window)); @@ -1380,6 +1409,7 @@ void tst_qquickwindow::ownershipRootItem() QQuickWindow *window = qobject_cast<QQuickWindow*>(created); QVERIFY(window); + window->setTitle(QTest::currentTestFunction()); window->show(); QVERIFY(QTest::qWaitForWindowExposed(window)); @@ -1396,7 +1426,9 @@ void tst_qquickwindow::ownershipRootItem() void tst_qquickwindow::cursor() { QQuickWindow window; - window.resize(320, 240); + window.setTitle(QTest::currentTestFunction()); + window.setFramePosition(QGuiApplication::primaryScreen()->availableGeometry().topLeft() + QPoint(50, 50)); + window.resize(320, 290); QQuickItem parentItem; parentItem.setPosition(QPointF(0, 0)); @@ -1551,6 +1583,8 @@ void tst_qquickwindow::hideThenDelete() { QQuickWindow window; + window.setTitle(QLatin1String(QTest::currentTestFunction()) + QLatin1Char(' ') + + QLatin1String(QTest::currentDataTag())); window.setColor(Qt::red); window.setPersistentSceneGraph(persistentSG); @@ -1577,8 +1611,8 @@ void tst_qquickwindow::hideThenDelete() else QVERIFY(openglDestroyed->size() == 0); } else { - QVERIFY(sgInvalidated->size() == 0); - QVERIFY(openglDestroyed->size() == 0); + QCOMPARE(sgInvalidated->size(), 0); + QCOMPARE(openglDestroyed->size(), 0); } } } @@ -1613,6 +1647,7 @@ void tst_qquickwindow::showHideAnimate() void tst_qquickwindow::testExpose() { QQuickWindow window; + window.setTitle(QTest::currentTestFunction()); window.setGeometry(100, 100, 300, 200); window.show(); @@ -1637,11 +1672,12 @@ void tst_qquickwindow::requestActivate() QQmlEngine engine; QQmlComponent component(&engine); component.loadUrl(testFileUrl("active.qml")); - QQuickWindow *window1 = qobject_cast<QQuickWindow *>(component.create()); - QVERIFY(window1); + QScopedPointer<QQuickWindow> window1(qobject_cast<QQuickWindow *>(component.create())); + QVERIFY(!window1.isNull()); + window1->setTitle(QTest::currentTestFunction()); QWindowList windows = QGuiApplication::topLevelWindows(); - QVERIFY(windows.size() == 2); + QCOMPARE(windows.size(), 2); for (int i = 0; i < windows.size(); ++i) { if (windows.at(i)->objectName() == window1->objectName()) { @@ -1649,14 +1685,14 @@ void tst_qquickwindow::requestActivate() break; } } - QVERIFY(windows.size() == 1); - QVERIFY(windows.at(0)->objectName() == "window2"); + QCOMPARE(windows.size(), 1); + QCOMPARE(windows.at(0)->objectName(), QLatin1String("window2")); window1->show(); QVERIFY(QTest::qWaitForWindowExposed(windows.at(0))); //We wait till window 2 comes up window1->requestActivate(); // and then transfer the focus to window1 - QTRY_VERIFY(QGuiApplication::focusWindow() == window1); + QTRY_COMPARE(QGuiApplication::focusWindow(), window1.data()); QVERIFY(window1->isActive() == true); QQuickItem *item = QQuickVisualTestUtil::findItem<QQuickItem>(window1->contentItem(), "item1"); @@ -1667,20 +1703,19 @@ void tst_qquickwindow::requestActivate() QMouseEvent me(QEvent::MouseButtonPress, pos, window1->mapToGlobal(pos), Qt::LeftButton, Qt::LeftButton, Qt::NoModifier); QSpontaneKeyEvent::setSpontaneous(&me); - if (!qApp->notify(window1, &me)) { + if (!qApp->notify(window1.data(), &me)) { QString warning = QString::fromLatin1("Mouse event MousePress not accepted by receiving window"); QWARN(warning.toLatin1().data()); } me = QMouseEvent(QEvent::MouseButtonPress, pos, window1->mapToGlobal(pos), Qt::LeftButton, 0, Qt::NoModifier); QSpontaneKeyEvent::setSpontaneous(&me); - if (!qApp->notify(window1, &me)) { + if (!qApp->notify(window1.data(), &me)) { QString warning = QString::fromLatin1("Mouse event MouseRelease not accepted by receiving window"); QWARN(warning.toLatin1().data()); } - QTRY_VERIFY(QGuiApplication::focusWindow() == windows.at(0)); + QTRY_COMPARE(QGuiApplication::focusWindow(), windows.at(0)); QVERIFY(windows.at(0)->isActive()); - delete window1; } void tst_qquickwindow::testWindowVisibilityOrder() @@ -1688,12 +1723,13 @@ void tst_qquickwindow::testWindowVisibilityOrder() QQmlEngine engine; QQmlComponent component(&engine); component.loadUrl(testFileUrl("windoworder.qml")); - QQuickWindow *window1 = qobject_cast<QQuickWindow *>(component.create()); + QScopedPointer<QQuickWindow> window1(qobject_cast<QQuickWindow *>(component.create())); + QVERIFY(!window1.isNull()); + window1->setTitle(QTest::currentTestFunction()); QQuickWindow *window2 = window1->property("win2").value<QQuickWindow*>(); QQuickWindow *window3 = window1->property("win3").value<QQuickWindow*>(); QQuickWindow *window4 = window1->property("win4").value<QQuickWindow*>(); QQuickWindow *window5 = window1->property("win5").value<QQuickWindow*>(); - QVERIFY(window1); QVERIFY(window2); QVERIFY(window3); @@ -1702,7 +1738,7 @@ void tst_qquickwindow::testWindowVisibilityOrder() QWindowList windows = QGuiApplication::topLevelWindows(); QTRY_COMPARE(windows.size(), 5); - QVERIFY(window3 == QGuiApplication::focusWindow()); + QCOMPARE(window3, QGuiApplication::focusWindow()); QVERIFY(window1->isActive()); QVERIFY(window2->isActive()); QVERIFY(window3->isActive()); @@ -1721,10 +1757,10 @@ void tst_qquickwindow::testWindowVisibilityOrder() window5->hide(); window3->hide(); - QTRY_COMPARE(window2 == QGuiApplication::focusWindow(), true); + QTRY_COMPARE(window2, QGuiApplication::focusWindow()); window2->hide(); - QTRY_COMPARE(window1 == QGuiApplication::focusWindow(), true); + QTRY_COMPARE(window1.data(), QGuiApplication::focusWindow()); } void tst_qquickwindow::blockClosing() @@ -1732,17 +1768,18 @@ void tst_qquickwindow::blockClosing() QQmlEngine engine; QQmlComponent component(&engine); component.loadUrl(testFileUrl("ucantclosethis.qml")); - QQuickWindow *window = qobject_cast<QQuickWindow *>(component.create()); - QVERIFY(window); + QScopedPointer<QQuickWindow> window(qobject_cast<QQuickWindow *>(component.create())); + QVERIFY(!window.isNull()); + window->setTitle(QTest::currentTestFunction()); window->show(); - QTest::qWaitForWindowExposed(window); + QTest::qWaitForWindowExposed(window.data()); QVERIFY(window->isVisible()); - QWindowSystemInterface::handleCloseEvent(window); + QWindowSystemInterface::handleCloseEvent(window.data()); QVERIFY(window->isVisible()); - QWindowSystemInterface::handleCloseEvent(window); + QWindowSystemInterface::handleCloseEvent(window.data()); QVERIFY(window->isVisible()); window->setProperty("canCloseThis", true); - QWindowSystemInterface::handleCloseEvent(window); + QWindowSystemInterface::handleCloseEvent(window.data()); QTRY_VERIFY(!window->isVisible()); } @@ -1751,17 +1788,18 @@ void tst_qquickwindow::blockCloseMethod() QQmlEngine engine; QQmlComponent component(&engine); component.loadUrl(testFileUrl("ucantclosethis.qml")); - QQuickWindow *window = qobject_cast<QQuickWindow *>(component.create()); - QVERIFY(window); + QScopedPointer<QQuickWindow> window(qobject_cast<QQuickWindow *>(component.create())); + QVERIFY(!window.isNull()); + window->setTitle(QTest::currentTestFunction()); window->show(); - QTest::qWaitForWindowExposed(window); + QTest::qWaitForWindowExposed(window.data()); QVERIFY(window->isVisible()); - QVERIFY(QMetaObject::invokeMethod(window, "close", Qt::DirectConnection)); + QVERIFY(QMetaObject::invokeMethod(window.data(), "close", Qt::DirectConnection)); QVERIFY(window->isVisible()); - QVERIFY(QMetaObject::invokeMethod(window, "close", Qt::DirectConnection)); + QVERIFY(QMetaObject::invokeMethod(window.data(), "close", Qt::DirectConnection)); QVERIFY(window->isVisible()); window->setProperty("canCloseThis", true); - QVERIFY(QMetaObject::invokeMethod(window, "close", Qt::DirectConnection)); + QVERIFY(QMetaObject::invokeMethod(window.data(), "close", Qt::DirectConnection)); QTRY_VERIFY(!window->isVisible()); } @@ -1771,15 +1809,16 @@ void tst_qquickwindow::crashWhenHoverItemDeleted() QQmlEngine engine; QQmlComponent component(&engine); component.loadUrl(testFileUrl("hoverCrash.qml")); - QQuickWindow *window = qobject_cast<QQuickWindow *>(component.create()); - QVERIFY(window); + QScopedPointer<QQuickWindow> window(qobject_cast<QQuickWindow *>(component.create())); + QVERIFY(!window.isNull()); + window->setTitle(QTest::currentTestFunction()); window->show(); - QTest::qWaitForWindowActive(window); + QTest::qWaitForWindowActive(window.data()); // Simulate a move from the first rectangle to the second. Crash will happen in here // Moving instantaneously from (0, 99) to (0, 102) does not cause the crash for (int i = 99; i < 102; ++i) { - QTest::mouseMove(window, QPoint(0, i)); + QTest::mouseMove(window.data(), QPoint(0, i)); } } @@ -1789,10 +1828,11 @@ void tst_qquickwindow::unloadSubWindow() QQmlEngine engine; QQmlComponent component(&engine); component.loadUrl(testFileUrl("unloadSubWindow.qml")); - QQuickWindow *window = qobject_cast<QQuickWindow *>(component.create()); - QVERIFY(window); + QScopedPointer<QQuickWindow> window(qobject_cast<QQuickWindow *>(component.create())); + QVERIFY(!window.isNull()); + window->setTitle(QTest::currentTestFunction()); window->show(); - QTest::qWaitForWindowExposed(window); + QTest::qWaitForWindowExposed(window.data()); QPointer<QQuickWindow> transient; QTRY_VERIFY(transient = window->property("transientWindow").value<QQuickWindow*>()); QTest::qWaitForWindowExposed(transient); @@ -1810,6 +1850,7 @@ void tst_qquickwindow::qobjectEventFilter_touch() window.resize(250, 250); window.setPosition(100, 100); + window.setTitle(QTest::currentTestFunction()); window.show(); QVERIFY(QTest::qWaitForWindowActive(&window)); @@ -1835,6 +1876,7 @@ void tst_qquickwindow::qobjectEventFilter_key() window.resize(250, 250); window.setPosition(100, 100); + window.setTitle(QTest::currentTestFunction()); window.show(); QVERIFY(QTest::qWaitForWindowExposed(&window)); @@ -1863,6 +1905,7 @@ void tst_qquickwindow::qobjectEventFilter_mouse() window.resize(250, 250); window.setPosition(100, 100); + window.setTitle(QTest::currentTestFunction()); window.show(); QVERIFY(QTest::qWaitForWindowActive(&window)); @@ -1884,6 +1927,7 @@ void tst_qquickwindow::qobjectEventFilter_mouse() void tst_qquickwindow::animatingSignal() { QQuickWindow window; + window.setTitle(QTest::currentTestFunction()); window.setGeometry(100, 100, 300, 200); QSignalSpy spy(&window, SIGNAL(afterAnimating())); @@ -1898,6 +1942,7 @@ void tst_qquickwindow::animatingSignal() void tst_qquickwindow::contentItemSize() { QQuickWindow window; + window.setTitle(QTest::currentTestFunction()); QQuickItem *contentItem = window.contentItem(); QVERIFY(contentItem); QCOMPARE(QSize(contentItem->width(), contentItem->height()), window.size()); @@ -1951,6 +1996,7 @@ void tst_qquickwindow::defaultSurfaceFormat() QSurfaceFormat::setDefaultFormat(format); QQuickWindow window; + window.setTitle(QTest::currentTestFunction()); window.show(); QVERIFY(QTest::qWaitForWindowExposed(&window)); @@ -1974,6 +2020,7 @@ void tst_qquickwindow::defaultSurfaceFormat() void tst_qquickwindow::attachedProperty() { QQuickView view(testFileUrl("windowattached.qml")); + view.setTitle(QTest::currentTestFunction()); view.show(); view.requestActivate(); QVERIFY(QTest::qWaitForWindowActive(&view)); @@ -2049,6 +2096,7 @@ void tst_qquickwindow::testRenderJob() { QQuickWindow window; + window.setTitle(QTest::currentTestFunction()); RenderJob::deleted = 0; // Schedule the jobs @@ -2165,6 +2213,7 @@ void tst_qquickwindow::testHoverChildMouseEventFilter() window.resize(250, 250); window.setPosition(100, 100); + window.setTitle(QTest::currentTestFunction()); window.show(); QVERIFY(QTest::qWaitForWindowActive(&window)); @@ -2190,15 +2239,15 @@ void tst_qquickwindow::testHoverChildMouseEventFilter() QTest::mouseMove(&window, pos); QTRY_VERIFY(bottomItem->eventCount(QEvent::HoverEnter) > 0); - QVERIFY(bottomItem->childMouseEventFilterEventCount(QEvent::HoverEnter) == 0); - QVERIFY(middleItem->eventCount(QEvent::HoverEnter) == 0); - QVERIFY(topItem->eventCount(QEvent::HoverEnter) == 0); + QCOMPARE(bottomItem->childMouseEventFilterEventCount(QEvent::HoverEnter), 0); + QCOMPARE(middleItem->eventCount(QEvent::HoverEnter), 0); + QCOMPARE(topItem->eventCount(QEvent::HoverEnter), 0); bottomItem->reset(); pos = QPoint(60, 60); QTest::mouseMove(&window, pos); QTRY_VERIFY(middleItem->eventCount(QEvent::HoverEnter) > 0); - QVERIFY(bottomItem->childMouseEventFilterEventCount(QEvent::HoverEnter) == 0); + QCOMPARE(bottomItem->childMouseEventFilterEventCount(QEvent::HoverEnter), 0); middleItem->reset(); pos = QPoint(70,70); @@ -2206,7 +2255,7 @@ void tst_qquickwindow::testHoverChildMouseEventFilter() QTest::mouseMove(&window, pos); QTRY_VERIFY(middleItem->eventCount(QEvent::HoverMove) > 0); QVERIFY(bottomItem->childMouseEventFilterEventCount(QEvent::HoverMove) > 0); - QVERIFY(topItem->eventCount(QEvent::HoverEnter) == 0); + QCOMPARE(topItem->eventCount(QEvent::HoverEnter), 0); bottomItem->reset(); middleItem->reset(); @@ -2214,8 +2263,8 @@ void tst_qquickwindow::testHoverChildMouseEventFilter() bottomItem->addFilterEvent(QEvent::HoverEnter); QTest::mouseMove(&window, pos); QTRY_VERIFY(bottomItem->childMouseEventFilterEventCount(QEvent::HoverEnter) > 0); - QVERIFY(topItem->eventCount(QEvent::HoverEnter) == 0); - QVERIFY(middleItem->eventCount(QEvent::HoverEnter) == 0); + QCOMPARE(topItem->eventCount(QEvent::HoverEnter), 0); + QCOMPARE(middleItem->eventCount(QEvent::HoverEnter), 0); } QTEST_MAIN(tst_qquickwindow) diff --git a/tests/auto/quick/shared/viewtestutil.cpp b/tests/auto/quick/shared/viewtestutil.cpp index 24e565012e..5b9111d448 100644 --- a/tests/auto/quick/shared/viewtestutil.cpp +++ b/tests/auto/quick/shared/viewtestutil.cpp @@ -350,9 +350,7 @@ namespace QQuickTouchUtils { QQuickWindowPrivate *wd = QQuickWindowPrivate::get(window); if (!wd || !wd->delayedTouch) return; - wd->reallyDeliverTouchEvent(wd->delayedTouch); - delete wd->delayedTouch; - wd->delayedTouch = 0; + wd->deliverDelayedTouchEvent(); } } |