diff options
Diffstat (limited to 'tests/auto/quick')
25 files changed, 1115 insertions, 346 deletions
diff --git a/tests/auto/quick/examples/tst_examples.cpp b/tests/auto/quick/examples/tst_examples.cpp index 1ca809c05f..d5c9aaeb90 100644 --- a/tests/auto/quick/examples/tst_examples.cpp +++ b/tests/auto/quick/examples/tst_examples.cpp @@ -88,12 +88,6 @@ tst_examples::tst_examples() excludedDirs << "snippets/qml/qtbinding"; excludedDirs << "snippets/qml/imports"; -#ifdef QT_NO_WEBKIT - excludedDirs << "qtquick/modelviews/webview"; - excludedDirs << "demos/webbrowser"; - excludedDirs << "doc/src/snippets/qml/webview"; -#endif - #ifdef QT_NO_XMLPATTERNS excludedDirs << "demos/twitter"; excludedDirs << "demos/flickr"; diff --git a/tests/auto/quick/qquickanimations/data/pathLineUnspecifiedXYBug.qml b/tests/auto/quick/qquickanimations/data/pathLineUnspecifiedXYBug.qml new file mode 100644 index 0000000000..426360bbcc --- /dev/null +++ b/tests/auto/quick/qquickanimations/data/pathLineUnspecifiedXYBug.qml @@ -0,0 +1,28 @@ +import QtQuick 2.0 + +Rectangle { + width: 400 + height: 400 + + Rectangle { + id: redRect + color: "red" + width: 100; height: 100 + x: 50; y: 50 + } + + PathAnimation { + target: redRect + duration: 1000 + path: Path { + startX: 100; startY: 100 + + PathLine { + x: 200 + y: 200 + } + + PathLine {} + } + } +} diff --git a/tests/auto/quick/qquickanimations/data/pathSvgAnimation.qml b/tests/auto/quick/qquickanimations/data/pathSvgAnimation.qml new file mode 100644 index 0000000000..e409bb031f --- /dev/null +++ b/tests/auto/quick/qquickanimations/data/pathSvgAnimation.qml @@ -0,0 +1,25 @@ +import QtQuick 2.0 + +Rectangle { + width: 400 + height: 400 + + Rectangle { + id: redRect + color: "red" + width: 100; height: 100 + x: 50; y: 50 + } + + PathAnimation { + target: redRect + duration: 1000; + path: Path { + startX: 100; startY: 100 + + PathSvg { + path: "M 200 200" + } + } + } +} diff --git a/tests/auto/quick/qquickanimations/tst_qquickanimations.cpp b/tests/auto/quick/qquickanimations/tst_qquickanimations.cpp index 6e265503a1..fbd6c9c97e 100644 --- a/tests/auto/quick/qquickanimations/tst_qquickanimations.cpp +++ b/tests/auto/quick/qquickanimations/tst_qquickanimations.cpp @@ -101,6 +101,8 @@ private slots: void scriptActionCrash(); void animatorInvalidTargetCrash(); void defaultPropertyWarning(); + void pathSvgAnimation(); + void pathLineUnspecifiedXYBug(); }; #define QTIMED_COMPARE(lhs, rhs) do { \ @@ -1523,6 +1525,48 @@ void tst_qquickanimations::defaultPropertyWarning() QVERIFY(warnings.isEmpty()); } +// QTBUG-57666 +void tst_qquickanimations::pathSvgAnimation() +{ + QQmlEngine engine; + QQmlComponent component(&engine, testFileUrl("pathSvgAnimation.qml")); + QScopedPointer<QQuickRectangle> rect(qobject_cast<QQuickRectangle*>(component.create())); + QVERIFY(rect); + + QQuickRectangle *redRect = rect->findChild<QQuickRectangle*>(); + QVERIFY(redRect); + QQuickPathAnimation *pathAnim = rect->findChild<QQuickPathAnimation*>(); + QVERIFY(pathAnim); + + QCOMPARE(redRect->x(), qreal(50)); + QCOMPARE(redRect->y(), qreal(50)); + + pathAnim->start(); + QTRY_COMPARE(redRect->x(), qreal(200)); + QCOMPARE(redRect->y(), qreal(200)); +} + +// QTBUG-57666 +void tst_qquickanimations::pathLineUnspecifiedXYBug() +{ + QQmlEngine engine; + QQmlComponent component(&engine, testFileUrl("pathLineUnspecifiedXYBug.qml")); + QScopedPointer<QQuickRectangle> rect(qobject_cast<QQuickRectangle*>(component.create())); + QVERIFY(rect); + + QQuickRectangle *redRect = rect->findChild<QQuickRectangle*>(); + QVERIFY(redRect); + QQuickPathAnimation *pathAnim = rect->findChild<QQuickPathAnimation*>(); + QVERIFY(pathAnim); + + QCOMPARE(redRect->x(), qreal(50)); + QCOMPARE(redRect->y(), qreal(50)); + + pathAnim->start(); + QTRY_COMPARE(redRect->x(), qreal(0)); + QCOMPARE(redRect->y(), qreal(0)); +} + QTEST_MAIN(tst_qquickanimations) #include "tst_qquickanimations.moc" diff --git a/tests/auto/quick/qquickflickable/data/overshoot.qml b/tests/auto/quick/qquickflickable/data/overshoot.qml new file mode 100644 index 0000000000..4235156479 --- /dev/null +++ b/tests/auto/quick/qquickflickable/data/overshoot.qml @@ -0,0 +1,79 @@ +/**************************************************************************** +** +** Copyright (C) 2016 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.9 + +Flickable { + width: 200; height: 200 + contentWidth: rect.width; contentHeight: rect.height + + property real minContentY: 0 + property real maxContentY: 0 + onContentYChanged: { + minContentY = Math.min(contentY, minContentY) + maxContentY = Math.max(contentY, maxContentY) + } + + property real minContentX: 0 + property real maxContentX: 0 + onContentXChanged: { + minContentX = Math.min(contentX, minContentX) + maxContentX = Math.max(contentX, maxContentX) + } + + property real minVerticalOvershoot: 0 + property real maxVerticalOvershoot: 0 + onVerticalOvershootChanged: { + minVerticalOvershoot = Math.min(verticalOvershoot, minVerticalOvershoot) + maxVerticalOvershoot = Math.max(verticalOvershoot, maxVerticalOvershoot) + } + + property real minHorizontalOvershoot: 0 + property real maxHorizontalOvershoot: 0 + onHorizontalOvershootChanged: { + minHorizontalOvershoot = Math.min(horizontalOvershoot, minHorizontalOvershoot) + maxHorizontalOvershoot = Math.max(horizontalOvershoot, maxHorizontalOvershoot) + } + + function reset() { + minContentY = contentY + maxContentY = contentY + minContentX = contentX + maxContentX = contentX + minVerticalOvershoot = 0 + maxVerticalOvershoot = 0 + minHorizontalOvershoot = 0 + maxHorizontalOvershoot = 0 + } + + Rectangle { + id: rect + color: "red" + width: 400; height: 400 + } +} diff --git a/tests/auto/quick/qquickflickable/data/overshoot_reentrant.qml b/tests/auto/quick/qquickflickable/data/overshoot_reentrant.qml new file mode 100644 index 0000000000..bc7abba25a --- /dev/null +++ b/tests/auto/quick/qquickflickable/data/overshoot_reentrant.qml @@ -0,0 +1,55 @@ +/**************************************************************************** +** +** Copyright (C) 2016 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.9 + +Flickable { + width: 200; height: 200 + contentWidth: rect.width; contentHeight: rect.height + + property real contentPosAdjustment: 0.0 + + onContentXChanged: { + var adjustment = contentPosAdjustment + contentPosAdjustment = 0.0 + contentX += adjustment + } + + onContentYChanged: { + var adjustment = contentPosAdjustment + contentPosAdjustment = 0.0 + contentY += adjustment + } + + Rectangle { + id: rect + border.color: "red" + border.width: 5 + width: 400; height: 400 + } +} diff --git a/tests/auto/quick/qquickflickable/tst_qquickflickable.cpp b/tests/auto/quick/qquickflickable/tst_qquickflickable.cpp index 942e99018f..1ad691d1c1 100644 --- a/tests/auto/quick/qquickflickable/tst_qquickflickable.cpp +++ b/tests/auto/quick/qquickflickable/tst_qquickflickable.cpp @@ -95,6 +95,9 @@ private slots: void ratios_smallContent(); void contentXYNotTruncatedToInt(); void keepGrab(); + void overshoot(); + void overshoot_data(); + void overshoot_reentrant(); private: void flickWithTouch(QQuickWindow *window, QTouchDevice *touchDevice, const QPoint &from, const QPoint &to); @@ -2037,6 +2040,199 @@ void tst_qquickflickable::keepGrab() QVERIFY(flickable->contentY() != 0.0); } +Q_DECLARE_METATYPE(QQuickFlickable::BoundsBehavior) + +void tst_qquickflickable::overshoot() +{ + QFETCH(QQuickFlickable::BoundsBehavior, boundsBehavior); + + QScopedPointer<QQuickView> window(new QQuickView); + window->setSource(testFileUrl("overshoot.qml")); + window->show(); + + QVERIFY(QTest::qWaitForWindowExposed(window.data())); + + QQuickFlickable *flickable = qobject_cast<QQuickFlickable*>(window->rootObject()); + QVERIFY(flickable); + + QCOMPARE(flickable->width(), 200.0); + QCOMPARE(flickable->height(), 200.0); + QCOMPARE(flickable->contentWidth(), 400.0); + QCOMPARE(flickable->contentHeight(), 400.0); + + flickable->setBoundsBehavior(boundsBehavior); + + // drag past the beginning + QTest::mousePress(window.data(), Qt::LeftButton, 0, QPoint(10, 10)); + QTest::mouseMove(window.data(), QPoint(20, 20)); + QTest::mouseMove(window.data(), QPoint(30, 30)); + QTest::mouseMove(window.data(), QPoint(40, 40)); + QTest::mouseRelease(window.data(), Qt::LeftButton, 0, QPoint(50, 50)); + + if (boundsBehavior & QQuickFlickable::DragOverBounds) { + QVERIFY(flickable->property("minVerticalOvershoot").toReal() < 0.0); + QVERIFY(flickable->property("minHorizontalOvershoot").toReal() < 0.0); + QCOMPARE(flickable->property("minContentY").toReal(), + flickable->property("minVerticalOvershoot").toReal()); + QCOMPARE(flickable->property("minContentX").toReal(), + flickable->property("minHorizontalOvershoot").toReal()); + } else { + QCOMPARE(flickable->property("minContentY").toReal(), 0.0); + QCOMPARE(flickable->property("minContentX").toReal(), 0.0); + QCOMPARE(flickable->property("minVerticalOvershoot").toReal(), 0.0); + QCOMPARE(flickable->property("minHorizontalOvershoot").toReal(), 0.0); + } + QCOMPARE(flickable->property("maxContentY").toReal(), 0.0); + QCOMPARE(flickable->property("maxContentX").toReal(), 0.0); + QCOMPARE(flickable->property("maxVerticalOvershoot").toReal(), 0.0); + QCOMPARE(flickable->property("maxHorizontalOvershoot").toReal(), 0.0); + + flickable->setContentX(20.0); + flickable->setContentY(20.0); + QMetaObject::invokeMethod(flickable, "reset"); + + // flick past the beginning + flick(window.data(), QPoint(10, 10), QPoint(50, 50), 100); + QTRY_VERIFY(!flickable->property("flicking").toBool()); + + if (boundsBehavior & QQuickFlickable::OvershootBounds) { + QVERIFY(flickable->property("minVerticalOvershoot").toReal() < 0.0); + QVERIFY(flickable->property("minHorizontalOvershoot").toReal() < 0.0); + QCOMPARE(flickable->property("minContentY").toReal(), + flickable->property("minVerticalOvershoot").toReal()); + QCOMPARE(flickable->property("minContentX").toReal(), + flickable->property("minHorizontalOvershoot").toReal()); + } else { + QCOMPARE(flickable->property("minContentY").toReal(), 0.0); + QCOMPARE(flickable->property("minContentX").toReal(), 0.0); + QCOMPARE(flickable->property("minVerticalOvershoot").toReal(), 0.0); + QCOMPARE(flickable->property("minHorizontalOvershoot").toReal(), 0.0); + } + QCOMPARE(flickable->property("maxContentY").toReal(), 20.0); + QCOMPARE(flickable->property("maxContentX").toReal(), 20.0); + QCOMPARE(flickable->property("maxVerticalOvershoot").toReal(), 0.0); + QCOMPARE(flickable->property("maxHorizontalOvershoot").toReal(), 0.0); + + flickable->setContentX(200.0); + flickable->setContentY(200.0); + QMetaObject::invokeMethod(flickable, "reset"); + + // drag past the end + QTest::mousePress(window.data(), Qt::LeftButton, 0, QPoint(50, 50)); + QTest::mouseMove(window.data(), QPoint(40, 40)); + QTest::mouseMove(window.data(), QPoint(30, 30)); + QTest::mouseMove(window.data(), QPoint(20, 20)); + QTest::mouseRelease(window.data(), Qt::LeftButton, 0, QPoint(10, 10)); + + if (boundsBehavior & QQuickFlickable::DragOverBounds) { + QVERIFY(flickable->property("maxVerticalOvershoot").toReal() > 0.0); + QVERIFY(flickable->property("maxHorizontalOvershoot").toReal() > 0.0); + QCOMPARE(flickable->property("maxContentY").toReal() - 200.0, + flickable->property("maxVerticalOvershoot").toReal()); + QCOMPARE(flickable->property("maxContentX").toReal() - 200.0, + flickable->property("maxHorizontalOvershoot").toReal()); + } else { + QCOMPARE(flickable->property("maxContentY").toReal(), 200.0); + QCOMPARE(flickable->property("maxContentX").toReal(), 200.0); + QCOMPARE(flickable->property("maxVerticalOvershoot").toReal(), 0.0); + QCOMPARE(flickable->property("maxHorizontalOvershoot").toReal(), 0.0); + } + QCOMPARE(flickable->property("minContentY").toReal(), 200.0); + QCOMPARE(flickable->property("minContentX").toReal(), 200.0); + QCOMPARE(flickable->property("minVerticalOvershoot").toReal(), 0.0); + QCOMPARE(flickable->property("minHorizontalOvershoot").toReal(), 0.0); + + flickable->setContentX(180.0); + flickable->setContentY(180.0); + QMetaObject::invokeMethod(flickable, "reset"); + + // flick past the end + flick(window.data(), QPoint(50, 50), QPoint(10, 10), 100); + QTRY_VERIFY(!flickable->property("flicking").toBool()); + + if (boundsBehavior & QQuickFlickable::OvershootBounds) { + QVERIFY(flickable->property("maxVerticalOvershoot").toReal() > 0.0); + QVERIFY(flickable->property("maxHorizontalOvershoot").toReal() > 0.0); + QCOMPARE(flickable->property("maxContentY").toReal() - 200.0, + flickable->property("maxVerticalOvershoot").toReal()); + QCOMPARE(flickable->property("maxContentX").toReal() - 200.0, + flickable->property("maxHorizontalOvershoot").toReal()); + } else { + QCOMPARE(flickable->property("maxContentY").toReal(), 200.0); + QCOMPARE(flickable->property("maxContentX").toReal(), 200.0); + QCOMPARE(flickable->property("maxVerticalOvershoot").toReal(), 0.0); + QCOMPARE(flickable->property("maxHorizontalOvershoot").toReal(), 0.0); + } + QCOMPARE(flickable->property("minContentY").toReal(), 180.0); + QCOMPARE(flickable->property("minContentX").toReal(), 180.0); + QCOMPARE(flickable->property("minVerticalOvershoot").toReal(), 0.0); + QCOMPARE(flickable->property("minHorizontalOvershoot").toReal(), 0.0); +} + +void tst_qquickflickable::overshoot_data() +{ + QTest::addColumn<QQuickFlickable::BoundsBehavior>("boundsBehavior"); + + QTest::newRow("StopAtBounds") + << QQuickFlickable::BoundsBehavior(QQuickFlickable::StopAtBounds); + QTest::newRow("DragOverBounds") + << QQuickFlickable::BoundsBehavior(QQuickFlickable::DragOverBounds); + QTest::newRow("OvershootBounds") + << QQuickFlickable::BoundsBehavior(QQuickFlickable::OvershootBounds); + QTest::newRow("DragAndOvershootBounds") + << QQuickFlickable::BoundsBehavior(QQuickFlickable::DragAndOvershootBounds); +} + +void tst_qquickflickable::overshoot_reentrant() +{ + QScopedPointer<QQuickView> window(new QQuickView); + window->setSource(testFileUrl("overshoot_reentrant.qml")); + window->show(); + + QVERIFY(QTest::qWaitForWindowExposed(window.data())); + + QQuickFlickable *flickable = qobject_cast<QQuickFlickable*>(window->rootObject()); + QVERIFY(flickable); + + // horizontal + flickable->setContentX(-10.0); + QCOMPARE(flickable->contentX(), -10.0); + QCOMPARE(flickable->horizontalOvershoot(), -10.0); + + flickable->setProperty("contentPosAdjustment", -5.0); + flickable->setContentX(-20.0); + QCOMPARE(flickable->contentX(), -25.0); + QCOMPARE(flickable->horizontalOvershoot(), -25.0); + + flickable->setContentX(210); + QCOMPARE(flickable->contentX(), 210.0); + QCOMPARE(flickable->horizontalOvershoot(), 10.0); + + flickable->setProperty("contentPosAdjustment", 5.0); + flickable->setContentX(220.0); + QCOMPARE(flickable->contentX(), 225.0); + QCOMPARE(flickable->horizontalOvershoot(), 25.0); + + // vertical + flickable->setContentY(-10.0); + QCOMPARE(flickable->contentY(), -10.0); + QCOMPARE(flickable->verticalOvershoot(), -10.0); + + flickable->setProperty("contentPosAdjustment", -5.0); + flickable->setContentY(-20.0); + QCOMPARE(flickable->contentY(), -25.0); + QCOMPARE(flickable->verticalOvershoot(), -25.0); + + flickable->setContentY(210); + QCOMPARE(flickable->contentY(), 210.0); + QCOMPARE(flickable->verticalOvershoot(), 10.0); + + flickable->setProperty("contentPosAdjustment", 5.0); + flickable->setContentY(220.0); + QCOMPARE(flickable->contentY(), 225.0); + QCOMPARE(flickable->verticalOvershoot(), 25.0); +} + QTEST_MAIN(tst_qquickflickable) #include "tst_qquickflickable.moc" diff --git a/tests/auto/quick/qquickgraphicsinfo/tst_qquickgraphicsinfo.cpp b/tests/auto/quick/qquickgraphicsinfo/tst_qquickgraphicsinfo.cpp index 650892d650..4da6da6043 100644 --- a/tests/auto/quick/qquickgraphicsinfo/tst_qquickgraphicsinfo.cpp +++ b/tests/auto/quick/qquickgraphicsinfo/tst_qquickgraphicsinfo.cpp @@ -51,7 +51,7 @@ private slots: void tst_QQuickGraphicsInfo::testProperties() { QQuickView view; - view.setSource(QUrl::fromLocalFile("data/basic.qml")); + view.setSource(QUrl("data/basic.qml")); view.show(); QVERIFY(QTest::qWaitForWindowExposed(&view)); diff --git a/tests/auto/quick/qquickimage/tst_qquickimage.cpp b/tests/auto/quick/qquickimage/tst_qquickimage.cpp index d345163db5..4699f947a1 100644 --- a/tests/auto/quick/qquickimage/tst_qquickimage.cpp +++ b/tests/auto/quick/qquickimage/tst_qquickimage.cpp @@ -145,9 +145,9 @@ void tst_qquickimage::imageSource_data() QTest::newRow("remote") << "/colors.png" << 120.0 << 120.0 << true << false << true << ""; QTest::newRow("remote redirected") << "/oldcolors.png" << 120.0 << 120.0 << true << false << false << ""; if (QImageReader::supportedImageFormats().contains("svg")) - QTest::newRow("remote svg") << "/heart.svg" << 550.0 << 500.0 << true << false << false << ""; + QTest::newRow("remote svg") << "/heart.svg" << 595.0 << 841.0 << true << false << false << ""; if (QImageReader::supportedImageFormats().contains("svgz")) - QTest::newRow("remote svgz") << "/heart.svgz" << 550.0 << 500.0 << true << false << false << ""; + QTest::newRow("remote svgz") << "/heart.svgz" << 595.0 << 841.0 << true << false << false << ""; QTest::newRow("remote not found") << "/no-such-file.png" << 0.0 << 0.0 << true << false << true << "<Unknown File>:2:1: QML Image: Error transferring {{ServerBaseUrl}}/no-such-file.png - server replied: Not found"; @@ -309,10 +309,6 @@ void tst_qquickimage::mirror() qreal devicePixelRatio = 1.0; foreach (QQuickImage::FillMode fillMode, fillModes) { -#if defined(Q_OS_BLACKBERRY) - QWindow dummy; // On BlackBerry first window is always full screen, - dummy.showFullScreen(); // so make test window a second window. -#endif QScopedPointer<QQuickView> window(new QQuickView); window->setSource(testFileUrl("mirror.qml")); @@ -402,12 +398,12 @@ void tst_qquickimage::svg() component.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); QQuickImage *obj = qobject_cast<QQuickImage*>(component.create()); QVERIFY(obj != 0); - QCOMPARE(obj->width(), 300.0); - QCOMPARE(obj->height(), 273.0); + QCOMPARE(obj->width(), 212.0); + QCOMPARE(obj->height(), 300.0); obj->setSourceSize(QSize(200,200)); - QCOMPARE(obj->width(), 200.0); - QCOMPARE(obj->height(), 182.0); + QCOMPARE(obj->width(), 141.0); + QCOMPARE(obj->height(), 200.0); delete obj; } diff --git a/tests/auto/quick/qquickitemlayer/tst_qquickitemlayer.cpp b/tests/auto/quick/qquickitemlayer/tst_qquickitemlayer.cpp index 44310008d6..5419778cfc 100644 --- a/tests/auto/quick/qquickitemlayer/tst_qquickitemlayer.cpp +++ b/tests/auto/quick/qquickitemlayer/tst_qquickitemlayer.cpp @@ -44,10 +44,6 @@ public: QImage runTest(const QString &fileName) { -#if defined(Q_OS_BLACKBERRY) - QWindow dummy; // On BlackBerry first window is always full screen, - dummy.showFullScreen(); // so make test window a second window. -#endif QQuickView view; view.setSource(testFileUrl(fileName)); diff --git a/tests/auto/quick/qquicklayouts/data/tst_rowlayout.qml b/tests/auto/quick/qquicklayouts/data/tst_rowlayout.qml index 2d4e227a9e..97860458fe 100644 --- a/tests/auto/quick/qquicklayouts/data/tst_rowlayout.qml +++ b/tests/auto/quick/qquicklayouts/data/tst_rowlayout.qml @@ -802,6 +802,27 @@ Item { layout.destroy() // Do not crash } + Component { + id: rectangle_Component + Rectangle { + width: 100 + height: 50 + } + } + + function test_destroyImplicitInvisibleLayout() + { + var root = rectangle_Component.createObject(container) + root.visible = false + var layout = layout_deleteLayout.createObject(root) + layout.visible = true + // at this point the layout is still invisible because root is invisible + layout.destroy() + // Do not crash when destructing the layout + waitForRendering(container) // should ideally call gc(), but does not work + root.destroy() + } + function test_sizeHintWithHiddenChildren(data) { var layout = layout_sizeHint_Component.createObject(container) var grid = layout.children[0] diff --git a/tests/auto/quick/qquicklayouts/data/tst_stacklayout.qml b/tests/auto/quick/qquicklayouts/data/tst_stacklayout.qml new file mode 100644 index 0000000000..8234ac6ef7 --- /dev/null +++ b/tests/auto/quick/qquicklayouts/data/tst_stacklayout.qml @@ -0,0 +1,107 @@ +/**************************************************************************** +** +** Copyright (C) 2016 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:BSD$ +** 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. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.2 +import QtTest 1.0 +import QtQuick.Layouts 1.3 + +Item { + id: container + width: 200 + height: 200 + TestCase { + id: testCase + name: "Tests_StackLayout" + when: windowShown + width: 200 + height: 200 + + Component { + id: layout_rearrange_Component + + StackLayout { + width: 640 + height: 480 + + property alias testRectangle: testRectangle + + RowLayout { + spacing: 0 + + Rectangle { + Layout.preferredWidth: 100 + Layout.preferredHeight: 100 + } + + Rectangle { + id: testRectangle + Layout.preferredWidth: 100 + Layout.preferredHeight: 100 + visible: false + } + + Item { + Layout.fillWidth: true + } + } + } + } + + function test_rearrange() + { + var layout = layout_rearrange_Component.createObject(container) + compare(layout.testRectangle.x, 0) + layout.testRectangle.visible = true + tryCompare(layout.testRectangle, "x", 100) + + layout.destroy() + } + } +} diff --git a/tests/auto/quick/qquicklayouts/qquicklayouts.pro b/tests/auto/quick/qquicklayouts/qquicklayouts.pro index 9ed3e076be..5079d0a182 100644 --- a/tests/auto/quick/qquicklayouts/qquicklayouts.pro +++ b/tests/auto/quick/qquicklayouts/qquicklayouts.pro @@ -9,5 +9,6 @@ TESTDATA = data/* OTHER_FILES += \ data/tst_rowlayout.qml \ - data/tst_gridlayout.qml + data/tst_gridlayout.qml \ + data/tst_stacklayout.qml diff --git a/tests/auto/quick/qquicklistview/data/flickBothDirections.qml b/tests/auto/quick/qquicklistview/data/flickBothDirections.qml new file mode 100644 index 0000000000..5d80ce4110 --- /dev/null +++ b/tests/auto/quick/qquicklistview/data/flickBothDirections.qml @@ -0,0 +1,70 @@ +/**************************************************************************** +** +** Copyright (C) 2017 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:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +import QtQuick 2.9 + +Rectangle { + width: 200 + height: 200 + ListView { + id: list + objectName: "list" + width: 100 + height: 100 + model: 20 + anchors.centerIn: parent + orientation: initialOrientation + contentWidth: initialContentWidth + contentHeight: initialContentHeight + flickableDirection: initialFlickableDirection + delegate: Rectangle { + width: list.orientation == ListView.Vertical ? 120 : 10 + height: list.orientation == ListView.Vertical ? 20 : 110 + color: Qt.rgba(0, 0, index / 19, 1) + opacity: 0.8 + } + Rectangle { + z: -1 + width: 100 + height: 100 + border.width: 1 + border.color: "red" + } + } +} diff --git a/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp b/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp index 4816d9c341..ff06c1e1a4 100644 --- a/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp +++ b/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp @@ -53,6 +53,7 @@ Q_DECLARE_METATYPE(Qt::LayoutDirection) Q_DECLARE_METATYPE(QQuickItemView::VerticalLayoutDirection) Q_DECLARE_METATYPE(QQuickItemView::PositionMode) Q_DECLARE_METATYPE(QQuickListView::Orientation) +Q_DECLARE_METATYPE(QQuickFlickable::FlickableDirection) Q_DECLARE_METATYPE(Qt::Key) using namespace QQuickViewTestUtil; @@ -205,6 +206,8 @@ private slots: void multipleDisplaced(); void flickBeyondBounds(); + void flickBothDirections(); + void flickBothDirections_data(); void destroyItemOnCreation(); void parentBinding(); @@ -7123,6 +7126,82 @@ void tst_QQuickListView::flickBeyondBounds() } } +void tst_QQuickListView::flickBothDirections() +{ + QFETCH(bool, initValues); + QFETCH(QQuickListView::Orientation, orientation); + QFETCH(QQuickFlickable::FlickableDirection, flickableDirection); + QFETCH(qreal, contentWidth); + QFETCH(qreal, contentHeight); + QFETCH(QPointF, targetPos); + + QQuickView *window = getView(); + QQuickViewTestUtil::moveMouseAway(window); + + QQmlContext *ctxt = window->rootContext(); + ctxt->setContextProperty("initialOrientation", initValues ? orientation : QQuickListView::Vertical); + ctxt->setContextProperty("initialFlickableDirection", initValues ? flickableDirection : QQuickFlickable::VerticalFlick); + ctxt->setContextProperty("initialContentWidth", initValues ? contentWidth : -1); + ctxt->setContextProperty("initialContentHeight", initValues ? contentHeight : -1); + + window->setSource(testFileUrl("flickBothDirections.qml")); + window->show(); + QVERIFY(QTest::qWaitForWindowActive(window)); + + QQuickListView *listview = findItem<QQuickListView>(window->rootObject(), "list"); + QVERIFY(listview); + + if (!initValues) { + listview->setOrientation(orientation); + listview->setFlickableDirection(flickableDirection); + if (contentWidth > 0) + listview->setContentWidth(contentWidth); + if (contentHeight > 0) + listview->setContentHeight(contentHeight); + } + + flick(window, QPoint(100, 100), QPoint(25, 25), 50); + QVERIFY(listview->isMoving()); + QTRY_VERIFY(!listview->isMoving()); + QCOMPARE(listview->contentX(), targetPos.x()); + QCOMPARE(listview->contentY(), targetPos.y()); +} + +void tst_QQuickListView::flickBothDirections_data() +{ + QTest::addColumn<bool>("initValues"); + QTest::addColumn<QQuickListView::Orientation>("orientation"); + QTest::addColumn<QQuickFlickable::FlickableDirection>("flickableDirection"); + QTest::addColumn<qreal>("contentWidth"); + QTest::addColumn<qreal>("contentHeight"); + QTest::addColumn<QPointF>("targetPos"); + + // model: 20 + // listview: 100x100 + // vertical delegate: 120x20 -> contentHeight: 20x20=400 + // horizontal delegate: 10x110 -> contentWidth: 20x10=200 + + QTest::newRow("init:vertical,-1") << true << QQuickListView::Vertical << QQuickFlickable::VerticalFlick << -1. << -1. << QPointF(0, 300); + QTest::newRow("init:vertical,120") << true << QQuickListView::Vertical << QQuickFlickable::VerticalFlick<< 120. << -1. << QPointF(0, 300); + QTest::newRow("init:vertical,auto,-1") << true << QQuickListView::Vertical << QQuickFlickable::AutoFlickDirection << -1. << -1. << QPointF(0, 300); + QTest::newRow("init:vertical,auto,120") << true << QQuickListView::Vertical << QQuickFlickable::AutoFlickDirection << 120. << -1. << QPointF(20, 300); + + QTest::newRow("completed:vertical,-1") << false << QQuickListView::Vertical << QQuickFlickable::VerticalFlick << -1. << -1. << QPointF(0, 300); + QTest::newRow("completed:vertical,120") << false << QQuickListView::Vertical << QQuickFlickable::VerticalFlick << 120. << -1. << QPointF(0, 300); + QTest::newRow("completed:vertical,auto,-1") << false << QQuickListView::Vertical << QQuickListView::AutoFlickDirection << -1. << -1. << QPointF(0, 300); + QTest::newRow("completed:vertical,auto,120") << false << QQuickListView::Vertical << QQuickListView::AutoFlickDirection << 120. << -1. << QPointF(20, 300); + + QTest::newRow("init:horizontal,-1") << true << QQuickListView::Horizontal << QQuickFlickable::HorizontalFlick << -1. << -1. << QPointF(100, 0); + QTest::newRow("init:horizontal,110") << true << QQuickListView::Horizontal << QQuickFlickable::HorizontalFlick <<-1. << 110. << QPointF(100, 0); + QTest::newRow("init:horizontal,auto,-1") << true << QQuickListView::Horizontal << QQuickListView::AutoFlickDirection << -1. << -1. << QPointF(100, 0); + QTest::newRow("init:horizontal,auto,110") << true << QQuickListView::Horizontal << QQuickListView::AutoFlickDirection << -1. << 110. << QPointF(100, 10); + + QTest::newRow("completed:horizontal,-1") << false << QQuickListView::Horizontal << QQuickFlickable::HorizontalFlick << -1. << -1. << QPointF(100, 0); + QTest::newRow("completed:horizontal,110") << false << QQuickListView::Horizontal << QQuickFlickable::HorizontalFlick << -1. << 110. << QPointF(100, 0); + QTest::newRow("completed:horizontal,auto,-1") << false << QQuickListView::Horizontal << QQuickListView::AutoFlickDirection << -1. << -1. << QPointF(100, 0); + QTest::newRow("completed:horizontal,auto,110") << false << QQuickListView::Horizontal << QQuickListView::AutoFlickDirection << -1. << 110. << QPointF(100, 10); +} + void tst_QQuickListView::destroyItemOnCreation() { QaimModel model; diff --git a/tests/auto/quick/qquickloader/tst_qquickloader.cpp b/tests/auto/quick/qquickloader/tst_qquickloader.cpp index 77af4796b6..3e7439f3e9 100644 --- a/tests/auto/quick/qquickloader/tst_qquickloader.cpp +++ b/tests/auto/quick/qquickloader/tst_qquickloader.cpp @@ -469,7 +469,7 @@ void tst_QQuickLoader::networkComponent() // because in the synchronous case we're already done loading. QTRY_COMPARE(component.status(), QQmlComponent::Ready); - QQuickItem *item = qobject_cast<QQuickItem*>(component.create()); + QScopedPointer<QQuickItem> item(qobject_cast<QQuickItem*>(component.create())); QVERIFY(item); QQuickLoader *loader = qobject_cast<QQuickLoader*>(item->children().at(1)); @@ -481,7 +481,6 @@ void tst_QQuickLoader::networkComponent() QCOMPARE(loader->status(), QQuickLoader::Ready); QCOMPARE(static_cast<QQuickItem*>(loader)->children().count(), 1); - delete loader; } void tst_QQuickLoader::failNetworkRequest() diff --git a/tests/auto/quick/qquickpathview/data/removePath.qml b/tests/auto/quick/qquickpathview/data/removePath.qml new file mode 100644 index 0000000000..85029f3eaf --- /dev/null +++ b/tests/auto/quick/qquickpathview/data/removePath.qml @@ -0,0 +1,26 @@ +import QtQuick 2.0 + +PathView { + width: 240 + height: 200 + + path: myPath + + delegate: Text { text: value } + model: 10 + + Path { + id: myPath + startX: 120; startY: 100 + PathQuad { x: 120; y: 25; controlX: 260; controlY: 75 } + PathQuad { x: 120; y: 100; controlX: -20; controlY: 75 } + } + + function removePath() { + path = null + } + + function setPath() { + path = myPath + } +} diff --git a/tests/auto/quick/qquickpathview/tst_qquickpathview.cpp b/tests/auto/quick/qquickpathview/tst_qquickpathview.cpp index ba3d182efc..b01d0c3cec 100644 --- a/tests/auto/quick/qquickpathview/tst_qquickpathview.cpp +++ b/tests/auto/quick/qquickpathview/tst_qquickpathview.cpp @@ -141,6 +141,7 @@ private slots: void addCustomAttribute(); void movementDirection_data(); void movementDirection(); + void removePath(); }; class TestObject : public QObject @@ -2504,6 +2505,19 @@ void tst_QQuickPathView::movementDirection() verify_offsets(pathview, toidx, fromoffset, tooffset); } +void tst_QQuickPathView::removePath() +{ + QScopedPointer<QQuickView> window(createView()); + window->setSource(testFileUrl("removePath.qml")); + window->show(); + + QQuickPathView *pathview = qobject_cast<QQuickPathView*>(window->rootObject()); + QVERIFY(pathview != 0); + + QVERIFY(QMetaObject::invokeMethod(pathview, "removePath")); + QVERIFY(QMetaObject::invokeMethod(pathview, "setPath")); +} + QTEST_MAIN(tst_QQuickPathView) #include "tst_qquickpathview.moc" diff --git a/tests/auto/quick/qquicktext/tst_qquicktext.cpp b/tests/auto/quick/qquicktext/tst_qquicktext.cpp index 2032f72e26..034ea4aec8 100644 --- a/tests/auto/quick/qquicktext/tst_qquicktext.cpp +++ b/tests/auto/quick/qquicktext/tst_qquicktext.cpp @@ -762,11 +762,6 @@ void tst_qquicktext::horizontalAlignment() void tst_qquicktext::horizontalAlignment_RightToLeft() { -#if defined(Q_OS_BLACKBERRY) - QQuickWindow dummy; // On BlackBerry first window is always full screen, - dummy.showFullScreen(); // so make test window a second window. -#endif - QScopedPointer<QQuickView> window(createView(testFile("horizontalAlignment_RightToLeft.qml"))); QQuickText *text = window->rootObject()->findChild<QQuickText*>("text"); QVERIFY(text != 0); diff --git a/tests/auto/quick/qquicktextinput/tst_qquicktextinput.cpp b/tests/auto/quick/qquicktextinput/tst_qquicktextinput.cpp index 1451f8e2fc..67921e1fd0 100644 --- a/tests/auto/quick/qquicktextinput/tst_qquicktextinput.cpp +++ b/tests/auto/quick/qquicktextinput/tst_qquicktextinput.cpp @@ -135,6 +135,7 @@ private slots: void signal_accepted(); void signal_editingfinished(); + void signal_textEdited(); void passwordCharacter(); void cursorDelegate_data(); @@ -2441,6 +2442,57 @@ void tst_qquicktextinput::signal_editingfinished() QTRY_COMPARE(editingFinished2Spy.count(), 1); } +void tst_qquicktextinput::signal_textEdited() +{ + QQuickWindow window; + window.show(); + window.requestActivate(); + QTest::qWaitForWindowActive(&window); + + QQuickTextInput *input = new QQuickTextInput(window.contentItem()); + QVERIFY(input); + + QSignalSpy textChangedSpy(input, SIGNAL(textChanged())); + QVERIFY(textChangedSpy.isValid()); + + QSignalSpy textEditedSpy(input, SIGNAL(textEdited())); + QVERIFY(textEditedSpy.isValid()); + + input->forceActiveFocus(); + QTRY_VERIFY(input->hasActiveFocus()); + + int textChanges = 0; + int textEdits = 0; + + QTest::keyClick(&window, Qt::Key_A); + QCOMPARE(textChangedSpy.count(), ++textChanges); + QCOMPARE(textEditedSpy.count(), ++textEdits); + + QTest::keyClick(&window, Qt::Key_B); + QCOMPARE(textChangedSpy.count(), ++textChanges); + QCOMPARE(textEditedSpy.count(), ++textEdits); + + QTest::keyClick(&window, Qt::Key_C); + QCOMPARE(textChangedSpy.count(), ++textChanges); + QCOMPARE(textEditedSpy.count(), ++textEdits); + + QTest::keyClick(&window, Qt::Key_Space); + QCOMPARE(textChangedSpy.count(), ++textChanges); + QCOMPARE(textEditedSpy.count(), ++textEdits); + + QTest::keyClick(&window, Qt::Key_Backspace); + QCOMPARE(textChangedSpy.count(), ++textChanges); + QCOMPARE(textEditedSpy.count(), ++textEdits); + + input->clear(); + QCOMPARE(textChangedSpy.count(), ++textChanges); + QCOMPARE(textEditedSpy.count(), textEdits); + + input->setText("TextInput"); + QCOMPARE(textChangedSpy.count(), ++textChanges); + QCOMPARE(textEditedSpy.count(), textEdits); +} + /* TextInput element should only handle left/right keys until the cursor reaches the extent of the text, then they should ignore the keys. diff --git a/tests/auto/quick/qquickwindow/data/grabContentItemToImage.qml b/tests/auto/quick/qquickwindow/data/grabContentItemToImage.qml new file mode 100644 index 0000000000..9086e0cc84 --- /dev/null +++ b/tests/auto/quick/qquickwindow/data/grabContentItemToImage.qml @@ -0,0 +1,15 @@ +import QtQuick 2.0 +import QtQuick.Window 2.2 as Window + +Window.Window { + visible: true + width: 100 + height: 100 + property int success: 0 + + function grabContentItemToImage() { + contentItem.grabToImage(function (image) { + success = 1 + }) + } +} diff --git a/tests/auto/quick/qquickwindow/qquickwindow.pro b/tests/auto/quick/qquickwindow/qquickwindow.pro index 05093ba8e0..b0a5f97a32 100644 --- a/tests/auto/quick/qquickwindow/qquickwindow.pro +++ b/tests/auto/quick/qquickwindow/qquickwindow.pro @@ -16,4 +16,5 @@ OTHER_FILES += \ data/AnimationsWhileHidden.qml \ data/Headless.qml \ data/showHideAnimate.qml \ - data/windoworder.qml + data/windoworder.qml \ + data/grabContentItemToImage.qml diff --git a/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp b/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp index 3e78230d2e..d3f43fcd4d 100644 --- a/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp +++ b/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp @@ -383,6 +383,8 @@ private slots: void pointerEventTypeAndPointCount(); + void grabContentItemToImage(); + private: QTouchDevice *touchDevice; QTouchDevice *touchDeviceWithVelocity; @@ -2604,6 +2606,23 @@ void tst_qquickwindow::pointerEventTypeAndPointCount() QVERIFY(!pte.touchPointById(0)); } +void tst_qquickwindow::grabContentItemToImage() +{ + QQmlEngine engine; + QQmlComponent component(&engine); + component.loadUrl(testFileUrl("grabContentItemToImage.qml")); + + QObject *created = component.create(); + QScopedPointer<QObject> cleanup(created); + QVERIFY(created); + + QQuickWindow *window = qobject_cast<QQuickWindow *>(created); + QVERIFY(QTest::qWaitForWindowActive(window)); + + QMetaObject::invokeMethod(window, "grabContentItemToImage"); + QTRY_COMPARE(created->property("success").toInt(), 1); +} + QTEST_MAIN(tst_qquickwindow) #include "tst_qquickwindow.moc" diff --git a/tests/auto/quick/qquickxmllistmodel/qquickxmllistmodel.pro b/tests/auto/quick/qquickxmllistmodel/qquickxmllistmodel.pro index 642345a4bb..902325802c 100644 --- a/tests/auto/quick/qquickxmllistmodel/qquickxmllistmodel.pro +++ b/tests/auto/quick/qquickxmllistmodel/qquickxmllistmodel.pro @@ -2,7 +2,9 @@ CONFIG += testcase TARGET = tst_qquickxmllistmodel macx:CONFIG -= app_bundle -SOURCES += tst_qquickxmllistmodel.cpp +SOURCES += tst_qquickxmllistmodel.cpp \ + ../../../../src/imports/xmllistmodel/qqmlxmllistmodel.cpp +HEADERS += ../../../../src/imports/xmllistmodel/qqmlxmllistmodel_p.h include (../../shared/util.pri) diff --git a/tests/auto/quick/touchmouse/tst_touchmouse.cpp b/tests/auto/quick/touchmouse/tst_touchmouse.cpp index b5af61d723..4f4fac8fa5 100644 --- a/tests/auto/quick/touchmouse/tst_touchmouse.cpp +++ b/tests/auto/quick/touchmouse/tst_touchmouse.cpp @@ -194,8 +194,6 @@ private: QQuickView *tst_TouchMouse::createView() { QQuickView *window = new QQuickView(0); - window->setGeometry(0,0,240,320); - return window; } @@ -210,13 +208,11 @@ void tst_TouchMouse::initTestCase() void tst_TouchMouse::simpleTouchEvent() { - QQuickView *window = createView(); - + QScopedPointer<QQuickView> window(createView()); window->setSource(testFileUrl("singleitem.qml")); window->show(); - QVERIFY(QTest::qWaitForWindowExposed(window)); - window->requestActivate(); - QVERIFY(QTest::qWaitForWindowActive(window)); + QQuickViewTestUtil::centerOnScreen(window.data()); + QVERIFY(QTest::qWaitForWindowActive(window.data())); QVERIFY(window->rootObject() != 0); EventItem *eventItem1 = window->rootObject()->findChild<EventItem*>("eventItem1"); @@ -225,33 +221,33 @@ void tst_TouchMouse::simpleTouchEvent() // Do not accept touch or mouse QPoint p1; p1 = QPoint(20, 20); - QTest::touchEvent(window, device).press(0, p1, window); - QQuickTouchUtils::flush(window); + QTest::touchEvent(window.data(), device).press(0, p1, window.data()); + QQuickTouchUtils::flush(window.data()); // Get a touch and then mouse event offered QCOMPARE(eventItem1->eventList.size(), 2); QCOMPARE(eventItem1->eventList.at(0).type, QEvent::TouchBegin); p1 += QPoint(10, 0); - QTest::touchEvent(window, device).move(0, p1, window); - QQuickTouchUtils::flush(window); + QTest::touchEvent(window.data(), device).move(0, p1, window.data()); + QQuickTouchUtils::flush(window.data()); // Not accepted, no updates QCOMPARE(eventItem1->eventList.size(), 2); - QTest::touchEvent(window, device).release(0, p1, window); - QQuickTouchUtils::flush(window); + QTest::touchEvent(window.data(), device).release(0, p1, window.data()); + QQuickTouchUtils::flush(window.data()); QCOMPARE(eventItem1->eventList.size(), 2); eventItem1->eventList.clear(); // Accept touch eventItem1->acceptTouch = true; p1 = QPoint(20, 20); - QTest::touchEvent(window, device).press(0, p1, window); - QQuickTouchUtils::flush(window); + QTest::touchEvent(window.data(), device).press(0, p1, window.data()); + QQuickTouchUtils::flush(window.data()); QCOMPARE(eventItem1->eventList.size(), 1); p1 += QPoint(10, 0); - QTest::touchEvent(window, device).move(0, p1, window); - QQuickTouchUtils::flush(window); + QTest::touchEvent(window.data(), device).move(0, p1, window.data()); + QQuickTouchUtils::flush(window.data()); QCOMPARE(eventItem1->eventList.size(), 2); - QTest::touchEvent(window, device).release(0, p1, window); - QQuickTouchUtils::flush(window); + QTest::touchEvent(window.data(), device).release(0, p1, window.data()); + QQuickTouchUtils::flush(window.data()); QCOMPARE(eventItem1->eventList.size(), 3); eventItem1->eventList.clear(); @@ -263,8 +259,8 @@ void tst_TouchMouse::simpleTouchEvent() eventItem1->acceptMouse = true; eventItem1->setAcceptedMouseButtons(Qt::LeftButton); p1 = QPoint(20, 20); - QTest::touchEvent(window, device).press(0, p1, window); - QQuickTouchUtils::flush(window); + QTest::touchEvent(window.data(), device).press(0, p1, window.data()); + QQuickTouchUtils::flush(window.data()); QCOMPARE(eventItem1->eventList.size(), 2); QCOMPARE(eventItem1->eventList.at(0).type, QEvent::TouchBegin); QCOMPARE(eventItem1->eventList.at(1).type, QEvent::MouseButtonPress); @@ -280,13 +276,13 @@ void tst_TouchMouse::simpleTouchEvent() QCOMPARE(eventItem1->eventList.at(1).mousePosGlobal, globalPos); p1 += QPoint(10, 0); - QTest::touchEvent(window, device).move(0, p1, window); - QQuickTouchUtils::flush(window); + QTest::touchEvent(window.data(), device).move(0, p1, window.data()); + QQuickTouchUtils::flush(window.data()); QCOMPARE(eventItem1->eventList.size(), 4); QCOMPARE(eventItem1->eventList.at(2).type, QEvent::TouchUpdate); QCOMPARE(eventItem1->eventList.at(3).type, QEvent::MouseMove); - QTest::touchEvent(window, device).release(0, p1, window); - QQuickTouchUtils::flush(window); + QTest::touchEvent(window.data(), device).release(0, p1, window.data()); + QQuickTouchUtils::flush(window.data()); QCOMPARE(eventItem1->eventList.size(), 7); QCOMPARE(eventItem1->eventList.at(4).type, QEvent::TouchEnd); QCOMPARE(eventItem1->eventList.at(5).type, QEvent::MouseButtonRelease); @@ -301,17 +297,17 @@ void tst_TouchMouse::simpleTouchEvent() eventItem1->acceptMouse = false; eventItem1->setAcceptedMouseButtons(Qt::LeftButton); p1 = QPoint(20, 20); - QTest::touchEvent(window, device).press(0, p1, window); - QQuickTouchUtils::flush(window); + QTest::touchEvent(window.data(), device).press(0, p1, window.data()); + QQuickTouchUtils::flush(window.data()); QCOMPARE(eventItem1->eventList.size(), 2); QCOMPARE(eventItem1->eventList.at(0).type, QEvent::TouchBegin); QCOMPARE(eventItem1->eventList.at(1).type, QEvent::MouseButtonPress); p1 += QPoint(10, 0); - QTest::touchEvent(window, device).move(0, p1, window); - QQuickTouchUtils::flush(window); + QTest::touchEvent(window.data(), device).move(0, p1, window.data()); + QQuickTouchUtils::flush(window.data()); QCOMPARE(eventItem1->eventList.size(), 2); - QTest::touchEvent(window, device).release(0, p1, window); - QQuickTouchUtils::flush(window); + QTest::touchEvent(window.data(), device).release(0, p1, window.data()); + QQuickTouchUtils::flush(window.data()); QCOMPARE(eventItem1->eventList.size(), 2); eventItem1->eventList.clear(); @@ -322,32 +318,30 @@ void tst_TouchMouse::simpleTouchEvent() eventItem1->acceptTouch = true; eventItem1->setAcceptedMouseButtons(Qt::LeftButton); p1 = QPoint(20, 20); - QTest::touchEvent(window, device).press(0, p1, window); - QQuickTouchUtils::flush(window); + QTest::touchEvent(window.data(), device).press(0, p1, window.data()); + QQuickTouchUtils::flush(window.data()); QCOMPARE(eventItem1->eventList.size(), 1); QCOMPARE(eventItem1->eventList.at(0).type, QEvent::TouchBegin); p1 += QPoint(10, 0); - QTest::touchEvent(window, device).move(0, p1, window); - QQuickTouchUtils::flush(window); + QTest::touchEvent(window.data(), device).move(0, p1, window.data()); + QQuickTouchUtils::flush(window.data()); QCOMPARE(eventItem1->eventList.size(), 2); QCOMPARE(eventItem1->eventList.at(1).type, QEvent::TouchUpdate); - QTest::touchEvent(window, device).release(0, p1, window); - QQuickTouchUtils::flush(window); + QTest::touchEvent(window.data(), device).release(0, p1, window.data()); + QQuickTouchUtils::flush(window.data()); QCOMPARE(eventItem1->eventList.size(), 3); QCOMPARE(eventItem1->eventList.at(2).type, QEvent::TouchEnd); eventItem1->eventList.clear(); - - delete window; } void tst_TouchMouse::testEventFilter() { // // install event filter on item and see that it can grab events -// QQuickView *window = createView(); - +// QScopedPointer<QQuickView> window(createView()); // window->setSource(testFileUrl("singleitem.qml")); // window->show(); -// window->requestActivate(); +// QQuickViewTestUtil::centerOnScreen(window.data()); +// QVERIFY(QTest::qWaitForWindowActive(window.data())); // QVERIFY(window->rootObject() != 0); // EventItem *eventItem1 = window->rootObject()->findChild<EventItem*>("eventItem1"); @@ -359,16 +353,15 @@ void tst_TouchMouse::testEventFilter() // eventItem1->installEventFilter(filter); // QPoint p1 = QPoint(20, 20); -// QTest::touchEvent(window, device).press(0, p1, window); +// QTest::touchEvent(window.data(), device).press(0, p1, window.data()); // // QEXPECT_FAIL("", "We do not implement event filters correctly", Abort); // QCOMPARE(eventItem1->eventList.size(), 0); // QCOMPARE(filter->eventList.size(), 1); -// QTest::touchEvent(window, device).release(0, p1, window); +// QTest::touchEvent(window.data(), device).release(0, p1, window.data()); // QCOMPARE(eventItem1->eventList.size(), 0); // QCOMPARE(filter->eventList.size(), 2); // delete filter; -// delete window; } void tst_TouchMouse::mouse() @@ -377,34 +370,29 @@ void tst_TouchMouse::mouse() // - eventItem2 QTest::qWait(qApp->styleHints()->mouseDoubleClickInterval() + 10); - QQuickView *window = createView(); - + QScopedPointer<QQuickView> window(createView()); window->setSource(testFileUrl("twoitems.qml")); window->show(); - QVERIFY(QTest::qWaitForWindowExposed(window)); - window->requestActivate(); - QVERIFY(QTest::qWaitForWindowActive(window)); + QQuickViewTestUtil::centerOnScreen(window.data()); + QVERIFY(QTest::qWaitForWindowActive(window.data())); QVERIFY(window->rootObject() != 0); EventItem *eventItem1 = window->rootObject()->findChild<EventItem*>("eventItem1"); QVERIFY(eventItem1); EventItem *eventItem2 = window->rootObject()->findChild<EventItem*>("eventItem2"); QVERIFY(eventItem2); - QVERIFY(QTest::qWaitForWindowExposed(window)); // bottom item likes mouse, top likes touch eventItem1->setAcceptedMouseButtons(Qt::LeftButton); eventItem1->acceptMouse = true; // item 2 doesn't accept anything, thus it sees a touch pass by QPoint p1 = QPoint(30, 30); - QTest::touchEvent(window, device).press(0, p1, window); - QQuickTouchUtils::flush(window); + QTest::touchEvent(window.data(), device).press(0, p1, window.data()); + QQuickTouchUtils::flush(window.data()); QCOMPARE(eventItem1->eventList.size(), 2); QCOMPARE(eventItem1->eventList.at(0).type, QEvent::TouchBegin); QCOMPARE(eventItem1->eventList.at(1).type, QEvent::MouseButtonPress); - - delete window; } void tst_TouchMouse::touchOverMouse() @@ -412,13 +400,11 @@ void tst_TouchMouse::touchOverMouse() // eventItem1 // - eventItem2 - QQuickView *window = createView(); - + QScopedPointer<QQuickView> window(createView()); window->setSource(testFileUrl("twoitems.qml")); window->show(); - QVERIFY(QTest::qWaitForWindowExposed(window)); - window->requestActivate(); - QVERIFY(QTest::qWaitForWindowActive(window)); + QQuickViewTestUtil::centerOnScreen(window.data()); + QVERIFY(QTest::qWaitForWindowActive(window.data())); QVERIFY(window->rootObject() != 0); EventItem *eventItem1 = window->rootObject()->findChild<EventItem*>("eventItem1"); @@ -430,27 +416,23 @@ void tst_TouchMouse::touchOverMouse() eventItem1->setAcceptedMouseButtons(Qt::LeftButton); eventItem2->acceptTouch = true; - QVERIFY(QTest::qWaitForWindowExposed(window)); - QCOMPARE(eventItem1->eventList.size(), 0); QPoint p1 = QPoint(20, 20); - QTest::touchEvent(window, device).press(0, p1, window); - QQuickTouchUtils::flush(window); + QTest::touchEvent(window.data(), device).press(0, p1, window.data()); + QQuickTouchUtils::flush(window.data()); QCOMPARE(eventItem1->eventList.size(), 0); QCOMPARE(eventItem2->eventList.size(), 1); QCOMPARE(eventItem2->eventList.at(0).type, QEvent::TouchBegin); p1 += QPoint(10, 0); - QTest::touchEvent(window, device).move(0, p1, window); - QQuickTouchUtils::flush(window); + QTest::touchEvent(window.data(), device).move(0, p1, window.data()); + QQuickTouchUtils::flush(window.data()); QCOMPARE(eventItem2->eventList.size(), 2); QCOMPARE(eventItem2->eventList.at(1).type, QEvent::TouchUpdate); - QTest::touchEvent(window, device).release(0, p1, window); - QQuickTouchUtils::flush(window); + QTest::touchEvent(window.data(), device).release(0, p1, window.data()); + QQuickTouchUtils::flush(window.data()); QCOMPARE(eventItem2->eventList.size(), 3); QCOMPARE(eventItem2->eventList.at(2).type, QEvent::TouchEnd); eventItem2->eventList.clear(); - - delete window; } void tst_TouchMouse::mouseOverTouch() @@ -458,13 +440,11 @@ void tst_TouchMouse::mouseOverTouch() // eventItem1 // - eventItem2 - QQuickView *window = createView(); - + QScopedPointer<QQuickView> window(createView()); window->setSource(testFileUrl("twoitems.qml")); window->show(); - QVERIFY(QTest::qWaitForWindowExposed(window)); - window->requestActivate(); - QVERIFY(QTest::qWaitForWindowActive(window)); + QQuickViewTestUtil::centerOnScreen(window.data()); + QVERIFY(QTest::qWaitForWindowActive(window.data())); QVERIFY(window->rootObject() != 0); EventItem *eventItem1 = window->rootObject()->findChild<EventItem*>("eventItem1"); @@ -477,12 +457,10 @@ void tst_TouchMouse::mouseOverTouch() eventItem2->setAcceptedMouseButtons(Qt::LeftButton); eventItem2->acceptMouse = true; - QVERIFY(QTest::qWaitForWindowExposed(window)); - QPoint p1 = QPoint(20, 20); QTest::qWait(qApp->styleHints()->mouseDoubleClickInterval() + 10); - QTest::touchEvent(window, device).press(0, p1, window); - QQuickTouchUtils::flush(window); + QTest::touchEvent(window.data(), device).press(0, p1, window.data()); + QQuickTouchUtils::flush(window.data()); QCOMPARE(eventItem1->eventList.size(), 0); QCOMPARE(eventItem2->eventList.size(), 2); QCOMPARE(eventItem2->eventList.at(0).type, QEvent::TouchBegin); @@ -490,13 +468,11 @@ void tst_TouchMouse::mouseOverTouch() // p1 += QPoint(10, 0); -// QTest::touchEvent(window, device).move(0, p1, window); +// QTest::touchEvent(window.data(), device).move(0, p1, window.data()); // QCOMPARE(eventItem2->eventList.size(), 1); -// QTest::touchEvent(window, device).release(0, p1, window); +// QTest::touchEvent(window.data(), device).release(0, p1, window.data()); // QCOMPARE(eventItem2->eventList.size(), 1); // eventItem2->eventList.clear(); - - delete window; } void tst_TouchMouse::buttonOnFlickable() @@ -505,13 +481,11 @@ void tst_TouchMouse::buttonOnFlickable() // - eventItem1 y: 100, height 100 // - eventItem2 y: 300, height 100 - QQuickView *window = createView(); - + QScopedPointer<QQuickView> window(createView()); window->setSource(testFileUrl("buttononflickable.qml")); window->show(); - QVERIFY(QTest::qWaitForWindowExposed(window)); - window->requestActivate(); - QVERIFY(QTest::qWaitForWindowActive(window)); + QQuickViewTestUtil::centerOnScreen(window.data()); + QVERIFY(QTest::qWaitForWindowActive(window.data())); QVERIFY(window->rootObject() != 0); QQuickFlickable *flickable = window->rootObject()->findChild<QQuickFlickable*>("flickable"); @@ -536,13 +510,13 @@ void tst_TouchMouse::buttonOnFlickable() // mouse button QCOMPARE(eventItem1->eventList.size(), 0); QPoint p1 = QPoint(20, 130); - QTest::touchEvent(window, device).press(0, p1, window); - QQuickTouchUtils::flush(window); + QTest::touchEvent(window.data(), device).press(0, p1, window.data()); + QQuickTouchUtils::flush(window.data()); QTRY_COMPARE(eventItem1->eventList.size(), 2); QCOMPARE(eventItem1->eventList.at(0).type, QEvent::TouchBegin); QCOMPARE(eventItem1->eventList.at(1).type, QEvent::MouseButtonPress); - QTest::touchEvent(window, device).release(0, p1, window); - QQuickTouchUtils::flush(window); + QTest::touchEvent(window.data(), device).release(0, p1, window.data()); + QQuickTouchUtils::flush(window.data()); QCOMPARE(eventItem1->eventList.size(), 5); QCOMPARE(eventItem1->eventList.at(2).type, QEvent::TouchEnd); QCOMPARE(eventItem1->eventList.at(3).type, QEvent::MouseButtonRelease); @@ -551,12 +525,12 @@ void tst_TouchMouse::buttonOnFlickable() // touch button p1 = QPoint(10, 310); - QTest::touchEvent(window, device).press(0, p1, window); - QQuickTouchUtils::flush(window); + QTest::touchEvent(window.data(), device).press(0, p1, window.data()); + QQuickTouchUtils::flush(window.data()); QCOMPARE(eventItem2->eventList.size(), 1); QCOMPARE(eventItem2->eventList.at(0).type, QEvent::TouchBegin); - QTest::touchEvent(window, device).release(0, p1, window); - QQuickTouchUtils::flush(window); + QTest::touchEvent(window.data(), device).release(0, p1, window.data()); + QQuickTouchUtils::flush(window.data()); QCOMPARE(eventItem2->eventList.size(), 2); QCOMPARE(eventItem2->eventList.at(1).type, QEvent::TouchEnd); QCOMPARE(eventItem1->eventList.size(), 0); @@ -567,11 +541,11 @@ void tst_TouchMouse::buttonOnFlickable() // click above button, no events please p1 = QPoint(10, 90); - QTest::touchEvent(window, device).press(0, p1, window); - QQuickTouchUtils::flush(window); + QTest::touchEvent(window.data(), device).press(0, p1, window.data()); + QQuickTouchUtils::flush(window.data()); QCOMPARE(eventItem1->eventList.size(), 0); - QTest::touchEvent(window, device).release(0, p1, window); - QQuickTouchUtils::flush(window); + QTest::touchEvent(window.data(), device).release(0, p1, window.data()); + QQuickTouchUtils::flush(window.data()); QCOMPARE(eventItem1->eventList.size(), 0); eventItem1->eventList.clear(); @@ -581,13 +555,13 @@ void tst_TouchMouse::buttonOnFlickable() // check that flickable moves - mouse button QCOMPARE(eventItem1->eventList.size(), 0); p1 = QPoint(10, 110); - QTest::touchEvent(window, device).press(0, p1, window); - QQuickTouchUtils::flush(window); + QTest::touchEvent(window.data(), device).press(0, p1, window.data()); + QQuickTouchUtils::flush(window.data()); QCOMPARE(eventItem1->eventList.size(), 2); QCOMPARE(eventItem1->eventList.at(0).type, QEvent::TouchBegin); QCOMPARE(eventItem1->eventList.at(1).type, QEvent::MouseButtonPress); - QQuickWindowPrivate *windowPriv = QQuickWindowPrivate::get(window); + QQuickWindowPrivate *windowPriv = QQuickWindowPrivate::get(window.data()); QVERIFY(windowPriv->touchMouseId != -1); auto pointerEvent = QQuickPointerDevice::touchDevices().at(0)->pointerEvent(); QCOMPARE(pointerEvent->point(0)->grabber(), eventItem1); @@ -596,13 +570,13 @@ void tst_TouchMouse::buttonOnFlickable() p1 += QPoint(0, -10); QPoint p2 = p1 + QPoint(0, -10); QPoint p3 = p2 + QPoint(0, -10); - QQuickTouchUtils::flush(window); - QTest::touchEvent(window, device).move(0, p1, window); - QQuickTouchUtils::flush(window); - QTest::touchEvent(window, device).move(0, p2, window); - QQuickTouchUtils::flush(window); - QTest::touchEvent(window, device).move(0, p3, window); - QQuickTouchUtils::flush(window); + QQuickTouchUtils::flush(window.data()); + QTest::touchEvent(window.data(), device).move(0, p1, window.data()); + QQuickTouchUtils::flush(window.data()); + QTest::touchEvent(window.data(), device).move(0, p2, window.data()); + QQuickTouchUtils::flush(window.data()); + QTest::touchEvent(window.data(), device).move(0, p3, window.data()); + QQuickTouchUtils::flush(window.data()); // we cannot really know when the events get grabbed away QVERIFY(eventItem1->eventList.size() >= 4); @@ -614,9 +588,8 @@ void tst_TouchMouse::buttonOnFlickable() QCOMPARE(pointerEvent->point(0)->grabber(), flickable); QVERIFY(flickable->isMovingVertically()); - QTest::touchEvent(window, device).release(0, p3, window); - QQuickTouchUtils::flush(window); - delete window; + QTest::touchEvent(window.data(), device).release(0, p3, window.data()); + QQuickTouchUtils::flush(window.data()); } void tst_TouchMouse::buttonOnDelayedPressFlickable_data() @@ -642,13 +615,11 @@ void tst_TouchMouse::buttonOnDelayedPressFlickable() qApp->setAttribute(Qt::AA_SynthesizeMouseForUnhandledTouchEvents, true); filteredEventList.clear(); - QQuickView *window = createView(); - + QScopedPointer<QQuickView> window(createView()); window->setSource(testFileUrl("buttononflickable.qml")); window->show(); - QVERIFY(QTest::qWaitForWindowExposed(window)); - window->requestActivate(); - QVERIFY(QTest::qWaitForWindowActive(window)); + QQuickViewTestUtil::centerOnScreen(window.data()); + QVERIFY(QTest::qWaitForWindowActive(window.data())); QVERIFY(window->rootObject() != 0); QQuickFlickable *flickable = window->rootObject()->findChild<QQuickFlickable*>("flickable"); @@ -673,13 +644,13 @@ void tst_TouchMouse::buttonOnDelayedPressFlickable() // wait to avoid getting a double click event QTest::qWait(qApp->styleHints()->mouseDoubleClickInterval() + 10); - QQuickWindowPrivate *windowPriv = QQuickWindowPrivate::get(window); + QQuickWindowPrivate *windowPriv = QQuickWindowPrivate::get(window.data()); QCOMPARE(windowPriv->touchMouseId, -1); // no grabber // touch press QPoint p1 = QPoint(10, 110); - QTest::touchEvent(window, device).press(0, p1, window); - QQuickTouchUtils::flush(window); + QTest::touchEvent(window.data(), device).press(0, p1, window.data()); + QQuickTouchUtils::flush(window.data()); if (scrollBeforeDelayIsOver) { // no events, the flickable got scrolled, the button sees nothing @@ -694,13 +665,13 @@ void tst_TouchMouse::buttonOnDelayedPressFlickable() p1 += QPoint(0, -10); QPoint p2 = p1 + QPoint(0, -10); QPoint p3 = p2 + QPoint(0, -10); - QQuickTouchUtils::flush(window); - QTest::touchEvent(window, device).move(0, p1, window); - QQuickTouchUtils::flush(window); - QTest::touchEvent(window, device).move(0, p2, window); - QQuickTouchUtils::flush(window); - QTest::touchEvent(window, device).move(0, p3, window); - QQuickTouchUtils::flush(window); + QQuickTouchUtils::flush(window.data()); + QTest::touchEvent(window.data(), device).move(0, p1, window.data()); + QQuickTouchUtils::flush(window.data()); + QTest::touchEvent(window.data(), device).move(0, p2, window.data()); + QQuickTouchUtils::flush(window.data()); + QTest::touchEvent(window.data(), device).move(0, p3, window.data()); + QQuickTouchUtils::flush(window.data()); QTRY_VERIFY(flickable->isMovingVertically()); if (scrollBeforeDelayIsOver) { @@ -721,8 +692,8 @@ void tst_TouchMouse::buttonOnDelayedPressFlickable() auto pointerEvent = QQuickPointerDevice::touchDevices().at(0)->pointerEvent(); QCOMPARE(pointerEvent->point(0)->grabber(), flickable); - QTest::touchEvent(window, device).release(0, p3, window); - QQuickTouchUtils::flush(window); + QTest::touchEvent(window.data(), device).release(0, p3, window.data()); + QQuickTouchUtils::flush(window.data()); // We should not have received any synthesised mouse events from Qt gui, // just the delayed press. @@ -730,8 +701,6 @@ void tst_TouchMouse::buttonOnDelayedPressFlickable() QCOMPARE(filteredEventList.count(), 0); else QCOMPARE(filteredEventList.count(), 1); - - delete window; } void tst_TouchMouse::buttonOnTouch() @@ -744,12 +713,11 @@ void tst_TouchMouse::buttonOnTouch() // - eventItem1 y: 100, height 100 // - eventItem2 y: 300, height 100 - QQuickView *window = createView(); + QScopedPointer<QQuickView> window(createView()); window->setSource(testFileUrl("buttonontouch.qml")); window->show(); - QVERIFY(QTest::qWaitForWindowExposed(window)); - window->requestActivate(); - QVERIFY(QTest::qWaitForWindowActive(window)); + QQuickViewTestUtil::centerOnScreen(window.data()); + QVERIFY(QTest::qWaitForWindowActive(window.data())); QVERIFY(window->rootObject() != 0); QQuickPinchArea *pinchArea = window->rootObject()->findChild<QQuickPinchArea*>("pincharea"); @@ -779,10 +747,10 @@ void tst_TouchMouse::buttonOnTouch() // Normal touch click QPoint p1 = QPoint(10, 110); - QTest::touchEvent(window, device).press(0, p1, window); - QQuickTouchUtils::flush(window); - QTest::touchEvent(window, device).release(0, p1, window); - QQuickTouchUtils::flush(window); + QTest::touchEvent(window.data(), device).press(0, p1, window.data()); + QQuickTouchUtils::flush(window.data()); + QTest::touchEvent(window.data(), device).release(0, p1, window.data()); + QQuickTouchUtils::flush(window.data()); QCOMPARE(eventItem1->eventList.size(), 5); QCOMPARE(eventItem1->eventList.at(0).type, QEvent::TouchBegin); QCOMPARE(eventItem1->eventList.at(1).type, QEvent::MouseButtonPress); @@ -792,7 +760,7 @@ void tst_TouchMouse::buttonOnTouch() eventItem1->eventList.clear(); // Normal mouse click - QTest::mouseClick(window, Qt::LeftButton, 0, p1); + QTest::mouseClick(window.data(), Qt::LeftButton, 0, p1); QCOMPARE(eventItem1->eventList.size(), 3); QCOMPARE(eventItem1->eventList.at(0).type, QEvent::MouseButtonPress); QCOMPARE(eventItem1->eventList.at(1).type, QEvent::MouseButtonRelease); @@ -804,35 +772,35 @@ void tst_TouchMouse::buttonOnTouch() QPoint p2 = QPoint(60, 10); // Start the events after each other - QTest::touchEvent(window, device).press(0, p1, window); - QQuickTouchUtils::flush(window); - QTest::touchEvent(window, device).stationary(0).press(1, p2, window); - QQuickTouchUtils::flush(window); + QTest::touchEvent(window.data(), device).press(0, p1, window.data()); + QQuickTouchUtils::flush(window.data()); + QTest::touchEvent(window.data(), device).stationary(0).press(1, p2, window.data()); + QQuickTouchUtils::flush(window.data()); QCOMPARE(button1->scale(), 1.0); // This event seems to be discarded, let's ignore it for now until someone digs into pincharea p1 -= QPoint(10, 0); p2 += QPoint(10, 0); - QTest::touchEvent(window, device).move(0, p1, window).move(1, p2, window); - QQuickTouchUtils::flush(window); + QTest::touchEvent(window.data(), device).move(0, p1, window.data()).move(1, p2, window.data()); + QQuickTouchUtils::flush(window.data()); p1 -= QPoint(10, 0); p2 += QPoint(10, 0); - QTest::touchEvent(window, device).move(0, p1, window).move(1, p2, window); - QQuickTouchUtils::flush(window); + QTest::touchEvent(window.data(), device).move(0, p1, window.data()).move(1, p2, window.data()); + QQuickTouchUtils::flush(window.data()); // QCOMPARE(button1->scale(), 1.5); qDebug() << "Button scale: " << button1->scale(); p1 -= QPoint(10, 0); p2 += QPoint(10, 0); - QTest::touchEvent(window, device).move(0, p1, window).move(1, p2, window); - QQuickTouchUtils::flush(window); + QTest::touchEvent(window.data(), device).move(0, p1, window.data()).move(1, p2, window.data()); + QQuickTouchUtils::flush(window.data()); // QCOMPARE(button1->scale(), 2.0); qDebug() << "Button scale: " << button1->scale(); - QTest::touchEvent(window, device).release(0, p1, window).release(1, p2, window); - QQuickTouchUtils::flush(window); + QTest::touchEvent(window.data(), device).release(0, p1, window.data()).release(1, p2, window.data()); + QQuickTouchUtils::flush(window.data()); // QVERIFY(eventItem1->eventList.isEmpty()); // QCOMPARE(button1->scale(), 2.0); qDebug() << "Button scale: " << button1->scale(); @@ -845,8 +813,8 @@ void tst_TouchMouse::buttonOnTouch() button1->setScale(1.0); p1 = QPoint(40, 110); p2 = QPoint(60, 110); - QTest::touchEvent(window, device).press(0, p1, window).press(1, p2, window); - QQuickTouchUtils::flush(window); + QTest::touchEvent(window.data(), device).press(0, p1, window.data()).press(1, p2, window.data()); + QQuickTouchUtils::flush(window.data()); QCOMPARE(button1->scale(), 1.0); QCOMPARE(eventItem1->eventList.count(), 2); QCOMPARE(eventItem1->eventList.at(0).type, QEvent::TouchBegin); @@ -855,40 +823,37 @@ void tst_TouchMouse::buttonOnTouch() // This event seems to be discarded, let's ignore it for now until someone digs into pincharea p1 -= QPoint(10, 0); p2 += QPoint(10, 0); - QTest::touchEvent(window, device).move(0, p1, window).move(1, p2, window); - QQuickTouchUtils::flush(window); + QTest::touchEvent(window.data(), device).move(0, p1, window.data()).move(1, p2, window.data()); + QQuickTouchUtils::flush(window.data()); p1 -= QPoint(10, 0); p2 += QPoint(10, 0); - QTest::touchEvent(window, device).move(0, p1, window).move(1, p2, window); - QQuickTouchUtils::flush(window); + QTest::touchEvent(window.data(), device).move(0, p1, window.data()).move(1, p2, window.data()); + QQuickTouchUtils::flush(window.data()); //QCOMPARE(button1->scale(), 1.5); qDebug() << button1->scale(); p1 -= QPoint(10, 0); p2 += QPoint(10, 0); - QTest::touchEvent(window, device).move(0, p1, window).move(1, p2, window); - QQuickTouchUtils::flush(window); + QTest::touchEvent(window.data(), device).move(0, p1, window.data()).move(1, p2, window.data()); + QQuickTouchUtils::flush(window.data()); qDebug() << button1->scale(); //QCOMPARE(button1->scale(), 2.0); - QTest::touchEvent(window, device).release(0, p1, window).release(1, p2, window); - QQuickTouchUtils::flush(window); + QTest::touchEvent(window.data(), device).release(0, p1, window.data()).release(1, p2, window.data()); + QQuickTouchUtils::flush(window.data()); // QCOMPARE(eventItem1->eventList.size(), 99); qDebug() << button1->scale(); //QCOMPARE(button1->scale(), 2.0); - - delete window; } void tst_TouchMouse::pinchOnFlickable() { - QQuickView *window = createView(); + QScopedPointer<QQuickView> window(createView()); window->setSource(testFileUrl("pinchonflickable.qml")); window->show(); - QVERIFY(QTest::qWaitForWindowExposed(window)); - window->requestActivate(); - QVERIFY(QTest::qWaitForWindowActive(window)); + QQuickViewTestUtil::centerOnScreen(window.data()); + QVERIFY(QTest::qWaitForWindowActive(window.data())); QVERIFY(window->rootObject() != 0); QQuickPinchArea *pinchArea = window->rootObject()->findChild<QQuickPinchArea*>("pincharea"); @@ -901,23 +866,23 @@ void tst_TouchMouse::pinchOnFlickable() // flickable - single touch point QCOMPARE(flickable->contentX(), 0.0); QPoint p = QPoint(100, 100); - QTest::touchEvent(window, device).press(0, p, window); - QQuickTouchUtils::flush(window); + QTest::touchEvent(window.data(), device).press(0, p, window.data()); + QQuickTouchUtils::flush(window.data()); QCOMPARE(rect->position(), QPointF(200.0, 200.0)); p -= QPoint(10, 0); - QTest::touchEvent(window, device).move(0, p, window); - QQuickTouchUtils::flush(window); + QTest::touchEvent(window.data(), device).move(0, p, window.data()); + QQuickTouchUtils::flush(window.data()); p -= QPoint(10, 0); - QTest::touchEvent(window, device).move(0, p, window); - QQuickTouchUtils::flush(window); + QTest::touchEvent(window.data(), device).move(0, p, window.data()); + QQuickTouchUtils::flush(window.data()); p -= QPoint(10, 0); - QTest::touchEvent(window, device).move(0, p, window); - QQuickTouchUtils::flush(window); + QTest::touchEvent(window.data(), device).move(0, p, window.data()); + QQuickTouchUtils::flush(window.data()); p -= QPoint(10, 0); - QTest::touchEvent(window, device).move(0, p, window); - QQuickTouchUtils::flush(window); - QTest::touchEvent(window, device).release(0, p, window); - QQuickTouchUtils::flush(window); + QTest::touchEvent(window.data(), device).move(0, p, window.data()); + QQuickTouchUtils::flush(window.data()); + QTest::touchEvent(window.data(), device).release(0, p, window.data()); + QQuickTouchUtils::flush(window.data()); QGuiApplication::processEvents(); QTest::qWait(10); @@ -929,48 +894,47 @@ void tst_TouchMouse::pinchOnFlickable() QPoint p1 = QPoint(40, 20); QPoint p2 = QPoint(60, 20); - QTest::QTouchEventSequence pinchSequence = QTest::touchEvent(window, device); - QQuickTouchUtils::flush(window); - pinchSequence.press(0, p1, window).commit(); - QQuickTouchUtils::flush(window); + QTest::QTouchEventSequence pinchSequence = QTest::touchEvent(window.data(), device); + QQuickTouchUtils::flush(window.data()); + pinchSequence.press(0, p1, window.data()).commit(); + QQuickTouchUtils::flush(window.data()); // In order for the stationary point to remember its previous position, // we have to reuse the same pinchSequence object. Otherwise if we let it // be destroyed and then start a new sequence, point 0 will default to being // stationary at 0, 0, and PinchArea will filter out that touchpoint because // it is outside its bounds. - pinchSequence.stationary(0).press(1, p2, window).commit(); - QQuickTouchUtils::flush(window); + pinchSequence.stationary(0).press(1, p2, window.data()).commit(); + QQuickTouchUtils::flush(window.data()); p1 -= QPoint(10,10); p2 += QPoint(10,10); - pinchSequence.move(0, p1, window).move(1, p2, window).commit(); - QQuickTouchUtils::flush(window); + pinchSequence.move(0, p1, window.data()).move(1, p2, window.data()).commit(); + QQuickTouchUtils::flush(window.data()); QCOMPARE(rect->scale(), 1.0); p1 -= QPoint(10, 0); p2 += QPoint(10, 0); - pinchSequence.move(0, p1, window).move(1, p2, window).commit(); - QQuickTouchUtils::flush(window); + pinchSequence.move(0, p1, window.data()).move(1, p2, window.data()).commit(); + QQuickTouchUtils::flush(window.data()); p1 -= QPoint(10, 0); p2 += QPoint(10, 0); - pinchSequence.move(0, p1, window).move(1, p2, window).commit(); - QQuickTouchUtils::flush(window); + pinchSequence.move(0, p1, window.data()).move(1, p2, window.data()).commit(); + QQuickTouchUtils::flush(window.data()); p1 -= QPoint(10, 0); p2 += QPoint(10, 0); - pinchSequence.move(0, p1, window).move(1, p2, window).commit(); + pinchSequence.move(0, p1, window.data()).move(1, p2, window.data()).commit(); QVERIFY(!flickable->isDragging()); - QQuickTouchUtils::flush(window); - pinchSequence.release(0, p1, window).release(1, p2, window).commit(); - QQuickTouchUtils::flush(window); + QQuickTouchUtils::flush(window.data()); + pinchSequence.release(0, p1, window.data()).release(1, p2, window.data()).commit(); + QQuickTouchUtils::flush(window.data()); QVERIFY(rect->scale() > 1.0); } void tst_TouchMouse::flickableOnPinch() { - QQuickView *window = createView(); + QScopedPointer<QQuickView> window(createView()); window->setSource(testFileUrl("flickableonpinch.qml")); window->show(); - QVERIFY(QTest::qWaitForWindowExposed(window)); - window->requestActivate(); - QVERIFY(QTest::qWaitForWindowActive(window)); + QQuickViewTestUtil::centerOnScreen(window.data()); + QVERIFY(QTest::qWaitForWindowActive(window.data())); QVERIFY(window->rootObject() != 0); QQuickPinchArea *pinchArea = window->rootObject()->findChild<QQuickPinchArea*>("pincharea"); @@ -983,23 +947,23 @@ void tst_TouchMouse::flickableOnPinch() // flickable - single touch point QCOMPARE(flickable->contentX(), 0.0); QPoint p = QPoint(100, 100); - QTest::touchEvent(window, device).press(0, p, window); - QQuickTouchUtils::flush(window); + QTest::touchEvent(window.data(), device).press(0, p, window.data()); + QQuickTouchUtils::flush(window.data()); QCOMPARE(rect->position(), QPointF(200.0, 200.0)); p -= QPoint(10, 0); - QTest::touchEvent(window, device).move(0, p, window); - QQuickTouchUtils::flush(window); + QTest::touchEvent(window.data(), device).move(0, p, window.data()); + QQuickTouchUtils::flush(window.data()); p -= QPoint(10, 0); - QTest::touchEvent(window, device).move(0, p, window); - QQuickTouchUtils::flush(window); + QTest::touchEvent(window.data(), device).move(0, p, window.data()); + QQuickTouchUtils::flush(window.data()); QTest::qWait(1000); p -= QPoint(10, 0); - QTest::touchEvent(window, device).move(0, p, window); - QQuickTouchUtils::flush(window); - QTest::touchEvent(window, device).release(0, p, window); - QQuickTouchUtils::flush(window); + QTest::touchEvent(window.data(), device).move(0, p, window.data()); + QQuickTouchUtils::flush(window.data()); + QTest::touchEvent(window.data(), device).release(0, p, window.data()); + QQuickTouchUtils::flush(window.data()); QTest::qWait(1000); @@ -1011,45 +975,47 @@ void tst_TouchMouse::flickableOnPinch() // pinch QPoint p1 = QPoint(40, 20); QPoint p2 = QPoint(60, 20); - QTest::QTouchEventSequence pinchSequence = QTest::touchEvent(window, device); - pinchSequence.press(0, p1, window).commit(); - QQuickTouchUtils::flush(window); + QTest::QTouchEventSequence pinchSequence = QTest::touchEvent(window.data(), device); + pinchSequence.press(0, p1, window.data()).commit(); + QQuickTouchUtils::flush(window.data()); // In order for the stationary point to remember its previous position, // we have to reuse the same pinchSequence object. Otherwise if we let it // be destroyed and then start a new sequence, point 0 will default to being // stationary at 0, 0, and PinchArea will filter out that touchpoint because // it is outside its bounds. - pinchSequence.stationary(0).press(1, p2, window).commit(); - QQuickTouchUtils::flush(window); + pinchSequence.stationary(0).press(1, p2, window.data()).commit(); + QQuickTouchUtils::flush(window.data()); p1 -= QPoint(10,10); p2 += QPoint(10,10); - pinchSequence.move(0, p1, window).move(1, p2, window).commit(); - QQuickTouchUtils::flush(window); + pinchSequence.move(0, p1, window.data()).move(1, p2, window.data()).commit(); + QQuickTouchUtils::flush(window.data()); QCOMPARE(rect->scale(), 1.0); p1 -= QPoint(10, 0); p2 += QPoint(10, 0); - pinchSequence.move(0, p1, window).move(1, p2, window).commit(); - QQuickTouchUtils::flush(window); + pinchSequence.move(0, p1, window.data()).move(1, p2, window.data()).commit(); + QQuickTouchUtils::flush(window.data()); p1 -= QPoint(10, 0); p2 += QPoint(10, 0); - pinchSequence.move(0, p1, window).move(1, p2, window).commit(); - QQuickTouchUtils::flush(window); + pinchSequence.move(0, p1, window.data()).move(1, p2, window.data()).commit(); + QQuickTouchUtils::flush(window.data()); p1 -= QPoint(10, 0); p2 += QPoint(10, 0); - pinchSequence.move(0, p1, window).move(1, p2, window).commit(); - QQuickTouchUtils::flush(window); - pinchSequence.release(0, p1, window).release(1, p2, window).commit(); - QQuickTouchUtils::flush(window); + pinchSequence.move(0, p1, window.data()).move(1, p2, window.data()).commit(); + QQuickTouchUtils::flush(window.data()); + pinchSequence.release(0, p1, window.data()).release(1, p2, window.data()).commit(); + QQuickTouchUtils::flush(window.data()); QVERIFY(rect->scale() > 1.0); } void tst_TouchMouse::mouseOnFlickableOnPinch() { - QQuickView *window = createView(); + QScopedPointer<QQuickView> window(createView()); window->setSource(testFileUrl("mouseonflickableonpinch.qml")); window->show(); - QVERIFY(QTest::qWaitForWindowExposed(window)); + QQuickViewTestUtil::centerOnScreen(window.data()); + QVERIFY(QTest::qWaitForWindowActive(window.data())); QVERIFY(window->rootObject() != 0); + QRect windowRect = QRect(window->position(), window->size()); QCursor::setPos(windowRect.center()); @@ -1063,20 +1029,20 @@ void tst_TouchMouse::mouseOnFlickableOnPinch() // flickable - single touch point QCOMPARE(flickable->contentX(), 0.0); QPoint p = QPoint(100, 100); - QTest::touchEvent(window, device).press(0, p, window); - QQuickTouchUtils::flush(window); + QTest::touchEvent(window.data(), device).press(0, p, window.data()); + QQuickTouchUtils::flush(window.data()); QCOMPARE(rect->position(), QPointF(200.0, 200.0)); p -= QPoint(10, 0); - QTest::touchEvent(window, device).move(0, p, window); - QQuickTouchUtils::flush(window); + QTest::touchEvent(window.data(), device).move(0, p, window.data()); + QQuickTouchUtils::flush(window.data()); p -= QPoint(10, 0); - QTest::touchEvent(window, device).move(0, p, window); - QQuickTouchUtils::flush(window); + QTest::touchEvent(window.data(), device).move(0, p, window.data()); + QQuickTouchUtils::flush(window.data()); p -= QPoint(10, 0); - QTest::touchEvent(window, device).move(0, p, window); - QQuickTouchUtils::flush(window); - QTest::touchEvent(window, device).release(0, p, window); - QQuickTouchUtils::flush(window); + QTest::touchEvent(window.data(), device).move(0, p, window.data()); + QQuickTouchUtils::flush(window.data()); + QTest::touchEvent(window.data(), device).release(0, p, window.data()); + QQuickTouchUtils::flush(window.data()); //QVERIFY(flickable->isMovingHorizontally()); @@ -1087,81 +1053,81 @@ void tst_TouchMouse::mouseOnFlickableOnPinch() // pinch QPoint p1 = QPoint(40, 20); QPoint p2 = QPoint(60, 20); - QTest::QTouchEventSequence pinchSequence = QTest::touchEvent(window, device); - pinchSequence.press(0, p1, window).commit(); - QQuickTouchUtils::flush(window); + QTest::QTouchEventSequence pinchSequence = QTest::touchEvent(window.data(), device); + pinchSequence.press(0, p1, window.data()).commit(); + QQuickTouchUtils::flush(window.data()); // In order for the stationary point to remember its previous position, // we have to reuse the same pinchSequence object. Otherwise if we let it // be destroyed and then start a new sequence, point 0 will default to being // stationary at 0, 0, and PinchArea will filter out that touchpoint because // it is outside its bounds. - pinchSequence.stationary(0).press(1, p2, window).commit(); - QQuickTouchUtils::flush(window); + pinchSequence.stationary(0).press(1, p2, window.data()).commit(); + QQuickTouchUtils::flush(window.data()); p1 -= QPoint(10,10); p2 += QPoint(10,10); - pinchSequence.move(0, p1, window).move(1, p2, window).commit(); - QQuickTouchUtils::flush(window); + pinchSequence.move(0, p1, window.data()).move(1, p2, window.data()).commit(); + QQuickTouchUtils::flush(window.data()); QCOMPARE(rect->scale(), 1.0); p1 -= QPoint(10, 0); p2 += QPoint(10, 0); - pinchSequence.move(0, p1, window).move(1, p2, window).commit(); - QQuickTouchUtils::flush(window); + pinchSequence.move(0, p1, window.data()).move(1, p2, window.data()).commit(); + QQuickTouchUtils::flush(window.data()); p1 -= QPoint(10, 0); p2 += QPoint(10, 0); - pinchSequence.move(0, p1, window).move(1, p2, window).commit(); - QQuickTouchUtils::flush(window); + pinchSequence.move(0, p1, window.data()).move(1, p2, window.data()).commit(); + QQuickTouchUtils::flush(window.data()); p1 -= QPoint(10, 0); p2 += QPoint(10, 0); - pinchSequence.move(0, p1, window).move(1, p2, window).commit(); - QQuickTouchUtils::flush(window); - pinchSequence.release(0, p1, window).release(1, p2, window).commit(); - QQuickTouchUtils::flush(window); + pinchSequence.move(0, p1, window.data()).move(1, p2, window.data()).commit(); + QQuickTouchUtils::flush(window.data()); + pinchSequence.release(0, p1, window.data()).release(1, p2, window.data()).commit(); + QQuickTouchUtils::flush(window.data()); QVERIFY(rect->scale() > 1.0); // PinchArea should steal the event after flicking started rect->setScale(1.0); flickable->setContentX(0.0); p = QPoint(100, 100); - pinchSequence.press(0, p, window).commit(); - QQuickTouchUtils::flush(window); + pinchSequence.press(0, p, window.data()).commit(); + QQuickTouchUtils::flush(window.data()); QCOMPARE(rect->position(), QPointF(200.0, 200.0)); p -= QPoint(10, 0); - pinchSequence.move(0, p, window).commit(); - QQuickTouchUtils::flush(window); + pinchSequence.move(0, p, window.data()).commit(); + QQuickTouchUtils::flush(window.data()); p -= QPoint(10, 0); - pinchSequence.move(0, p, window).commit(); - QQuickTouchUtils::flush(window); + pinchSequence.move(0, p, window.data()).commit(); + QQuickTouchUtils::flush(window.data()); QGuiApplication::processEvents(); p -= QPoint(10, 0); - pinchSequence.move(0, p, window).commit(); - QQuickTouchUtils::flush(window); + pinchSequence.move(0, p, window.data()).commit(); + QQuickTouchUtils::flush(window.data()); QCOMPARE(window->mouseGrabberItem(), flickable); // Add a second finger, this should lead to stealing p1 = QPoint(40, 100); p2 = QPoint(60, 100); - pinchSequence.stationary(0).press(1, p2, window).commit(); - QQuickTouchUtils::flush(window); + pinchSequence.stationary(0).press(1, p2, window.data()).commit(); + QQuickTouchUtils::flush(window.data()); QCOMPARE(rect->scale(), 1.0); p1 -= QPoint(5, 0); p2 += QPoint(5, 0); - pinchSequence.move(0, p1, window).move(1, p2, window).commit(); - QQuickTouchUtils::flush(window); + pinchSequence.move(0, p1, window.data()).move(1, p2, window.data()).commit(); + QQuickTouchUtils::flush(window.data()); p1 -= QPoint(5, 0); p2 += QPoint(5, 0); - pinchSequence.move(0, p1, window).move(1, p2, window).commit(); - QQuickTouchUtils::flush(window); + pinchSequence.move(0, p1, window.data()).move(1, p2, window.data()).commit(); + QQuickTouchUtils::flush(window.data()); p1 -= QPoint(5, 0); p2 += QPoint(5, 0); - pinchSequence.move(0, p1, window).move(1, p2, window).commit(); - QQuickTouchUtils::flush(window); - pinchSequence.release(0, p1, window).release(1, p2, window).commit(); - QQuickTouchUtils::flush(window); + pinchSequence.move(0, p1, window.data()).move(1, p2, window.data()).commit(); + QQuickTouchUtils::flush(window.data()); + pinchSequence.release(0, p1, window.data()).release(1, p2, window.data()).commit(); + QQuickTouchUtils::flush(window.data()); QVERIFY(rect->scale() > 1.0); - pinchSequence.release(0, p, window).commit(); - QQuickTouchUtils::flush(window); + pinchSequence.release(0, p, window.data()).commit(); + QQuickTouchUtils::flush(window.data()); } /* @@ -1176,13 +1142,11 @@ void tst_TouchMouse::mouseOnFlickableOnPinch() */ void tst_TouchMouse::tapOnDismissiveTopMouseAreaClicksBottomOne() { - QQuickView *window = createView(); - + QScopedPointer<QQuickView> window(createView()); window->setSource(testFileUrl("twoMouseAreas.qml")); window->show(); - QVERIFY(QTest::qWaitForWindowExposed(window)); - window->requestActivate(); - QVERIFY(QTest::qWaitForWindowActive(window)); + QQuickViewTestUtil::centerOnScreen(window.data()); + QVERIFY(QTest::qWaitForWindowActive(window.data())); QVERIFY(window->rootObject() != 0); QQuickMouseArea *bottomMouseArea = @@ -1194,23 +1158,21 @@ void tst_TouchMouse::tapOnDismissiveTopMouseAreaClicksBottomOne() // tap the front mouse area (see qml file) QPoint p1(20, 20); - QTest::touchEvent(window, device).press(0, p1, window); - QQuickTouchUtils::flush(window); - QTest::touchEvent(window, device).release(0, p1, window); - QQuickTouchUtils::flush(window); + QTest::touchEvent(window.data(), device).press(0, p1, window.data()); + QQuickTouchUtils::flush(window.data()); + QTest::touchEvent(window.data(), device).release(0, p1, window.data()); + QQuickTouchUtils::flush(window.data()); QCOMPARE(bottomClickedSpy.count(), 1); QCOMPARE(bottomDoubleClickedSpy.count(), 0); - QTest::touchEvent(window, device).press(0, p1, window); - QQuickTouchUtils::flush(window); - QTest::touchEvent(window, device).release(0, p1, window); - QQuickTouchUtils::flush(window); + QTest::touchEvent(window.data(), device).press(0, p1, window.data()); + QQuickTouchUtils::flush(window.data()); + QTest::touchEvent(window.data(), device).release(0, p1, window.data()); + QQuickTouchUtils::flush(window.data()); QCOMPARE(bottomClickedSpy.count(), 1); QCOMPARE(bottomDoubleClickedSpy.count(), 1); - - delete window; } /* @@ -1220,13 +1182,11 @@ void tst_TouchMouse::tapOnDismissiveTopMouseAreaClicksBottomOne() */ void tst_TouchMouse::touchGrabCausesMouseUngrab() { - QQuickView *window = createView(); - + QScopedPointer<QQuickView> window(createView()); window->setSource(testFileUrl("twosiblingitems.qml")); window->show(); - QVERIFY(QTest::qWaitForWindowExposed(window)); - window->requestActivate(); - QVERIFY(QTest::qWaitForWindowActive(window)); + QQuickViewTestUtil::centerOnScreen(window.data()); + QVERIFY(QTest::qWaitForWindowActive(window.data())); QVERIFY(window->rootObject() != 0); EventItem *leftItem = window->rootObject()->findChild<EventItem*>("leftItem"); @@ -1242,8 +1202,8 @@ void tst_TouchMouse::touchGrabCausesMouseUngrab() leftItem->setAcceptedMouseButtons(Qt::LeftButton); QPoint p1; p1 = QPoint(leftItem->width() / 2, leftItem->height() / 2); - QTest::touchEvent(window, device).press(0, p1, window); - QQuickTouchUtils::flush(window); + QTest::touchEvent(window.data(), device).press(0, p1, window.data()); + QQuickTouchUtils::flush(window.data()); QCOMPARE(leftItem->eventList.size(), 2); QCOMPARE(leftItem->eventList.at(0).type, QEvent::TouchBegin); QCOMPARE(leftItem->eventList.at(1).type, QEvent::MouseButtonPress); @@ -1262,16 +1222,17 @@ void tst_TouchMouse::touchGrabCausesMouseUngrab() QCOMPARE(leftItem->eventList.size(), 1); QCOMPARE(leftItem->eventList.at(0).type, QEvent::UngrabMouse); QCOMPARE(window->mouseGrabberItem(), (QQuickItem*)0); - - delete window; } void tst_TouchMouse::touchPointDeliveryOrder() { // Touch points should be first delivered to the item under the primary finger QScopedPointer<QQuickView> window(createView()); - window->setSource(testFileUrl("touchpointdeliveryorder.qml")); + window->show(); + QQuickViewTestUtil::centerOnScreen(window.data()); + QVERIFY(QTest::qWaitForWindowActive(window.data())); + /* The items are positioned from left to right: | background | @@ -1285,8 +1246,6 @@ void tst_TouchMouse::touchPointDeliveryOrder() QPoint pLeftMiddle = QPoint(200, 100); QPoint pRightMiddle = QPoint(350, 100); - window->show(); - QVERIFY(QTest::qWaitForWindowExposed(window.data())); QVector<QQuickItem*> events; EventItem *background = window->rootObject()->findChild<EventItem*>("background"); @@ -1371,16 +1330,12 @@ void tst_TouchMouse::hoverEnabled() // device->setType(QTouchDevice::TouchScreen); // QWindowSystemInterface::registerTouchDevice(device); - // Ensure the cursor is away from the window - QCursor::setPos(0, 0); - - QQuickView *window = createView(); + QScopedPointer<QQuickView> window(createView()); window->setSource(testFileUrl("hoverMouseAreas.qml")); - window->setPosition(10, 10); - + QQuickViewTestUtil::centerOnScreen(window.data()); + QQuickViewTestUtil::moveMouseAway(window.data()); window->show(); - window->requestActivate(); - QVERIFY(QTest::qWaitForWindowExposed(window)); + QVERIFY(QTest::qWaitForWindowActive(window.data())); QQuickItem *root = window->rootObject(); QVERIFY(root != 0); @@ -1403,14 +1358,14 @@ void tst_TouchMouse::hoverEnabled() QPoint p2(150, 250); // ------------------------- Mouse move to mouseArea1 - QTest::mouseMove(window, p1); + QTest::mouseMove(window.data(), p1); QVERIFY(enterSpy1.count() == 1); QVERIFY(mouseArea1->hovered()); QVERIFY(!mouseArea2->hovered()); // ------------------------- Touch click on mouseArea1 - QTest::touchEvent(window, device).press(0, p1, window); + QTest::touchEvent(window.data(), device).press(0, p1, window.data()); QCOMPARE(enterSpy1.count(), 1); QCOMPARE(enterSpy2.count(), 0); @@ -1418,7 +1373,7 @@ void tst_TouchMouse::hoverEnabled() QVERIFY(mouseArea1->hovered()); QVERIFY(!mouseArea2->hovered()); - QTest::touchEvent(window, device).release(0, p1, window); + QTest::touchEvent(window.data(), device).release(0, p1, window.data()); QVERIFY(clickSpy1.count() == 1); QVERIFY(mouseArea1->hovered()); QVERIFY(!mouseArea2->hovered()); @@ -1427,7 +1382,7 @@ void tst_TouchMouse::hoverEnabled() if (QGuiApplication::platformName().compare(QLatin1String("xcb"), Qt::CaseInsensitive) == 0) QSKIP("hover can be momentarily inconsistent on X11, depending on timing of flushFrameSynchronousEvents with touch and mouse movements (QTBUG-55350)"); - QTest::touchEvent(window, device).press(0, p2, window); + QTest::touchEvent(window.data(), device).press(0, p2, window.data()); QVERIFY(mouseArea1->hovered()); QVERIFY(mouseArea2->hovered()); @@ -1435,7 +1390,7 @@ void tst_TouchMouse::hoverEnabled() QCOMPARE(enterSpy1.count(), 1); QCOMPARE(enterSpy2.count(), 1); - QTest::touchEvent(window, device).release(0, p2, window); + QTest::touchEvent(window.data(), device).release(0, p2, window.data()); QVERIFY(clickSpy2.count() == 1); QVERIFY(mouseArea1->hovered()); @@ -1444,7 +1399,7 @@ void tst_TouchMouse::hoverEnabled() QCOMPARE(exitSpy2.count(), 1); // ------------------------- Another touch click on mouseArea1 - QTest::touchEvent(window, device).press(0, p1, window); + QTest::touchEvent(window.data(), device).press(0, p1, window.data()); QCOMPARE(enterSpy1.count(), 1); QCOMPARE(enterSpy2.count(), 1); @@ -1452,7 +1407,7 @@ void tst_TouchMouse::hoverEnabled() QVERIFY(mouseArea1->hovered()); QVERIFY(!mouseArea2->hovered()); - QTest::touchEvent(window, device).release(0, p1, window); + QTest::touchEvent(window.data(), device).release(0, p1, window.data()); QCOMPARE(clickSpy1.count(), 2); QVERIFY(mouseArea1->hovered()); QVERIFY(!mouseArea1->pressed()); |