diff options
author | Liang Qi <liang.qi@qt.io> | 2016-06-30 13:25:53 +0200 |
---|---|---|
committer | Liang Qi <liang.qi@qt.io> | 2016-06-30 13:28:35 +0200 |
commit | 42f485231c6bdbf2ad42e9483ec372b108d40f37 (patch) | |
tree | fd0ab45513e9f7c9b2af9a751ec8d7c469725ab2 /tests | |
parent | 15849d78b7cca848b87badcfee33db1db70b8b52 (diff) | |
parent | ac44a5b574289e8a24c7ad76760fdbb0a0728478 (diff) |
Merge remote-tracking branch 'origin/5.7' into dev
Conflicts:
src/quick/items/context2d/qquickcanvasitem.cpp
src/quickwidgets/qquickwidget.cpp
tests/auto/quickwidgets/qquickwidget/tst_qquickwidget.cpp
Change-Id: Idf279cb88e0df2a383489af5b6afdf04d04ae611
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/qmltest/BLACKLIST | 5 | ||||
-rw-r--r-- | tests/auto/qmltest/itemgrabber/tst_itemgrabber.qml (renamed from tests/auto/qmltest-blacklist/itemgrabber/tst_itemgrabber.qml) | 4 | ||||
-rw-r--r-- | tests/auto/qmltest/textinput/tst_textinput.qml | 1 | ||||
-rw-r--r-- | tests/auto/quick/qquickanimatedsprite/data/img100x100.png | bin | 0 -> 238 bytes | |||
-rw-r--r-- | tests/auto/quick/qquickanimatedsprite/data/img50x50.png | bin | 0 -> 135 bytes | |||
-rw-r--r-- | tests/auto/quick/qquickanimatedsprite/data/sourceSwitch.qml | 46 | ||||
-rw-r--r-- | tests/auto/quick/qquickanimatedsprite/tst_qquickanimatedsprite.cpp | 39 | ||||
-rw-r--r-- | tests/auto/quick/qquicklistview/tst_qquicklistview.cpp | 17 | ||||
-rw-r--r-- | tests/auto/quick/qquickmultipointtoucharea/data/cancel.qml | 41 | ||||
-rw-r--r-- | tests/auto/quick/qquickmultipointtoucharea/tst_qquickmultipointtoucharea.cpp | 55 | ||||
-rw-r--r-- | tests/auto/quickwidgets/qquickwidget/tst_qquickwidget.cpp | 13 |
11 files changed, 214 insertions, 7 deletions
diff --git a/tests/auto/qmltest/BLACKLIST b/tests/auto/qmltest/BLACKLIST index c472a51a1c..c38347b42a 100644 --- a/tests/auto/qmltest/BLACKLIST +++ b/tests/auto/qmltest/BLACKLIST @@ -9,8 +9,3 @@ linux linux [ListView::test_listInteractiveCurrentIndexEnforce] linux -[Text::test_linecount] -osx -windows -[TextInput::test_doublevalidators] -osx diff --git a/tests/auto/qmltest-blacklist/itemgrabber/tst_itemgrabber.qml b/tests/auto/qmltest/itemgrabber/tst_itemgrabber.qml index 743dad70eb..022e98a202 100644 --- a/tests/auto/qmltest-blacklist/itemgrabber/tst_itemgrabber.qml +++ b/tests/auto/qmltest/itemgrabber/tst_itemgrabber.qml @@ -102,7 +102,7 @@ Item { property int callCount: 0; property bool ready: false; function handleGrab(result) { - if (!result.saveToFile("image.png")) + if (!result.saveToFile("itemgrabber/image.png")) print("Error: Failed to save image to disk..."); source = "image.png"; ready = true; @@ -116,7 +116,7 @@ Item { y: 0 property bool ready: false; function handleGrab(result) { - if (!result.saveToFile("image_small.png")) + if (!result.saveToFile("itemgrabber/image_small.png")) print("Error: Failed to save image to disk..."); source = "image_small.png"; ready = true; diff --git a/tests/auto/qmltest/textinput/tst_textinput.qml b/tests/auto/qmltest/textinput/tst_textinput.qml index 62659a2188..51868ec8aa 100644 --- a/tests/auto/qmltest/textinput/tst_textinput.qml +++ b/tests/auto/qmltest/textinput/tst_textinput.qml @@ -277,6 +277,7 @@ Item { } function test_doublevalidators(row) { + txtdoublevalidator.validator.locale = "C" compare(txtdoublevalidator.validator.top, 2.0) compare(txtdoublevalidator.validator.bottom, 1.0) txtdoublevalidator.text = row.testnumber; diff --git a/tests/auto/quick/qquickanimatedsprite/data/img100x100.png b/tests/auto/quick/qquickanimatedsprite/data/img100x100.png Binary files differnew file mode 100644 index 0000000000..9dd1990780 --- /dev/null +++ b/tests/auto/quick/qquickanimatedsprite/data/img100x100.png diff --git a/tests/auto/quick/qquickanimatedsprite/data/img50x50.png b/tests/auto/quick/qquickanimatedsprite/data/img50x50.png Binary files differnew file mode 100644 index 0000000000..5cbb47981a --- /dev/null +++ b/tests/auto/quick/qquickanimatedsprite/data/img50x50.png diff --git a/tests/auto/quick/qquickanimatedsprite/data/sourceSwitch.qml b/tests/auto/quick/qquickanimatedsprite/data/sourceSwitch.qml new file mode 100644 index 0000000000..18a8f52661 --- /dev/null +++ b/tests/auto/quick/qquickanimatedsprite/data/sourceSwitch.qml @@ -0,0 +1,46 @@ +/**************************************************************************** +** +** 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:LGPL21$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** As a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.4 + +AnimatedSprite { + id: animatedSprite + source: big ? "img100x100.png" : "img50x50.png" + frameWidth: 100 + frameHeight: 100 + property bool big: true + MouseArea { + anchors.fill: parent + onClicked: animatedSprite.big = !animatedSprite.big + } +} diff --git a/tests/auto/quick/qquickanimatedsprite/tst_qquickanimatedsprite.cpp b/tests/auto/quick/qquickanimatedsprite/tst_qquickanimatedsprite.cpp index 27ce46d163..820c804065 100644 --- a/tests/auto/quick/qquickanimatedsprite/tst_qquickanimatedsprite.cpp +++ b/tests/auto/quick/qquickanimatedsprite/tst_qquickanimatedsprite.cpp @@ -35,6 +35,7 @@ #include <QtGui/qopenglcontext.h> #include <QtGui/qopenglfunctions.h> #include <QtGui/qoffscreensurface.h> +#include <QtQml/qqmlproperty.h> class tst_qquickanimatedsprite : public QQmlDataTest { @@ -50,6 +51,7 @@ private slots: void test_largeAnimation_data(); void test_largeAnimation(); void test_reparenting(); + void test_changeSourceToSmallerImgKeepingBigFrameSize(); }; void tst_qquickanimatedsprite::initTestCase() @@ -286,6 +288,43 @@ void tst_qquickanimatedsprite::test_reparenting() QTRY_COMPARE(QQuickItemPrivate::get(sprite)->polishScheduled, false); } +class KillerThread : public QThread +{ + Q_OBJECT +protected: + void run() Q_DECL_OVERRIDE { + sleep(3); + qFatal("Either the GUI or the render thread is stuck in an infinite loop."); + } +}; + +// Regression test for QTBUG-53937 +void tst_qquickanimatedsprite::test_changeSourceToSmallerImgKeepingBigFrameSize() +{ + QQuickView window; + window.setSource(testFileUrl("sourceSwitch.qml")); + window.show(); + QVERIFY(QTest::qWaitForWindowExposed(&window)); + + QVERIFY(window.rootObject()); + QQuickAnimatedSprite* sprite = qobject_cast<QQuickAnimatedSprite*>(window.rootObject()); + QVERIFY(sprite); + + QQmlProperty big(sprite, "big"); + big.write(QVariant::fromValue(false)); + + KillerThread *killer = new KillerThread; + killer->start(); // will kill us in case the GUI or render thread enters an infinite loop + + QTest::qWait(50); // let it draw with the new source. + + // If we reach this point it's because we didn't hit QTBUG-53937 + + killer->terminate(); + killer->wait(); + delete killer; +} + QTEST_MAIN(tst_qquickanimatedsprite) #include "tst_qquickanimatedsprite.moc" diff --git a/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp b/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp index f5e79614df..b83edec996 100644 --- a/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp +++ b/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp @@ -629,6 +629,8 @@ void tst_QQuickListView::inserted_more(QQuickItemView::VerticalLayoutDirection v } listview->setContentY(contentY); + QQuickItemViewPrivate::get(listview)->layout(); + QList<QPair<QString, QString> > newData; for (int i=0; i<insertCount; i++) newData << qMakePair(QString("value %1").arg(i), QString::number(i)); @@ -650,6 +652,16 @@ void tst_QQuickListView::inserted_more(QQuickItemView::VerticalLayoutDirection v QCOMPARE(item0->y(), itemsOffsetAfterMove); #endif + QList<FxViewItem *> visibleItems = QQuickItemViewPrivate::get(listview)->visibleItems; + for (QList<FxViewItem *>::const_iterator itemIt = visibleItems.begin(); itemIt != visibleItems.end(); ++itemIt) + { + FxViewItem *item = *itemIt; + if (item->item->position().y() >= 0 && item->item->position().y() < listview->height()) + { + QVERIFY(!QQuickItemPrivate::get(item->item)->culled); + } + } + QList<QQuickItem*> items = findItems<QQuickItem>(contentItem, "wrapper"); int firstVisibleIndex = -1; for (int i=0; i<items.count(); i++) { @@ -770,6 +782,11 @@ void tst_QQuickListView::inserted_more_data() << 80.0 // show 4-19 << 20 << 3 << 0.0; + + QTest::newRow("add multiple, within visible, content at start") + << 0.0 + << 2 << 50 + << 0.0; } void tst_QQuickListView::insertBeforeVisible() diff --git a/tests/auto/quick/qquickmultipointtoucharea/data/cancel.qml b/tests/auto/quick/qquickmultipointtoucharea/data/cancel.qml new file mode 100644 index 0000000000..e108003bca --- /dev/null +++ b/tests/auto/quick/qquickmultipointtoucharea/data/cancel.qml @@ -0,0 +1,41 @@ +import QtQuick 2.0 + +MultiPointTouchArea { + width: 240 + height: 320 + + minimumTouchPoints: 1 + maximumTouchPoints: 5 + touchPoints: [ + TouchPoint { objectName: "point1" }, + TouchPoint { objectName: "point2" }, + TouchPoint { objectName: "point3" }, + TouchPoint { objectName: "point4" }, + TouchPoint { objectName: "point5" } + ] + + function clearCounts() { + touchPointPressCount = 0; + touchPointUpdateCount = 0; + touchPointReleaseCount = 0; + touchPointCancelCount = 0; + touchCount = 0; + touchUpdatedHandled = false; + } + + property int touchPointPressCount: 0 + property int touchPointUpdateCount: 0 + property int touchPointReleaseCount: 0 + property int touchPointCancelCount: 0 + property int touchCount: 0 + property bool touchUpdatedHandled: false + + onPressed: { touchPointPressCount = touchPoints.length } + onUpdated: { touchPointUpdateCount = touchPoints.length } + onReleased: { touchPointReleaseCount = touchPoints.length } + onCanceled: { touchPointCancelCount = touchPoints.length } + onTouchUpdated: { + touchCount = touchPoints.length + touchUpdatedHandled = true + } +} diff --git a/tests/auto/quick/qquickmultipointtoucharea/tst_qquickmultipointtoucharea.cpp b/tests/auto/quick/qquickmultipointtoucharea/tst_qquickmultipointtoucharea.cpp index 8320d899f9..c3981c466f 100644 --- a/tests/auto/quick/qquickmultipointtoucharea/tst_qquickmultipointtoucharea.cpp +++ b/tests/auto/quick/qquickmultipointtoucharea/tst_qquickmultipointtoucharea.cpp @@ -69,6 +69,7 @@ private slots: void transformedTouchArea(); void mouseInteraction(); void mouseInteraction_data(); + void cancel(); private: QQuickView *createAndShowView(const QString &file); @@ -1195,6 +1196,60 @@ void tst_QQuickMultiPointTouchArea::mouseInteraction() QCOMPARE(area->property("touchCount").toInt(), 0); } +void tst_QQuickMultiPointTouchArea::cancel() +{ + QScopedPointer<QQuickView> window(createAndShowView("cancel.qml")); + QVERIFY(window->rootObject() != 0); + + QQuickMultiPointTouchArea *area = qobject_cast<QQuickMultiPointTouchArea *>(window->rootObject()); + QTest::QTouchEventSequence sequence = QTest::touchEvent(window.data(), device); + QQuickTouchPoint *point1 = area->findChild<QQuickTouchPoint*>("point1"); + + QPoint p1(20,100); + sequence.press(0, p1).commit(); + QQuickTouchUtils::flush(window.data()); + QCOMPARE(point1->pressed(), true); + QCOMPARE(area->property("touchPointPressCount").toInt(), 1); + QCOMPARE(area->property("touchPointUpdateCount").toInt(), 0); + QCOMPARE(area->property("touchPointReleaseCount").toInt(), 0); + QCOMPARE(area->property("touchPointCancelCount").toInt(), 0); + QCOMPARE(area->property("touchCount").toInt(), 1); + QMetaObject::invokeMethod(area, "clearCounts"); + + area->setVisible(false); + // we should get a onCancel signal + QCOMPARE(point1->pressed(), false); + QCOMPARE(area->property("touchPointPressCount").toInt(), 0); + QCOMPARE(area->property("touchPointUpdateCount").toInt(), 0); + QCOMPARE(area->property("touchPointReleaseCount").toInt(), 0); + QCOMPARE(area->property("touchPointCancelCount").toInt(), 1); + QCOMPARE(area->property("touchCount").toInt(), 0); + QMetaObject::invokeMethod(area, "clearCounts"); + area->setVisible(true); + + + sequence.press(0, p1).commit(); + QQuickTouchUtils::flush(window.data()); + QCOMPARE(point1->pressed(), true); + QCOMPARE(area->property("touchPointPressCount").toInt(), 1); + QCOMPARE(area->property("touchPointUpdateCount").toInt(), 0); + QCOMPARE(area->property("touchPointReleaseCount").toInt(), 0); + QCOMPARE(area->property("touchPointCancelCount").toInt(), 0); + QCOMPARE(area->property("touchCount").toInt(), 1); + QMetaObject::invokeMethod(area, "clearCounts"); + + area->setEnabled(false); + // we should get a onCancel signal + QCOMPARE(point1->pressed(), false); + QCOMPARE(area->property("touchPointPressCount").toInt(), 0); + QCOMPARE(area->property("touchPointUpdateCount").toInt(), 0); + QCOMPARE(area->property("touchPointReleaseCount").toInt(), 0); + QCOMPARE(area->property("touchPointCancelCount").toInt(), 1); + QCOMPARE(area->property("touchCount").toInt(), 0); + QMetaObject::invokeMethod(area, "clearCounts"); + +} + QTEST_MAIN(tst_QQuickMultiPointTouchArea) diff --git a/tests/auto/quickwidgets/qquickwidget/tst_qquickwidget.cpp b/tests/auto/quickwidgets/qquickwidget/tst_qquickwidget.cpp index 7676bd6c31..5e8f762e23 100644 --- a/tests/auto/quickwidgets/qquickwidget/tst_qquickwidget.cpp +++ b/tests/auto/quickwidgets/qquickwidget/tst_qquickwidget.cpp @@ -57,6 +57,7 @@ private slots: void renderingSignals(); void grabBeforeShow(); void reparentToNewWindow(); + void nullEngine(); }; @@ -324,6 +325,18 @@ void tst_qquickwidget::reparentToNewWindow() QCOMPARE(img.pixel(5, 5), qRgb(255, 0, 0)); } +void tst_qquickwidget::nullEngine() +{ + QQuickWidget widget; + // Default should have no errors, even with a null qml engine + QVERIFY(widget.errors().isEmpty()); + QCOMPARE(widget.status(), QQuickWidget::Null); + + // A QML engine should be created lazily. + QVERIFY(widget.rootContext()); + QVERIFY(widget.engine()); +} + QTEST_MAIN(tst_qquickwidget) #include "tst_qquickwidget.moc" |