summaryrefslogtreecommitdiffstats
path: root/tests/auto/installer/binaryformat/tst_binaryformat.cpp
diff options
context:
space:
mode:
authorKatja Marttila <katja.marttila@qt.io>2023-06-06 11:43:36 +0300
committerKatja Marttila <katja.marttila@qt.io>2023-08-23 15:58:38 +0300
commita9fd39352c3d3717fb9ea33871bb8e3a2ddf5483 (patch)
tree28bd5d8c3f7717a2ad28fcddf67e4ca3f3029074 /tests/auto/installer/binaryformat/tst_binaryformat.cpp
parent27d9e170d4191fb218b65f100a3c8d43c47dc9f6 (diff)
Fix deprecated QVariant usage
Also adding tests for UpdateOperations which used the deprecated QVariant functions Task-number: QTIFW-3077 Change-Id: I5b6b975631b4d0380511f614b0cad1f90a4849e8 Reviewed-by: Arttu Tarkiainen <arttu.tarkiainen@qt.io>
Diffstat (limited to 'tests/auto/installer/binaryformat/tst_binaryformat.cpp')
-rw-r--r--tests/auto/installer/binaryformat/tst_binaryformat.cpp47
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 7e0f5ed24..2fcad0b38 100644
--- a/tests/auto/installer/binaryformat/tst_binaryformat.cpp
+++ b/tests/auto/installer/binaryformat/tst_binaryformat.cpp
@@ -1,6 +1,6 @@
/**************************************************************************
**
-** Copyright (C) 2021 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:
- explicit 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();