aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/qml/qqmlsettings
diff options
context:
space:
mode:
authorJ-P Nurmi <jpnurmi@digia.com>2013-10-27 10:51:10 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-10-29 15:33:00 +0100
commitd2acb7e3c1c05149101dd9860575799423e3cb0f (patch)
treed07da4e7180d798aef8f4d822b863afddaf0992d /tests/auto/qml/qqmlsettings
parent8ac2c403a7deec9d192ad674040933c3a87a6971 (diff)
QQmlSettings: fix loading of initial values
When the initial value of a QML Settings var property is invalid ie. it has no initial value set, it must be loaded from QSettings as is without testing QVariant conversion (that would fail when the conversion target type is "invalid"). Change-Id: If002d52251e3f2d6373dcc305b439de61c6b8c79 Reviewed-by: Shawn Rutledge <shawn.rutledge@digia.com>
Diffstat (limited to 'tests/auto/qml/qqmlsettings')
-rw-r--r--tests/auto/qml/qqmlsettings/tst_qqmlsettings.cpp18
1 files changed, 18 insertions, 0 deletions
diff --git a/tests/auto/qml/qqmlsettings/tst_qqmlsettings.cpp b/tests/auto/qml/qqmlsettings/tst_qqmlsettings.cpp
index 897450823c..7b5ed5e236 100644
--- a/tests/auto/qml/qqmlsettings/tst_qqmlsettings.cpp
+++ b/tests/auto/qml/qqmlsettings/tst_qqmlsettings.cpp
@@ -65,6 +65,7 @@ private slots:
void aliases();
void categories();
void siblings();
+ void initial();
};
class CppObject : public QObject
@@ -579,6 +580,23 @@ void tst_QQmlSettings::siblings()
QCOMPARE(settings.value("alias2").toString(), QStringLiteral("value2"));
}
+void tst_QQmlSettings::initial()
+{
+ QSettings qs;
+ qs.setValue("value", QStringLiteral("initial"));
+ qs.sync();
+
+ QQmlEngine engine;
+ QQmlComponent component(&engine);
+ component.setData("import Qt.labs.settings 1.0; Settings { property var value }", QUrl());
+ QScopedPointer<QObject> settings(component.create());
+ QVERIFY(settings.data());
+
+ // verify that the initial value from QSettings gets properly loaded
+ // even if no initial value is set in QML
+ QCOMPARE(settings->property("value").toString(), QStringLiteral("initial"));
+}
+
QTEST_MAIN(tst_QQmlSettings)
#include "tst_qqmlsettings.moc"