From 2ca187caa383ddc0cdebeb1dbc312405c8c871ad Mon Sep 17 00:00:00 2001 From: Albert Astals Cid Date: Fri, 10 Mar 2017 13:14:19 +0100 Subject: moc: Allow NOTIFY signals defined in parent classes Limitation is that the signal needs to be parameter-less [ChangeLog][moc] moc now supports NOTIFY signals of parent classes in Q_PROPERTY Change-Id: Iad64c96c3ec65d4be8ad9ff1a9f889938ab9bf45 Reviewed-by: Olivier Goffart (Woboq GmbH) Reviewed-by: Brett Stottlemyer --- tests/auto/tools/moc/error-on-wrong-notify.h | 2 +- tests/auto/tools/moc/tst_moc.cpp | 22 +++++++++++++++++----- 2 files changed, 18 insertions(+), 6 deletions(-) (limited to 'tests/auto/tools/moc') diff --git a/tests/auto/tools/moc/error-on-wrong-notify.h b/tests/auto/tools/moc/error-on-wrong-notify.h index 11f5e954db..9e6b27bff3 100644 --- a/tests/auto/tools/moc/error-on-wrong-notify.h +++ b/tests/auto/tools/moc/error-on-wrong-notify.h @@ -28,7 +28,7 @@ #ifndef ERROR_ON_WRONG_NOTIFY_H #define ERROR_ON_WRONG_NOTIFY_H -#include +#include class ClassWithWrongNOTIFY : public QObject { diff --git a/tests/auto/tools/moc/tst_moc.cpp b/tests/auto/tools/moc/tst_moc.cpp index 8189227cbe..55e8054a70 100644 --- a/tests/auto/tools/moc/tst_moc.cpp +++ b/tests/auto/tools/moc/tst_moc.cpp @@ -1830,13 +1830,25 @@ void tst_Moc::notifyError() const QString header = m_sourceDirectory + QStringLiteral("/error-on-wrong-notify.h"); proc.start(m_moc, QStringList(header)); QVERIFY(proc.waitForFinished()); - QCOMPARE(proc.exitCode(), 1); + QCOMPARE(proc.exitCode(), 0); QCOMPARE(proc.exitStatus(), QProcess::NormalExit); QByteArray mocOut = proc.readAllStandardOutput(); - QVERIFY(mocOut.isEmpty()); - QString mocError = QString::fromLocal8Bit(proc.readAllStandardError()); - QCOMPARE(mocError, header + - QString(":42: Error: NOTIFY signal 'fooChanged' of property 'foo' does not exist in class ClassWithWrongNOTIFY.\n")); + QVERIFY(!mocOut.isEmpty()); + QCOMPARE(proc.readAllStandardError(), QByteArray()); + + QStringList args; + args << "-c" << "-x" << "c++" << "-I" << "." + << "-I" << qtIncludePath << "-o" << "/dev/null" << "-fPIC" << "-std=c++11" << "-"; + proc.start("gcc", args); + QVERIFY(proc.waitForStarted()); + proc.write(mocOut); + proc.closeWriteChannel(); + + QVERIFY(proc.waitForFinished()); + QCOMPARE(proc.exitCode(), 1); + const QString gccOutput = QString::fromLocal8Bit(proc.readAllStandardError()); + QVERIFY(gccOutput.contains(QLatin1String("error"))); + QVERIFY(gccOutput.contains(QLatin1String("fooChanged"))); #else QSKIP("Only tested on linux/gcc"); #endif -- cgit v1.2.3