diff options
author | Katja Marttila <katja.marttila@qt.io> | 2022-12-20 09:16:08 +0200 |
---|---|---|
committer | Katja Marttila <katja.marttila@qt.io> | 2022-12-22 10:02:11 +0200 |
commit | 7828f6f9c4f49afc4583d67b42ce31323256312a (patch) | |
tree | 0de0541c09a22cea188104af8f80a6d3b779a9d6 /tests | |
parent | fa94c6f7bc97a112ec0b27f0e896a92845f2a894 (diff) |
Optimize Updates.xml parsing
QDomDocument::setContent is time consuming operation especially when
there are thousands of Updates.xml to be parsed. Using QXmlStreamReader
for parsing the xml content instead, the Updates.xml content is already
validated in metadata job after download.
In Windows, using QXmlStreamReader instead of QDomDocument decreases the
xml parsing time from ~10 seconds to ~1 seconds when there are thousands
of Updates.xml to be parsed.
Task-number: QTIFW-2924
Change-Id: I14f5eba5b72f451a12ab4e3bf6b2f00b5f66faaf
Reviewed-by: Arttu Tarkiainen <arttu.tarkiainen@qt.io>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/installer/componentmodel/data/updates.xml | 2 | ||||
-rw-r--r-- | tests/auto/installer/componentmodel/tst_componentmodel.cpp | 14 |
2 files changed, 16 insertions, 0 deletions
diff --git a/tests/auto/installer/componentmodel/data/updates.xml b/tests/auto/installer/componentmodel/data/updates.xml index 3a6139446..cc2da0f8e 100644 --- a/tests/auto/installer/componentmodel/data/updates.xml +++ b/tests/auto/installer/componentmodel/data/updates.xml @@ -8,6 +8,8 @@ <DisplayName xml:lang="ru_RU">Корневая компонента</DisplayName> <DisplayName xml:lang="de_DE">Wurzel Komponente</DisplayName> <Description>Install this example.</Description> + <Description xml:lang="ru_RU">Установите этот пример.</Description> + <Description xml:lang="de_DE">Installieren Sie dieses Beispiel.</Description> <Version>0.1.0-1</Version> <ReleaseDate>2010-09-21</ReleaseDate> <Default>true</Default> diff --git a/tests/auto/installer/componentmodel/tst_componentmodel.cpp b/tests/auto/installer/componentmodel/tst_componentmodel.cpp index 463485d96..2836c80df 100644 --- a/tests/auto/installer/componentmodel/tst_componentmodel.cpp +++ b/tests/auto/installer/componentmodel/tst_componentmodel.cpp @@ -59,6 +59,12 @@ static const QMap<QString, QString> rootComponentDisplayNames = { {"de_de", QString::fromUtf8("Wurzel Komponente")} }; +static const QMap<QString, QString> rootComponentDescriptions = { + {"", QLatin1String("Install this example.")}, + {"ru_ru", QString::fromUtf8("Установите этот пример.")}, + {"de_de", QString::fromUtf8("Installieren Sie dieses Beispiel.")} +}; + class tst_ComponentModel : public QObject { Q_OBJECT @@ -372,6 +378,10 @@ private slots: ? rootComponentDisplayNames[localeToTest.toLower()] : rootComponentDisplayNames[QString()]; + QString expectedDescription = rootComponentDescriptions.contains(localeToTest.toLower()) + ? rootComponentDescriptions[localeToTest.toLower()] + : rootComponentDescriptions[QString()]; + setPackageManagerOptions(NoFlags); QList<Component*> rootComponents = loadComponents(); @@ -384,6 +394,9 @@ private slots: const QModelIndex root = model.indexFromComponentName(vendorProduct); QCOMPARE(model.data(root, Qt::DisplayRole).toString(), expectedName); + Component *comp = model.componentFromIndex(root); + QCOMPARE(comp->value("Description"), expectedDescription); + qDeleteAll(rootComponents); } } @@ -529,6 +542,7 @@ private: component->setValue("Virtual", info.data.value("Virtual").toString()); component->setValue("DisplayName", info.data.value("DisplayName").toString()); component->setValue("Checkable", info.data.value("Checkable").toString()); + component->setValue("Description", info.data.value("Description").toString()); QString forced = info.data.value("ForcedInstallation", scFalse).toString().toLower(); if (m_core.noForceInstallation()) |