aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2020-03-27 16:00:18 +0100
committerUlf Hermann <ulf.hermann@qt.io>2020-03-30 13:46:42 +0200
commit3f0126ed86f56178fa707db629fabcc01eb31754 (patch)
tree486ee21b1c1cd37eee2eabdb43e8e125b0d10831 /tests
parent0124f73dfb779924e46eb8b319358dbbd5af2577 (diff)
qmltyperegistrar: Accept more file extensions as headers
Also, even if the file does not appear to be a header, still try to include it. People use strange file names. Change-Id: I2db7bd6aa14007a8b458c3860ba0553bb3b384b7 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/qml/qmltyperegistrar/hppheader.hpp64
-rw-r--r--tests/auto/qml/qmltyperegistrar/noextheader64
-rw-r--r--tests/auto/qml/qmltyperegistrar/tst_qmltyperegistrar.cpp17
-rw-r--r--tests/auto/qml/qmltyperegistrar/tst_qmltyperegistrar.h5
-rw-r--r--tests/auto/qml/qmltyperegistrar/tst_qmltyperegistrar.pro5
5 files changed, 152 insertions, 3 deletions
diff --git a/tests/auto/qml/qmltyperegistrar/hppheader.hpp b/tests/auto/qml/qmltyperegistrar/hppheader.hpp
new file mode 100644
index 0000000000..f5fc881b77
--- /dev/null
+++ b/tests/auto/qml/qmltyperegistrar/hppheader.hpp
@@ -0,0 +1,64 @@
+/****************************************************************************
+**
+** Copyright (C) 2020 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** 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 The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef HPPHEADER_HPP
+#define HPPHEADER_HPP
+
+#include <QtCore/qobject.h>
+#include <QtQml/qqml.h>
+
+class HppClass : public QObject
+{
+ Q_OBJECT
+ QML_ELEMENT
+ Q_PROPERTY(int eieiei READ eieiei WRITE setEieiei NOTIFY eieieiChanged)
+
+public:
+ int eieiei() const
+ {
+ return m_eieiei;
+ }
+
+public slots:
+ void setEieiei(int eieiei)
+ {
+ if (m_eieiei == eieiei)
+ return;
+
+ m_eieiei = eieiei;
+ emit eieieiChanged(m_eieiei);
+ }
+
+signals:
+ void eieieiChanged(int eieiei);
+
+private:
+ int m_eieiei;
+};
+
+#endif // HPPHEADER_HPP
diff --git a/tests/auto/qml/qmltyperegistrar/noextheader b/tests/auto/qml/qmltyperegistrar/noextheader
new file mode 100644
index 0000000000..3b6cb6d72c
--- /dev/null
+++ b/tests/auto/qml/qmltyperegistrar/noextheader
@@ -0,0 +1,64 @@
+/****************************************************************************
+**
+** Copyright (C) 2020 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** 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 The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef NOEXTHEADER
+#define NOEXTHEADER
+
+#include <QtCore/qobject.h>
+#include <QtQml/qqml.h>
+
+class Noext : public QObject
+{
+ Q_OBJECT
+ QML_ELEMENT
+ Q_PROPERTY(int gagaga READ gagaga WRITE setGagaga NOTIFY gagagaChanged)
+
+public:
+ int gagaga() const
+ {
+ return m_gagaga;
+ }
+
+public slots:
+ void setGagaga(int gagaga)
+ {
+ if (m_gagaga == gagaga)
+ return;
+
+ m_gagaga = gagaga;
+ emit gagagaChanged(m_gagaga);
+ }
+
+signals:
+ void gagagaChanged(int gagaga);
+
+private:
+ int m_gagaga;
+};
+
+#endif // NOEXTHEADER
diff --git a/tests/auto/qml/qmltyperegistrar/tst_qmltyperegistrar.cpp b/tests/auto/qml/qmltyperegistrar/tst_qmltyperegistrar.cpp
index e464820656..1aeca50653 100644
--- a/tests/auto/qml/qmltyperegistrar/tst_qmltyperegistrar.cpp
+++ b/tests/auto/qml/qmltyperegistrar/tst_qmltyperegistrar.cpp
@@ -31,11 +31,24 @@
#include <QtCore/qcoreapplication.h>
#include <QtCore/qfile.h>
-void tst_qmltyperegistrar::qmltypesHasForeign()
+void tst_qmltyperegistrar::initTestCase()
{
QFile file(QCoreApplication::applicationDirPath() + "/tst_qmltyperegistrar.qmltypes");
QVERIFY(file.open(QIODevice::ReadOnly));
- QVERIFY(file.readAll().contains("things"));
+ qmltypesData = file.readAll();
+ QVERIFY(file.atEnd());
+ QCOMPARE(file.error(), QFile::NoError);
+}
+
+void tst_qmltyperegistrar::qmltypesHasForeign()
+{
+ QVERIFY(qmltypesData.contains("things"));
+}
+
+void tst_qmltyperegistrar::qmltypesHasHppClassAndNoext()
+{
+ QVERIFY(qmltypesData.contains("HppClass"));
+ QVERIFY(qmltypesData.contains("Noext"));
}
QTEST_MAIN(tst_qmltyperegistrar)
diff --git a/tests/auto/qml/qmltyperegistrar/tst_qmltyperegistrar.h b/tests/auto/qml/qmltyperegistrar/tst_qmltyperegistrar.h
index 1cfcd25102..cee88fde7b 100644
--- a/tests/auto/qml/qmltyperegistrar/tst_qmltyperegistrar.h
+++ b/tests/auto/qml/qmltyperegistrar/tst_qmltyperegistrar.h
@@ -44,7 +44,12 @@ class tst_qmltyperegistrar : public QObject
Q_OBJECT
private slots:
+ void initTestCase();
void qmltypesHasForeign();
+ void qmltypesHasHppClassAndNoext();
+
+private:
+ QByteArray qmltypesData;
};
#endif // TST_QMLTYPEREGISTRAR_H
diff --git a/tests/auto/qml/qmltyperegistrar/tst_qmltyperegistrar.pro b/tests/auto/qml/qmltyperegistrar/tst_qmltyperegistrar.pro
index 02c04dec47..fe21b122c2 100644
--- a/tests/auto/qml/qmltyperegistrar/tst_qmltyperegistrar.pro
+++ b/tests/auto/qml/qmltyperegistrar/tst_qmltyperegistrar.pro
@@ -6,7 +6,10 @@ CONFIG -= debug_and_release_target
macos:CONFIG -= app_bundle
SOURCES += tst_qmltyperegistrar.cpp
-HEADERS += tst_qmltyperegistrar.h
+HEADERS += \
+ hppheader.hpp \
+ noextheader \
+ tst_qmltyperegistrar.h
QMLTYPES_FILENAME = tst_qmltyperegistrar.qmltypes
QML_FOREIGN_METATYPES += foreign/foreign_metatypes.json