aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp')
-rw-r--r--tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp35
1 files changed, 35 insertions, 0 deletions
diff --git a/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp b/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp
index 3fd4e9c619..c629651040 100644
--- a/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp
+++ b/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp
@@ -41,6 +41,7 @@ private slots:
void attachedSelf();
void attachedType();
void badSequence();
+ void basicBlocksWithBackJump();
void bindToValueType();
void bindingExpression();
void blockComments();
@@ -700,6 +701,40 @@ void tst_QmlCppCodegen::badSequence()
QCOMPARE(dadsCousins.at(&dadsCousins, 0), other);
}
+static bool expectingMessage = false;
+static void handler(QtMsgType type, const QMessageLogContext &, const QString &message)
+{
+ QVERIFY(expectingMessage);
+ QCOMPARE(type, QtDebugMsg);
+ QCOMPARE(message, u"false");
+ expectingMessage = false;
+}
+
+void tst_QmlCppCodegen::basicBlocksWithBackJump()
+{
+ QQmlEngine engine;
+ QQmlComponent component(&engine, QUrl(u"qrc:/qt/qml/TestTypes/basicBlocksWithBackJump.qml"_s));
+ QVERIFY2(component.isReady(), qPrintable(component.errorString()));
+ QScopedPointer<QObject> o(component.create());
+ QVERIFY(!o.isNull());
+
+ const auto oldHandler = qInstallMessageHandler(&handler);
+ const auto guard = qScopeGuard([oldHandler]() { qInstallMessageHandler(oldHandler); });
+
+ // t1 does not log anything
+ QMetaObject::invokeMethod(o.data(), "t1");
+
+ // t2 logs "false" exactly once
+ expectingMessage = true;
+ QMetaObject::invokeMethod(o.data(), "t2");
+ QVERIFY(!expectingMessage);
+
+ // t3 logs "false" exactly once
+ expectingMessage = true;
+ QMetaObject::invokeMethod(o.data(), "t3");
+ QVERIFY(!expectingMessage);
+}
+
void tst_QmlCppCodegen::bindToValueType()
{
QQmlEngine engine;