summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIvan Solovev <ivan.solovev@qt.io>2022-03-25 13:18:08 +0100
committerIvan Solovev <ivan.solovev@qt.io>2022-03-25 22:43:49 +0100
commit904d613a51d77bb75fc093ce70685fe9483e3f17 (patch)
tree87cdb3f27b79c7d63e1f33921ede487061ce9881
parent5ef748d321a94fd8a00f8dc45a545830a9263874 (diff)
Android: activate tst_QPlugin
- Use QT_ANDROID_EXTRA_LIBS to correctly deploy libraries on Android. - Update the test code to use the application libraries directory instead of resources on Android. This allows to enable the test for Android in CMakeLists.txt Task-number: QTBUG-87438 Pick-to: 6.3 6.2 Change-Id: I2f6d2d4f3ab3872cf7d7fad1668b5c2c3eef3aad Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Alexey Edelev <alexey.edelev@qt.io> Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
-rw-r--r--tests/auto/corelib/plugin/CMakeLists.txt3
-rw-r--r--tests/auto/corelib/plugin/qplugin/CMakeLists.txt36
-rw-r--r--tests/auto/corelib/plugin/qplugin/tst_qplugin.cpp9
3 files changed, 34 insertions, 14 deletions
diff --git a/tests/auto/corelib/plugin/CMakeLists.txt b/tests/auto/corelib/plugin/CMakeLists.txt
index 14ce4c316d..e2ff4dc660 100644
--- a/tests/auto/corelib/plugin/CMakeLists.txt
+++ b/tests/auto/corelib/plugin/CMakeLists.txt
@@ -10,7 +10,6 @@ if(QT_FEATURE_library AND NOT ANDROID)
add_subdirectory(qpluginloader)
add_subdirectory(qlibrary)
endif()
-# QTBUG-87438 # special case
-if(QT_BUILD_SHARED_LIBS AND QT_FEATURE_library AND NOT ANDROID)
+if(QT_BUILD_SHARED_LIBS AND QT_FEATURE_library)
add_subdirectory(qplugin)
endif()
diff --git a/tests/auto/corelib/plugin/qplugin/CMakeLists.txt b/tests/auto/corelib/plugin/qplugin/CMakeLists.txt
index 2c901eff44..1713f8c2af 100644
--- a/tests/auto/corelib/plugin/qplugin/CMakeLists.txt
+++ b/tests/auto/corelib/plugin/qplugin/CMakeLists.txt
@@ -1,27 +1,41 @@
# Generated from qplugin.pro.
add_subdirectory(invalidplugin)
-
-# special case begin
add_subdirectory(debugplugin)
add_subdirectory(releaseplugin)
-# The contents below are generated from ./tst_qplugin.pro
-# Collect test data
-file(GLOB_RECURSE test_data_glob
- RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
- plugins/*)
-list(APPEND test_data ${test_data_glob})
-
qt_internal_add_test(tst_qplugin
SOURCES
tst_qplugin.cpp
LIBRARIES
Qt::CorePrivate
- TESTDATA ${test_data}
)
+if(NOT ANDROID)
+ # Collect test data
+ file(GLOB_RECURSE test_data_glob
+ RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
+ plugins/*)
+ list(APPEND test_data ${test_data_glob})
+ set_target_properties(tst_qplugin PROPERTIES TESTDATA "${test_data}")
+else()
+ # On Android the plugins must be located in the libs subdir of the APK.
+ # Use QT_ANDROID_EXTRA_LIBS to achieve that.
+ set(plugins
+ invalidplugin
+ debugplugin
+ releaseplugin
+ )
+ set(extra_libs)
+ foreach(plugin IN LISTS plugins)
+ list(APPEND extra_libs
+ "${CMAKE_CURRENT_BINARY_DIR}/plugins/lib${plugin}_${CMAKE_ANDROID_ARCH_ABI}.so")
+ endforeach()
+ set_target_properties(tst_qplugin PROPERTIES
+ QT_ANDROID_EXTRA_LIBS "${extra_libs}"
+ )
+endif()
+
target_compile_definitions(tst_qplugin PRIVATE CMAKE_BUILD=1)
add_dependencies(tst_qplugin invalidplugin debugplugin releaseplugin)
-# special case end
diff --git a/tests/auto/corelib/plugin/qplugin/tst_qplugin.cpp b/tests/auto/corelib/plugin/qplugin/tst_qplugin.cpp
index 6db2a80abc..569a84c51b 100644
--- a/tests/auto/corelib/plugin/qplugin/tst_qplugin.cpp
+++ b/tests/auto/corelib/plugin/qplugin/tst_qplugin.cpp
@@ -54,8 +54,15 @@ private slots:
};
tst_QPlugin::tst_QPlugin()
- : dir(QFINDTESTDATA("plugins"))
{
+ // On Android the plugins must be located in the APK's libs subdir
+#ifndef Q_OS_ANDROID
+ dir = QFINDTESTDATA("plugins");
+#else
+ const QStringList paths = QCoreApplication::libraryPaths();
+ if (!paths.isEmpty())
+ dir = paths.first();
+#endif
}
void tst_QPlugin::initTestCase()