2011-10-04 10:22:07 +00:00
|
|
|
/****************************************************************************
|
|
|
|
**
|
2016-01-19 11:23:05 +00:00
|
|
|
** Copyright (C) 2016 The Qt Company Ltd.
|
|
|
|
** Contact: https://www.qt.io/licensing/
|
2011-10-04 10:22:07 +00:00
|
|
|
**
|
|
|
|
** This file is part of the test suite of the Qt Toolkit.
|
|
|
|
**
|
2016-01-19 11:23:05 +00:00
|
|
|
** $QT_BEGIN_LICENSE:GPL-EXCEPT$
|
2012-09-20 05:21:40 +00:00
|
|
|
** 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
|
2015-01-28 11:55:39 +00:00
|
|
|
** a written agreement between you and The Qt Company. For licensing terms
|
2016-01-19 11:23:05 +00:00
|
|
|
** and conditions see https://www.qt.io/terms-conditions. For further
|
|
|
|
** information use the contact form at https://www.qt.io/contact-us.
|
2012-09-20 05:21:40 +00:00
|
|
|
**
|
2016-01-19 11:23:05 +00:00
|
|
|
** 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.
|
2011-10-04 10:22:07 +00:00
|
|
|
**
|
|
|
|
** $QT_END_LICENSE$
|
|
|
|
**
|
|
|
|
****************************************************************************/
|
|
|
|
|
2017-09-20 09:25:22 +00:00
|
|
|
#include "util.h"
|
|
|
|
|
2011-10-04 10:22:07 +00:00
|
|
|
#include <qtest.h>
|
|
|
|
#include <QLibraryInfo>
|
|
|
|
#include <QDir>
|
|
|
|
#include <QProcess>
|
|
|
|
#include <QDebug>
|
|
|
|
#include <cstdlib>
|
|
|
|
|
2017-09-20 09:25:22 +00:00
|
|
|
class tst_qmlplugindump : public QQmlDataTest
|
2011-10-04 10:22:07 +00:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
|
|
|
tst_qmlplugindump();
|
|
|
|
|
|
|
|
private slots:
|
|
|
|
void initTestCase();
|
|
|
|
void builtins();
|
2015-12-04 14:56:07 +00:00
|
|
|
void singleton();
|
2018-11-09 15:53:19 +00:00
|
|
|
void compositeWithinSingleton();
|
2019-07-01 09:04:39 +00:00
|
|
|
void compositeWithEnum();
|
2018-11-09 15:53:19 +00:00
|
|
|
|
2018-09-27 14:18:31 +00:00
|
|
|
void plugin_data();
|
|
|
|
void plugin();
|
2011-10-04 10:22:07 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
QString qmlplugindumpPath;
|
|
|
|
};
|
|
|
|
|
|
|
|
tst_qmlplugindump::tst_qmlplugindump()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void tst_qmlplugindump::initTestCase()
|
|
|
|
{
|
2017-09-20 09:25:22 +00:00
|
|
|
QQmlDataTest::initTestCase();
|
2011-11-10 05:56:29 +00:00
|
|
|
qmlplugindumpPath = QLibraryInfo::location(QLibraryInfo::BinariesPath);
|
|
|
|
|
2013-05-08 17:22:29 +00:00
|
|
|
#if defined(Q_OS_WIN)
|
2011-11-10 05:56:29 +00:00
|
|
|
qmlplugindumpPath += QLatin1String("/qmlplugindump.exe");
|
|
|
|
#else
|
|
|
|
qmlplugindumpPath += QLatin1String("/qmlplugindump");
|
2011-10-04 10:22:07 +00:00
|
|
|
#endif
|
2011-11-10 05:56:29 +00:00
|
|
|
|
2011-10-04 10:22:07 +00:00
|
|
|
if (!QFileInfo(qmlplugindumpPath).exists()) {
|
|
|
|
QString message = QString::fromLatin1("qmlplugindump executable not found (looked for %0)")
|
|
|
|
.arg(qmlplugindumpPath);
|
|
|
|
QFAIL(qPrintable(message));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void tst_qmlplugindump::builtins()
|
|
|
|
{
|
|
|
|
QProcess dumper;
|
|
|
|
QStringList args;
|
|
|
|
args += QLatin1String("-builtins");
|
|
|
|
dumper.start(qmlplugindumpPath, args);
|
|
|
|
dumper.waitForFinished();
|
|
|
|
|
|
|
|
if (dumper.error() != QProcess::UnknownError
|
|
|
|
|| dumper.exitStatus() != QProcess::NormalExit) {
|
|
|
|
qWarning() << QString("Error while running '%1 %2'").arg(
|
2015-10-13 11:06:26 +00:00
|
|
|
qmlplugindumpPath, args.join(QLatin1Char(' ')));
|
2011-10-04 10:22:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (dumper.error() == QProcess::FailedToStart) {
|
|
|
|
QFAIL("failed to start");
|
|
|
|
}
|
|
|
|
if (dumper.error() == QProcess::Crashed) {
|
|
|
|
qWarning() << "stderr:\n" << dumper.readAllStandardError();
|
|
|
|
QFAIL("crashed");
|
|
|
|
}
|
|
|
|
|
|
|
|
QCOMPARE(dumper.error(), QProcess::UnknownError);
|
|
|
|
QCOMPARE(dumper.exitStatus(), QProcess::NormalExit);
|
|
|
|
|
|
|
|
const QString &result = dumper.readAllStandardOutput();
|
|
|
|
QVERIFY(result.contains(QLatin1String("Module {")));
|
|
|
|
}
|
|
|
|
|
2015-12-04 14:56:07 +00:00
|
|
|
void tst_qmlplugindump::singleton()
|
|
|
|
{
|
|
|
|
QProcess dumper;
|
|
|
|
QStringList args;
|
2018-09-27 14:18:31 +00:00
|
|
|
args << QLatin1String("dumper.CompositeSingleton") << QLatin1String("1.0")
|
|
|
|
<< QLatin1String(QT_QMLTEST_DIR "/data");
|
2015-12-04 14:56:07 +00:00
|
|
|
dumper.start(qmlplugindumpPath, args);
|
2017-04-07 12:16:14 +00:00
|
|
|
QVERIFY2(dumper.waitForStarted(), qPrintable(dumper.errorString()));
|
|
|
|
QVERIFY2(dumper.waitForFinished(), qPrintable(dumper.errorString()));
|
2015-12-04 14:56:07 +00:00
|
|
|
|
|
|
|
const QString &result = dumper.readAllStandardOutput();
|
2017-04-07 12:16:14 +00:00
|
|
|
QVERIFY2(result.contains(QLatin1String("exports: [\"Singleton 1.0\"]")), qPrintable(result));
|
|
|
|
QVERIFY2(result.contains(QLatin1String("exportMetaObjectRevisions: [0]")), qPrintable(result));
|
2015-12-04 14:56:07 +00:00
|
|
|
}
|
|
|
|
|
2018-11-09 15:53:19 +00:00
|
|
|
void tst_qmlplugindump::compositeWithinSingleton()
|
|
|
|
{
|
|
|
|
QProcess dumper;
|
|
|
|
QStringList args;
|
|
|
|
args << QLatin1String("dumper.CompositeWithinSingleton") << QLatin1String("1.0")
|
|
|
|
<< QLatin1String(QT_QMLTEST_DIR "/data");
|
|
|
|
dumper.start(qmlplugindumpPath, args);
|
|
|
|
QVERIFY2(dumper.waitForStarted(), qPrintable(dumper.errorString()));
|
|
|
|
QVERIFY2(dumper.waitForFinished(), qPrintable(dumper.errorString()));
|
|
|
|
|
|
|
|
const QString &result = dumper.readAllStandardOutput();
|
|
|
|
QVERIFY2(result.contains(QLatin1String("exports: [\"Composite 1.0\"]")), qPrintable(result));
|
|
|
|
QVERIFY2(result.contains(QLatin1String("exportMetaObjectRevisions: [0]")), qPrintable(result));
|
|
|
|
}
|
|
|
|
|
2019-07-01 09:04:39 +00:00
|
|
|
void tst_qmlplugindump::compositeWithEnum()
|
|
|
|
{
|
|
|
|
QProcess dumper;
|
|
|
|
QStringList args;
|
|
|
|
args << QLatin1String("dumper.CompositeWithEnum") << QLatin1String("1.0")
|
|
|
|
<< QLatin1String(QT_QMLTEST_DIR "/data");
|
|
|
|
dumper.start(qmlplugindumpPath, args);
|
|
|
|
QVERIFY2(dumper.waitForStarted(), qPrintable(dumper.errorString()));
|
|
|
|
QVERIFY2(dumper.waitForFinished(), qPrintable(dumper.errorString()));
|
|
|
|
|
|
|
|
const QString &result = dumper.readAllStandardOutput();
|
|
|
|
QVERIFY2(result.contains(QLatin1String("exports: [\"Animal 1.0\"]")), qPrintable(result));
|
|
|
|
QVERIFY2(result.contains(QLatin1String("Enum {")), qPrintable(result));
|
|
|
|
}
|
|
|
|
|
2018-09-27 14:18:31 +00:00
|
|
|
void tst_qmlplugindump::plugin_data()
|
|
|
|
{
|
|
|
|
QTest::addColumn<QString>("import");
|
|
|
|
QTest::addColumn<QString>("version");
|
|
|
|
QTest::addColumn<QString>("expectedPath");
|
|
|
|
|
|
|
|
QTest::newRow("dumper.Dummy") << "dumper.Dummy" << "1.0" << testFile("dumper/Dummy/plugins.qmltypes");
|
|
|
|
QTest::newRow("dumper.Imports") << "dumper.Imports" << "1.0" << testFile("dumper/Imports/plugins.qmltypes");
|
|
|
|
QTest::newRow("dumper.Versions") << "dumper.Versions" << "1.1" << testFile("dumper/Versions/plugins.qmltypes");
|
qmlplugindump: Properly handle extension types
Extension classes do augment the primary C++ class with additional
properties that should be part of the QML type. Anyhow, they should
not be visible in the API.
The old logic tried to emulate this by making the extension
class the actual C++ type, and 'inheriting' from the normal
class by setting it in the prototype. Anyhow, this failed for
e.g. Qt3D, where there are numerous types sharing the same
extension class.
Instead, this patch fixes the issue
a) hiding the extension class metainformation itself, and
b) printing properties of the extension class as part of the
main type.
In the QMetaObject collection phase, we now traverse the class
hierarchy using QQmlType::baseMetaObject instead of
QQmlType::metaObject.
In the generation phase, we explicitly resolve the extended type,
and dump additional properties and "DefaultProperty" information
into the main type description.
Note that the ExtendedType sets the DefaultProperty independent
of the version. Changing this would require either revisioning
the defaultProperty, or (again) splitting up the types, which
however brings other problems.
Task-number: QTBUG-70294
Change-Id: I324469152398a605fae9e5a35b619845444ac4e8
Reviewed-by: Marco Benelli <marco.benelli@qt.io>
2018-09-18 10:03:09 +00:00
|
|
|
QTest::newRow("dumper.ExtendedType") << "dumper.ExtendedType"
|
|
|
|
<< "1.1" << testFile("dumper/ExtendedType/plugins.qmltypes");
|
2018-09-27 14:18:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void tst_qmlplugindump::plugin()
|
|
|
|
{
|
|
|
|
QFETCH(QString, import);
|
|
|
|
QFETCH(QString, version);
|
|
|
|
QFETCH(QString, expectedPath);
|
|
|
|
|
|
|
|
QProcess dumper;
|
|
|
|
dumper.setWorkingDirectory(dataDirectory());
|
|
|
|
QStringList args = { QLatin1String("-nonrelocatable"), QLatin1String("-noforceqtquick"), import, version, QLatin1String(".") };
|
|
|
|
dumper.start(qmlplugindumpPath, args);
|
|
|
|
QVERIFY2(dumper.waitForStarted(), qPrintable(dumper.errorString()));
|
|
|
|
QVERIFY2(dumper.waitForFinished(), qPrintable(dumper.errorString()));
|
|
|
|
|
|
|
|
const QString &result = dumper.readAllStandardOutput();
|
|
|
|
QFile expectedFile(expectedPath);
|
|
|
|
QVERIFY2(expectedFile.open(QIODevice::ReadOnly), qPrintable(expectedFile.errorString()));
|
|
|
|
const QString expected = expectedFile.readAll();
|
|
|
|
QCOMPARE(result, expected);
|
|
|
|
}
|
|
|
|
|
2011-10-04 10:22:07 +00:00
|
|
|
QTEST_MAIN(tst_qmlplugindump)
|
|
|
|
|
|
|
|
#include "tst_qmlplugindump.moc"
|