summaryrefslogtreecommitdiffstats
path: root/tests/auto/installer/componentmodel/tst_componentmodel.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/installer/componentmodel/tst_componentmodel.cpp')
-rw-r--r--tests/auto/installer/componentmodel/tst_componentmodel.cpp32
1 files changed, 32 insertions, 0 deletions
diff --git a/tests/auto/installer/componentmodel/tst_componentmodel.cpp b/tests/auto/installer/componentmodel/tst_componentmodel.cpp
index 287c1bb42..f764a9371 100644
--- a/tests/auto/installer/componentmodel/tst_componentmodel.cpp
+++ b/tests/auto/installer/componentmodel/tst_componentmodel.cpp
@@ -4,6 +4,7 @@
#include "packagemanagercore.h"
#include <QTest>
+#include <QtCore/QLocale>
using namespace KDUpdater;
using namespace QInstaller;
@@ -20,6 +21,12 @@ static const char vendorSecondProductSubnode[] = "com.vendor.second.product.subn
static const char vendorSecondProductSubnodeSub[] = "com.vendor.second.product.subnode.sub";
static const char vendorThirdProductVirtual[] = "com.vendor.third.product.virtual";
+static const QMap<QString, QString> rootComponentDisplayNames = {
+ {"", QLatin1String("The root component")},
+ {"ru_ru", QString::fromUtf8("Корневая компонента")},
+ {"de_de", QString::fromUtf8("Wurzel Komponente")}
+};
+
class tst_ComponentModel : public QObject
{
Q_OBJECT
@@ -311,6 +318,31 @@ private slots:
delete component;
}
+ void testComponentsLocalization()
+ {
+ QStringList localesToTest = { "en_US", "ru_RU", "de_DE", "fr_FR" };
+ foreach (const QString &localeToTest, localesToTest) {
+ QLocale::setDefault(localeToTest);
+ QString expectedName = rootComponentDisplayNames.contains(localeToTest.toLower())
+ ? rootComponentDisplayNames[localeToTest.toLower()]
+ : rootComponentDisplayNames[QString()];
+
+ setPackageManagerOptions(NoFlags);
+
+ QList<Component*> rootComponents = loadComponents();
+ testComponentsLoaded(rootComponents);
+
+ // setup the model with 1 column
+ ComponentModel model(1, &m_core);
+ model.setRootComponents(rootComponents);
+
+ const QModelIndex root = model.indexFromComponentName(vendorProduct);
+ QCOMPARE(model.data(root, Qt::DisplayRole).toString(), expectedName);
+
+ qDeleteAll(rootComponents);
+ }
+ }
+
private:
void setPackageManagerOptions(Options flags) const
{