mirror of
https://github.com/crystalidea/qt6windows7.git
synced 2025-07-03 07:45:30 +08:00
6.5.3 clean
This commit is contained in:
@ -14,7 +14,7 @@ endif()
|
||||
if(TARGET Qt::Widgets AND NOT ANDROID AND NOT IOS)
|
||||
add_subdirectory(uic)
|
||||
endif()
|
||||
if(TARGET Qt::DBus)
|
||||
if(run_dbus_tests)
|
||||
add_subdirectory(qdbuscpp2xml)
|
||||
add_subdirectory(qdbusxml2cpp)
|
||||
endif()
|
||||
|
@ -4,7 +4,8 @@
|
||||
#include <QtCore>
|
||||
#include <QtTest>
|
||||
|
||||
bool g_testDirectoryBuild = false; // toggle to keep build output for debugging.
|
||||
Q_LOGGING_CATEGORY(lcTests, "qt.tools.tests")
|
||||
|
||||
QTemporaryDir *g_temporaryDirectory;
|
||||
QString g_macdeployqtBinary;
|
||||
QString g_qmakeBinary;
|
||||
@ -34,6 +35,24 @@ static bool runProcess(const QString &binary,
|
||||
process.setProcessEnvironment(env);
|
||||
if (!workingDir.isEmpty())
|
||||
process.setWorkingDirectory(workingDir);
|
||||
|
||||
const auto outputReader = qScopeGuard([&] {
|
||||
QByteArray standardOutput = process.readAllStandardOutput();
|
||||
if (!standardOutput.trimmed().isEmpty())
|
||||
qCDebug(lcTests).nospace() << "Standard output:\n" << qUtf8Printable(standardOutput.trimmed());
|
||||
if (stdOut)
|
||||
*stdOut = standardOutput;
|
||||
QByteArray standardError = process.readAllStandardError();
|
||||
if (!standardError.trimmed().isEmpty())
|
||||
qCDebug(lcTests).nospace() << "Standard error:\n" << qUtf8Printable(standardError.trimmed());
|
||||
if (stdErr)
|
||||
*stdErr = standardError;
|
||||
});
|
||||
|
||||
qCDebug(lcTests).noquote() << "Running" << binary
|
||||
<< "with arguments" << arguments
|
||||
<< "in" << workingDir;
|
||||
|
||||
process.start(binary, arguments, QIODevice::ReadOnly);
|
||||
if (!process.waitForStarted()) {
|
||||
*errorMessage = msgProcessError(process, "Failed to start");
|
||||
@ -46,10 +65,7 @@ static bool runProcess(const QString &binary,
|
||||
process.kill();
|
||||
return false;
|
||||
}
|
||||
if (stdOut)
|
||||
*stdOut = process.readAllStandardOutput();
|
||||
if (stdErr)
|
||||
*stdErr= process.readAllStandardError();
|
||||
|
||||
if (process.exitStatus() != QProcess::NormalExit) {
|
||||
*errorMessage = msgProcessError(process, "Crashed");
|
||||
return false;
|
||||
@ -91,8 +107,6 @@ QString sourcePath(const QString &name)
|
||||
|
||||
QString buildPath(const QString &name)
|
||||
{
|
||||
if (g_testDirectoryBuild)
|
||||
return "build_" + name;
|
||||
return g_temporaryDirectory->path() + "/build_" + name;
|
||||
}
|
||||
|
||||
@ -148,26 +162,14 @@ bool deploy(const QString &name, const QStringList &options, QString *errorMessa
|
||||
QString bundle = name + ".app";
|
||||
QString path = buildPath(name);
|
||||
QStringList args = QStringList() << bundle << options;
|
||||
#if defined(QT_DEBUG)
|
||||
args << "-use-debug-libs";
|
||||
#endif
|
||||
if (lcTests().isDebugEnabled())
|
||||
args << "-verbose=3";
|
||||
return runProcess(g_macdeployqtBinary, args, errorMessage, path);
|
||||
}
|
||||
|
||||
bool debugDeploy(const QString &name, const QStringList &options, QString *errorMessage)
|
||||
{
|
||||
QString bundle = name + ".app";
|
||||
QString path = buildPath(name);
|
||||
QStringList args = QStringList() << bundle << options << "-verbose=3";
|
||||
QByteArray stdOut;
|
||||
QByteArray stdErr;
|
||||
bool exitOK = runProcess(g_macdeployqtBinary, args, errorMessage, path, QProcessEnvironment(),
|
||||
10000, &stdOut, &stdErr);
|
||||
|
||||
qDebug() << "macdeployqt exit OK" << exitOK;
|
||||
qDebug() << qPrintable(stdOut);
|
||||
qDebug() << qPrintable(stdErr);
|
||||
|
||||
return exitOK;
|
||||
}
|
||||
|
||||
bool run(const QString &name, QString *errorMessage)
|
||||
{
|
||||
QString path = buildPath(name);
|
||||
@ -197,11 +199,11 @@ void runVerifyDeployment(const QString &name)
|
||||
const QList<QString> parts = QString::fromLocal8Bit(libraries).split("dyld: loaded:");
|
||||
const QString qtPath = QLibraryInfo::path(QLibraryInfo::PrefixPath);
|
||||
// Let assume Qt is not installed in system
|
||||
foreach (QString part, parts) {
|
||||
part = part.trimmed();
|
||||
if (part.isEmpty())
|
||||
for (const QString &part : parts) {
|
||||
const auto trimmed = part.trimmed();
|
||||
if (trimmed.isEmpty())
|
||||
continue;
|
||||
QVERIFY(!parts.startsWith(qtPath));
|
||||
QVERIFY(!trimmed.startsWith(qtPath));
|
||||
}
|
||||
}
|
||||
|
||||
@ -224,6 +226,7 @@ void tst_macdeployqt::initTestCase()
|
||||
|
||||
// Set up test-global unique temporary directory
|
||||
g_temporaryDirectory = new QTemporaryDir();
|
||||
g_temporaryDirectory->setAutoRemove(!lcTests().isDebugEnabled());
|
||||
QVERIFY(g_temporaryDirectory->isValid());
|
||||
|
||||
// Locate build and deployment tools
|
||||
|
@ -60,6 +60,8 @@
|
||||
|
||||
#include "qmlmacro.h"
|
||||
|
||||
using namespace Qt::StringLiterals;
|
||||
|
||||
#ifdef Q_MOC_RUN
|
||||
// check that moc can parse these constructs, they are being used in Windows winsock2.h header
|
||||
#define STRING_HASH_HASH(x) ("foo" ## x ## "bar")
|
||||
@ -79,6 +81,19 @@ Q_DECLARE_METATYPE(const QMetaObject*);
|
||||
|
||||
#define TESTEXPORTMACRO Q_DECL_EXPORT
|
||||
|
||||
#if !defined(Q_MOC_RUN) && !defined(Q_NOREPLY)
|
||||
# define Q_NOREPLY
|
||||
#endif
|
||||
|
||||
struct TagTest : QObject {
|
||||
Q_OBJECT
|
||||
|
||||
Q_INVOKABLE Q_NOREPLY inline int test() {return 0;}
|
||||
public slots:
|
||||
Q_NOREPLY virtual inline void pamOpen(int){}
|
||||
};
|
||||
|
||||
|
||||
namespace TestNonQNamespace {
|
||||
|
||||
struct TestGadget {
|
||||
@ -577,6 +592,10 @@ private slots:
|
||||
|
||||
QT_WARNING_POP
|
||||
|
||||
// quick test to verify that moc handles the L suffix
|
||||
// correctly in the preprocessor
|
||||
#if 2000L < 1
|
||||
#else
|
||||
class PropertyTestClass : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
@ -586,6 +605,7 @@ public:
|
||||
|
||||
Q_ENUM(TestEnum)
|
||||
};
|
||||
#endif
|
||||
|
||||
class PropertyUseClass : public QObject
|
||||
{
|
||||
@ -758,6 +778,7 @@ private slots:
|
||||
void setQPRopertyBinding();
|
||||
void privateQPropertyShim();
|
||||
void readWriteThroughBindable();
|
||||
void virtualInlineTaggedSlot();
|
||||
|
||||
signals:
|
||||
void sigWithUnsignedArg(unsigned foo);
|
||||
@ -2296,6 +2317,13 @@ void tst_Moc::warnings_data()
|
||||
<< QString()
|
||||
<< QString("standard input:3:1: error: Parse error at \"decltype\"");
|
||||
|
||||
QTest::newRow("QTBUG-36367: report correct error location")
|
||||
<< "class X { \n Q_PROPERTY(Foo* foo NONSENSE foo) \n };"_ba
|
||||
<< QStringList()
|
||||
<< 1
|
||||
<< QString()
|
||||
<< u"standard input:2:1: error: Parse error at \"NONSENSE\""_s;
|
||||
|
||||
#ifdef Q_OS_UNIX // Limit to Unix because the error message is platform-dependent
|
||||
QTest::newRow("Q_PLUGIN_METADATA: unreadable file")
|
||||
<< QByteArray("class X { \n Q_PLUGIN_METADATA(FILE \".\") \n };")
|
||||
@ -4426,6 +4454,20 @@ void tst_Moc::readWriteThroughBindable()
|
||||
}
|
||||
}
|
||||
|
||||
void tst_Moc::virtualInlineTaggedSlot()
|
||||
{
|
||||
auto mo = TagTest::staticMetaObject;
|
||||
auto idx = mo.indexOfMethod("pamOpen(int)");
|
||||
auto method = mo.method(idx);
|
||||
QVERIFY(method.isValid()); // fails!
|
||||
QCOMPARE(method.tag(), "Q_NOREPLY");
|
||||
idx = mo.indexOfMethod("test()");
|
||||
method = mo.method(idx);
|
||||
QVERIFY(method.isValid());
|
||||
QCOMPARE(method.tag(), "Q_NOREPLY");
|
||||
QCOMPARE(method.returnMetaType(), QMetaType::fromType<int>());
|
||||
}
|
||||
|
||||
QTEST_MAIN(tst_Moc)
|
||||
|
||||
// the generated code must compile with QT_NO_KEYWORDS
|
||||
|
@ -10,7 +10,7 @@ qt_internal_add_test(tst_qdbuscpp2xml
|
||||
test1.h
|
||||
tst_qdbuscpp2xml.cpp
|
||||
LIBRARIES
|
||||
Qt::DBus
|
||||
Qt::DBusPrivate
|
||||
)
|
||||
|
||||
# Resources:
|
||||
|
@ -5,9 +5,11 @@
|
||||
#include <QLibraryInfo>
|
||||
#include <QProcess>
|
||||
|
||||
#include <QtDBus/QDBusConnection>
|
||||
#include <QtDBus/private/dbus_minimal_p.h>
|
||||
|
||||
#include "test1.h"
|
||||
|
||||
#include <QtDBus/QDBusConnection>
|
||||
|
||||
// in qdbusxmlgenerator.cpp
|
||||
QT_BEGIN_NAMESPACE
|
||||
@ -32,6 +34,8 @@ class tst_qdbuscpp2xml : public QObject
|
||||
private slots:
|
||||
void qdbuscpp2xml_data();
|
||||
void qdbuscpp2xml();
|
||||
void qtdbusTypes_data();
|
||||
void qtdbusTypes();
|
||||
|
||||
void initTestCase();
|
||||
void cleanupTestCase();
|
||||
@ -141,6 +145,77 @@ void tst_qdbuscpp2xml::qdbuscpp2xml()
|
||||
QCOMPARE(out, expected);
|
||||
}
|
||||
|
||||
void tst_qdbuscpp2xml::qtdbusTypes_data()
|
||||
{
|
||||
QTest::addColumn<QByteArray>("type");
|
||||
QTest::addColumn<QByteArray>("expectedSignature");
|
||||
auto addRow = [](QByteArray type, QByteArray signature) {
|
||||
QTest::addRow("%s", type.constData()) << type << signature;
|
||||
|
||||
// lists and vectors
|
||||
QTest::addRow("QList-%s", type.constData())
|
||||
<< "QList<" + type + '>' << DBUS_TYPE_ARRAY + signature;
|
||||
QTest::addRow("QVector-%s", type.constData())
|
||||
<< "QVector<" + type + '>' << DBUS_TYPE_ARRAY + signature;
|
||||
};
|
||||
addRow("QDBusVariant", DBUS_TYPE_VARIANT_AS_STRING);
|
||||
addRow("QDBusObjectPath", DBUS_TYPE_OBJECT_PATH_AS_STRING);
|
||||
addRow("QDBusSignature", DBUS_TYPE_SIGNATURE_AS_STRING);
|
||||
addRow("QDBusUnixFileDescriptor", DBUS_TYPE_UNIX_FD_AS_STRING);
|
||||
|
||||
// QDBusMessage is not a type, but must be recognized
|
||||
QTest::newRow("QDBusMessage") << QByteArray("QDBusMessage") << QByteArray();
|
||||
}
|
||||
|
||||
void tst_qdbuscpp2xml::qtdbusTypes()
|
||||
{
|
||||
static const char cppSkeleton[] = R"(
|
||||
class QDBusVariantBugRepro : public QDBusAbstractAdaptor
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_CLASSINFO("D-Bus Interface", "org.qtproject.test")
|
||||
public Q_SLOTS:
|
||||
void method(const @TYPE@ &);
|
||||
};)";
|
||||
static const char methodXml[] = R"(<method name="method")";
|
||||
static const char expectedSkeleton[] = R"(<arg type="@S@" direction="in"/>)";
|
||||
|
||||
QFETCH(QByteArray, type);
|
||||
QFETCH(QByteArray, expectedSignature);
|
||||
|
||||
const QString binpath = QLibraryInfo::path(QLibraryInfo::BinariesPath);
|
||||
const QString command = binpath + QLatin1String("/qdbuscpp2xml");
|
||||
QProcess process;
|
||||
process.start(command);
|
||||
|
||||
process.write(QByteArray(cppSkeleton).replace("@TYPE@", type));
|
||||
process.closeWriteChannel();
|
||||
|
||||
if (!process.waitForStarted()) {
|
||||
const QString path = QString::fromLocal8Bit(qgetenv("PATH"));
|
||||
QString message = QString::fromLatin1("'%1' could not be found when run from '%2'. Path: '%3' ").
|
||||
arg(command, QDir::currentPath(), path);
|
||||
QFAIL(qPrintable(message));
|
||||
}
|
||||
QVERIFY2(process.waitForFinished(), qPrintable(process.errorString()));
|
||||
|
||||
// verify nothing was printed on stderr
|
||||
QCOMPARE(process.readAllStandardError(), QString());
|
||||
|
||||
// we don't do a full XML parsing here...
|
||||
QByteArray output = process.readAll().simplified();
|
||||
QVERIFY2(output.contains("<node>") && output.contains("</node>"), "Output was: " + output);
|
||||
output = output.mid(output.indexOf("<node>") + strlen("<node>"));
|
||||
output = output.left(output.indexOf("</node>"));
|
||||
|
||||
QVERIFY2(output.contains(methodXml), "Output was: " + output);
|
||||
|
||||
if (!expectedSignature.isEmpty()) {
|
||||
QByteArray expected = QByteArray(expectedSkeleton).replace("@S@", expectedSignature);
|
||||
QVERIFY2(output.contains(expected), "Expected: '" + expected + "'; got: '" + output + '\'');
|
||||
}
|
||||
}
|
||||
|
||||
QTEST_APPLESS_MAIN(tst_qdbuscpp2xml)
|
||||
|
||||
#include "tst_qdbuscpp2xml.moc"
|
||||
|
@ -240,6 +240,46 @@ void tst_qdbusxml2cpp::process_data()
|
||||
<< QRegularExpression("Q_SLOTS:.*QString Method\\(const QString &\\w*, const QString &\\w*, QString &",
|
||||
QRegularExpression::DotMatchesEverythingOption);
|
||||
|
||||
QTest::newRow("method-deprecated-0out")
|
||||
<< "<method name=\"Method\">"
|
||||
"<annotation name=\"org.freedesktop.DBus.Deprecated\" value=\"true\"/>"
|
||||
"</method>"
|
||||
<< QRegularExpression("Q_SLOTS:.*Q_DECL_DEPRECATED inline QDBusPendingReply<> Method\\(\\)",
|
||||
QRegularExpression::DotMatchesEverythingOption)
|
||||
<< QRegularExpression("Q_SLOTS:.*void Method\\(\\)",
|
||||
QRegularExpression::DotMatchesEverythingOption);
|
||||
|
||||
QTest::newRow("method-deprecated-2out")
|
||||
<< "<method name=\"Method\">"
|
||||
"<annotation name=\"org.freedesktop.DBus.Deprecated\" value=\"true\"/>"
|
||||
"<arg type=\"s\" direction=\"out\"/>"
|
||||
"<arg type=\"s\" direction=\"out\"/>"
|
||||
"</method>"
|
||||
<< QRegularExpression("Q_SLOTS:.*Q_DECL_DEPRECATED inline QDBusPendingReply<QString, QString> Method\\(\\)"
|
||||
".*Q_DECL_DEPRECATED inline QDBusReply<QString> Method\\(QString &\\w*\\)",
|
||||
QRegularExpression::DotMatchesEverythingOption)
|
||||
<< QRegularExpression("Q_SLOTS:.*QString Method\\(QString &",
|
||||
QRegularExpression::DotMatchesEverythingOption);
|
||||
|
||||
QTest::newRow("method-noreply")
|
||||
<< "<method name=\"Method\">"
|
||||
"<annotation name=\"org.freedesktop.DBus.Method.NoReply\" value=\"true\"/>"
|
||||
"</method>"
|
||||
<< QRegularExpression("Q_SLOTS:.*Q_NOREPLY inline void Method\\(\\).*\\bQDBus::NoBlock\\b",
|
||||
QRegularExpression::DotMatchesEverythingOption)
|
||||
<< QRegularExpression("Q_SLOTS:.*Q_NOREPLY void Method\\(",
|
||||
QRegularExpression::DotMatchesEverythingOption);
|
||||
|
||||
QTest::newRow("method-deprecated-noreply")
|
||||
<< "<method name=\"Method\">"
|
||||
"<annotation name=\"org.freedesktop.DBus.Method.NoReply\" value=\"true\"/>"
|
||||
"<annotation name=\"org.freedesktop.DBus.Deprecated\" value=\"true\"/>"
|
||||
"</method>"
|
||||
<< QRegularExpression("Q_SLOTS:.*Q_DECL_DEPRECATED Q_NOREPLY inline void Method\\(\\).*\\bQDBus::NoBlock\\b",
|
||||
QRegularExpression::DotMatchesEverythingOption)
|
||||
<< QRegularExpression("Q_SLOTS:.*Q_NOREPLY void Method\\(",
|
||||
QRegularExpression::DotMatchesEverythingOption);
|
||||
|
||||
// -- signals --
|
||||
for (int i = 0; i < basicTypeCount; ++i) {
|
||||
QRegularExpression rx(QString("Q_SIGNALS:.*\\bvoid Signal\\((const )?%1\\b")
|
||||
@ -261,6 +301,15 @@ void tst_qdbusxml2cpp::process_data()
|
||||
<annotation name="org.qtproject.QtDBus.QtTypeName.Out0" value="QVariantMap"/>"
|
||||
</signal>)"
|
||||
<< rx << rx;
|
||||
|
||||
QTest::newRow("signal-deprecated")
|
||||
<< R"(<signal name="Signal">
|
||||
<annotation name="org.freedesktop.DBus.Deprecated" value="true"/>
|
||||
</signal>)"
|
||||
<< QRegularExpression(R"(Q_SIGNALS:.*\bQ_DECL_DEPRECATED void Signal\(\))",
|
||||
QRegularExpression::DotMatchesEverythingOption)
|
||||
<< QRegularExpression(R"(Q_SIGNALS:.*\bvoid Signal\(\))",
|
||||
QRegularExpression::DotMatchesEverythingOption);
|
||||
}
|
||||
|
||||
void tst_qdbusxml2cpp::process()
|
||||
|
@ -211,8 +211,8 @@ static QStringMap readExpectedFiles(const QString &fileName)
|
||||
{
|
||||
QStringMap expectedFiles;
|
||||
|
||||
QStringList lines = readLinesFromFile(fileName, Qt::SkipEmptyParts);
|
||||
foreach (const QString &line, lines) {
|
||||
const QStringList lines = readLinesFromFile(fileName, Qt::SkipEmptyParts);
|
||||
for (const QString &line : lines) {
|
||||
QString resourceFileName = line.section(QLatin1Char(' '), 0, 0, QString::SectionSkipEmpty);
|
||||
QString actualFileName = line.section(QLatin1Char(' '), 1, 1, QString::SectionSkipEmpty);
|
||||
expectedFiles[resourceFileName] = actualFileName;
|
||||
@ -276,8 +276,8 @@ void tst_rcc::binary_data()
|
||||
QString localeFileName = absoluteBaseName + QLatin1String(".locale");
|
||||
QFile localeFile(localeFileName);
|
||||
if (localeFile.exists()) {
|
||||
QStringList locales = readLinesFromFile(localeFileName, Qt::SkipEmptyParts);
|
||||
foreach (const QString &locale, locales) {
|
||||
const QStringList locales = readLinesFromFile(localeFileName, Qt::SkipEmptyParts);
|
||||
for (const QString &locale : locales) {
|
||||
QString expectedFileName = QString::fromLatin1("%1.%2.%3").arg(absoluteBaseName, locale, QLatin1String("expected"));
|
||||
QStringMap expectedFiles = readExpectedFiles(expectedFileName);
|
||||
QTest::newRow(qPrintable(qrcFileInfo.baseName() + QLatin1Char('_') + locale)) << rccFileName
|
||||
@ -473,7 +473,7 @@ void tst_rcc::cleanupTestCase()
|
||||
QFileInfoList entries = dataDir.entryInfoList(QStringList() << QLatin1String("*.rcc"));
|
||||
QDir dataDepDir(m_dataPath + QLatin1String("/depfile"));
|
||||
entries += dataDepDir.entryInfoList({QLatin1String("*.d"), QLatin1String("*.qrc.cpp")});
|
||||
foreach (const QFileInfo &entry, entries)
|
||||
for (const QFileInfo &entry : std::as_const(entries))
|
||||
QFile::remove(entry.absoluteFilePath());
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user