From kde-commits Sun Jan 31 22:51:59 2016 From: Milian Wolff Date: Sun, 31 Jan 2016 22:51:59 +0000 To: kde-commits Subject: [kdevplatform/5.0] project/tests: Add manual test executable for the AbstractFileManagerPlugin impor Message-Id: X-MARC-Message: https://marc.info/?l=kde-commits&m=145428074230153 Git commit 5579ad88186e289d45b9d87007e8996425b5c145 by Milian Wolff. Committed on 31/01/2016 at 22:51. Pushed by mwolff into branch '5.0'. Add manual test executable for the AbstractFileManagerPlugin import. This can be used to benchmark the code by calling it with a path to folders that contain lots of subfolders and files. Note that even without the GUI latency issue introduced by QTBUG-50700 [1] the code currently takes 10x as long as a recursive `find` call. I will try to implement a non-blocking QDir based KIO alternative for this purpose in the next days to speed up the common case of loading a project from the local file system. This will then also help as a workaround for the Qt bug mentioned above. [1]: https://bugreports.qt.io/browse/QTBUG-50700 M +10 -2 project/tests/CMakeLists.txt A +55 -0 project/tests/abstractfilemanagerpluginimporttest.cpp [L= icense: LGPL (v2+)] http://commits.kde.org/kdevplatform/5579ad88186e289d45b9d87007e8996425b5c145 diff --git a/project/tests/CMakeLists.txt b/project/tests/CMakeLists.txt index d5beeeb..74e5baa 100644 --- a/project/tests/CMakeLists.txt +++ b/project/tests/CMakeLists.txt @@ -1,10 +1,9 @@ ecm_add_test(test_projectmodel.cpp LINK_LIBRARIES Qt5::Test KDev::Interfaces KDev::Project KDev::Language= KDev::Tests) = -set( projectmodelperformancetest_SRCS +add_executable(projectmodelperformancetest projectmodelperformancetest.cpp ) -add_executable(projectmodelperformancetest ${projectmodelperformancetest_S= RCS}) target_link_libraries(projectmodelperformancetest Qt5::Test Qt5::Gui @@ -13,3 +12,12 @@ target_link_libraries(projectmodelperformancetest KDev::Language KDev::Tests ) + +add_executable(abstractfilemanagerpluginimporttest + abstractfilemanagerpluginimporttest.cpp +) +target_link_libraries(abstractfilemanagerpluginimporttest + KDev::Project + KDev::Tests + Qt5::QuickWidgets +) diff --git a/project/tests/abstractfilemanagerpluginimporttest.cpp b/projec= t/tests/abstractfilemanagerpluginimporttest.cpp new file mode 100644 index 0000000..6263683 --- /dev/null +++ b/project/tests/abstractfilemanagerpluginimporttest.cpp @@ -0,0 +1,55 @@ +/* This file is part of KDevelop + Copyright 2016 Milian Wolff + + 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 Lice= nse + 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 + +#include +#include +#include + +#include + +#include + +#include +#include + +using namespace KDevelop; + +int main(int argc, char** argv) +{ + if (argc !=3D 2) { + qWarning() << "Missing argument for directory path to list."; + return 1; + } + QCoreApplication app(argc, argv); + + AutoTestShell::init(); + auto core =3D TestCore::initialize(Core::NoUi); + + auto plugin =3D new AbstractFileManagerPlugin({}, core); + auto project =3D new TestProject(Path(QString::fromUtf8(argv[1]))); + auto root =3D plugin->import(project); + auto import =3D plugin->createImportJob(root); + QObject::connect(import, &KJob::finished, + &app, &QCoreApplication::quit); + import->start(); + + return app.exec(); +} \ No newline at end of file