summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/declarative/qdeclarativelocale/data/properties.qml1
-rw-r--r--tests/auto/declarative/qdeclarativelocale/tst_qdeclarativelocale.cpp41
2 files changed, 42 insertions, 0 deletions
diff --git a/tests/auto/declarative/qdeclarativelocale/data/properties.qml b/tests/auto/declarative/qdeclarativelocale/data/properties.qml
index 1d2968b419..16d1f4092a 100644
--- a/tests/auto/declarative/qdeclarativelocale/data/properties.qml
+++ b/tests/auto/declarative/qdeclarativelocale/data/properties.qml
@@ -23,4 +23,5 @@ QtObject {
property var measurementSystem: locale.measurementSystem
property var textDirection: locale.textDirection
property var weekDays: locale.weekDays
+ property var uiLanguages: locale.uiLanguages
}
diff --git a/tests/auto/declarative/qdeclarativelocale/tst_qdeclarativelocale.cpp b/tests/auto/declarative/qdeclarativelocale/tst_qdeclarativelocale.cpp
index ab11dbc6da..5afc2354a6 100644
--- a/tests/auto/declarative/qdeclarativelocale/tst_qdeclarativelocale.cpp
+++ b/tests/auto/declarative/qdeclarativelocale/tst_qdeclarativelocale.cpp
@@ -70,6 +70,8 @@ private slots:
void standaloneDayName();
void weekDays_data();
void weekDays();
+ void uiLanguages_data();
+ void uiLanguages();
void dateFormat_data();
void dateFormat();
void dateTimeFormat_data();
@@ -463,6 +465,45 @@ void tst_qdeclarativelocale::weekDays()
delete obj;
}
+void tst_qdeclarativelocale::uiLanguages_data()
+{
+ QTest::addColumn<QString>("locale");
+
+ QTest::newRow("en_US") << "en_US";
+ QTest::newRow("de_DE") << "de_DE";
+ QTest::newRow("ar_SA") << "ar_SA";
+ QTest::newRow("hi_IN") << "hi_IN";
+ QTest::newRow("zh_CN") << "zh_CN";
+ QTest::newRow("th_TH") << "th_TH";
+}
+
+void tst_qdeclarativelocale::uiLanguages()
+{
+ QFETCH(QString, locale);
+
+ QDeclarativeComponent c(&engine, testFileUrl("properties.qml"));
+
+ QObject *obj = c.create();
+ QVERIFY(obj);
+
+ QMetaObject::invokeMethod(obj, "setLocale", Qt::DirectConnection,
+ Q_ARG(QVariant, QVariant(locale)));
+
+ QVariant val = obj->property("uiLanguages");
+ QVERIFY(val.type() == QVariant::List);
+
+ QList<QVariant> qmlLangs = val.toList();
+ QStringList langs = QLocale(locale).uiLanguages();
+
+ QVERIFY(langs.count() == qmlLangs.count());
+
+ for (int i = 0; i < langs.count(); ++i) {
+ QCOMPARE(langs.at(i), qmlLangs.at(i).toString());
+ }
+
+ delete obj;
+}
+
void tst_qdeclarativelocale::dateTimeFormat_data()
{