diff --git a/tests/auto/qml/connectioneditor/tst_connectioneditor.cpp b/tests/auto/qml/connectioneditor/tst_connectioneditor.cpp index 7df48b92f37..61e19d1253d 100644 --- a/tests/auto/qml/connectioneditor/tst_connectioneditor.cpp +++ b/tests/auto/qml/connectioneditor/tst_connectioneditor.cpp @@ -35,6 +35,7 @@ private slots: void parseConsoleLog(); void parseCallFunction(); void parseEmpty(); + void parseComplexCondition(); QByteArray countOne(); private: @@ -337,6 +338,42 @@ void tst_ConnectionEditor::parseEmpty() QVERIFY(std::holds_alternative(parsedStatement)); } +void tst_ConnectionEditor::parseComplexCondition() +{ + auto result = ConnectionEditorEvaluator::parseStatement( + "{if (someItem.deeper.gothis && thistest.is.getit){someItem.trigger()}}"); + auto &matchedCondition = ConnectionEditorStatements::matchedCondition(result); + QCOMPARE(matchedCondition.statements.count(), 2); + + auto firstStatement = matchedCondition.statements.first(); + QVERIFY(std::holds_alternative(firstStatement)); + + auto variable = std::get(firstStatement); + + QCOMPARE(variable.nodeId, "someItem"); + QCOMPARE(variable.propertyName, "deeper.gothis"); + + auto lastStatement = matchedCondition.statements.last(); + QVERIFY(std::holds_alternative(lastStatement)); + + variable = std::get(lastStatement); + + QCOMPARE(variable.nodeId, "thistest"); + QCOMPARE(variable.propertyName, "is.getit"); + + matchedCondition.statements.clear(); + matchedCondition.tokens.clear(); + + variable.nodeId = "justId"; + variable.propertyName = {}; + + matchedCondition.statements.append(variable); + + const QString source = ConnectionEditorStatements::toJavascript(result); + + QVERIFY(source.startsWith("if (justId)")); +} + void tst_ConnectionEditor::test01() { QFETCH(QString, statement);