summaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
authorLorn Potter <lorn.potter@gmail.com>2021-01-06 07:30:03 +1000
committerJuha Vuolle <juha.vuolle@insta.fi>2021-04-19 13:29:47 +0300
commit45c8ae3232df8955644697ee88c4321f26bb5cf2 (patch)
tree77edea26c249ce6bb8a921fe67c266d3c95e094a /tests/auto
parent5a8aa096dc61336ac95734e8cc61f106e359c865 (diff)
QtSensors initial cmake support
This commit introduces the bare minimum cmake support that should unblock the CI and allow further verification and development on most platforms: macOS, Linux, Win, iOS and Android. Some clarifications: * The support for sensorfw backend is very preliminary and can be enabled later if needed (no Qt6 version of the sensorfw). * The simulator backend is dropped as obsolete / unnecessary. * Three examples are currently commented out and shall be ported with a later commit. Task-number: QTBUG-92502 Change-Id: Id523d43ed3ef177010dc73afc5812ed374cff0dd Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/CMakeLists.txt10
-rw-r--r--tests/auto/auto.pro14
-rw-r--r--tests/auto/cmake/CMakeLists.txt45
-rw-r--r--tests/auto/cmake/cmake.pro7
-rw-r--r--tests/auto/legacy_sensors/CMakeLists.txt16
-rw-r--r--tests/auto/legacy_sensors/legacy_sensors.pro15
-rw-r--r--tests/auto/qsensor/CMakeLists.txt19
-rw-r--r--tests/auto/qsensor/qsensor.pro27
-rw-r--r--tests/auto/qsensorgestureplugins/CMakeLists.txt14
-rw-r--r--tests/auto/qsensorgestureplugins/qsensorgestureplugins.pro17
-rw-r--r--tests/auto/qsensorgestures/CMakeLists.txt18
-rw-r--r--tests/auto/qsensorgestures/plugins/test1/CMakeLists.txt21
-rw-r--r--tests/auto/qsensorgestures/plugins/test1/test1.pro18
-rw-r--r--tests/auto/qsensorgestures/qsensorgestures.pro34
-rw-r--r--tests/auto/qsensorgestures_gestures/CMakeLists.txt19
-rw-r--r--tests/auto/qsensorgestures_gestures/qsensorgestures_gestures.pro21
-rw-r--r--tests/auto/qtsensors5/qtsensors5.pro6
-rw-r--r--tests/auto/qtsensors5/tst_qtsensors5.cpp54
-rw-r--r--tests/auto/sensors2qmlapi/CMakeLists.txt17
-rw-r--r--tests/auto/sensors2qmlapi/sensors2qmlapi.pro20
20 files changed, 172 insertions, 240 deletions
diff --git a/tests/auto/CMakeLists.txt b/tests/auto/CMakeLists.txt
new file mode 100644
index 00000000..8f1c9ec7
--- /dev/null
+++ b/tests/auto/CMakeLists.txt
@@ -0,0 +1,10 @@
+add_subdirectory(qsensor)
+add_subdirectory(qsensorgestures)
+add_subdirectory(qsensorgestureplugins)
+add_subdirectory(cmake)
+if(TARGET Qt::Quick)
+ add_subdirectory(sensors2qmlapi)
+endif()
+if(UNIX AND NOT APPLE)
+ add_subdirectory(qsensorgestures_gestures)
+endif()
diff --git a/tests/auto/auto.pro b/tests/auto/auto.pro
deleted file mode 100644
index ffcb62cf..00000000
--- a/tests/auto/auto.pro
+++ /dev/null
@@ -1,14 +0,0 @@
-TEMPLATE = subdirs
-
-SUBDIRS += qsensor
-qtHaveModule(qml) {
- SUBDIRS += sensors2qmlapi
- SUBDIRS += qtsensors5
-}
-#SUBDIRS += legacy_sensors
-SUBDIRS += qsensorgestures
-SUBDIRS += qsensorgestureplugins
-SUBDIRS += cmake
-
-!mac:!win32:SUBDIRS += qsensorgestures_gestures
-
diff --git a/tests/auto/cmake/CMakeLists.txt b/tests/auto/cmake/CMakeLists.txt
index 4eba8604..cd0dfda1 100644
--- a/tests/auto/cmake/CMakeLists.txt
+++ b/tests/auto/cmake/CMakeLists.txt
@@ -1,14 +1,45 @@
+# This is an automatic test for the CMake configuration files.
+# To run it manually,
+# 1) mkdir build # Create a build directory
+# 2) cd build
+# 3) # Run cmake on this directory
+# `$qt_prefix/bin/qt-cmake ..` or `cmake -DCMAKE_PREFIX_PATH=/path/to/qt ..`
+# 4) ctest # Run ctest
-cmake_minimum_required(VERSION 2.8)
+cmake_minimum_required(VERSION 3.14)
+project(sensors_cmake_tests)
+enable_testing()
-project(qmake_cmake_files)
+set(required_packages Core Sensors)
-enable_testing()
+# Setup the test when called as a completely standalone project.
+if(TARGET Qt6::Core)
+ # Tests are built as part of the qtsensors build tree.
+ # Setup paths so that the Qt packages are found.
+ qt_internal_set_up_build_dir_package_paths()
+endif()
+
+find_package(Qt6 REQUIRED COMPONENTS ${required_packages})
-find_package(Qt5Core REQUIRED)
+# Setup common test variables which were previously set by ctest_testcase_common.prf.
+set(CMAKE_MODULES_UNDER_TEST "${required_packages}")
-include("${_Qt5CTestMacros}")
+foreach(qt_package ${CMAKE_MODULES_UNDER_TEST})
+ set(package_name "${QT_CMAKE_EXPORT_NAMESPACE}${qt_package}")
+ if(${package_name}_FOUND)
+ set(CMAKE_${qt_package}_MODULE_MAJOR_VERSION "${${package_name}_VERSION_MAJOR}")
+ set(CMAKE_${qt_package}_MODULE_MINOR_VERSION "${${package_name}_VERSION_MINOR}")
+ set(CMAKE_${qt_package}_MODULE_PATCH_VERSION "${${package_name}_VERSION_PATCH}")
+ endif()
+endforeach()
+
+include("${_Qt6CTestMacros}")
+
+set(module_includes
+ Sensors QLightSensor
+ Sensors QRotationSensor
+)
-test_module_includes(
- Sensors QLightSensor
+_qt_internal_test_module_includes(
+ ${module_includes}
)
diff --git a/tests/auto/cmake/cmake.pro b/tests/auto/cmake/cmake.pro
deleted file mode 100644
index f8c4e0a9..00000000
--- a/tests/auto/cmake/cmake.pro
+++ /dev/null
@@ -1,7 +0,0 @@
-
-# Cause make to do nothing.
-TEMPLATE = subdirs
-
-CMAKE_QT_MODULES_UNDER_TEST = sensors
-
-CONFIG += ctest_testcase
diff --git a/tests/auto/legacy_sensors/CMakeLists.txt b/tests/auto/legacy_sensors/CMakeLists.txt
new file mode 100644
index 00000000..8ed9eeb0
--- /dev/null
+++ b/tests/auto/legacy_sensors/CMakeLists.txt
@@ -0,0 +1,16 @@
+#####################################################################
+## tst_legacy_sensors Binary:
+#####################################################################
+
+qt_internal_add_test(tst_legacy_sensors
+ SOURCES
+ ../qsensor/test_backends.cpp ../qsensor/test_backends.h
+ tst_legacy_sensors.cpp
+ INCLUDE_DIRECTORIES
+ ../qsensor
+ PUBLIC_LIBRARIES
+ Qt::Gui
+ Qt::Qml
+ Qt::Sensors
+ Qt::Test
+)
diff --git a/tests/auto/legacy_sensors/legacy_sensors.pro b/tests/auto/legacy_sensors/legacy_sensors.pro
deleted file mode 100644
index daf0185d..00000000
--- a/tests/auto/legacy_sensors/legacy_sensors.pro
+++ /dev/null
@@ -1,15 +0,0 @@
-TEMPLATE=app
-TARGET=tst_legacy_sensors
-!no_system_tests:CONFIG += testcase
-QT = core testlib gui qml sensors
-SOURCES += tst_legacy_sensors.cpp
-
-VPATH += ../qsensor
-INCLUDEPATH += ../qsensor
-
-HEADERS += \
- test_backends.h
-
-SOURCES += \
- test_backends.cpp
-
diff --git a/tests/auto/qsensor/CMakeLists.txt b/tests/auto/qsensor/CMakeLists.txt
new file mode 100644
index 00000000..3cdb4cf8
--- /dev/null
+++ b/tests/auto/qsensor/CMakeLists.txt
@@ -0,0 +1,19 @@
+#####################################################################
+## tst_qsensor Test:
+#####################################################################
+
+qt_internal_add_test(tst_qsensor
+ SOURCES
+ test_backends.cpp test_backends.h
+ test_sensor.cpp test_sensor.h test_sensor_p.h
+ test_sensor2.cpp test_sensor2.h test_sensor2_p.h
+ test_sensor2impl.cpp test_sensor2impl.h
+ test_sensorimpl.cpp test_sensorimpl.h
+ test_sensorplugin.cpp
+ tst_qsensor.cpp
+ DEFINES
+ QT_STATICPLUGIN
+ PUBLIC_LIBRARIES
+ Qt::CorePrivate
+ Qt::SensorsPrivate
+)
diff --git a/tests/auto/qsensor/qsensor.pro b/tests/auto/qsensor/qsensor.pro
deleted file mode 100644
index 1366a5df..00000000
--- a/tests/auto/qsensor/qsensor.pro
+++ /dev/null
@@ -1,27 +0,0 @@
-TEMPLATE = app
-TARGET = tst_qsensor
-
-CONFIG += testcase
-QT = core-private testlib sensors-private
-DEFINES += QT_STATICPLUGIN
-
-SOURCES += \
- tst_qsensor.cpp
-
-HEADERS += \
- test_sensor.h\
- test_sensor_p.h\
- test_sensorimpl.h\
- test_sensor2.h\
- test_sensor2_p.h\
- test_sensor2impl.h\
- test_backends.h
-
-SOURCES += \
- test_sensor.cpp\
- test_sensorimpl.cpp\
- test_sensor2.cpp\
- test_sensor2impl.cpp\
- test_sensorplugin.cpp\
- test_backends.cpp
-
diff --git a/tests/auto/qsensorgestureplugins/CMakeLists.txt b/tests/auto/qsensorgestureplugins/CMakeLists.txt
new file mode 100644
index 00000000..676098df
--- /dev/null
+++ b/tests/auto/qsensorgestureplugins/CMakeLists.txt
@@ -0,0 +1,14 @@
+#####################################################################
+## tst_qsensorgesturepluginstest Binary:
+#####################################################################
+
+qt_internal_add_test(tst_qsensorgesturepluginstest
+ SOURCES
+ ../qsensor/test_backends.cpp ../qsensor/test_backends.h
+ tst_qsensorgesturepluginstest.cpp
+ INCLUDE_DIRECTORIES
+ ../qsensor
+ PUBLIC_LIBRARIES
+ Qt::Sensors
+ Qt::Test
+)
diff --git a/tests/auto/qsensorgestureplugins/qsensorgestureplugins.pro b/tests/auto/qsensorgestureplugins/qsensorgestureplugins.pro
deleted file mode 100644
index 117afab1..00000000
--- a/tests/auto/qsensorgestureplugins/qsensorgestureplugins.pro
+++ /dev/null
@@ -1,17 +0,0 @@
-TEMPLATE = app
-TARGET = tst_qsensorgesturepluginstest
-!no_system_tests:CONFIG += testcase
-
-QT += core testlib sensors
-QT -= gui
-
-SOURCES += tst_qsensorgesturepluginstest.cpp
-
-VPATH += ../qsensor
-INCLUDEPATH += ../qsensor
-
-HEADERS += \
- test_backends.h
-
-SOURCES += \
- test_backends.cpp
diff --git a/tests/auto/qsensorgestures/CMakeLists.txt b/tests/auto/qsensorgestures/CMakeLists.txt
new file mode 100644
index 00000000..dc107e3d
--- /dev/null
+++ b/tests/auto/qsensorgestures/CMakeLists.txt
@@ -0,0 +1,18 @@
+#####################################################################
+## tst_qsensorgesturetest Test:
+#####################################################################
+
+qt_internal_add_test(tst_qsensorgesturetest
+ SOURCES
+ plugins/test/qtest2recognizer.cpp plugins/test/qtest2recognizer.h
+ plugins/test/qtestrecognizer.cpp plugins/test/qtestrecognizer.h
+ plugins/test/qtestsensorgestureplugin.cpp plugins/test/qtestsensorgestureplugin_p.h
+ plugins/test1/qtest2recognizerdup.cpp plugins/test1/qtest2recognizerdup.h
+ plugins/test1/qtestrecognizerdup.cpp plugins/test1/qtestrecognizerdup.h
+ plugins/test1/qtestsensorgestureplugindup.cpp plugins/test1/qtestsensorgestureplugindup.h
+ tst_qsensorgesturetest.cpp
+ DEFINES
+ QT_STATICPLUGIN
+ PUBLIC_LIBRARIES
+ Qt::Sensors
+)
diff --git a/tests/auto/qsensorgestures/plugins/test1/CMakeLists.txt b/tests/auto/qsensorgestures/plugins/test1/CMakeLists.txt
new file mode 100644
index 00000000..8a9bc73c
--- /dev/null
+++ b/tests/auto/qsensorgestures/plugins/test1/CMakeLists.txt
@@ -0,0 +1,21 @@
+#####################################################################
+## QTestSensorGestureDupPlugin Plugin:
+#####################################################################
+
+qt_internal_add_plugin(QTestSensorGestureDupPlugin
+ OUTPUT_NAME qtsensorgestures_testplugin1
+ TYPE sensorgestures
+ DEFAULT_IF FALSE
+ SOURCES
+ qtest2recognizerduo.cpp
+ qtest2recognizerdup.h
+ qtestrecognizerdup.cpp qtestrecognizerdup.h
+ qtestsensorgestureplugindup.cpp qtestsensorgestureplugindup_p.h
+ DEFINES
+ QT_DISABLE_DEPRECATED_BEFORE=0
+ PUBLIC_LIBRARIES
+ Qt::Core
+ Qt::Gui
+ Qt::Sensors
+ Qt::SensorGestures
+)
diff --git a/tests/auto/qsensorgestures/plugins/test1/test1.pro b/tests/auto/qsensorgestures/plugins/test1/test1.pro
deleted file mode 100644
index 5f890689..00000000
--- a/tests/auto/qsensorgestures/plugins/test1/test1.pro
+++ /dev/null
@@ -1,18 +0,0 @@
-TARGET = qtsensorgestures_testplugin1
-
-QT += sensors sensorgestures
-
-# Input
-HEADERS += qtestsensorgestureplugindup_p.h \
- qtestrecognizerdup.h \
- qtest2recognizerdup.h
-SOURCES += qtestsensorgestureplugindup.cpp \
- qtestrecognizerdup.cpp \
- qtest2recognizerduo.cpp
-
-DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0
-
-PLUGIN_TYPE = sensorgestures
-PLUGIN_CLASS_NAME = QTestSensorGestureDupPlugin
-PLUGIN_EXTENDS = -
-load(qt_plugin)
diff --git a/tests/auto/qsensorgestures/qsensorgestures.pro b/tests/auto/qsensorgestures/qsensorgestures.pro
deleted file mode 100644
index e3b152c7..00000000
--- a/tests/auto/qsensorgestures/qsensorgestures.pro
+++ /dev/null
@@ -1,34 +0,0 @@
-TEMPLATE = app
-TARGET = tst_qsensorgesturetest
-CONFIG += testcase
-DEFINES += QT_STATICPLUGIN
-
-QT += core testlib sensors
-QT -= gui
-
-SOURCES += tst_qsensorgesturetest.cpp
-
-
-PLUGIN_1_HEADERS = \
- plugins/test1/qtestsensorgestureplugindup.h \
- plugins/test1/qtestrecognizerdup.h \
- plugins/test1/qtest2recognizerdup.h
-
-PLUGIN_1_SOURCES = \
- plugins/test1/qtestsensorgestureplugindup.cpp \
- plugins/test1/qtestrecognizerdup.cpp \
- plugins/test1/qtest2recognizerdup.cpp
-
-HEADERS += $$PLUGIN_1_HEADERS
-SOURCES += $$PLUGIN_1_SOURCES
-
-HEADERS += \
- plugins/test/qtestsensorgestureplugin_p.h \
- plugins/test/qtestrecognizer.h \
- plugins/test/qtest2recognizer.h
-
-SOURCES += \
- plugins/test/qtestsensorgestureplugin.cpp \
- plugins/test/qtestrecognizer.cpp \
- plugins/test/qtest2recognizer.cpp
-
diff --git a/tests/auto/qsensorgestures_gestures/CMakeLists.txt b/tests/auto/qsensorgestures_gestures/CMakeLists.txt
new file mode 100644
index 00000000..cebdf1a1
--- /dev/null
+++ b/tests/auto/qsensorgestures_gestures/CMakeLists.txt
@@ -0,0 +1,19 @@
+#####################################################################
+## tst_sensorgestures_gestures Test:
+#####################################################################
+
+# Collect test data
+list(APPEND test_data "mock_data")
+list(APPEND test_data "dataset2_mock_data")
+
+qt_internal_add_test(tst_sensorgestures_gestures
+ SOURCES
+ mockbackends.h
+ mockcommon.cpp mockcommon.h
+ tst_sensorgestures_gestures.cpp
+ DEFINES
+ SRCDIR=\\\"${CMAKE_CURRENT_SOURCE_DIR}/\\\"
+ PUBLIC_LIBRARIES
+ Qt::SensorsPrivate
+ TESTDATA ${test_data}
+)
diff --git a/tests/auto/qsensorgestures_gestures/qsensorgestures_gestures.pro b/tests/auto/qsensorgestures_gestures/qsensorgestures_gestures.pro
deleted file mode 100644
index f2259d48..00000000
--- a/tests/auto/qsensorgestures_gestures/qsensorgestures_gestures.pro
+++ /dev/null
@@ -1,21 +0,0 @@
-TEMPLATE = app
-TARGET = tst_sensorgestures_gestures
-CONFIG += testcase
-
-QT += core testlib sensors-private
-QT -= gui
-
-CONFIG += console
-CONFIG -= app_bundle
-
-
-SOURCES += tst_sensorgestures_gestures.cpp \
- mockcommon.cpp
-
-DEFINES += SRCDIR=\\\"$$PWD/\\\"
-
-HEADERS += \
- mockcommon.h \
- mockbackends.h
-
-TESTDATA += mock_data dataset2_mock_data
diff --git a/tests/auto/qtsensors5/qtsensors5.pro b/tests/auto/qtsensors5/qtsensors5.pro
deleted file mode 100644
index a5101024..00000000
--- a/tests/auto/qtsensors5/qtsensors5.pro
+++ /dev/null
@@ -1,6 +0,0 @@
-TEMPLATE=app
-TARGET=tst_qtsensors5
-!no_system_tests:CONFIG += testcase
-QT = core testlib qml
-SOURCES += tst_qtsensors5.cpp
-
diff --git a/tests/auto/qtsensors5/tst_qtsensors5.cpp b/tests/auto/qtsensors5/tst_qtsensors5.cpp
deleted file mode 100644
index 01ed6140..00000000
--- a/tests/auto/qtsensors5/tst_qtsensors5.cpp
+++ /dev/null
@@ -1,54 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtSensors 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$
-**
-****************************************************************************/
-
-#include <QtTest/QtTest>
-#include <QQmlEngine>
-#include <QQmlComponent>
-
-class tst_QtSensors : public QObject
-{
- Q_OBJECT
-public:
- tst_QtSensors(QObject *parent = 0)
- : QObject(parent)
- {
- }
-
-private slots:
- void initTestCase()
- {
- }
-
- void cleanupTestCase()
- {
- }
-};
-
-QTEST_MAIN(tst_QtSensors)
-
-#include "tst_qtsensors5.moc"
diff --git a/tests/auto/sensors2qmlapi/CMakeLists.txt b/tests/auto/sensors2qmlapi/CMakeLists.txt
new file mode 100644
index 00000000..8e1a0ccf
--- /dev/null
+++ b/tests/auto/sensors2qmlapi/CMakeLists.txt
@@ -0,0 +1,17 @@
+#####################################################################
+## tst_sensors2qmlapi Test:
+#####################################################################
+
+qt_internal_add_test(tst_sensors2qmlapi
+ SOURCES
+ ../../../src/imports/sensors/qmlsensor.cpp ../../../src/imports/sensors/qmlsensor.h
+ ../../../src/imports/sensors/qmlsensorgesture.cpp ../../../src/imports/sensors/qmlsensorgesture.h
+ ../../../src/imports/sensors/qmlsensorrange.cpp ../../../src/imports/sensors/qmlsensorrange.h
+ qtemplategestureplugin.cpp qtemplategestureplugin.h
+ qtemplaterecognizer.cpp qtemplaterecognizer.h
+ tst_sensors2qmlapi.cpp
+ PUBLIC_LIBRARIES
+ Qt::Qml
+ LIBRARIES
+ Qt::SensorsPrivate
+)
diff --git a/tests/auto/sensors2qmlapi/sensors2qmlapi.pro b/tests/auto/sensors2qmlapi/sensors2qmlapi.pro
deleted file mode 100644
index 74388660..00000000
--- a/tests/auto/sensors2qmlapi/sensors2qmlapi.pro
+++ /dev/null
@@ -1,20 +0,0 @@
-TEMPLATE = app
-TARGET = tst_sensors2qmlapi
-
-CONFIG += testcase
-QT = core testlib sensors-private qml
-
-SOURCES += tst_sensors2qmlapi.cpp \
- ./../../../src/imports/sensors/qmlsensor.cpp \
- ./../../../src/imports/sensors/qmlsensorgesture.cpp \
- ./../../../src/imports/sensors/qmlsensorrange.cpp \
- qtemplategestureplugin.cpp \
- qtemplaterecognizer.cpp
-
-HEADERS += \
- ./../../../src/imports/sensors/qmlsensor.h \
- ./../../../src/imports/sensors/qmlsensorgesture.h \
- ./../../../src/imports/sensors/qmlsensorrange.h \
- qtemplategestureplugin.h \
- qtemplaterecognizer.h
-