aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/quick
diff options
context:
space:
mode:
authorQt Forward Merge Bot <qt_forward_merge_bot@qt-project.org>2018-07-14 01:02:04 +0200
committerSimon Hausmann <simon.hausmann@qt.io>2018-07-16 09:38:30 +0200
commit43645fd59c6bcb0a3e37eef530ef970f51ed48af (patch)
treed377a19c36e9e853377db59b58d937db0ea67e0d /tests/auto/quick
parentad0f200df54e5afcb1fdcb977794259bdb9216b5 (diff)
parentf42207cbdb0cbe5e345bfd9e000b3e77b34a503c (diff)
Merge remote-tracking branch 'origin/5.11' into dev
Conflicts: src/quick/items/qquickloader.cpp tests/auto/quick/qquickanimations/tst_qquickanimations.cpp Change-Id: I0cb9f637d24ccd0ecfb50c455cc210119f744b02
Diffstat (limited to 'tests/auto/quick')
-rw-r--r--tests/auto/quick/qquickanimations/data/replacingTransitions.qml51
-rw-r--r--tests/auto/quick/qquickanimations/tst_qquickanimations.cpp37
-rw-r--r--tests/auto/quick/qquickitem/BLACKLIST3
-rw-r--r--tests/auto/quick/qquickitem/tst_qquickitem.cpp14
-rw-r--r--tests/auto/quick/qquicklayouts/data/rowlayout/LayerEnabled.qml78
-rw-r--r--tests/auto/quick/qquicklayouts/data/tst_rowlayout.qml18
-rw-r--r--tests/auto/quick/qquickloader/tst_qquickloader.cpp53
7 files changed, 245 insertions, 9 deletions
diff --git a/tests/auto/quick/qquickanimations/data/replacingTransitions.qml b/tests/auto/quick/qquickanimations/data/replacingTransitions.qml
new file mode 100644
index 0000000000..ff7c50cd67
--- /dev/null
+++ b/tests/auto/quick/qquickanimations/data/replacingTransitions.qml
@@ -0,0 +1,51 @@
+import QtQuick 2.9
+
+Rectangle {
+ id: theRoot
+ property alias model: theModel
+ property alias addTimer: addToModel
+ property alias addTransition: addTrans
+ property alias displaceTransition: displaceTrans
+
+ width: 400
+ height: 400
+
+ ListModel {
+ id: theModel
+ }
+ Timer {
+ id: addToModel
+ interval: 1000
+ running: false
+ repeat: true
+ onTriggered: {
+ theModel.insert(0, {"name": "item " + theModel.count})
+ if (theModel.count > 2)
+ stop()
+ }
+ }
+ Component {
+ id: listDelegate
+ Text {
+ text: name
+ }
+ }
+ ListView {
+ id: listView
+
+ property int animationDuration: 10000
+
+ anchors.fill: parent
+ model: theModel
+ delegate: listDelegate
+ add: Transition {
+ id: addTrans
+ NumberAnimation { properties: "x"; from: 400; duration: listView.animationDuration }
+ NumberAnimation { properties: "y"; from: 400; duration: listView.animationDuration }
+ }
+ addDisplaced: Transition {
+ id: displaceTrans
+ NumberAnimation { properties: "x,y"; duration: listView.animationDuration }
+ }
+ }
+}
diff --git a/tests/auto/quick/qquickanimations/tst_qquickanimations.cpp b/tests/auto/quick/qquickanimations/tst_qquickanimations.cpp
index 3cfe03a376..0f095774e8 100644
--- a/tests/auto/quick/qquickanimations/tst_qquickanimations.cpp
+++ b/tests/auto/quick/qquickanimations/tst_qquickanimations.cpp
@@ -29,6 +29,8 @@
#include <QtQml/qqmlengine.h>
#include <QtQml/qqmlcomponent.h>
#include <QtQuick/qquickview.h>
+#include <QtQml/private/qqmltimer_p.h>
+#include <QtQml/private/qqmllistmodel_p.h>
#include <QtQml/private/qanimationgroupjob_p.h>
#include <QtQuick/private/qquickrectangle_p.h>
#include <QtQuick/private/qquickitemanimation_p.h>
@@ -106,6 +108,7 @@ private slots:
void pathLineUnspecifiedXYBug();
void unsetAnimatorProxyJobWindow();
void finished();
+ void replacingTransitions();
};
#define QTIMED_COMPARE(lhs, rhs) do { \
@@ -1686,6 +1689,40 @@ void tst_qquickanimations::finished()
}
}
+void tst_qquickanimations::replacingTransitions()
+{
+ QQmlEngine engine;
+ QQmlComponent c(&engine, testFileUrl("replacingTransitions.qml"));
+ QScopedPointer<QQuickRectangle> rect(qobject_cast<QQuickRectangle*>(c.create()));
+ if (!c.errors().isEmpty())
+ qDebug() << c.errorString();
+ QVERIFY(rect);
+
+ QQmlTimer *addTimer = rect->property("addTimer").value<QQmlTimer*>();
+ QVERIFY(addTimer);
+ QCOMPARE(addTimer->isRunning(), false);
+
+ QQuickTransition *addTrans = rect->property("addTransition").value<QQuickTransition*>();
+ QVERIFY(addTrans);
+ QCOMPARE(addTrans->running(), false);
+
+ QQuickTransition *displaceTrans = rect->property("displaceTransition").value<QQuickTransition*>();
+ QVERIFY(displaceTrans);
+ QCOMPARE(displaceTrans->running(), false);
+
+ QQmlListModel *model = rect->property("model").value<QQmlListModel *>();
+ QVERIFY(model);
+ QCOMPARE(model->count(), 0);
+
+ addTimer->start();
+ QTest::qWait(1000 + 1000 + 10000);
+
+ QTRY_COMPARE(addTimer->isRunning(), false);
+ QTRY_COMPARE(addTrans->running(), false);
+ QTRY_COMPARE(displaceTrans->running(), false);
+ QCOMPARE(model->count(), 3);
+}
+
QTEST_MAIN(tst_qquickanimations)
#include "tst_qquickanimations.moc"
diff --git a/tests/auto/quick/qquickitem/BLACKLIST b/tests/auto/quick/qquickitem/BLACKLIST
index 85c4df4feb..d94a3ef102 100644
--- a/tests/auto/quick/qquickitem/BLACKLIST
+++ b/tests/auto/quick/qquickitem/BLACKLIST
@@ -1,5 +1,2 @@
[contains:hollow square: testing points inside]
xcb
-
-[qtBug60123]
-offscreen
diff --git a/tests/auto/quick/qquickitem/tst_qquickitem.cpp b/tests/auto/quick/qquickitem/tst_qquickitem.cpp
index ee9d36560d..7e132f97b6 100644
--- a/tests/auto/quick/qquickitem/tst_qquickitem.cpp
+++ b/tests/auto/quick/qquickitem/tst_qquickitem.cpp
@@ -2105,32 +2105,34 @@ void tst_qquickitem::shortcutOverride()
void tst_qquickitem::qtBug60123()
{
QMainWindow main;
+ main.resize(400, 200);
QQuickView window;
QQuickView window2;
window.setSource(testFileUrl("mainWindowQtBug60123.qml"));
window2.setSource(testFileUrl("mainWindowQtBug60123.qml"));
+ // Create central widget for the main window
QWidget *baseWidget = new QWidget(&main);
- main.resize(400, 200);
baseWidget->resize(400, 200);
baseWidget->setMaximumHeight(200);
baseWidget->setMaximumWidth(400);
+ main.setCentralWidget(baseWidget);
// Create container widgets for both windows
QWidget *containers = QWidget::createWindowContainer(&window, baseWidget);
- containers->setGeometry(0, 0, 400, 200);
- QWidget* containers2 = QWidget::createWindowContainer(&window2, baseWidget);
- containers2->setGeometry(50, 50, 300, 150);
+ QWidget *containers2 = QWidget::createWindowContainer(&window2, baseWidget);
+ containers->setGeometry(0, 0, 100, 100);
+ containers2->setGeometry(100, 100, 100, 100);
// Show and activate the main window
main.show();
- QTest::qWaitForWindowActive(&main);
+ QVERIFY(QTest::qWaitForWindowExposed(&main));
// Activate window, test press and release events
auto activateWindowAndTestPress = [] (QQuickView* testWindow) {
testWindow->requestActivate();
- QTest::qWaitForWindowActive(testWindow);
+ QVERIFY(QTest::qWaitForWindowActive(testWindow));
QTest::mousePress(testWindow, Qt::LeftButton, Qt::NoModifier, QPoint(10, 10));
QCOMPARE(testWindow->rootObject()->property("lastEvent").toString(), QString("pressed"));
QTest::mouseRelease(testWindow, Qt::LeftButton, Qt::NoModifier, QPoint(10, 10));
diff --git a/tests/auto/quick/qquicklayouts/data/rowlayout/LayerEnabled.qml b/tests/auto/quick/qquicklayouts/data/rowlayout/LayerEnabled.qml
new file mode 100644
index 0000000000..39500cc19d
--- /dev/null
+++ b/tests/auto/quick/qquicklayouts/data/rowlayout/LayerEnabled.qml
@@ -0,0 +1,78 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE: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.7
+import QtQuick.Layouts 1.3
+
+Rectangle {
+ width: 100
+ height: 100
+ color: "black"
+
+ property alias layout: layout
+ property alias item1: r1
+
+ RowLayout {
+ id: layout
+ anchors.fill: parent
+ visible: false
+ spacing: 0
+
+ Rectangle {
+ id: r1
+ color: "red"
+
+ layer.enabled: true
+
+ Layout.fillWidth: true
+ Layout.fillHeight: true
+ }
+ }
+}
diff --git a/tests/auto/quick/qquicklayouts/data/tst_rowlayout.qml b/tests/auto/quick/qquicklayouts/data/tst_rowlayout.qml
index 763c4cf6e4..07af6a77ac 100644
--- a/tests/auto/quick/qquicklayouts/data/tst_rowlayout.qml
+++ b/tests/auto/quick/qquicklayouts/data/tst_rowlayout.qml
@@ -1082,5 +1082,23 @@ Item {
// Shouldn't crash upon destroying containerUser.
}
+
+ /*
+ Tests that a layout-managed item that sets layer.enabled to true
+ still renders something. This is a simpler test case that only
+ reproduces the issue when the layout that manages it is made visible
+ after component completion, but QTBUG-63269 has a more complex example
+ where this (setting visible to true afterwards) isn't necessary.
+ */
+ function test_layerEnabled() {
+ var component = Qt.createComponent("rowlayout/LayerEnabled.qml");
+ compare(component.status, Component.Ready);
+
+ var rootRect = createTemporaryObject(component, container);
+ verify(rootRect);
+ rootRect.layout.visible = true;
+ waitForRendering(rootRect.layout)
+ compare(rootRect.item1.width, 100)
+ }
}
}
diff --git a/tests/auto/quick/qquickloader/tst_qquickloader.cpp b/tests/auto/quick/qquickloader/tst_qquickloader.cpp
index fd9fed39b5..fbdd87905b 100644
--- a/tests/auto/quick/qquickloader/tst_qquickloader.cpp
+++ b/tests/auto/quick/qquickloader/tst_qquickloader.cpp
@@ -126,6 +126,8 @@ private slots:
void parentErrors();
void rootContext();
+ void sourceURLKeepComponent();
+
};
Q_DECLARE_METATYPE(QList<QQmlError>)
@@ -1388,6 +1390,57 @@ void tst_QQuickLoader::rootContext()
QCOMPARE(objectInRootContext.didIt, 2);
}
+void tst_QQuickLoader::sourceURLKeepComponent()
+{
+ QQmlEngine engine;
+ QQmlComponent component(&engine);
+ component.setData(QByteArray(
+ "import QtQuick 2.0\n"
+ " Loader { id: loader\n }"),
+ dataDirectoryUrl());
+
+ QScopedPointer<QQuickLoader> loader(qobject_cast<QQuickLoader*>(component.create()));
+ loader->setSource(testFileUrl("/Rect120x60.qml"));
+
+ QVERIFY(loader);
+ QVERIFY(loader->item());
+ QVERIFY(loader->sourceComponent());
+ QCOMPARE(loader->progress(), 1.0);
+
+ const QPointer<QQmlComponent> sourceComponent = loader->sourceComponent();
+
+ //Ensure toggling active status does not recreate component
+ loader->setActive(false);
+ QVERIFY(!loader->item());
+ QVERIFY(loader->sourceComponent());
+ QCOMPARE(sourceComponent.data(), loader->sourceComponent());
+
+ loader->setActive(true);
+ QVERIFY(loader->item());
+ QVERIFY(loader->sourceComponent());
+ QCOMPARE(sourceComponent.data(), loader->sourceComponent());
+
+ loader->setActive(false);
+ QVERIFY(!loader->item());
+ QVERIFY(loader->sourceComponent());
+ QCOMPARE(sourceComponent.data(), loader->sourceComponent());
+
+ //Ensure changing source url causes component to be recreated when inactive
+ loader->setSource(testFileUrl("/BlueRect.qml"));
+
+ loader->setActive(true);
+ QVERIFY(loader->item());
+ QVERIFY(loader->sourceComponent());
+
+ const QPointer<QQmlComponent> newSourceComponent = loader->sourceComponent();
+ QVERIFY(sourceComponent.data() != newSourceComponent.data());
+
+ //Ensure changing source url causes component to be recreated when active
+ loader->setSource(testFileUrl("/Rect120x60.qml"));
+ QVERIFY(loader->sourceComponent() != newSourceComponent.data());
+
+}
+
QTEST_MAIN(tst_QQuickLoader)
#include "tst_qquickloader.moc"