summaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
authorJuha Vuolle <juha.vuolle@insta.fi>2021-05-07 14:20:07 +0300
committerJuha Vuolle <juha.vuolle@insta.fi>2021-05-10 13:56:39 +0300
commit1cd5a96bb3e2a2954b502e41d0711b7d5479e179 (patch)
tree805dbb8fa862512d88d6e496338d82f9f1bf3dbf /tests/auto
parent0654884519446190051ba791c56354ccb3e8425f (diff)
Enable StateMachine QML tests as autotests and add one testcase
The QML autotests are now built and run as part of the autotests, where they previously relied on running with qmltestrunner manually. Also fixes one testcase warning about missing 'initialState'. Additionally this commit adds one QML testcase which tests a Scxml bug that was specific to Qt5; while the bug does not happen with Qt6 it is important to add the test case also to Qt6 to catch any regression in the future. Change-Id: I8fbaa44dab52b64a4d2c5c73ad5d3e3ff2eb0346 Reviewed-by: Karsten Heimrich <karsten.heimrich@qt.io>
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/qmltest/CMakeLists.txt1
-rw-r--r--tests/auto/qmltest/scxml/CMakeLists.txt27
-rw-r--r--tests/auto/qmltest/scxml/statemachine.scxml45
-rw-r--r--tests/auto/qmltest/scxml/tst_dynamic.qml52
-rw-r--r--tests/auto/qmltest/scxml/tst_scxmlqml.cpp30
-rw-r--r--tests/auto/qmltest/scxml/tst_scxmlqml.qrc5
-rw-r--r--tests/auto/qmltest/statemachine/CMakeLists.txt14
-rw-r--r--tests/auto/qmltest/statemachine/tst_anonymousstate.qml2
-rw-r--r--tests/auto/qmltest/statemachine/tst_statemachineqml.cpp30
9 files changed, 201 insertions, 5 deletions
diff --git a/tests/auto/qmltest/CMakeLists.txt b/tests/auto/qmltest/CMakeLists.txt
index 3a4da03..c1a2719 100644
--- a/tests/auto/qmltest/CMakeLists.txt
+++ b/tests/auto/qmltest/CMakeLists.txt
@@ -1,2 +1,3 @@
add_subdirectory(statemachine)
+add_subdirectory(scxml)
diff --git a/tests/auto/qmltest/scxml/CMakeLists.txt b/tests/auto/qmltest/scxml/CMakeLists.txt
new file mode 100644
index 0000000..64bec63
--- /dev/null
+++ b/tests/auto/qmltest/scxml/CMakeLists.txt
@@ -0,0 +1,27 @@
+# Collect test data
+file(GLOB_RECURSE test_data_glob
+ RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
+ ${CMAKE_CURRENT_SOURCE_DIR}/tst_*)
+list(APPEND test_data ${test_data_glob})
+
+qt_internal_add_test(tst_scxmlqml
+ GUI
+ QMLTEST
+ SOURCES
+ tst_scxmlqml.cpp
+ PUBLIC_LIBRARIES
+ Qt::Gui
+ TESTDATA ${test_data}
+)
+
+# Resources:
+set(tst_scxmlqml_resource_files
+ "statemachine.scxml"
+)
+
+qt_internal_add_resource(tst_scxmlqml "tst_scxmlqml"
+ PREFIX
+ "/"
+ FILES
+ ${tst_scxmlqml_resource_files}
+)
diff --git a/tests/auto/qmltest/scxml/statemachine.scxml b/tests/auto/qmltest/scxml/statemachine.scxml
new file mode 100644
index 0000000..68c9768
--- /dev/null
+++ b/tests/auto/qmltest/scxml/statemachine.scxml
@@ -0,0 +1,45 @@
+<?xml version="1.0" ?>
+<!--
+/****************************************************************************
+**
+** Copyright (C) 2021 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtScxml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+-->
+<scxml xmlns="http://www.w3.org/2005/07/scxml"
+ version="1.0"
+ name="ColorStepper"
+ initial="red">
+
+ <state id = "red">
+ <transition target="yellow" event="step"/>
+ </state>
+
+ <state id = "yellow">
+ <transition target="green" event="step"/>
+ </state>
+
+ <final id="green"/>
+</scxml>
diff --git a/tests/auto/qmltest/scxml/tst_dynamic.qml b/tests/auto/qmltest/scxml/tst_dynamic.qml
new file mode 100644
index 0000000..f8c411d
--- /dev/null
+++ b/tests/auto/qmltest/scxml/tst_dynamic.qml
@@ -0,0 +1,52 @@
+/****************************************************************************
+**
+** Copyright (C) 2021 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtTest 1.15
+import QtScxml 5.15
+
+TestCase {
+ id: testCase
+
+ StateMachineLoader {
+ id: loader
+ source: "qrc:///statemachine.scxml"
+ }
+
+ function test_overloaded_calls_with_dynamic_statemachine()
+ {
+ // This test calls "submitEvent" invokable function which has 3
+ // overloads, differentiated both by parameter types and amounts.
+ // Test verifies that the overloads are callable while using
+ // a dynamic statemachine which has a dynamic metaobject under the hood
+ tryVerify(() => loader.stateMachine.activeStateNames()[0] === "red", 200)
+ loader.stateMachine.submitEvent("step")
+ tryVerify(() => loader.stateMachine.activeStateNames()[0] === "yellow", 200)
+ loader.stateMachine.submitEvent("step", "somedata")
+ tryVerify(() => loader.stateMachine.activeStateNames()[0] === "green", 200)
+ }
+}
diff --git a/tests/auto/qmltest/scxml/tst_scxmlqml.cpp b/tests/auto/qmltest/scxml/tst_scxmlqml.cpp
new file mode 100644
index 0000000..a32c12a
--- /dev/null
+++ b/tests/auto/qmltest/scxml/tst_scxmlqml.cpp
@@ -0,0 +1,30 @@
+/****************************************************************************
+**
+** Copyright (C) 2021 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtQuickTest/quicktest.h>
+QUICK_TEST_MAIN(tst_scxmlqml)
diff --git a/tests/auto/qmltest/scxml/tst_scxmlqml.qrc b/tests/auto/qmltest/scxml/tst_scxmlqml.qrc
new file mode 100644
index 0000000..241bd0b
--- /dev/null
+++ b/tests/auto/qmltest/scxml/tst_scxmlqml.qrc
@@ -0,0 +1,5 @@
+<RCC>
+ <qresource prefix="/">
+ <file>statemachine.scxml</file>
+ </qresource>
+</RCC>
diff --git a/tests/auto/qmltest/statemachine/CMakeLists.txt b/tests/auto/qmltest/statemachine/CMakeLists.txt
index de9b470..5f80b69 100644
--- a/tests/auto/qmltest/statemachine/CMakeLists.txt
+++ b/tests/auto/qmltest/statemachine/CMakeLists.txt
@@ -1,11 +1,15 @@
+# Collect test data
+file(GLOB_RECURSE test_data_glob
+ RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
+ ${CMAKE_CURRENT_SOURCE_DIR}/tst_*)
+list(APPEND test_data ${test_data_glob})
-#####################################################################
-## statemachine Test:
-#####################################################################
-
-qt_internal_add_test(statemachine
+qt_internal_add_test(tst_statemachineqml
GUI
QMLTEST
+ SOURCES
+ tst_statemachineqml.cpp
PUBLIC_LIBRARIES
Qt::Gui
+ TESTDATA ${test_data}
)
diff --git a/tests/auto/qmltest/statemachine/tst_anonymousstate.qml b/tests/auto/qmltest/statemachine/tst_anonymousstate.qml
index 4f60a29..acfff65 100644
--- a/tests/auto/qmltest/statemachine/tst_anonymousstate.qml
+++ b/tests/auto/qmltest/statemachine/tst_anonymousstate.qml
@@ -32,7 +32,9 @@ import QtQml.StateMachine
TestCase {
StateMachine {
State {
+ id: stateId
}
+ initialState: stateId
}
name: "anonymousState"
// no real tests, just make sure it runs
diff --git a/tests/auto/qmltest/statemachine/tst_statemachineqml.cpp b/tests/auto/qmltest/statemachine/tst_statemachineqml.cpp
new file mode 100644
index 0000000..90638a5
--- /dev/null
+++ b/tests/auto/qmltest/statemachine/tst_statemachineqml.cpp
@@ -0,0 +1,30 @@
+/****************************************************************************
+**
+** Copyright (C) 2021 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtQuickTest/quicktest.h>
+QUICK_TEST_MAIN(tst_statemachineqml)