aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/qml/qwidgetsinqml
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/qml/qwidgetsinqml')
-rw-r--r--tests/auto/qml/qwidgetsinqml/CMakeLists.txt8
-rw-r--r--tests/auto/qml/qwidgetsinqml/dummy_imports.qml7
-rw-r--r--tests/auto/qml/qwidgetsinqml/tst_qwidgetsinqml.cpp19
3 files changed, 22 insertions, 12 deletions
diff --git a/tests/auto/qml/qwidgetsinqml/CMakeLists.txt b/tests/auto/qml/qwidgetsinqml/CMakeLists.txt
index 4daa98889a..d2374997f2 100644
--- a/tests/auto/qml/qwidgetsinqml/CMakeLists.txt
+++ b/tests/auto/qml/qwidgetsinqml/CMakeLists.txt
@@ -7,6 +7,12 @@
## tst_qwidgetsinqml Test:
#####################################################################
+if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
+ cmake_minimum_required(VERSION 3.16)
+ project(tst_qwidgetsinqml LANGUAGES CXX)
+ find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST)
+endif()
+
qt_internal_add_test(tst_qwidgetsinqml
SOURCES
tst_qwidgetsinqml.cpp
@@ -15,6 +21,8 @@ qt_internal_add_test(tst_qwidgetsinqml
Qt::GuiPrivate
Qt::Qml
Qt::Widgets
+ Qt::QuickTestUtilsPrivate
+ TESTDATA "dummy_imports.qml"
)
## Scopes:
diff --git a/tests/auto/qml/qwidgetsinqml/dummy_imports.qml b/tests/auto/qml/qwidgetsinqml/dummy_imports.qml
new file mode 100644
index 0000000000..afe2b33adf
--- /dev/null
+++ b/tests/auto/qml/qwidgetsinqml/dummy_imports.qml
@@ -0,0 +1,7 @@
+// This file exists for the sole purpose for qmlimportscanner to find
+// which modules it needs to extract for deployment.
+// Otherwise, it fails to find the imports that are expressed in C++.
+
+import QtQml
+
+QtObject { }
diff --git a/tests/auto/qml/qwidgetsinqml/tst_qwidgetsinqml.cpp b/tests/auto/qml/qwidgetsinqml/tst_qwidgetsinqml.cpp
index 15236c20d8..12058fbba2 100644
--- a/tests/auto/qml/qwidgetsinqml/tst_qwidgetsinqml.cpp
+++ b/tests/auto/qml/qwidgetsinqml/tst_qwidgetsinqml.cpp
@@ -1,10 +1,11 @@
// Copyright (C) 2018 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QtTest/QtTest>
#include <QQmlEngine>
#include <QtQml>
#include <QWidget>
+#include <QtQuickTestUtils/private/qmlutils_p.h>
class tst_QWidgetsInQml : public QObject
{
@@ -20,13 +21,6 @@ private slots:
void widgetAsDefaultPropertyKeptDuringCreation();
};
-static void gc(QQmlEngine &engine)
-{
- engine.collectGarbage();
- QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete);
- QCoreApplication::processEvents();
-}
-
// Like QtObject, but with default property
class QObjectContainer : public QObject
{
@@ -40,7 +34,8 @@ public:
{}
QQmlListProperty<QObject> data() {
- return QQmlListProperty<QObject>(this, 0, children_append, children_count, children_at, children_clear);
+ return QQmlListProperty<QObject>(
+ this, nullptr, children_append, children_count, children_at, children_clear);
}
static void children_append(QQmlListProperty<QObject> *prop, QObject *o)
@@ -58,12 +53,12 @@ public:
}
}
- static int children_count(QQmlListProperty<QObject> *prop)
+ static qsizetype children_count(QQmlListProperty<QObject> *prop)
{
return static_cast<QObjectContainer*>(prop->object)->dataChildren.count();
}
- static QObject *children_at(QQmlListProperty<QObject> *prop, int index)
+ static QObject *children_at(QQmlListProperty<QObject> *prop, qsizetype index)
{
return static_cast<QObjectContainer*>(prop->object)->dataChildren.at(index);
}
@@ -71,7 +66,7 @@ public:
static void children_clear(QQmlListProperty<QObject> *prop)
{
QObjectContainer *that = static_cast<QObjectContainer*>(prop->object);
- foreach (QObject *c, that->dataChildren)
+ for (QObject *c : std::as_const(that->dataChildren))
QObject::disconnect(c, SIGNAL(destroyed(QObject*)), that, SLOT(childDestroyed(QObject*)));
that->dataChildren.clear();
}