From bb594453f9cb96bf8f2975d4a8aa5379cfc46e23 Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Sat, 25 Jun 2016 12:16:25 +0200 Subject: Flickable: add horizontal/verticalOvershoot properties [ChangeLog][QtQuick][Flickable] Added horizontalOvershoot and verticalOvershoot properties that can be used for implementing boundary actions and effects. Task-number: QTBUG-38515 Change-Id: I06379348a67d03507b56788d6fc7020bbb2d375f Reviewed-by: Robin Burchell --- .../auto/quick/qquickflickable/data/overshoot.qml | 79 +++++++++ .../qquickflickable/data/overshoot_reentrant.qml | 55 ++++++ .../quick/qquickflickable/tst_qquickflickable.cpp | 196 +++++++++++++++++++++ 3 files changed, 330 insertions(+) create mode 100644 tests/auto/quick/qquickflickable/data/overshoot.qml create mode 100644 tests/auto/quick/qquickflickable/data/overshoot_reentrant.qml (limited to 'tests') 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 window(new QQuickView); + window->setSource(testFileUrl("overshoot.qml")); + window->show(); + + QVERIFY(QTest::qWaitForWindowExposed(window.data())); + + QQuickFlickable *flickable = qobject_cast(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("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 window(new QQuickView); + window->setSource(testFileUrl("overshoot_reentrant.qml")); + window->show(); + + QVERIFY(QTest::qWaitForWindowExposed(window.data())); + + QQuickFlickable *flickable = qobject_cast(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" -- cgit v1.2.3 From 3f6d82715dda8dd06f6bddf2ed89e89640f63a2e Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Wed, 30 Nov 2016 09:40:23 +0100 Subject: Add TextInput::textEdited() [ChangeLog][QtQuick][TextInput] Added textEdited() signal to distinguish user edits from programmatical text changes. Change-Id: I1d78499e3e11f9f1cab80ce3b0a6d9f2713219f4 Task-number: QTBUG-57203 Reviewed-by: Mitch Curtis Reviewed-by: Shawn Rutledge --- .../quick/qquicktextinput/tst_qquicktextinput.cpp | 52 ++++++++++++++++++++++ 1 file changed, 52 insertions(+) (limited to 'tests') 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. -- cgit v1.2.3 From bb123fa3a4b06dabb2a63304ee3d24f94d74c1f2 Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Fri, 2 Dec 2016 12:08:29 +0100 Subject: add text manual test The initial goal is to verify the behavior of text, preeditText and displayText properties and their associated signals on various platforms. Change-Id: Ie50c78a83930e05158a197f38087db9ae3cba534 Reviewed-by: J-P Nurmi --- tests/manual/text/SignalIndicator.qml | 66 ++++++++++ tests/manual/text/main.cpp | 51 ++++++++ tests/manual/text/main.qml | 56 +++++++++ tests/manual/text/qml.qrc | 7 ++ tests/manual/text/text.pro | 7 ++ .../manual/text/textInputPropertiesAndSignals.qml | 134 +++++++++++++++++++++ 6 files changed, 321 insertions(+) create mode 100644 tests/manual/text/SignalIndicator.qml create mode 100644 tests/manual/text/main.cpp create mode 100644 tests/manual/text/main.qml create mode 100644 tests/manual/text/qml.qrc create mode 100644 tests/manual/text/text.pro create mode 100644 tests/manual/text/textInputPropertiesAndSignals.qml (limited to 'tests') diff --git a/tests/manual/text/SignalIndicator.qml b/tests/manual/text/SignalIndicator.qml new file mode 100644 index 0000000000..3eaadde6d7 --- /dev/null +++ b/tests/manual/text/SignalIndicator.qml @@ -0,0 +1,66 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the manual tests 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 { + implicitWidth: text.implicitWidth * 1.2 + implicitHeight: text.implicitHeight * 1.1 + color: "lightgrey" + property color blipColor: "green" + property int blipDuration: 30 // ms + property alias label: text.text + + function blip() { + blipAnim.start() + } + + SequentialAnimation on color { + id: blipAnim + PropertyAction { value: blipColor } + PauseAnimation { duration: blipDuration } + PropertyAction { value: "lightgrey" } + } + + Text { + id: text + anchors.centerIn: parent + } +} diff --git a/tests/manual/text/main.cpp b/tests/manual/text/main.cpp new file mode 100644 index 0000000000..a4e1060cf5 --- /dev/null +++ b/tests/manual/text/main.cpp @@ -0,0 +1,51 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the manual tests 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$ +** +****************************************************************************/ +#include +#include + +int main(int argc, char *argv[]) +{ + QGuiApplication app(argc, argv); + + QQmlApplicationEngine engine; + engine.load(QUrl(QStringLiteral("qrc:/main.qml"))); + + return app.exec(); +} diff --git a/tests/manual/text/main.qml b/tests/manual/text/main.qml new file mode 100644 index 0000000000..d7e214ee38 --- /dev/null +++ b/tests/manual/text/main.qml @@ -0,0 +1,56 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the manual tests 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 +import QtQuick.Window 2.2 +import "qrc:/quick/shared/" as Examples + +Window { + width: 800 + height: 600 + visible: true + Examples.LauncherList { + id: ll + anchors.fill: parent + Component.onCompleted: { + addExample("TextInput", "TextInput properties and signals", Qt.resolvedUrl("textInputPropertiesAndSignals.qml")) + } + } +} diff --git a/tests/manual/text/qml.qrc b/tests/manual/text/qml.qrc new file mode 100644 index 0000000000..555e37bd69 --- /dev/null +++ b/tests/manual/text/qml.qrc @@ -0,0 +1,7 @@ + + + main.qml + textInputPropertiesAndSignals.qml + SignalIndicator.qml + + diff --git a/tests/manual/text/text.pro b/tests/manual/text/text.pro new file mode 100644 index 0000000000..3705d41df0 --- /dev/null +++ b/tests/manual/text/text.pro @@ -0,0 +1,7 @@ +TEMPLATE = app + +QT += qml quick + +SOURCES += main.cpp + +RESOURCES += qml.qrc ../../../examples/quick/shared/quick_shared.qrc diff --git a/tests/manual/text/textInputPropertiesAndSignals.qml b/tests/manual/text/textInputPropertiesAndSignals.qml new file mode 100644 index 0000000000..a3fd602c16 --- /dev/null +++ b/tests/manual/text/textInputPropertiesAndSignals.qml @@ -0,0 +1,134 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the manual tests 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 +import QtQuick.Layouts 1.1 +import "qrc:/quick/shared/" as Shared + +Item { + width: 600; height: 600 + GridLayout { + columns: 3; rowSpacing: 6; columnSpacing: 6 + anchors { left: parent.left; right: parent.right; top: parent.top; margins: 12 } + + // ---------------------------------------------------- + Text { + text: "try typing and input methods in the TextInput below:" + Layout.columnSpan: 3 + } + + // ---------------------------------------------------- + Text { + text: "TextInput" + } + + Rectangle { + Layout.fillWidth: true + implicitHeight: textInput.implicitHeight + 8 + radius: 4; antialiasing: true + border.color: "black"; color: "transparent" + + TextInput { + id: textInput + anchors.fill: parent; anchors.margins: 4 + + onTextEdited: textEditedInd.blip() + onTextChanged: textChangedInd.blip() + onPreeditTextChanged: preeditInd.blip() + onDisplayTextChanged: displayTextInd.blip() + } + + } + + SignalIndicator { + id: textEditedInd + label: "textEdited" + } + + // ---------------------------------------------------- + Text { text: "text" } + + Text { text: textInput.text; Layout.fillWidth: true } + + SignalIndicator { + id: textChangedInd + label: "textChanged" + } + + // ---------------------------------------------------- + Text { text: "preeditText" } + + Text { text: textInput.preeditText; Layout.fillWidth: true } + + SignalIndicator { + id: preeditInd + label: "preeditTextChanged" + } + + // ---------------------------------------------------- + Text { text: "displayText" } + + Text { text: textInput.displayText; Layout.fillWidth: true } + + SignalIndicator { + id: displayTextInd + label: "displayTextChanged" + } + + // ---------------------------------------------------- + Shared.TextField { + id: copyFrom + Layout.column: 1 + Layout.row: 5 + Layout.fillWidth: true + text: "copy this" + } + + Shared.Button { + Layout.column: 2 + Layout.row: 5 + text: "setText" + onClicked: { + Qt.inputMethod.reset() + textInput.text = copyFrom.text + } + } + } +} -- cgit v1.2.3 From f70066e95e7e23562155686cb7d7874b2d5da5a1 Mon Sep 17 00:00:00 2001 From: Oleg Yadrov Date: Tue, 20 Dec 2016 16:45:20 -0800 Subject: Make it possible to call grabToImage() on Window.contentItem Window.contentItem was not associated with any QQmlContext and QQmlEngine. A valid pointer to QQmlEngine is needed for callback function execution. Task-number: QTBUG-57175 Change-Id: Iab7730bfc8860521ff2e8c1631a11d0e1fe0cf94 Reviewed-by: Shawn Rutledge --- .../qquickwindow/data/grabContentItemToImage.qml | 15 +++++++++++++++ tests/auto/quick/qquickwindow/qquickwindow.pro | 3 ++- tests/auto/quick/qquickwindow/tst_qquickwindow.cpp | 19 +++++++++++++++++++ 3 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 tests/auto/quick/qquickwindow/data/grabContentItemToImage.qml (limited to 'tests') 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 300ca392f9..dd00154935 100644 --- a/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp +++ b/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp @@ -370,6 +370,8 @@ private slots: void pointerEventTypeAndPointCount(); + void grabContentItemToImage(); + private: QTouchDevice *touchDevice; QTouchDevice *touchDeviceWithVelocity; @@ -2554,6 +2556,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 cleanup(created); + QVERIFY(created); + + QQuickWindow *window = qobject_cast(created); + QVERIFY(QTest::qWaitForWindowActive(window)); + + QMetaObject::invokeMethod(window, "grabContentItemToImage"); + QTRY_COMPARE(created->property("success").toInt(), 1); +} + QTEST_MAIN(tst_qquickwindow) #include "tst_qquickwindow.moc" -- cgit v1.2.3 From f43dc181d7416eddfafb7493273a371c1eba8b4a Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Mon, 2 Jan 2017 10:46:38 +0100 Subject: Fix QML cache not being invalidated when source path changes When somebody renames the directory name underneath a QML file and its cache file, then we need to re-generate the cache as it contains the fully path of the source path. That is sometimes used to resolve relative URLs (such as images) and therefore needs updating (by re-creating the cache). Task-number: QTBUG-57644 Change-Id: I9766668859aad8e9d71f278c3f26c0585258c14e Reviewed-by: Lars Knoll --- tests/auto/qml/qmldiskcache/tst_qmldiskcache.cpp | 58 ++++++++++++++++++++++-- 1 file changed, 53 insertions(+), 5 deletions(-) (limited to 'tests') diff --git a/tests/auto/qml/qmldiskcache/tst_qmldiskcache.cpp b/tests/auto/qml/qmldiskcache/tst_qmldiskcache.cpp index 8af446173d..b265607fd1 100644 --- a/tests/auto/qml/qmldiskcache/tst_qmldiskcache.cpp +++ b/tests/auto/qml/qmldiskcache/tst_qmldiskcache.cpp @@ -53,6 +53,7 @@ private slots: void registerImportForImplicitComponent(); void basicVersionChecks(); void recompileAfterChange(); + void recompileAfterDirectoryChange(); void fileSelectors(); void localAliases(); void cacheResources(); @@ -95,11 +96,17 @@ struct TestCompiler TestCompiler(QQmlEngine *engine) : engine(engine) , tempDir() - , testFilePath(tempDir.path() + QStringLiteral("/test.qml")) - , cacheFilePath(tempDir.path() + QStringLiteral("/test.qmlc")) - , mappedFile(cacheFilePath) , currentMapping(nullptr) { + init(tempDir.path()); + } + + void init(const QString &baseDirectory) + { + closeMapping(); + testFilePath = baseDirectory + QStringLiteral("/test.qml"); + cacheFilePath = baseDirectory + QStringLiteral("/test.qmlc"); + mappedFile.setFileName(cacheFilePath); } bool compile(const QByteArray &contents) @@ -187,8 +194,8 @@ struct TestCompiler QQmlEngine *engine; const QTemporaryDir tempDir; - const QString testFilePath; - const QString cacheFilePath; + QString testFilePath; + QString cacheFilePath; QString lastErrorString; QFile mappedFile; uchar *currentMapping; @@ -441,6 +448,47 @@ void tst_qmldiskcache::recompileAfterChange() } } +void tst_qmldiskcache::recompileAfterDirectoryChange() +{ + QQmlEngine engine; + TestCompiler testCompiler(&engine); + + QVERIFY(testCompiler.tempDir.isValid()); + + QVERIFY(QDir(testCompiler.tempDir.path()).mkdir("source1")); + testCompiler.init(testCompiler.tempDir.path() + QLatin1String("/source1")); + + { + const QByteArray contents = QByteArrayLiteral("import QtQml 2.0\n" + "QtObject {\n" + " property int blah: 42;\n" + "}"); + + testCompiler.clearCache(); + QVERIFY2(testCompiler.compile(contents), qPrintable(testCompiler.lastErrorString)); + QVERIFY2(testCompiler.verify(), qPrintable(testCompiler.lastErrorString)); + testCompiler.closeMapping(); + } + + const QDateTime initialCacheTimeStamp = QFileInfo(testCompiler.cacheFilePath).lastModified(); + + QDir(testCompiler.tempDir.path()).rename(QStringLiteral("source1"), QStringLiteral("source2")); + waitForFileSystem(); + + testCompiler.init(testCompiler.tempDir.path() + QLatin1String("/source2")); + + { + CleanlyLoadingComponent component(&engine, testCompiler.testFilePath); + QScopedPointer obj(component.create()); + QVERIFY(!obj.isNull()); + QCOMPARE(obj->property("blah").toInt(), 42); + } + + QFile cacheFile(testCompiler.cacheFilePath); + QVERIFY2(cacheFile.exists(), qPrintable(cacheFile.fileName())); + QVERIFY(QFileInfo(testCompiler.cacheFilePath).lastModified() > initialCacheTimeStamp); +} + void tst_qmldiskcache::fileSelectors() { QQmlEngine engine; -- cgit v1.2.3 From 63a03f6772b8c008c3b7e6d17e484f585244a5e7 Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Fri, 30 Dec 2016 12:31:44 +0100 Subject: mpta-crosshairs manual test: correct the velocity vector rotation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit acos cannot return any possible angle, but atan2 can. Change-Id: Ic277bc1d3616900775b6076dce6b05bdf3c35da3 Reviewed-by: Jan Arve Sæther --- tests/manual/touch/mpta-crosshairs.qml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/manual/touch/mpta-crosshairs.qml b/tests/manual/touch/mpta-crosshairs.qml index 8b71e4fdc3..a55dfc7799 100644 --- a/tests/manual/touch/mpta-crosshairs.qml +++ b/tests/manual/touch/mpta-crosshairs.qml @@ -98,7 +98,8 @@ Rectangle { height: 1 x: touchPoint.x y: touchPoint.y - rotation: width > 0 ? Math.acos(touchPoint.velocity.x / width) : 0 + rotation: width > 0 ? Math.atan2(touchPoint.velocity.y, touchPoint.velocity.x) * 180 / Math.PI : 0 + Behavior on rotation { SmoothedAnimation { duration: 20 } } transformOrigin: Item.BottomLeft } -- cgit v1.2.3 From 4038160a32dcb51d843fb751a9a9340e7cc2bb63 Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Mon, 14 Mar 2016 17:37:36 +0100 Subject: MultiPointTouchArea.TouchPoint: add rotation, uniqueId and ellipseDiameters MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit So far uniqueId and rotation are mainly applicable to TUIO. Deprecate the area property in favor of ellipseDiameters. Also improve the mpta-crosshairs manual test to show this information. Change-Id: I16ea6618ae21ce66dac45638d6e2bb3c0a3b1818 Reviewed-by: Jan Arve Sæther --- tests/manual/touch/mpta-crosshairs.qml | 84 +++++++++++++++++++++++++--------- 1 file changed, 63 insertions(+), 21 deletions(-) (limited to 'tests') diff --git a/tests/manual/touch/mpta-crosshairs.qml b/tests/manual/touch/mpta-crosshairs.qml index a55dfc7799..d1dbd0f188 100644 --- a/tests/manual/touch/mpta-crosshairs.qml +++ b/tests/manual/touch/mpta-crosshairs.qml @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2015 The Qt Company Ltd. +** Copyright (C) 2017 The Qt Company Ltd. ** Contact: http://www.qt.io/licensing/ ** ** This file is part of the manual tests of the Qt Toolkit. @@ -38,11 +38,13 @@ ** ****************************************************************************/ -import QtQuick 2.4 +import QtQuick 2.9 import QtQuick.Window 2.2 Rectangle { id: root + width: 480 + height: 480 color: "black" MultiPointTouchArea { @@ -51,11 +53,11 @@ Rectangle { touchPoints: [ TouchPoint { property color color: "red" }, TouchPoint { property color color: "orange" }, - TouchPoint { property color color: "yellow" }, + TouchPoint { property color color: "lightsteelblue" }, TouchPoint { property color color: "green" }, TouchPoint { property color color: "blue" }, TouchPoint { property color color: "violet" }, - TouchPoint { property color color: "cyan" }, + TouchPoint { property color color: "steelblue" }, TouchPoint { property color color: "magenta" }, TouchPoint { property color color: "goldenrod" }, TouchPoint { property color color: "darkgray" } @@ -65,40 +67,80 @@ Rectangle { model: 10 Item { - anchors.fill: parent + id: crosshairs property TouchPoint touchPoint + x: touchPoint.x - width / 2 + y: touchPoint.y - height / 2 + width: 300; height: 300 visible: touchPoint.pressed + rotation: touchPoint.rotation Rectangle { color: touchPoint.color - anchors.top: parent.top - anchors.bottom: parent.bottom - width: 2 - x: touchPoint.x - 1 + anchors.centerIn: parent + width: 2; height: parent.height + antialiasing: true } Rectangle { color: touchPoint.color - anchors.left: parent.left - anchors.right: parent.right - height: 2 - y: touchPoint.y - 1 + anchors.centerIn: parent + width: parent.width; height: 2 + antialiasing: true } Rectangle { color: touchPoint.color - width: 50 * touchPoint.pressure - height: width + implicitWidth: label.implicitWidth + 8 + implicitHeight: label.implicitHeight + 16 radius: width / 2 - x: touchPoint.x - width / 2 - y: touchPoint.y - width / 2 + anchors.centerIn: parent + antialiasing: true + Rectangle { + color: "black" + opacity: 0.35 + width: (parent.width - 8) * touchPoint.pressure + height: width + radius: width / 2 + anchors.centerIn: parent + antialiasing: true + } + Rectangle { + color: "transparent" + border.color: "white" + border.width: 2 + opacity: 0.75 + visible: width > 0 + width: touchPoint.ellipseDiameters.width + height: touchPoint.ellipseDiameters.height + radius: Math.min(width, height) / 2 + anchors.centerIn: parent + antialiasing: true + } + Text { + id: label + anchors.centerIn: parent + color: "white" + horizontalAlignment: Text.AlignHCenter + verticalAlignment: Text.AlignVCenter + property string uid: touchPoint.uniqueId === undefined || touchPoint.uniqueId.numericId === -1 ? + "" : "\nUID " + touchPoint.uniqueId.numericId + text: "x " + touchPoint.x.toFixed(1) + + "\ny " + touchPoint.y.toFixed(1) + uid + + "\nID " + touchPoint.pointId.toString(16) + + "\n∡" + touchPoint.rotation.toFixed(1) + "°" + } } Rectangle { id: velocityVector visible: width > 0 width: touchPoint.velocity.length() - height: 1 - x: touchPoint.x - y: touchPoint.y - rotation: width > 0 ? Math.atan2(touchPoint.velocity.y, touchPoint.velocity.x) * 180 / Math.PI : 0 + height: 4 + Behavior on width { SmoothedAnimation { duration: 200 } } + radius: height / 2 + antialiasing: true + color: "gray" + x: crosshairs.width / 2 + y: crosshairs.height / 2 + rotation: width > 0 ? Math.atan2(touchPoint.velocity.y, touchPoint.velocity.x) * 180 / Math.PI - crosshairs.rotation : 0 Behavior on rotation { SmoothedAnimation { duration: 20 } } transformOrigin: Item.BottomLeft } -- cgit v1.2.3 From 26051fd5724e56e0715bc56fde8e8464ff386bbc Mon Sep 17 00:00:00 2001 From: Liang Qi Date: Tue, 10 Jan 2017 11:14:45 +0100 Subject: Blacklist tst_QQuickGraphicsInfo::testProperties() on linux Task-number: QTBUG-58039 Change-Id: Ib7a371c6dec7748b9c5257b6cf4dfb61efc7aa88 Reviewed-by: Simon Hausmann Reviewed-by: Lars Knoll --- tests/auto/quick/qquickgraphicsinfo/BLACKLIST | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 tests/auto/quick/qquickgraphicsinfo/BLACKLIST (limited to 'tests') diff --git a/tests/auto/quick/qquickgraphicsinfo/BLACKLIST b/tests/auto/quick/qquickgraphicsinfo/BLACKLIST new file mode 100644 index 0000000000..4cefc165f0 --- /dev/null +++ b/tests/auto/quick/qquickgraphicsinfo/BLACKLIST @@ -0,0 +1,3 @@ +[tst_QQuickGraphicsInfo::testProperties] +opensuse-42.1 +ubuntu-14.04 -- cgit v1.2.3 From ba244f5400bfff1601cc6b373383b55956fcf6bb Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Fri, 28 Oct 2016 17:23:13 +0200 Subject: tst_qqmllocale: use QVERIFY() rather than QCOMPARE(, true) Use booleans as booleans, it's what they're for. Change-Id: I68c0ba5efcfd3556eeef043b179769e91c77cf03 Reviewed-by: Simon Hausmann --- tests/auto/qml/qqmllocale/tst_qqmllocale.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'tests') diff --git a/tests/auto/qml/qqmllocale/tst_qqmllocale.cpp b/tests/auto/qml/qqmllocale/tst_qqmllocale.cpp index 4d2cae1523..44d11cdda3 100644 --- a/tests/auto/qml/qqmllocale/tst_qqmllocale.cpp +++ b/tests/auto/qml/qqmllocale/tst_qqmllocale.cpp @@ -1291,7 +1291,7 @@ void tst_qqmllocale::timeZoneUpdated() QQmlComponent c(&e, testFileUrl("timeZoneUpdated.qml")); QScopedPointer obj(c.create()); QVERIFY(obj); - QCOMPARE(obj->property("success").toBool(), true); + QVERIFY(obj->property("success").toBool()); // Change to Indian time setTimeZone(QByteArray("IST-05:30")); @@ -1302,7 +1302,7 @@ void tst_qqmllocale::timeZoneUpdated() setTimeZone(original); QMetaObject::invokeMethod(obj.data(), "resetTimeZone"); - QCOMPARE(obj->property("success").toBool(), true); + QVERIFY(obj->property("success").toBool()); } #endif -- cgit v1.2.3 From e7bfab82b45df088d15cbb4c5213ca94e260220d Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Wed, 9 Nov 2016 18:27:04 +0100 Subject: tst_qqmllocale: use unsetenv to clear environment variable tst_qqmllocale::timeZoneUpdated() was recording the prior time zone, frobbing it for the duration of its test, then restoring it. However, if TZ was previously unset, it got set to empty instead of being unset. This did not quite have the same effect; UTC ends up being used instead of the system default, with potential for conflict between system functions (that have attended to tzset) and third-party libraries (e.g. ICU) with internal state saved from before the change. Change-Id: I9f2147cd8858316e9ba5fd84d95dfc2c4538b0ab Reviewed-by: Matthew Vogt Reviewed-by: Simon Hausmann --- tests/auto/qml/qqmllocale/tst_qqmllocale.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/auto/qml/qqmllocale/tst_qqmllocale.cpp b/tests/auto/qml/qqmllocale/tst_qqmllocale.cpp index 44d11cdda3..7a6cb7c929 100644 --- a/tests/auto/qml/qqmllocale/tst_qqmllocale.cpp +++ b/tests/auto/qml/qqmllocale/tst_qqmllocale.cpp @@ -1267,7 +1267,10 @@ QString DateFormatter::getLocalizedForm(const QString &isoTimestamp) // which will require linking to a different library to access that API. static void setTimeZone(const QByteArray &tz) { - qputenv("TZ", tz); + if (tz.isEmpty()) + qunsetenv("TZ"); + else + qputenv("TZ", tz); ::tzset(); // following left for future reference, see comment above -- cgit v1.2.3 From fb15a8c24209cee59f2d7c5f0d00f327a68014d6 Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Fri, 4 Nov 2016 14:55:07 +0100 Subject: tst_qqmllocale: shuffle commentary on JS Date's month numbering While it departs from common date numbering, as used by QDateTime, the 0=Jan numbering used by JS's Date was copied from Java's Date, which (probably) copied it from ANSI C's struct tm; and C likes to count from zero. So don't call it weird; and let's comment on it where it's actually relevant (in JS code with the offset, rather than against uses of QDate, which uses 1=Jan numbering) and only once. Change-Id: I926138e88583339bec8641e3b28a642794dc217d Reviewed-by: Simon Hausmann --- tests/auto/qml/qqmllocale/data/date.qml | 1 + tests/auto/qml/qqmllocale/tst_qqmllocale.cpp | 12 ++++++------ 2 files changed, 7 insertions(+), 6 deletions(-) (limited to 'tests') diff --git a/tests/auto/qml/qqmllocale/data/date.qml b/tests/auto/qml/qqmllocale/data/date.qml index 3f58497d22..d8cd043cdf 100644 --- a/tests/auto/qml/qqmllocale/data/date.qml +++ b/tests/auto/qml/qqmllocale/data/date.qml @@ -7,6 +7,7 @@ QtObject { locale = Qt.locale(l) } + // Month number 9 is October: JS Date()'s month range is 0 to 11. function toLocaleString(fmt) { var d = new Date(2011, 9, 7, 18, 53, 48, 345); if (fmt < 0) diff --git a/tests/auto/qml/qqmllocale/tst_qqmllocale.cpp b/tests/auto/qml/qqmllocale/tst_qqmllocale.cpp index 7a6cb7c929..e0836468fb 100644 --- a/tests/auto/qml/qqmllocale/tst_qqmllocale.cpp +++ b/tests/auto/qml/qqmllocale/tst_qqmllocale.cpp @@ -641,7 +641,7 @@ void tst_qqmllocale::dateToLocaleString() QVERIFY(obj); QDateTime dt; - dt.setDate(QDate(2011, 10, 7)); // weirdly, JS Date month range is 0-11 + dt.setDate(QDate(2011, 10, 7)); dt.setTime(QTime(18, 53, 48, 345)); QMetaObject::invokeMethod(obj, "setLocale", Qt::DirectConnection, @@ -702,7 +702,7 @@ void tst_qqmllocale::dateToLocaleStringFormatted() QVERIFY(obj); QDateTime dt; - dt.setDate(QDate(2011, 10, 7)); // weirdly, JS Date month range is 0-11 + dt.setDate(QDate(2011, 10, 7)); dt.setTime(QTime(18, 53, 48, 345)); QMetaObject::invokeMethod(obj, "setLocale", Qt::DirectConnection, @@ -733,7 +733,7 @@ void tst_qqmllocale::dateToLocaleDateString() QVERIFY(obj); QDateTime dt; - dt.setDate(QDate(2011, 10, 7)); // weirdly, JS Date month range is 0-11 + dt.setDate(QDate(2011, 10, 7)); dt.setTime(QTime(18, 53, 48, 345)); QMetaObject::invokeMethod(obj, "setLocale", Qt::DirectConnection, @@ -794,7 +794,7 @@ void tst_qqmllocale::dateToLocaleDateStringFormatted() QVERIFY(obj); QDateTime dt; - dt.setDate(QDate(2011, 10, 7)); // weirdly, JS Date month range is 0-11 + dt.setDate(QDate(2011, 10, 7)); dt.setTime(QTime(18, 53, 48, 345)); QMetaObject::invokeMethod(obj, "setLocale", Qt::DirectConnection, @@ -825,7 +825,7 @@ void tst_qqmllocale::dateToLocaleTimeString() QVERIFY(obj); QDateTime dt; - dt.setDate(QDate(2011, 10, 7)); // weirdly, JS Date month range is 0-11 + dt.setDate(QDate(2011, 10, 7)); dt.setTime(QTime(18, 53, 48, 345)); QMetaObject::invokeMethod(obj, "setLocale", Qt::DirectConnection, @@ -886,7 +886,7 @@ void tst_qqmllocale::dateToLocaleTimeStringFormatted() QVERIFY(obj); QDateTime dt; - dt.setDate(QDate(2011, 10, 7)); // weirdly, JS Date month range is 0-11 + dt.setDate(QDate(2011, 10, 7)); dt.setTime(QTime(18, 53, 48, 345)); QMetaObject::invokeMethod(obj, "setLocale", Qt::DirectConnection, -- cgit v1.2.3 From 676340aef688e6271bb3df456a45cf26be52f588 Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Fri, 4 Nov 2016 16:04:36 +0100 Subject: tst_qqmllocale: simplify creation of a QDateTime Nine tests all used setDate and setTime on a default QDateTime, where just initializing it right, in one line, is simple, terse and easy to understand. This also allows it to be const. Change-Id: I77fd8b36b705cafc49f9020ae9280dfdcfece0d8 Reviewed-by: Simon Hausmann --- tests/auto/qml/qqmllocale/tst_qqmllocale.cpp | 36 +++++++--------------------- 1 file changed, 9 insertions(+), 27 deletions(-) (limited to 'tests') diff --git a/tests/auto/qml/qqmllocale/tst_qqmllocale.cpp b/tests/auto/qml/qqmllocale/tst_qqmllocale.cpp index e0836468fb..1b83738ecf 100644 --- a/tests/auto/qml/qqmllocale/tst_qqmllocale.cpp +++ b/tests/auto/qml/qqmllocale/tst_qqmllocale.cpp @@ -640,9 +640,7 @@ void tst_qqmllocale::dateToLocaleString() QObject *obj = c.create(); QVERIFY(obj); - QDateTime dt; - dt.setDate(QDate(2011, 10, 7)); - dt.setTime(QTime(18, 53, 48, 345)); + const QDateTime dt(QDate(2011, 10, 7), QTime(18, 53, 48, 345)); QMetaObject::invokeMethod(obj, "setLocale", Qt::DirectConnection, Q_ARG(QVariant, QVariant(locale))); @@ -701,9 +699,7 @@ void tst_qqmllocale::dateToLocaleStringFormatted() QObject *obj = c.create(); QVERIFY(obj); - QDateTime dt; - dt.setDate(QDate(2011, 10, 7)); - dt.setTime(QTime(18, 53, 48, 345)); + const QDateTime dt(QDate(2011, 10, 7), QTime(18, 53, 48, 345)); QMetaObject::invokeMethod(obj, "setLocale", Qt::DirectConnection, Q_ARG(QVariant, QVariant(locale))); @@ -732,9 +728,7 @@ void tst_qqmllocale::dateToLocaleDateString() QObject *obj = c.create(); QVERIFY(obj); - QDateTime dt; - dt.setDate(QDate(2011, 10, 7)); - dt.setTime(QTime(18, 53, 48, 345)); + const QDateTime dt(QDate(2011, 10, 7), QTime(18, 53, 48, 345)); QMetaObject::invokeMethod(obj, "setLocale", Qt::DirectConnection, Q_ARG(QVariant, QVariant(locale))); @@ -793,9 +787,7 @@ void tst_qqmllocale::dateToLocaleDateStringFormatted() QObject *obj = c.create(); QVERIFY(obj); - QDateTime dt; - dt.setDate(QDate(2011, 10, 7)); - dt.setTime(QTime(18, 53, 48, 345)); + const QDateTime dt(QDate(2011, 10, 7), QTime(18, 53, 48, 345)); QMetaObject::invokeMethod(obj, "setLocale", Qt::DirectConnection, Q_ARG(QVariant, QVariant(locale))); @@ -824,9 +816,7 @@ void tst_qqmllocale::dateToLocaleTimeString() QObject *obj = c.create(); QVERIFY(obj); - QDateTime dt; - dt.setDate(QDate(2011, 10, 7)); - dt.setTime(QTime(18, 53, 48, 345)); + const QDateTime dt(QDate(2011, 10, 7), QTime(18, 53, 48, 345)); QMetaObject::invokeMethod(obj, "setLocale", Qt::DirectConnection, Q_ARG(QVariant, QVariant(locale))); @@ -885,9 +875,7 @@ void tst_qqmllocale::dateToLocaleTimeStringFormatted() QObject *obj = c.create(); QVERIFY(obj); - QDateTime dt; - dt.setDate(QDate(2011, 10, 7)); - dt.setTime(QTime(18, 53, 48, 345)); + const QDateTime dt(QDate(2011, 10, 7), QTime(18, 53, 48, 345)); QMetaObject::invokeMethod(obj, "setLocale", Qt::DirectConnection, Q_ARG(QVariant, QVariant(locale))); @@ -927,9 +915,7 @@ void tst_qqmllocale::dateFromLocaleString() QObject *obj = c.create(); QVERIFY(obj); - QDateTime dt; - dt.setDate(QDate(2011, 10, 7)); - dt.setTime(QTime(18, 53, 48, 345)); + const QDateTime dt(QDate(2011, 10, 7), QTime(18, 53, 48, 345)); QMetaObject::invokeMethod(obj, "setLocale", Qt::DirectConnection, Q_ARG(QVariant, QVariant(locale))); @@ -971,9 +957,7 @@ void tst_qqmllocale::dateFromLocaleDateString() QObject *obj = c.create(); QVERIFY(obj); - QDateTime dt; - dt.setDate(QDate(2011, 10, 7)); - dt.setTime(QTime(18, 53, 48, 345)); + const QDateTime dt(QDate(2011, 10, 7), QTime(18, 53, 48, 345)); QMetaObject::invokeMethod(obj, "setLocale", Qt::DirectConnection, Q_ARG(QVariant, QVariant(locale))); @@ -1015,9 +999,7 @@ void tst_qqmllocale::dateFromLocaleTimeString() QObject *obj = c.create(); QVERIFY(obj); - QDateTime dt; - dt.setDate(QDate(2011, 10, 7)); - dt.setTime(QTime(18, 53, 48, 345)); + const QDateTime dt(QDate(2011, 10, 7), QTime(18, 53, 48, 345)); QMetaObject::invokeMethod(obj, "setLocale", Qt::DirectConnection, Q_ARG(QVariant, QVariant(locale))); -- cgit v1.2.3 From 7277fdd603c940fb99c3eda183f5d75f32c57e7b Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Fri, 4 Nov 2016 16:20:06 +0100 Subject: tst_qqmllocale: avoid duplicating a QLocale::toString() call Reuse the same const QString in both places, in each of the functions that repeated this pattern. Change-Id: Ic20281692d84b3ad5257af9837957e0893452b1a Reviewed-by: Simon Hausmann --- tests/auto/qml/qqmllocale/tst_qqmllocale.cpp | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'tests') diff --git a/tests/auto/qml/qqmllocale/tst_qqmllocale.cpp b/tests/auto/qml/qqmllocale/tst_qqmllocale.cpp index 1b83738ecf..d0ce83b997 100644 --- a/tests/auto/qml/qqmllocale/tst_qqmllocale.cpp +++ b/tests/auto/qml/qqmllocale/tst_qqmllocale.cpp @@ -921,13 +921,14 @@ void tst_qqmllocale::dateFromLocaleString() Q_ARG(QVariant, QVariant(locale))); QLocale l(locale); + const QString localeText(l.toString(dt, format)); QVariant val; QMetaObject::invokeMethod(obj, "fromLocaleString", Qt::DirectConnection, Q_RETURN_ARG(QVariant, val), - Q_ARG(QVariant, QVariant(l.toString(dt, format))), + Q_ARG(QVariant, QVariant(localeText)), Q_ARG(QVariant, QVariant(format))); - QDateTime pd = l.toDateTime(l.toString(dt, format), format); + QDateTime pd = l.toDateTime(localeText, format); QCOMPARE(val.toDateTime(), pd); } @@ -963,13 +964,14 @@ void tst_qqmllocale::dateFromLocaleDateString() Q_ARG(QVariant, QVariant(locale))); QLocale l(locale); + const QString localeText(l.toString(dt, format)); QVariant val; QMetaObject::invokeMethod(obj, "fromLocaleDateString", Qt::DirectConnection, Q_RETURN_ARG(QVariant, val), - Q_ARG(QVariant, QVariant(l.toString(dt, format))), + Q_ARG(QVariant, QVariant(localeText)), Q_ARG(QVariant, QVariant(format))); - QDate pd = l.toDate(l.toString(dt, format), format); + QDate pd = l.toDate(localeText, format); QCOMPARE(val.toDate(), pd); } @@ -1005,13 +1007,14 @@ void tst_qqmllocale::dateFromLocaleTimeString() Q_ARG(QVariant, QVariant(locale))); QLocale l(locale); + const QString localeText(l.toString(dt, format)); QVariant val; QMetaObject::invokeMethod(obj, "fromLocaleTimeString", Qt::DirectConnection, Q_RETURN_ARG(QVariant, val), - Q_ARG(QVariant, QVariant(l.toString(dt, format))), + Q_ARG(QVariant, QVariant(localeText)), Q_ARG(QVariant, QVariant(format))); - QTime pd = l.toTime(l.toString(dt, format), format); + QTime pd = l.toTime(localeText, format); QCOMPARE(val.toTime(), pd); } -- cgit v1.2.3 From 6746db54f2adb40b836ce41101462bc38604749f Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Wed, 11 Jan 2017 11:44:58 +0100 Subject: QML tooling: Make sure we signal object creation also from QQmlIncubator We have to call the QQmlEngineDebugService back from QQmlObjectCreator rather than QQmlComponent, as there are more ways to create an object. We also add the new instance to the global instance list if only the V4 debug service is active, as both QQmlEngineDebugService and QV4DebugService use it. Change-Id: I5dcc71b2e91049bc19ec70d7b87959a61c9b6b75 Reviewed-by: Simon Hausmann --- .../tst_qqmlenginedebugservice.cpp | 28 ++++++++++++++++++++++ .../qml/debugger/shared/qqmlenginedebugclient.cpp | 4 +++- .../qml/debugger/shared/qqmlenginedebugclient.h | 2 +- 3 files changed, 32 insertions(+), 2 deletions(-) (limited to 'tests') diff --git a/tests/auto/qml/debugger/qqmlenginedebugservice/tst_qqmlenginedebugservice.cpp b/tests/auto/qml/debugger/qqmlenginedebugservice/tst_qqmlenginedebugservice.cpp index 40e19d375d..8c30a82317 100644 --- a/tests/auto/qml/debugger/qqmlenginedebugservice/tst_qqmlenginedebugservice.cpp +++ b/tests/auto/qml/debugger/qqmlenginedebugservice/tst_qqmlenginedebugservice.cpp @@ -45,6 +45,7 @@ #include #include #include +#include #include #include @@ -136,6 +137,7 @@ private slots: void regression_QTCREATORBUG_7451(); void queryObjectWithNonStreamableTypes(); + void asynchronousCreate(); }; QmlDebugObjectReference tst_QQmlEngineDebugService::findRootObject( @@ -1220,6 +1222,32 @@ void tst_QQmlEngineDebugService::queryObjectTree() QCOMPARE(findProperty(animation.properties,"duration").value.toInt(), 100); } +void tst_QQmlEngineDebugService::asynchronousCreate() { + QmlDebugObjectReference object; + auto connection = connect(m_dbg, &QQmlEngineDebugClient::newObject, this, [&](int objectId) { + object.debugId = objectId; + }); + + QByteArray asynchronousComponent = "import QtQuick 2.5\n" + "Rectangle { id: asyncRect }"; + QQmlComponent component(m_engine); + component.setData(asynchronousComponent, QUrl::fromLocalFile("")); + QVERIFY(component.isReady()); // fails if bad syntax + QQmlIncubator incubator(QQmlIncubator::Asynchronous); + component.create(incubator); + + QVERIFY(m_dbg->object().idString != QLatin1String("asyncRect")); + + QTRY_VERIFY(object.debugId != -1); + disconnect(connection); + + bool success = false; + m_dbg->queryObject(object, &success); + QVERIFY(success); + + QTRY_COMPARE(m_dbg->object().idString, QLatin1String("asyncRect")); +} + int main(int argc, char *argv[]) { int _argc = argc + 1; diff --git a/tests/auto/qml/debugger/shared/qqmlenginedebugclient.cpp b/tests/auto/qml/debugger/shared/qqmlenginedebugclient.cpp index 3ad7beb7ff..3e27951d78 100644 --- a/tests/auto/qml/debugger/shared/qqmlenginedebugclient.cpp +++ b/tests/auto/qml/debugger/shared/qqmlenginedebugclient.cpp @@ -489,7 +489,9 @@ void QQmlEngineDebugClient::messageReceived(const QByteArray &data) return; } else if (type == "OBJECT_CREATED") { - emit newObjects(); + int engineId, objectId, parentId; + ds >> engineId >> objectId >> parentId; + emit newObject(objectId); return; } else if (type == "SET_BINDING_R") { ds >> m_valid; diff --git a/tests/auto/qml/debugger/shared/qqmlenginedebugclient.h b/tests/auto/qml/debugger/shared/qqmlenginedebugclient.h index a64a77e13e..5d74f2d43c 100644 --- a/tests/auto/qml/debugger/shared/qqmlenginedebugclient.h +++ b/tests/auto/qml/debugger/shared/qqmlenginedebugclient.h @@ -213,7 +213,7 @@ public: bool valid() { return m_valid; } signals: - void newObjects(); + void newObject(int objectId); void valueChanged(QByteArray,QVariant); void result(); -- cgit v1.2.3 From 5a5f140e60a65ae9a976444c1e47e5a8c606ff21 Mon Sep 17 00:00:00 2001 From: Robin Burchell Date: Thu, 5 Jan 2017 20:19:18 +0100 Subject: QQmlInfo: Add qmlDebug & qmlWarning functions alongside qmlInfo This way, we can correctly write to multiple levels of QDebug with QML context information. A followup change will port all existing callers, and subsequently change qmlInfo's message level to QtInfoMsg. [ChangeLog][QtQml] Introduced qmlDebug & qmlWarning functions to qqmlinfo.h, in addition to the pre-existing qmlInfo function. As a side effect, QQmlError has also gained messageType() and setMessageType(). Change-Id: I04ced5952c5c3c58293a89a6767c7b545c03cc0a Reviewed-by: Simon Hausmann --- tests/auto/qml/qqmlinfo/tst_qqmlinfo.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'tests') diff --git a/tests/auto/qml/qqmlinfo/tst_qqmlinfo.cpp b/tests/auto/qml/qqmlinfo/tst_qqmlinfo.cpp index acda06c8d8..ce3004a31c 100644 --- a/tests/auto/qml/qqmlinfo/tst_qqmlinfo.cpp +++ b/tests/auto/qml/qqmlinfo/tst_qqmlinfo.cpp @@ -49,6 +49,7 @@ private slots: void nonQmlContextedObject(); void types(); void chaining(); + void messageTypes(); private: QQmlEngine engine; @@ -202,6 +203,19 @@ void tst_qqmlinfo::chaining() << QUrl("http://www.qt-project.org"); } +// Ensure that messages of different types are sent with the correct QtMsgType. +void tst_qqmlinfo::messageTypes() +{ + QTest::ignoreMessage(QtDebugMsg, ": debug"); + qmlDebug(0) << QLatin1String("debug"); + + QTest::ignoreMessage(QtWarningMsg, ": info"); + qmlInfo(0) << QLatin1String("info"); + + QTest::ignoreMessage(QtWarningMsg, ": warning"); + qmlWarning(0) << QLatin1String("warning"); +} + QTEST_MAIN(tst_qqmlinfo) #include "tst_qqmlinfo.moc" -- cgit v1.2.3 From 0252d05d06f450b2f2783c905c424d24725fc70a Mon Sep 17 00:00:00 2001 From: Oleg Yadrov Date: Wed, 28 Dec 2016 14:40:11 -0800 Subject: PathView: fix crash on path remove There was no check if new path is a valid object Task-number: QTBUG-53917 Change-Id: I2fd9534c1d34633243d16eda56a2b07e18dabe16 Reviewed-by: Laszlo Agocs Reviewed-by: Shawn Rutledge Reviewed-by: Robin Burchell --- .../auto/quick/qquickpathview/data/removePath.qml | 26 ++++++++++++++++++++++ .../quick/qquickpathview/tst_qquickpathview.cpp | 14 ++++++++++++ 2 files changed, 40 insertions(+) create mode 100644 tests/auto/quick/qquickpathview/data/removePath.qml (limited to 'tests') 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 window(createView()); + window->setSource(testFileUrl("removePath.qml")); + window->show(); + + QQuickPathView *pathview = qobject_cast(window->rootObject()); + QVERIFY(pathview != 0); + + QVERIFY(QMetaObject::invokeMethod(pathview, "removePath")); + QVERIFY(QMetaObject::invokeMethod(pathview, "setPath")); +} + QTEST_MAIN(tst_QQuickPathView) #include "tst_qquickpathview.moc" -- cgit v1.2.3 From 3294d1b291ebd52eb967c7cdb2081ce4e594ad89 Mon Sep 17 00:00:00 2001 From: Robin Burchell Date: Wed, 11 Jan 2017 16:40:28 +0100 Subject: tst_touchmouse: Have a go at some stabilisation & improvements * Use QScopedPointer to own views, preventing leakage (was a problem in a few of these tests, e.g. pinchOnFlickable/flickableOnPinch/mouseOnFlickableOnPinch) * Only qWaitForWindowActive, as the tests aren't doing anything graphical, they don't need an expose event, which means less waiting * Use the test utilities to center the windows on screen to make sure they are not under desktop chrome & have a non-null position. If position is 0,0 that means window->position().isNull() is true, so qWaitForWindowActive will wait for its entire timeout: 5 seconds. This means no "manual" tweaking of geometry anymore: the position is now taken care of by the test utilities, and we let the root QML item size determine the window size. * Move the mouse away from the window using the test utilities. Done-with: Shawn Rutledge Change-Id: I4ac6a0d56067c57ef51f186fe3cd118cab056ff2 Reviewed-by: Shawn Rutledge --- tests/auto/quick/touchmouse/tst_touchmouse.cpp | 585 ++++++++++++------------- 1 file changed, 270 insertions(+), 315 deletions(-) (limited to 'tests') 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 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("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 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("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 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("eventItem1"); QVERIFY(eventItem1); EventItem *eventItem2 = window->rootObject()->findChild("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 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("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 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("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 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("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 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("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 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("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 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("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 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("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 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 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 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("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 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 events; EventItem *background = window->rootObject()->findChild("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 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()); -- cgit v1.2.3 From a16f2cc391c0be5614641e629267bcbf4d200951 Mon Sep 17 00:00:00 2001 From: Liang Qi Date: Wed, 11 Jan 2017 16:11:18 +0100 Subject: test: fix tst_QQuickGraphicsInfo::testProperties() This also reverts commit 26051fd5724e56e0715bc56fde8e8464ff386bbc. Task-number: QTBUG-58039 Change-Id: I0b9146a64f1a112f5c059b2e29e874631c81d12c Reviewed-by: David Faure --- tests/auto/quick/qquickgraphicsinfo/BLACKLIST | 3 --- tests/auto/quick/qquickgraphicsinfo/tst_qquickgraphicsinfo.cpp | 2 +- 2 files changed, 1 insertion(+), 4 deletions(-) delete mode 100644 tests/auto/quick/qquickgraphicsinfo/BLACKLIST (limited to 'tests') diff --git a/tests/auto/quick/qquickgraphicsinfo/BLACKLIST b/tests/auto/quick/qquickgraphicsinfo/BLACKLIST deleted file mode 100644 index 4cefc165f0..0000000000 --- a/tests/auto/quick/qquickgraphicsinfo/BLACKLIST +++ /dev/null @@ -1,3 +0,0 @@ -[tst_QQuickGraphicsInfo::testProperties] -opensuse-42.1 -ubuntu-14.04 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)); -- cgit v1.2.3 From 342c72da64cac4aec1463091f6fe0bfb16cd1850 Mon Sep 17 00:00:00 2001 From: Jan Arve Saether Date: Thu, 5 Jan 2017 13:42:14 +0100 Subject: Avoid needless notifications when destroying layouts When deleting a layout with children, it ends up in ~QQuickItem(), which in turn will call setParentItem(0). setParentItem(0) will in turn call setEffectiveVisibleRecur(), which will recurse down all its descendants. Therefore, deleting a top level layout might trigger item change listeners for *all* its descendants, not only its direct children. This behavior might even cause crashes: The visibility changes will then trigger an invalidation of the layout, which will propagate up the parent hierarchy, and potentially call invalidate() on a partially-destroyed layout, which then might crash. Change-Id: I48e11d57f69e9011ced6c3a0b51e3d89b24ad5c1 Task-number: QTBUG-55103 Reviewed-by: Shawn Rutledge --- .../auto/quick/qquicklayouts/data/tst_rowlayout.qml | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'tests') 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] -- cgit v1.2.3 From 0820efecb48d241f46f13f72c688d809fab6b72d Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Fri, 21 Oct 2016 17:21:36 -0500 Subject: Improve visibility into Positioner positioning from QML Add a forceLayout function, similar to the views, as well as a signal that indicates when positioning has completed. Change-Id: Ice01ea0840c707e403fdd4ea59d92a89e2ed8e4b Task-number: QTBUG-44762 Task-number: QTBUG-32114 Reviewed-by: J-P Nurmi --- tests/auto/qmltest/positioners/tst_positioners.qml | 75 ++++++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 tests/auto/qmltest/positioners/tst_positioners.qml (limited to 'tests') diff --git a/tests/auto/qmltest/positioners/tst_positioners.qml b/tests/auto/qmltest/positioners/tst_positioners.qml new file mode 100644 index 0000000000..03a0e13225 --- /dev/null +++ b/tests/auto/qmltest/positioners/tst_positioners.qml @@ -0,0 +1,75 @@ +/**************************************************************************** +** +** Copyright (C) 2016 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 +import QtTest 1.1 + +Item { + Column { + id: column + Repeater { + id: repeater + model: 2 + Rectangle { + width: 100 + height: 30 + border.width: 1 + } + } + } + + SignalSpy { + id: spy + target: column + signalName: "positioningComplete" + } + + TestCase { + function test_forceLayout() { + compare(column.height, 60) + repeater.model = 4 + column.forceLayout() + compare(column.height, 120) + + // initial positioning and our forced layout + compare(spy.count, 2) + } + } +} -- cgit v1.2.3 From 0e3380f9c6ab6e3ea7398caccf5aa84f1575f1cd Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Fri, 13 Jan 2017 13:31:35 +0100 Subject: Fix crash when C++ QJSValue parameterized signal interacts with JS When converting the parameters of a C++ signal to JS values to provide to a signal handler written in JS, the conversion of a QJSValue to a QV4::Value* may yield a null pointer in case of a default constructed QJSValue for example. This is a regression from commit aa869cbb06bcf005e238059a2cb0205947ff0b5f and we must check for this. Task-number: QTBUG-58133 Change-Id: I528b606b2851dfb3072e54902bd8843d31571a55 Reviewed-by: Lars Knoll --- tests/auto/qml/qqmlecmascript/data/signalParameterTypes.qml | 2 ++ tests/auto/qml/qqmlecmascript/testtypes.h | 1 + tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp | 1 + 3 files changed, 4 insertions(+) (limited to 'tests') diff --git a/tests/auto/qml/qqmlecmascript/data/signalParameterTypes.qml b/tests/auto/qml/qqmlecmascript/data/signalParameterTypes.qml index 4fc2dab943..676593096c 100644 --- a/tests/auto/qml/qqmlecmascript/data/signalParameterTypes.qml +++ b/tests/auto/qml/qqmlecmascript/data/signalParameterTypes.qml @@ -15,4 +15,6 @@ MyQmlObject onMySignal: { intProperty = a; realProperty = b; colorProperty = c; variantProperty = d; enumProperty = e; qtEnumProperty = f; } onBasicSignal: root.mySignal(10, 19.2, Qt.rgba(1, 1, 0, 1), Qt.rgba(1, 0, 1, 1), MyQmlObject.EnumValue3, Qt.LeftButton) + + onQjsValueEmittingSignal: {} } diff --git a/tests/auto/qml/qqmlecmascript/testtypes.h b/tests/auto/qml/qqmlecmascript/testtypes.h index 47fb2a56e7..1f7f3344ef 100644 --- a/tests/auto/qml/qqmlecmascript/testtypes.h +++ b/tests/auto/qml/qqmlecmascript/testtypes.h @@ -244,6 +244,7 @@ signals: void signalWithGlobalName(int parseInt); void intChanged(); void qjsvalueChanged(); + void qjsValueEmittingSignal(QJSValue value); public slots: void deleteMe() { delete this; } diff --git a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp index 88a8886ecb..b8f12e772d 100644 --- a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp +++ b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp @@ -1410,6 +1410,7 @@ void tst_qqmlecmascript::signalParameterTypes() QVERIFY(object != 0); emit object->basicSignal(); + emit object->qjsValueEmittingSignal(QJSValue()); QCOMPARE(object->property("intProperty").toInt(), 10); QCOMPARE(object->property("realProperty").toReal(), 19.2); -- cgit v1.2.3 From e85ebe01b61a64ed64592dedb71c5913cd5080fd Mon Sep 17 00:00:00 2001 From: Robin Burchell Date: Thu, 12 Jan 2017 21:36:38 +0100 Subject: Blacklist imageSource and svg tests QtSvg changed how the dimensions of an SVG are determined in 4bd5d6ced07d2d0e643a13e7cebb228c521d2046. These tests assume the old behavior at present, so blacklist the tests so qt5 integration can proceed. Task-number: QTBUG-58082 Change-Id: Ia579fbe6736932c081f9873d84bea4c01a975bad Reviewed-by: Lars Schmertmann Reviewed-by: Liang Qi Reviewed-by: Shawn Rutledge --- tests/auto/quick/qquickimage/BLACKLIST | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 tests/auto/quick/qquickimage/BLACKLIST (limited to 'tests') diff --git a/tests/auto/quick/qquickimage/BLACKLIST b/tests/auto/quick/qquickimage/BLACKLIST new file mode 100644 index 0000000000..c081228f5e --- /dev/null +++ b/tests/auto/quick/qquickimage/BLACKLIST @@ -0,0 +1,6 @@ +#QTBUG-58082 +[svg] +* +#QTBUG-58082 +[imageSource] +* -- cgit v1.2.3 From efa22507386d3a0dcc97b703219dcf9714f55a8d Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Fri, 13 Jan 2017 08:40:29 +0100 Subject: Deprecate Text::doLayout() in favor of forceLayout() Item views and positioners all have now forceLayout(), so make the Text element API consistent with them. The old doLayout(), which sounds more like an internal helper method, is deprecated and marked for removal in Qt 6. [ChangeLog][QtQuick][Text] Deprecated doLayout() in favor of forceLayout(). Change-Id: I051988fca13c4cd84904f7b268d51f6a96f28af3 Reviewed-by: Robin Burchell --- tests/testapplications/textlayout/styledtext-layout.qml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/testapplications/textlayout/styledtext-layout.qml b/tests/testapplications/textlayout/styledtext-layout.qml index 4ad0c7e279..80f62a6b8f 100644 --- a/tests/testapplications/textlayout/styledtext-layout.qml +++ b/tests/testapplications/textlayout/styledtext-layout.qml @@ -88,7 +88,7 @@ Rectangle { drag.target: rect acceptedButtons: Qt.LeftButton | Qt.RightButton onClicked: mouse.button == Qt.RightButton ? myText.font.pixelSize -= 1 : myText.font.pixelSize += 1 - onPositionChanged: myText.doLayout() + onPositionChanged: myText.forceLayout() } } } -- cgit v1.2.3 From ed024294c570b948970b36bc8ad8b303bfeebe4a Mon Sep 17 00:00:00 2001 From: Robin Burchell Date: Thu, 12 Jan 2017 21:42:57 +0100 Subject: Fix imageSource and svg tests after change to how QtSvg interprets image size These tests were blacklisted after QtSvg/4bd5d6ced07d2d0e643a13e7cebb228c521d2046. in order to integrate qt5.git. Now, fix the tests to match the new behavior, and remove the blacklisting. Task-number: QTBUG-58082 Change-Id: I77abe995095ee52978c5957e49e1547b3af7708b Reviewed-by: Lars Schmertmann Reviewed-by: Shawn Rutledge --- tests/auto/quick/qquickimage/BLACKLIST | 6 ------ tests/auto/quick/qquickimage/tst_qquickimage.cpp | 12 ++++++------ 2 files changed, 6 insertions(+), 12 deletions(-) delete mode 100644 tests/auto/quick/qquickimage/BLACKLIST (limited to 'tests') diff --git a/tests/auto/quick/qquickimage/BLACKLIST b/tests/auto/quick/qquickimage/BLACKLIST deleted file mode 100644 index c081228f5e..0000000000 --- a/tests/auto/quick/qquickimage/BLACKLIST +++ /dev/null @@ -1,6 +0,0 @@ -#QTBUG-58082 -[svg] -* -#QTBUG-58082 -[imageSource] -* diff --git a/tests/auto/quick/qquickimage/tst_qquickimage.cpp b/tests/auto/quick/qquickimage/tst_qquickimage.cpp index d345163db5..0b48c34b92 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 << ":2:1: QML Image: Error transferring {{ServerBaseUrl}}/no-such-file.png - server replied: Not found"; @@ -402,12 +402,12 @@ void tst_qquickimage::svg() component.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); QQuickImage *obj = qobject_cast(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; } -- cgit v1.2.3 From 01f7a9dbe2e41434db34841f7d0c812e7a492128 Mon Sep 17 00:00:00 2001 From: Robin Burchell Date: Sun, 15 Jan 2017 15:25:25 +0100 Subject: QQmlApplicationEngine: Yet another fix after QUrl behavior changes in QtBase Picture the following application: QQmlApplication qAppEngine("main.qml"); With main.qml: ... AComponentInTheSameDirectory { } ... This was failing, with the error: file:main.qml:13 AComponentInTheSameDirectory is not a type Which is wrong, but also reveals the root cause in that the original filename was not a fully resolved path. Change-Id: Ifc5557cc43f4bb92fd121ea9f7a37f09b3b38a9b Reviewed-by: David Faure --- .../qqmlapplicationengine/data/LocalComponent.qml | 6 ++++++ .../data/nonResolvedLocal.qml | 9 ++++++++ .../tst_qqmlapplicationengine.cpp | 24 ++++++++++++++++++++++ 3 files changed, 39 insertions(+) create mode 100644 tests/auto/qml/qqmlapplicationengine/data/LocalComponent.qml create mode 100644 tests/auto/qml/qqmlapplicationengine/data/nonResolvedLocal.qml (limited to 'tests') diff --git a/tests/auto/qml/qqmlapplicationengine/data/LocalComponent.qml b/tests/auto/qml/qqmlapplicationengine/data/LocalComponent.qml new file mode 100644 index 0000000000..ece4f45b4a --- /dev/null +++ b/tests/auto/qml/qqmlapplicationengine/data/LocalComponent.qml @@ -0,0 +1,6 @@ +import QtQml 2.0 + +// used in nonResolvedLocal +QtObject { + +} diff --git a/tests/auto/qml/qqmlapplicationengine/data/nonResolvedLocal.qml b/tests/auto/qml/qqmlapplicationengine/data/nonResolvedLocal.qml new file mode 100644 index 0000000000..45a235346d --- /dev/null +++ b/tests/auto/qml/qqmlapplicationengine/data/nonResolvedLocal.qml @@ -0,0 +1,9 @@ +import QtQml 2.0 + +QtObject { + property bool success: true + + property QtObject local: LocalComponent { + } +} + diff --git a/tests/auto/qml/qqmlapplicationengine/tst_qqmlapplicationengine.cpp b/tests/auto/qml/qqmlapplicationengine/tst_qqmlapplicationengine.cpp index 98b92e5fab..74add85cb0 100644 --- a/tests/auto/qml/qqmlapplicationengine/tst_qqmlapplicationengine.cpp +++ b/tests/auto/qml/qqmlapplicationengine/tst_qqmlapplicationengine.cpp @@ -42,6 +42,7 @@ public: private slots: void initTestCase(); void basicLoading(); + void testNonResolvedPath(); void application(); void applicationProperties(); private: @@ -83,6 +84,29 @@ void tst_qqmlapplicationengine::basicLoading() delete test; } +// make sure we resolve a relative URL to an absolute one, otherwise things +// will break. +void tst_qqmlapplicationengine::testNonResolvedPath() +{ + { + // NOTE NOTE NOTE! Missing testFileUrl is *WANTED* here! We want a + // non-resolved URL. + QQmlApplicationEngine test("data/nonResolvedLocal.qml"); + QCOMPARE(test.rootObjects().size(), 1); + QVERIFY(test.rootObjects()[0]); + QVERIFY(test.rootObjects()[0]->property("success").toBool()); + } + { + QQmlApplicationEngine test; + // NOTE NOTE NOTE! Missing testFileUrl is *WANTED* here! We want a + // non-resolved URL. + test.load("data/nonResolvedLocal.qml"); + QCOMPARE(test.rootObjects().size(), 1); + QVERIFY(test.rootObjects()[0]); + QVERIFY(test.rootObjects()[0]->property("success").toBool()); + } +} + void tst_qqmlapplicationengine::application() { /* This test batches together some tests about running an external application -- cgit v1.2.3 From 2c826af7c363e91656eb977fadb8afaf35f48290 Mon Sep 17 00:00:00 2001 From: Robin Burchell Date: Mon, 16 Jan 2017 12:51:41 +0100 Subject: tests: Remove some vestigial references qtdeclarative hasn't relied on qtwebkit for a long time (since fbfb27a44a824fe479b526cbc6ccd4696d674c83 & 56d34a653a7ec4265835a7cb9b6352696f802e31 as early as 2011!). Change-Id: If02572617034bf2c3eecbf081b96b1ed0ad65b45 Reviewed-by: Simon Hausmann --- .../qml/qqmlsqldatabase/tst_qqmlsqldatabase.cpp | 42 ---------------------- tests/auto/quick/examples/tst_examples.cpp | 6 ---- 2 files changed, 48 deletions(-) (limited to 'tests') diff --git a/tests/auto/qml/qqmlsqldatabase/tst_qqmlsqldatabase.cpp b/tests/auto/qml/qqmlsqldatabase/tst_qqmlsqldatabase.cpp index e16bfb08a2..3b982d1ab7 100644 --- a/tests/auto/qml/qqmlsqldatabase/tst_qqmlsqldatabase.cpp +++ b/tests/auto/qml/qqmlsqldatabase/tst_qqmlsqldatabase.cpp @@ -31,12 +31,6 @@ #include #include #include -/* -#include -#include -#include -#include -*/ #include #include #include @@ -150,42 +144,6 @@ void tst_qqmlsqldatabase::testQml_data() // test - in which case increment total_databases_created_by_tests above. } -/* -class QWebPageWithJavaScriptConsoleMessages : public QWebPage { -public: - void javaScriptConsoleMessage(const QString& message, int lineNumber, const QString& sourceID) - { - qWarning() << sourceID << ":" << lineNumber << ":" << message; - } -}; - -void tst_qqmlsqldatabase::validateAgainstWebkit() -{ - // Validates tests against WebKit (HTML5) support. - // - QFETCH(QString, jsfile); - QFETCH(QString, result); - QFETCH(int, databases); - - QFile f(jsfile); - QVERIFY(f.open(QIODevice::ReadOnly)); - QString js=f.readAll(); - - QWebPageWithJavaScriptConsoleMessages webpage; - webpage.settings()->setOfflineStoragePath(dbDir()); - webpage.settings()->setAttribute(QWebSettings::OfflineStorageDatabaseEnabled, true); - - QEXPECT_FAIL("","WebKit doesn't support openDatabaseSync yet", Continue); - QCOMPARE(webpage.mainFrame()->evaluateJavaScript(js).toString(),result); - - QTest::qWait(100); // WebKit crashes if you quit it too fast - - QWebSecurityOrigin origin = webpage.mainFrame()->securityOrigin(); - QList dbs = origin.databases(); - QCOMPARE(dbs.count(), databases); -} -*/ - void tst_qqmlsqldatabase::testQml() { if (engine->offlineStoragePath().isEmpty()) 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"; -- cgit v1.2.3 From 8eada7ae7d41a2d93142ea1a6454ab2bbb0998ed Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Fri, 30 Dec 2016 13:20:24 +0100 Subject: ListView: allow flicking to both directions Previously flicking was restricted to the orientation of the ListView. [ChangeLog][QtQuick][ListView] Made it possible to enable horizontal flicking in a vertical ListView, and vice versa. The only thing apps must do is to specify the desired flick direction and the content width (vertical ListView) or content height (horizontal ListView), which is not calculated by ListView. Change-Id: Ic370e57f5d18679940d48e7a2c20c200b2ef36d1 Task-number: QTBUG-52553 Task-number: QTBUG-56501 Reviewed-by: Robin Burchell Reviewed-by: Shawn Rutledge --- .../qquicklistview/data/flickBothDirections.qml | 70 +++++++++++++++++++ .../quick/qquicklistview/tst_qquicklistview.cpp | 79 ++++++++++++++++++++++ 2 files changed, 149 insertions(+) create mode 100644 tests/auto/quick/qquicklistview/data/flickBothDirections.qml (limited to 'tests') 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(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("initValues"); + QTest::addColumn("orientation"); + QTest::addColumn("flickableDirection"); + QTest::addColumn("contentWidth"); + QTest::addColumn("contentHeight"); + QTest::addColumn("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; -- cgit v1.2.3 From 373cdc297f343932218782d3587b98af5f8ccc53 Mon Sep 17 00:00:00 2001 From: Robin Burchell Date: Mon, 16 Jan 2017 15:51:58 +0100 Subject: Remove remnants of blackberry platform support The last remnants were removed from qtbase in 5.7 making this all dead code, so match here too. Change-Id: I10f3f1c614562f2a97ade7cdf5002065d6f79e07 Reviewed-by: Simon Hausmann --- tests/auto/quick/qquickimage/tst_qquickimage.cpp | 4 ---- tests/auto/quick/qquickitemlayer/tst_qquickitemlayer.cpp | 4 ---- tests/auto/quick/qquicktext/tst_qquicktext.cpp | 5 ----- 3 files changed, 13 deletions(-) (limited to 'tests') diff --git a/tests/auto/quick/qquickimage/tst_qquickimage.cpp b/tests/auto/quick/qquickimage/tst_qquickimage.cpp index 0b48c34b92..4699f947a1 100644 --- a/tests/auto/quick/qquickimage/tst_qquickimage.cpp +++ b/tests/auto/quick/qquickimage/tst_qquickimage.cpp @@ -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 window(new QQuickView); window->setSource(testFileUrl("mirror.qml")); 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/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 window(createView(testFile("horizontalAlignment_RightToLeft.qml"))); QQuickText *text = window->rootObject()->findChild("text"); QVERIFY(text != 0); -- cgit v1.2.3 From 0412de08fd65c5fef9d010a68b40a256f521ef61 Mon Sep 17 00:00:00 2001 From: Robin Burchell Date: Tue, 10 Jan 2017 15:49:49 +0100 Subject: qmlInfo: Switch message level to QtInfoMsg, matching the function name qmlInfo predated info-level messages in QtCore, and as such previously sent warning-level messages despite the unfortunate naming. Now that we have an actual qmlWarning function, and we have switched our code to use it, we can change qmlInfo's behavior to better match the function naming. This does have the impact that existing qmlInfo callers will basically need a s/qmlInfo/qmlWarning/g to retain the same QDebug level in user code, but I feel that this behavior change makes sense given the better consistency with C++-side QDebug we attain. [ChangeLog][QtQml][Important Behavior Changes] qmlInfo now reports messages with a QtMsgType of QtInfoMsg instead of QtWarningMsg. To continue to send warnings, callers should migrate to the newly-introduced qmlWarning function. Change-Id: I16c88d94377b5956eb6921b64af7c84d1ca024f6 Reviewed-by: Simon Hausmann --- tests/auto/qml/qqmlinfo/tst_qqmlinfo.cpp | 46 ++++++++++++++++---------------- 1 file changed, 23 insertions(+), 23 deletions(-) (limited to 'tests') diff --git a/tests/auto/qml/qqmlinfo/tst_qqmlinfo.cpp b/tests/auto/qml/qqmlinfo/tst_qqmlinfo.cpp index ce3004a31c..3f6c200027 100644 --- a/tests/auto/qml/qqmlinfo/tst_qqmlinfo.cpp +++ b/tests/auto/qml/qqmlinfo/tst_qqmlinfo.cpp @@ -63,14 +63,14 @@ void tst_qqmlinfo::qmlObject() QVERIFY(object != 0); QString message = component.url().toString() + ":3:1: QML QtObject: Test Message"; - QTest::ignoreMessage(QtWarningMsg, qPrintable(message)); + QTest::ignoreMessage(QtInfoMsg, qPrintable(message)); qmlInfo(object) << "Test Message"; QObject *nested = qvariant_cast(object->property("nested")); QVERIFY(nested != 0); message = component.url().toString() + ":6:13: QML QtObject: Second Test Message"; - QTest::ignoreMessage(QtWarningMsg, qPrintable(message)); + QTest::ignoreMessage(QtInfoMsg, qPrintable(message)); qmlInfo(nested) << "Second Test Message"; } @@ -87,11 +87,11 @@ void tst_qqmlinfo::nestedQmlObject() QVERIFY(nested2 != 0); QString message = component.url().toString() + ":5:13: QML NestedObject: Outer Object"; - QTest::ignoreMessage(QtWarningMsg, qPrintable(message)); + QTest::ignoreMessage(QtInfoMsg, qPrintable(message)); qmlInfo(nested) << "Outer Object"; message = testFileUrl("NestedObject.qml").toString() + ":6:14: QML QtObject: Inner Object"; - QTest::ignoreMessage(QtWarningMsg, qPrintable(message)); + QTest::ignoreMessage(QtInfoMsg, qPrintable(message)); qmlInfo(nested2) << "Inner Object"; } @@ -108,28 +108,28 @@ void tst_qqmlinfo::nestedComponent() QVERIFY(nested2 != 0); QString message = component.url().toString() + ":10:9: QML NestedObject: Complex Object"; - QTest::ignoreMessage(QtWarningMsg, qPrintable(message)); + QTest::ignoreMessage(QtInfoMsg, qPrintable(message)); qmlInfo(nested) << "Complex Object"; message = component.url().toString() + ":16:9: QML Image: Simple Object"; - QTest::ignoreMessage(QtWarningMsg, qPrintable(message)); + QTest::ignoreMessage(QtInfoMsg, qPrintable(message)); qmlInfo(nested2) << "Simple Object"; } void tst_qqmlinfo::nonQmlObject() { QObject object; - QTest::ignoreMessage(QtWarningMsg, ": QML QtObject: Test Message"); + QTest::ignoreMessage(QtInfoMsg, ": QML QtObject: Test Message"); qmlInfo(&object) << "Test Message"; QTimer nonQmlObject; - QTest::ignoreMessage(QtWarningMsg, ": QML QTimer: Test Message"); + QTest::ignoreMessage(QtInfoMsg, ": QML QTimer: Test Message"); qmlInfo(&nonQmlObject) << "Test Message"; } void tst_qqmlinfo::nullObject() { - QTest::ignoreMessage(QtWarningMsg, ": Null Object Test Message"); + QTest::ignoreMessage(QtInfoMsg, ": Null Object Test Message"); qmlInfo(0) << "Null Object Test Message"; } @@ -138,50 +138,50 @@ void tst_qqmlinfo::nonQmlContextedObject() QObject object; QQmlContext context(&engine); QQmlEngine::setContextForObject(&object, &context); - QTest::ignoreMessage(QtWarningMsg, ": QML QtObject: Test Message"); + QTest::ignoreMessage(QtInfoMsg, ": QML QtObject: Test Message"); qmlInfo(&object) << "Test Message"; } void tst_qqmlinfo::types() { - QTest::ignoreMessage(QtWarningMsg, ": false"); + QTest::ignoreMessage(QtInfoMsg, ": false"); qmlInfo(0) << false; - QTest::ignoreMessage(QtWarningMsg, ": 1.1"); + QTest::ignoreMessage(QtInfoMsg, ": 1.1"); qmlInfo(0) << 1.1; - QTest::ignoreMessage(QtWarningMsg, ": 1.2"); + QTest::ignoreMessage(QtInfoMsg, ": 1.2"); qmlInfo(0) << 1.2f; - QTest::ignoreMessage(QtWarningMsg, ": 15"); + QTest::ignoreMessage(QtInfoMsg, ": 15"); qmlInfo(0) << 15; - QTest::ignoreMessage(QtWarningMsg, ": 'b'"); + QTest::ignoreMessage(QtInfoMsg, ": 'b'"); qmlInfo(0) << QChar('b'); - QTest::ignoreMessage(QtWarningMsg, ": \"Qt\""); + QTest::ignoreMessage(QtInfoMsg, ": \"Qt\""); qmlInfo(0) << QByteArray("Qt"); - QTest::ignoreMessage(QtWarningMsg, ": true"); + QTest::ignoreMessage(QtInfoMsg, ": true"); qmlInfo(0) << bool(true); //### do we actually want QUrl to show up in the output? //### why the extra space at the end? - QTest::ignoreMessage(QtWarningMsg, ": QUrl(\"http://www.qt-project.org\") "); + QTest::ignoreMessage(QtInfoMsg, ": QUrl(\"http://www.qt-project.org\") "); qmlInfo(0) << QUrl("http://www.qt-project.org"); //### should this be quoted? - QTest::ignoreMessage(QtWarningMsg, ": hello"); + QTest::ignoreMessage(QtInfoMsg, ": hello"); qmlInfo(0) << QLatin1String("hello"); //### should this be quoted? - QTest::ignoreMessage(QtWarningMsg, ": World"); + QTest::ignoreMessage(QtInfoMsg, ": World"); QString str("Hello World"); QStringRef ref(&str, 6, 5); qmlInfo(0) << ref; //### should this be quoted? - QTest::ignoreMessage(QtWarningMsg, ": Quick"); + QTest::ignoreMessage(QtInfoMsg, ": Quick"); qmlInfo(0) << QString ("Quick"); } @@ -189,7 +189,7 @@ void tst_qqmlinfo::chaining() { QString str("Hello World"); QStringRef ref(&str, 6, 5); - QTest::ignoreMessage(QtWarningMsg, ": false 1.1 1.2 15 hello 'b' World \"Qt\" true Quick QUrl(\"http://www.qt-project.org\") "); + QTest::ignoreMessage(QtInfoMsg, ": false 1.1 1.2 15 hello 'b' World \"Qt\" true Quick QUrl(\"http://www.qt-project.org\") "); qmlInfo(0) << false << ' ' << 1.1 << ' ' << 1.2f << ' ' @@ -209,7 +209,7 @@ void tst_qqmlinfo::messageTypes() QTest::ignoreMessage(QtDebugMsg, ": debug"); qmlDebug(0) << QLatin1String("debug"); - QTest::ignoreMessage(QtWarningMsg, ": info"); + QTest::ignoreMessage(QtInfoMsg, ": info"); qmlInfo(0) << QLatin1String("info"); QTest::ignoreMessage(QtWarningMsg, ": warning"); -- cgit v1.2.3 From 89c6bee139422b17534f79129eea2820d2ce952e Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Mon, 16 Jan 2017 16:28:31 +0100 Subject: Fix support for QJSValue as C++ signal parameter type, part 2 After commit 0e3380f9c6ab6e3ea7398caccf5aa84f1575f1cd we wouldn't crash anymore, if QJSValue::UndefinedValue was provided as value for a QJSValue C++ signal parameter. However that was not a complete fix for the regression of commit aa869cbb06bcf005e238059a2cb0205947ff0b5f, as other primitive values stored in QJSValue as QVariant were not converted, so for example QJSValue(42). So let's fix this once and for all by using QJSValuePrivate::valueForData, that handles all types of QJSValuePrivate encodings. Task-number: QTBUG-58133 Change-Id: Ib7c0461b18df6260ccd4bce729ae2348281eb7f3 Reviewed-by: Arnaud Vrac Reviewed-by: Lars Knoll --- tests/auto/qml/qqmlecmascript/data/signalParameterTypes.qml | 8 +++++++- tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp | 7 ++++++- 2 files changed, 13 insertions(+), 2 deletions(-) (limited to 'tests') diff --git a/tests/auto/qml/qqmlecmascript/data/signalParameterTypes.qml b/tests/auto/qml/qqmlecmascript/data/signalParameterTypes.qml index 676593096c..54d29dfc94 100644 --- a/tests/auto/qml/qqmlecmascript/data/signalParameterTypes.qml +++ b/tests/auto/qml/qqmlecmascript/data/signalParameterTypes.qml @@ -16,5 +16,11 @@ MyQmlObject onBasicSignal: root.mySignal(10, 19.2, Qt.rgba(1, 1, 0, 1), Qt.rgba(1, 0, 1, 1), MyQmlObject.EnumValue3, Qt.LeftButton) - onQjsValueEmittingSignal: {} + property bool emittedQjsValueWasUndefined + property int emittedQjsValueAsInt + + onQjsValueEmittingSignal: { + emittedQjsValueWasUndefined = value === undefined; + emittedQjsValueAsInt = value + } } diff --git a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp index b8f12e772d..20f7940e9d 100644 --- a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp +++ b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp @@ -1410,7 +1410,6 @@ void tst_qqmlecmascript::signalParameterTypes() QVERIFY(object != 0); emit object->basicSignal(); - emit object->qjsValueEmittingSignal(QJSValue()); QCOMPARE(object->property("intProperty").toInt(), 10); QCOMPARE(object->property("realProperty").toReal(), 19.2); @@ -1419,6 +1418,12 @@ void tst_qqmlecmascript::signalParameterTypes() QVERIFY(object->property("enumProperty") == MyQmlObject::EnumValue3); QVERIFY(object->property("qtEnumProperty") == Qt::LeftButton); + emit object->qjsValueEmittingSignal(QJSValue()); + QVERIFY(object->property("emittedQjsValueWasUndefined").toBool()); + emit object->qjsValueEmittingSignal(QJSValue(42)); + QVERIFY(!object->property("emittedQjsValueWasUndefined").toBool()); + QCOMPARE(object->property("emittedQjsValueAsInt").value(), 42); + delete object; } -- cgit v1.2.3 From d7cd210bb4aed802d30e6f67e2db950e561a033b Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Wed, 18 Jan 2017 12:06:57 +0100 Subject: Make inspector animation speed test more robust We don't exactly know when the animation speed is actually set and the system clock may play tricks on us. Consider the test failed when the wrong animation speed is witnessed 3 times in a row and successful if the correct one is witnessed 3 times in a row. Also, make sure we don't confuse lines from different hits of the timer. Task-number: QTBUG-58186 Change-Id: Iaa2c35f723a92f32131e36084399b3d32accb7d0 Reviewed-by: Robin Burchell --- .../qml/debugger/qqmlinspector/data/qtquick2.qml | 5 +- .../debugger/qqmlinspector/tst_qqmlinspector.cpp | 53 ++++++++++++++-------- 2 files changed, 37 insertions(+), 21 deletions(-) (limited to 'tests') diff --git a/tests/auto/qml/debugger/qqmlinspector/data/qtquick2.qml b/tests/auto/qml/debugger/qqmlinspector/data/qtquick2.qml index f44c653840..f43cff15e4 100644 --- a/tests/auto/qml/debugger/qqmlinspector/data/qtquick2.qml +++ b/tests/auto/qml/debugger/qqmlinspector/data/qtquick2.qml @@ -29,16 +29,15 @@ Rectangle { } var milliDelta = millis - prevHit; - if (milliDelta < 0) + if (milliDelta <= 0) milliDelta += 1000; - console.log(milliDelta, "milliseconds "); prevHit = millis; var delta = parent.rotation - prevRotation; if (delta < 0) delta += 360 prevRotation = parent.rotation - console.log(delta, "degrees "); + console.log(milliDelta, delta, "ms/degrees "); } } } diff --git a/tests/auto/qml/debugger/qqmlinspector/tst_qqmlinspector.cpp b/tests/auto/qml/debugger/qqmlinspector/tst_qqmlinspector.cpp index f55fef232e..9461922eff 100644 --- a/tests/auto/qml/debugger/qqmlinspector/tst_qqmlinspector.cpp +++ b/tests/auto/qml/debugger/qqmlinspector/tst_qqmlinspector.cpp @@ -102,29 +102,46 @@ void tst_QQmlInspector::startQmlProcess(const QString &qmlFile, bool restrictSer void tst_QQmlInspector::checkAnimationSpeed(int targetMillisPerDegree) { - QString degreesString = QStringLiteral("degrees"); - QString millisecondsString = QStringLiteral("milliseconds"); - for (int i = 0; i < 2; ++i) { // skip one period; the change might have happened inside it - int position = m_process->output().length(); - while (!m_process->output().mid(position).contains(degreesString) || - !m_process->output().mid(position).contains(millisecondsString)) { + const QString markerString = QStringLiteral("ms/degrees"); + + // Funny things can happen with time and VMs. Also the change might take a while to propagate. + // Thus, we wait until we either have 3 passes or 3 failures in a row, or 10 loops have passed. + + int numFailures = 0; + int numPasses = 0; + + for (int i = 0; i < 10; ++i) { + QString output = m_process->output(); + int position = output.length(); + do { QVERIFY(QQmlDebugTest::waitForSignal(m_process.data(), SIGNAL(readyReadStandardOutput()))); + output = m_process->output(); + } while (!output.mid(position).contains(markerString)); + + + QStringList words = output.split(QLatin1Char(' ')); + const int marker = words.lastIndexOf(markerString); + QVERIFY(marker > 1); + const double degrees = words[marker - 1].toDouble(); + const int milliseconds = words[marker - 2].toInt(); + const double millisecondsPerDegree = milliseconds / degrees; + + if (millisecondsPerDegree > targetMillisPerDegree - 3 + || millisecondsPerDegree < targetMillisPerDegree + 3) { + if (++numPasses == 3) + return; // pass + numFailures = 0; + } else { + QVERIFY2(++numFailures < 3, + QString("3 consecutive failures when checking for %1 milliseconds per degree") + .arg(targetMillisPerDegree).toLocal8Bit().constData()); + numPasses = 0; } } - QStringList words = m_process->output().split(QLatin1Char(' ')); - int degreesMarker = words.lastIndexOf(degreesString); - QVERIFY(degreesMarker > 1); - double degrees = words[degreesMarker - 1].toDouble(); - int millisecondsMarker = words.lastIndexOf(millisecondsString); - QVERIFY(millisecondsMarker > 1); - int milliseconds = words[millisecondsMarker - 1].toInt(); - - double millisecondsPerDegree = milliseconds / degrees; - QVERIFY(millisecondsPerDegree > targetMillisPerDegree - 3); - QVERIFY(millisecondsPerDegree < targetMillisPerDegree + 3); - + QFAIL(QString("Animation speed won't settle to %1 milliseconds per degree") + .arg(targetMillisPerDegree).toLocal8Bit().constData()); } void tst_QQmlInspector::cleanup() -- cgit v1.2.3 From 7a8842460dc3c5e4e4ed42e7e2ae5bc619be5c78 Mon Sep 17 00:00:00 2001 From: Albert Astals Cid Date: Thu, 5 Jan 2017 16:52:54 +0100 Subject: Q_ENUMS -> Q_ENUM and Q_FLAGS -> Q_FLAG Change-Id: Ibedd0d0c23cf194ea02a229ab643450dbefd40aa Reviewed-by: Shawn Rutledge --- tests/auto/quick/qquickxmllistmodel/qquickxmllistmodel.pro | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'tests') 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) -- cgit v1.2.3 From edffdcf9b45641708fb242449b77e8e53ee05d87 Mon Sep 17 00:00:00 2001 From: Robin Burchell Date: Wed, 18 Jan 2017 20:08:44 +0100 Subject: test262: Allow specifying a custom V4CMD Useful for running a test tree against different qmljs or if qmljs is outside PATH. Change-Id: Ibaa24a15d32b21f9293db2c042fe3f1de3bb75eb Reviewed-by: Simon Hausmann --- tests/manual/v4/tests.pro | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/manual/v4/tests.pro b/tests/manual/v4/tests.pro index a86a6bf6af..ce4a34f7a0 100644 --- a/tests/manual/v4/tests.pro +++ b/tests/manual/v4/tests.pro @@ -1,7 +1,7 @@ TEMPLATE = aux TESTSCRIPT=$$PWD/test262.py -V4CMD = qmljs +isEmpty(V4CMD): V4CMD = qmljs checktarget.target = check checktarget.commands = python $$TESTSCRIPT --command=$$V4CMD --parallel --with-test-expectations --update-expectations -- cgit v1.2.3 From 03505d6eb7164298617c1a88979e802d7da12e15 Mon Sep 17 00:00:00 2001 From: Oleg Yadrov Date: Tue, 3 Jan 2017 14:49:13 -0800 Subject: StackLayout: propagate rearrange() call to child layouts MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Task-number: QTBUG-57867 Change-Id: I0190b892e2bc2966b82a0dbd99e53fd9d6848957 Reviewed-by: Jan Arve Sæther --- .../quick/qquicklayouts/data/tst_stacklayout.qml | 107 +++++++++++++++++++++ tests/auto/quick/qquicklayouts/qquicklayouts.pro | 3 +- 2 files changed, 109 insertions(+), 1 deletion(-) create mode 100644 tests/auto/quick/qquicklayouts/data/tst_stacklayout.qml (limited to 'tests') 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 -- cgit v1.2.3 From 7ee15ecdd960cde6d0202e9675f7f6bd31bbb927 Mon Sep 17 00:00:00 2001 From: Oleg Yadrov Date: Mon, 19 Dec 2016 12:08:20 -0800 Subject: PathAnimation: fix bug when PathSvg or PathLine is the last item in Path MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Both QQuickPathLine and QQuickPathSvg inherit QQuickCurve class which has “x” and “y” properties that return qreal type, but internally they are stored as QQmlNullableValue. At the same time, if any of them is not specified explicitly, its getter returns 0. QQuickPath processes QQuickPath%Type% objects and produces a QPainterPath which later used by QQuickPathAnimation. QQuickPathAnimation only created a QAbstractAnimationJob if QQuickPath::hasEnd returned true, and hasEnd returned true only if both “x” and “y” were specified explicitly. All that in conjunction led to the situation when if you had either - a PathLine with unspecified “x” or “y”; or - a PathSvg which was the last (or the only) path element in your Path, PathAnimation would not start. This patch removes hasEnd check, it should be safe to do because QPainterPath is always valid anyway due to the fact QQuickCurve::x() and QQuickCurve::y() return 0 if they have not been not explicitly set. Task-number: QTBUG-57666 Change-Id: Id320aaeb5aff0964d6493b7b80d5d9a7d36acce8 Reviewed-by: Robin Burchell --- .../data/pathLineUnspecifiedXYBug.qml | 28 ++++++++++++++ .../qquickanimations/data/pathSvgAnimation.qml | 25 ++++++++++++ .../qquickanimations/tst_qquickanimations.cpp | 44 ++++++++++++++++++++++ 3 files changed, 97 insertions(+) create mode 100644 tests/auto/quick/qquickanimations/data/pathLineUnspecifiedXYBug.qml create mode 100644 tests/auto/quick/qquickanimations/data/pathSvgAnimation.qml (limited to 'tests') 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 rect(qobject_cast(component.create())); + QVERIFY(rect); + + QQuickRectangle *redRect = rect->findChild(); + QVERIFY(redRect); + QQuickPathAnimation *pathAnim = rect->findChild(); + 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 rect(qobject_cast(component.create())); + QVERIFY(rect); + + QQuickRectangle *redRect = rect->findChild(); + QVERIFY(redRect); + QQuickPathAnimation *pathAnim = rect->findChild(); + 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" -- cgit v1.2.3 From 0b1d4983ff523be4c5758fc36e407fa7a4a18158 Mon Sep 17 00:00:00 2001 From: Liang Qi Date: Fri, 20 Jan 2017 10:21:01 +0100 Subject: qmltest: added layout/tst_layout.qml and related files They are moved from qtquickcontrols:tests/auto/controls in 3437fd56. Task-number: QTBUG-58294 Change-Id: I281d4e505b2f699154dd4efb7a4601bdf3856295 Reviewed-by: Shawn Rutledge --- tests/auto/qmltest/layout/Container.qml | 55 ++++++++++++++++++++ tests/auto/qmltest/layout/ContainerUser.qml | 53 ++++++++++++++++++++ tests/auto/qmltest/layout/tst_layout.qml | 78 +++++++++++++++++++++++++++++ 3 files changed, 186 insertions(+) create mode 100644 tests/auto/qmltest/layout/Container.qml create mode 100644 tests/auto/qmltest/layout/ContainerUser.qml create mode 100644 tests/auto/qmltest/layout/tst_layout.qml (limited to 'tests') diff --git a/tests/auto/qmltest/layout/Container.qml b/tests/auto/qmltest/layout/Container.qml new file mode 100644 index 0000000000..db3d68c485 --- /dev/null +++ b/tests/auto/qmltest/layout/Container.qml @@ -0,0 +1,55 @@ +/**************************************************************************** +** +** Copyright (C) 2016 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.5 +import QtQuick.Layouts 1.2 + +Item { + objectName: "qtbug51927-window" + visible: true + + default property alias _contents: customContent.data + + ColumnLayout { + id: customContent + objectName: "qtbug51927-columnLayout" + anchors.fill: parent + } +} diff --git a/tests/auto/qmltest/layout/ContainerUser.qml b/tests/auto/qmltest/layout/ContainerUser.qml new file mode 100644 index 0000000000..ff7ce6221b --- /dev/null +++ b/tests/auto/qmltest/layout/ContainerUser.qml @@ -0,0 +1,53 @@ +/**************************************************************************** +** +** Copyright (C) 2016 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.6 +import QtQuick.Window 2.2 + +Container { + visible: true + + Text { + objectName: "qtbug51927-text" + text: qsTr("Hello World") + anchors.centerIn: parent + renderType: Text.QtRendering + } +} diff --git a/tests/auto/qmltest/layout/tst_layout.qml b/tests/auto/qmltest/layout/tst_layout.qml new file mode 100644 index 0000000000..ee44a01080 --- /dev/null +++ b/tests/auto/qmltest/layout/tst_layout.qml @@ -0,0 +1,78 @@ +/**************************************************************************** +** +** 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 + +TestCase { + id: testCase + name: "Tests_Layout" + when:windowShown + width:400 + height:400 + + function test_invalidParent() { + ignoreWarning(':1:49: QML QtObject: Layout must be attached to Item elements') + var object = Qt.createQmlObject('import QtQuick 2.2; import QtQuick.Layouts 1.0; QtObject { Layout.fillWidth: true }', testCase, ''); + object.destroy() + } + + function test_defaultPropertyAliasCrash() { + var containerUserComponent = Qt.createComponent("ContainerUser.qml"); + compare(containerUserComponent.status, Component.Ready); + + var containerUser = containerUserComponent.createObject(testCase); + verify(containerUser); + + // Shouldn't crash. + containerUser.destroy(); + } +} + -- cgit v1.2.3 From b3629b4c27a17e7fbb2f3098b17d9b449f64bc47 Mon Sep 17 00:00:00 2001 From: Robin Burchell Date: Fri, 20 Jan 2017 00:36:57 +0100 Subject: tst_qqmlecmascript: Add some simple coverage for instanceof Since I'm working on this, it is nice to have some simple verification that things are working. I don't expect this to provide full coverage, but it should at least make sure that the basics are ok, and nicely provides a place to put further tests if it ever somehow breaks. Change-Id: If91154dee836cc514515bde122e48b271de22676 Reviewed-by: Lars Knoll --- .../auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp | 64 ++++++++++++++++++++++ 1 file changed, 64 insertions(+) (limited to 'tests') diff --git a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp index b8f12e772d..8c0b0601fc 100644 --- a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp +++ b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp @@ -331,6 +331,8 @@ private slots: void qtbug_54589(); void qtbug_54687(); void stringify_qtbug_50592(); + void instanceof_data(); + void instanceof(); private: // static void propertyVarWeakRefCallback(v8::Persistent object, void* parameter); @@ -8114,6 +8116,68 @@ void tst_qqmlecmascript::stringify_qtbug_50592() QCOMPARE(obj->property("source").toString(), QString::fromLatin1("http://example.org/some_nonexistant_image.png")); } +void tst_qqmlecmascript::instanceof_data() +{ + QTest::addColumn("setupCode"); + QTest::addColumn("expectedValue"); + + // so the way this works is that the name of the test tag defines the test + // to run. the code in setupCode defines code run before the actual test + // (e.g. to create vars). + // + // the expectedValue is either a boolean true or false for whether the two + // operands are indeed an instanceof each other, or a string for the + // expected error message. + QTest::newRow("String instanceof String") + << "" + << QVariant(false); + QTest::newRow("s instanceof String") + << "var s = \"hello\"" + << QVariant(false); + QTest::newRow("objectString instanceof String") + << "var objectString = new String(\"hello\")" + << QVariant(true); + QTest::newRow("o instanceof Object") + << "var o = new Object()" + << QVariant(true); + QTest::newRow("o instanceof String") + << "var o = new Object()" + << QVariant(false); + QTest::newRow("true instanceof true") + << "" + << QVariant("TypeError: Type error"); + QTest::newRow("1 instanceof Math") + << "" + << QVariant("TypeError: Type error"); + QTest::newRow("date instanceof Date") + << "var date = new Date" + << QVariant(true); + QTest::newRow("date instanceof Object") + << "var date = new Date" + << QVariant(true); + QTest::newRow("date instanceof String") + << "var date = new Date" + << QVariant(false); +} + +void tst_qqmlecmascript::instanceof() +{ + QFETCH(QString, setupCode); + QFETCH(QVariant, expectedValue); + + QJSEngine engine; + QJSValue ret = engine.evaluate(setupCode + ";\n" + QTest::currentDataTag()); + + if (expectedValue.type() == QMetaType::Bool) { + bool returnValue = ret.toBool(); + QVERIFY2(!ret.isError(), qPrintable(ret.toString())); + QCOMPARE(returnValue, expectedValue.toBool()); + } else { + QVERIFY2(ret.isError(), qPrintable(ret.toString())); + QCOMPARE(ret.toString(), expectedValue.toString()); + } +} + QTEST_MAIN(tst_qqmlecmascript) #include "tst_qqmlecmascript.moc" -- cgit v1.2.3 From c4067b42f7ab359ed8d1285211a3eb2311ed5338 Mon Sep 17 00:00:00 2001 From: Jan Arve Saether Date: Thu, 19 Jan 2017 16:10:09 +0100 Subject: Do not leak the item, and use a QScopedPointer to guarantee cleanup Change-Id: Ib4160f418686cef6d85dfd64657d25836f66778e Reviewed-by: Shawn Rutledge --- tests/auto/quick/qquickloader/tst_qquickloader.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'tests') 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(component.create()); + QScopedPointer item(qobject_cast(component.create())); QVERIFY(item); QQuickLoader *loader = qobject_cast(item->children().at(1)); @@ -481,7 +481,6 @@ void tst_QQuickLoader::networkComponent() QCOMPARE(loader->status(), QQuickLoader::Ready); QCOMPARE(static_cast(loader)->children().count(), 1); - delete loader; } void tst_QQuickLoader::failNetworkRequest() -- cgit v1.2.3 From 432eb3344b0581ea1915840365b71376388a75b2 Mon Sep 17 00:00:00 2001 From: Liang Qi Date: Tue, 10 Jan 2017 10:50:43 +0100 Subject: Blacklist qmltest::mouserelease::test_mouseDrag() on RHEL 7.2 Task-number: QTBUG-58025 Change-Id: I0768ea834d5666f2831f24c3b2c71b7a4260d5d9 Reviewed-by: Simon Hausmann --- tests/auto/qmltest/BLACKLIST | 2 ++ 1 file changed, 2 insertions(+) (limited to 'tests') diff --git a/tests/auto/qmltest/BLACKLIST b/tests/auto/qmltest/BLACKLIST index c38347b42a..fd796fcdb4 100644 --- a/tests/auto/qmltest/BLACKLIST +++ b/tests/auto/qmltest/BLACKLIST @@ -9,3 +9,5 @@ linux linux [ListView::test_listInteractiveCurrentIndexEnforce] linux +[mouserelease::test_mouseDrag] +rhel-7.2 -- cgit v1.2.3 From 941fb369ebfa7d44e5db0f589d81159fe156cf88 Mon Sep 17 00:00:00 2001 From: Jan Arve Saether Date: Mon, 23 Jan 2017 14:56:50 +0100 Subject: Stabilize test Obviously, if the animation still hasn't stopped, we cannot expect it to fail on the next QTRY_COMPARE, since that might wait until it then passes, thus CI will log that as an XPASS. This failed during CI run for MSVC 2015: XPASS : tst_QPauseAnimationJob::multipleSequentialGroups() QCOMPARE(((group.state())), QAbstractAnimationJob::Stopped) returned TRUE unexpectedly. tst_qpauseanimationjob.cpp(396) : failure location Change-Id: I25151123b8fc2617f2a4d3690215e6a1ed2856ff Reviewed-by: Shawn Rutledge --- .../auto/qml/animation/qpauseanimationjob/tst_qpauseanimationjob.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/auto/qml/animation/qpauseanimationjob/tst_qpauseanimationjob.cpp b/tests/auto/qml/animation/qpauseanimationjob/tst_qpauseanimationjob.cpp index 1791407934..ff295c5409 100644 --- a/tests/auto/qml/animation/qpauseanimationjob/tst_qpauseanimationjob.cpp +++ b/tests/auto/qml/animation/qpauseanimationjob/tst_qpauseanimationjob.cpp @@ -392,8 +392,10 @@ void tst_QPauseAnimationJob::multipleSequentialGroups() #ifdef Q_OS_WIN if (group.state() != QAbstractAnimationJob::Stopped) QEXPECT_FAIL("", winTimerError, Abort); -#endif + QCOMPARE(group.state(), QAbstractAnimationJob::Stopped); +#else QTRY_COMPARE(group.state(), QAbstractAnimationJob::Stopped); +#endif #ifdef Q_OS_WIN if (subgroup1.state() != QAbstractAnimationJob::Stopped) -- cgit v1.2.3 From b9fe2c2bfd99098ad06154d7fa8c104ac63a1257 Mon Sep 17 00:00:00 2001 From: Robin Burchell Date: Tue, 24 Jan 2017 12:35:13 +0100 Subject: Teach QQmlDirParser to ignore the classname keyword This saves QQmlImport from some unnecessary bad lookups when finding types (due to classname being misinterpreted as belonging as a component). Change-Id: I36e622e357e55e98a5af46911709640c5d8fa291 Reviewed-by: Simon Hausmann --- tests/auto/qml/qqmldirparser/data/classname/qmldir | 5 +++++ tests/auto/qml/qqmldirparser/tst_qqmldirparser.cpp | 9 +++++++++ 2 files changed, 14 insertions(+) create mode 100644 tests/auto/qml/qqmldirparser/data/classname/qmldir (limited to 'tests') diff --git a/tests/auto/qml/qqmldirparser/data/classname/qmldir b/tests/auto/qml/qqmldirparser/data/classname/qmldir new file mode 100644 index 0000000000..8167e813df --- /dev/null +++ b/tests/auto/qml/qqmldirparser/data/classname/qmldir @@ -0,0 +1,5 @@ +module QtQuick +plugin qtquick2plugin +classname QtQuick2Plugin +typeinfo plugins.qmltypes +designersupported diff --git a/tests/auto/qml/qqmldirparser/tst_qqmldirparser.cpp b/tests/auto/qml/qqmldirparser/tst_qqmldirparser.cpp index 7d154d0ea6..3643ca65c6 100644 --- a/tests/auto/qml/qqmldirparser/tst_qqmldirparser.cpp +++ b/tests/auto/qml/qqmldirparser/tst_qqmldirparser.cpp @@ -325,6 +325,15 @@ void tst_qqmldirparser::parse_data() << QStringList() << (QStringList() << "bar||1|0|true") << false; + + QTest::newRow("classname") + << "classname/qmldir" + << QStringList() + << (QStringList() << "qtquick2plugin|") + << QStringList() + << QStringList() + << QStringList() + << true; } void tst_qqmldirparser::parse() -- cgit v1.2.3 From ff1a728e957c36d566055caf922d160cbbbd7587 Mon Sep 17 00:00:00 2001 From: Robin Burchell Date: Sat, 21 Jan 2017 21:13:23 +0100 Subject: tst_compilation: Add a test for compilation of a large number of types As I'll be touching QQmlImport, it would be good to ensure it doesn't regress. This may also be useful for future such changes (e.g. I want to try play around with how the implicit import is handled). Results for me on a recent dev snapshot, 2013 rmbp: ********* Start testing of tst_compilation ********* Config: Using QtTest library 5.9.0, Qt 5.9.0 (x86_64-little_endian-lp64 shared (dynamic) release build; by Clang 8.0.0 (clang-800.0.42.1) (Apple)) PASS : tst_compilation::initTestCase() PASS : tst_compilation::bigimport(10, qmldir) RESULT : tst_compilation::bigimport():"10, qmldir": 3.6 msecs per iteration (total: 59, iterations: 16) PASS : tst_compilation::bigimport(100, qmldir) RESULT : tst_compilation::bigimport():"100, qmldir": 54 msecs per iteration (total: 54, iterations: 1) PASS : tst_compilation::bigimport(1000, qmldir) RESULT : tst_compilation::bigimport():"1000, qmldir": 558 msecs per iteration (total: 558, iterations: 1) PASS : tst_compilation::bigimport(10, noqmldir) RESULT : tst_compilation::bigimport():"10, noqmldir": 5.0 msecs per iteration (total: 80, iterations: 16) PASS : tst_compilation::bigimport(100, noqmldir) RESULT : tst_compilation::bigimport():"100, noqmldir": 58 msecs per iteration (total: 58, iterations: 1) PASS : tst_compilation::bigimport(1000, noqmldir) RESULT : tst_compilation::bigimport():"1000, noqmldir": 558 msecs per iteration (total: 558, iterations: 1) PASS : tst_compilation::cleanupTestCase() Totals: 8 passed, 0 failed, 0 skipped, 0 blacklisted, 22400ms ********* Finished testing of tst_compilation ********* Change-Id: I7159e561fb13a3c48e966d5b963dc0ef1ca783e3 Reviewed-by: Simon Hausmann --- .../benchmarks/qml/compilation/tst_compilation.cpp | 71 ++++++++++++++++++++++ 1 file changed, 71 insertions(+) (limited to 'tests') diff --git a/tests/benchmarks/qml/compilation/tst_compilation.cpp b/tests/benchmarks/qml/compilation/tst_compilation.cpp index 61339c6f60..b28d69332c 100644 --- a/tests/benchmarks/qml/compilation/tst_compilation.cpp +++ b/tests/benchmarks/qml/compilation/tst_compilation.cpp @@ -51,6 +51,9 @@ private slots: void jsparser_data(); void jsparser(); + void bigimport_data(); + void bigimport(); + private: QQmlEngine engine; }; @@ -115,6 +118,74 @@ void tst_compilation::jsparser() } } +void tst_compilation::bigimport_data() +{ + QTest::addColumn("filesToCreate"); + QTest::addColumn("writeQmldir"); + + QTest::newRow("10, qmldir") + << 10 << true; + QTest::newRow("100, qmldir") + << 100 << true; + QTest::newRow("1000, qmldir") + << 1000 << true; + + QTest::newRow("10, noqmldir") + << 10 << false; + QTest::newRow("100, noqmldir") + << 100 << false; + QTest::newRow("1000, noqmldir") + << 1000 << false; +} + +void tst_compilation::bigimport() +{ + QFETCH(int, filesToCreate); + QFETCH(bool, writeQmldir); + QTemporaryDir d; + //d.setAutoRemove(false); // for debugging + + QString p; + { + for (int i = 0; i < filesToCreate; ++i) { + QFile f(d.path() + QDir::separator() + QString::fromLatin1("Type%1.qml").arg(i)); + QVERIFY(f.open(QIODevice::WriteOnly)); + f.write("import QtQuick 2.0\n"); + f.write("import \".\"\n"); + f.write("Item {}\n"); + } + + QFile qmldir(d.path() + QDir::separator() + "qmldir"); + if (writeQmldir) + QVERIFY(qmldir.open(QIODevice::WriteOnly)); + QFile main(d.path() + QDir::separator() + "main.qml"); + QVERIFY(main.open(QIODevice::WriteOnly)); + p = QFileInfo(main).absoluteFilePath(); + //qDebug() << p; // for debugging + + main.write("import QtQuick 2.0\n"); + main.write("import \".\"\n"); + main.write("\n"); + main.write("Item {\n"); + + for (int i = 0; i < filesToCreate; ++i) { + main.write(qPrintable(QString::fromLatin1("Type%1 {}\n").arg(i))); + if (writeQmldir) + qmldir.write(qPrintable(QString::fromLatin1("Type%1 1.0 Type%1.qml\n").arg(i))); + } + + main.write("}"); + } + + QBENCHMARK { + QQmlEngine e; + QQmlComponent c(&e, p); + QCOMPARE(c.status(), QQmlComponent::Ready); + QScopedPointer o(c.create()); + QVERIFY(o->children().count() == filesToCreate); + } +} + QTEST_MAIN(tst_compilation) #include "tst_compilation.moc" -- cgit v1.2.3