diff options
Diffstat (limited to 'tests/auto/quick/qquickbehaviors')
5 files changed, 55 insertions, 3 deletions
diff --git a/tests/auto/quick/qquickbehaviors/CMakeLists.txt b/tests/auto/quick/qquickbehaviors/CMakeLists.txt index b66226776a..4c79b376a8 100644 --- a/tests/auto/quick/qquickbehaviors/CMakeLists.txt +++ b/tests/auto/quick/qquickbehaviors/CMakeLists.txt @@ -7,6 +7,12 @@ ## tst_qquickbehaviors Test: ##################################################################### +if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT) + cmake_minimum_required(VERSION 3.16) + project(tst_qquickbehaviors LANGUAGES CXX) + find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST) +endif() + # Collect test data file(GLOB_RECURSE test_data_glob RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} diff --git a/tests/auto/quick/qquickbehaviors/bindable.h b/tests/auto/quick/qquickbehaviors/bindable.h index aa6acc6615..0eeed6f87a 100644 --- a/tests/auto/quick/qquickbehaviors/bindable.h +++ b/tests/auto/quick/qquickbehaviors/bindable.h @@ -1,5 +1,5 @@ // Copyright (C) 2021 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #ifndef BINDABLE_H #define BINDABLE_H diff --git a/tests/auto/quick/qquickbehaviors/data/duplicated.qml b/tests/auto/quick/qquickbehaviors/data/duplicated.qml new file mode 100644 index 0000000000..15518a05cf --- /dev/null +++ b/tests/auto/quick/qquickbehaviors/data/duplicated.qml @@ -0,0 +1,31 @@ +import QtQuick 2.0 +Rectangle { + id: main + + width: 400 + height: 400 + + property bool behavior1Triggered + property bool behavior2Triggered + + Behavior on x { + ScriptAction { script: behavior1Triggered = true } + } + Behavior on x { + ScriptAction { script: behavior2Triggered = true } + } + + MouseArea { + id: clicker + anchors.fill: parent + } + + states: State { + name: "moved" + when: clicker.pressed + PropertyChanges { + target: main + x: 200 + } + } +} diff --git a/tests/auto/quick/qquickbehaviors/data/qtbug21549-2.qml b/tests/auto/quick/qquickbehaviors/data/qtbug21549-2.qml index 23804af711..4c3d4a0d26 100644 --- a/tests/auto/quick/qquickbehaviors/data/qtbug21549-2.qml +++ b/tests/auto/quick/qquickbehaviors/data/qtbug21549-2.qml @@ -1,5 +1,5 @@ // Copyright (C) 2017 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only import QtQuick 2.0 diff --git a/tests/auto/quick/qquickbehaviors/tst_qquickbehaviors.cpp b/tests/auto/quick/qquickbehaviors/tst_qquickbehaviors.cpp index 5ea11729d8..e9720130f2 100644 --- a/tests/auto/quick/qquickbehaviors/tst_qquickbehaviors.cpp +++ b/tests/auto/quick/qquickbehaviors/tst_qquickbehaviors.cpp @@ -1,5 +1,5 @@ // Copyright (C) 2021 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #include <QtTest/QtTest> #include <qsignalspy.h> #include <QtQml/qqmlengine.h> @@ -33,6 +33,7 @@ private slots: void group(); void valueType(); void emptyBehavior(); + void duplicatedBehavior(); void explicitSelection(); void nonSelectingBehavior(); void reassignedAnimation(); @@ -223,6 +224,20 @@ void tst_qquickbehaviors::emptyBehavior() QCOMPARE(x, qreal(200)); //should change immediately } +void tst_qquickbehaviors::duplicatedBehavior() +{ + QTest::failOnWarning(QRegularExpression(".*")); + QTest::ignoreMessage(QtMsgType::QtWarningMsg, + QRegularExpression("Attempting to set another interceptor on.*")); + QQmlEngine engine; + QQmlComponent c(&engine, testFileUrl("duplicated.qml")); + QScopedPointer<QQuickRectangle> rect(qobject_cast<QQuickRectangle *>(c.create())); + QVERIFY2(!rect.isNull(), qPrintable(c.errorString())); + + // Expecting no crash + QQuickItemPrivate::get(rect.data())->setState("moved"); +} + void tst_qquickbehaviors::explicitSelection() { QQmlEngine engine; |