diff options
Diffstat (limited to 'tests/auto/qml/qqmlecmascript/testtypes.cpp')
-rw-r--r-- | tests/auto/qml/qqmlecmascript/testtypes.cpp | 103 |
1 files changed, 68 insertions, 35 deletions
diff --git a/tests/auto/qml/qqmlecmascript/testtypes.cpp b/tests/auto/qml/qqmlecmascript/testtypes.cpp index 688ed2c946..5f7713392b 100644 --- a/tests/auto/qml/qqmlecmascript/testtypes.cpp +++ b/tests/auto/qml/qqmlecmascript/testtypes.cpp @@ -1,30 +1,6 @@ -/**************************************************************************** -** -** Copyright (C) 2016 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$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only + #include "testtypes.h" #ifndef QT_NO_WIDGETS # include <QWidget> @@ -33,6 +9,7 @@ #include <QQmlEngine> #include <QJSEngine> #include <QThread> +#include <QtQuickTestUtils/private/qmlutils_p.h> class BaseExtensionObject : public QObject { @@ -76,7 +53,7 @@ class ImplementedExtensionObject : public AbstractExtensionObject Q_PROPERTY(int implementedProperty READ implementedProperty WRITE setImplementedProperty NOTIFY implementedPropertyChanged) public: ImplementedExtensionObject(QObject *parent = nullptr) : AbstractExtensionObject(parent), m_implementedProperty(883) {} - void shouldBeImplemented() {} + void shouldBeImplemented() override {} void setImplementedProperty(int implementedProperty) { m_implementedProperty = implementedProperty; emit implementedPropertyChanged(); } int implementedProperty() const { return m_implementedProperty; } @@ -129,7 +106,7 @@ public: void setWidth(int) { } }; -void MyQmlObject::v8function(QQmlV4Function *function) +void MyQmlObject::v8function(QQmlV4FunctionPtr function) { function->v4engine()->throwError(QStringLiteral("Exception thrown from within QObject slot")); } @@ -238,7 +215,7 @@ class MyWorkerObjectThread : public QThread public: MyWorkerObjectThread(MyWorkerObject *o) : QThread(o), o(o) { start(); } - virtual void run() { + void run() override { emit o->done(QLatin1String("good")); } @@ -418,15 +395,13 @@ void QObjectContainer::children_append(QQmlListProperty<QObject> *prop, QObject if (that->gcOnAppend) { QQmlEngine *engine = qmlEngine(that); - engine->collectGarbage(); - QCoreApplication::sendPostedEvents(nullptr, QEvent::DeferredDelete); - QCoreApplication::processEvents(); + gc(*engine); } } qsizetype QObjectContainer::children_count(QQmlListProperty<QObject> *prop) { - return static_cast<QObjectContainer*>(prop->object)->dataChildren.count(); + return static_cast<QObjectContainer*>(prop->object)->dataChildren.size(); } QObject *QObjectContainer::children_at(QQmlListProperty<QObject> *prop, qsizetype index) @@ -437,7 +412,7 @@ QObject *QObjectContainer::children_at(QQmlListProperty<QObject> *prop, qsizetyp void QObjectContainer::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(); } @@ -461,6 +436,44 @@ void ClassWithQProperty2::callback() // Q_UNUSED(this->value.value()); // force evaluation } +ListPropertyAssignment_Gadget::ListPropertyAssignment_Gadget() { } + +QStringList ListPropertyAssignment_Gadget::gadgetStringList() const +{ + return m_gadgetStringList; +} + +void ListPropertyAssignment_Gadget::setGadgetStringList(const QStringList &list) +{ + if (m_gadgetStringList == list) + return; + m_gadgetStringList = list; +} + +QVariantList ListPropertyAssignment_Gadget::gadgetVariantList() const +{ + return m_gadgetVariantList; +} + +void ListPropertyAssignment_Gadget::setGadgetVariantList(const QVariantList &list) +{ + if (m_gadgetVariantList == list) + return; + m_gadgetVariantList = list; +} + +ListPropertyAssignment_Object::ListPropertyAssignment_Object(QObject *parent) + : QObject{ parent } { } + +void ListPropertyAssignment_Object::setQobjectStringList(const QStringList &newList) +{ + if (m_qobjectStringList == newList) + return; + m_qobjectStringList = newList; +} + +bool MetaCallInterceptor::didGetObjectDestroyedCallback = false; + void registerTypes() { qmlRegisterType<MyQmlObject>("Qt.test", 1,0, "MyQmlObjectAlias"); @@ -468,6 +481,12 @@ void registerTypes() qmlRegisterSingletonType<MyInheritedQmlObject>("Test", 1, 0, "MyInheritedQmlObjectSingleton", inheritedQmlObject_provider); qmlRegisterSingletonType<TestTypeCppSingleton>("Test", 1, 0, "TestTypeCppSingleton", testTypeCppProvider); qmlRegisterType<MyDeferredObject>("Qt.test", 1,0, "MyDeferredObject"); + qmlRegisterType<MyImmediateObject>("Qt.test", 1,0, "MyImmediateObject"); + qmlRegisterType<DerivedFromImmediate>("Qt.test", 1,0, "DerivedFromImmediate"); + qmlRegisterType<BrokenImmediateDeferred>("Qt.test", 1,0, "BrokenImmediateDeferred"); + qmlRegisterType<DeferredChild>("Qt.test", 1,0, "DeferredChild"); + qmlRegisterType<DeferredChildOverwrite>("Qt.test", 1, 0, "DeferredChildOverwrite"); + qmlRegisterType<DeferredByParentChild>("Qt.test", 1,0, "DeferredByParentChild"); qmlRegisterType<MyVeryDeferredObject>("Qt.test", 1,0, "MyVeryDeferredObject"); qmlRegisterType<MyQmlContainer>("Qt.test", 1,0, "MyQmlContainer"); qmlRegisterExtendedType<MyBaseExtendedObject, BaseExtensionObject>("Qt.test", 1,0, "MyBaseExtendedObject"); @@ -555,7 +574,21 @@ void registerTypes() qmlRegisterType<ClashingNames>("Qt.test", 1, 0, "ClashingNames"); qmlRegisterType<ClassWithQProperty>("Qt.test", 1, 0, "ClassWithQProperty"); + qmlRegisterType<ClassWithQObjectProperty>("Qt.test", 1, 0, "ClassWithQObjectProperty"); qmlRegisterType<ClassWithQProperty2>("Qt.test", 1, 0, "ClassWithQProperty2"); + + qmlRegisterType<Receiver>("Qt.test", 1,0, "Receiver"); + qmlRegisterType<Sender>("Qt.test", 1,0, "Sender"); + qmlRegisterTypesAndRevisions<ReadOnlyBindable>("Qt.test", 1); + qmlRegisterTypesAndRevisions<ResettableGadgetHolder>("Qt.test", 1); + + qmlRegisterTypesAndRevisions<ListPropertyAssignment_Gadget>("Qt.test", 1); + qmlRegisterTypesAndRevisions<ListPropertyAssignment_Object>("Qt.test", 1); + + qmlRegisterTypesAndRevisions<SingletonRegistrationWrapper>("Qt.test", 1); + + qmlRegisterExtendedType<TypeWithCustomMetaObject, TypeToTriggerProxyMetaObject>( + "Qt.test", 1,0, "TypeWithCustomMetaObject"); } #include "testtypes.moc" |