summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorOlivier Goffart <olivier.goffart@nokia.com>2010-08-18 16:10:01 (GMT)
committerOlivier Goffart <olivier.goffart@nokia.com>2010-08-19 13:21:26 (GMT)
commit6cf0ad80bb8a168115772aa5c3b4abec3e372ccc (patch)
tree653e5ca61f01394888122a9d6e6745a6618df7bb /tests
parent380b3dbd3ec3de31fb9be72a5cfd02543d291a62 (diff)
downloadQt-6cf0ad80bb8a168115772aa5c3b4abec3e372ccc.zip
Qt-6cf0ad80bb8a168115772aa5c3b4abec3e372ccc.tar.gz
Qt-6cf0ad80bb8a168115772aa5c3b4abec3e372ccc.tar.bz2
moc: Error if the NOTIFY signal is invalid.
Previously, an invalid NOTIFY signal would be silently ignored. Now it throws an error Reviewed-by: Joao Task-number: QTBUG-7684
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/moc/error-on-wrong-notify.h53
-rw-r--r--tests/auto/moc/tst_moc.cpp22
2 files changed, 75 insertions, 0 deletions
diff --git a/tests/auto/moc/error-on-wrong-notify.h b/tests/auto/moc/error-on-wrong-notify.h
new file mode 100644
index 0000000..4b6284a
--- /dev/null
+++ b/tests/auto/moc/error-on-wrong-notify.h
@@ -0,0 +1,53 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, 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.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include <QObject>
+
+class ClassWithWrongNOTIFY : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(int foo READ foo WRITE setFoo NOTIFY fooChanged)
+
+ int m_foo;
+public:
+ void setFoo(int i) { m_foo = i; }
+ int foo() { return m_foo; }
+};
+
diff --git a/tests/auto/moc/tst_moc.cpp b/tests/auto/moc/tst_moc.cpp
index d3a7e03..f9c3ccb 100644
--- a/tests/auto/moc/tst_moc.cpp
+++ b/tests/auto/moc/tst_moc.cpp
@@ -492,6 +492,7 @@ private slots:
void warnOnVirtualSignal();
void QTBUG5590_dummyProperty();
void QTBUG12260_defaultTemplate();
+ void notifyError();
signals:
void sigWithUnsignedArg(unsigned foo);
void sigWithSignedArg(signed foo);
@@ -1362,6 +1363,27 @@ void tst_Moc::QTBUG12260_defaultTemplate()
QVERIFY(QTBUG12260_defaultTemplate_Object::staticMetaObject.indexOfSlot("doAnotherThing(bool,bool)") != -1);
}
+void tst_Moc::notifyError()
+{
+#ifdef MOC_CROSS_COMPILED
+ QSKIP("Not tested when cross-compiled", SkipAll);
+#endif
+#if defined(Q_OS_LINUX) && defined(Q_CC_GNU) && !defined(QT_NO_PROCESS)
+ QProcess proc;
+ proc.start("moc", QStringList(srcify("error-on-wrong-notify.h")));
+ QVERIFY(proc.waitForFinished());
+ QCOMPARE(proc.exitCode(), 1);
+ QCOMPARE(proc.exitStatus(), QProcess::NormalExit);
+ QByteArray mocOut = proc.readAllStandardOutput();
+ QVERIFY(mocOut.isEmpty());
+ QString mocError = QString::fromLocal8Bit(proc.readAllStandardError());
+ QCOMPARE(mocError, QString(SRCDIR) +
+ QString("/error-on-wrong-notify.h:52: Error: NOTIFY signal 'fooChanged' of property 'foo' does not exist in class ClassWithWrongNOTIFY.\n"));
+#else
+ QSKIP("Only tested on linux/gcc", SkipAll);
+#endif
+}
+
QTEST_APPLESS_MAIN(tst_Moc)
#include "tst_moc.moc"