From ae966127fd7c14669dc202a6d30dc8cf56164f94 Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Mon, 26 Mar 2018 10:17:56 +0200 Subject: Improve QtQuickCompiler cmake tests Perform not only a build test when running the cmake tests, also run the resulting testlib based binary to verify the toolchain end to end. Change-Id: Ic962edf10b810b36f3feb68df55e7230841865d6 Reviewed-by: Kevin Funk --- tests/auto/cmake/CMakeLists.txt | 1 + tests/auto/cmake/qtquickcompiler/CMakeLists.txt | 5 ++++- tests/auto/cmake/qtquickcompiler/main.cpp | 29 +++++++++++++++++++++---- tests/auto/cmake/qtquickcompiler/main.qml | 2 +- 4 files changed, 31 insertions(+), 6 deletions(-) diff --git a/tests/auto/cmake/CMakeLists.txt b/tests/auto/cmake/CMakeLists.txt index 4d4d8e3db7..f304a99705 100644 --- a/tests/auto/cmake/CMakeLists.txt +++ b/tests/auto/cmake/CMakeLists.txt @@ -25,4 +25,5 @@ add_test(qtquickcompiler ${CMAKE_CTEST_COMMAND} --build-makeprogram ${CMAKE_MAKE_PROGRAM} --build-project qqc_test --build-options "-DCMAKE_PREFIX_PATH=${CMAKE_PREFIX_PATH}" ${BUILD_OPTIONS_LIST} + --test-command qqc_test ) diff --git a/tests/auto/cmake/qtquickcompiler/CMakeLists.txt b/tests/auto/cmake/qtquickcompiler/CMakeLists.txt index 6dee1e25dc..ded79d87ed 100644 --- a/tests/auto/cmake/qtquickcompiler/CMakeLists.txt +++ b/tests/auto/cmake/qtquickcompiler/CMakeLists.txt @@ -4,11 +4,14 @@ project(qqc_test) find_package(Qt5Qml 5.0.0 REQUIRED) find_package(Qt5Gui 5.0.0 REQUIRED) +find_package(Qt5Test 5.0.0 REQUIRED) find_package(Qt5QuickCompiler) set(CMAKE_CXXFLAGS "${CMAKE_CXXFLAGS} ${Qt5Core_EXECUTABLE_COMPILE_FLAGS}") qtquick_compiler_add_resources(RESOURCES qqc_test.qrc) +set(CMAKE_AUTOMOC ON) + add_executable(qqc_test "${CMAKE_CURRENT_SOURCE_DIR}/main.cpp" ${RESOURCES}) -target_link_libraries(qqc_test Qt5::Gui Qt5::Qml) +target_link_libraries(qqc_test Qt5::Gui Qt5::Qml Qt5::Test) diff --git a/tests/auto/cmake/qtquickcompiler/main.cpp b/tests/auto/cmake/qtquickcompiler/main.cpp index 47fc709c0a..c357ef60e6 100644 --- a/tests/auto/cmake/qtquickcompiler/main.cpp +++ b/tests/auto/cmake/qtquickcompiler/main.cpp @@ -1,9 +1,30 @@ -#include +#include #include +#include -int main(int argc, char **argv) +class tst_QQC : public QObject { - QGuiApplication app(argc, argv); - return app.exec(); + Q_OBJECT +private slots: + void packaging(); +}; + +void tst_QQC::packaging() +{ + QVERIFY(QFile::exists(":/main.qml")); + QCOMPARE(QFileInfo(":/main.qml").size(), 0); + QVERIFY(QFile::exists(":/main.cpp")); + QVERIFY(QFileInfo(":/main.cpp").size() > 0); + + + QQmlEngine engine; + QQmlComponent component(&engine, QUrl("qrc:/main.qml")); + QScopedPointer obj(component.create()); + QVERIFY(!obj.isNull()); + QCOMPARE(obj->property("success").toInt(), 42); } + +QTEST_MAIN(tst_QQC) + +#include "main.moc" diff --git a/tests/auto/cmake/qtquickcompiler/main.qml b/tests/auto/cmake/qtquickcompiler/main.qml index 1f146d89c3..0836808dc2 100644 --- a/tests/auto/cmake/qtquickcompiler/main.qml +++ b/tests/auto/cmake/qtquickcompiler/main.qml @@ -1,4 +1,4 @@ import QtQml 2.0 QtObject { - property bool success: 42 + property int success: 42 } -- cgit v1.2.3