diff options
author | Katja Marttila <[email protected]> | 2025-06-05 12:55:26 +0300 |
---|---|---|
committer | Katja Marttila <[email protected]> | 2025-06-06 06:18:08 +0000 |
commit | 2372b336f731520141f53f21b662967603905659 (patch) | |
tree | b10aa6744e7c97e0a7c045ada56e38bd7efc6266 /tests | |
parent | 1e033dde76b1ef17d71d318a98411dba0aaf3610 (diff) |
Variables can be defined inside '@' symbols, and are resolved by
runtime, like @HomeDir@. This enables the usage of the correct variable
value before its final set.
If the variable inside '@' was not an installer value, installer
replaced the variable with empty value. As the double '@' can be also
part of the value itself, installer should not replace it with empty
value if no real variable is found for it.
Task-number: QTIFW-2945
Change-Id: I83ca40db1e03a12ba51535766b054765071d09ad
Reviewed-by: Arttu Tarkiainen <[email protected]>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/installer/packagemanagercore/tst_packagemanagercore.cpp | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/tests/auto/installer/packagemanagercore/tst_packagemanagercore.cpp b/tests/auto/installer/packagemanagercore/tst_packagemanagercore.cpp index f2f397021..b2104420c 100644 --- a/tests/auto/installer/packagemanagercore/tst_packagemanagercore.cpp +++ b/tests/auto/installer/packagemanagercore/tst_packagemanagercore.cpp @@ -346,6 +346,48 @@ private slots: QCOMPARE(core.fromNativeSeparators(path), path); #endif } + + void testReplaceVariablesStr_data() + { + QTest::addColumn<QString>("key"); + QTest::addColumn<QString>("value"); + QTest::addColumn<QString>("result"); + + QTest::newRow("Normal variables") << "myKey" << "myValue" << "myValue"; + QTest::newRow("Nonreplaced variables") << "myNonreplaceKey" << "@myValue1@" << "@myValue1@"; + } + + void testReplaceVariablesStr() + { + QFETCH(QString, key); + QFETCH(QString, value); + QFETCH(QString, result); + + PackageManagerCore core; + core.setValue(key, value); + QCOMPARE(core.replaceVariables(value), result); + } + + void testReplaceVariablesBytearray_data() + { + QTest::addColumn<QString>("key"); + QTest::addColumn<QByteArray>("value"); + QTest::addColumn<QByteArray>("result"); + + QTest::newRow("Normal variables") << "myKey" << QByteArray("myValue") << QByteArray("myValue"); + QTest::newRow("Nonreplaced variables") << "myNonreplaceKey" << QByteArray("@myValue1@") << QByteArray("@myValue1@"); + } + + void testReplaceVariablesBytearray() + { + QFETCH(QString, key); + QFETCH(QByteArray, value); + QFETCH(QByteArray, result); + + PackageManagerCore core; + core.setValue(key, value); + QCOMPARE(core.replaceVariables(value), result); + } }; |