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 +- tests/auto/qquickxmllistmodel/qquickxmllistmodel.pro | 6 ++++-- .../qquickxmllistmodel/tst_qquickxmllistmodel.cpp | 19 ++++++++++--------- 3 files changed, 15 insertions(+), 12 deletions(-) (limited to 'tests/auto') diff --git a/tests/auto/auto.pro b/tests/auto/auto.pro index 40f4c5c..81669e3 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 e2d873c..2c7eacc 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 b2e5703..8059afc 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; -- cgit v1.2.1