diff options
author | Dmitry Mordvinov <dvvsrd@gmail.com> | 2015-05-07 05:25:07 +0300 |
---|---|---|
committer | Karsten Heimrich <karsten.heimrich@theqtcompany.com> | 2015-05-08 11:42:02 +0000 |
commit | ff19df37415ead8d26597d861b4d0311ac971c74 (patch) | |
tree | 677388c7d6e8e71fcf8467b1e2bc6e8af5337626 /tests | |
parent | d74b5e575dfbc3d39f5a2970cc698cc389542116 (diff) |
Implemented xml:lang attribute support for DisplayName tag.
Components in tree view are often need to be localized. Therefore
packages.xml syntax is extended with possibility to specify xml:lang
attribute for DisplayName tag (similarly to Description one).
Test data extended with root component localization.
Added new testcase that changes default locale and checks that
loaded component names correspond to hard-coded ones.
Docs updated with new feature description.
Change-Id: Ic330c3c6684e763eb48a2e99e71784913544e686
Reviewed-by: Leena Miettinen <riitta-leena.miettinen@theqtcompany.com>
Reviewed-by: Karsten Heimrich <karsten.heimrich@theqtcompany.com>
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 | 32 |
2 files changed, 34 insertions, 0 deletions
diff --git a/tests/auto/installer/componentmodel/data/updates.xml b/tests/auto/installer/componentmodel/data/updates.xml index e1f72de10..cfd756a5c 100644 --- a/tests/auto/installer/componentmodel/data/updates.xml +++ b/tests/auto/installer/componentmodel/data/updates.xml @@ -5,6 +5,8 @@ <PackageUpdate> <Name>com.vendor.product</Name> <DisplayName>The root component</DisplayName> + <DisplayName xml:lang="ru_RU">Корневая компонента</DisplayName> + <DisplayName xml:lang="de_DE">Wurzel Komponente</DisplayName> <Description>Install this example.</Description> <Version>0.1.0-1</Version> <ReleaseDate>2010-09-21</ReleaseDate> 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 { |