diff options
Diffstat (limited to 'tests/auto/widgets/kernel/qwidgetmetatype/tst_qwidgetmetatype.cpp')
-rw-r--r-- | tests/auto/widgets/kernel/qwidgetmetatype/tst_qwidgetmetatype.cpp | 57 |
1 files changed, 16 insertions, 41 deletions
diff --git a/tests/auto/widgets/kernel/qwidgetmetatype/tst_qwidgetmetatype.cpp b/tests/auto/widgets/kernel/qwidgetmetatype/tst_qwidgetmetatype.cpp index 0c99042e10..885c26a128 100644 --- a/tests/auto/widgets/kernel/qwidgetmetatype/tst_qwidgetmetatype.cpp +++ b/tests/auto/widgets/kernel/qwidgetmetatype/tst_qwidgetmetatype.cpp @@ -1,33 +1,8 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Stephen Kelly <stephen.kelly@kdab.com> -** 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 <QtTest/QtTest> +// Copyright (C) 2012 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Stephen Kelly <stephen.kelly@kdab.com> +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only + + +#include <QTest> #include <qwidget.h> #include <qlabel.h> @@ -49,7 +24,7 @@ class CustomWidget : public QWidget { Q_OBJECT public: - CustomWidget(QWidget *parent = 0) + CustomWidget(QWidget *parent = nullptr) : QWidget(parent) { @@ -64,10 +39,10 @@ static_assert((!QMetaTypeId2<QMap<QString,QSizePolicy> >::IsBuiltIn)); void tst_QWidgetMetaType::metaObject() { - QCOMPARE(QMetaType::metaObjectForType(qMetaTypeId<QWidget*>()), &QWidget::staticMetaObject); - QCOMPARE(QMetaType::metaObjectForType(qMetaTypeId<QLabel*>()), &QLabel::staticMetaObject); - QCOMPARE(QMetaType::metaObjectForType(qMetaTypeId<CustomWidget*>()), &CustomWidget::staticMetaObject); - QCOMPARE(QMetaType::metaObjectForType(qMetaTypeId<QSizePolicy>()), &QSizePolicy::staticMetaObject); + QCOMPARE(QMetaType::fromType<QWidget*>().metaObject(), &QWidget::staticMetaObject); + QCOMPARE(QMetaType::fromType<QLabel*>().metaObject(), &QLabel::staticMetaObject); + QCOMPARE(QMetaType::fromType<CustomWidget*>().metaObject(), &CustomWidget::staticMetaObject); + QCOMPARE(QMetaType::fromType<QSizePolicy>().metaObject(), &QSizePolicy::staticMetaObject); } template <typename T> @@ -93,25 +68,25 @@ void tst_QWidgetMetaType::saveAndLoadBuiltin() QFETCH(int, type); QFETCH(bool, isStreamable); - void *value = QMetaType::create(type); + void *value = QMetaType(type).create(); QByteArray ba; QDataStream stream(&ba, QIODevice::ReadWrite); - QCOMPARE(QMetaType::save(stream, type, value), isStreamable); + QCOMPARE(QMetaType(type).save(stream, value), isStreamable); QCOMPARE(stream.status(), QDataStream::Ok); if (isStreamable) - QVERIFY(QMetaType::load(stream, type, value)); + QVERIFY(QMetaType(type).load(stream, value)); stream.device()->seek(0); stream.resetStatus(); - QCOMPARE(QMetaType::load(stream, type, value), isStreamable); + QCOMPARE(QMetaType(type).load(stream, value), isStreamable); QCOMPARE(stream.status(), QDataStream::Ok); if (isStreamable) - QVERIFY(QMetaType::load(stream, type, value)); + QVERIFY(QMetaType(type).load(stream, value)); - QMetaType::destroy(type, value); + QMetaType(type).destroy(value); } |