Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,13 @@ option( BUILD_TEXTDOCUMENT "Build the Grantlee textdocument library" TRUE )
option( BUILD_MAIN_PLUGINS "Build the Grantlee Templates plugins" TRUE )
option( BUILD_I18N_PLUGIN "Build the Grantlee Templates i18n plugin" TRUE )
option( BUILD_TESTS "Build the Grantlee tests" TRUE )
option( INSTALL_TESTS "Build and install the Grantlee tests" FALSE )
option( GRANTLEE_BUILD_WITH_QT6 "Build Grantlee with Qt 6" FALSE)

if (INSTALL_TESTS)
set(BUILD_TESTS TRUE)
endif()

if (BUILD_TESTS)
include (CTest)
enable_testing()
Expand Down
7 changes: 7 additions & 0 deletions templates/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@ endif()

set( EXECUTABLE_OUTPUT_PATH ${CMAKE_CURRENT_BINARY_DIR} )

if(INSTALL_TESTS)
set( GRANTLEE_PLUGIN_PATH ${CMAKE_INSTALL_PREFIX}/${LIB_INSTALL_DIR} )
else()
set( GRANTLEE_PLUGIN_PATH "${CMAKE_BINARY_DIR}/" )
endif()

configure_file(grantlee_paths.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/grantlee_paths.h)

Expand Down Expand Up @@ -83,6 +87,9 @@ macro(grantlee_templates_unit_tests)
)
add_test(${_testname} ${_testname}_exec )
target_link_libraries(${_testname}_exec Grantlee5::Templates template_test_builtins)
if (INSTALL_TESTS)
install(TARGETS ${_testname}_exec RUNTIME DESTINATION libexec/grantlee_tests)
endif()

if (Qt6Qml_FOUND)
target_compile_definitions(${_testname}_exec PRIVATE HAVE_QTQML_LIB)
Expand Down
15 changes: 14 additions & 1 deletion textdocument/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,25 @@ else()
endif()
target_compile_features(textdocument_test_builtins PUBLIC cxx_auto_type)


configure_file(testresource.qrc.cmake "${CMAKE_CURRENT_BINARY_DIR}/testresource.qrc")
set (_rcc_file "${CMAKE_CURRENT_BINARY_DIR}/testresource.qrc")

if (GRANTLEE_BUILD_WITH_QT6)
qt6_add_resources(_testresource_rcc_src ${_rcc_file} OPTIONS -root "/" )
else()
qt5_add_resources(_testresource_rcc_src ${_rcc_file} OPTIONS -root "/" )
endif()

macro(GRANTLEE_TEXTDOCUMENT_UNIT_TESTS)
foreach(_testname ${ARGN})
add_executable(${_testname}_exec ${_testname}.cpp)
add_executable(${_testname}_exec ${_testname}.cpp ${_testresource_rcc_src})
add_test(${_testname} ${_testname}_exec )
target_link_libraries(${_testname}_exec Grantlee::TextDocument textdocument_test_builtins)
set_property(GLOBAL APPEND PROPERTY TEST_COVERAGE "${CMAKE_CURRENT_BINARY_DIR}/${_testname}_exec" )
if (INSTALL_TESTS)
install(TARGETS ${_testname}_exec RUNTIME DESTINATION libexec/grantlee_tests)
endif()
endforeach(_testname)
endmacro(GRANTLEE_TEXTDOCUMENT_UNIT_TESTS)

Expand Down
11 changes: 9 additions & 2 deletions textdocument/tests/plainmarkupbuildertest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class TestPlainMarkupOutput : public CoverageObject
{
Q_OBJECT
private Q_SLOTS:

void initTestCase();
// Test paragraph contents:
void testSingleFormat();
void testDoubleFormat();
Expand Down Expand Up @@ -70,6 +70,13 @@ private Q_SLOTS:
void testNestedList();
};



void TestPlainMarkupOutput::initTestCase()
{
Q_INIT_RESOURCE(testresource);
}

void TestPlainMarkupOutput::testSingleFormat()
{
QTextDocument doc;
Expand Down Expand Up @@ -622,7 +629,7 @@ void TestPlainMarkupOutput::testLongDocument()
{
QTextDocument doc;

QFile sourceHtml(QFINDTESTDATA("sourcehtml"));
QFile sourceHtml(QStringLiteral(":/templates/sourcehtml"));
QVERIFY(sourceHtml.open(QIODevice::ReadOnly));
doc.setHtml(QString::fromLatin1(sourceHtml.readAll().constData()));

Expand Down
6 changes: 6 additions & 0 deletions textdocument/tests/testresource.qrc.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<!DOCTYPE RCC><RCC version="1.0">
<qresource prefix="/templates/">
<file alias="sourcehtml">@CMAKE_CURRENT_SOURCE_DIR@/sourcehtml</file>
</qresource>
@QM_FILES@
</RCC>