summaryrefslogtreecommitdiffstats
path: root/tests/auto/tools
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/tools')
-rw-r--r--tests/auto/tools/moc/moc.pro5
-rw-r--r--tests/auto/tools/moc/qtbug-35657-gadget.h51
-rw-r--r--tests/auto/tools/moc/related-metaobjects-in-gadget.h54
-rw-r--r--tests/auto/tools/moc/related-metaobjects-in-namespaces.h60
-rw-r--r--tests/auto/tools/moc/tst_moc.cpp73
-rw-r--r--tests/auto/tools/uic/baseline/translation/Dialog_without_Buttons_tr.h50
-rw-r--r--tests/auto/tools/uic/tst_uic.cpp52
7 files changed, 342 insertions, 3 deletions
diff --git a/tests/auto/tools/moc/moc.pro b/tests/auto/tools/moc/moc.pro
index 779e992881..320887637d 100644
--- a/tests/auto/tools/moc/moc.pro
+++ b/tests/auto/tools/moc/moc.pro
@@ -24,7 +24,10 @@ HEADERS += using-namespaces.h no-keywords.h task87883.h c-comments.h backslash-n
parse-defines.h \
function-with-attributes.h \
plugin_metadata.h \
- single-quote-digit-separator-n3781.h
+ single-quote-digit-separator-n3781.h \
+ related-metaobjects-in-namespaces.h \
+ qtbug-35657-gadget.h \
+ related-metaobjects-in-gadget.h
if(*-g++*|*-icc*|*-clang*|*-llvm):!irix-*:!win32-*: HEADERS += os9-newlines.h win-newlines.h
diff --git a/tests/auto/tools/moc/qtbug-35657-gadget.h b/tests/auto/tools/moc/qtbug-35657-gadget.h
new file mode 100644
index 0000000000..1f25ce1b1d
--- /dev/null
+++ b/tests/auto/tools/moc/qtbug-35657-gadget.h
@@ -0,0 +1,51 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** 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
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** 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, Digia gives you certain additional
+** rights. These rights are described in the Digia 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.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QObject>
+
+namespace QTBUG_35657 {
+ class A {
+ Q_GADGET
+ Q_ENUMS(SomeEnum)
+ public:
+ enum SomeEnum { SomeEnumValue = 0 };
+ };
+}
diff --git a/tests/auto/tools/moc/related-metaobjects-in-gadget.h b/tests/auto/tools/moc/related-metaobjects-in-gadget.h
new file mode 100644
index 0000000000..5665a79251
--- /dev/null
+++ b/tests/auto/tools/moc/related-metaobjects-in-gadget.h
@@ -0,0 +1,54 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** 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
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** 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, Digia gives you certain additional
+** rights. These rights are described in the Digia 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.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QObject>
+#include "qtbug-35657-gadget.h"
+
+namespace QTBUG_35657 {
+ class B : public QObject
+ {
+ Q_OBJECT
+ Q_PROPERTY(A::SomeEnum blah READ blah)
+ public:
+
+ A::SomeEnum blah() const { return A::SomeEnumValue; }
+ };
+}
diff --git a/tests/auto/tools/moc/related-metaobjects-in-namespaces.h b/tests/auto/tools/moc/related-metaobjects-in-namespaces.h
new file mode 100644
index 0000000000..0a3e9ed77d
--- /dev/null
+++ b/tests/auto/tools/moc/related-metaobjects-in-namespaces.h
@@ -0,0 +1,60 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** 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
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** 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, Digia gives you certain additional
+** rights. These rights are described in the Digia 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.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QObject>
+
+namespace QTBUG_2151 {
+ class A : public QObject {
+ Q_OBJECT
+ Q_ENUMS(SomeEnum)
+ public:
+ enum SomeEnum { SomeEnumValue = 0 };
+ };
+
+ class B : public QObject
+ {
+ Q_OBJECT
+ Q_PROPERTY(A::SomeEnum blah READ blah)
+ public:
+
+ A::SomeEnum blah() const { return A::SomeEnumValue; }
+ };
+}
diff --git a/tests/auto/tools/moc/tst_moc.cpp b/tests/auto/tools/moc/tst_moc.cpp
index 7fae29e5ca..e0e6129075 100644
--- a/tests/auto/tools/moc/tst_moc.cpp
+++ b/tests/auto/tools/moc/tst_moc.cpp
@@ -76,6 +76,8 @@
#include "cxx11-explicit-override-control.h"
#include "parse-defines.h"
+#include "related-metaobjects-in-namespaces.h"
+#include "related-metaobjects-in-gadget.h"
QT_USE_NAMESPACE
@@ -568,6 +570,9 @@ private slots:
void preprocessorOnly();
void unterminatedFunctionMacro();
void QTBUG32933_relatedObjectsDontIncludeItself();
+ void writeEnumFromUnrelatedClass();
+ void relatedMetaObjectsWithinNamespaces();
+ void relatedMetaObjectsInGadget();
signals:
void sigWithUnsignedArg(unsigned foo);
@@ -884,7 +889,7 @@ void tst_Moc::testExtraDataForEnum()
const QMetaObject *mobjUser = &EnumUserClass::staticMetaObject;
QCOMPARE(mobjUser->enumeratorCount(), 0);
- const QMetaObject **objects = mobjUser->d.relatedMetaObjects;
+ const QMetaObject * const *objects = mobjUser->d.relatedMetaObjects;
QVERIFY(objects);
QVERIFY(objects[0] == mobjSource);
QVERIFY(objects[1] == 0);
@@ -3098,12 +3103,76 @@ namespace QTBUG32933_relatedObjectsDontIncludeItself {
void tst_Moc::QTBUG32933_relatedObjectsDontIncludeItself()
{
const QMetaObject *mo = &QTBUG32933_relatedObjectsDontIncludeItself::NS::Obj::staticMetaObject;
- const QMetaObject **objects = mo->d.relatedMetaObjects;
+ const QMetaObject * const *objects = mo->d.relatedMetaObjects;
// the related objects should be empty because the enums is in the same object.
QVERIFY(!objects);
}
+class UnrelatedClass : public QObject
+{
+ Q_OBJECT
+ Q_ENUMS(UnrelatedEnum)
+public:
+ enum UnrelatedEnum {
+ UnrelatedInvalidValue = -1,
+ UnrelatedValue = 42
+ };
+};
+
+// The presence of this macro used to confuse moc and prevent
+// UnrelatedClass from being listed in the related meta objects.
+Q_DECLARE_METATYPE(UnrelatedClass::UnrelatedEnum)
+
+class TestClassReferencingUnrelatedEnum : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(UnrelatedClass::UnrelatedEnum enumProperty READ enumProperty WRITE setEnumProperty)
+public:
+ TestClassReferencingUnrelatedEnum()
+ : m_enumProperty(UnrelatedClass::UnrelatedInvalidValue)
+ {}
+
+ UnrelatedClass::UnrelatedEnum enumProperty() const {
+ return m_enumProperty;
+ }
+
+ void setEnumProperty(UnrelatedClass::UnrelatedEnum arg) {
+ m_enumProperty = arg;
+ }
+
+private:
+ UnrelatedClass::UnrelatedEnum m_enumProperty;
+};
+
+void tst_Moc::writeEnumFromUnrelatedClass()
+{
+ TestClassReferencingUnrelatedEnum obj;
+ QString enumValueAsString("UnrelatedValue");
+ obj.setProperty("enumProperty", enumValueAsString);
+ QCOMPARE(int(obj.enumProperty()), int(UnrelatedClass::UnrelatedValue));
+}
+
+
+
+void tst_Moc::relatedMetaObjectsWithinNamespaces()
+{
+ const QMetaObject *relatedMo = &QTBUG_2151::A::staticMetaObject;
+
+ const QMetaObject *testMo = &QTBUG_2151::B::staticMetaObject;
+ QVERIFY(testMo->d.relatedMetaObjects);
+ QVERIFY(testMo->d.relatedMetaObjects[0] == relatedMo);
+}
+
+void tst_Moc::relatedMetaObjectsInGadget()
+{
+ const QMetaObject *relatedMo = &QTBUG_35657::A::staticMetaObject;
+
+ const QMetaObject *testMo = &QTBUG_35657::B::staticMetaObject;
+ QVERIFY(testMo->d.relatedMetaObjects);
+ QVERIFY(testMo->d.relatedMetaObjects[0] == relatedMo);
+}
+
QTEST_MAIN(tst_Moc)
// the generated code must compile with QT_NO_KEYWORDS
diff --git a/tests/auto/tools/uic/baseline/translation/Dialog_without_Buttons_tr.h b/tests/auto/tools/uic/baseline/translation/Dialog_without_Buttons_tr.h
new file mode 100644
index 0000000000..597728e207
--- /dev/null
+++ b/tests/auto/tools/uic/baseline/translation/Dialog_without_Buttons_tr.h
@@ -0,0 +1,50 @@
+/********************************************************************************
+** Form generated from reading UI file 'Dialog_without_Buttons.ui'
+**
+** Created by: Qt User Interface Compiler version 5.3.0
+**
+** WARNING! All changes made in this file will be lost when recompiling UI file!
+********************************************************************************/
+
+#ifndef DIALOG_WITHOUT_BUTTONS_TR_H
+#define DIALOG_WITHOUT_BUTTONS_TR_H
+
+#include <QtCore/QVariant>
+#include <QtWidgets/QAction>
+#include <QtWidgets/QApplication>
+#include <QtWidgets/QButtonGroup>
+#include <QtWidgets/QDialog>
+#include <QtWidgets/QHeaderView>
+#include <ki18n.h>
+
+QT_BEGIN_NAMESPACE
+
+class Ui_Dialog
+{
+public:
+
+ void setupUi(QDialog *Dialog)
+ {
+ if (Dialog->objectName().isEmpty())
+ Dialog->setObjectName(QStringLiteral("Dialog"));
+ Dialog->resize(400, 300);
+
+ retranslateUi(Dialog);
+
+ QMetaObject::connectSlotsByName(Dialog);
+ } // setupUi
+
+ void retranslateUi(QDialog *Dialog)
+ {
+ Dialog->setWindowTitle(i18n("Dialog", 0));
+ } // retranslateUi
+
+};
+
+namespace Ui {
+ class Dialog: public Ui_Dialog {};
+} // namespace Ui
+
+QT_END_NAMESPACE
+
+#endif // DIALOG_WITHOUT_BUTTONS_TR_H
diff --git a/tests/auto/tools/uic/tst_uic.cpp b/tests/auto/tools/uic/tst_uic.cpp
index c6e8466d89..02a19c0c33 100644
--- a/tests/auto/tools/uic/tst_uic.cpp
+++ b/tests/auto/tools/uic/tst_uic.cpp
@@ -64,9 +64,13 @@ private Q_SLOTS:
void run();
void run_data() const;
+ void runTranslation();
+
void compare();
void compare_data() const;
+ void runCompare();
+
private:
const QString m_command;
QString m_baseline;
@@ -220,5 +224,53 @@ void tst_uic::compare_data() const
}
}
+void tst_uic::runTranslation()
+{
+ QProcess process;
+
+ QDir baseline(m_baseline);
+
+ QDir generated(m_generated.path());
+ generated.mkdir(QLatin1String("translation"));
+ QString generatedFile = generated.absolutePath() + QLatin1String("/translation/Dialog_without_Buttons_tr.h");
+
+ process.start(m_command, QStringList(baseline.filePath("Dialog_without_Buttons.ui"))
+ << QString(QLatin1String("-tr")) << "i18n"
+ << QString(QLatin1String("-include")) << "ki18n.h"
+ << QString(QLatin1String("-o")) << generatedFile);
+ QVERIFY2(process.waitForStarted(), msgProcessStartFailed(m_command, process.errorString()));
+ QVERIFY(process.waitForFinished());
+ QCOMPARE(process.exitStatus(), QProcess::NormalExit);
+ QCOMPARE(process.exitCode(), 0);
+ QCOMPARE(QFileInfo(generatedFile).exists(), true);
+}
+
+
+void tst_uic::runCompare()
+{
+ QFile orgFile(m_baseline + QLatin1String("/translation/Dialog_without_Buttons_tr.h"));
+
+ QDir generated(m_generated.path());
+ QFile genFile(generated.absolutePath() + QLatin1String("/translation/Dialog_without_Buttons_tr.h"));
+
+ if (!orgFile.open(QIODevice::ReadOnly | QIODevice::Text)) {
+ QString err(QLatin1String("Could not read file: %1..."));
+ QFAIL(err.arg(orgFile.fileName()).toUtf8());
+ }
+
+ if (!genFile.open(QIODevice::ReadOnly | QIODevice::Text)) {
+ QString err(QLatin1String("Could not read file: %1..."));
+ QFAIL(err.arg(genFile.fileName()).toUtf8());
+ }
+
+ QString originalFile = orgFile.readAll();
+ originalFile.replace(QRegExp(QLatin1String("Created by: Qt User Interface Compiler version [.\\d]{5,5}")), "");
+
+ QString generatedFile = genFile.readAll();
+ generatedFile.replace(QRegExp(QLatin1String("Created by: Qt User Interface Compiler version [.\\d]{5,5}")), "");
+
+ QCOMPARE(generatedFile, originalFile);
+}
+
QTEST_MAIN(tst_uic)
#include "tst_uic.moc"