aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorQt Forward Merge Bot <qt_forward_merge_bot@qt-project.org>2020-03-26 01:00:11 +0100
committerFabian Kosmale <fabian.kosmale@qt.io>2020-04-09 10:08:41 +0200
commit2812184e1bb87cd94d2989162bc6ea954bb585c4 (patch)
tree25460548730e2ddc1f6f328d54e97d3fbfb49d21 /tests
parentcd4a99a7ba92968bf88da9af2624bb738d71e726 (diff)
parentbf205b45a29ba80d94df3b6bac5fec4c7cd79bf9 (diff)
Merge remote-tracking branch 'origin/5.15' into dev
Conflicts: src/qml/jsruntime/qv4executablecompilationunit.cpp src/qml/jsruntime/qv4executablecompilationunit_p.h src/qml/qml/qqmlobjectcreator.cpp src/qml/qml/qqmlpropertycachecreator_p.h src/qml/qml/qqmltypecompiler.cpp src/qml/qml/qqmltypedata.cpp tests/auto/qml/qmlformat/tst_qmlformat.cpp tools/qmllint/scopetree.cpp src/qml/qml/qqmlapplicationengine_p.h Adjusted tools/qmllint/findunqualified.cpp to use newer API Change-Id: Ibfb4678ca39d626d47527265e3c96e43313873d4
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/qml/qml.pro3
-rw-r--r--tests/auto/qml/qmlformat/data/FrontInline.formatted.qml3
-rw-r--r--tests/auto/qml/qmlformat/data/FrontInline.qml2
-rw-r--r--tests/auto/qml/qmlformat/data/IfBlocks.formatted.qml63
-rw-r--r--tests/auto/qml/qmlformat/data/IfBlocks.qml66
-rw-r--r--tests/auto/qml/qmlformat/tst_qmlformat.cpp59
-rw-r--r--tests/auto/qml/qmltyperegistrar/foreign/foreign.cpp43
-rw-r--r--tests/auto/qml/qmltyperegistrar/foreign/foreign.h52
-rw-r--r--tests/auto/qml/qmltyperegistrar/foreign/foreign.pro10
-rw-r--r--tests/auto/qml/qmltyperegistrar/hppheader.hpp64
-rw-r--r--tests/auto/qml/qmltyperegistrar/noextheader64
-rw-r--r--tests/auto/qml/qmltyperegistrar/qmltyperegistrar.pro4
-rw-r--r--tests/auto/qml/qmltyperegistrar/tst_qmltyperegistrar.cpp61
-rw-r--r--tests/auto/qml/qmltyperegistrar/tst_qmltyperegistrar.h56
-rw-r--r--tests/auto/qml/qmltyperegistrar/tst_qmltyperegistrar.pro20
-rw-r--r--tests/auto/qml/qqmllanguage/data/arrayToContainer.qml2
-rw-r--r--tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp25
-rw-r--r--tests/auto/quick/qquickanimations/data/signalorder.qml27
-rw-r--r--tests/auto/quick/qquickanimations/qquickanimations.pro1
-rw-r--r--tests/auto/quick/qquickanimations/tst_qquickanimations.cpp52
-rw-r--r--tests/auto/quick/qquickcanvasitem/BLACKLIST10
-rw-r--r--tests/auto/quick/qquickcanvasitem/data/CanvasTestCase.qml5
-rw-r--r--tests/auto/quick/qquickcanvasitem/data/tst_arcto.qml8
-rw-r--r--tests/auto/quick/qquickcanvasitem/data/tst_canvas.qml25
-rw-r--r--tests/auto/quick/qquickcanvasitem/qquickcanvasitem.pro2
-rw-r--r--tests/auto/quick/qquickcanvasitem/tst_qquickcanvasitem.cpp2
-rw-r--r--tests/auto/quick/qquicklayouts/data/tst_rowlayout.qml6
-rw-r--r--tests/auto/quick/qquickmousearea/data/settingHiddenInPressUngrabs.qml36
-rw-r--r--tests/auto/quick/qquickmousearea/tst_qquickmousearea.cpp38
-rw-r--r--tests/auto/quickwidgets/qquickwidget/data/resizeOverlay.qml15
-rw-r--r--tests/auto/quickwidgets/qquickwidget/tst_qquickwidget.cpp70
31 files changed, 856 insertions, 38 deletions
diff --git a/tests/auto/qml/qml.pro b/tests/auto/qml/qml.pro
index 418d3d4cb5..bc90d6df03 100644
--- a/tests/auto/qml/qml.pro
+++ b/tests/auto/qml/qml.pro
@@ -104,3 +104,6 @@ qtConfig(private_tests): \
qtNomakeTools( \
qmlplugindump \
)
+
+!cross_compile: \
+ SUBDIRS += qmltyperegistrar
diff --git a/tests/auto/qml/qmlformat/data/FrontInline.formatted.qml b/tests/auto/qml/qmlformat/data/FrontInline.formatted.qml
new file mode 100644
index 0000000000..620fbf4120
--- /dev/null
+++ b/tests/auto/qml/qmlformat/data/FrontInline.formatted.qml
@@ -0,0 +1,3 @@
+// This comment should be directly above Item after formatting
+Item {
+}
diff --git a/tests/auto/qml/qmlformat/data/FrontInline.qml b/tests/auto/qml/qmlformat/data/FrontInline.qml
new file mode 100644
index 0000000000..c63265481c
--- /dev/null
+++ b/tests/auto/qml/qmlformat/data/FrontInline.qml
@@ -0,0 +1,2 @@
+Item { // This comment should be directly above Item after formatting
+}
diff --git a/tests/auto/qml/qmlformat/data/IfBlocks.formatted.qml b/tests/auto/qml/qmlformat/data/IfBlocks.formatted.qml
new file mode 100644
index 0000000000..b8e77ec23a
--- /dev/null
+++ b/tests/auto/qml/qmlformat/data/IfBlocks.formatted.qml
@@ -0,0 +1,63 @@
+Item {
+
+ function test() {
+ //// The following if blocks should NOT HAVE braces
+ // Single branch, no braces
+ if (true)
+ console.log("foo");
+
+ // Single branch, no braces
+ if (true)
+ console.log("foo");
+
+ // Multiple branches, No braces
+ if (true)
+ console.log("foo");
+ else if (false)
+ console.log("bar");
+ else
+ console.log("baz");
+ // Multiple branches, all braces
+ if (true)
+ console.log("foo");
+ else if (false)
+ console.log("bar");
+ else
+ console.log("baz");
+
+ //// The following if blocks should HAVE braces
+ // Single branch, braces
+ if (true) {
+ console.log("foo");
+ console.log("bar");
+ }
+ // Multiple branches, some braces
+ if (true) {
+ console.log("foo");
+ console.log("foo2");
+ } else if (false) {
+ console.log("bar");
+ } else {
+ console.log("baz");
+ }
+ // Multiple branches, some braces
+ if (true) {
+ console.log("foo");
+ } else if (false) {
+ console.log("bar");
+ console.log("bar2");
+ } else {
+ console.log("baz");
+ }
+ // Multiple branches, some braces
+ if (true) {
+ console.log("foo");
+ } else if (false) {
+ console.log("bar");
+ } else {
+ console.log("baz");
+ console.log("baz2");
+ }
+ }
+
+}
diff --git a/tests/auto/qml/qmlformat/data/IfBlocks.qml b/tests/auto/qml/qmlformat/data/IfBlocks.qml
new file mode 100644
index 0000000000..505988b238
--- /dev/null
+++ b/tests/auto/qml/qmlformat/data/IfBlocks.qml
@@ -0,0 +1,66 @@
+Item {
+ function test() {
+ //// The following if blocks should NOT HAVE braces
+ // Single branch, no braces
+ if (true)
+ console.log("foo");
+
+ // Single branch, no braces
+ if (true) {
+ console.log("foo");
+ }
+
+
+ // Multiple branches, No braces
+ if (true)
+ console.log("foo");
+ else if (false)
+ console.log("bar");
+ else
+ console.log("baz");
+
+ // Multiple branches, all braces
+ if (true) {
+ console.log("foo");
+ } else if (false) {
+ console.log("bar");
+ } else {
+ console.log("baz");
+ }
+
+ //// The following if blocks should HAVE braces
+ // Single branch, braces
+ if (true) {
+ console.log("foo");
+ console.log("bar");
+ }
+
+ // Multiple branches, some braces
+ if (true) {
+ console.log("foo");
+ console.log("foo2");
+ } else if (false)
+ console.log("bar");
+ else
+ console.log("baz");
+
+ // Multiple branches, some braces
+ if (true)
+ console.log("foo");
+ else if (false) {
+ console.log("bar");
+ console.log("bar2");
+ } else
+ console.log("baz");
+
+ // Multiple branches, some braces
+ if (true)
+ console.log("foo");
+ else if (false)
+ console.log("bar");
+ else {
+ console.log("baz");
+ console.log("baz2");
+ }
+ }
+}
diff --git a/tests/auto/qml/qmlformat/tst_qmlformat.cpp b/tests/auto/qml/qmlformat/tst_qmlformat.cpp
index 21d5ae46a9..997a5cc753 100644
--- a/tests/auto/qml/qmlformat/tst_qmlformat.cpp
+++ b/tests/auto/qml/qmlformat/tst_qmlformat.cpp
@@ -27,8 +27,11 @@
****************************************************************************/
#include <QtTest/QtTest>
+#include <QDir>
+#include <QFile>
#include <QProcess>
#include <QString>
+#include <QTemporaryDir>
#include <util.h>
@@ -43,6 +46,9 @@ private Q_SLOTS:
void testFormatNoSort();
void testAnnotations();
void testAnnotationsNoSort();
+ void testLineEndings();
+ void testFrontInline();
+ void testIfBlocks();
void testReadOnlyProps();
void testStatesAndTransitions();
@@ -55,7 +61,7 @@ private Q_SLOTS:
private:
QString readTestFile(const QString &path);
- QString runQmlformat(const QString &fileToFormat, bool sortImports, bool shouldSucceed);
+ QString runQmlformat(const QString &fileToFormat, bool sortImports, bool shouldSucceed, const QString &newlineFormat = "native");
QString m_qmlformatPath;
QStringList m_excludedDirs;
@@ -113,6 +119,7 @@ void TestQmlformat::initTestCase()
m_invalidFiles << "tests/auto/qml/qqmlecmascript/data/numberParsing_error.1.qml";
m_invalidFiles << "tests/auto/qml/qqmlecmascript/data/numberParsing_error.2.qml";
m_invalidFiles << "tests/auto/qml/qqmlecmascript/data/incrDecrSemicolon_error1.qml";
+ m_invalidFiles << "tests/auto/qml/qqmlecmascript/data/incrDecrSemicolon_error1.qml";
m_invalidFiles << "tests/auto/qml/debugger/qqmlpreview/data/broken.qml";
m_invalidFiles << "tests/auto/qml/qqmllanguage/data/fuzzed.2.qml";
m_invalidFiles << "tests/auto/qml/qqmllanguage/data/fuzzed.3.qml";
@@ -197,6 +204,16 @@ void TestQmlformat::testAnnotationsNoSort()
QCOMPARE(runQmlformat(testFile("Annotations.qml"), false, true), readTestFile("Annotations.formatted.nosort.qml"));
}
+void TestQmlformat::testFrontInline()
+{
+ QCOMPARE(runQmlformat(testFile("FrontInline.qml"), false, true), readTestFile("FrontInline.formatted.qml"));
+}
+
+void TestQmlformat::testIfBlocks()
+{
+ QCOMPARE(runQmlformat(testFile("IfBlocks.qml"), false, true), readTestFile("IfBlocks.formatted.qml"));
+}
+
void TestQmlformat::testReadOnlyProps()
{
QCOMPARE(runQmlformat(testFile("readOnlyProps.qml"), false, true), readTestFile("readOnlyProps.formatted.qml"));
@@ -212,6 +229,23 @@ void TestQmlformat::testLargeBindings()
QCOMPARE(runQmlformat(testFile("largeBindings.qml"), false, true), readTestFile("largeBindings.formatted.qml"));
}
+void TestQmlformat::testLineEndings()
+{
+ // macos
+ const QString macosContents = runQmlformat(testFile("Example1.formatted.qml"), false, true, "macos");
+ QVERIFY(!macosContents.contains("\n"));
+ QVERIFY(macosContents.contains("\r"));
+
+ // windows
+ const QString windowsContents = runQmlformat(testFile("Example1.formatted.qml"), false, true, "windows");
+ QVERIFY(windowsContents.contains("\r\n"));
+
+ // unix
+ const QString unixContents = runQmlformat(testFile("Example1.formatted.qml"), false, true, "unix");
+ QVERIFY(unixContents.contains("\n"));
+ QVERIFY(!unixContents.contains("\r"));
+}
+
#if !defined(QTEST_CROSS_COMPILED) // sources not available when cross compiled
void TestQmlformat::testExample_data()
{
@@ -240,15 +274,22 @@ void TestQmlformat::testExample()
}
#endif
-QString TestQmlformat::runQmlformat(const QString &fileToFormat, bool sortImports, bool shouldSucceed)
+QString TestQmlformat::runQmlformat(const QString &fileToFormat, bool sortImports, bool shouldSucceed, const QString &newlineFormat)
{
+ // Copy test file to temporary location
+ QTemporaryDir tempDir;
+ const QString tempFile = tempDir.path() + QDir::separator() + "to_format.qml";
+ QFile::copy(fileToFormat, tempFile);
+
QStringList args;
- args << fileToFormat;
+ args << "-i";
+ args << tempFile;
if (!sortImports)
args << "-n";
- QString output;
+ args << "-l" << newlineFormat;
+
auto verify = [&]() {
QProcess process;
process.start(m_qmlformatPath, args);
@@ -256,13 +297,15 @@ QString TestQmlformat::runQmlformat(const QString &fileToFormat, bool sortImport
QCOMPARE(process.exitStatus(), QProcess::NormalExit);
if (shouldSucceed)
QCOMPARE(process.exitCode(), 0);
- else
- QVERIFY(process.exitCode() != 0);
- output = process.readAllStandardOutput();
};
verify();
- return output;
+ QFile temp(tempFile);
+
+ temp.open(QIODevice::ReadOnly);
+ QString formatted = QString::fromUtf8(temp.readAll());
+
+ return formatted;
}
QTEST_MAIN(TestQmlformat)
diff --git a/tests/auto/qml/qmltyperegistrar/foreign/foreign.cpp b/tests/auto/qml/qmltyperegistrar/foreign/foreign.cpp
new file mode 100644
index 0000000000..db080a5cad
--- /dev/null
+++ b/tests/auto/qml/qmltyperegistrar/foreign/foreign.cpp
@@ -0,0 +1,43 @@
+/****************************************************************************
+**
+** Copyright (C) 2020 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:GPL-EXCEPT$
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "foreign.h"
+
+int Foreign::things() const
+{
+ return m_things;
+}
+
+void Foreign::setThings(int things)
+{
+ if (m_things == things)
+ return;
+
+ m_things = things;
+ emit thingsChanged(m_things);
+}
diff --git a/tests/auto/qml/qmltyperegistrar/foreign/foreign.h b/tests/auto/qml/qmltyperegistrar/foreign/foreign.h
new file mode 100644
index 0000000000..d5e5a060b4
--- /dev/null
+++ b/tests/auto/qml/qmltyperegistrar/foreign/foreign.h
@@ -0,0 +1,52 @@
+/****************************************************************************
+**
+** Copyright (C) 2020 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:GPL-EXCEPT$
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef FOREIGN_H
+#define FOREIGN_H
+
+#include <QtCore/qobject.h>
+
+class Foreign : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(int things READ things WRITE setThings NOTIFY thingsChanged)
+
+public:
+ int things() const;
+
+public slots:
+ void setThings(int things);
+
+signals:
+ void thingsChanged(int things);
+
+private:
+ int m_things = 0;
+};
+
+#endif // FOREIGN_H
diff --git a/tests/auto/qml/qmltyperegistrar/foreign/foreign.pro b/tests/auto/qml/qmltyperegistrar/foreign/foreign.pro
new file mode 100644
index 0000000000..87521eac43
--- /dev/null
+++ b/tests/auto/qml/qmltyperegistrar/foreign/foreign.pro
@@ -0,0 +1,10 @@
+TEMPLATE = lib
+QT = core
+
+macos:CONFIG -= app_bundle
+CONFIG -= debug_and_release_target
+
+SOURCES = foreign.cpp
+HEADERS = foreign.h
+
+CONFIG += metatypes static
diff --git a/tests/auto/qml/qmltyperegistrar/hppheader.hpp b/tests/auto/qml/qmltyperegistrar/hppheader.hpp
new file mode 100644
index 0000000000..f5fc881b77
--- /dev/null
+++ b/tests/auto/qml/qmltyperegistrar/hppheader.hpp
@@ -0,0 +1,64 @@
+/****************************************************************************
+**
+** Copyright (C) 2020 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:GPL-EXCEPT$
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef HPPHEADER_HPP
+#define HPPHEADER_HPP
+
+#include <QtCore/qobject.h>
+#include <QtQml/qqml.h>
+
+class HppClass : public QObject
+{
+ Q_OBJECT
+ QML_ELEMENT
+ Q_PROPERTY(int eieiei READ eieiei WRITE setEieiei NOTIFY eieieiChanged)
+
+public:
+ int eieiei() const
+ {
+ return m_eieiei;
+ }
+
+public slots:
+ void setEieiei(int eieiei)
+ {
+ if (m_eieiei == eieiei)
+ return;
+
+ m_eieiei = eieiei;
+ emit eieieiChanged(m_eieiei);
+ }
+
+signals:
+ void eieieiChanged(int eieiei);
+
+private:
+ int m_eieiei;
+};
+
+#endif // HPPHEADER_HPP
diff --git a/tests/auto/qml/qmltyperegistrar/noextheader b/tests/auto/qml/qmltyperegistrar/noextheader
new file mode 100644
index 0000000000..3b6cb6d72c
--- /dev/null
+++ b/tests/auto/qml/qmltyperegistrar/noextheader
@@ -0,0 +1,64 @@
+/****************************************************************************
+**
+** Copyright (C) 2020 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:GPL-EXCEPT$
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef NOEXTHEADER
+#define NOEXTHEADER
+
+#include <QtCore/qobject.h>
+#include <QtQml/qqml.h>
+
+class Noext : public QObject
+{
+ Q_OBJECT
+ QML_ELEMENT
+ Q_PROPERTY(int gagaga READ gagaga WRITE setGagaga NOTIFY gagagaChanged)
+
+public:
+ int gagaga() const
+ {
+ return m_gagaga;
+ }
+
+public slots:
+ void setGagaga(int gagaga)
+ {
+ if (m_gagaga == gagaga)
+ return;
+
+ m_gagaga = gagaga;
+ emit gagagaChanged(m_gagaga);
+ }
+
+signals:
+ void gagagaChanged(int gagaga);
+
+private:
+ int m_gagaga;
+};
+
+#endif // NOEXTHEADER
diff --git a/tests/auto/qml/qmltyperegistrar/qmltyperegistrar.pro b/tests/auto/qml/qmltyperegistrar/qmltyperegistrar.pro
new file mode 100644
index 0000000000..738d099123
--- /dev/null
+++ b/tests/auto/qml/qmltyperegistrar/qmltyperegistrar.pro
@@ -0,0 +1,4 @@
+TEMPLATE = subdirs
+SUBDIRS = foreign tst_qmltyperegistrar.pro
+
+tst_qmltyperegistrar_pro.depends = foreign
diff --git a/tests/auto/qml/qmltyperegistrar/tst_qmltyperegistrar.cpp b/tests/auto/qml/qmltyperegistrar/tst_qmltyperegistrar.cpp
new file mode 100644
index 0000000000..8bdee2f937
--- /dev/null
+++ b/tests/auto/qml/qmltyperegistrar/tst_qmltyperegistrar.cpp
@@ -0,0 +1,61 @@
+/****************************************************************************
+**
+** Copyright (C) 2020 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:GPL-EXCEPT$
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "tst_qmltyperegistrar.h"
+#include <QtTest/qtest.h>
+#include <QtCore/qcoreapplication.h>
+#include <QtCore/qfile.h>
+
+void tst_qmltyperegistrar::initTestCase()
+{
+ QFile file(QCoreApplication::applicationDirPath() + "/tst_qmltyperegistrar.qmltypes");
+ QVERIFY(file.open(QIODevice::ReadOnly));
+ qmltypesData = file.readAll();
+ QVERIFY(file.atEnd());
+ QCOMPARE(file.error(), QFile::NoError);
+}
+
+void tst_qmltyperegistrar::qmltypesHasForeign()
+{
+ QVERIFY(qmltypesData.contains("things"));
+}
+
+void tst_qmltyperegistrar::qmltypesHasHppClassAndNoext()
+{
+ QVERIFY(qmltypesData.contains("HppClass"));
+ QVERIFY(qmltypesData.contains("Noext"));
+}
+
+void tst_qmltyperegistrar::qmltypesHasFileNames()
+{
+ QVERIFY(qmltypesData.contains("file: \"hppheader.hpp\""));
+ QVERIFY(qmltypesData.contains("file: \"noextheader\""));
+ QVERIFY(qmltypesData.contains("file: \"tst_qmltyperegistrar.h\""));
+}
+
+QTEST_MAIN(tst_qmltyperegistrar)
diff --git a/tests/auto/qml/qmltyperegistrar/tst_qmltyperegistrar.h b/tests/auto/qml/qmltyperegistrar/tst_qmltyperegistrar.h
new file mode 100644
index 0000000000..37d49efa40
--- /dev/null
+++ b/tests/auto/qml/qmltyperegistrar/tst_qmltyperegistrar.h
@@ -0,0 +1,56 @@
+/****************************************************************************
+**
+** Copyright (C) 2020 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:GPL-EXCEPT$
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef TST_QMLTYPEREGISTRAR_H
+#define TST_QMLTYPEREGISTRAR_H
+
+#include "foreign.h"
+
+#include <QtQml/qqml.h>
+
+class Local : public Foreign
+{
+ Q_OBJECT
+ QML_ELEMENT
+};
+
+class tst_qmltyperegistrar : public QObject
+{
+ Q_OBJECT
+
+private slots:
+ void initTestCase();
+ void qmltypesHasForeign();
+ void qmltypesHasHppClassAndNoext();
+ void qmltypesHasFileNames();
+
+private:
+ QByteArray qmltypesData;
+};
+
+#endif // TST_QMLTYPEREGISTRAR_H
diff --git a/tests/auto/qml/qmltyperegistrar/tst_qmltyperegistrar.pro b/tests/auto/qml/qmltyperegistrar/tst_qmltyperegistrar.pro
new file mode 100644
index 0000000000..fe21b122c2
--- /dev/null
+++ b/tests/auto/qml/qmltyperegistrar/tst_qmltyperegistrar.pro
@@ -0,0 +1,20 @@
+TEMPLATE = app
+
+QT = core qml testlib
+CONFIG += testcase qmltypes
+CONFIG -= debug_and_release_target
+macos:CONFIG -= app_bundle
+
+SOURCES += tst_qmltyperegistrar.cpp
+HEADERS += \
+ hppheader.hpp \
+ noextheader \
+ tst_qmltyperegistrar.h
+
+QMLTYPES_FILENAME = tst_qmltyperegistrar.qmltypes
+QML_FOREIGN_METATYPES += foreign/foreign_metatypes.json
+QML_IMPORT_NAME = QmlTypeRegistrarTest
+QML_IMPORT_VERSION = 1.0
+
+INCLUDEPATH += foreign
+LIBS += -Lforeign -lforeign
diff --git a/tests/auto/qml/qqmllanguage/data/arrayToContainer.qml b/tests/auto/qml/qqmllanguage/data/arrayToContainer.qml
index ee400eb41f..d8e278a7a1 100644
--- a/tests/auto/qml/qqmllanguage/data/arrayToContainer.qml
+++ b/tests/auto/qml/qqmllanguage/data/arrayToContainer.qml
@@ -3,5 +3,7 @@ import qt.test 1.0
TestItem {
property var vector
+ property var myset
positions: vector
+ barrays: myset
}
diff --git a/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp b/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp
index f2fa301565..8bee4ef260 100644
--- a/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp
+++ b/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp
@@ -2464,20 +2464,31 @@ void tst_qqmllanguage::scriptStringJs()
QVERIFY(!object->scriptProperty().booleanLiteral(&ok) && !ok);
}
+struct FreeUnitData
+{
+ static void cleanup(const QV4::CompiledData::Unit *readOnlyQmlUnit)
+ {
+ if (readOnlyQmlUnit && !(readOnlyQmlUnit->flags & QV4::CompiledData::Unit::StaticData))
+ free(const_cast<QV4::CompiledData::Unit *>(readOnlyQmlUnit));
+ }
+};
+
void tst_qqmllanguage::scriptStringWithoutSourceCode()
{
QUrl url = testFileUrl("scriptString7.qml");
+ QScopedPointer<const QV4::CompiledData::Unit, FreeUnitData> readOnlyQmlUnit;
{
QQmlEnginePrivate *eng = QQmlEnginePrivate::get(&engine);
QQmlRefPointer<QQmlTypeData> td = eng->typeLoader.getType(url);
Q_ASSERT(td);
- const QV4::CompiledData::Unit *readOnlyQmlUnit = td->compilationUnit()->unitData();
+ QQmlRefPointer<QV4::ExecutableCompilationUnit> compilationUnit = td->compilationUnit();
+ readOnlyQmlUnit.reset(compilationUnit->unitData());
Q_ASSERT(readOnlyQmlUnit);
QV4::CompiledData::Unit *qmlUnit = reinterpret_cast<QV4::CompiledData::Unit *>(malloc(readOnlyQmlUnit->unitSize));
- memcpy(qmlUnit, readOnlyQmlUnit, readOnlyQmlUnit->unitSize);
+ memcpy(qmlUnit, readOnlyQmlUnit.data(), readOnlyQmlUnit->unitSize);
+
qmlUnit->flags &= ~QV4::CompiledData::Unit::StaticData;
- QQmlRefPointer<QV4::ExecutableCompilationUnit> compilationUnit = td->compilationUnit();
compilationUnit->setUnitData(qmlUnit);
const QV4::CompiledData::Object *rootObject = compilationUnit->objectAt(/*root object*/0);
@@ -5773,25 +5784,31 @@ class TestItem : public QObject
{
Q_OBJECT
Q_PROPERTY( QVector<QPointF> positions MEMBER m_points )
+ Q_PROPERTY( QSet<QByteArray> barrays MEMBER m_barrays )
public:
TestItem() = default;
QVector< QPointF > m_points;
+ QSet<QByteArray> m_barrays;
};
Q_DECLARE_METATYPE(QVector<QPointF>);
+Q_DECLARE_METATYPE(QSet<QByteArray>);
void tst_qqmllanguage::arrayToContainer()
{
QQmlEngine engine;
qmlRegisterType<TestItem>("qt.test", 1, 0, "TestItem");
QVector<QPointF> points { QPointF (2.0, 3.0) };
+ QSet<QByteArray> barrays { QByteArray("hello"), QByteArray("world") };
engine.rootContext()->setContextProperty("test", QVariant::fromValue(points));
QQmlComponent component(&engine, testFileUrl("arrayToContainer.qml"));
VERIFY_ERRORS(0);
- QScopedPointer<TestItem> root(qobject_cast<TestItem *>(component.createWithInitialProperties( {{"vector", QVariant::fromValue(points)}} )));
+ QScopedPointer<TestItem> root(qobject_cast<TestItem *>(component.createWithInitialProperties( {{"vector", QVariant::fromValue(points)}, {"myset", QVariant::fromValue(barrays)} } )));
QVERIFY(root);
QCOMPARE(root->m_points.at(0), QPointF (2.0, 3.0) );
+ QVERIFY(root->m_barrays.contains("hello"));
+ QVERIFY(root->m_barrays.contains("world"));
}
class EnumTester : public QObject
diff --git a/tests/auto/quick/qquickanimations/data/signalorder.qml b/tests/auto/quick/qquickanimations/data/signalorder.qml
new file mode 100644
index 0000000000..35029b0c84
--- /dev/null
+++ b/tests/auto/quick/qquickanimations/data/signalorder.qml
@@ -0,0 +1,27 @@
+import QtQuick 2.12
+
+
+Item {
+ id: wrapper
+ width: 400; height: 400
+
+ Rectangle {
+ id: greenRect
+ width: 50; height: 50
+ color: "red"
+
+ ColorAnimation on color {
+ id: colorAnimation
+ objectName: "ColorAnimation"
+ to: "green"
+ duration: 10
+ running: false
+ }
+
+ ParallelAnimation {
+ id: parallelAnimation
+ objectName: "ParallelAnimation"
+ running: false
+ }
+ }
+}
diff --git a/tests/auto/quick/qquickanimations/qquickanimations.pro b/tests/auto/quick/qquickanimations/qquickanimations.pro
index 94f694181d..6998c023db 100644
--- a/tests/auto/quick/qquickanimations/qquickanimations.pro
+++ b/tests/auto/quick/qquickanimations/qquickanimations.pro
@@ -64,6 +64,7 @@ OTHER_FILES += \
data/scriptActionCrash.qml \
data/sequentialAnimationNullChildBug.qml \
data/signals.qml \
+ data/signalorder.qml \
data/transitionAssignmentBug.qml \
data/valuesource.qml \
data/valuesource2.qml
diff --git a/tests/auto/quick/qquickanimations/tst_qquickanimations.cpp b/tests/auto/quick/qquickanimations/tst_qquickanimations.cpp
index 55957fa71a..e62d49ed6b 100644
--- a/tests/auto/quick/qquickanimations/tst_qquickanimations.cpp
+++ b/tests/auto/quick/qquickanimations/tst_qquickanimations.cpp
@@ -89,6 +89,8 @@ private slots:
void easingProperties();
void rotation();
void startStopSignals();
+ void signalOrder_data();
+ void signalOrder();
void runningTrueBug();
void nonTransitionBug();
void registrationBug();
@@ -1323,6 +1325,56 @@ void tst_qquickanimations::startStopSignals()
QVERIFY(timer.elapsed() >= 200);
}
+void tst_qquickanimations::signalOrder_data()
+{
+ QTest::addColumn<QByteArray>("animationType");
+ QTest::addColumn<int>("duration");
+
+ QTest::addRow("ColorAnimation, duration = 10") << QByteArray("ColorAnimation") << 10;
+ QTest::addRow("ColorAnimation, duration = 0") << QByteArray("ColorAnimation") << 0;
+ QTest::addRow("ParallelAnimation, duration = 0") << QByteArray("ParallelAnimation") << 0;
+}
+
+void tst_qquickanimations::signalOrder()
+{
+ QFETCH(QByteArray, animationType);
+ QFETCH(int, duration);
+
+ QQmlEngine engine;
+ QQmlComponent c(&engine, testFileUrl("signalorder.qml"));
+ QScopedPointer<QObject> obj(c.create());
+ auto *root = qobject_cast<QQuickItem *>(obj.data());
+ QVERIFY(root);
+ QQuickAbstractAnimation *animation = root->findChild<QQuickAbstractAnimation*>(animationType);
+
+ const QVector<void (QQuickAbstractAnimation::*)()> signalsToConnect = {
+ &QQuickAbstractAnimation::started,
+ &QQuickAbstractAnimation::stopped,
+ &QQuickAbstractAnimation::finished
+ };
+ const QVector<const char*> expectedSignalOrder = {
+ "started",
+ "stopped",
+ "finished"
+ };
+
+ QVector<const char*> actualSignalOrder;
+
+ for (int i = 0; i < signalsToConnect.size(); ++i) {
+ const char *str = expectedSignalOrder.at(i);
+ connect(animation, signalsToConnect.at(i) , [str, &actualSignalOrder] () {
+ actualSignalOrder.append(str);
+ });
+ }
+ QSignalSpy finishedSpy(animation, SIGNAL(finished()));
+ if (QQuickColorAnimation *colorAnimation = qobject_cast<QQuickColorAnimation*>(animation))
+ colorAnimation->setDuration(duration);
+
+ animation->start();
+ QTRY_VERIFY(finishedSpy.count());
+ QCOMPARE(actualSignalOrder, expectedSignalOrder);
+}
+
void tst_qquickanimations::runningTrueBug()
{
//ensure we start correctly when "running: true" is explicitly set
diff --git a/tests/auto/quick/qquickcanvasitem/BLACKLIST b/tests/auto/quick/qquickcanvasitem/BLACKLIST
index 21580b6730..a4b25475a4 100644
--- a/tests/auto/quick/qquickcanvasitem/BLACKLIST
+++ b/tests/auto/quick/qquickcanvasitem/BLACKLIST
@@ -3,12 +3,18 @@ macos
[canvas::test_paint]
macos
[canvas::test_save]
+windows
macos
[canvas::test_implicitlySizedParent]
-macos ci
+*
+# QTBUG-41043
[canvas::test_toDataURL]
-macos
+*
[fillRect::test_fillRect]
macos
[imagedata::test_rounding]
macos ci
+[ContextFontValidation::test_pixelSize]
+opensuse-leap
+[ContextFontValidation::test_valid]
+opensuse-leap
diff --git a/tests/auto/quick/qquickcanvasitem/data/CanvasTestCase.qml b/tests/auto/quick/qquickcanvasitem/data/CanvasTestCase.qml
index b0fb7fcf8c..5e02ca10d0 100644
--- a/tests/auto/quick/qquickcanvasitem/data/CanvasTestCase.qml
+++ b/tests/auto/quick/qquickcanvasitem/data/CanvasTestCase.qml
@@ -7,6 +7,7 @@ TestCase {
when:windowShown
width:100
height:100
+ visible: true
property Component component:CanvasComponent{}
function cleanupTestCase() {
wait(100) //wait for a short while to make sure no leaked textures
@@ -19,8 +20,8 @@ TestCase {
// { tag:"image cooperative", properties:{width:100, height:100, renderTarget:Canvas.Image, renderStrategy:Canvas.Cooperative}},
{ tag:"image immediate", properties:{width:100, height:100, renderTarget:Canvas.Image, renderStrategy:Canvas.Immediate}},
// { tag:"fbo cooperative", properties:{width:100, height:100, renderTarget:Canvas.FramebufferObject, renderStrategy:Canvas.Cooperative}},
- { tag:"fbo immediate", properties:{width:100, height:100, renderTarget:Canvas.FramebufferObject, renderStrategy:Canvas.Immediate}},
- { tag:"fbo threaded", properties:{width:100, height:100, renderTarget:Canvas.FramebufferObject, renderStrategy:Canvas.Threaded}}
+ { tag:"fbo immediate", properties:{width:100, height:100, renderTarget:Canvas.FramebufferObject, renderStrategy:Canvas.Immediate}}
+// { tag:"fbo threaded", properties:{width:100, height:100, renderTarget:Canvas.FramebufferObject, renderStrategy:Canvas.Threaded}} // QTBUG-82675
];
return [];
}
diff --git a/tests/auto/quick/qquickcanvasitem/data/tst_arcto.qml b/tests/auto/quick/qquickcanvasitem/data/tst_arcto.qml
index d9017150a4..ef1b7a7b2a 100644
--- a/tests/auto/quick/qquickcanvasitem/data/tst_arcto.qml
+++ b/tests/auto/quick/qquickcanvasitem/data/tst_arcto.qml
@@ -357,7 +357,7 @@ CanvasTestCase {
ctx.fillStyle = '#0f0';
ctx.beginPath();
ctx.moveTo(0, 50);
- ctx.translate(100, 0);
+ ctx.translate(50, 0);
ctx.arcTo(50, 50, 50, 0, 50);
ctx.lineTo(-100, 0);
ctx.fill();
@@ -367,11 +367,11 @@ CanvasTestCase {
comparePixel(ctx, 99,0, 0,255,0,255);
comparePixel(ctx, 0,25, 0,255,0,255);
comparePixel(ctx, 50,25, 0,255,0,255);
- comparePixel(ctx, 99,25, 0,255,0,255);
+ comparePixel(ctx, 99,25, 255,0,0,255);
comparePixel(ctx, 0,49, 0,255,0,255);
comparePixel(ctx, 50,49, 0,255,0,255);
- comparePixel(ctx, 99,49, 0,255,0,255);
- }
+ comparePixel(ctx, 99,49, 255,0,0,255);
+ }
function test_zero(row) {
var canvas = createCanvasObject(row);
var ctx = canvas.getContext('2d');
diff --git a/tests/auto/quick/qquickcanvasitem/data/tst_canvas.qml b/tests/auto/quick/qquickcanvasitem/data/tst_canvas.qml
index 8238d87313..d74df3daa7 100644
--- a/tests/auto/quick/qquickcanvasitem/data/tst_canvas.qml
+++ b/tests/auto/quick/qquickcanvasitem/data/tst_canvas.qml
@@ -129,12 +129,12 @@ CanvasTestCase {
tryCompare(c, "availableChangedCount", 1);
c.requestPaint();
- verify(c.save("c.png"));
- c.loadImage("c.png");
- wait(200);
- verify(c.isImageLoaded("c.png"));
- verify(!c.isImageLoading("c.png"));
- verify(!c.isImageError("c.png"));
+ var imagePath = applicationDirPath + "/c.png";
+ verify(c.save(imagePath));
+ c.loadImage(imagePath);
+ tryVerify(function() { return c.isImageLoaded(imagePath) })
+ verify(!c.isImageLoading(imagePath));
+ verify(!c.isImageError(imagePath));
c.destroy();
}
@@ -187,28 +187,28 @@ CanvasTestCase {
tryCompare(c, "availableChangedCount", 1);
//scene graph could be available immediately
//in this case, we force waiting a short while until the init paint finished
- tryCompare(c, "paintedCount", 1);
+ tryCompare(c, "paintedCount", 0);
ctx.fillRect(0, 0, c.width, c.height);
c.toDataURL();
- tryCompare(c, "paintedCount", 2);
+ tryCompare(c, "paintedCount", 1);
tryCompare(c, "paintCount", 1);
// implicit repaint when visible and resized
testCase.visible = true;
c.width += 1;
c.height += 1;
tryCompare(c, "paintCount", 2);
- tryCompare(c, "paintedCount", 2);
+ tryCompare(c, "paintedCount", 1);
// allow explicit repaint even when hidden
testCase.visible = false;
c.requestPaint();
tryCompare(c, "paintCount", 3);
- tryCompare(c, "paintedCount", 2);
+ tryCompare(c, "paintedCount", 1);
// no implicit repaint when resized but hidden
c.width += 1;
c.height += 1;
waitForRendering(c);
compare(c.paintCount, 3);
- tryCompare(c, "paintedCount", 2);
+ tryCompare(c, "paintedCount", 1);
c.destroy();
}
function test_loadImage(row) {
@@ -221,8 +221,7 @@ CanvasTestCase {
verify(!c.isImageLoaded("red.png"));
c.loadImage("red.png");
- wait(200);
- verify(c.isImageLoaded("red.png"));
+ tryVerify(function() { return c.isImageLoaded("red.png") });
verify(!c.isImageLoading("red.png"));
verify(!c.isImageError("red.png"));
diff --git a/tests/auto/quick/qquickcanvasitem/qquickcanvasitem.pro b/tests/auto/quick/qquickcanvasitem/qquickcanvasitem.pro
index 70e5a05f8d..90c7962382 100644
--- a/tests/auto/quick/qquickcanvasitem/qquickcanvasitem.pro
+++ b/tests/auto/quick/qquickcanvasitem/qquickcanvasitem.pro
@@ -55,5 +55,3 @@ OTHER_FILES += \
data/yellow75.png \
data/tst_invalidContext.qml
-
-CONFIG += insignificant_test # QTBUG-41043
diff --git a/tests/auto/quick/qquickcanvasitem/tst_qquickcanvasitem.cpp b/tests/auto/quick/qquickcanvasitem/tst_qquickcanvasitem.cpp
index dad8df0682..4a83bd6c0d 100644
--- a/tests/auto/quick/qquickcanvasitem/tst_qquickcanvasitem.cpp
+++ b/tests/auto/quick/qquickcanvasitem/tst_qquickcanvasitem.cpp
@@ -46,6 +46,8 @@ public slots:
false
#endif
));
+ engine->rootContext()->setContextProperty("applicationDirPath",
+ QCoreApplication::applicationDirPath());
}
};
diff --git a/tests/auto/quick/qquicklayouts/data/tst_rowlayout.qml b/tests/auto/quick/qquicklayouts/data/tst_rowlayout.qml
index 0732884c97..f61e2e0f48 100644
--- a/tests/auto/quick/qquicklayouts/data/tst_rowlayout.qml
+++ b/tests/auto/quick/qquicklayouts/data/tst_rowlayout.qml
@@ -118,10 +118,10 @@ Item {
function test_warnAboutLayoutItemsWithAnchors()
{
- var fullPath = Qt.resolvedUrl("tst_rowlayout.qml")
+ var regex = new RegExp("QML Item: Detected anchors on an item that is managed by a layout. "
+ + "This is undefined behavior; use Layout.alignment instead.")
for (var i = 0; i < 7; ++i) {
- ignoreWarning(fullPath + ":" + (75 + 5*i) +":17: QML Item: Detected anchors on an item that is managed by a layout. "
- + "This is undefined behavior; use Layout.alignment instead.")
+ ignoreWarning(regex)
}
var layout = itemsWithAnchorsLayout_Component.createObject(container)
waitForRendering(layout)
diff --git a/tests/auto/quick/qquickmousearea/data/settingHiddenInPressUngrabs.qml b/tests/auto/quick/qquickmousearea/data/settingHiddenInPressUngrabs.qml
new file mode 100644
index 0000000000..4532dabfd8
--- /dev/null
+++ b/tests/auto/quick/qquickmousearea/data/settingHiddenInPressUngrabs.qml
@@ -0,0 +1,36 @@
+import QtQuick 2.11
+import QtQuick.Window 2.11
+
+Window {
+ id: window
+ visible: true
+ width: 200
+ height: 200
+
+ MouseArea {
+ objectName: "cat"
+ anchors.fill: parent
+ onPressed: visible = false
+ width: parent.width / 2
+ height: parent.height
+ Rectangle {
+ width: 10
+ height: 10
+ color: "blue"
+ }
+ }
+ MouseArea {
+ objectName: "mouse"
+ x: parent.width / 2
+ width: parent.width / 2
+ height: parent.height
+ onPressed: {
+ enabled = false
+ }
+ Rectangle {
+ width: 10
+ height: 10
+ color: "blue"
+ }
+ }
+}
diff --git a/tests/auto/quick/qquickmousearea/tst_qquickmousearea.cpp b/tests/auto/quick/qquickmousearea/tst_qquickmousearea.cpp
index 3503e8a9fd..5879fc6897 100644
--- a/tests/auto/quick/qquickmousearea/tst_qquickmousearea.cpp
+++ b/tests/auto/quick/qquickmousearea/tst_qquickmousearea.cpp
@@ -158,6 +158,7 @@ private slots:
void pressOneAndTapAnother();
void mask();
void nestedEventDelivery();
+ void settingHiddenInPressUngrabs();
private:
int startDragDistance() const {
@@ -2346,6 +2347,43 @@ void tst_QQuickMouseArea::nestedEventDelivery() // QTBUG-70898
QTest::mouseClick(window.data(), Qt::LeftButton, Qt::NoModifier, QPoint(50,150));
}
+void tst_QQuickMouseArea::settingHiddenInPressUngrabs()
+{
+ // When an item sets itself hidden, while handling pressed, it doesn't receive the grab.
+ // But that in turn means it doesn't see any release events, so we need to make sure it
+ // receives an ungrab event.
+
+ QQmlEngine engine;
+ QQmlComponent c(&engine, testFileUrl("settingHiddenInPressUngrabs.qml"));
+ QScopedPointer<QQuickWindow> window(qmlobject_cast<QQuickWindow *>(c.create()));
+ QVERIFY(window.data());
+ window->show();
+ window->requestActivate();
+ QVERIFY(QTest::qWaitForWindowExposed(window.data()));
+
+ QQuickMouseArea *catArea = window->findChild<QQuickMouseArea*>("cat");
+ QVERIFY(catArea != nullptr);
+ auto pointOnCatArea = catArea->mapToScene(QPointF(5.0, 5.0)).toPoint();
+ QTest::mouseClick(window.data(), Qt::LeftButton, Qt::NoModifier, pointOnCatArea);
+
+ QCoreApplication::processEvents();
+ // The click hides the cat area
+ QTRY_VERIFY(!catArea->isVisible());
+ // The cat area is not stuck in pressed state.
+ QVERIFY(!catArea->pressed());
+
+ QQuickMouseArea *mouseArea = window->findChild<QQuickMouseArea*>("mouse");
+ QVERIFY(mouseArea != nullptr);
+ auto pointOnMouseArea = mouseArea->mapToScene(QPointF(5.0, 5.0)).toPoint();
+ QTest::mouseClick(window.data(), Qt::LeftButton, Qt::NoModifier, pointOnMouseArea);
+
+ QCoreApplication::processEvents();
+ // The click disables the mouse area
+ QTRY_VERIFY(!mouseArea->isEnabled());
+ // The mouse area is not stuck in pressed state.
+ QVERIFY(!mouseArea->pressed());
+}
+
QTEST_MAIN(tst_QQuickMouseArea)
#include "tst_qquickmousearea.moc"
diff --git a/tests/auto/quickwidgets/qquickwidget/data/resizeOverlay.qml b/tests/auto/quickwidgets/qquickwidget/data/resizeOverlay.qml
new file mode 100644
index 0000000000..5547856941
--- /dev/null
+++ b/tests/auto/quickwidgets/qquickwidget/data/resizeOverlay.qml
@@ -0,0 +1,15 @@
+import QtQuick 2.15
+
+import Test 1.0
+
+Item {
+ id: root
+
+ property alias overlay: overlay
+
+ Overlay {
+ id: overlay
+ // Parent it to the contentItem of the underlying QQuickWindow.
+ parent: root.parent
+ }
+}
diff --git a/tests/auto/quickwidgets/qquickwidget/tst_qquickwidget.cpp b/tests/auto/quickwidgets/qquickwidget/tst_qquickwidget.cpp
index 691dfd1bc6..12c51caa75 100644
--- a/tests/auto/quickwidgets/qquickwidget/tst_qquickwidget.cpp
+++ b/tests/auto/quickwidgets/qquickwidget/tst_qquickwidget.cpp
@@ -33,6 +33,7 @@
#include <QtQml/qqmlcontext.h>
#include <QtQuick/qquickview.h>
#include <QtQuick/qquickitem.h>
+#include <QtQuick/private/qquickitem_p.h>
#include "../../shared/util.h"
#include <QtGui/QWindow>
#include <QtGui/QScreen>
@@ -142,6 +143,7 @@ private slots:
void synthMouseFromTouch_data();
void synthMouseFromTouch();
void tabKey();
+ void resizeOverlay();
private:
QTouchDevice *device = QTest::createTouchDevice();
@@ -662,6 +664,74 @@ void tst_qquickwidget::tabKey()
QVERIFY(middleItem->property("activeFocus").toBool());
}
+class Overlay : public QQuickItem, public QQuickItemChangeListener
+{
+ Q_OBJECT
+
+public:
+ Overlay() = default;
+
+ ~Overlay()
+ {
+ QQuickItemPrivate::get(parentItem())->removeItemChangeListener(this, QQuickItemPrivate::Geometry);
+ }
+
+ // componentCompleted() is too early to add the listener, as parentItem()
+ // is still null by that stage, so we use this function instead.
+ void startListening()
+ {
+ QQuickItemPrivate::get(parentItem())->addItemChangeListener(this, QQuickItemPrivate::Geometry);
+ }
+
+private:
+ virtual void itemGeometryChanged(QQuickItem *, QQuickGeometryChange, const QRectF &/*oldGeometry*/) override
+ {
+ auto window = QQuickItemPrivate::get(this)->window;
+ if (!window)
+ return;
+
+ setSize(window->size());
+ }
+};
+
+// Test that an item that resizes itself based on the window size can use a
+// Geometry item change listener to respond to changes in size. This is a
+// simplified test to mimic a use case involving Overlay from Qt Quick Controls 2.
+void tst_qquickwidget::resizeOverlay()
+{
+ QWidget widget;
+ auto contentVerticalLayout = new QVBoxLayout(&widget);
+ contentVerticalLayout->setMargin(0);
+
+ qmlRegisterType<Overlay>("Test", 1, 0, "Overlay");
+
+ auto quickWidget = new QQuickWidget(testFileUrl("resizeOverlay.qml"), &widget);
+ QCOMPARE(quickWidget->status(), QQuickWidget::Ready);
+ quickWidget->setResizeMode(QQuickWidget::SizeRootObjectToView);
+ contentVerticalLayout->addWidget(quickWidget);
+
+ auto rootItem = qobject_cast<QQuickItem*>(quickWidget->rootObject());
+ QVERIFY(rootItem);
+
+ auto overlay = rootItem->property("overlay").value<Overlay*>();
+ QVERIFY(overlay);
+ QVERIFY(overlay->parentItem());
+ overlay->startListening();
+
+ widget.resize(200, 200);
+ widget.show();
+ QCOMPARE(rootItem->width(), 200);
+ QCOMPARE(rootItem->height(), 200);
+ QCOMPARE(overlay->width(), rootItem->width());
+ QCOMPARE(overlay->height(), rootItem->height());
+
+ widget.resize(300, 300);
+ QCOMPARE(rootItem->width(), 300);
+ QCOMPARE(rootItem->height(), 300);
+ QCOMPARE(overlay->width(), rootItem->width());
+ QCOMPARE(overlay->height(), rootItem->height());
+}
+
QTEST_MAIN(tst_qquickwidget)
#include "tst_qquickwidget.moc"