From 3f01f6ff0396148e753066f481b3828522a94514 Mon Sep 17 00:00:00 2001 From: Albert Astals Cid Date: Tue, 28 May 2013 10:28:56 +0200 Subject: Resizing items out of the list viewport should not change the viewport Consider the old geometry, not the new one to check if an item was outside the viewport or not Change-Id: I108412d560faf86130044f3d091254c07af0c004 Reviewed-by: Alan Alpert --- .../data/outsideViewportChangeNotAffectingView.qml | 67 ++++++++++++++++++++++ .../quick/qquicklistview/tst_qquicklistview.cpp | 38 ++++++++++++ 2 files changed, 105 insertions(+) create mode 100644 tests/auto/quick/qquicklistview/data/outsideViewportChangeNotAffectingView.qml (limited to 'tests') diff --git a/tests/auto/quick/qquicklistview/data/outsideViewportChangeNotAffectingView.qml b/tests/auto/quick/qquicklistview/data/outsideViewportChangeNotAffectingView.qml new file mode 100644 index 0000000000..7903c392d1 --- /dev/null +++ b/tests/auto/quick/qquicklistview/data/outsideViewportChangeNotAffectingView.qml @@ -0,0 +1,67 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** 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 Digia Plc and its Subsidiary(-ies) 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.1 +import QtTest 1.0 + +Item { + function resizeThirdItem(size) { + resizingListModel.setProperty(3, "size", size) + } + + ListView { + width: 300 + height: 542 + model: ListModel { + id: resizingListModel + ListElement { size: 300; } + ListElement { size: 300; } + ListElement { size: 300; } + ListElement { size: 300; } + ListElement { size: 300; } + ListElement { size: 300; } + } + delegate: Rectangle { + width: parent.width + color: index % 2 == 0 ? "red" : "blue" + height: size + } + } +} diff --git a/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp b/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp index bec61eaccb..2268f0754c 100644 --- a/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp +++ b/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp @@ -209,6 +209,7 @@ private slots: void defaultHighlightMoveDuration(); void accessEmptyCurrentItem_QTBUG_30227(); void delayedChanges_QTBUG_30555(); + void outsideViewportChangeNotAffectingView(); private: template void items(const QUrl &source); @@ -6880,6 +6881,43 @@ void tst_QQuickListView::delayedChanges_QTBUG_30555() delete window; } +void tst_QQuickListView::outsideViewportChangeNotAffectingView() +{ + QQuickView *window = createView(); + window->setSource(testFileUrl("outsideViewportChangeNotAffectingView.qml")); + + QQuickListView *listview = window->rootObject()->findChild(); + QTRY_VERIFY(listview != 0); + + window->show(); + QVERIFY(QTest::qWaitForWindowExposed(window)); + + flick(window, QPoint(20, 200), QPoint(20, 20), 10); + + QTRY_COMPARE(listview->isFlicking(), false); + + QTRY_COMPARE(listview->indexAt(0, listview->contentY()), 4); + QTRY_COMPARE(listview->itemAt(0, listview->contentY())->y(), 1200.); + + QMetaObject::invokeMethod(window->rootObject(), "resizeThirdItem", Q_ARG(QVariant, 290)); + QTRY_COMPARE(listview->indexAt(0, listview->contentY()), 4); + QTRY_COMPARE(listview->itemAt(0, listview->contentY())->y(), 1200.); + + QMetaObject::invokeMethod(window->rootObject(), "resizeThirdItem", Q_ARG(QVariant, 300)); + QTRY_COMPARE(listview->indexAt(0, listview->contentY()), 4); + QTRY_COMPARE(listview->itemAt(0, listview->contentY())->y(), 1200.); + + QMetaObject::invokeMethod(window->rootObject(), "resizeThirdItem", Q_ARG(QVariant, 310)); + QTRY_COMPARE(listview->indexAt(0, listview->contentY()), 4); + QTRY_COMPARE(listview->itemAt(0, listview->contentY())->y(), 1200.); + + QMetaObject::invokeMethod(window->rootObject(), "resizeThirdItem", Q_ARG(QVariant, 400)); + QTRY_COMPARE(listview->indexAt(0, listview->contentY()), 4); + QTRY_COMPARE(listview->itemAt(0, listview->contentY())->y(), 1200.); + + delete window; +} + QTEST_MAIN(tst_QQuickListView) #include "tst_qquicklistview.moc" -- cgit v1.2.3 From 4f8b87e3066c007e2ef3d1a105e75e307d54bcac Mon Sep 17 00:00:00 2001 From: Rafael Roquetto Date: Tue, 23 Jul 2013 15:59:16 -0300 Subject: Fix tst_qquicktextinput for fullscreen platforms Change-Id: I42683f69a439608f778fbccf90573173bbc03f5b Reviewed-by: Wolfgang Bremer Reviewed-by: Frederik Gladhorn --- tests/auto/quick/qquicktextinput/tst_qquicktextinput.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'tests') diff --git a/tests/auto/quick/qquicktextinput/tst_qquicktextinput.cpp b/tests/auto/quick/qquicktextinput/tst_qquicktextinput.cpp index 8c72be56a4..def1c76ba1 100644 --- a/tests/auto/quick/qquicktextinput/tst_qquicktextinput.cpp +++ b/tests/auto/quick/qquicktextinput/tst_qquicktextinput.cpp @@ -1573,7 +1573,7 @@ void tst_qquicktextinput::verticalAlignment() QQuickView window(testFileUrl("horizontalAlignment.qml")); QQuickTextInput *textInput = window.rootObject()->findChild("text"); QVERIFY(textInput != 0); - window.show(); + window.showNormal(); QCOMPARE(textInput->vAlign(), QQuickTextInput::AlignTop); QVERIFY(textInput->boundingRect().bottom() < window.height() / 2); @@ -3314,7 +3314,7 @@ void tst_qquicktextinput::focusOnPress() QQuickWindow window; window.resize(100, 50); textInputObject->setParentItem(window.contentItem()); - window.show(); + window.showNormal(); window.requestActivate(); QTest::qWaitForWindowActive(&window); @@ -3377,7 +3377,7 @@ void tst_qquicktextinput::openInputPanel() inputMethodPrivate->testContext = &platformInputContext; QQuickView view(testFileUrl("openInputPanel.qml")); - view.show(); + view.showNormal(); view.requestActivate(); QTest::qWaitForWindowActive(&view); @@ -3769,7 +3769,7 @@ void tst_qquicktextinput::inputContextMouseHandler() input->setFocus(true); input->setText(""); - view.show(); + view.showNormal(); view.requestActivate(); QTest::qWaitForWindowActive(&view); -- cgit v1.2.3 From 56324d40c7704fcf2dfdacfa7ee9bdc8e8dd6b4e Mon Sep 17 00:00:00 2001 From: Rafael Roquetto Date: Tue, 23 Jul 2013 16:24:35 -0300 Subject: Fix tst_rendernode for fullscreen platforms Change-Id: Ib82aef04b7748ecdf148c3d9ec60ad15b3dfd7cb Reviewed-by: Frederik Gladhorn --- tests/auto/quick/rendernode/tst_rendernode.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/auto/quick/rendernode/tst_rendernode.cpp b/tests/auto/quick/rendernode/tst_rendernode.cpp index 509b209654..04b32499ff 100644 --- a/tests/auto/quick/rendernode/tst_rendernode.cpp +++ b/tests/auto/quick/rendernode/tst_rendernode.cpp @@ -59,7 +59,7 @@ public: QQuickView view; view.setSource(testFileUrl(fileName)); - view.show(); + view.showNormal(); QTest::qWaitForWindowExposed(&view); return view.grabWindow(); -- cgit v1.2.3 From 9c0f871a6b113529729f744d1edd22760911ebc0 Mon Sep 17 00:00:00 2001 From: Rafael Roquetto Date: Wed, 24 Jul 2013 19:17:11 -0300 Subject: Fix tst_qquickwindow for fullscreen platforms Change-Id: I040282f1bf1a2a8f212b9c7192a5ffaa2dbfdfb8 Reviewed-by: Wolfgang Bremer Reviewed-by: Frederik Gladhorn --- tests/auto/quick/qquickwindow/tst_qquickwindow.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp b/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp index e2bb6b431c..fbbc77c31c 100644 --- a/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp +++ b/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp @@ -1072,7 +1072,7 @@ void tst_qquickwindow::noUpdateWhenNothingChanges() QQuickRectangle rect(window.contentItem()); - window.show(); + window.showNormal(); QTRY_VERIFY(window.isExposed()); if (window.openglContext()->thread() == QGuiApplication::instance()->thread()) { -- cgit v1.2.3 From 1099b26535fedbaaa134ccb63310362951fce847 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Mon, 22 Jul 2013 15:52:54 +0200 Subject: Stabilize text tests that grab windows. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add window flags to make sure window stays on top to tst_qquicktext::hAlignImplicitWidth() and tst_qquicktextedit::hAlignVisual(). Add diagnostic output. Determine the section size by checking the font size. Add more characters to line 2 to make it more discriminative. Task-number: QTBUG-32540 Change-Id: I19a74a775bf2663027ec211784870fd9f6547b48 Reviewed-by: Simo Fält Reviewed-by: Alan Alpert --- .../quick/qquicktext/data/hAlignImplicitWidth.qml | 2 +- tests/auto/quick/qquicktext/tst_qquicktext.cpp | 52 ++++++++++++----- .../quick/qquicktextedit/data/hAlignVisual.qml | 2 +- .../quick/qquicktextedit/tst_qquicktextedit.cpp | 68 +++++++++++++++------- 4 files changed, 85 insertions(+), 39 deletions(-) (limited to 'tests') diff --git a/tests/auto/quick/qquicktext/data/hAlignImplicitWidth.qml b/tests/auto/quick/qquicktext/data/hAlignImplicitWidth.qml index 136e5d21a2..9c9318d3cc 100644 --- a/tests/auto/quick/qquicktext/data/hAlignImplicitWidth.qml +++ b/tests/auto/quick/qquicktext/data/hAlignImplicitWidth.qml @@ -6,7 +6,7 @@ Rectangle { Text { objectName: "textItem" - text: "AA\nBBBBB\nCCCCCCCCCCCCCCCC" + text: "AA\nBBBBBBB\nCCCCCCCCCCCCCCCC" anchors.centerIn: parent horizontalAlignment: Text.AlignLeft } diff --git a/tests/auto/quick/qquicktext/tst_qquicktext.cpp b/tests/auto/quick/qquicktext/tst_qquicktext.cpp index 6637d36318..51a5b2547f 100644 --- a/tests/auto/quick/qquicktext/tst_qquicktext.cpp +++ b/tests/auto/quick/qquicktext/tst_qquicktext.cpp @@ -854,9 +854,20 @@ int tst_qquicktext::numberOfNonWhitePixels(int fromX, int toX, const QImage &ima return pixels; } +static inline QByteArray msgNotGreaterThan(int n1, int n2) +{ + return QByteArray::number(n1) + QByteArrayLiteral(" is not greater than ") + QByteArray::number(n2); +} + +static inline QByteArray msgNotLessThan(int n1, int n2) +{ + return QByteArray::number(n1) + QByteArrayLiteral(" is not less than ") + QByteArray::number(n2); +} + void tst_qquicktext::hAlignImplicitWidth() { QQuickView view(testFileUrl("hAlignImplicitWidth.qml")); + view.setFlags(view.flags() | Qt::WindowStaysOnTopHint); // Prevent being obscured by other windows. view.show(); view.requestActivate(); QVERIFY(QTest::qWaitForWindowActive(&view)); @@ -864,34 +875,45 @@ void tst_qquicktext::hAlignImplicitWidth() QQuickText *text = view.rootObject()->findChild("textItem"); QVERIFY(text != 0); + // Try to check whether alignment works by checking the number of black + // pixels in the thirds of the grabbed image. + const int windowWidth = 200; + const int textWidth = qCeil(text->implicitWidth()); + QVERIFY2(textWidth < windowWidth, "System font too large."); + const int sectionWidth = textWidth / 3; + const int centeredSection1 = (windowWidth - textWidth) / 2; + const int centeredSection2 = centeredSection1 + sectionWidth; + const int centeredSection3 = centeredSection2 + sectionWidth; + const int centeredSection3End = centeredSection3 + sectionWidth; + { // Left Align QImage image = view.grabWindow(); - int left = numberOfNonWhitePixels(0, image.width() / 3, image); - int mid = numberOfNonWhitePixels(image.width() / 3, 2 * image.width() / 3, image); - int right = numberOfNonWhitePixels( 2 * image.width() / 3, image.width(), image); - QVERIFY(left > mid); - QVERIFY(mid > right); + const int left = numberOfNonWhitePixels(centeredSection1, centeredSection2, image); + const int mid = numberOfNonWhitePixels(centeredSection2, centeredSection3, image); + const int right = numberOfNonWhitePixels(centeredSection3, centeredSection3End, image); + QVERIFY2(left > mid, msgNotGreaterThan(left, mid).constData()); + QVERIFY2(mid > right, msgNotGreaterThan(mid, right).constData()); } { // HCenter Align text->setHAlign(QQuickText::AlignHCenter); QImage image = view.grabWindow(); - int left = numberOfNonWhitePixels(0, image.width() / 3, image); - int mid = numberOfNonWhitePixels(image.width() / 3, 2 * image.width() / 3, image); - int right = numberOfNonWhitePixels( 2 * image.width() / 3, image.width(), image); - QVERIFY(left < mid); - QVERIFY(mid > right); + const int left = numberOfNonWhitePixels(centeredSection1, centeredSection2, image); + const int mid = numberOfNonWhitePixels(centeredSection2, centeredSection3, image); + const int right = numberOfNonWhitePixels(centeredSection3, centeredSection3End, image); + QVERIFY2(left < mid, msgNotLessThan(left, mid).constData()); + QVERIFY2(mid > right, msgNotGreaterThan(mid, right).constData()); } { // Right Align text->setHAlign(QQuickText::AlignRight); QImage image = view.grabWindow(); - int left = numberOfNonWhitePixels(0, image.width() / 3, image); - int mid = numberOfNonWhitePixels(image.width() / 3, 2 * image.width() / 3, image); - int right = numberOfNonWhitePixels( 2 * image.width() / 3, image.width(), image); - QVERIFY(left < mid); - QVERIFY(mid < right); + const int left = numberOfNonWhitePixels(centeredSection1, centeredSection2, image); + const int mid = numberOfNonWhitePixels(centeredSection2, centeredSection3, image); + const int right = numberOfNonWhitePixels(centeredSection3, centeredSection3End, image); + QVERIFY2(left < mid, msgNotLessThan(left, mid).constData()); + QVERIFY2(mid < right, msgNotLessThan(mid, right).constData()); } } diff --git a/tests/auto/quick/qquicktextedit/data/hAlignVisual.qml b/tests/auto/quick/qquicktextedit/data/hAlignVisual.qml index 136e5d21a2..9c9318d3cc 100644 --- a/tests/auto/quick/qquicktextedit/data/hAlignVisual.qml +++ b/tests/auto/quick/qquicktextedit/data/hAlignVisual.qml @@ -6,7 +6,7 @@ Rectangle { Text { objectName: "textItem" - text: "AA\nBBBBB\nCCCCCCCCCCCCCCCC" + text: "AA\nBBBBBBB\nCCCCCCCCCCCCCCCC" anchors.centerIn: parent horizontalAlignment: Text.AlignLeft } diff --git a/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp b/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp index 667d52ee7a..6e74d840aa 100644 --- a/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp +++ b/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp @@ -818,42 +818,66 @@ static int numberOfNonWhitePixels(int fromX, int toX, const QImage &image) return pixels; } +static inline QByteArray msgNotGreaterThan(int n1, int n2) +{ + return QByteArray::number(n1) + QByteArrayLiteral(" is not greater than ") + QByteArray::number(n2); +} + +static inline QByteArray msgNotLessThan(int n1, int n2) +{ + return QByteArray::number(n1) + QByteArrayLiteral(" is not less than ") + QByteArray::number(n2); +} + void tst_qquicktextedit::hAlignVisual() { QQuickView view(testFileUrl("hAlignVisual.qml")); + view.setFlags(view.flags() | Qt::WindowStaysOnTopHint); // Prevent being obscured by other windows. view.show(); QVERIFY(QTest::qWaitForWindowExposed(&view)); QQuickText *text = view.rootObject()->findChild("textItem"); QVERIFY(text != 0); + + // Try to check whether alignment works by checking the number of black + // pixels in the thirds of the grabbed image. + const int windowWidth = 200; + const int textWidth = qCeil(text->implicitWidth()); + QVERIFY2(textWidth < windowWidth, "System font too large."); + const int sectionWidth = textWidth / 3; + const int centeredSection1 = (windowWidth - textWidth) / 2; + const int centeredSection2 = centeredSection1 + sectionWidth; + const int centeredSection3 = centeredSection2 + sectionWidth; + const int centeredSection3End = centeredSection3 + sectionWidth; + { // Left Align QImage image = view.grabWindow(); - int left = numberOfNonWhitePixels(0, image.width() / 3, image); - int mid = numberOfNonWhitePixels(image.width() / 3, 2 * image.width() / 3, image); - int right = numberOfNonWhitePixels( 2 * image.width() / 3, image.width(), image); - QVERIFY(left > mid); - QVERIFY(mid > right); + const int left = numberOfNonWhitePixels(centeredSection1, centeredSection2, image); + const int mid = numberOfNonWhitePixels(centeredSection2, centeredSection3, image); + const int right = numberOfNonWhitePixels(centeredSection3, centeredSection3End, image); + QVERIFY2(left > mid, msgNotGreaterThan(left, mid).constData()); + QVERIFY2(mid > right, msgNotGreaterThan(mid, right).constData()); } { // HCenter Align text->setHAlign(QQuickText::AlignHCenter); QImage image = view.grabWindow(); - int left = numberOfNonWhitePixels(0, image.width() / 3, image); - int mid = numberOfNonWhitePixels(image.width() / 3, 2 * image.width() / 3, image); - int right = numberOfNonWhitePixels( 2 * image.width() / 3, image.width(), image); - QVERIFY(left < mid); - QVERIFY(mid > right); + const int left = numberOfNonWhitePixels(centeredSection1, centeredSection2, image); + const int mid = numberOfNonWhitePixels(centeredSection2, centeredSection3, image); + const int right = numberOfNonWhitePixels(centeredSection3, centeredSection3End, image); + QVERIFY2(left < mid, msgNotLessThan(left, mid).constData()); + QVERIFY2(mid > right, msgNotGreaterThan(mid, right).constData()); } { // Right Align text->setHAlign(QQuickText::AlignRight); QImage image = view.grabWindow(); - int left = numberOfNonWhitePixels(0, image.width() / 3, image); - int mid = numberOfNonWhitePixels(image.width() / 3, 2 * image.width() / 3, image); - int right = numberOfNonWhitePixels( 2 * image.width() / 3, image.width(), image); - QVERIFY(left < mid); - QVERIFY(mid < right); + const int left = numberOfNonWhitePixels(centeredSection1, centeredSection2, image); + const int mid = numberOfNonWhitePixels(centeredSection2, centeredSection3, image); + const int right = numberOfNonWhitePixels(centeredSection3, centeredSection3End, image); + image.save("test3.png"); + QVERIFY2(left < mid, msgNotLessThan(left, mid).constData()); + QVERIFY2(mid < right, msgNotLessThan(mid, right).constData()); } text->setWidth(200); @@ -864,8 +888,8 @@ void tst_qquicktextedit::hAlignVisual() int x = qCeil(text->implicitWidth()); int left = numberOfNonWhitePixels(0, x, image); int right = numberOfNonWhitePixels(x, image.width() - x, image); - QVERIFY(left > 0); - QVERIFY(right == 0); + QVERIFY2(left > 0, msgNotGreaterThan(left, 0).constData()); + QCOMPARE(right, 0); } { // HCenter Align @@ -876,9 +900,9 @@ void tst_qquicktextedit::hAlignVisual() int left = numberOfNonWhitePixels(0, x1, image); int mid = numberOfNonWhitePixels(x1, x2 - x1, image); int right = numberOfNonWhitePixels(x2, image.width() - x2, image); - QVERIFY(left == 0); - QVERIFY(mid > 0); - QVERIFY(right == 0); + QCOMPARE(left, 0); + QVERIFY2(mid > 0, msgNotGreaterThan(left, 0).constData()); + QCOMPARE(right, 0); } { // Right Align @@ -887,8 +911,8 @@ void tst_qquicktextedit::hAlignVisual() int x = image.width() - qCeil(text->implicitWidth()); int left = numberOfNonWhitePixels(0, x, image); int right = numberOfNonWhitePixels(x, image.width() - x, image); - QVERIFY(left == 0); - QVERIFY(right > 0); + QCOMPARE(left, 0); + QVERIFY2(right > 0, msgNotGreaterThan(left, 0).constData()); } } -- cgit v1.2.3 From 54c13c0e9524fb97802318bacc602c5fcf504a20 Mon Sep 17 00:00:00 2001 From: Rafael Roquetto Date: Tue, 23 Jul 2013 16:04:41 -0300 Subject: Fix tst_qquicktextinput::remoteCursorDelegate Do not query for QQmlComponent::Loading on remoteCursorDelegate: when a new connection is established to the test http server, it will setup a single shot QTimer with a 500ms timeout that will trigger the reply to be sent back, making the call to sendDelayedItem() obsolete and reduntant. Also, it means that in some platforms, data will arrive back to the component before the check for QQmlComponent::Loading is executed, causing the test to fail since at this point the status will already be QQmlComponent::Ready instead. Change-Id: I30adeed2a669d5f6618f56d8a023fe7eaea16bc0 Reviewed-by: Wolfgang Bremer Reviewed-by: Frederik Gladhorn --- tests/auto/quick/qquicktextinput/tst_qquicktextinput.cpp | 5 ----- 1 file changed, 5 deletions(-) (limited to 'tests') diff --git a/tests/auto/quick/qquicktextinput/tst_qquicktextinput.cpp b/tests/auto/quick/qquicktextinput/tst_qquicktextinput.cpp index def1c76ba1..06b757d198 100644 --- a/tests/auto/quick/qquicktextinput/tst_qquicktextinput.cpp +++ b/tests/auto/quick/qquicktextinput/tst_qquicktextinput.cpp @@ -2775,7 +2775,6 @@ void tst_qquicktextinput::cursorDelegate() void tst_qquicktextinput::remoteCursorDelegate() { - QSKIP("This test is unstable"); TestHTTPServer server(SERVER_PORT); server.serveDirectory(dataDirectory(), TestHTTPServer::Delay); @@ -2799,10 +2798,6 @@ void tst_qquicktextinput::remoteCursorDelegate() textInputObject->setFocus(true); QVERIFY(textInputObject->isCursorVisible()); - QCOMPARE(component.status(), QQmlComponent::Loading); - QVERIFY(!textInputObject->findChild("cursorInstance")); - server.sendDelayedItem(); - // Wait for component to load. QTRY_COMPARE(component.status(), QQmlComponent::Ready); QVERIFY(textInputObject->findChild("cursorInstance")); -- cgit v1.2.3 From 40ebc1d909d69fffbf69cf2c2317f04a823e837e Mon Sep 17 00:00:00 2001 From: Sergio Ahumada Date: Fri, 26 Jul 2013 14:28:45 +0200 Subject: test: Remove insignificant mark from tst_qquickgridview Tests are passing nowaways on OS X. Task-number: QTBUG-27890 Change-Id: Iddceb2f0641115f03e5116c38e95ae5772938248 Reviewed-by: Friedemann Kleint --- tests/auto/quick/qquickgridview/qquickgridview.pro | 2 -- 1 file changed, 2 deletions(-) (limited to 'tests') diff --git a/tests/auto/quick/qquickgridview/qquickgridview.pro b/tests/auto/quick/qquickgridview/qquickgridview.pro index dd69cda49e..0e679387cc 100644 --- a/tests/auto/quick/qquickgridview/qquickgridview.pro +++ b/tests/auto/quick/qquickgridview/qquickgridview.pro @@ -12,5 +12,3 @@ TESTDATA = data/* QT += core-private gui-private v8-private qml-private quick-private testlib DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 - -mac:CONFIG+=insignificant_test # QTBUG-27890 -- cgit v1.2.3 From 46e758e985798ca659c79d39683ab000cf870354 Mon Sep 17 00:00:00 2001 From: Sergio Ahumada Date: Fri, 26 Jul 2013 14:30:55 +0200 Subject: test: Remove insignificant mark from tst_touchmouse Tests are passing nowaways on OS X. Task-number: QTBUG-27890 Change-Id: I2245801a44b9b6fd8773c91e2d5dd67f5a5b7373 Reviewed-by: Friedemann Kleint --- tests/auto/quick/touchmouse/touchmouse.pro | 2 -- 1 file changed, 2 deletions(-) (limited to 'tests') diff --git a/tests/auto/quick/touchmouse/touchmouse.pro b/tests/auto/quick/touchmouse/touchmouse.pro index 378e199bf5..af6d536cbc 100644 --- a/tests/auto/quick/touchmouse/touchmouse.pro +++ b/tests/auto/quick/touchmouse/touchmouse.pro @@ -14,5 +14,3 @@ TESTDATA = data/* # OTHER_FILES += data/foo.qml DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 - -mac:CONFIG+=insignificant_test # QTBUG-27890 -- cgit v1.2.3 From c71c7dadda2b15d7dbde6591172a1d7e85b7fbe6 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Fri, 26 Jul 2013 14:40:09 +0200 Subject: FolderListModel: Do not return invalid URLs like "file:" when navigating up. Task-number: QTBUG-32139 Change-Id: I715b97eb85bc4235de6a2bb696131efae56477fd Reviewed-by: Shawn Rutledge --- .../tst_qquickfolderlistmodel.cpp | 28 ++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'tests') diff --git a/tests/auto/qml/qquickfolderlistmodel/tst_qquickfolderlistmodel.cpp b/tests/auto/qml/qquickfolderlistmodel/tst_qquickfolderlistmodel.cpp index 9230608622..ef24e0a2d2 100644 --- a/tests/auto/qml/qquickfolderlistmodel/tst_qquickfolderlistmodel.cpp +++ b/tests/auto/qml/qquickfolderlistmodel/tst_qquickfolderlistmodel.cpp @@ -73,6 +73,7 @@ private slots: void basicProperties(); void resetFiltering(); void refresh(); + void cdUp(); #if defined (Q_OS_WIN) && !defined (Q_OS_WINCE) // WinCE does not have drive concept, so lets execute this test only on desktop Windows. void changeDrive(); @@ -182,6 +183,33 @@ void tst_qquickfolderlistmodel::refresh() QTRY_COMPARE(removeEnd, count-1); // wait for refresh } +void tst_qquickfolderlistmodel::cdUp() +{ + enum { maxIterations = 50 }; + QQmlComponent component(&engine, testFileUrl("basic.qml")); + checkNoErrors(component); + + QAbstractListModel *flm = qobject_cast(component.create()); + QVERIFY(flm != 0); + const QUrl startFolder = flm->property("folder").toUrl(); + QVERIFY(startFolder.isValid()); + + // QTBUG-32139: Ensure navigating upwards terminates cleanly and does not + // return invalid Urls like "file:". + for (int i = 0; ; ++i) { + const QVariant folderV = flm->property("parentFolder"); + const QUrl folder = folderV.toUrl(); + if (!folder.isValid()) + break; + QVERIFY(folder.toString() != QLatin1String("file:")); + QVERIFY2(i < maxIterations, + qPrintable(QString::fromLatin1("Unable to reach root after %1 iterations starting from %2, stuck at %3") + .arg(maxIterations).arg(QDir::toNativeSeparators(startFolder.toLocalFile()), + QDir::toNativeSeparators(folder.toLocalFile())))); + flm->setProperty("folder", folderV); + } +} + #if defined (Q_OS_WIN) && !defined (Q_OS_WINCE) void tst_qquickfolderlistmodel::changeDrive() { -- cgit v1.2.3 From 85d39c72c6427ff9fd11be25c42a5c7abc277b8b Mon Sep 17 00:00:00 2001 From: Rafael Roquetto Date: Fri, 26 Jul 2013 17:58:00 -0300 Subject: Fix tst_QQuickDrag::recursion() Process events and handle number of move events correctly. Change-Id: I555582ad4e10d5c76bbdc8ce9203b8f5897d0f56 Reviewed-by: Frederik Gladhorn --- tests/auto/quick/qquickdrag/tst_qquickdrag.cpp | 46 ++++++++++++++++++++++++-- 1 file changed, 43 insertions(+), 3 deletions(-) (limited to 'tests') diff --git a/tests/auto/quick/qquickdrag/tst_qquickdrag.cpp b/tests/auto/quick/qquickdrag/tst_qquickdrag.cpp index dbb4736c05..15282d4b02 100644 --- a/tests/auto/quick/qquickdrag/tst_qquickdrag.cpp +++ b/tests/auto/quick/qquickdrag/tst_qquickdrag.cpp @@ -1070,106 +1070,131 @@ void tst_QQuickDrag::recursion_data() { QTest::addColumn("script"); QTest::addColumn("type"); + QTest::addColumn("moveEvents"); QTest::addColumn("warning"); QTest::newRow("Drag.start() in Enter") << QString("Drag.start()") << int(QEvent::DragEnter) + << 1 << QByteArray(": QML QQuickDragAttached: start() cannot be called from within a drag event handler"); QTest::newRow("Drag.cancel() in Enter") << QString("Drag.cancel()") << int(QEvent::DragEnter) + << 1 << QByteArray(": QML QQuickDragAttached: cancel() cannot be called from within a drag event handler"); QTest::newRow("Drag.drop() in Enter") << QString("Drag.drop()") << int(QEvent::DragEnter) + << 1 << QByteArray(": QML QQuickDragAttached: drop() cannot be called from within a drag event handler"); QTest::newRow("Drag.active = true in Enter") << QString("Drag.active = true") << int(QEvent::DragEnter) + << 1 << QByteArray(); QTest::newRow("Drag.active = false in Enter") << QString("Drag.active = false") << int(QEvent::DragEnter) + << 1 << QByteArray(": QML QQuickDragAttached: active cannot be changed from within a drag event handler"); QTest::newRow("move in Enter") << QString("x = 23") << int(QEvent::DragEnter) + << 1 << QByteArray(); QTest::newRow("Drag.start() in Move") << QString("Drag.start()") << int(QEvent::DragMove) + << 1 << QByteArray(": QML QQuickDragAttached: start() cannot be called from within a drag event handler"); QTest::newRow("Drag.cancel() in Move") << QString("Drag.cancel()") << int(QEvent::DragMove) + << 1 << QByteArray(": QML QQuickDragAttached: cancel() cannot be called from within a drag event handler"); QTest::newRow("Drag.drop() in Move") << QString("Drag.drop()") << int(QEvent::DragMove) + << 1 << QByteArray(": QML QQuickDragAttached: drop() cannot be called from within a drag event handler"); QTest::newRow("Drag.active = true in Move") << QString("Drag.active = true") << int(QEvent::DragMove) + << 1 << QByteArray(); QTest::newRow("Drag.active = false in Move") << QString("Drag.active = false") << int(QEvent::DragMove) + << 1 << QByteArray(": QML QQuickDragAttached: active cannot be changed from within a drag event handler"); QTest::newRow("move in Move") << QString("x = 23") << int(QEvent::DragMove) + << 2 << QByteArray(); QTest::newRow("Drag.start() in Leave") << QString("Drag.start()") << int(QEvent::DragLeave) + << 1 << QByteArray(": QML QQuickDragAttached: start() cannot be called from within a drag event handler"); QTest::newRow("Drag.cancel() in Leave") << QString("Drag.cancel()") << int(QEvent::DragLeave) + << 1 << QByteArray(": QML QQuickDragAttached: cancel() cannot be called from within a drag event handler"); QTest::newRow("Drag.drop() in Leave") << QString("Drag.drop()") << int(QEvent::DragLeave) + << 1 << QByteArray(": QML QQuickDragAttached: drop() cannot be called from within a drag event handler"); QTest::newRow("Drag.active = true in Leave") << QString("Drag.active = true") << int(QEvent::DragLeave) + << 1 << QByteArray(": QML QQuickDragAttached: active cannot be changed from within a drag event handler"); QTest::newRow("Drag.active = false in Leave") << QString("Drag.active = false") << int(QEvent::DragLeave) + << 1 << QByteArray(); QTest::newRow("move in Leave") << QString("x = 23") << int(QEvent::DragLeave) + << 1 << QByteArray(); QTest::newRow("Drag.start() in Drop") << QString("Drag.start()") << int(QEvent::Drop) + << 1 << QByteArray(": QML QQuickDragAttached: start() cannot be called from within a drag event handler"); QTest::newRow("Drag.cancel() in Drop") << QString("Drag.cancel()") << int(QEvent::Drop) + << 1 << QByteArray(": QML QQuickDragAttached: cancel() cannot be called from within a drag event handler"); QTest::newRow("Drag.drop() in Drop") << QString("Drag.drop()") << int(QEvent::Drop) + << 1 << QByteArray(": QML QQuickDragAttached: drop() cannot be called from within a drag event handler"); QTest::newRow("Drag.active = true in Drop") << QString("Drag.active = true") << int(QEvent::Drop) + << 1 << QByteArray(": QML QQuickDragAttached: active cannot be changed from within a drag event handler"); QTest::newRow("Drag.active = false in Drop") << QString("Drag.active = false") << int(QEvent::Drop) + << 1 << QByteArray(); QTest::newRow("move in Drop") << QString("x = 23") << int(QEvent::Drop) + << 1 << QByteArray(); } @@ -1177,6 +1202,7 @@ void tst_QQuickDrag::recursion() { QFETCH(QString, script); QFETCH(int, type); + QFETCH(int, moveEvents); QFETCH(QByteArray, warning); if (!warning.isEmpty()) @@ -1206,22 +1232,36 @@ void tst_QQuickDrag::recursion() QCOMPARE(dropTarget.leaveEvents, 0); evaluate(item, "y = 15"); + + // the evaluate statement above, y = 15, will cause + // QQuickItem::setY(15) to be called, leading to an + // event being posted that will be delivered + // to RecursingDropTarget::dragMoveEvent(), hence + // the following call to QCoreApplication::processEvents() QCoreApplication::processEvents(); + + + // Regarding 'move in Move' when + // RecursingDropTarget::dragMoveEvent() runs, + // its call 'evaluate' triggers a second + // move event (x = 23) that needs to be delivered. + QCoreApplication::processEvents(); + QCOMPARE(dropTarget.enterEvents, 1); - QCOMPARE(dropTarget.moveEvents, 1); + QCOMPARE(dropTarget.moveEvents, moveEvents); QCOMPARE(dropTarget.dropEvents, 0); QCOMPARE(dropTarget.leaveEvents, 0); if (type == QEvent::Drop) { QCOMPARE(evaluate(item, "Drag.drop() == Qt.MoveAction"), true); QCOMPARE(dropTarget.enterEvents, 1); - QCOMPARE(dropTarget.moveEvents, 1); + QCOMPARE(dropTarget.moveEvents, moveEvents); QCOMPARE(dropTarget.dropEvents, 1); QCOMPARE(dropTarget.leaveEvents, 0); } else { evaluate(item, "Drag.cancel()"); QCOMPARE(dropTarget.enterEvents, 1); - QCOMPARE(dropTarget.moveEvents, 1); + QCOMPARE(dropTarget.moveEvents, moveEvents); QCOMPARE(dropTarget.dropEvents, 0); QCOMPARE(dropTarget.leaveEvents, 1); } -- cgit v1.2.3 From 1a90b94afabc064048a88b4a5fc6cd886694c061 Mon Sep 17 00:00:00 2001 From: Nils Jeisecke Date: Tue, 30 Jul 2013 13:59:01 +0200 Subject: Correctly update flickable visibleArea.heightRatio when geometry changes Without this fix the visibleArea.heightRatio and widthRatio values were only updated on geometry changes when flicking was active. So when setting the flickable geometry to the content geometry and thereby disabling flicking the ratios were not updated. This could for example cause wrong scrollbar renderings. The ratios are now also calculated directly after accessing the visibleArea property for the first time. The new autotest covers both problems. Change-Id: I54ba606524557fb328a198c312c1f65eb125c5a3 Reviewed-by: Alan Alpert --- tests/auto/quick/qquickflickable/data/ratios.qml | 71 ++++++++++++++++++++++ .../quick/qquickflickable/tst_qquickflickable.cpp | 23 +++++++ 2 files changed, 94 insertions(+) create mode 100644 tests/auto/quick/qquickflickable/data/ratios.qml (limited to 'tests') diff --git a/tests/auto/quick/qquickflickable/data/ratios.qml b/tests/auto/quick/qquickflickable/data/ratios.qml new file mode 100644 index 0000000000..1291cada72 --- /dev/null +++ b/tests/auto/quick/qquickflickable/data/ratios.qml @@ -0,0 +1,71 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** 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 Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Rectangle { + width: 400 + height: 400 + + property bool forceNoFlicking: true + property double heightRatioIs: flickable.visibleArea.heightRatio + property double heightRatioShould: flickable.height / flickable.contentHeight + property double widthRatioIs: flickable.visibleArea.widthRatio + property double widthRatioShould: flickable.height / flickable.contentWidth + + Flickable { + id: flickable + flickableDirection: Flickable.AutoFlickDirection + width: forceNoFlicking ? contentItem.width /* so xflick() returns false */ : 20 + height: forceNoFlicking ? contentItem.height /* likewise */ : 20 + contentHeight: contentItem.height + contentWidth: contentItem.width + clip: true + + Rectangle { + id: contentItem + color: "red" + width: 300 + height: 300 + } + } +} + diff --git a/tests/auto/quick/qquickflickable/tst_qquickflickable.cpp b/tests/auto/quick/qquickflickable/tst_qquickflickable.cpp index 3575dfa012..a8055b3467 100644 --- a/tests/auto/quick/qquickflickable/tst_qquickflickable.cpp +++ b/tests/auto/quick/qquickflickable/tst_qquickflickable.cpp @@ -67,6 +67,7 @@ private slots: void create(); void horizontalViewportSize(); void verticalViewportSize(); + void visibleAreaRatiosUpdate(); void properties(); void boundsBehavior(); void rebound(); @@ -158,6 +159,28 @@ void tst_qquickflickable::verticalViewportSize() delete obj; } +void tst_qquickflickable::visibleAreaRatiosUpdate() +{ + QQmlEngine engine; + QQmlComponent c(&engine, testFileUrl("ratios.qml")); + QQuickItem *obj = qobject_cast(c.create()); + + QVERIFY(obj != 0); + // check initial ratio values + QCOMPARE(obj->property("heightRatioIs").toDouble(), obj->property("heightRatioShould").toDouble()); + QCOMPARE(obj->property("widthRatioIs").toDouble(), obj->property("widthRatioShould").toDouble()); + // change flickable geometry so that flicking is enabled (content size > flickable size) + obj->setProperty("forceNoFlicking", false); + QCOMPARE(obj->property("heightRatioIs").toDouble(), obj->property("heightRatioShould").toDouble()); + QCOMPARE(obj->property("widthRatioIs").toDouble(), obj->property("widthRatioShould").toDouble()); + // change flickable geometry so that flicking is disabled (content size == flickable size) + obj->setProperty("forceNoFlicking", true); + QCOMPARE(obj->property("heightRatioIs").toDouble(), obj->property("heightRatioShould").toDouble()); + QCOMPARE(obj->property("widthRatioIs").toDouble(), obj->property("widthRatioShould").toDouble()); + + delete obj; +} + void tst_qquickflickable::properties() { QQmlEngine engine; -- cgit v1.2.3 From 7f702f736a2d16268b55baf06e4bc5bfd9737a1f Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Mon, 29 Jul 2013 14:46:37 +0200 Subject: Add diagnostic output to tst_qquickpathview::cancelDrag(). MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Task-number: QTBUG-32662 Change-Id: I62b53f94659be95b3bef86f853733998d4d882dc Reviewed-by: Simo Fält Reviewed-by: Sergio Ahumada --- tests/auto/quick/qquickpathview/tst_qquickpathview.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/auto/quick/qquickpathview/tst_qquickpathview.cpp b/tests/auto/quick/qquickpathview/tst_qquickpathview.cpp index 274b93e81a..e4ad7b9c40 100644 --- a/tests/auto/quick/qquickpathview/tst_qquickpathview.cpp +++ b/tests/auto/quick/qquickpathview/tst_qquickpathview.cpp @@ -1725,6 +1725,14 @@ void tst_QQuickPathView::missingPercent() delete obj; } +static inline bool hasFraction(qreal o) +{ + const bool result = o != qFloor(o); + if (!result) + qDebug() << "o != qFloor(o)" << o; + return result; +} + void tst_QQuickPathView::cancelDrag() { QScopedPointer window(createView()); @@ -1747,7 +1755,7 @@ void tst_QQuickPathView::cancelDrag() QTest::mouseMove(window.data(), QPoint(30, 100)); QTest::mouseMove(window.data(), QPoint(85, 100)); - QTRY_VERIFY(pathview->offset() != qFloor(pathview->offset())); + QTRY_VERIFY(hasFraction(pathview->offset())); QTRY_VERIFY(pathview->isMoving()); QVERIFY(pathview->isDragging()); QCOMPARE(draggingSpy.count(), 1); -- cgit v1.2.3 From b57b1ca8e9c1e2720e0041807737c23751dcc645 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Fri, 26 Jul 2013 16:56:49 +0200 Subject: Stabilize tst_qquickitem. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Instantiate windows and views on the stack or add QScopedPointer. Add waitForWindowExposed() after show(). Add diagnostic message. Task-number: QTBUG-32664 Change-Id: I190f2a0490b8333a7886a23e26582c6cb615df94 Reviewed-by: Simo Fält Reviewed-by: Sergio Ahumada --- tests/auto/quick/qquickitem/tst_qquickitem.cpp | 167 ++++++++++++------------- 1 file changed, 82 insertions(+), 85 deletions(-) (limited to 'tests') diff --git a/tests/auto/quick/qquickitem/tst_qquickitem.cpp b/tests/auto/quick/qquickitem/tst_qquickitem.cpp index a7343f686f..79f08d5147 100644 --- a/tests/auto/quick/qquickitem/tst_qquickitem.cpp +++ b/tests/auto/quick/qquickitem/tst_qquickitem.cpp @@ -718,24 +718,24 @@ void tst_qquickitem::changeParent() void tst_qquickitem::multipleFocusClears() { //Multiple clears of focus inside a focus scope shouldn't crash. QTBUG-24714 - QQuickView *view = new QQuickView; - view->setSource(testFileUrl("multipleFocusClears.qml")); - view->show(); - ensureFocus(view); - QTRY_VERIFY(QGuiApplication::focusWindow() == view); + QQuickView view; + view.setSource(testFileUrl("multipleFocusClears.qml")); + view.show(); + ensureFocus(&view); + QTRY_VERIFY(QGuiApplication::focusWindow() == &view); } void tst_qquickitem::focusSubItemInNonFocusScope() { - QQuickView *view = new QQuickView; - view->setSource(testFileUrl("focusSubItemInNonFocusScope.qml")); - view->show(); - QTest::qWaitForWindowActive(view); + QQuickView view; + view.setSource(testFileUrl("focusSubItemInNonFocusScope.qml")); + view.show(); + QTest::qWaitForWindowActive(&view); - QQuickItem *dummyItem = view->rootObject()->findChild("dummyItem"); + QQuickItem *dummyItem = view.rootObject()->findChild("dummyItem"); QVERIFY(dummyItem); - QQuickItem *textInput = view->rootObject()->findChild("textInput"); + QQuickItem *textInput = view.rootObject()->findChild("textInput"); QVERIFY(textInput); QVERIFY(dummyItem->hasFocus()); @@ -747,8 +747,6 @@ void tst_qquickitem::focusSubItemInNonFocusScope() QVERIFY(!dummyItem->hasFocus()); QVERIFY(textInput->hasFocus()); QVERIFY(textInput->hasActiveFocus()); - - delete view; } void tst_qquickitem::parentItemWithFocus() @@ -880,24 +878,22 @@ void tst_qquickitem::reparentFocusedItem() void tst_qquickitem::constructor() { - QQuickItem *root = new QQuickItem; + QScopedPointer root(new QQuickItem); QVERIFY(root->parent() == 0); QVERIFY(root->parentItem() == 0); - QQuickItem *child1 = new QQuickItem(root); - QVERIFY(child1->parent() == root); - QVERIFY(child1->parentItem() == root); + QQuickItem *child1 = new QQuickItem(root.data()); + QVERIFY(child1->parent() == root.data()); + QVERIFY(child1->parentItem() == root.data()); QCOMPARE(root->childItems().count(), 1); QCOMPARE(root->childItems().at(0), child1); - QQuickItem *child2 = new QQuickItem(root); - QVERIFY(child2->parent() == root); - QVERIFY(child2->parentItem() == root); + QQuickItem *child2 = new QQuickItem(root.data()); + QVERIFY(child2->parent() == root.data()); + QVERIFY(child2->parentItem() == root.data()); QCOMPARE(root->childItems().count(), 2); QCOMPARE(root->childItems().at(0), child1); QCOMPARE(root->childItems().at(1), child2); - - delete root; } void tst_qquickitem::setParentItem() @@ -1157,80 +1153,87 @@ void tst_qquickitem::enabledFocus() QCOMPARE(window.activeFocusItem(), static_cast(&child1)); } +static inline QByteArray msgItem(const QQuickItem *item) +{ + QString result; + QDebug(&result) << item; + return result.toLocal8Bit(); +} + void tst_qquickitem::mouseGrab() { - QQuickWindow *window = new QQuickWindow; - window->resize(200, 200); - window->show(); + QQuickWindow window; + window.setFramePosition(QPoint(100, 100)); + window.resize(200, 200); + window.show(); + QVERIFY(QTest::qWaitForWindowExposed(&window)); - TestItem *child1 = new TestItem; + QScopedPointer child1(new TestItem); + child1->setObjectName(QStringLiteral("child1")); child1->setAcceptedMouseButtons(Qt::LeftButton); child1->setSize(QSizeF(200, 100)); - child1->setParentItem(window->contentItem()); + child1->setParentItem(window.contentItem()); - TestItem *child2 = new TestItem; + QScopedPointer child2(new TestItem); + child2->setObjectName(QStringLiteral("child2")); child2->setAcceptedMouseButtons(Qt::LeftButton); child2->setY(51); child2->setSize(QSizeF(200, 100)); - child2->setParentItem(window->contentItem()); + child2->setParentItem(window.contentItem()); - QTest::mousePress(window, Qt::LeftButton, 0, QPoint(50,50)); + QTest::mousePress(&window, Qt::LeftButton, 0, QPoint(50,50)); QTest::qWait(100); - QVERIFY(window->mouseGrabberItem() == child1); + QVERIFY2(window.mouseGrabberItem() == child1.data(), msgItem(window.mouseGrabberItem()).constData()); QTest::qWait(100); QCOMPARE(child1->pressCount, 1); - QTest::mouseRelease(window, Qt::LeftButton, 0, QPoint(50,50)); + QTest::mouseRelease(&window, Qt::LeftButton, 0, QPoint(50,50)); QTest::qWait(50); - QVERIFY(window->mouseGrabberItem() == 0); + QVERIFY2(window.mouseGrabberItem() == 0, msgItem(window.mouseGrabberItem()).constData()); QCOMPARE(child1->releaseCount, 1); - QTest::mousePress(window, Qt::LeftButton, 0, QPoint(50,50)); + QTest::mousePress(&window, Qt::LeftButton, 0, QPoint(50,50)); QTest::qWait(50); - QVERIFY(window->mouseGrabberItem() == child1); + QVERIFY2(window.mouseGrabberItem() == child1.data(), msgItem(window.mouseGrabberItem()).constData()); QCOMPARE(child1->pressCount, 2); child1->setEnabled(false); - QVERIFY(window->mouseGrabberItem() == 0); - QTest::mouseRelease(window, Qt::LeftButton, 0, QPoint(50,50)); + QVERIFY2(window.mouseGrabberItem() == 0, msgItem(window.mouseGrabberItem()).constData()); + QTest::mouseRelease(&window, Qt::LeftButton, 0, QPoint(50,50)); QTest::qWait(50); QCOMPARE(child1->releaseCount, 1); child1->setEnabled(true); - QTest::mousePress(window, Qt::LeftButton, 0, QPoint(50,50)); + QTest::mousePress(&window, Qt::LeftButton, 0, QPoint(50,50)); QTest::qWait(50); - QVERIFY(window->mouseGrabberItem() == child1); + QVERIFY2(window.mouseGrabberItem() == child1.data(), msgItem(window.mouseGrabberItem()).constData()); QCOMPARE(child1->pressCount, 3); child1->setVisible(false); - QVERIFY(window->mouseGrabberItem() == 0); - QTest::mouseRelease(window, Qt::LeftButton, 0, QPoint(50,50)); + QVERIFY2(window.mouseGrabberItem() == 0, msgItem(window.mouseGrabberItem())); + QTest::mouseRelease(&window, Qt::LeftButton, 0, QPoint(50,50)); QCOMPARE(child1->releaseCount, 1); child1->setVisible(true); - QTest::mousePress(window, Qt::LeftButton, 0, QPoint(50,50)); + QTest::mousePress(&window, Qt::LeftButton, 0, QPoint(50,50)); QTest::qWait(50); - QVERIFY(window->mouseGrabberItem() == child1); + QVERIFY2(window.mouseGrabberItem() == child1.data(), msgItem(window.mouseGrabberItem()).constData()); QCOMPARE(child1->pressCount, 4); child2->grabMouse(); - QVERIFY(window->mouseGrabberItem() == child2); - QTest::mouseRelease(window, Qt::LeftButton, 0, QPoint(50,50)); + QVERIFY2(window.mouseGrabberItem() == child2.data(), msgItem(window.mouseGrabberItem()).constData()); + QTest::mouseRelease(&window, Qt::LeftButton, 0, QPoint(50,50)); QTest::qWait(50); QCOMPARE(child1->releaseCount, 1); QCOMPARE(child2->releaseCount, 1); child2->grabMouse(); - QVERIFY(window->mouseGrabberItem() == child2); - QTest::mousePress(window, Qt::LeftButton, 0, QPoint(50,50)); + QVERIFY2(window.mouseGrabberItem() == child2.data(), msgItem(window.mouseGrabberItem()).constData()); + QTest::mousePress(&window, Qt::LeftButton, 0, QPoint(50,50)); QTest::qWait(50); QCOMPARE(child1->pressCount, 4); QCOMPARE(child2->pressCount, 1); - QTest::mouseRelease(window, Qt::LeftButton, 0, QPoint(50,50)); + QTest::mouseRelease(&window, Qt::LeftButton, 0, QPoint(50,50)); QTest::qWait(50); QCOMPARE(child1->releaseCount, 1); QCOMPARE(child2->releaseCount, 2); - - delete child1; - delete child2; - delete window; } void tst_qquickitem::touchEventAcceptIgnore_data() @@ -1245,13 +1248,14 @@ void tst_qquickitem::touchEventAcceptIgnore() { QFETCH(bool, itemSupportsTouch); - TestWindow *window = new TestWindow; - window->resize(100, 100); - window->show(); + TestWindow window; + window.resize(100, 100); + window.show(); + QTest::qWaitForWindowExposed(&window); - TestItem *item = new TestItem; + QScopedPointer item(new TestItem); item->setSize(QSizeF(100, 100)); - item->setParentItem(window->contentItem()); + item->setParentItem(window.contentItem()); item->acceptIncomingTouchEvents = itemSupportsTouch; static QTouchDevice* device = 0; @@ -1277,7 +1281,7 @@ void tst_qquickitem::touchEventAcceptIgnore() item->touchEventReached = false; - bool accepted = window->event(&event); + bool accepted = window.event(&event); QVERIFY(item->touchEventReached); QCOMPARE(accepted && event.isAccepted(), itemSupportsTouch); @@ -1297,7 +1301,7 @@ void tst_qquickitem::touchEventAcceptIgnore() item->touchEventReached = false; - bool accepted = window->event(&event); + bool accepted = window.event(&event); QCOMPARE(item->touchEventReached, itemSupportsTouch); QCOMPARE(accepted && event.isAccepted(), itemSupportsTouch); @@ -1317,14 +1321,11 @@ void tst_qquickitem::touchEventAcceptIgnore() item->touchEventReached = false; - bool accepted = window->event(&event); + bool accepted = window.event(&event); QCOMPARE(item->touchEventReached, itemSupportsTouch); QCOMPARE(accepted && event.isAccepted(), itemSupportsTouch); } - - delete item; - delete window; } void tst_qquickitem::polishOutsideAnimation() @@ -1346,16 +1347,15 @@ void tst_qquickitem::polishOutsideAnimation() void tst_qquickitem::polishOnCompleted() { - QQuickView *view = new QQuickView; - view->setSource(testFileUrl("polishOnCompleted.qml")); - view->show(); + QQuickView view; + view.setSource(testFileUrl("polishOnCompleted.qml")); + view.show(); + QTest::qWaitForWindowExposed(&view); - TestPolishItem *item = qobject_cast(view->rootObject()); + TestPolishItem *item = qobject_cast(view.rootObject()); QVERIFY(item); QTRY_VERIFY(item->wasPolished); - - delete view; } void tst_qquickitem::wheelEvent_data() @@ -1376,20 +1376,21 @@ void tst_qquickitem::wheelEvent() const bool shouldReceiveWheelEvents = visible && enabled; - QQuickWindow *window = new QQuickWindow; - window->resize(200, 200); - window->show(); + QQuickWindow window; + window.resize(200, 200); + window.show(); + QTest::qWaitForWindowExposed(&window); TestItem *item = new TestItem; item->setSize(QSizeF(200, 100)); - item->setParentItem(window->contentItem()); + item->setParentItem(window.contentItem()); item->setEnabled(enabled); item->setVisible(visible); QWheelEvent event(QPoint(100, 50), -120, Qt::NoButton, Qt::NoModifier, Qt::Vertical); event.setAccepted(false); - QGuiApplication::sendEvent(window, &event); + QGuiApplication::sendEvent(&window, &event); if (shouldReceiveWheelEvents) { QVERIFY(event.isAccepted()); @@ -1398,8 +1399,6 @@ void tst_qquickitem::wheelEvent() QVERIFY(!event.isAccepted()); QCOMPARE(item->wheelCount, 0); } - - delete window; } class HoverItem : public QQuickItem @@ -1503,11 +1502,11 @@ void tst_qquickitem::hoverEvent() void tst_qquickitem::hoverEventInParent() { - QQuickWindow *window = new QQuickWindow(); - window->resize(200, 200); - window->show(); + QQuickWindow window; + window.resize(200, 200); + window.show(); - HoverItem *parentItem = new HoverItem(window->contentItem()); + HoverItem *parentItem = new HoverItem(window.contentItem()); parentItem->setSize(QSizeF(200, 200)); parentItem->setAcceptHoverEvents(true); @@ -1523,12 +1522,12 @@ void tst_qquickitem::hoverEventInParent() const QPoint insideLeft(50, 100); const QPoint insideRight(150, 100); - sendMouseMove(window, insideLeft); + sendMouseMove(&window, insideLeft); parentItem->resetCounters(); leftItem->resetCounters(); rightItem->resetCounters(); - sendMouseMove(window, insideRight); + sendMouseMove(&window, insideRight); QCOMPARE(parentItem->hoverEnterCount, 0); QCOMPARE(parentItem->hoverLeaveCount, 0); QCOMPARE(leftItem->hoverEnterCount, 0); @@ -1536,15 +1535,13 @@ void tst_qquickitem::hoverEventInParent() QCOMPARE(rightItem->hoverEnterCount, 1); QCOMPARE(rightItem->hoverLeaveCount, 0); - sendMouseMove(window, insideLeft); + sendMouseMove(&window, insideLeft); QCOMPARE(parentItem->hoverEnterCount, 0); QCOMPARE(parentItem->hoverLeaveCount, 0); QCOMPARE(leftItem->hoverEnterCount, 1); QCOMPARE(leftItem->hoverLeaveCount, 1); QCOMPARE(rightItem->hoverEnterCount, 1); QCOMPARE(rightItem->hoverLeaveCount, 1); - - delete window; } void tst_qquickitem::paintOrder_data() -- cgit v1.2.3 From 472950ecab88fc41a99f2a1deb861a4abd273174 Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Fri, 19 Jul 2013 14:32:17 -0500 Subject: Fix crash when changing non-cached source of image during animation Ensure deferred deletions are handled while syncing, otherwise texture might be deleted after sync but before deferred deletion is processed. Task-number: QTBUG-32513 Change-Id: Id276f536a5722a36baae815b7b550b574eeeb483 Reviewed-by: Gunnar Sletta --- tests/auto/quick/qquickimage/data/qtbug_32513.qml | 63 +++++++++++++++++++++++ tests/auto/quick/qquickimage/tst_qquickimage.cpp | 10 ++++ 2 files changed, 73 insertions(+) create mode 100644 tests/auto/quick/qquickimage/data/qtbug_32513.qml (limited to 'tests') diff --git a/tests/auto/quick/qquickimage/data/qtbug_32513.qml b/tests/auto/quick/qquickimage/data/qtbug_32513.qml new file mode 100644 index 0000000000..b6cbe33eec --- /dev/null +++ b/tests/auto/quick/qquickimage/data/qtbug_32513.qml @@ -0,0 +1,63 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** 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 Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Item { + width: 200; height: 200 + + Image { + cache: false + + NumberAnimation on opacity { + loops: Animation.Infinite + from: 1; to: 0 + } + + SequentialAnimation on source { + loops: Animation.Infinite + PropertyAction { value: "green.png" } + PauseAnimation { duration: 100 } + PropertyAction { value: "pattern.png" } + PauseAnimation { duration: 100 } + } + } +} diff --git a/tests/auto/quick/qquickimage/tst_qquickimage.cpp b/tests/auto/quick/qquickimage/tst_qquickimage.cpp index 0804c7b900..8bdb9c9de5 100644 --- a/tests/auto/quick/qquickimage/tst_qquickimage.cpp +++ b/tests/auto/quick/qquickimage/tst_qquickimage.cpp @@ -99,6 +99,7 @@ private slots: void sourceSize_QTBUG_16389(); void nullPixmapPaint(); void imageCrash_QTBUG_22125(); + void imageCrash_QTBUG_32513(); void sourceSize_data(); void sourceSize(); void progressAndStatusChanges(); @@ -704,6 +705,15 @@ void tst_qquickimage::imageCrash_QTBUG_22125() QCoreApplication::processEvents(); } +void tst_qquickimage::imageCrash_QTBUG_32513() +{ + QQuickView view(testFileUrl("qtbug_32513.qml")); + view.show(); + QVERIFY(QTest::qWaitForWindowExposed(&view)); + QTest::qWait(1000); + // shouldn't crash when the image changes sources +} + void tst_qquickimage::sourceSize_data() { QTest::addColumn("sourceWidth"); -- cgit v1.2.3 From b2a1db155bd9cb803abc5d98278cc425b0995c18 Mon Sep 17 00:00:00 2001 From: Rafael Roquetto Date: Mon, 22 Jul 2013 17:40:22 -0300 Subject: Fix tst_qquicktextedit - Use showNormal() instead of show() to keep expected window sizes on fullscreen platforms. - Use consistent point size for hAlignVisual - Do not query for QQmlComponent::Loading on remoteCursorDelegate: when a new connection is established to the test http server, it will setup a single shot QTimer with a 500ms timeout that will trigger the reply to be sent back, making the call to sendDelayedItem() obsolete and reduntant. Also, it means that in some platforms, data will arrive back to the component before the check for QQmlComponent::Loading is executed, causing the test to fail since at this point the status will already be QQmlComponent::Ready instead. Change-Id: I6508c28fa55a1aa2ae5861922701a8c322342380 Reviewed-by: Thomas McGuire Reviewed-by: Wolfgang Bremer Reviewed-by: Frederik Gladhorn --- tests/auto/quick/qquicktextedit/data/hAlignVisual.qml | 1 + tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp | 14 +++++--------- 2 files changed, 6 insertions(+), 9 deletions(-) (limited to 'tests') diff --git a/tests/auto/quick/qquicktextedit/data/hAlignVisual.qml b/tests/auto/quick/qquicktextedit/data/hAlignVisual.qml index 9c9318d3cc..017bab97a7 100644 --- a/tests/auto/quick/qquicktextedit/data/hAlignVisual.qml +++ b/tests/auto/quick/qquicktextedit/data/hAlignVisual.qml @@ -9,5 +9,6 @@ Rectangle { text: "AA\nBBBBBBB\nCCCCCCCCCCCCCCCC" anchors.centerIn: parent horizontalAlignment: Text.AlignLeft + font.pointSize: 12 } } diff --git a/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp b/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp index 6e74d840aa..a5cf91603b 100644 --- a/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp +++ b/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp @@ -654,7 +654,7 @@ void tst_qquicktextedit::hAlign_RightToLeft() QQuickView window(testFileUrl("horizontalAlignment_RightToLeft.qml")); QQuickTextEdit *textEdit = window.rootObject()->findChild("text"); QVERIFY(textEdit != 0); - window.show(); + window.showNormal(); const QString rtlText = textEdit->text(); @@ -832,7 +832,7 @@ void tst_qquicktextedit::hAlignVisual() { QQuickView view(testFileUrl("hAlignVisual.qml")); view.setFlags(view.flags() | Qt::WindowStaysOnTopHint); // Prevent being obscured by other windows. - view.show(); + view.showNormal(); QVERIFY(QTest::qWaitForWindowExposed(&view)); QQuickText *text = view.rootObject()->findChild("textItem"); @@ -1262,7 +1262,7 @@ void tst_qquicktextedit::focusOnPress() QQuickWindow window; window.resize(100, 50); textEditObject->setParentItem(window.contentItem()); - window.show(); + window.showNormal(); window.requestActivate(); QTest::qWaitForWindowActive(&window); @@ -2530,7 +2530,7 @@ void tst_qquicktextedit::remoteCursorDelegate() view.rootContext()->setContextProperty("contextDelegate", &component); view.setSource(testFileUrl("cursorTestRemote.qml")); - view.show(); + view.showNormal(); view.requestActivate(); QTest::qWaitForWindowActive(&view); QQuickTextEdit *textEditObject = view.rootObject()->findChild("textEditObject"); @@ -2544,10 +2544,6 @@ void tst_qquicktextedit::remoteCursorDelegate() textEditObject->setFocus(true); QVERIFY(textEditObject->isCursorVisible()); - QCOMPARE(component.status(), QQmlComponent::Loading); - QVERIFY(!textEditObject->findChild("cursorInstance")); - server.sendDelayedItem(); - // Wait for component to load. QTRY_COMPARE(component.status(), QQmlComponent::Ready); QVERIFY(textEditObject->findChild("cursorInstance")); @@ -3057,7 +3053,7 @@ void tst_qquicktextedit::openInputPanel() inputMethodPrivate->testContext = &platformInputContext; QQuickView view(testFileUrl("openInputPanel.qml")); - view.show(); + view.showNormal(); view.requestActivate(); QTest::qWaitForWindowActive(&view); -- cgit v1.2.3 From 0316506d9ddbc3ca9f26f880b9e7fb5d5b0fec36 Mon Sep 17 00:00:00 2001 From: Rafael Roquetto Date: Tue, 30 Jul 2013 17:07:48 -0300 Subject: Fix tst_qquickpath not to use fuzzy compare On arm platforms, qreal == float. QPointF stores its coordinates internally on qreal variables (float on arm). When QPointF comparison takes place, a call to qFuzzyIsNull(float) will ultimately be triggered, causing the test to fail for some values, because the epsilon of 0.00001f is too small. In the particular case regarding BB10, the comparison between QPointF(100, 150) and QPointF(99.9999771, 150) is failing because of that. Change-Id: I53c8cfe7f8a975f6a015e7690702d3e5f05bc2f2 Reviewed-by: Frederik Gladhorn --- tests/auto/quick/qquickpath/tst_qquickpath.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'tests') diff --git a/tests/auto/quick/qquickpath/tst_qquickpath.cpp b/tests/auto/quick/qquickpath/tst_qquickpath.cpp index fa68442329..6ecc5cee50 100644 --- a/tests/auto/quick/qquickpath/tst_qquickpath.cpp +++ b/tests/auto/quick/qquickpath/tst_qquickpath.cpp @@ -128,7 +128,7 @@ void tst_QuickPath::catmullromCurve() pos = obj->pointAt(.75); QCOMPARE(pos.toPoint(), QPoint(51,105)); //fuzzy compare pos = obj->pointAt(1); - QCOMPARE(pos, QPointF(100,150)); + QCOMPARE(pos.toPoint(), QPoint(100,150)); } void tst_QuickPath::closedCatmullromCurve() @@ -227,7 +227,7 @@ void tst_QuickPath::line() QCOMPARE(p1.x(), p1.y()); QPointF p2 = path2->pointAt(t); - QCOMPARE(p1, p2); + QCOMPARE(p1.toPoint(), p2.toPoint()); } } -- cgit v1.2.3