diff options
Diffstat (limited to 'tests/auto/installer/componentmodel/tst_componentmodel.cpp')
-rw-r--r-- | tests/auto/installer/componentmodel/tst_componentmodel.cpp | 47 |
1 files changed, 33 insertions, 14 deletions
diff --git a/tests/auto/installer/componentmodel/tst_componentmodel.cpp b/tests/auto/installer/componentmodel/tst_componentmodel.cpp index 0672a03ec..276292233 100644 --- a/tests/auto/installer/componentmodel/tst_componentmodel.cpp +++ b/tests/auto/installer/componentmodel/tst_componentmodel.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. @@ -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 @@ -92,7 +98,7 @@ private slots: // setup the model with 1 column ComponentModel model(1, &m_core); - model.setRootComponents(rootComponents); + model.reset(rootComponents); // all names should be resolvable, virtual components are not indexed if they are not visible QStringList all; @@ -116,7 +122,7 @@ private slots: // setup the model with 1 column ComponentModel model(1, &m_core); - model.setRootComponents(rootComponents); + model.reset(rootComponents); // all names should be resolvable, including virtual components QStringList all; @@ -141,7 +147,7 @@ private slots: // setup the model with 1 column ComponentModel model(1, &m_core); - model.setRootComponents(rootComponents); + model.reset(rootComponents); testDefaultInheritedModelBehavior(&model, 1); QCOMPARE(model.core(), &m_core); @@ -162,7 +168,7 @@ private slots: // setup the model with 1 column ComponentModel model(1, &m_core); - model.setRootComponents(rootComponents); + model.reset(rootComponents); testDefaultInheritedModelBehavior(&model, 1); QCOMPARE(model.checkedState(), ComponentModel::DefaultChecked); @@ -184,7 +190,7 @@ private slots: // setup the model with 1 column ComponentModel model(1, &m_core); - model.setRootComponents(rootComponents); + model.reset(rootComponents); testDefaultInheritedModelBehavior(&model, 1); QCOMPARE(model.checkedState(), ComponentModel::DefaultChecked); @@ -204,7 +210,7 @@ private slots: // setup the model with 1 column ComponentModel model(1, &m_core); - model.setRootComponents(rootComponents); + model.reset(rootComponents); testDefaultInheritedModelBehavior(&model, 1); QCOMPARE(model.checkedState(), ComponentModel::DefaultChecked); @@ -226,7 +232,7 @@ private slots: // setup the model with 1 column ComponentModel model(1, &m_core); - model.setRootComponents(rootComponents); + model.reset(rootComponents); testDefaultInheritedModelBehavior(&model, 1); // select all possible components. @@ -262,7 +268,7 @@ private slots: // setup the model with 1 column ComponentModel model(1, &m_core); - model.setRootComponents(rootComponents); + model.reset(rootComponents); testDefaultInheritedModelBehavior(&model, 1); // select all possible components. @@ -300,7 +306,7 @@ private slots: // setup the model with 1 column ComponentModel model(1, &m_core); - model.setRootComponents(rootComponents); + model.reset(rootComponents); testDefaultInheritedModelBehavior(&model, 1); // select all possible components. @@ -335,7 +341,7 @@ private slots: // setup the model with 1 column ComponentModel model(1, &m_core); - model.setRootComponents(rootComponents); + model.reset(rootComponents); testDefaultInheritedModelBehavior(&model, 1); // select all possible components. @@ -367,11 +373,19 @@ private slots: { QStringList localesToTest = { "en_US", "ru_RU", "de_DE", "fr_FR" }; foreach (const QString &localeToTest, localesToTest) { +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + QLocale::setDefault(QLocale(localeToTest)); +#else QLocale::setDefault(localeToTest); +#endif QString expectedName = rootComponentDisplayNames.contains(localeToTest.toLower()) ? rootComponentDisplayNames[localeToTest.toLower()] : rootComponentDisplayNames[QString()]; + QString expectedDescription = rootComponentDescriptions.contains(localeToTest.toLower()) + ? rootComponentDescriptions[localeToTest.toLower()] + : rootComponentDescriptions[QString()]; + setPackageManagerOptions(NoFlags); QList<Component*> rootComponents = loadComponents(); @@ -379,11 +393,14 @@ private slots: // setup the model with 1 column ComponentModel model(1, &m_core); - model.setRootComponents(rootComponents); + model.reset(rootComponents); 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); } } @@ -397,7 +414,7 @@ private slots: // setup the model with 1 column ComponentModel model(1, &m_core); - model.setRootComponents(rootComponents); + model.reset(rootComponents); testDefaultInheritedModelBehavior(&model, 1); model.setCheckedState(ComponentModel::DefaultChecked); @@ -513,6 +530,7 @@ private: { UpdatesInfo updatesInfo; updatesInfo.setFileName(":///data/updates.xml"); + updatesInfo.parseFile(); const QList<UpdateInfo> updateInfos = updatesInfo.updatesInfo(); QHash<QString, Component*> components; @@ -521,7 +539,7 @@ private: // we need at least these to be able to test the model component->setValue("Name", info.data.value("Name").toString()); - component->setValue("TreeName", info.data.value("TreeName").toString()); + component->setValue("TreeName", info.data.value("TreeName").value<QPair<QString, bool>>().first); QString isDefault = info.data.value("Default").toString(); if (m_core.noDefaultInstallation()) isDefault = scFalse; @@ -529,6 +547,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()) |