diff options
Diffstat (limited to 'tests/auto')
15 files changed, 352 insertions, 22 deletions
diff --git a/tests/auto/qml/debugger/qqmldebugjs/tst_qqmldebugjs.cpp b/tests/auto/qml/debugger/qqmldebugjs/tst_qqmldebugjs.cpp index f8fa6e6716..1ac28c473b 100644 --- a/tests/auto/qml/debugger/qqmldebugjs/tst_qqmldebugjs.cpp +++ b/tests/auto/qml/debugger/qqmldebugjs/tst_qqmldebugjs.cpp @@ -527,7 +527,7 @@ void tst_QQmlDebugJS::changeBreakpoint() QCOMPARE(init(qmlscene, CHANGEBREAKPOINT_QMLFILE), ConnectSuccess); bool isStopped = false; - QObject::connect(m_client, &QV4DebugClient::stopped, this, [&]() { isStopped = true; }); + QObject::connect(m_client.data(), &QV4DebugClient::stopped, this, [&]() { isStopped = true; }); auto continueDebugging = [&]() { m_client->continueDebugging(QV4DebugClient::Continue); @@ -549,7 +549,7 @@ void tst_QQmlDebugJS::changeBreakpoint() auto setBreakPoint = [&](int sourceLine, bool enabled) { int id = -1; - auto connection = QObject::connect(m_client, &QV4DebugClient::result, [&]() { + auto connection = QObject::connect(m_client.data(), &QV4DebugClient::result, [&]() { id = extractBody().value("breakpoint").toInt(); }); @@ -888,7 +888,7 @@ void tst_QQmlDebugJS::encodeQmlScope() bool isStopped = false; bool scopesFailed = false; - QObject::connect(m_client, &QV4DebugClient::failure, this, [&]() { + QObject::connect(m_client.data(), &QV4DebugClient::failure, this, [&]() { qWarning() << "received failure" << m_client->response().body; scopesFailed = true; m_process->stop(); @@ -896,12 +896,12 @@ void tst_QQmlDebugJS::encodeQmlScope() isStopped = false; }); - QObject::connect(m_client, &QV4DebugClient::stopped, this, [&]() { + QObject::connect(m_client.data(), &QV4DebugClient::stopped, this, [&]() { m_client->frame(); isStopped = true; }); - QObject::connect(m_client, &QV4DebugClient::result, this, [&]() { + QObject::connect(m_client.data(), &QV4DebugClient::result, this, [&]() { const QV4DebugClient::Response value = m_client->response(); if (value.command == QString("scope")) { @@ -944,20 +944,20 @@ void tst_QQmlDebugJS::breakOnAnchor() int breaks = 0; bool stopped = false; - QObject::connect(m_client, &QV4DebugClient::stopped, this, [&]() { + QObject::connect(m_client.data(), &QV4DebugClient::stopped, this, [&]() { stopped = true; ++breaks; m_client->evaluate("this", 0, -1); }); - QObject::connect(m_client, &QV4DebugClient::result, this, [&]() { + QObject::connect(m_client.data(), &QV4DebugClient::result, this, [&]() { if (stopped) { m_client->continueDebugging(QV4DebugClient::Continue); stopped = false; } }); - QObject::connect(m_client, &QV4DebugClient::failure, this, [&]() { + QObject::connect(m_client.data(), &QV4DebugClient::failure, this, [&]() { qWarning() << "received failure" << m_client->response().body; }); diff --git a/tests/auto/qml/debugger/qqmlpreview/tst_qqmlpreview.cpp b/tests/auto/qml/debugger/qqmlpreview/tst_qqmlpreview.cpp index b4f8f389cf..4c4c514832 100644 --- a/tests/auto/qml/debugger/qqmlpreview/tst_qqmlpreview.cpp +++ b/tests/auto/qml/debugger/qqmlpreview/tst_qqmlpreview.cpp @@ -101,11 +101,11 @@ QList<QQmlDebugClient *> tst_QQmlPreview::createClients() { m_client = new QQmlPreviewClient(m_connection); - QObject::connect(m_client, &QQmlPreviewClient::request, this, &tst_QQmlPreview::serveRequest); - QObject::connect(m_client, &QQmlPreviewClient::error, this, [this](const QString &error) { + QObject::connect(m_client.data(), &QQmlPreviewClient::request, this, &tst_QQmlPreview::serveRequest); + QObject::connect(m_client.data(), &QQmlPreviewClient::error, this, [this](const QString &error) { m_serviceErrors.append(error); }); - QObject::connect(m_client, &QQmlPreviewClient::fps, + QObject::connect(m_client.data(), &QQmlPreviewClient::fps, this, [this](const QQmlPreviewClient::FpsInfo &info) { m_frameStats = info; }); diff --git a/tests/auto/qml/debugger/qqmlprofilerservice/tst_qqmlprofilerservice.cpp b/tests/auto/qml/debugger/qqmlprofilerservice/tst_qqmlprofilerservice.cpp index 3337e6d3fd..085eb7b87a 100644 --- a/tests/auto/qml/debugger/qqmlprofilerservice/tst_qqmlprofilerservice.cpp +++ b/tests/auto/qml/debugger/qqmlprofilerservice/tst_qqmlprofilerservice.cpp @@ -468,7 +468,7 @@ QList<QQmlDebugClient *> tst_QQmlProfilerService::createClients() m_client.reset(new QQmlProfilerTestClient(m_connection)); m_client->client->setRecording(m_recordFromStart); m_client->client->setFlushInterval(m_flushInterval); - QObject::connect(m_client->client, &QQmlProfilerClient::complete, + QObject::connect(m_client->client.data(), &QQmlProfilerClient::complete, this, [this](){ m_isComplete = true; }); return QList<QQmlDebugClient *>({m_client->client}); } diff --git a/tests/auto/qml/qqmlcontext/data/MyItem.qml b/tests/auto/qml/qqmlcontext/data/MyItem.qml new file mode 100644 index 0000000000..2ffd984dfa --- /dev/null +++ b/tests/auto/qml/qqmlcontext/data/MyItem.qml @@ -0,0 +1,5 @@ +import QtQuick 2.0 + +QtObject { + Component.onCompleted: 5 + 5 +} diff --git a/tests/auto/qml/qqmlcontext/data/outerContextObject.qml b/tests/auto/qml/qqmlcontext/data/outerContextObject.qml new file mode 100644 index 0000000000..992b760915 --- /dev/null +++ b/tests/auto/qml/qqmlcontext/data/outerContextObject.qml @@ -0,0 +1,18 @@ +import QtQml 2.2 + +QtObject { + id: window + + property Component itemComponent: Qt.createComponent("MyItem.qml") + property MyItem item + + property Timer timer: Timer { + running: true + interval: 10 + repeat: true + onTriggered: { + item = itemComponent.createObject(null, {}); + gc(); + } + } +} diff --git a/tests/auto/qml/qqmlcontext/tst_qqmlcontext.cpp b/tests/auto/qml/qqmlcontext/tst_qqmlcontext.cpp index 990e364c76..5838193a6b 100644 --- a/tests/auto/qml/qqmlcontext/tst_qqmlcontext.cpp +++ b/tests/auto/qml/qqmlcontext/tst_qqmlcontext.cpp @@ -28,6 +28,7 @@ #include <qtest.h> #include <QDebug> +#include <QTimer> #include <QQmlEngine> #include <QQmlContext> #include <QQmlComponent> @@ -68,6 +69,8 @@ private slots: void contextViaClosureAfterDestruction(); void contextLeak(); + void outerContextObject(); + private: QQmlEngine engine; }; @@ -815,6 +818,61 @@ void tst_qqmlcontext::contextLeak() QVERIFY(scriptContext.isNull()); } + +static bool buildObjectList(QQmlContext *ctxt) +{ + static QHash<QObject *, QString> deletedObjects; + QQmlContextData *p = QQmlContextData::get(ctxt); + QObject *object = p->contextObject; + if (object) { + // If the object was actually deleted this is likely to crash in one way or another. + // Either the memory is still intact, then we will probably find the objectName, or it is + // not, then the connect() below is likely to fail. + if (deletedObjects.contains(object) && deletedObjects[object] == object->objectName()) + return false; + QObject::connect(object, &QObject::destroyed, [object]() { + object->setObjectName(QString::number(deletedObjects.size())); + deletedObjects.insert(object, object->objectName()); + }); + } + + QQmlContextData *child = p->childContexts; + while (child) { + if (!buildObjectList(child->asQQmlContext())) + return false; + child = child->nextChild; + } + + return true; +} + +void tst_qqmlcontext::outerContextObject() +{ + QQmlEngine engine; + + QQmlComponent component(&engine, testFileUrl("outerContextObject.qml")); + QVERIFY(component.isReady()); + + QScopedPointer<QObject> object(component.create()); + QVERIFY(!object.isNull()); + + int iterations = 0; + QTimer timer; + timer.setInterval(1); + QObject::connect(&timer, &QTimer::timeout, &engine, [&]() { + if (!buildObjectList(engine.rootContext())) { + iterations = 100; + timer.stop(); + QFAIL("Deleted object found as context object"); + } else { + ++iterations; + } + }); + timer.start(); + + QTRY_VERIFY(iterations >= 100); +} + QTEST_MAIN(tst_qqmlcontext) #include "tst_qqmlcontext.moc" diff --git a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp index 71c4e03812..254a6bc878 100644 --- a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp +++ b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp @@ -360,6 +360,7 @@ private slots: void importLexicalVariables_data(); void importLexicalVariables(); void hugeObject(); + void templateStringTerminator(); private: // static void propertyVarWeakRefCallback(v8::Persistent<v8::Value> object, void* parameter); @@ -8858,6 +8859,14 @@ void tst_qqmlecmascript::hugeObject() QVERIFY(!v.isError()); } +void tst_qqmlecmascript::templateStringTerminator() +{ + QJSEngine engine; + const QJSValue value = engine.evaluate("let a = 123; let b = `x${a}\ny^`; b;"); + QVERIFY(!value.isError()); + QCOMPARE(value.toString(), QLatin1String("x123\ny^")); +} + QTEST_MAIN(tst_qqmlecmascript) #include "tst_qqmlecmascript.moc" diff --git a/tests/auto/quick/pointerhandlers/qquickpointerhandler/data/dynamicallyCreated.qml b/tests/auto/quick/pointerhandlers/qquickpointerhandler/data/dynamicallyCreated.qml new file mode 100644 index 0000000000..8f774a7ec3 --- /dev/null +++ b/tests/auto/quick/pointerhandlers/qquickpointerhandler/data/dynamicallyCreated.qml @@ -0,0 +1,34 @@ +import QtQuick 2.12 +import Qt.test 1.0 + +Item { + id: root + objectName: "root Item" + width: 320 + height: 480 + + Rectangle { + objectName: "eventItem's bounds" + anchors.fill: eventItem + color: "lightsteelblue" + } + + EventItem { + id: eventItem + objectName: "eventItem1" + x: 5 + y: 5 + height: 30 + width: 30 + + Component.onCompleted: handlerComponent.createObject(eventItem) + + Component { + id: handlerComponent + + EventHandler { + objectName: "eventHandler" + } + } + } +} diff --git a/tests/auto/quick/pointerhandlers/qquickpointerhandler/data/dynamicallyCreatedInWindow.qml b/tests/auto/quick/pointerhandlers/qquickpointerhandler/data/dynamicallyCreatedInWindow.qml new file mode 100644 index 0000000000..058726b267 --- /dev/null +++ b/tests/auto/quick/pointerhandlers/qquickpointerhandler/data/dynamicallyCreatedInWindow.qml @@ -0,0 +1,20 @@ +import QtQuick 2.12 +import QtQuick.Window 2.12 +import Qt.test 1.0 + +Window { + id: root + objectName: "root Window" + width: 320 + height: 480 + + Component.onCompleted: handlerComponent.createObject(root) + + Component { + id: handlerComponent + + EventHandler { + objectName: "eventHandler" + } + } +} diff --git a/tests/auto/quick/pointerhandlers/qquickpointerhandler/data/handlerInWindow.qml b/tests/auto/quick/pointerhandlers/qquickpointerhandler/data/handlerInWindow.qml new file mode 100644 index 0000000000..49ec9be4a7 --- /dev/null +++ b/tests/auto/quick/pointerhandlers/qquickpointerhandler/data/handlerInWindow.qml @@ -0,0 +1,14 @@ +import QtQuick 2.12 +import QtQuick.Window 2.12 +import Qt.test 1.0 + +Window { + id: root + objectName: "root Window" + width: 320 + height: 480 + + EventHandler { + objectName: "eventHandler" + } +} diff --git a/tests/auto/quick/pointerhandlers/qquickpointerhandler/tst_qquickpointerhandler.cpp b/tests/auto/quick/pointerhandlers/qquickpointerhandler/tst_qquickpointerhandler.cpp index e8b076052a..feb356a7d5 100644 --- a/tests/auto/quick/pointerhandlers/qquickpointerhandler/tst_qquickpointerhandler.cpp +++ b/tests/auto/quick/pointerhandlers/qquickpointerhandler/tst_qquickpointerhandler.cpp @@ -182,12 +182,18 @@ public: class EventHandler : public QQuickPointerHandler { +public: void handlePointerEventImpl(QQuickPointerEvent *event) override { QQuickPointerHandler::handlePointerEventImpl(event); if (!enabled()) return; - EventItem *item = static_cast<EventItem *>(target()); + ++eventCount; + EventItem *item = qmlobject_cast<EventItem *>(target()); + if (!item) { + event->point(0)->setGrabberPointerHandler(this); + return; + } qCDebug(lcPointerTests) << item->objectName() << event; int c = event->pointCount(); for (int i = 0; i < c; ++i) { @@ -206,10 +212,13 @@ class EventHandler : public QQuickPointerHandler void onGrabChanged(QQuickPointerHandler *, QQuickEventPoint::GrabTransition stateChange, QQuickEventPoint *point) override { - EventItem *item = static_cast<EventItem *>(target()); - item->eventList.append(Event(Event::HandlerDestination, QEvent::None, - static_cast<Qt::TouchPointState>(point->state()), stateChange, eventPos(point), point->scenePosition())); + EventItem *item = qmlobject_cast<EventItem *>(target()); + if (item) + item->eventList.append(Event(Event::HandlerDestination, QEvent::None, + static_cast<Qt::TouchPointState>(point->state()), stateChange, eventPos(point), point->scenePosition())); } + + int eventCount = 0; }; class tst_PointerHandlers : public QQmlDataTest @@ -228,6 +237,9 @@ private slots: void mouseEventDelivery(); void touchReleaseOutside_data(); void touchReleaseOutside(); + void dynamicCreation(); + void handlerInWindow(); + void dynamicCreationInWindow(); protected: bool eventFilter(QObject *, QEvent *event) @@ -593,6 +605,76 @@ void tst_PointerHandlers::touchReleaseOutside() QCOMPARE_EVENT(endIndexToTest, endDestination, endType, endState, endGrabState); } +void tst_PointerHandlers::dynamicCreation() +{ + QScopedPointer<QQuickView> windowPtr; + createView(windowPtr, "dynamicallyCreated.qml"); + QQuickView * window = windowPtr.data(); + + EventItem *eventItem1 = window->rootObject()->findChild<EventItem*>("eventItem1"); + QVERIFY(eventItem1); + EventHandler *handler = window->rootObject()->findChild<EventHandler*>("eventHandler"); + QVERIFY(handler); + + QCOMPARE(handler->parentItem(), eventItem1); + QCOMPARE(handler->target(), eventItem1); + + QPoint p1(20, 20); + QTest::mousePress(window, Qt::LeftButton, Qt::NoModifier, p1); + QTRY_COMPARE(eventItem1->eventList.size(), 2); + QCOMPARE_EVENT(0, Event::HandlerDestination, QEvent::Pointer, Qt::TouchPointPressed, NoGrab); + QCOMPARE_EVENT(1, Event::MouseDestination, QEvent::MouseButtonPress, Qt::TouchPointPressed, NoGrab); + QTest::mouseRelease(window, Qt::LeftButton, Qt::NoModifier, p1); +} + +void tst_PointerHandlers::handlerInWindow() +{ + QQmlEngine engine; + QQmlComponent component(&engine); + component.loadUrl(testFileUrl("handlerInWindow.qml")); + QQuickWindow *window = qobject_cast<QQuickWindow*>(component.create()); + QScopedPointer<QQuickWindow> cleanup(window); + QVERIFY(window); + window->show(); + QVERIFY(QTest::qWaitForWindowExposed(window)); + + EventHandler *handler = window->contentItem()->findChild<EventHandler*>("eventHandler"); + QVERIFY(handler); + + QCOMPARE(handler->parentItem(), window->contentItem()); + QCOMPARE(handler->target(), window->contentItem()); + + QPoint p1(20, 20); + QTest::mousePress(window, Qt::LeftButton, Qt::NoModifier, p1); + QTRY_COMPARE(handler->eventCount, 1); + QTest::mouseRelease(window, Qt::LeftButton, Qt::NoModifier, p1); + QTRY_COMPARE(handler->eventCount, 2); +} + +void tst_PointerHandlers::dynamicCreationInWindow() +{ + QQmlEngine engine; + QQmlComponent component(&engine); + component.loadUrl(testFileUrl("dynamicallyCreatedInWindow.qml")); + QQuickWindow *window = qobject_cast<QQuickWindow*>(component.create()); + QScopedPointer<QQuickWindow> cleanup(window); + QVERIFY(window); + window->show(); + QVERIFY(QTest::qWaitForWindowExposed(window)); + + EventHandler *handler = window->contentItem()->findChild<EventHandler*>("eventHandler"); + QVERIFY(handler); + + QCOMPARE(handler->parentItem(), window->contentItem()); + QCOMPARE(handler->target(), window->contentItem()); + + QPoint p1(20, 20); + QTest::mousePress(window, Qt::LeftButton, Qt::NoModifier, p1); + QTRY_COMPARE(handler->eventCount, 1); + QTest::mouseRelease(window, Qt::LeftButton, Qt::NoModifier, p1); + QTRY_COMPARE(handler->eventCount, 2); +} + QTEST_MAIN(tst_PointerHandlers) #include "tst_qquickpointerhandler.moc" diff --git a/tests/auto/quick/pointerhandlers/qquicktaphandler/data/rightTapHandler.qml b/tests/auto/quick/pointerhandlers/qquicktaphandler/data/rightTapHandler.qml new file mode 100644 index 0000000000..aea01c154c --- /dev/null +++ b/tests/auto/quick/pointerhandlers/qquicktaphandler/data/rightTapHandler.qml @@ -0,0 +1,41 @@ +/**************************************************************************** +** +** Copyright (C) 2018 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:GPL-EXCEPT$ +** 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 https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.12 + +Rectangle { + width: 320 + height: 240 + color: rightTap.pressed ? "tomato" : "beige" + TapHandler { + id: rightTap + objectName: "right button TapHandler" + longPressThreshold: 0.5 + acceptedButtons: Qt.RightButton + } +} diff --git a/tests/auto/quick/pointerhandlers/qquicktaphandler/tst_qquicktaphandler.cpp b/tests/auto/quick/pointerhandlers/qquicktaphandler/tst_qquicktaphandler.cpp index 467c964001..ab6fa0dbe4 100644 --- a/tests/auto/quick/pointerhandlers/qquicktaphandler/tst_qquicktaphandler.cpp +++ b/tests/auto/quick/pointerhandlers/qquicktaphandler/tst_qquicktaphandler.cpp @@ -69,6 +69,7 @@ private slots: void mouseLongPress(); void buttonsMultiTouch(); void componentUserBehavioralOverride(); + void rightLongPressIgnoreWheel(); private: void createView(QScopedPointer<QQuickView> &window, const char *fileName); @@ -622,6 +623,44 @@ void tst_TapHandler::componentUserBehavioralOverride() QCOMPARE(userGrabChangedSpy.count(), 2); } +void tst_TapHandler::rightLongPressIgnoreWheel() +{ + QScopedPointer<QQuickView> windowPtr; + createView(windowPtr, "rightTapHandler.qml"); + QQuickView * window = windowPtr.data(); + + QQuickTapHandler *tap = window->rootObject()->findChild<QQuickTapHandler*>(); + QVERIFY(tap); + QSignalSpy tappedSpy(tap, SIGNAL(tapped(QQuickEventPoint *))); + QSignalSpy longPressedSpy(tap, SIGNAL(longPressed())); + QPoint p1(100, 100); + + // Mouse wheel with ScrollBegin phase (because as soon as two fingers are touching + // the trackpad, it will send such an event: QTBUG-71955) + { + QWheelEvent wheelEvent(p1, p1, QPoint(0, 0), QPoint(0, 0), + Qt::NoButton, Qt::NoModifier, Qt::ScrollBegin, false, Qt::MouseEventNotSynthesized); + QGuiApplication::sendEvent(window, &wheelEvent); + } + + // Press + QTest::mousePress(window, Qt::RightButton, Qt::NoModifier, p1); + QTRY_COMPARE(tap->isPressed(), true); + + // Mouse wheel ScrollEnd phase + QWheelEvent wheelEvent(p1, p1, QPoint(0, 0), QPoint(0, 0), + Qt::NoButton, Qt::NoModifier, Qt::ScrollEnd, false, Qt::MouseEventNotSynthesized); + QGuiApplication::sendEvent(window, &wheelEvent); + QTRY_COMPARE(longPressedSpy.count(), 1); + QCOMPARE(tap->isPressed(), true); + QCOMPARE(tappedSpy.count(), 0); + + // Release + QTest::mouseRelease(window, Qt::RightButton, Qt::NoModifier, p1, 500); + QTRY_COMPARE(tap->isPressed(), false); + QCOMPARE(tappedSpy.count(), 0); +} + QTEST_MAIN(tst_TapHandler) #include "tst_qquicktaphandler.moc" diff --git a/tests/auto/quick/qquickstyledtext/tst_qquickstyledtext.cpp b/tests/auto/quick/qquickstyledtext/tst_qquickstyledtext.cpp index 6ca5ad2653..88b0e95e0a 100644 --- a/tests/auto/quick/qquickstyledtext/tst_qquickstyledtext.cpp +++ b/tests/auto/quick/qquickstyledtext/tst_qquickstyledtext.cpp @@ -44,7 +44,8 @@ public: Bold = 0x01, Underline = 0x02, Italic = 0x04, - Anchor = 0x08 + Anchor = 0x08, + StrikeOut = 0x10 }; Format(int t, int s, int l) : type(t), start(s), length(l) {} @@ -92,6 +93,10 @@ void tst_qquickstyledtext::textOutput_data() QTest::newRow("underline") << "<u>underline</u>" << "underline" << (FormatList() << Format(Format::Underline, 0, 9)) << false; QTest::newRow("strong") << "<strong>strong</strong>" << "strong" << (FormatList() << Format(Format::Bold, 0, 6)) << false; QTest::newRow("underline") << "<u>underline</u>" << "underline" << (FormatList() << Format(Format::Underline, 0, 9)) << false; + QTest::newRow("strike out s") << "<s>strike out</s>" << "strike out" << (FormatList() << Format(Format::StrikeOut, 0, 10)) << false; + QTest::newRow("strike out del") << "<del>strike out</del>" << "strike out" << (FormatList() << Format(Format::StrikeOut, 0, 10)) << false; + QTest::newRow("strike out not s") << "this is <s>not</s> a test" << "this is not a test" << (FormatList() << Format(Format::StrikeOut, 8, 3)) << false; + QTest::newRow("strike out not del") << "this is <del>not</del> a test" << "this is not a test" << (FormatList() << Format(Format::StrikeOut, 8, 3)) << false; QTest::newRow("missing >") << "<b>text</b" << "text" << (FormatList() << Format(Format::Bold, 0, 4)) << false; QTest::newRow("missing b>") << "<b>text</" << "text" << (FormatList() << Format(Format::Bold, 0, 4)) << false; QTest::newRow("missing /b>") << "<b>text<" << "text" << (FormatList() << Format(Format::Bold, 0, 4)) << false; @@ -178,6 +183,7 @@ void tst_qquickstyledtext::textOutput() QCOMPARE(layoutFormats.at(i).format.fontWeight(), int(QFont::Normal)); QVERIFY(layoutFormats.at(i).format.fontItalic() == bool(formats.at(i).type & Format::Italic)); QVERIFY(layoutFormats.at(i).format.fontUnderline() == bool(formats.at(i).type & Format::Underline)); + QVERIFY(layoutFormats.at(i).format.fontStrikeOut() == bool(formats.at(i).type & Format::StrikeOut)); } QCOMPARE(fontSizeModified, modifiesFontSize); } diff --git a/tests/auto/quickwidgets/qquickwidget/tst_qquickwidget.cpp b/tests/auto/quickwidgets/qquickwidget/tst_qquickwidget.cpp index e523274d0a..24e55e3b3a 100644 --- a/tests/auto/quickwidgets/qquickwidget/tst_qquickwidget.cpp +++ b/tests/auto/quickwidgets/qquickwidget/tst_qquickwidget.cpp @@ -35,6 +35,7 @@ #include <QtQuick/qquickitem.h> #include "../../shared/util.h" #include <QtGui/QWindow> +#include <QtGui/QScreen> #include <QtGui/QImage> #include <QtCore/QDebug> #include <QtQml/qqmlengine.h> @@ -144,6 +145,7 @@ private slots: private: QTouchDevice *device = QTest::createTouchDevice(); + const QRect m_availableGeometry = QGuiApplication::primaryScreen()->availableGeometry(); }; tst_qquickwidget::tst_qquickwidget() @@ -199,7 +201,7 @@ void tst_qquickwidget::changeGeometry() void tst_qquickwidget::resizemodeitem() { QWidget window; - window.setGeometry(0, 0, 400, 400); + window.setGeometry(m_availableGeometry.left(), m_availableGeometry.top(), 400, 400); QScopedPointer<QQuickWidget> view(new QQuickWidget); view->setParent(&window); @@ -533,18 +535,20 @@ void tst_qquickwidget::enterLeave() view.setSource(testFileUrl("enterleave.qml")); // Ensure it is not inside the window first - QCursor::setPos(QPoint(50, 50)); - QTRY_VERIFY(QCursor::pos() == QPoint(50, 50)); + const auto outside = m_availableGeometry.topLeft() + QPoint(50, 50); + QCursor::setPos(outside); + QTRY_VERIFY(QCursor::pos() == outside); - view.move(100, 100); + view.move(m_availableGeometry.topLeft() + QPoint(100, 100)); view.show(); QVERIFY(QTest::qWaitForWindowExposed(&view, 5000)); QQuickItem *rootItem = view.rootObject(); QVERIFY(rootItem); + const QPoint frameOffset = view.geometry().topLeft() - view.frameGeometry().topLeft(); QTRY_VERIFY(!rootItem->property("hasMouse").toBool()); // Check the enter - QCursor::setPos(view.pos() + QPoint(50, 50)); + QCursor::setPos(view.pos() + QPoint(50, 50) + frameOffset); QTRY_VERIFY(rootItem->property("hasMouse").toBool()); // Now check the leave QCursor::setPos(view.pos() - QPoint(50, 50)); |