Add qml test for chatdocumenthandler

This commit is contained in:
James Graham
2025-12-22 13:39:28 +00:00
parent 4db1e1c437
commit aadc441686
6 changed files with 74 additions and 34 deletions

View File

@@ -110,3 +110,32 @@ ecm_add_test(
LINK_LIBRARIES neochat Qt::Test neochat_server Devtools
TEST_NAME modeltest
)
macro(add_qml_tests)
if (WIN32)
set(_extra_args -platform offscreen)
endif()
foreach(test ${ARGV})
add_test(NAME ${test}
COMMAND qmltest
${_extra_args}
-input ${test}
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
)
endforeach()
endmacro()
add_executable(qmltest qmltest.cpp)
target_link_libraries(qmltest
PRIVATE
Qt6::Qml
Qt6::QuickTest
LibNeoChat
LibNeoChatplugin
)
add_qml_tests(
chatdocumenthelpertest.qml
)

View File

@@ -0,0 +1,34 @@
// SPDX-FileCopyrightText: 2024 Carl Schwan <carl@carlschwan.eu>
// SPDX-License-Identifier: LGPL-2.0-or-later
import QtQuick
import QtTest
import org.kde.neochat.libneochat as LibNeoChat
TestCase {
name: "ChatDocumentHandlerTest"
LibNeoChat.ChatDocumentHandler {
id: documentHandler
}
TextEdit {
id: TextEdit
}
function test_empty(): void {
compare(documentHandler.type, LibNeoChat.ChatBarType.None);
compare(documentHandler.room, null);
compare(documentHandler.textItem, null);
compare(documentHandler.completionModel instanceof LibNeoChat.CompletionModel, true);
compare(documentHandler.atFirstLine, false);
compare(documentHandler.atLastLine, false);
compare(documentHandler.bold, false);
compare(documentHandler.italic, false);
compare(documentHandler.underline, false);
compare(documentHandler.strikethrough, false);
compare(documentHandler.style, 0);
compare(documentHandler.currentListStyle, 0);
}
}

9
autotests/qmltest.cpp Normal file
View File

@@ -0,0 +1,9 @@
/*
* SPDX-FileCopyrightText: 2020 Arjen Hiemstra <ahiemstra@heimr.nl>
*
* SPDX-License-Identifier: LGPL-2.0-or-later
*/
#include <quicktest.h>
QUICK_TEST_MAIN(Kirigami)