mirror of
https://github.com/crystalidea/qt6windows7.git
synced 2025-07-05 08:45:25 +08:00
qt 6.5.1 original
This commit is contained in:
11
tests/auto/corelib/kernel/qapplicationstatic/CMakeLists.txt
Normal file
11
tests/auto/corelib/kernel/qapplicationstatic/CMakeLists.txt
Normal file
@ -0,0 +1,11 @@
|
||||
# Copyright (C) 2022 The Qt Company Ltd.
|
||||
# SPDX-License-Identifier: BSD-3-Clause
|
||||
|
||||
#####################################################################
|
||||
## tst_qapplicationstatic Test:
|
||||
#####################################################################
|
||||
|
||||
qt_internal_add_test(tst_qapplicationstatic
|
||||
SOURCES
|
||||
tst_qapplicationstatic.cpp
|
||||
)
|
@ -0,0 +1,40 @@
|
||||
// Copyright (C) 2021 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
||||
|
||||
#include <QTest>
|
||||
#include <QPointer>
|
||||
#include "QtCore/qapplicationstatic.h"
|
||||
|
||||
Q_APPLICATION_STATIC(QObject, tstObject)
|
||||
|
||||
class tst_qapplicationstatic : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
private slots:
|
||||
void testCreateMultipleApplications() const;
|
||||
};
|
||||
|
||||
void tst_qapplicationstatic::testCreateMultipleApplications() const
|
||||
{
|
||||
for (int i = 0; i < 5; i++) {
|
||||
int argc = 1;
|
||||
char *argv[] = { (char *)"tst_qapplicationstatic" };
|
||||
auto app = new QCoreApplication(argc, argv);
|
||||
|
||||
QVERIFY(tstObject);
|
||||
|
||||
QPointer<QObject> tstObjectPointer(tstObject);
|
||||
QVERIFY(tstObjectPointer.get());
|
||||
|
||||
QVERIFY2(tstObject->objectName().isEmpty(), "Got QObject from previous iteration, not correctly recreated");
|
||||
tstObject->setObjectName(QStringLiteral("tstObject"));
|
||||
QVERIFY(!tstObject->objectName().isEmpty());
|
||||
|
||||
delete app;
|
||||
QVERIFY2(!tstObjectPointer.get(), "QObject wasn't destroyed on QCoreApplication destruction");
|
||||
}
|
||||
}
|
||||
|
||||
QTEST_APPLESS_MAIN(tst_qapplicationstatic)
|
||||
#include "tst_qapplicationstatic.moc"
|
Reference in New Issue
Block a user