diff --git a/CMakeLists.txt b/CMakeLists.txt index d665a512..a4a5c9ff 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,122 +1,122 @@ cmake_minimum_required(VERSION 3.0) set(KF5_VERSION "5.40.0") # handled by release scripts set(KF5_DEP_VERSION "5.40.0") # handled by release scripts project(KTextEditor VERSION ${KF5_VERSION}) # ECM setup include(FeatureSummary) find_package(ECM 5.40.0 NO_MODULE) set_package_properties(ECM PROPERTIES TYPE REQUIRED DESCRIPTION "Extra CMake Modules." URL "https://projects.kde.org/projects/kdesupport/extra-cmake-modules") feature_summary(WHAT REQUIRED_PACKAGES_NOT_FOUND FATAL_ON_MISSING_REQUIRED_PACKAGES) # add own modules to search path, too set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH} ${ECM_KDE_MODULE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/cmake) include(ECMSetupVersion) include(ECMGenerateHeaders) include(CMakePackageConfigHelpers) include(CheckFunctionExists) include(CheckSymbolExists) include(KDEInstallDirs) include(KDEFrameworkCompilerSettings NO_POLICY_SCOPE) include(KDECMakeSettings) include(KDEPackageAppTemplates) include(GenerateExportHeader) include(ECMAddQch) option(BUILD_QCH "Build API documentation in QCH format (for e.g. Qt Assistant, Qt Creator & KDevelop)" OFF) add_feature_info(QCH ${BUILD_QCH} "API documentation in QCH format (for e.g. Qt Assistant, Qt Creator & KDevelop)") ecm_setup_version( PROJECT VARIABLE_PREFIX KTEXTEDITOR VERSION_HEADER "${CMAKE_CURRENT_BINARY_DIR}/ktexteditor_version.h" PACKAGE_VERSION_FILE "${CMAKE_CURRENT_BINARY_DIR}/KF5TextEditorConfigVersion.cmake" SOVERSION 5 ) # Dependencies set(REQUIRED_QT_VERSION 5.7.0) # Required Qt5 components to build this framework find_package(Qt5 ${REQUIRED_QT_VERSION} NO_MODULE REQUIRED Core Widgets Qml - Script PrintSupport Xml XmlPatterns) + PrintSupport Xml XmlPatterns) find_package(KF5Archive ${KF5_DEP_VERSION} REQUIRED) find_package(KF5Config ${KF5_DEP_VERSION} REQUIRED) find_package(KF5GuiAddons ${KF5_DEP_VERSION} REQUIRED) find_package(KF5I18n ${KF5_DEP_VERSION} REQUIRED) find_package(KF5KIO ${KF5_DEP_VERSION} REQUIRED) find_package(KF5Parts ${KF5_DEP_VERSION} REQUIRED) find_package(KF5Sonnet ${KF5_DEP_VERSION} REQUIRED) find_package(KF5IconThemes ${KF5_DEP_VERSION} REQUIRED) find_package(KF5SyntaxHighlighting ${KF5_DEP_VERSION} REQUIRED) # libgit2 integration, at least 0.22 with proper git_libgit2_init() find_package(LibGit2 "0.22.0") # EditorConfig integration find_package(EditorConfig) # vi mode on per default option (BUILD_VIMODE "Build vimode in" ON) # Subdirectories add_definitions(-DTRANSLATION_DOMAIN=\"ktexteditor5\") if (IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/po") ki18n_install(po) endif() add_subdirectory(src) if (BUILD_TESTING) add_subdirectory(autotests) endif() add_subdirectory(templates) # Create a Config.cmake and a ConfigVersion.cmake file and install them set(CMAKECONFIG_INSTALL_DIR "${KDE_INSTALL_CMAKEPACKAGEDIR}/KF5TextEditor") if (BUILD_QCH) ecm_install_qch_export( TARGETS KF5TextEditor_QCH FILE KF5TextEditorQchTargets.cmake DESTINATION "${CMAKECONFIG_INSTALL_DIR}" COMPONENT Devel ) set(PACKAGE_INCLUDE_QCHTARGETS "include(\"\${CMAKE_CURRENT_LIST_DIR}/KF5TextEditorQchTargets.cmake\")") endif() configure_package_config_file( "${CMAKE_CURRENT_SOURCE_DIR}/KF5TextEditorConfig.cmake.in" "${CMAKE_CURRENT_BINARY_DIR}/KF5TextEditorConfig.cmake" INSTALL_DESTINATION "${CMAKECONFIG_INSTALL_DIR}" ) install(FILES "${CMAKE_CURRENT_BINARY_DIR}/KF5TextEditorConfig.cmake" "${CMAKE_CURRENT_BINARY_DIR}/KF5TextEditorConfigVersion.cmake" DESTINATION "${CMAKECONFIG_INSTALL_DIR}" COMPONENT Devel ) install(EXPORT KF5TextEditorTargets DESTINATION "${CMAKECONFIG_INSTALL_DIR}" FILE KF5TextEditorTargets.cmake NAMESPACE KF5:: ) install(FILES "${CMAKE_CURRENT_BINARY_DIR}/ktexteditor_version.h" DESTINATION "${KDE_INSTALL_INCLUDEDIR_KF5}" COMPONENT Devel ) # config.h check_symbol_exists (fdatasync unistd.h HAVE_FDATASYNC) configure_file (config.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config.h) # let our config.h be found first in any case include_directories (BEFORE ${CMAKE_CURRENT_BINARY_DIR}) feature_summary(WHAT ALL FATAL_ON_MISSING_REQUIRED_PACKAGES) diff --git a/autotests/CMakeLists.txt b/autotests/CMakeLists.txt index 25d30615..12ecc8ac 100644 --- a/autotests/CMakeLists.txt +++ b/autotests/CMakeLists.txt @@ -1,157 +1,156 @@ find_package(Qt5 ${REQUIRED_QT_VERSION} CONFIG REQUIRED Test) include(ECMMarkAsTest) include(ECMAddTests) remove_definitions(-DQT_NO_CAST_FROM_ASCII) set( EXECUTABLE_OUTPUT_PATH ${CMAKE_CURRENT_BINARY_DIR} ) include_directories( # for config.h ${CMAKE_BINARY_DIR} # for generated ktexteditor headers ${CMAKE_BINARY_DIR}/src/include # for normal sources ${CMAKE_SOURCE_DIR}/src ${CMAKE_SOURCE_DIR}/src/include ${CMAKE_SOURCE_DIR}/src/buffer ${CMAKE_SOURCE_DIR}/src/completion ${CMAKE_SOURCE_DIR}/src/dialogs ${CMAKE_SOURCE_DIR}/src/document ${CMAKE_SOURCE_DIR}/src/script ${CMAKE_SOURCE_DIR}/src/mode ${CMAKE_SOURCE_DIR}/src/render ${CMAKE_SOURCE_DIR}/src/search ${CMAKE_SOURCE_DIR}/src/syntax ${CMAKE_SOURCE_DIR}/src/undo ${CMAKE_SOURCE_DIR}/src/utils ${CMAKE_SOURCE_DIR}/src/view ) add_definitions(-DTEST_DATA_DIR=\"${CMAKE_SOURCE_DIR}/autotests/input/\") add_definitions(-DJS_DATA_DIR=\"${CMAKE_SOURCE_DIR}/src/script/data/\") set (KTEXTEDITOR_TEST_LINK_LIBS KF5TextEditor KF5::I18n KF5::IconThemes KF5::GuiAddons Qt5::Qml - Qt5::Script ) include(ECMMarkAsTest) # test executable for encoding add_executable(kateencodingtest src/kateencodingtest.cpp) target_link_libraries(kateencodingtest ${KTEXTEDITOR_TEST_LINK_LIBS}) ecm_mark_as_test(kateencodingtest) # test macro for encoding tests MACRO(KTEXTEDITOR_ENCODING_TEST _encoding _testname) ADD_TEST (NAME encoding_${_testname}_create COMMAND kateencodingtest ${_encoding} ${CMAKE_SOURCE_DIR}/autotests/input/encoding/${_testname} ${CMAKE_CURRENT_BINARY_DIR}/${_testname} ) ADD_TEST (NAME encoding_${_testname}_diff COMMAND ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/autotests/input/encoding/${_testname} ${CMAKE_CURRENT_BINARY_DIR}/${_testname} ) ENDMACRO(KTEXTEDITOR_ENCODING_TEST) # add tests # this file is utf-8, simple KTEXTEDITOR_ENCODING_TEST ("utf-8" "utf8.txt") # this file is latin15, but fallback should work! KTEXTEDITOR_ENCODING_TEST ("utf-8" "latin15.txt") # this file is utf32, little endian, but fallback should work! KTEXTEDITOR_ENCODING_TEST ("utf-8" "utf32.txt") # this file is utf16, little endian, but fallback should work! KTEXTEDITOR_ENCODING_TEST ("utf-8" "utf16.txt") # this file is utf32, big endian, but fallback should work! KTEXTEDITOR_ENCODING_TEST ("utf-8" "utf32be.txt") # this file is utf16, big endian, but fallback should work! KTEXTEDITOR_ENCODING_TEST ("utf-8" "utf16be.txt") # cyrillic utf-8 KTEXTEDITOR_ENCODING_TEST ("utf-8" "cyrillic_utf8.txt") # cyrillic cp1251 KTEXTEDITOR_ENCODING_TEST ("utf-8" "cp1251.txt") # cyrillic koi8-r KTEXTEDITOR_ENCODING_TEST ("utf-8" "koi8-r.txt") # one character latin-15 test, segfaulted KTEXTEDITOR_ENCODING_TEST ("utf-8" "one-char-latin-15.txt") # test executable for indentation add_executable(kateindenttest src/indenttest.cpp src/script_test_base.cpp src/testutils.cpp) target_link_libraries(kateindenttest ${KTEXTEDITOR_TEST_LINK_LIBS} Qt5::Test) ecm_mark_as_test(kateindenttest) # test macro for indentation tests MACRO(KTEXTEDITOR_INDENT_TEST _testname) ADD_TEST (NAME kateindenttest_${_testname} COMMAND kateindenttest ${_testname}) ENDMACRO(KTEXTEDITOR_INDENT_TEST) # test different indenters sepearately to have smaller test chunks, that takes LONG KTEXTEDITOR_INDENT_TEST ("testPython") KTEXTEDITOR_INDENT_TEST ("testCstyle") KTEXTEDITOR_INDENT_TEST ("testCppstyle") KTEXTEDITOR_INDENT_TEST ("testCMake") KTEXTEDITOR_INDENT_TEST ("testRuby") KTEXTEDITOR_INDENT_TEST ("testHaskell") KTEXTEDITOR_INDENT_TEST ("testLatex") KTEXTEDITOR_INDENT_TEST ("testPascal") KTEXTEDITOR_INDENT_TEST ("testAda") KTEXTEDITOR_INDENT_TEST ("testXml") KTEXTEDITOR_INDENT_TEST ("testNormal") KTEXTEDITOR_INDENT_TEST ("testReplicode") macro(ktexteditor_unit_test testname) ecm_add_test(src/${testname}.cpp ${ARGN} TEST_NAME ${testname} LINK_LIBRARIES ${KTEXTEDITOR_TEST_LINK_LIBS} Qt5::Test) endmacro() ecm_add_tests( src/katetextbuffertest.cpp src/range_test.cpp src/undomanager_test.cpp src/plaintextsearch_test.cpp src/regexpsearch_test.cpp src/scriptdocument_test.cpp src/wordcompletiontest.cpp src/searchbar_test.cpp src/movingcursor_test.cpp src/configinterface_test.cpp src/messagetest.cpp src/kte_documentcursor.cpp src/bug313769.cpp src/katedocument_test.cpp src/movingrange_test.cpp src/kateview_test.cpp src/revision_test.cpp src/modificationsystem_test.cpp src/templatehandler_test.cpp src/katefoldingtest.cpp src/bug286887.cpp src/katewildcardmatcher_test.cpp LINK_LIBRARIES ${KTEXTEDITOR_TEST_LINK_LIBS} Qt5::Test ) ktexteditor_unit_test(completion_test src/codecompletiontestmodel.cpp src/codecompletiontestmodels.cpp) ktexteditor_unit_test(commands_test src/script_test_base.cpp src/testutils.cpp) ktexteditor_unit_test(scripting_test src/script_test_base.cpp src/testutils.cpp) ktexteditor_unit_test(bug313759 src/testutils.cpp) ktexteditor_unit_test(bug317111 src/testutils.cpp) ktexteditor_unit_test(bug205447 src/testutils.cpp) ktexteditor_unit_test(katesyntaxtest) if (BUILD_VIMODE) add_subdirectory(src/vimode) endif() diff --git a/autotests/src/bug205447.cpp b/autotests/src/bug205447.cpp index e64188ef..6a11a4e3 100644 --- a/autotests/src/bug205447.cpp +++ b/autotests/src/bug205447.cpp @@ -1,113 +1,112 @@ /* This file is part of the KDE libraries * Copyright (C) 2015 Zoe Clifford * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public License * along with this library; see the file COPYING.LIB. If not, write to * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. */ #include "bug205447.h" #include #include #include #include #include -#include #include #include "testutils.h" QTEST_MAIN(BugTest) using namespace KTextEditor; BugTest::BugTest() : QObject() { } BugTest::~BugTest() { } void BugTest::initTestCase() { KTextEditor::EditorPrivate::enableUnitTestMode(); } void BugTest::cleanupTestCase() { } void BugTest::deleteSurrogates() { // set up document and view and open test file KTextEditor::DocumentPrivate doc; KTextEditor::ViewPrivate *view = static_cast(doc.createView(nullptr)); const QUrl url = QUrl::fromLocalFile(QLatin1String(TEST_DATA_DIR"bug205447.txt")); doc.setEncoding(QStringLiteral("UTF-8")); QVERIFY(doc.openUrl(url)); // test delete // get UTF-32 representation of original line (before any deletes) QVector line = doc.line(0).toUcs4(); QVERIFY(line.size() == 23); // delete from start of line view->setCursorPosition(Cursor(0, 0)); QVERIFY(DocumentCursor(&doc, view->cursorPosition()).isValidTextPosition()); for (int i = 0; i < line.size(); i++) { // get the current line, after `i` delete presses, and convert it to utf32 // then ensure it's the expected substring of the original line QVector current = doc.line(0).toUcs4(); QCOMPARE(current, line.mid(i)); // press the delete key and verify that the new text position isn't invalid view->keyDelete(); QVERIFY(DocumentCursor(&doc, view->cursorPosition()).isValidTextPosition()); } QCOMPARE(doc.lineLength(0), 0); } void BugTest::backspaceSurrogates() { // set up document and view and open test file KTextEditor::DocumentPrivate doc; KTextEditor::ViewPrivate *view = static_cast(doc.createView(nullptr)); const QUrl url = QUrl::fromLocalFile(QLatin1String(TEST_DATA_DIR"bug205447.txt")); doc.setEncoding(QStringLiteral("UTF-8")); QVERIFY(doc.openUrl(url)); // test backspace // get UTF-32 representation of original line (before any backspaces) QVector line = doc.line(0).toUcs4(); QVERIFY(line.size() == 23); // backspace from end of line view->setCursorPosition(Cursor(0, doc.line(0).size())); QVERIFY(DocumentCursor(&doc, view->cursorPosition()).isValidTextPosition()); for (int i = 0; i < line.size(); i++) { // get the current line, after `i` delete presses, and convert it to utf32 // then ensure it's the expected substring of the original line QVector current = doc.line(0).toUcs4(); QCOMPARE(current, line.mid(0, line.size()-i)); // press the backspace key and verify that the new text position isn't invalid view->backspace(); QVERIFY(DocumentCursor(&doc, view->cursorPosition()).isValidTextPosition()); } QCOMPARE(doc.lineLength(0), 0); } #include "moc_bug205447.cpp" diff --git a/autotests/src/scripting_test.cpp b/autotests/src/scripting_test.cpp index 90ab6411..63da86a7 100644 --- a/autotests/src/scripting_test.cpp +++ b/autotests/src/scripting_test.cpp @@ -1,76 +1,75 @@ /** * This file is part of the KDE project * * Copyright (C) 2013 Gerald Senarclens de Grancy * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public License * along with this library; see the file COPYING.LIB. If not, write to * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. * */ //BEGIN Includes #include "scripting_test.h" #include "kateview.h" #include "katedocument.h" #include "kateconfig.h" #include "katecmd.h" #include "kateglobal.h" #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include -#include #include #include "script_test_base.h" #include "testutils.h" QTEST_MAIN(ScriptingTest) #define FAILURE( test, comment ) qMakePair( (test), (comment) ) void ScriptingTest::initTestCase() { ScriptTestBase::initTestCase(); m_section = "scripting"; m_script_dir = ""; } void ScriptingTest::bugs_data() { getTestData("bugs"); } void ScriptingTest::bugs() { runTest(ExpectedFailures()); }