summaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/corelib/global/qlogging/app/main.cpp7
-rw-r--r--tests/auto/corelib/global/qlogging/tst_qlogging.cpp48
-rw-r--r--tests/auto/corelib/io/qdebug/tst_qdebug.cpp28
-rw-r--r--tests/auto/corelib/kernel/qmimedata/tst_qmimedata.cpp2
-rw-r--r--tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp9
-rw-r--r--tests/auto/corelib/tools/qstringbuilder/qstringbuilder1/stringbuilder.cpp30
-rw-r--r--tests/auto/tools/qdbusxml2cpp/qdbusxml2cpp.pro5
-rw-r--r--tests/auto/tools/qdbusxml2cpp/tst_qdbusxml2cpp.cpp263
-rw-r--r--tests/auto/tools/tools.pro2
9 files changed, 330 insertions, 64 deletions
diff --git a/tests/auto/corelib/global/qlogging/app/main.cpp b/tests/auto/corelib/global/qlogging/app/main.cpp
index dfa52315c7..2f5a975e43 100644
--- a/tests/auto/corelib/global/qlogging/app/main.cpp
+++ b/tests/auto/corelib/global/qlogging/app/main.cpp
@@ -51,8 +51,15 @@ int main(int argc, char **argv)
QCoreApplication app(argc, argv);
app.setApplicationName("tst_qlogging");
+ qSetMessagePattern("[%{type}] %{message}");
+
qDebug("qDebug");
qWarning("qWarning");
qCritical("qCritical");
+
+ qSetMessagePattern(QString());
+
+ qDebug("qDebug2");
+
return 0;
}
diff --git a/tests/auto/corelib/global/qlogging/tst_qlogging.cpp b/tests/auto/corelib/global/qlogging/tst_qlogging.cpp
index aaec46fe64..5474b9aa3b 100644
--- a/tests/auto/corelib/global/qlogging/tst_qlogging.cpp
+++ b/tests/auto/corelib/global/qlogging/tst_qlogging.cpp
@@ -73,13 +73,13 @@ int s_line;
const char *s_function;
static QString s_message;
-void customMessageHandler(QtMsgType type, const QMessageLogContext &context, const char *msg)
+void customMessageHandler(QtMsgType type, const QMessageLogContext &context, const QString &msg)
{
s_type = type;
s_file = context.file;
s_line = context.line;
s_function = context.function;
- s_message = QString::fromLocal8Bit(msg);
+ s_message = msg;
}
void customMsgHandler(QtMsgType type, const char *msg)
@@ -101,7 +101,7 @@ void tst_qmessagehandler::initTestCase()
void tst_qmessagehandler::cleanup()
{
qInstallMsgHandler(0);
- qInstallMessageHandler(0);
+ qInstallMessageHandler((QtMessageHandler)0);
s_type = QtFatalMsg;
s_file = 0;
s_line = 0;
@@ -117,7 +117,7 @@ void tst_qmessagehandler::defaultHandler()
void tst_qmessagehandler::installMessageHandler()
{
- QMessageHandler oldHandler = qInstallMessageHandler(customMessageHandler);
+ QtMessageHandler oldHandler = qInstallMessageHandler(customMessageHandler);
qDebug("installMessageHandler"); int line = __LINE__;
@@ -127,7 +127,7 @@ void tst_qmessagehandler::installMessageHandler()
QCOMPARE(s_function, Q_FUNC_INFO);
QCOMPARE(s_line, line);
- QMessageHandler myHandler = qInstallMessageHandler(oldHandler);
+ QtMessageHandler myHandler = qInstallMessageHandler(oldHandler);
QCOMPARE((void*)myHandler, (void*)customMessageHandler);
}
@@ -630,13 +630,16 @@ void tst_qmessagehandler::cleanupFuncinfo()
void tst_qmessagehandler::qMessagePattern()
{
QProcess process;
+ const QString appExe = m_appDir + "/app";
+ //
+ // test QT_MESSAGE_PATTERN
+ //
QStringList environment = QProcess::systemEnvironment();
// %{file} is tricky because of shadow builds
environment.prepend("QT_MESSAGE_PATTERN=\"%{type} %{appname} %{line} %{function} %{message}\"");
process.setEnvironment(environment);
- QString appExe = m_appDir + "/app";
process.start(appExe);
QVERIFY2(process.waitForStarted(), qPrintable(
QString::fromLatin1("Could not start %1: %2").arg(appExe, process.errorString())));
@@ -649,9 +652,10 @@ void tst_qmessagehandler::qMessagePattern()
QVERIFY(output.contains("debug 45 T::T static constructor"));
// we can't be sure whether the QT_MESSAGE_PATTERN is already destructed
QVERIFY(output.contains("static destructor"));
- QVERIFY(output.contains("debug tst_qlogging 54 main qDebug"));
- QVERIFY(output.contains("warning tst_qlogging 55 main qWarning"));
- QVERIFY(output.contains("critical tst_qlogging 56 main qCritical"));
+ QVERIFY(output.contains("debug tst_qlogging 56 main qDebug"));
+ QVERIFY(output.contains("warning tst_qlogging 57 main qWarning"));
+ QVERIFY(output.contains("critical tst_qlogging 58 main qCritical"));
+ QVERIFY(output.contains("debug tst_qlogging 62 main qDebug2"));
environment = QProcess::systemEnvironment();
environment.prepend("QT_MESSAGE_PATTERN=\"PREFIX: %{unknown} %{message}\"");
@@ -668,6 +672,32 @@ void tst_qmessagehandler::qMessagePattern()
QVERIFY(output.contains("QT_MESSAGE_PATTERN: Unknown placeholder %{unknown}"));
QVERIFY(output.contains("PREFIX: qDebug"));
+
+ //
+ // test qSetMessagePattern
+ //
+ QMutableListIterator<QString> iter(environment);
+ while (iter.hasNext()) {
+ if (iter.next().startsWith("QT_MESSAGE_PATTERN"))
+ iter.remove();
+ }
+ process.setEnvironment(environment);
+
+ process.start(appExe);
+ QVERIFY2(process.waitForStarted(), qPrintable(
+ QString::fromLatin1("Could not start %1: %2").arg(appExe, process.errorString())));
+ process.waitForFinished();
+
+ output = process.readAllStandardError();
+ //qDebug() << output;
+ QByteArray expected = "static constructor\n"
+ "[debug] qDebug\n"
+ "[warning] qWarning\n"
+ "[critical] qCritical\n";
+#ifdef Q_OS_WIN
+ output.replace("\r\n", "\n");
+#endif
+ QCOMPARE(QString::fromLatin1(output), QString::fromLatin1(expected));
}
QTEST_MAIN(tst_qmessagehandler)
diff --git a/tests/auto/corelib/io/qdebug/tst_qdebug.cpp b/tests/auto/corelib/io/qdebug/tst_qdebug.cpp
index 12f7e28a1d..035c781e4a 100644
--- a/tests/auto/corelib/io/qdebug/tst_qdebug.cpp
+++ b/tests/auto/corelib/io/qdebug/tst_qdebug.cpp
@@ -74,12 +74,12 @@ void tst_QDebug::assignment() const
}
static QtMsgType s_msgType;
-static QByteArray s_msg;
+static QString s_msg;
static QByteArray s_file;
static int s_line;
static QByteArray s_function;
-static void myMessageHandler(QtMsgType type, const QMessageLogContext &context, const char *msg)
+static void myMessageHandler(QtMsgType type, const QMessageLogContext &context, const QString &msg)
{
s_msg = msg;
s_msgType = type;
@@ -94,7 +94,7 @@ static void myMessageHandler(QtMsgType type, const QMessageLogContext &context,
class MessageHandlerSetter
{
public:
- MessageHandlerSetter(QMessageHandler newMessageHandler)
+ MessageHandlerSetter(QtMessageHandler newMessageHandler)
: oldMessageHandler(qInstallMessageHandler(newMessageHandler))
{ }
@@ -104,7 +104,7 @@ public:
}
private:
- QMessageHandler oldMessageHandler;
+ QtMessageHandler oldMessageHandler;
};
/*! \internal
@@ -116,7 +116,7 @@ void tst_QDebug::warningWithoutDebug() const
{ qWarning() << "A qWarning() message"; }
QString file = __FILE__; int line = __LINE__ - 1; QString function = Q_FUNC_INFO;
QCOMPARE(s_msgType, QtWarningMsg);
- QCOMPARE(QString::fromLatin1(s_msg.data()), QString::fromLatin1("A qWarning() message "));
+ QCOMPARE(s_msg, QString::fromLatin1("A qWarning() message "));
QCOMPARE(QString::fromLatin1(s_file), file);
QCOMPARE(s_line, line);
QCOMPARE(QString::fromLatin1(s_function), function);
@@ -131,7 +131,7 @@ void tst_QDebug::criticalWithoutDebug() const
{ qCritical() << "A qCritical() message"; }
QString file = __FILE__; int line = __LINE__ - 1; QString function = Q_FUNC_INFO;
QCOMPARE(s_msgType, QtCriticalMsg);
- QCOMPARE(QString::fromLatin1(s_msg), QString::fromLatin1("A qCritical() message "));
+ QCOMPARE(s_msg, QString::fromLatin1("A qCritical() message "));
QCOMPARE(QString::fromLatin1(s_file), file);
QCOMPARE(s_line, line);
QCOMPARE(QString::fromLatin1(s_function), function);
@@ -143,7 +143,7 @@ void tst_QDebug::debugWithBool() const
{ qDebug() << false << true; }
QString file = __FILE__; int line = __LINE__ - 1; QString function = Q_FUNC_INFO;
QCOMPARE(s_msgType, QtDebugMsg);
- QCOMPARE(QString::fromLatin1(s_msg), QString::fromLatin1("false true "));
+ QCOMPARE(s_msg, QString::fromLatin1("false true "));
QCOMPARE(QString::fromLatin1(s_file), file);
QCOMPARE(s_line, line);
QCOMPARE(QString::fromLatin1(s_function), function);
@@ -161,7 +161,7 @@ void tst_QDebug::veryLongWarningMessage() const
}
QString file = __FILE__; int line = __LINE__ - 2; QString function = Q_FUNC_INFO;
QCOMPARE(s_msgType, QtWarningMsg);
- QCOMPARE(QString::fromLatin1(s_msg), QString::fromLatin1("Test output:\n")+test+QString::fromLatin1("\nend"));
+ QCOMPARE(s_msg, QString::fromLatin1("Test output:\n")+test+QString::fromLatin1("\nend"));
QCOMPARE(QString::fromLatin1(s_file), file);
QCOMPARE(s_line, line);
QCOMPARE(QString::fromLatin1(s_function), function);
@@ -178,7 +178,7 @@ void tst_QDebug::qDebugQStringRef() const
{ qDebug() << inRef; }
QString file = __FILE__; int line = __LINE__ - 1; QString function = Q_FUNC_INFO;
QCOMPARE(s_msgType, QtDebugMsg);
- QCOMPARE(QString::fromLatin1(s_msg), QString::fromLatin1("\"input\" "));
+ QCOMPARE(s_msg, QString::fromLatin1("\"input\" "));
QCOMPARE(QString::fromLatin1(s_file), file);
QCOMPARE(s_line, line);
QCOMPARE(QString::fromLatin1(s_function), function);
@@ -192,7 +192,7 @@ void tst_QDebug::qDebugQStringRef() const
{ qDebug() << inRef; }
QString file = __FILE__; int line = __LINE__ - 1; QString function = Q_FUNC_INFO;
QCOMPARE(s_msgType, QtDebugMsg);
- QCOMPARE(QString::fromLatin1(s_msg), QString::fromLatin1("\"\" "));
+ QCOMPARE(s_msg, QString::fromLatin1("\"\" "));
QCOMPARE(QString::fromLatin1(s_file), file);
QCOMPARE(s_line, line);
QCOMPARE(QString::fromLatin1(s_function), function);
@@ -205,7 +205,7 @@ void tst_QDebug::qDebugQLatin1String() const
{ qDebug() << QLatin1String("foo") << QLatin1String("") << QLatin1String("barbaz", 3); }
QString file = __FILE__; int line = __LINE__ - 1; QString function = Q_FUNC_INFO;
QCOMPARE(s_msgType, QtDebugMsg);
- QCOMPARE(QString::fromLatin1(s_msg), QString::fromLatin1("\"foo\" \"\" \"bar\" "));
+ QCOMPARE(s_msg, QString::fromLatin1("\"foo\" \"\" \"bar\" "));
QCOMPARE(QString::fromLatin1(s_file), file);
QCOMPARE(s_line, line);
QCOMPARE(QString::fromLatin1(s_function), function);
@@ -214,11 +214,11 @@ void tst_QDebug::qDebugQLatin1String() const
void tst_QDebug::defaultMessagehandler() const
{
MessageHandlerSetter mhs(0);
- QMessageHandler defaultMessageHandler1 = qInstallMessageHandler(0);
- QMessageHandler defaultMessageHandler2 = qInstallMessageHandler(myMessageHandler);
+ QtMessageHandler defaultMessageHandler1 = qInstallMessageHandler((QtMessageHandler)0);
+ QtMessageHandler defaultMessageHandler2 = qInstallMessageHandler(myMessageHandler);
bool same = (*defaultMessageHandler1 == *defaultMessageHandler2);
QVERIFY(same);
- QMessageHandler messageHandler = qInstallMessageHandler(0);
+ QtMessageHandler messageHandler = qInstallMessageHandler((QtMessageHandler)0);
same = (*messageHandler == *myMessageHandler);
QVERIFY(same);
}
diff --git a/tests/auto/corelib/kernel/qmimedata/tst_qmimedata.cpp b/tests/auto/corelib/kernel/qmimedata/tst_qmimedata.cpp
index f9a6bae087..dc9fc19a21 100644
--- a/tests/auto/corelib/kernel/qmimedata/tst_qmimedata.cpp
+++ b/tests/auto/corelib/kernel/qmimedata/tst_qmimedata.cpp
@@ -97,7 +97,7 @@ void tst_QMimeData::colorData() const
QCOMPARE(qvariant_cast<QColor>(mimeData.colorData()), red);
// change, verify
- mimeData.setColorData(Qt::blue);
+ mimeData.setColorData(QColor(Qt::blue));
QVERIFY(mimeData.hasColor());
QCOMPARE(qvariant_cast<QColor>(mimeData.colorData()), blue);
}
diff --git a/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp b/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp
index 869eaf45b7..569e448d88 100644
--- a/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp
+++ b/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp
@@ -237,8 +237,6 @@ private slots:
void saveLoadCustomTypes();
- void globalColor();
-
void variantMap();
void variantHash();
@@ -2510,13 +2508,6 @@ void tst_QVariant::url()
QCOMPARE(v3.toString(), str);
}
-void tst_QVariant::globalColor()
-{
- QVariant variant(Qt::blue);
- QVERIFY(variant.type() == QVariant::Color);
- QVERIFY(qvariant_cast<QColor>(variant) == QColor(Qt::blue));
-}
-
void tst_QVariant::variantMap()
{
QMap<QString, QVariant> map;
diff --git a/tests/auto/corelib/tools/qstringbuilder/qstringbuilder1/stringbuilder.cpp b/tests/auto/corelib/tools/qstringbuilder/qstringbuilder1/stringbuilder.cpp
index 2badbc2133..d0f82a38b7 100644
--- a/tests/auto/corelib/tools/qstringbuilder/qstringbuilder1/stringbuilder.cpp
+++ b/tests/auto/corelib/tools/qstringbuilder/qstringbuilder1/stringbuilder.cpp
@@ -107,21 +107,6 @@ void runScenario()
QCOMPARE(r, r3);
#endif
- {
- static const QStaticStringData<12> literalData = {
- Q_STATIC_STRING_DATA_HEADER_INITIALIZER(12),
- { 's', 'o', 'm', 'e', ' ', 'l', 'i', 't', 'e', 'r', 'a', 'l' }
- };
- static QStringDataPtr literal = { literalData.data_ptr() };
-
- r = literal;
- QCOMPARE(r, string);
- r = r Q literal;
- QCOMPARE(r, r2);
- r = literal Q literal;
- QCOMPARE(r, r2);
- }
-
#ifndef QT_NO_CAST_FROM_ASCII
r = string P LITERAL;
QCOMPARE(r, r2);
@@ -226,21 +211,6 @@ void runScenario()
QCOMPARE(r, ba);
}
- {
- static const QStaticByteArrayData<12> literalData = {
- Q_STATIC_BYTE_ARRAY_DATA_HEADER_INITIALIZER(12),
- { 's', 'o', 'm', 'e', ' ', 'l', 'i', 't', 'e', 'r', 'a', 'l' }
- };
- static QByteArrayDataPtr literal = { literalData.data_ptr() };
-
- QByteArray ba = literal;
- QCOMPARE(ba, QByteArray(LITERAL));
- ba = ba Q literal;
- QCOMPARE(ba, QByteArray(LITERAL LITERAL));
- ba = literal Q literal;
- QCOMPARE(ba, QByteArray(LITERAL LITERAL));
- }
-
//operator QString +=
{
QString str = QString::fromUtf8(UTF8_LITERAL);
diff --git a/tests/auto/tools/qdbusxml2cpp/qdbusxml2cpp.pro b/tests/auto/tools/qdbusxml2cpp/qdbusxml2cpp.pro
new file mode 100644
index 0000000000..8c29ff47c4
--- /dev/null
+++ b/tests/auto/tools/qdbusxml2cpp/qdbusxml2cpp.pro
@@ -0,0 +1,5 @@
+CONFIG += testcase
+QT = core testlib
+TARGET = tst_qdbusxml2cpp
+SOURCES += tst_qdbusxml2cpp.cpp
+QMAKE_CXXFLAGS += $$QT_CFLAGS_DBUS
diff --git a/tests/auto/tools/qdbusxml2cpp/tst_qdbusxml2cpp.cpp b/tests/auto/tools/qdbusxml2cpp/tst_qdbusxml2cpp.cpp
new file mode 100644
index 0000000000..aaa2bb4235
--- /dev/null
+++ b/tests/auto/tools/qdbusxml2cpp/tst_qdbusxml2cpp.cpp
@@ -0,0 +1,263 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Intel Corporation.
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtTest/QtTest>
+#include <QtCore/QProcess>
+#include <QtCore/QRegularExpression>
+#include <dbus/dbus.h>
+
+class tst_qdbusxml2cpp : public QObject
+{
+ Q_OBJECT
+
+ enum { Interface, Adaptor };
+
+private slots:
+ void initTestCase_data();
+ void process_data();
+ void process();
+};
+
+struct BasicTypeList {
+ char dbusType[3];
+ char cppType[24];
+};
+static const BasicTypeList basicTypeList[] =
+{
+ { DBUS_TYPE_BOOLEAN_AS_STRING, "bool" },
+ { DBUS_TYPE_BYTE_AS_STRING, "uchar" },
+ { DBUS_TYPE_INT16_AS_STRING, "short" },
+ { DBUS_TYPE_UINT16_AS_STRING, "ushort" },
+ { DBUS_TYPE_INT32_AS_STRING, "int" },
+ { DBUS_TYPE_UINT32_AS_STRING, "uint" },
+ { DBUS_TYPE_INT64_AS_STRING, "qlonglong" },
+ { DBUS_TYPE_UINT64_AS_STRING, "qulonglong" },
+ { DBUS_TYPE_DOUBLE_AS_STRING, "double" },
+ { DBUS_TYPE_STRING_AS_STRING, "QString" },
+ { DBUS_TYPE_OBJECT_PATH_AS_STRING, "QDBusObjectPath" },
+ { DBUS_TYPE_SIGNATURE_AS_STRING, "QDBusSignature" },
+#ifdef DBUS_TYPE_UNIX_FD_AS_STRING
+ { DBUS_TYPE_UNIX_FD_AS_STRING, "QDBusUnixFileDescriptor" },
+#endif
+ { DBUS_TYPE_VARIANT_AS_STRING, "QDBusVariant" },
+ { DBUS_TYPE_ARRAY_AS_STRING DBUS_TYPE_BYTE_AS_STRING, "QByteArray" },
+ { DBUS_TYPE_ARRAY_AS_STRING DBUS_TYPE_STRING_AS_STRING, "QStringList" },
+ { DBUS_TYPE_ARRAY_AS_STRING DBUS_TYPE_VARIANT_AS_STRING, "QVariantList" }
+};
+static const int basicTypeCount = sizeof(basicTypeList) / sizeof(basicTypeList[0]);
+
+static QString stripHeader(QString output)
+{
+ static QRegularExpression header("^.*?(?=\\Rclass)", QRegularExpression::DotMatchesEverythingOption);
+ return output.remove(header);
+}
+
+void tst_qdbusxml2cpp::initTestCase_data()
+{
+ QTest::addColumn<int>("outputMode");
+ QTest::addColumn<QString>("commandLineArg");
+ QTest::newRow("interface") << int(Interface) << "-p";
+ QTest::newRow("adaptor") << int(Adaptor) << "-a";
+}
+
+void tst_qdbusxml2cpp::process_data()
+{
+ QTest::addColumn<QString>("xmlSnippet");
+ QTest::addColumn<QRegularExpression>("interfaceSearch");
+ QTest::addColumn<QRegularExpression>("adaptorSearch");
+
+ // -- class info --
+ QTest::newRow("classinfo")
+ << ""
+ << QRegularExpression("staticInterfaceName\\(\\)\\s+"
+ "{ return \"local\\.name\\.is\\.not\\.important\"\\; }")
+ << QRegularExpression("Q_CLASSINFO\\(\"D-Bus Interface\", \"local\\.name\\.is\\.not\\.important\"\\)");
+
+ // -- properties --
+ for (int i = 0; i < basicTypeCount; ++i) {
+ QRegularExpression rx(QString("\\bQ_PROPERTY\\(%1 PropertyIsPresent "
+ "READ propertyIsPresent WRITE setPropertyIsPresent\\b")
+ .arg(basicTypeList[i].cppType));
+ QTest::newRow(QByteArray("property-") + basicTypeList[i].dbusType)
+ << QString("<property type=\"%1\" name=\"PropertyIsPresent\" access=\"readwrite\" />")
+ .arg(basicTypeList[i].dbusType)
+ << rx << rx;
+ }
+
+ QTest::newRow("property-readonly-multi")
+ << "<property type=\"i\" name=\"Value\" access=\"read\"></property>"
+ << QRegularExpression("\\bQ_PROPERTY\\(int Value READ value(?! WRITE)")
+ << QRegularExpression("\\bQ_PROPERTY\\(int Value READ value(?! WRITE)");
+ QTest::newRow("property-readonly")
+ << "<property type=\"i\" name=\"Value\" access=\"read\" />"
+ << QRegularExpression("\\bQ_PROPERTY\\(int Value READ value(?! WRITE)")
+ << QRegularExpression("\\bQ_PROPERTY\\(int Value READ value(?! WRITE)");
+ QTest::newRow("property-writeonly")
+ << "<property type=\"i\" name=\"Value\" access=\"write\" />"
+ << QRegularExpression("\\bQ_PROPERTY\\(int Value WRITE setValue\\b")
+ << QRegularExpression("\\bQ_PROPERTY\\(int Value WRITE setValue\\b");
+
+ QTest::newRow("property-getter-setter")
+ << "<property type=\"b\" name=\"Enabled\" access=\"readwrite\">"
+ "<annotation name=\"org.qtproject.QtDBus.PropertyGetter\" value=\"wasEnabled\" />"
+ "<annotation name=\"org.qtproject.QtDBus.PropertySetter\" value=\"setEnabledFlag\" />"
+ "</property>"
+ << QRegularExpression("\\bQ_PROPERTY\\(bool Enabled READ wasEnabled WRITE setEnabledFlag\\b.*"
+ "\\bbool wasEnabled\\(\\) const.*" // no semi-colon
+ "\\bvoid setEnabledFlag\\(bool", QRegularExpression::DotMatchesEverythingOption)
+ << QRegularExpression("\\bQ_PROPERTY\\(bool Enabled READ wasEnabled WRITE setEnabledFlag\\b.*"
+ "\\bbool wasEnabled\\(\\) const;.*" // has semi-colon
+ "\\bvoid setEnabledFlag\\(bool", QRegularExpression::DotMatchesEverythingOption);
+
+ QTest::newRow("property-complex")
+ << "<property type=\"(ii)\" name=\"Position\" access=\"readwrite\">"
+ "<annotation name=\"org.qtproject.QtDBus.QtTypeName\" value=\"Point\"/>"
+ "</property>"
+ << QRegularExpression("\\bQ_PROPERTY\\(Point Position READ position WRITE setPosition\\b")
+ << QRegularExpression("\\bQ_PROPERTY\\(Point Position READ position WRITE setPosition\\b");
+
+ // -- methods --
+ for (int i = 0; i < basicTypeCount; ++i) {
+ QTest::newRow(QByteArray("method-") + basicTypeList[i].dbusType)
+ << QString("<method name=\"Method\">"
+ "<arg type=\"%1\" direction=\"out\"/>"
+ "<arg type=\"%1\" direction=\"in\"/>"
+ "</method>")
+ .arg(basicTypeList[i].dbusType)
+ << QRegularExpression(QString("Q_SLOTS:.*\\bQDBusPendingReply<%1> Method\\((const )?%1 ")
+ .arg(basicTypeList[i].cppType), QRegularExpression::DotMatchesEverythingOption)
+ << QRegularExpression(QString("Q_SLOTS:.*\\b%1 Method\\((const )?%1 ")
+ .arg(basicTypeList[i].cppType), QRegularExpression::DotMatchesEverythingOption);
+ }
+
+ QTest::newRow("method-complex")
+ << "<method name=\"Method\">"
+ "<arg type=\"(dd)\" direction=\"in\"/>"
+ "<arg type=\"(ii)\" direction=\"out\"/>"
+ "<annotation name=\"org.qtproject.QtDBus.QtTypeName.Out0\" value=\"Point\"/>"
+ "<annotation name=\"org.qtproject.QtDBus.QtTypeName.In0\" value=\"PointF\"/>"
+ "</method>"
+ << QRegularExpression("Q_SLOTS:.*\\bQDBusPendingReply<Point> Method\\(PointF ",
+ QRegularExpression::DotMatchesEverythingOption)
+ << QRegularExpression("Q_SLOTS:.*\\bPoint Method\\(PointF ",
+ QRegularExpression::DotMatchesEverythingOption);
+
+ QTest::newRow("method-ss")
+ << "<method name=\"Method\">"
+ "<arg type=\"s\" direction=\"in\"/>"
+ "<arg type=\"s\" direction=\"in\"/>"
+ "<arg type=\"s\" direction=\"out\"/>"
+ "<arg type=\"s\" direction=\"out\"/>"
+ "</method>"
+ << QRegularExpression("Q_SLOTS:.*QDBusPendingReply<QString, QString> Method\\(const QString &\\w*, const QString &",
+ QRegularExpression::DotMatchesEverythingOption)
+ << QRegularExpression("Q_SLOTS:.*QString Method\\(const QString &\\w*, const QString &\\w*, QString &",
+ QRegularExpression::DotMatchesEverythingOption);
+
+ // -- signals --
+ for (int i = 0; i < basicTypeCount; ++i) {
+ QRegularExpression rx(QString("Q_SIGNALS:.*\\bvoid Signal\\((const )?%1\\b")
+ .arg(basicTypeList[i].cppType),
+ QRegularExpression::DotMatchesEverythingOption);
+ QTest::newRow(QByteArray("signal-") + basicTypeList[i].dbusType)
+ << QString("<signal name=\"Signal\">"
+ "<arg type=\"%1\"/>"
+ "</signal>")
+ .arg(basicTypeList[i].dbusType)
+ << rx << rx;
+ }
+}
+
+void tst_qdbusxml2cpp::process()
+{
+ QFETCH(QString, xmlSnippet);
+ QFETCH(QRegularExpression, interfaceSearch);
+ QFETCH(QRegularExpression, adaptorSearch);
+ QVERIFY2(interfaceSearch.isValid(), qPrintable(interfaceSearch.errorString()));
+ QVERIFY2(adaptorSearch.isValid(), qPrintable(adaptorSearch.errorString()));
+
+ // test both interface and adaptor generation
+ QFETCH_GLOBAL(int, outputMode);
+ QFETCH_GLOBAL(QString, commandLineArg);
+
+ // Run the tool
+ QProcess process;
+ process.start("qdbusxml2cpp", QStringList() << commandLineArg << "-" << "-N");
+ QVERIFY2(process.waitForStarted(), qPrintable(process.errorString()));
+
+ // feed it our XML data
+ static const char xmlHeader[] =
+ "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n"
+ DBUS_INTROSPECT_1_0_XML_DOCTYPE_DECL_NODE // \n is included
+ "<node>\n"
+ " <interface name=\"local.name.is.not.important\">\n"
+ " <!-- begin data -->\n";
+ static const char xmlFooter[] = "\n"
+ " <!-- end data -->\n"
+ " </interface>\n"
+ "</node>\n";
+
+ process.write(xmlHeader, int(sizeof xmlHeader) - 1);
+ process.write(xmlSnippet.toLatin1());
+ process.write(xmlFooter, int(sizeof xmlFooter) - 1);
+ while (process.bytesToWrite())
+ QVERIFY2(process.waitForBytesWritten(), qPrintable(process.errorString()));
+ // fprintf(stderr, "%s%s%s", xmlHeader, xmlSnippet.toLatin1().constData(), xmlFooter);
+
+ process.closeWriteChannel();
+ QVERIFY2(process.waitForFinished(), qPrintable(process.errorString()));
+
+ QByteArray errOutput = process.readAllStandardError();
+ QVERIFY2(errOutput.isEmpty(), errOutput);
+ QCOMPARE(process.exitCode(), 0);
+
+ QByteArray fullOutput = process.readAll();
+ QString output = stripHeader(QString::fromLatin1(fullOutput));
+ QVERIFY2(!output.isEmpty(), fullOutput);
+ if (outputMode == Interface)
+ QVERIFY2(output.count(interfaceSearch) == 1, qPrintable(interfaceSearch.pattern() + "\nin\n" + output));
+ else
+ QVERIFY2(output.count(adaptorSearch) == 1, qPrintable(adaptorSearch.pattern() + "\nin\n" + output));
+}
+
+QTEST_MAIN(tst_qdbusxml2cpp)
+
+#include "tst_qdbusxml2cpp.moc"
diff --git a/tests/auto/tools/tools.pro b/tests/auto/tools/tools.pro
index 0a2821773f..4cc3d62a43 100644
--- a/tests/auto/tools/tools.pro
+++ b/tests/auto/tools/tools.pro
@@ -5,4 +5,4 @@ SUBDIRS=\
moc \
rcc \
-contains(QT_CONFIG, dbus):SUBDIRS += qdbuscpp2xml
+contains(QT_CONFIG, dbus):SUBDIRS += qdbuscpp2xml qdbusxml2cpp