diff options
Diffstat (limited to 'tests/auto/installer/binaryformat/tst_binaryformat.cpp')
-rw-r--r-- | tests/auto/installer/binaryformat/tst_binaryformat.cpp | 47 |
1 files changed, 44 insertions, 3 deletions
diff --git a/tests/auto/installer/binaryformat/tst_binaryformat.cpp b/tests/auto/installer/binaryformat/tst_binaryformat.cpp index c9cd2b00f..2fcad0b38 100644 --- a/tests/auto/installer/binaryformat/tst_binaryformat.cpp +++ b/tests/auto/installer/binaryformat/tst_binaryformat.cpp @@ -1,6 +1,6 @@ /************************************************************************** ** -** Copyright (C) 2017 The Qt Company Ltd. +** Copyright (C) 2023 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the Qt Installer Framework. @@ -26,6 +26,8 @@ ** **************************************************************************/ +#include "../shared/packagemanager.h" + #include <binarycontent.h> #include <binaryformat.h> #include <errors.h> @@ -51,8 +53,8 @@ struct Layout : public QInstaller::BinaryLayout class TestOperation : public KDUpdater::UpdateOperation { public: - TestOperation(const QString &name) - : KDUpdater::UpdateOperation(nullptr) + explicit TestOperation(const QString &name, PackageManagerCore *core = nullptr) + : KDUpdater::UpdateOperation(core) { setName(name); } virtual void backup() {} @@ -392,6 +394,45 @@ private slots: resource->close(); } + void testXmlDocumentParsing() + { + PackageManagerCore core; + core.setValue(scTargetDir, QLatin1String("relocatable_targetdir")); + + TestOperation op(QLatin1String("Operation 3"), &core); + QStringList stringListValue = (QStringList() << QLatin1String("list_value1") << QLatin1String("list_value2")); + op.setValue(QLatin1String("string_list"), stringListValue); + + const QString stringValue = core.value(scTargetDir) + QLatin1String(", string_value1"); + op.setValue(QLatin1String("string"), stringValue); + + QVariantMap map; + map.insert(QLatin1String("key1"), 1); + map.insert(QLatin1String("key2"), QLatin1String("map_value2")); + op.setValue(QLatin1String("variant_map"), map); + + QDomDocument document = op.toXml(); + QVERIFY2(document.toString().contains(QLatin1String("@RELOCATABLE_PATH@")), + "TargetDir not replaced with @RELOCATABLE_PATH@"); + + op.fromXml(document); // Resets the operation values from written QDomDocuments + + QCOMPARE(op.value(QLatin1String("string_list")), stringListValue); + QVERIFY2(!op.value(QLatin1String("string")).toString().contains(QLatin1String("@RELOCATABLE_PATH@")), + "@RELOCATABLE@ not replaced with TargetDir"); + QCOMPARE(op.value(QLatin1String("variant_map")), map); + +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + QCOMPARE(op.value(QLatin1String("string_list")).metaType().id(), QMetaType::QStringList); + QCOMPARE(op.value(QLatin1String("string")).metaType().id(), QMetaType::QString); + QCOMPARE(op.value(QLatin1String("variant_map")).metaType().id(), QMetaType::QVariantMap); +#else + QCOMPARE(op.value(QLatin1String("string_list")).type(), QMetaType::QStringList); + QCOMPARE(op.value(QLatin1String("string")).type(), QMetaType::QString); + QCOMPARE(op.value(QLatin1String("variant_map")).type(), QMetaType::QVariantMap); +#endif + } + void cleanupTestCase() { m_manager.clear(); |