From 47c86cbb55a03df0f9d95dc2311b0be6d7852a5b Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Sat, 29 Jun 2019 22:16:34 +0200 Subject: Actually test XmlListModel Due to a typo in 'SUBDIRS', the test was never added to the build. Adding tests/shared/util.* from (current) qtdeclarative, adjusting paths and eradicating Q_FOREACHs, as the module defines QT_NO_FOREACH. Amends 8c6e24329ecd65f364654b1ca2b6a273f0826a8b. Change-Id: Ifacec982e8628c1317b1d7cc5c454c0a2cfafba1 Reviewed-by: Simon Hausmann --- tests/auto/auto.pro | 2 +- .../auto/qquickxmllistmodel/qquickxmllistmodel.pro | 6 +- .../qquickxmllistmodel/tst_qquickxmllistmodel.cpp | 19 ++-- tests/shared/util.cpp | 103 +++++++++++++++++++++ tests/shared/util.h | 95 +++++++++++++++++++ tests/shared/util.pri | 10 ++ 6 files changed, 223 insertions(+), 12 deletions(-) create mode 100644 tests/shared/util.cpp create mode 100644 tests/shared/util.h create mode 100644 tests/shared/util.pri diff --git a/tests/auto/auto.pro b/tests/auto/auto.pro index 40f4c5c3..81669e36 100644 --- a/tests/auto/auto.pro +++ b/tests/auto/auto.pro @@ -53,7 +53,7 @@ xmlpatternsxqts.depends = xmlpatternssdk xmlpatternsxqts \ xmlpatternsxslts \ -qtHaveModule(quick): SUBIDIRS += qquickxmllistmodel +qtHaveModule(quick):SUBDIRS += qquickxmllistmodel !cross_compile: SUBDIRS += host.pro diff --git a/tests/auto/qquickxmllistmodel/qquickxmllistmodel.pro b/tests/auto/qquickxmllistmodel/qquickxmllistmodel.pro index e2d873c4..2c7eaccb 100644 --- a/tests/auto/qquickxmllistmodel/qquickxmllistmodel.pro +++ b/tests/auto/qquickxmllistmodel/qquickxmllistmodel.pro @@ -3,8 +3,10 @@ TARGET = tst_qquickxmllistmodel macos:CONFIG -= app_bundle SOURCES += tst_qquickxmllistmodel.cpp \ - ../../../../src/imports/xmllistmodel/qqmlxmllistmodel.cpp -HEADERS += ../../../../src/imports/xmllistmodel/qqmlxmllistmodel_p.h + $$PWD/../../../src/imports/xmllistmodel/qqmlxmllistmodel.cpp +HEADERS += $$PWD/../../../src/imports/xmllistmodel/qqmlxmllistmodel_p.h + +INCLUDEPATH *= $$PWD/../../../src/imports/xmllistmodel include (../../shared/util.pri) diff --git a/tests/auto/qquickxmllistmodel/tst_qquickxmllistmodel.cpp b/tests/auto/qquickxmllistmodel/tst_qquickxmllistmodel.cpp index b2e5703a..8059afcd 100644 --- a/tests/auto/qquickxmllistmodel/tst_qquickxmllistmodel.cpp +++ b/tests/auto/qquickxmllistmodel/tst_qquickxmllistmodel.cpp @@ -44,7 +44,7 @@ #include #include -#include "../../../../src/imports/xmllistmodel/qqmlxmllistmodel_p.h" +#include "../../../src/imports/xmllistmodel/qqmlxmllistmodel_p.h" #include @@ -110,14 +110,14 @@ private: QString xml; if (!data.isEmpty()) { - QStringList items = data.split(QLatin1Char(';')); - foreach (const QString &item, items) { + const QStringList items = data.split(QLatin1Char(';')); + for (const QString &item : items) { if (item.isEmpty()) continue; QVariantList variants; xml += QLatin1String(""); - QStringList fields = item.split(QLatin1Char(',')); - foreach (const QString &field, fields) { + const QStringList fields = item.split(QLatin1Char(',')); + for (const QString &field : fields) { QStringList values = field.split(QLatin1Char('=')); if (values.count() != 2) { qWarning() << "makeItemXmlAndData: invalid field:" << field; @@ -168,7 +168,8 @@ protected: { if (m_factory) { QVariantMap map; - foreach (const QString &header, req.rawHeaderList()) + const auto rawHeaderList = req.rawHeaderList(); + for (const QString &header : rawHeaderList) map[header] = req.rawHeader(header.toUtf8()); m_factory->lastSentHeaders = map; } @@ -421,9 +422,9 @@ void tst_qquickxmllistmodel::headers() expectedHeaders["Accept"] = "application/xml,*/*"; QCOMPARE(factory.lastSentHeaders.count(), expectedHeaders.count()); - foreach (const QString &header, expectedHeaders.keys()) { - QVERIFY(factory.lastSentHeaders.contains(header)); - QCOMPARE(factory.lastSentHeaders[header].toString(), expectedHeaders[header].toString()); + for (auto it = expectedHeaders.cbegin(), end = expectedHeaders.cend(); it != end; ++it) { + QVERIFY(factory.lastSentHeaders.contains(it.key())); + QCOMPARE(factory.lastSentHeaders[it.key()].toString(), it.value().toString()); } delete model; diff --git a/tests/shared/util.cpp b/tests/shared/util.cpp new file mode 100644 index 00000000..96876428 --- /dev/null +++ b/tests/shared/util.cpp @@ -0,0 +1,103 @@ +/**************************************************************************** +** +** Copyright (C) 2016 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$ +** +****************************************************************************/ + +#include "util.h" + +#include +#include + +QQmlDataTest *QQmlDataTest::m_instance = 0; + +QQmlDataTest::QQmlDataTest() : +#ifdef QT_TESTCASE_BUILDDIR + m_dataDirectory(QTest::qFindTestData("data", QT_QMLTEST_DATADIR, 0, QT_TESTCASE_BUILDDIR)), +#else + m_dataDirectory(QTest::qFindTestData("data", QT_QMLTEST_DATADIR, 0)), +#endif + + m_dataDirectoryUrl(m_dataDirectory.startsWith(QLatin1Char(':')) + ? QUrl(QLatin1String("qrc") + m_dataDirectory) + : QUrl::fromLocalFile(m_dataDirectory + QLatin1Char('/'))) +{ + m_instance = this; +} + +QQmlDataTest::~QQmlDataTest() +{ + m_instance = 0; +} + +void QQmlDataTest::initTestCase() +{ + QVERIFY2(!m_dataDirectory.isEmpty(), "'data' directory not found"); + m_directory = QFileInfo(m_dataDirectory).absolutePath(); + if (m_dataDirectoryUrl.scheme() != QLatin1String("qrc")) + QVERIFY2(QDir::setCurrent(m_directory), qPrintable(QLatin1String("Could not chdir to ") + m_directory)); +} + +QString QQmlDataTest::testFile(const QString &fileName) const +{ + if (m_directory.isEmpty()) + qFatal("QQmlDataTest::initTestCase() not called."); + QString result = m_dataDirectory; + result += QLatin1Char('/'); + result += fileName; + return result; +} + +Q_GLOBAL_STATIC(QMutex, qQmlTestMessageHandlerMutex) + +QQmlTestMessageHandler *QQmlTestMessageHandler::m_instance = 0; + +void QQmlTestMessageHandler::messageHandler(QtMsgType, const QMessageLogContext &context, const QString &message) +{ + QMutexLocker locker(qQmlTestMessageHandlerMutex()); + if (QQmlTestMessageHandler::m_instance) { + if (QQmlTestMessageHandler::m_instance->m_includeCategories) + QQmlTestMessageHandler::m_instance->m_messages.push_back(QString("%1: %2").arg(context.category, message)); + else + QQmlTestMessageHandler::m_instance->m_messages.push_back(message); + } +} + +QQmlTestMessageHandler::QQmlTestMessageHandler() +{ + QMutexLocker locker(qQmlTestMessageHandlerMutex()); + Q_ASSERT(!QQmlTestMessageHandler::m_instance); + QQmlTestMessageHandler::m_instance = this; + m_oldHandler = qInstallMessageHandler(messageHandler); + m_includeCategories = false; +} + +QQmlTestMessageHandler::~QQmlTestMessageHandler() +{ + QMutexLocker locker(qQmlTestMessageHandlerMutex()); + Q_ASSERT(QQmlTestMessageHandler::m_instance); + qInstallMessageHandler(m_oldHandler); + QQmlTestMessageHandler::m_instance = 0; +} diff --git a/tests/shared/util.h b/tests/shared/util.h new file mode 100644 index 00000000..6f3f0a06 --- /dev/null +++ b/tests/shared/util.h @@ -0,0 +1,95 @@ +/**************************************************************************** +** +** Copyright (C) 2016 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 QQMLTESTUTILS_H +#define QQMLTESTUTILS_H + +#include +#include +#include +#include +#include + +/* Base class for tests with data that are located in a "data" subfolder. */ + +class QQmlDataTest : public QObject +{ + Q_OBJECT +public: + QQmlDataTest(); + virtual ~QQmlDataTest(); + + QString testFile(const QString &fileName) const; + inline QString testFile(const char *fileName) const + { return testFile(QLatin1String(fileName)); } + inline QUrl testFileUrl(const QString &fileName) const + { return QUrl::fromLocalFile(testFile(fileName)); } + inline QUrl testFileUrl(const char *fileName) const + { return testFileUrl(QLatin1String(fileName)); } + + inline QString dataDirectory() const { return m_dataDirectory; } + inline QUrl dataDirectoryUrl() const { return m_dataDirectoryUrl; } + inline QString directory() const { return m_directory; } + + static inline QQmlDataTest *instance() { return m_instance; } + +public slots: + virtual void initTestCase(); + +private: + static QQmlDataTest *m_instance; + + const QString m_dataDirectory; + const QUrl m_dataDirectoryUrl; + QString m_directory; +}; + +class QQmlTestMessageHandler +{ + Q_DISABLE_COPY(QQmlTestMessageHandler) +public: + QQmlTestMessageHandler(); + ~QQmlTestMessageHandler(); + + const QStringList &messages() const { return m_messages; } + const QString messageString() const { return m_messages.join(QLatin1Char('\n')); } + + void clear() { m_messages.clear(); } + + void setIncludeCategoriesEnabled(bool enabled) { m_includeCategories = enabled; } + +private: + static void messageHandler(QtMsgType, const QMessageLogContext &context, const QString &message); + + static QQmlTestMessageHandler *m_instance; + QStringList m_messages; + QtMessageHandler m_oldHandler; + bool m_includeCategories; +}; + +#endif // QQMLTESTUTILS_H diff --git a/tests/shared/util.pri b/tests/shared/util.pri new file mode 100644 index 00000000..b54897ac --- /dev/null +++ b/tests/shared/util.pri @@ -0,0 +1,10 @@ + +INCLUDEPATH += $$PWD +HEADERS += $$PWD/util.h +SOURCES += $$PWD/util.cpp + +android|ios { + DEFINES += QT_QMLTEST_DATADIR=\\\":/data\\\" +} else { + DEFINES += QT_QMLTEST_DATADIR=\\\"$${_PRO_FILE_PWD_}/data\\\" +} -- cgit v1.2.3 From adf91ef5da6bb51288fffd68d3c9ebb02c3fe9bf Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Sat, 29 Jun 2019 22:31:26 +0200 Subject: Fix GCC 9 -Wdeprecated-copy MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: Ida54f2edbfa41936d40e7309c0ea1cd8d6d02e5f Reviewed-by: MÃ¥rten Nordheim --- src/xmlpatterns/api/qabstractxmlnodemodel.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/xmlpatterns/api/qabstractxmlnodemodel.h b/src/xmlpatterns/api/qabstractxmlnodemodel.h index d16a35e6..13e0a186 100644 --- a/src/xmlpatterns/api/qabstractxmlnodemodel.h +++ b/src/xmlpatterns/api/qabstractxmlnodemodel.h @@ -127,6 +127,8 @@ public: { } + QXmlNodeModelIndex &operator=(const QXmlNodeModelIndex &) = default; + bool operator==(const QXmlNodeModelIndex &other) const; bool operator!=(const QXmlNodeModelIndex &other) const; -- cgit v1.2.3 From 1fe82f967320b3c65f29ed704862f8c34a6c0c87 Mon Sep 17 00:00:00 2001 From: Frederik Gladhorn Date: Mon, 1 Jul 2019 16:01:54 +0200 Subject: Bump version Change-Id: Ieef19b19ec0ea8df01190de0ad24105c61465c2c --- .qmake.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.qmake.conf b/.qmake.conf index 74462990..4a957d04 100644 --- a/.qmake.conf +++ b/.qmake.conf @@ -2,4 +2,4 @@ load(qt_build_config) CONFIG += warning_clean DEFINES += QT_NO_FOREACH -MODULE_VERSION = 5.12.4 +MODULE_VERSION = 5.12.5 -- cgit v1.2.3 From 5e6e09823da454e16341b9cab944b74a13265ef9 Mon Sep 17 00:00:00 2001 From: Topi Reinio Date: Wed, 3 Jul 2019 13:33:42 +0200 Subject: Doc: Replace example file lists with links to code.qt.io Task-number: QTBUG-74391 Change-Id: Ibc00cc7b8cb9258ea0675f01ff4731788a4b4c8b Reviewed-by: Paul Wicking --- src/xmlpatterns/doc/qtxmlpatterns.qdocconf | 1 + 1 file changed, 1 insertion(+) diff --git a/src/xmlpatterns/doc/qtxmlpatterns.qdocconf b/src/xmlpatterns/doc/qtxmlpatterns.qdocconf index 7407c123..eb7984ff 100644 --- a/src/xmlpatterns/doc/qtxmlpatterns.qdocconf +++ b/src/xmlpatterns/doc/qtxmlpatterns.qdocconf @@ -1,4 +1,5 @@ include($QT_INSTALL_DOCS/global/qt-module-defaults.qdocconf) +include($QT_INSTALL_DOCS/config/exampleurl-qtxmlpatterns.qdocconf) project = QtXmlPatterns description = Qt XML Patterns Reference Documentation -- cgit v1.2.3