From 7f36556603f7ea6d3a15625c9057ea875a6b6f41 Mon Sep 17 00:00:00 2001 From: Sona Kurazyan Date: Mon, 5 Aug 2019 15:54:02 +0200 Subject: Remove usages of deprecated APIs of QWheelEvent Task-number: QTBUG-76491 Change-Id: I346ddb1e926047878ce57c88cea24d8a4689adaa Reviewed-by: Volker Hilsheimer Reviewed-by: Mitch Curtis --- tests/auto/focus/tst_focus.cpp | 8 ++++++-- tests/auto/qquickdrawer/tst_qquickdrawer.cpp | 4 +++- tests/auto/qquickpopup/tst_qquickpopup.cpp | 4 +++- 3 files changed, 12 insertions(+), 4 deletions(-) (limited to 'tests') diff --git a/tests/auto/focus/tst_focus.cpp b/tests/auto/focus/tst_focus.cpp index 958b996b..8a1b36ad 100644 --- a/tests/auto/focus/tst_focus.cpp +++ b/tests/auto/focus/tst_focus.cpp @@ -232,7 +232,9 @@ void tst_focus::policy() QVERIFY(!control->hasActiveFocus()); // Qt::WheelFocus - QWheelEvent wheelEvent(QPoint(control->width() / 2, control->height() / 2), 10, Qt::NoButton, Qt::NoModifier); + QWheelEvent wheelEvent(QPointF(control->width() / 2, control->height() / 2), QPointF(), + QPoint(), QPoint(0, 10), Qt::NoButton, Qt::NoModifier, + Qt::NoScrollPhase, false); QGuiApplication::sendEvent(control, &wheelEvent); QVERIFY(!control->hasActiveFocus()); QVERIFY(!control->hasVisualFocus()); @@ -403,7 +405,9 @@ void tst_focus::scope() QVERIFY(control->hasActiveFocus()); // Qt::WheelFocus - QWheelEvent wheelEvent(QPoint(control->width() / 2, control->height() / 2), 10, Qt::NoButton, Qt::NoModifier); + QWheelEvent wheelEvent(QPointF(control->width() / 2, control->height() / 2), QPointF(), + QPoint(), QPoint(0, 10), Qt::NoButton, Qt::NoModifier, + Qt::NoScrollPhase, false); QGuiApplication::sendEvent(control, &wheelEvent); QVERIFY(!child->hasActiveFocus()); QVERIFY(control->hasActiveFocus()); diff --git a/tests/auto/qquickdrawer/tst_qquickdrawer.cpp b/tests/auto/qquickdrawer/tst_qquickdrawer.cpp index 816f9b67..97472a11 100644 --- a/tests/auto/qquickdrawer/tst_qquickdrawer.cpp +++ b/tests/auto/qquickdrawer/tst_qquickdrawer.cpp @@ -613,7 +613,9 @@ void tst_QQuickDrawer::wheel_data() static bool sendWheelEvent(QQuickItem *item, const QPoint &localPos, int degrees) { QQuickWindow *window = item->window(); - QWheelEvent wheelEvent(localPos, item->window()->mapToGlobal(localPos), QPoint(0, 0), QPoint(0, 8 * degrees), 0, Qt::Vertical, Qt::NoButton, 0); + QWheelEvent wheelEvent(localPos, item->window()->mapToGlobal(localPos), QPoint(0, 0), + QPoint(0, 8 * degrees), Qt::NoButton, Qt::NoModifier, Qt::NoScrollPhase, + false); QSpontaneKeyEvent::setSpontaneous(&wheelEvent); return qGuiApp->notify(window, &wheelEvent); } diff --git a/tests/auto/qquickpopup/tst_qquickpopup.cpp b/tests/auto/qquickpopup/tst_qquickpopup.cpp index c2f876b8..6eb9482c 100644 --- a/tests/auto/qquickpopup/tst_qquickpopup.cpp +++ b/tests/auto/qquickpopup/tst_qquickpopup.cpp @@ -741,7 +741,9 @@ void tst_QQuickPopup::wheel_data() static bool sendWheelEvent(QQuickItem *item, const QPoint &localPos, int degrees) { QQuickWindow *window = item->window(); - QWheelEvent wheelEvent(localPos, item->window()->mapToGlobal(localPos), QPoint(0, 0), QPoint(0, 8 * degrees), 0, Qt::Vertical, Qt::NoButton, 0); + QWheelEvent wheelEvent(localPos, item->window()->mapToGlobal(localPos), QPoint(0, 0), + QPoint(0, 8 * degrees), Qt::NoButton, Qt::NoModifier, Qt::NoScrollPhase, + false); QSpontaneKeyEvent::setSpontaneous(&wheelEvent); return qGuiApp->notify(window, &wheelEvent); } -- cgit v1.2.3 From 97fc102cd079f32cc1a4f00a764ceea981699fc0 Mon Sep 17 00:00:00 2001 From: Mitch Curtis Date: Tue, 3 Sep 2019 13:20:29 +0200 Subject: Fix flakiness in tst_qquickdrawer tests Although it's not ideal to add arbitrary delays to tests, it does reflect a more realistic testing environment, and more importantly, seems to fix the flakiness on OpenSUSE. Change-Id: I0c13e5f628654aaff349c2f07be46792773a9789 Fixes: QTBUG-77946 Reviewed-by: Liang Qi --- tests/auto/qquickdrawer/tst_qquickdrawer.cpp | 6 ++++-- tests/auto/qquickpopup/tst_qquickpopup.cpp | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) (limited to 'tests') diff --git a/tests/auto/qquickdrawer/tst_qquickdrawer.cpp b/tests/auto/qquickdrawer/tst_qquickdrawer.cpp index 97472a11..7644cacf 100644 --- a/tests/auto/qquickdrawer/tst_qquickdrawer.cpp +++ b/tests/auto/qquickdrawer/tst_qquickdrawer.cpp @@ -350,7 +350,8 @@ void tst_QQuickDrawer::position() QVERIFY(drawer); drawer->setEdge(edge); - QTest::mousePress(window, Qt::LeftButton, Qt::NoModifier, press); + // Give it some time (50 ms) before the press to avoid flakiness on OpenSUSE: QTBUG-77946 + QTest::mousePress(window, Qt::LeftButton, Qt::NoModifier, press, 50); QTest::mouseMove(window, from); QTest::mouseMove(window, to); QCOMPARE(drawer->position(), position); @@ -403,7 +404,8 @@ void tst_QQuickDrawer::dragMargin() int leftX = qMax(0, dragMargin); int leftDistance = startDragDistance + drawer->width() * 0.45; QVERIFY(leftDistance > QGuiApplication::styleHints()->startDragDistance()); - QTest::mousePress(window, Qt::LeftButton, Qt::NoModifier, QPoint(leftX, drawer->height() / 2)); + // Give it some time (50 ms) before the press to avoid flakiness on OpenSUSE: QTBUG-77946 + QTest::mousePress(window, Qt::LeftButton, Qt::NoModifier, QPoint(leftX, drawer->height() / 2), 50); QTest::mouseMove(window, QPoint(leftX + startDragDistance, drawer->height() / 2)); QTest::mouseMove(window, QPoint(leftX + leftDistance, drawer->height() / 2)); QCOMPARE(drawer->position(), dragFromLeft); diff --git a/tests/auto/qquickpopup/tst_qquickpopup.cpp b/tests/auto/qquickpopup/tst_qquickpopup.cpp index 6eb9482c..229d2704 100644 --- a/tests/auto/qquickpopup/tst_qquickpopup.cpp +++ b/tests/auto/qquickpopup/tst_qquickpopup.cpp @@ -494,7 +494,7 @@ void tst_QQuickPopup::closePolicy() QTRY_VERIFY(popup->isOpened()); // press outside popup and its parent - QTest::mousePress(window, Qt::LeftButton, Qt::NoModifier, QPoint(1, 1)); + QTest::mousePress(window, Qt::LeftButton, Qt::NoModifier, QPoint(1, 1), 50); if (closePolicy.testFlag(QQuickPopup::CloseOnPressOutside) || closePolicy.testFlag(QQuickPopup::CloseOnPressOutsideParent)) QTRY_VERIFY(!popup->isVisible()); else -- cgit v1.2.3 From 1e99cb6e809ff0c8647c5017c11ead68ae1a591d Mon Sep 17 00:00:00 2001 From: Mitch Curtis Date: Tue, 3 Sep 2019 13:20:29 +0200 Subject: Fix flakiness in tst_qquickdrawer tests Although it's not ideal to add arbitrary delays to tests, it does reflect a more realistic testing environment, and more importantly, seems to fix the flakiness on OpenSUSE. (cherry picked from commit 97fc102cd079f32cc1a4f00a764ceea981699fc0) Fixes: QTBUG-77946 Change-Id: I2998611759106386091d7375b31e56523c95371f Reviewed-by: Mitch Curtis Reviewed-by: Liang Qi --- tests/auto/qquickdrawer/tst_qquickdrawer.cpp | 6 ++++-- tests/auto/qquickpopup/tst_qquickpopup.cpp | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) (limited to 'tests') diff --git a/tests/auto/qquickdrawer/tst_qquickdrawer.cpp b/tests/auto/qquickdrawer/tst_qquickdrawer.cpp index 816f9b67..4cf0dabe 100644 --- a/tests/auto/qquickdrawer/tst_qquickdrawer.cpp +++ b/tests/auto/qquickdrawer/tst_qquickdrawer.cpp @@ -350,7 +350,8 @@ void tst_QQuickDrawer::position() QVERIFY(drawer); drawer->setEdge(edge); - QTest::mousePress(window, Qt::LeftButton, Qt::NoModifier, press); + // Give it some time (50 ms) before the press to avoid flakiness on OpenSUSE: QTBUG-77946 + QTest::mousePress(window, Qt::LeftButton, Qt::NoModifier, press, 50); QTest::mouseMove(window, from); QTest::mouseMove(window, to); QCOMPARE(drawer->position(), position); @@ -403,7 +404,8 @@ void tst_QQuickDrawer::dragMargin() int leftX = qMax(0, dragMargin); int leftDistance = startDragDistance + drawer->width() * 0.45; QVERIFY(leftDistance > QGuiApplication::styleHints()->startDragDistance()); - QTest::mousePress(window, Qt::LeftButton, Qt::NoModifier, QPoint(leftX, drawer->height() / 2)); + // Give it some time (50 ms) before the press to avoid flakiness on OpenSUSE: QTBUG-77946 + QTest::mousePress(window, Qt::LeftButton, Qt::NoModifier, QPoint(leftX, drawer->height() / 2), 50); QTest::mouseMove(window, QPoint(leftX + startDragDistance, drawer->height() / 2)); QTest::mouseMove(window, QPoint(leftX + leftDistance, drawer->height() / 2)); QCOMPARE(drawer->position(), dragFromLeft); diff --git a/tests/auto/qquickpopup/tst_qquickpopup.cpp b/tests/auto/qquickpopup/tst_qquickpopup.cpp index 81b2d583..4046bd3d 100644 --- a/tests/auto/qquickpopup/tst_qquickpopup.cpp +++ b/tests/auto/qquickpopup/tst_qquickpopup.cpp @@ -493,7 +493,7 @@ void tst_QQuickPopup::closePolicy() QTRY_VERIFY(popup->isOpened()); // press outside popup and its parent - QTest::mousePress(window, Qt::LeftButton, Qt::NoModifier, QPoint(1, 1)); + QTest::mousePress(window, Qt::LeftButton, Qt::NoModifier, QPoint(1, 1), 50); if (closePolicy.testFlag(QQuickPopup::CloseOnPressOutside) || closePolicy.testFlag(QQuickPopup::CloseOnPressOutsideParent)) QTRY_VERIFY(!popup->isVisible()); else -- cgit v1.2.3 From 382531ab5e2270833d3805c57c00ebcf6b24d635 Mon Sep 17 00:00:00 2001 From: Konstantin Ritt Date: Thu, 25 Apr 2019 18:23:32 +0300 Subject: QQuickIcon: properly resolve implicit values when the property has not been set explicitly, the resolved mask must not contain a respective bit set either Change-Id: Iab0bd600b5bf458e26ed4601d4d2f608021f1518 Reviewed-by: Mitch Curtis --- tests/auto/controls/data/tst_abstractbutton.qml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/auto/controls/data/tst_abstractbutton.qml b/tests/auto/controls/data/tst_abstractbutton.qml index 80155f69..ee26a6d6 100644 --- a/tests/auto/controls/data/tst_abstractbutton.qml +++ b/tests/auto/controls/data/tst_abstractbutton.qml @@ -599,7 +599,7 @@ TestCase { AbstractButton { action: Action { text: "Default" - icon.name: "default" + icon.name: checked ? "checked" : "unchecked" icon.source: "qrc:/icons/default.png" checkable: true checked: true @@ -617,6 +617,7 @@ TestCase { compare(control.checkable, true) compare(control.checked, true) compare(control.enabled, false) + compare(control.icon.name, "checked") var textSpy = signalSpy.createObject(control, { target: control, signalName: "textChanged" }) verify(textSpy.valid) @@ -630,6 +631,7 @@ TestCase { compare(control.checkable, false) // propagates compare(control.checked, false) // propagates compare(control.enabled, true) // propagates + compare(control.icon.name, "unchecked") // propagates compare(textSpy.count, 1) // changes via button @@ -637,19 +639,23 @@ TestCase { control.checkable = true control.checked = true control.enabled = false + control.icon.name = "default" compare(control.text, "Button") compare(control.checkable, true) compare(control.checked, true) compare(control.enabled, false) + compare(control.icon.name, "default") compare(control.action.text, "Action") // does NOT propagate compare(control.action.checkable, true) // propagates compare(control.action.checked, true) // propagates compare(control.action.enabled, true) // does NOT propagate + compare(control.action.icon.name, control.action.checked ? "checked" : "unchecked") // does NOT propagate compare(textSpy.count, 2) // remove the action so that only the button's properties are left control.action = null compare(control.text, "Button") + compare(control.icon.name, "default") compare(textSpy.count, 2) // setting an action while button has a particular property set -- cgit v1.2.3 From b059cc37c0c8cf329fe2847b323c8283664f3bdd Mon Sep 17 00:00:00 2001 From: Mitch Curtis Date: Fri, 6 Sep 2019 10:39:31 +0200 Subject: tst_dial: fix copy-paste mistake Slider was incorrectly used in a03b6fec6. Change-Id: Ib76172f9ea0dca3b776a74df2329bd63c72f8517 Reviewed-by: Liang Qi --- tests/auto/controls/data/tst_dial.qml | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'tests') diff --git a/tests/auto/controls/data/tst_dial.qml b/tests/auto/controls/data/tst_dial.qml index cd2f6112..86999594 100644 --- a/tests/auto/controls/data/tst_dial.qml +++ b/tests/auto/controls/data/tst_dial.qml @@ -470,15 +470,15 @@ TestCase { function test_snapMode_data(immediate) { return [ - { tag: "NoSnap", snapMode: Slider.NoSnap, from: 0, to: 2, values: [0, 0, 1], positions: [0, 0.5, 0.5] }, - { tag: "SnapAlways (0..2)", snapMode: Slider.SnapAlways, from: 0, to: 2, values: [0.0, 0.0, 1.0], positions: [0.0, 0.5, 0.5] }, - { tag: "SnapAlways (1..3)", snapMode: Slider.SnapAlways, from: 1, to: 3, values: [1.0, 1.0, 2.0], positions: [0.0, 0.5, 0.5] }, - { tag: "SnapAlways (-1..1)", snapMode: Slider.SnapAlways, from: -1, to: 1, values: [0.0, 0.0, 0.0], positions: [0.5, 0.5, 0.5] }, - { tag: "SnapAlways (1..-1)", snapMode: Slider.SnapAlways, from: 1, to: -1, values: [1.0, 1.0, 0.0], positions: [0.0, 0.5, 0.5] }, - { tag: "SnapOnRelease (0..2)", snapMode: Slider.SnapOnRelease, from: 0, to: 2, values: [0.0, 0.0, 1.0], positions: [0.0, 0.5, 0.5] }, - { tag: "SnapOnRelease (1..3)", snapMode: Slider.SnapOnRelease, from: 1, to: 3, values: [1.0, 1.0, 2.0], positions: [0.0, 0.5, 0.5] }, - { tag: "SnapOnRelease (-1..1)", snapMode: Slider.SnapOnRelease, from: -1, to: 1, values: [0.0, 0.0, 0.0], positions: [immediate ? 0.0 : 0.5, 0.5, 0.5] }, - { tag: "SnapOnRelease (1..-1)", snapMode: Slider.SnapOnRelease, from: 1, to: -1, values: [1.0, 1.0, 0.0], positions: [0.0, 0.5, 0.5] } + { tag: "NoSnap", snapMode: Dial.NoSnap, from: 0, to: 2, values: [0, 0, 1], positions: [0, 0.5, 0.5] }, + { tag: "SnapAlways (0..2)", snapMode: Dial.SnapAlways, from: 0, to: 2, values: [0.0, 0.0, 1.0], positions: [0.0, 0.5, 0.5] }, + { tag: "SnapAlways (1..3)", snapMode: Dial.SnapAlways, from: 1, to: 3, values: [1.0, 1.0, 2.0], positions: [0.0, 0.5, 0.5] }, + { tag: "SnapAlways (-1..1)", snapMode: Dial.SnapAlways, from: -1, to: 1, values: [0.0, 0.0, 0.0], positions: [0.5, 0.5, 0.5] }, + { tag: "SnapAlways (1..-1)", snapMode: Dial.SnapAlways, from: 1, to: -1, values: [1.0, 1.0, 0.0], positions: [0.0, 0.5, 0.5] }, + { tag: "SnapOnRelease (0..2)", snapMode: Dial.SnapOnRelease, from: 0, to: 2, values: [0.0, 0.0, 1.0], positions: [0.0, 0.5, 0.5] }, + { tag: "SnapOnRelease (1..3)", snapMode: Dial.SnapOnRelease, from: 1, to: 3, values: [1.0, 1.0, 2.0], positions: [0.0, 0.5, 0.5] }, + { tag: "SnapOnRelease (-1..1)", snapMode: Dial.SnapOnRelease, from: -1, to: 1, values: [0.0, 0.0, 0.0], positions: [immediate ? 0.0 : 0.5, 0.5, 0.5] }, + { tag: "SnapOnRelease (1..-1)", snapMode: Dial.SnapOnRelease, from: 1, to: -1, values: [1.0, 1.0, 0.0], positions: [0.0, 0.5, 0.5] } ] } -- cgit v1.2.3 From c18c7bd7f9596e5ad3d13876a91203e1ceba2544 Mon Sep 17 00:00:00 2001 From: Mitch Curtis Date: Mon, 9 Sep 2019 15:59:49 +0200 Subject: DialogButtonBox: fix standard buttons not being translated When calling QQmlEngine::retranslate() after component completion, buttons in a DialogButtonBox were not being retranslated. For now the only way to be notified of language change events is by installing an event filter on the application, but in the future we can use the solution to QTBUG-78141 instead. Change-Id: Ibc435c3829945489adcbaa8a813013fe735a9c38 Fixes: QTBUG-75085 Reviewed-by: Andy Shaw --- tests/auto/translation/data/dialogButtonBox.qml | 61 +++++++++++++++ tests/auto/translation/qtbase_fr.ts | 22 ++++++ tests/auto/translation/translation.pro | 19 +++++ tests/auto/translation/tst_translation.cpp | 100 ++++++++++++++++++++++++ 4 files changed, 202 insertions(+) create mode 100644 tests/auto/translation/data/dialogButtonBox.qml create mode 100644 tests/auto/translation/qtbase_fr.ts create mode 100644 tests/auto/translation/translation.pro create mode 100644 tests/auto/translation/tst_translation.cpp (limited to 'tests') diff --git a/tests/auto/translation/data/dialogButtonBox.qml b/tests/auto/translation/data/dialogButtonBox.qml new file mode 100644 index 00000000..03a3ae0e --- /dev/null +++ b/tests/auto/translation/data/dialogButtonBox.qml @@ -0,0 +1,61 @@ +/**************************************************************************** +** +** Copyright (C) 2019 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.13 +import QtQuick.Controls 2.13 + +Item { + property Dialog dialog: Dialog { + width: 300 + height: 300 + visible: true + standardButtons: DialogButtonBox.Save | DialogButtonBox.Discard + } +} diff --git a/tests/auto/translation/qtbase_fr.ts b/tests/auto/translation/qtbase_fr.ts new file mode 100644 index 00000000..a2a05a07 --- /dev/null +++ b/tests/auto/translation/qtbase_fr.ts @@ -0,0 +1,22 @@ + + + + + QPlatformTheme + + Save + Enregistrer + + + Discard + Ne pas tenir compte + + + + QGnomeTheme + + &Save + &Enregistrer + + + diff --git a/tests/auto/translation/translation.pro b/tests/auto/translation/translation.pro new file mode 100644 index 00000000..d2d9d6ee --- /dev/null +++ b/tests/auto/translation/translation.pro @@ -0,0 +1,19 @@ +CONFIG += testcase +TARGET = tst_translation +SOURCES += tst_translation.cpp + +macos:CONFIG -= app_bundle + +QT += testlib gui-private quicktemplates2-private + +include (../shared/util.pri) + +TESTDATA = data/* + +OTHER_FILES += \ + data/*.qml + +# We only want to run lrelease, which is why we use EXTRA_TRANSLATIONS. +EXTRA_TRANSLATIONS = qtbase_fr.ts +# Embed the translations in a qrc file. +CONFIG += lrelease embed_translations diff --git a/tests/auto/translation/tst_translation.cpp b/tests/auto/translation/tst_translation.cpp new file mode 100644 index 00000000..9cbca915 --- /dev/null +++ b/tests/auto/translation/tst_translation.cpp @@ -0,0 +1,100 @@ +/**************************************************************************** +** +** Copyright (C) 2019 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:LGPL3$ +** 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 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later 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 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include "../shared/visualtestutil.h" + +#include +#include +#include +#include +#include +#include +#include + +using namespace QQuickVisualTestUtil; + +class tst_translation : public QQmlDataTest +{ + Q_OBJECT + +private slots: + void dialogButtonBox(); +}; + +void tst_translation::dialogButtonBox() +{ + QQuickView view(testFileUrl("dialogButtonBox.qml")); + if (view.status() != QQuickView::Ready) + QFAIL("Failed to load QML file"); + view.show(); + QVERIFY(QTest::qWaitForWindowActive(&view)); + + QQuickDialog *dialog = view.rootObject()->property("dialog").value(); + QVERIFY(dialog); + + QQuickDialogButtonBox *dialogButtonBox = qobject_cast(dialog->footer()); + QVERIFY(dialogButtonBox); + + QQuickAbstractButton *saveButton = dialogButtonBox->standardButton(QPlatformDialogHelper::Save); + QVERIFY(saveButton); + QString defaultSaveText = QGuiApplicationPrivate::platformTheme()->standardButtonText(QPlatformDialogHelper::Save); + defaultSaveText = QPlatformTheme::removeMnemonics(defaultSaveText); + QCOMPARE(saveButton->text(), defaultSaveText); + + QQuickAbstractButton *discardButton = dialogButtonBox->standardButton(QPlatformDialogHelper::Discard); + QVERIFY(discardButton); + QString defaultDiscardText = QGuiApplicationPrivate::platformTheme()->standardButtonText(QPlatformDialogHelper::Discard); + defaultDiscardText = QPlatformTheme::removeMnemonics(defaultDiscardText); + QCOMPARE(discardButton->text(), defaultDiscardText); + + QTranslator translator; + QVERIFY(translator.load(":/i18n/qtbase_fr.qm")); + QVERIFY(qApp->installTranslator(&translator)); + view.engine()->retranslate(); + + QString translatedSaveText = QGuiApplicationPrivate::platformTheme()->standardButtonText(QPlatformDialogHelper::Save); + translatedSaveText = QPlatformTheme::removeMnemonics(translatedSaveText); + QCOMPARE(saveButton->text(), translatedSaveText); + + QString translatedDiscardText = QGuiApplicationPrivate::platformTheme()->standardButtonText(QPlatformDialogHelper::Discard); + translatedDiscardText = QPlatformTheme::removeMnemonics(translatedDiscardText); + QCOMPARE(discardButton->text(), translatedDiscardText); +} + +QTEST_MAIN(tst_translation) + +#include "tst_translation.moc" -- cgit v1.2.3 From 27c18e488cd826365b1def7fb449fbd381c42bac Mon Sep 17 00:00:00 2001 From: Mitch Curtis Date: Fri, 13 Sep 2019 10:17:40 +0200 Subject: Blacklist tst_focus::policy on OpenSUSE 15.0 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Task-number: QTBUG-78261 Change-Id: I5373ffbb21f70f4fc9f18a7574165f383f55d899 Reviewed-by: Tony Sarajärvi --- tests/auto/focus/BLACKLIST | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 tests/auto/focus/BLACKLIST (limited to 'tests') diff --git a/tests/auto/focus/BLACKLIST b/tests/auto/focus/BLACKLIST new file mode 100644 index 00000000..730d3844 --- /dev/null +++ b/tests/auto/focus/BLACKLIST @@ -0,0 +1,3 @@ +# QTBUG-78261 +[policy] +opensuse-leap -- cgit v1.2.3 From 0cab878ae937451c8b53262cde7a05e7feaec0a6 Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Wed, 18 Sep 2019 17:46:31 +0200 Subject: Fix calendar tests The actual names of the components are MonthGrid and WeekNumberColumn, not AbtractMonthGrid and AbstractWeekNumberColumn. We should at least accept the real names. Fixes: QTBUG-78470 Change-Id: I01bf7174fd0c790b3b24d867bc823651fbdbe8c7 Reviewed-by: Liang Qi --- tests/auto/calendar/data/tst_monthgrid.qml | 9 +++++---- tests/auto/calendar/data/tst_weeknumbercolumn.qml | 8 ++++---- 2 files changed, 9 insertions(+), 8 deletions(-) (limited to 'tests') diff --git a/tests/auto/calendar/data/tst_monthgrid.qml b/tests/auto/calendar/data/tst_monthgrid.qml index 25c8378b..6d125712 100644 --- a/tests/auto/calendar/data/tst_monthgrid.qml +++ b/tests/auto/calendar/data/tst_monthgrid.qml @@ -148,28 +148,29 @@ TestCase { control.month = 0 compare(control.month, 0) - ignoreWarning(Qt.resolvedUrl("tst_monthgrid.qml") + ":65:9: QML AbstractMonthGrid: month -1 is out of range [0...11]") + + ignoreWarning(/tst_monthgrid.qml:65:9: QML (Abstract)?MonthGrid: month -1 is out of range \[0...11\]$/) control.month = -1 compare(control.month, 0) control.month = 11 compare(control.month, 11) - ignoreWarning(Qt.resolvedUrl("tst_monthgrid.qml") + ":65:9: QML AbstractMonthGrid: month 12 is out of range [0...11]") + ignoreWarning(/tst_monthgrid.qml:65:9: QML (Abstract)?MonthGrid: month 12 is out of range \[0...11\]$/) control.month = 12 compare(control.month, 11) control.year = -271820 compare(control.year, -271820) - ignoreWarning(Qt.resolvedUrl("tst_monthgrid.qml") + ":65:9: QML AbstractMonthGrid: year -271821 is out of range [-271820...275759]") + ignoreWarning(/tst_monthgrid.qml:65:9: QML (Abstract)?MonthGrid: year -271821 is out of range \[-271820...275759\]$/) control.year = -271821 compare(control.year, -271820) control.year = 275759 compare(control.year, 275759) - ignoreWarning(Qt.resolvedUrl("tst_monthgrid.qml") + ":65:9: QML AbstractMonthGrid: year 275760 is out of range [-271820...275759]") + ignoreWarning(/tst_monthgrid.qml:65:9: QML (Abstract)?MonthGrid: year 275760 is out of range \[-271820...275759\]$/) control.year = 275760 compare(control.year, 275759) diff --git a/tests/auto/calendar/data/tst_weeknumbercolumn.qml b/tests/auto/calendar/data/tst_weeknumbercolumn.qml index f94fed43..d1b50339 100644 --- a/tests/auto/calendar/data/tst_weeknumbercolumn.qml +++ b/tests/auto/calendar/data/tst_weeknumbercolumn.qml @@ -93,28 +93,28 @@ TestCase { control.month = 0 compare(control.month, 0) - ignoreWarning(Qt.resolvedUrl("tst_weeknumbercolumn.qml") + ":65:9: QML AbstractWeekNumberColumn: month -1 is out of range [0...11]") + ignoreWarning(/tst_weeknumbercolumn.qml:65:9: QML (Abstract)?WeekNumberColumn: month -1 is out of range \[0...11\]$/) control.month = -1 compare(control.month, 0) control.month = 11 compare(control.month, 11) - ignoreWarning(Qt.resolvedUrl("tst_weeknumbercolumn.qml") + ":65:9: QML AbstractWeekNumberColumn: month 12 is out of range [0...11]") + ignoreWarning(/tst_weeknumbercolumn.qml:65:9: QML (Abstract)?WeekNumberColumn: month 12 is out of range \[0...11\]$/) control.month = 12 compare(control.month, 11) control.year = -271820 compare(control.year, -271820) - ignoreWarning(Qt.resolvedUrl("tst_weeknumbercolumn.qml") + ":65:9: QML AbstractWeekNumberColumn: year -271821 is out of range [-271820...275759]") + ignoreWarning(/tst_weeknumbercolumn.qml:65:9: QML (Abstract)?WeekNumberColumn: year -271821 is out of range \[-271820...275759\]$/) control.year = -271821 compare(control.year, -271820) control.year = 275759 compare(control.year, 275759) - ignoreWarning(Qt.resolvedUrl("tst_weeknumbercolumn.qml") + ":65:9: QML AbstractWeekNumberColumn: year 275760 is out of range [-271820...275759]") + ignoreWarning(/tst_weeknumbercolumn.qml:65:9: QML (Abstract)?WeekNumberColumn: year 275760 is out of range \[-271820...275759\]$/) control.year = 275760 compare(control.year, 275759) -- cgit v1.2.3 From a89c3bc67ea6c76bfc89d64f235ebf5cb4b0fca4 Mon Sep 17 00:00:00 2001 From: Konstantin Ritt Date: Wed, 11 Sep 2019 16:39:47 +0000 Subject: Revert "QQuickTextArea: prevent changing size of background recursively" This reverts commit da06da57002b64cf4bcde0ca708b3275a5f919ae. Reason for revert: the change removes symptoms leaving a cause unfixed Change-Id: I0a91409230c521da73ed53e2a00a4ccd8dca7335 Reviewed-by: Mitch Curtis --- .../auto/qquickmaterialstyle/data/tst_material.qml | 35 ---------------------- 1 file changed, 35 deletions(-) (limited to 'tests') diff --git a/tests/auto/qquickmaterialstyle/data/tst_material.qml b/tests/auto/qquickmaterialstyle/data/tst_material.qml index 45bc0dab..9f2456b8 100644 --- a/tests/auto/qquickmaterialstyle/data/tst_material.qml +++ b/tests/auto/qquickmaterialstyle/data/tst_material.qml @@ -715,39 +715,4 @@ TestCase { control.destroy() } - - Component { - id: testResizeBackground - Item { - width: 200 - height: 200 - property alias textArea: textArea - ScrollView { - anchors.fill: parent - ScrollBar.horizontal.policy: ScrollBar.AlwaysOff - TextArea { - id: textArea - wrapMode : TextEdit.WordWrap - readOnly: false - selectByMouse: true - focus: true - text: "test message" - } - } - } - } - - function test_resize_background() { - var control = testCase.createTemporaryObject(testResizeBackground, testCase) - compare(control.textArea.background.height, 1) - compare(control.textArea.background.width, control.width) - control.width = 400 - control.height = 400 - compare(control.textArea.background.height, 1) - compare(control.textArea.background.width, control.width) - control.width = 200 - control.height = 200 - compare(control.textArea.background.height, 1) - compare(control.textArea.background.width, control.width) - } } -- cgit v1.2.3 From 6815f353e5a73c0dcf39fbfc91c6a2c1b0784324 Mon Sep 17 00:00:00 2001 From: Konstantin Ritt Date: Wed, 11 Sep 2019 21:54:53 +0300 Subject: TextArea: prevent changing size of background recursively When the x/y position of background depends on the height/width of background and these values are not constant, the if statement in the method resizeBackground() will always pass. And since `resizingBackground` guard wasn't checked, any geometry change will always call resizeBackground() and then call themself recursively (via the change listener), that means the height/width of background will always be reset, no matter what value you set. Another part of the issue was in determining the extra bits too late: in case the background gets parented by the flickable, the new child caused the flickable to re-calculate its metrics and thus resize the background *prior* to remembering if it has w/h set. As a side effect, this fix also brings the possibility to reset previously set w/h to get the default background sizing behavior. Inspired by da06da57002b64cf4bcde0ca708b3275a5f919ae [ChangeLog][QtQuick][QQuickTextArea] prevent changing size of background recursively in construction Fixes: QTBUG-76369 Change-Id: Ide51ec1ebab63605ae3bfcc10a76a28be960ef36 Reviewed-by: Mitch Curtis --- tests/auto/controls/data/tst_textarea.qml | 68 +++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) (limited to 'tests') diff --git a/tests/auto/controls/data/tst_textarea.qml b/tests/auto/controls/data/tst_textarea.qml index ee40c9b7..1e455ffc 100644 --- a/tests/auto/controls/data/tst_textarea.qml +++ b/tests/auto/controls/data/tst_textarea.qml @@ -688,4 +688,72 @@ TestCase { compare(control.background.width, 100) compare(control.background.height, 100) } + + // QTBUG-76369 + Component { + id: testResizeBackground + Item { + width: 200 + height: 200 + property alias textArea: textArea + ScrollView { + anchors.fill: parent + ScrollBar.horizontal.policy: ScrollBar.AlwaysOff + TextArea { + id: textArea + // workaround test failing due to default insets on Imagine + topInset: undefined + leftInset: undefined + rightInset: undefined + bottomInset: undefined + wrapMode : TextEdit.WordWrap + readOnly: false + selectByMouse: true + focus: true + text: "test message" + + background: Rectangle { + y: parent.height - height - textArea.bottomPadding / 2 + implicitWidth: 120 + height: textArea.activeFocus ? 2 : 1 + } + } + } + } + } + + function test_resize_background() { + var control = createTemporaryObject(testResizeBackground, testCase) + + compare(control.textArea.background.width, control.width) + compare(control.textArea.background.height, 1) + control.width = 400 + control.height = 400 + compare(control.textArea.background.width, control.width) + compare(control.textArea.background.height, 1) + control.width = 200 + control.height = 200 + compare(control.textArea.background.width, control.width) + compare(control.textArea.background.height, 1) + + // hasBackgroundWidth=true + control.textArea.background.width = 1 + compare(control.textArea.background.width, 1) + compare(control.textArea.background.height, 1) + control.width = 400 + control.height = 400 + compare(control.textArea.background.width, 1) + compare(control.textArea.background.height, 1) + // hasBackgroundHeight=false + control.textArea.background.height = undefined + compare(control.textArea.background.width, 1) + compare(control.textArea.background.height, 0) + control.textArea.background.y = 0 + compare(control.textArea.background.width, 1) + compare(control.textArea.background.height, control.height) + control.width = 200 + control.height = 200 + compare(control.textArea.background.width, 1) + compare(control.textArea.background.height, control.height) + } } -- cgit v1.2.3 From d39a6d80f63414a4e933ac2f859805635850942a Mon Sep 17 00:00:00 2001 From: Mitch Curtis Date: Tue, 24 Sep 2019 10:09:12 +0200 Subject: Tumbler: fix displacement calculation when wrap is false Use the position of the item and the currentItem in the calculation in order to get reliable results. This fixes the displacement being off by a small margin, which increased as the delegate height became smaller. Fixes: QTBUG-66799 Change-Id: Ieca5033fb4c0ed62f5965a21fcab7aa558bd40e6 Reviewed-by: Andy Shaw Reviewed-by: Mitch Curtis --- tests/auto/controls/data/tst_tumbler.qml | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) (limited to 'tests') diff --git a/tests/auto/controls/data/tst_tumbler.qml b/tests/auto/controls/data/tst_tumbler.qml index c9cc10d7..5b3ef6e3 100644 --- a/tests/auto/controls/data/tst_tumbler.qml +++ b/tests/auto/controls/data/tst_tumbler.qml @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2017 The Qt Company Ltd. +** Copyright (C) 2019 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the test suite of the Qt Toolkit. @@ -54,8 +54,8 @@ import QtQuick.Controls 2.12 TestCase { id: testCase - width: 200 - height: 200 + width: 300 + height: 300 visible: true when: windowShown name: "Tumbler" @@ -513,6 +513,7 @@ TestCase { Text { text: parent.displacement.toFixed(2) anchors.right: parent.right + anchors.verticalCenter: parent.verticalCenter } property real displacement: Tumbler.displacement @@ -1236,4 +1237,24 @@ TestCase { // 5 - 2 = 3 compare(tumbler.currentIndex, 3); } + + function test_displacementAfterResizing() { + createTumbler({ + width: 200, + wrap: false, + delegate: displacementDelegate, + model: 30, + visibleItemCount: 7, + currentIndex: 15 + }) + + var delegate = findChild(tumblerView, "delegate15") + verify(delegate) + + tryCompare(delegate, "displacement", 0) + + // Resizing the Tumbler shouldn't affect the displacement. + tumbler.height *= 1.4 + tryCompare(delegate, "displacement", 0) + } } -- cgit v1.2.3 From 100550dd22dc8eaa47405cdb3e7e461edb01a7a3 Mon Sep 17 00:00:00 2001 From: Konstantin Ritt Date: Mon, 26 Aug 2019 17:56:43 +0300 Subject: QQuickToolTip: fix setTimeout() behavior when tool tip is visible by applying the passed timeout value prior to re-starting the timer Change-Id: I27953dbb4781b5cb0c2039d56faa56f3c000206f Reviewed-by: Mitch Curtis --- tests/auto/controls/data/tst_tooltip.qml | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'tests') diff --git a/tests/auto/controls/data/tst_tooltip.qml b/tests/auto/controls/data/tst_tooltip.qml index 18911895..70579c70 100644 --- a/tests/auto/controls/data/tst_tooltip.qml +++ b/tests/auto/controls/data/tst_tooltip.qml @@ -205,6 +205,15 @@ TestCase { else control.visible = true compare(control.visible, true) + // wait a bit to make sure that it's still visible + wait(50) + compare(control.visible, true) + // re-arm for another 200 ms + control.timeout = 200 + compare(control.visible, true) + // ensure that it's still visible after 150 ms (where old timeout < 150 < new timeout) + wait(150) + compare(control.visible, true) tryCompare(control, "visible", false) } -- cgit v1.2.3 From 83fbf44b980c4a072ede122f2f16921bfff8c08d Mon Sep 17 00:00:00 2001 From: Mitch Curtis Date: Mon, 23 Sep 2019 13:42:03 +0200 Subject: Fix a crash on exit when using ToolTip in a specific item hierarchy QQuickPopup connects its parent item's (MouseArea, in this case) windowChanged() signal to QQuickPopupPrivate::setWindow(). It does this so that: 1) QQuickOverlay can keep track of all of the popups that it manages. 2) Fonts, palettes and locales can be resolved. 3) If the QQuickPopup component has completed loading and the popup is visible with a valid window, start the enter transition. The problem arises only when using a very specific item hierarchy: Window { width: 640 height: 480 visible: true Item { anchors.fill: parent Item { anchors.fill: parent ColorOverlay { source: parent anchors.fill: parent } MouseArea { anchors.fill: parent hoverEnabled: true ToolTip.visible: containsMouse ToolTip.text: "ToolTip text" } } } } When the window is closed and hence begins to be destroyed, the following events occur: - QQuickWindow's destructor is called. - The window's root item (QQuickRootItem) begins destruction. - QQuickOverlay is destroyed. - QQuickWindow's destructor is done, so the QWindow and then QObject destructors are called. - The QQuickItem destructor for the outer Item is called. - The child items of the outer Item have setParentItem(nullptr) called on them, one of which being the inner Item. - The inner Item's setParentItem() function calls derefWindow(), which in turn calls derefWindow() on its children. One of those children is MouseArea. - Since the MouseArea's window is deref'd, it emits the windowChanged() signal. MouseArea is the parentItem of the popup, so its windowChanged() signal causes QQuickPopupPrivate::setWindow() to be called. - setWindow() tries to remove the popup from the old overlay, which has already been destroyed. One approach I tried involved using QQuickOverlay::itemChange() to remove all of the popups (via setWindow(nullptr), to ensure that their window pointer is nullified), since that was called much earlier than the windowChanged() signal is emitted. However, this still resulted in a heap-use-after-free in the same place when running the newly added setOverlayParentToNull() test. I also tried removing the popups in QQuickOverlay's destructor, but this resulted in another heap-use-after-free (when accessing a popup in the destructor) in tst_QQuickPopup::Universal::visible(). The remaining options were: store the window in a QPointer or return early in overlay() if the wasDeleted member of the window was true. Using QPointer seems like it would catch more issues than a single check in overlay(), so I went with that. Fixes: QTBUG-73243 Change-Id: Ieb5ce26dd76d45771d28297031ec43e27d958b5b Reviewed-by: Mitch Curtis --- .../auto/qquickpopup/data/toolTipCrashOnClose.qml | 94 ++++++++++++++++++++++ tests/auto/qquickpopup/tst_qquickpopup.cpp | 42 ++++++++++ 2 files changed, 136 insertions(+) create mode 100644 tests/auto/qquickpopup/data/toolTipCrashOnClose.qml (limited to 'tests') diff --git a/tests/auto/qquickpopup/data/toolTipCrashOnClose.qml b/tests/auto/qquickpopup/data/toolTipCrashOnClose.qml new file mode 100644 index 00000000..8de14f4c --- /dev/null +++ b/tests/auto/qquickpopup/data/toolTipCrashOnClose.qml @@ -0,0 +1,94 @@ +/**************************************************************************** +** +** Copyright (C) 2019 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.13 +import QtQuick.Window 2.13 +import QtQuick.Controls 2.13 +import QtGraphicalEffects 1.13 + +Window { + width: 640 + height: 480 + + readonly property bool toolTipOpened: mouseArea.ToolTip.toolTip.opened + + Component.onCompleted: contentItem.objectName = "windowContentItem" + + // For the setOverlayParentToNull test. + function nullifyOverlayParent() { + Overlay.overlay.parent = null + } + + Item { + objectName: "outerItem" + anchors.fill: parent + + Item { + objectName: "innerItem" + anchors.fill: parent + + ColorOverlay { + objectName: "colorOverlay" + source: parent + anchors.fill: parent + } + + MouseArea { + id: mouseArea + objectName: "mouseArea" + anchors.fill: parent + hoverEnabled: true + + ToolTip.visible: containsMouse + ToolTip.text: "ToolTip text" + } + } + } +} diff --git a/tests/auto/qquickpopup/tst_qquickpopup.cpp b/tests/auto/qquickpopup/tst_qquickpopup.cpp index 636b2b21..4d238663 100644 --- a/tests/auto/qquickpopup/tst_qquickpopup.cpp +++ b/tests/auto/qquickpopup/tst_qquickpopup.cpp @@ -89,6 +89,8 @@ private slots: void disabledPalette(); void disabledParentPalette(); void countChanged(); + void toolTipCrashOnClose(); + void setOverlayParentToNull(); }; void tst_QQuickPopup::initTestCase() @@ -1187,6 +1189,46 @@ void tst_QQuickPopup::countChanged() QVERIFY(window->setProperty("isModel1", false)); QTRY_COMPARE(window->property("count").toInt(), 2); } + +// QTBUG-73243 +void tst_QQuickPopup::toolTipCrashOnClose() +{ + QQuickApplicationHelper helper(this, "toolTipCrashOnClose.qml"); + + QQuickWindow *window = helper.window; + window->show(); + // TODO: Using ignoreMessage() fails in CI with macOS for release builds, + // so for now we let the warning through. +// QTest::ignoreMessage(QtWarningMsg, "ShaderEffectSource: 'recursive' must be set to true when rendering recursively."); + QVERIFY(QTest::qWaitForWindowActive(window)); + + QTest::mouseMove(window, QPoint(window->width() / 2, window->height() / 2)); + QTRY_VERIFY(window->property("toolTipOpened").toBool()); + + QVERIFY(window->close()); + // Shouldn't crash. +} + +void tst_QQuickPopup::setOverlayParentToNull() +{ + QQuickApplicationHelper helper(this, "toolTipCrashOnClose.qml"); + + QQuickWindow *window = helper.window; + window->show(); + // TODO: Using ignoreMessage() fails in CI with macOS for release builds, + // so for now we let the warning through. +// QTest::ignoreMessage(QtWarningMsg, "ShaderEffectSource: 'recursive' must be set to true when rendering recursively."); + QVERIFY(QTest::qWaitForWindowActive(window)); + + QVERIFY(QMetaObject::invokeMethod(window, "nullifyOverlayParent")); + + QTest::mouseMove(window, QPoint(window->width() / 2, window->height() / 2)); + QTRY_VERIFY(window->property("toolTipOpened").toBool()); + + QVERIFY(window->close()); + // While nullifying the overlay parent doesn't make much sense, it shouldn't crash. +} + QTEST_QUICKCONTROLS_MAIN(tst_QQuickPopup) #include "tst_qquickpopup.moc" -- cgit v1.2.3