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$
|
|
|
|
**
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#include <qtest.h>
|
|
|
|
#include <QLibraryInfo>
|
|
|
|
#include <QDir>
|
|
|
|
#include <QProcess>
|
|
|
|
#include <QDebug>
|
|
|
|
#include <cstdlib>
|
|
|
|
|
|
|
|
class tst_qmlplugindump : public QObject
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
|
|
|
tst_qmlplugindump();
|
|
|
|
|
|
|
|
private slots:
|
|
|
|
void initTestCase();
|
|
|
|
void builtins();
|
2015-12-04 14:56:07 +00:00
|
|
|
void singleton();
|
2011-10-04 10:22:07 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
QString qmlplugindumpPath;
|
|
|
|
};
|
|
|
|
|
|
|
|
tst_qmlplugindump::tst_qmlplugindump()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void tst_qmlplugindump::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;
|
|
|
|
args << QLatin1String("tests.dumper.CompositeSingleton") << QLatin1String("1.0")
|
|
|
|
<< QLatin1String(".");
|
|
|
|
dumper.start(qmlplugindumpPath, args);
|
|
|
|
dumper.waitForFinished();
|
|
|
|
|
|
|
|
const QString &result = dumper.readAllStandardOutput();
|
2016-04-26 09:49:52 +00:00
|
|
|
qDebug() << "result: " << result;
|
2015-12-04 14:56:07 +00:00
|
|
|
QVERIFY(result.contains(QLatin1String("exports: [\"Singleton 1.0\"]")));
|
2016-01-15 09:07:52 +00:00
|
|
|
QVERIFY(result.contains(QLatin1String("exportMetaObjectRevisions: [0]")));
|
2015-12-04 14:56:07 +00:00
|
|
|
}
|
|
|
|
|
2011-10-04 10:22:07 +00:00
|
|
|
QTEST_MAIN(tst_qmlplugindump)
|
|
|
|
|
|
|
|
#include "tst_qmlplugindump.moc"
|