aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorMitch Curtis <mitch.curtis@digia.com>2014-01-14 12:34:35 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-01-14 14:02:09 +0100
commit7f50eca469a24809d6d5812ee94b447966ff81f9 (patch)
treec7974606ee5079231f9a156ec6cd98c0451334d5 /tests
parent20f533671ab37be8a5868fecc64dc9d5e5e3ada0 (diff)
Allow assignment of a QML Locale object to a C++ QLocale property.
Task-number: QTBUG-36125 Change-Id: I58454db0c47684aed3e95c52a8135fd5fd6bf2f9 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/qml/qqmllocale/tst_qqmllocale.cpp36
1 files changed, 36 insertions, 0 deletions
diff --git a/tests/auto/qml/qqmllocale/tst_qqmllocale.cpp b/tests/auto/qml/qqmllocale/tst_qqmllocale.cpp
index d565ad557c..0eb38d92e6 100644
--- a/tests/auto/qml/qqmllocale/tst_qqmllocale.cpp
+++ b/tests/auto/qml/qqmllocale/tst_qqmllocale.cpp
@@ -117,6 +117,7 @@ private slots:
void stringLocaleCompare_data();
void stringLocaleCompare();
+ void localeAsCppProperty();
private:
void addPropertyData(const QString &l);
QVariant getProperty(QObject *obj, const QString &locale, const QString &property);
@@ -1223,6 +1224,41 @@ void tst_qqmllocale::stringLocaleCompare()
QCOMPARE(obj->property("comparison").toInt(), QString::localeAwareCompare(string1, string2));
}
+class Calendar : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(QLocale locale READ locale WRITE setLocale)
+public:
+ Calendar() {
+ }
+
+ QLocale locale() const {
+ return mLocale;
+ }
+
+ void setLocale(const QLocale &locale) {
+ mLocale = locale;
+ }
+private:
+ QLocale mLocale;
+};
+
+void tst_qqmllocale::localeAsCppProperty()
+{
+ QQmlComponent component(&engine);
+ qmlRegisterType<Calendar>("Test", 1, 0, "Calendar");
+ component.setData("import QtQml 2.2\nimport Test 1.0\nCalendar { locale: Qt.locale('en_GB'); property var testLocale }", QUrl());
+ QVERIFY(!component.isError());
+ QTRY_VERIFY(component.isReady());
+
+ Calendar *item = qobject_cast<Calendar*>(component.create());
+ QCOMPARE(item->property("locale").toLocale().name(), QLatin1String("en_GB"));
+
+ QVariant localeVariant(QLocale("nb_NO"));
+ item->setProperty("testLocale", localeVariant);
+ QCOMPARE(item->property("testLocale").toLocale().name(), QLatin1String("nb_NO"));
+}
+
class DateFormatter : public QObject
{
Q_OBJECT