aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/qquickapplicationwindow
diff options
context:
space:
mode:
authorJan Arve Sæther <Jan-Arve.Saether@qt.io>2021-06-11 16:31:30 +0200
committerJan Arve Sæther <Jan-Arve.Saether@qt.io>2021-06-16 16:29:02 +0200
commit6dc95399797de4ec27984956df1fa587f4eb18ba (patch)
treebdc6870c716f301a1da78fa5224dddc2232eea3e /tests/auto/qquickapplicationwindow
parent41766ac6d6e100b69d74c98edde60f0835b7da13 (diff)
Add recursion guard to QQuickApplicationWindowPrivate::relayout()
relayout() might change the size of the header, footer or contentitem When one of those items changes, QQuickApplicationWindowPrivate will get notified by that through QQuickApplicationWindowPrivate::itemGeometryChanged(). itemGeometryChanged() will then call relayout()... (*recursed*). Pick-to: 5.15 6.2 Task-number: QTBUG-87708 Change-Id: I9403952e776afb2be37d009642c65b5520c79341 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Diffstat (limited to 'tests/auto/qquickapplicationwindow')
-rw-r--r--tests/auto/qquickapplicationwindow/data/layoutLayout.qml66
-rw-r--r--tests/auto/qquickapplicationwindow/tst_qquickapplicationwindow.cpp37
2 files changed, 103 insertions, 0 deletions
diff --git a/tests/auto/qquickapplicationwindow/data/layoutLayout.qml b/tests/auto/qquickapplicationwindow/data/layoutLayout.qml
new file mode 100644
index 00000000..670306fa
--- /dev/null
+++ b/tests/auto/qquickapplicationwindow/data/layoutLayout.qml
@@ -0,0 +1,66 @@
+/****************************************************************************
+**
+** Copyright (C) 2021 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
+import QtQuick.Controls
+import QtQuick.Layouts
+
+ApplicationWindow {
+ width: 200
+ height: 200
+ visible: true
+
+ header: RowLayout {
+ Rectangle { color: "red"; implicitWidth: 20; implicitHeight: 20; Layout.fillWidth: true}
+ }
+ footer: ColumnLayout {
+ Rectangle { color: "green"; implicitWidth: 20; implicitHeight: 20; Layout.fillWidth: true}
+ }
+}
diff --git a/tests/auto/qquickapplicationwindow/tst_qquickapplicationwindow.cpp b/tests/auto/qquickapplicationwindow/tst_qquickapplicationwindow.cpp
index 7816622c..f6bf7d74 100644
--- a/tests/auto/qquickapplicationwindow/tst_qquickapplicationwindow.cpp
+++ b/tests/auto/qquickapplicationwindow/tst_qquickapplicationwindow.cpp
@@ -79,6 +79,7 @@ private slots:
void focusAfterPopupClosed();
void clearFocusOnDestruction();
void layout();
+ void layoutLayout();
void componentComplete();
void opacity();
};
@@ -869,6 +870,42 @@ void tst_QQuickApplicationWindow::layout()
QCOMPARE(content->height(), qreal(window->height()));
}
+void tst_QQuickApplicationWindow::layoutLayout()
+{
+ QQmlEngine engine;
+ QQmlComponent component(&engine);
+ component.loadUrl(testFileUrl("layoutLayout.qml"));
+ QScopedPointer<QObject> object(component.create());
+ QVERIFY2(!object.isNull(), qPrintable(component.errorString()));
+
+ QQuickApplicationWindow* window = qobject_cast<QQuickApplicationWindow*>(object.data());
+ QVERIFY(window);
+ QVERIFY(QTest::qWaitForWindowExposed(window));
+
+ QQuickItem *content = window->contentItem();
+ QVERIFY(content);
+ QQuickItem *header = window->header();
+ QVERIFY(header);
+ QQuickItem *footer = window->footer();
+ QVERIFY(footer);
+
+ QQuickItem *headerChild = header->findChild<QQuickItem*>();
+ QVERIFY(headerChild);
+ QCOMPARE(header->x(), 0.0);
+ QCOMPARE(header->y(), -header->height());
+ QCOMPARE(header->width(), qreal(window->width()));
+ QCOMPARE(headerChild->width(), qreal(window->width()));
+ QVERIFY(header->height() > 0);
+
+ QQuickItem *footerChild = header->findChild<QQuickItem*>();
+ QVERIFY(footerChild);
+ QCOMPARE(footer->x(), 0.0);
+ QCOMPARE(footer->y(), content->height());
+ QCOMPARE(footer->width(), qreal(window->width()));
+ QCOMPARE(footerChild->width(), qreal(window->width()));
+ QVERIFY(footer->height() > 0.0);
+}
+
class FriendlyApplicationWindow : public QQuickApplicationWindow
{
friend class tst_QQuickApplicationWindow;