aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/qml
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/qml')
-rw-r--r--tests/auto/qml/qmlcppcodegen/data/CMakeLists.txt1
-rw-r--r--tests/auto/qml/qmlcppcodegen/data/conversionDecrement.qml18
-rw-r--r--tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp22
3 files changed, 41 insertions, 0 deletions
diff --git a/tests/auto/qml/qmlcppcodegen/data/CMakeLists.txt b/tests/auto/qml/qmlcppcodegen/data/CMakeLists.txt
index ae2a172654..2228f4ad22 100644
--- a/tests/auto/qml/qmlcppcodegen/data/CMakeLists.txt
+++ b/tests/auto/qml/qmlcppcodegen/data/CMakeLists.txt
@@ -55,6 +55,7 @@ set(qml_files
compositesingleton.qml
construct.qml
contextParam.qml
+ conversionDecrement.qml
conversions.qml
conversions2.qml
curlygrouped.qml
diff --git a/tests/auto/qml/qmlcppcodegen/data/conversionDecrement.qml b/tests/auto/qml/qmlcppcodegen/data/conversionDecrement.qml
new file mode 100644
index 0000000000..fdce0fe65c
--- /dev/null
+++ b/tests/auto/qml/qmlcppcodegen/data/conversionDecrement.qml
@@ -0,0 +1,18 @@
+pragma Strict
+import QtQml
+
+QtObject {
+ id: panelGrid
+ property var pages: 4
+ property int currentPageIndex: 0
+
+ onPagesChanged: {
+ if (panelGrid.currentPageIndex === 0) {
+ panelGrid.currentPageIndex = panelGrid.pages - 2
+ } else if (panelGrid.currentPageIndex === panelGrid.pages - 1) {
+ panelGrid.currentPageIndex = 0
+ } else {
+ panelGrid.currentPageIndex -= 1
+ }
+ }
+}
diff --git a/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp b/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp
index 40b0fb78c2..81179be36d 100644
--- a/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp
+++ b/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp
@@ -123,6 +123,7 @@ private slots:
void objectToString();
void throwObjectName();
void javaScriptArgument();
+ void conversionDecrement();
};
void tst_QmlCppCodegen::simpleBinding()
@@ -2242,6 +2243,27 @@ void tst_QmlCppCodegen::javaScriptArgument()
QCOMPARE(o->property("d").toString(), u"9"_qs);
}
+void tst_QmlCppCodegen::conversionDecrement()
+{
+ QQmlEngine engine;
+ QQmlComponent c(&engine, QUrl(u"qrc:/TestTypes/conversionDecrement.qml"_s));
+
+ QVERIFY2(c.isReady(), qPrintable(c.errorString()));
+
+ QScopedPointer<QObject> o(c.create());
+ QVERIFY(!o.isNull());
+
+ QCOMPARE(o->property("currentPageIndex").toInt(), 0);
+ o->setProperty("pages", 5);
+ QCOMPARE(o->property("currentPageIndex").toInt(), 3);
+ o->setProperty("pages", 4);
+ QCOMPARE(o->property("currentPageIndex").toInt(), 0);
+ o->setProperty("pages", 6);
+ QCOMPARE(o->property("currentPageIndex").toInt(), 4);
+ o->setProperty("pages", 60);
+ QCOMPARE(o->property("currentPageIndex").toInt(), 3);
+}
+
void tst_QmlCppCodegen::runInterpreted()
{
#ifdef Q_OS_ANDROID