aboutsummaryrefslogtreecommitdiffstats
path: root/tests/manual
diff options
context:
space:
mode:
authorLucie Gérard <lucie.gerard@qt.io>2023-11-20 14:40:11 +0100
committerLucie Gérard <lucie.gerard@qt.io>2023-11-22 08:23:59 +0100
commit877c90776568b6ef8c5abd9052230446ff9f6b69 (patch)
tree040689b7e3e52e5c70ac3539a1b86621329e26ce /tests/manual
parent38ebf3791e4a7eec00a017302eaa3ad9ceac824c (diff)
Move undocumented qmltest example to tests/manual
Task-number: QTBUG-119117 Change-Id: I92cd8c754f9442a8efb3e0dd2b4b791010cacc7c Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Diffstat (limited to 'tests/manual')
-rw-r--r--tests/manual/CMakeLists.txt1
-rw-r--r--tests/manual/qmltest/CMakeLists.txt47
-rw-r--r--tests/manual/qmltest/qmltest.pro26
-rw-r--r--tests/manual/qmltest/tst_basic.qml41
-rw-r--r--tests/manual/qmltest/tst_item.qml20
-rw-r--r--tests/manual/qmltest/tst_qmltest.cpp5
6 files changed, 140 insertions, 0 deletions
diff --git a/tests/manual/CMakeLists.txt b/tests/manual/CMakeLists.txt
index 94a0377a79..041dc7205d 100644
--- a/tests/manual/CMakeLists.txt
+++ b/tests/manual/CMakeLists.txt
@@ -25,3 +25,4 @@ endif()
add_subdirectory(qmlextensionplugins)
add_subdirectory(fontfeatures)
add_subdirectory(wasm)
+add_subdirectory(qmltest)
diff --git a/tests/manual/qmltest/CMakeLists.txt b/tests/manual/qmltest/CMakeLists.txt
new file mode 100644
index 0000000000..90d0d77749
--- /dev/null
+++ b/tests/manual/qmltest/CMakeLists.txt
@@ -0,0 +1,47 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
+cmake_minimum_required(VERSION 3.16)
+project(tst_qmltestexample LANGUAGES CXX)
+
+set(CMAKE_AUTOMOC ON)
+
+if(NOT DEFINED INSTALL_EXAMPLESDIR)
+ set(INSTALL_EXAMPLESDIR "examples")
+endif()
+
+set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/qmltest/qmltest")
+
+find_package(Qt6 REQUIRED COMPONENTS Core Gui QuickTest)
+
+qt_add_executable(tst_qmltestexample
+ tst_qmltest.cpp
+)
+
+set_target_properties(tst_qmltestexample PROPERTIES
+ WIN32_EXECUTABLE TRUE
+ MACOSX_BUNDLE TRUE
+)
+
+target_link_libraries(tst_qmltestexample PUBLIC
+ Qt6::Core
+ Qt6::Gui
+ Qt6::QuickTest
+)
+
+if(MACOS AND QT_BUILDING_QT)
+ set_target_properties(tst_qmltestexample PROPERTIES
+ MACOSX_BUNDLE FALSE
+ )
+endif()
+
+set(tst_files tst_basic.qml tst_item.qml)
+
+install(FILES ${tst_files}
+ DESTINATION "${INSTALL_EXAMPLEDIR}")
+
+install(TARGETS tst_qmltestexample
+ RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
+ BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
+ LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
+)
diff --git a/tests/manual/qmltest/qmltest.pro b/tests/manual/qmltest/qmltest.pro
new file mode 100644
index 0000000000..b5893c5a1e
--- /dev/null
+++ b/tests/manual/qmltest/qmltest.pro
@@ -0,0 +1,26 @@
+TEMPLATE=app
+TARGET=tst_qmltestexample
+
+SOURCES += tst_qmltest.cpp
+
+!QTDIR_build {
+# This is the code actual testcases should use:
+
+CONFIG += qmltestcase
+
+TESTDATA += tst_basic.qml tst_item.qml
+
+} else {
+# This code exists solely for the purpose of building this example
+# inside the examples/ hierarchy.
+
+QT += qml qmltest
+
+macx: CONFIG -= app_bundle
+
+target.path = $$[QT_INSTALL_EXAMPLES]/qmltest/qmltest
+qml.files = tst_basic.qml tst_item.qml
+qml.path = $$[QT_INSTALL_EXAMPLES]/qmltest/qmltest
+INSTALLS += target qml
+
+}
diff --git a/tests/manual/qmltest/tst_basic.qml b/tests/manual/qmltest/tst_basic.qml
new file mode 100644
index 0000000000..e3ce172beb
--- /dev/null
+++ b/tests/manual/qmltest/tst_basic.qml
@@ -0,0 +1,41 @@
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+import QtQuick
+import QtTest
+
+TestCase {
+ name: "BasicTests"
+
+ function test_pass() {
+ compare(2 + 2, 4, "2 + 2")
+ }
+
+ function test_fail() {
+ expectFail("", "this is the fail we wanted")
+ compare(2 + 2, 5, "2 + 2")
+ }
+
+ function test_skip() {
+ skip("skipping")
+ }
+
+ function test_expecting() {
+ expectFail("", "this is the fail we wanted")
+ verify(false)
+ }
+
+ function test_table_data() {
+ return [
+ {tag: "2 + 2 = 4", a: 2, b: 2, answer: 4 },
+ {tag: "2 + 6 = 8", a: 2, b: 6, answer: 8 },
+ {tag: "2 + 2 = 5", a: 2, b: 2, answer: 5 }, // fail
+ ]
+ }
+
+ function test_table(data) {
+ if (data.answer === 5)
+ expectFail("", "this is the fail we wanted")
+ compare(data.a + data.b, data.answer)
+ }
+}
diff --git a/tests/manual/qmltest/tst_item.qml b/tests/manual/qmltest/tst_item.qml
new file mode 100644
index 0000000000..047bd254dd
--- /dev/null
+++ b/tests/manual/qmltest/tst_item.qml
@@ -0,0 +1,20 @@
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+import QtQuick
+import QtTest
+
+Rectangle {
+ id: foo
+ width: 640; height: 480
+ color: "cyan"
+
+ TestCase {
+ name: "ItemTests"
+ id: test1
+
+ function test_color() {
+ compare(foo.color, "#00ffff")
+ }
+ }
+}
diff --git a/tests/manual/qmltest/tst_qmltest.cpp b/tests/manual/qmltest/tst_qmltest.cpp
new file mode 100644
index 0000000000..d9b367c5a8
--- /dev/null
+++ b/tests/manual/qmltest/tst_qmltest.cpp
@@ -0,0 +1,5 @@
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+#include <QtQuickTest/quicktest.h>
+QUICK_TEST_MAIN(qmltestexample)