[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [kdevplatform/5.0] project/tests: Add manual test executable for the AbstractFileManagerPlugin impor
From:       Milian Wolff <mail () milianw ! de>
Date:       2016-01-31 22:51:59
Message-ID: E1aQ0qd-0003JH-2z () scm ! kde ! org
[Download RAW message or body]

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     [License: \
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_SRCS})
 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/project/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 <mail@milianw.de>
+
+    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 <project/abstractfilemanagerplugin.h>
+
+#include <tests/autotestshell.h>
+#include <tests/testcore.h>
+#include <tests/testproject.h>
+
+#include <util/path.h>
+
+#include <KJob>
+
+#include <QCoreApplication>
+#include <QDebug>
+
+using namespace KDevelop;
+
+int main(int argc, char** argv)
+{
+    if (argc != 2) {
+        qWarning() << "Missing argument for directory path to list.";
+        return 1;
+    }
+    QCoreApplication app(argc, argv);
+
+    AutoTestShell::init();
+    auto core = TestCore::initialize(Core::NoUi);
+
+    auto plugin = new AbstractFileManagerPlugin({}, core);
+    auto project = new TestProject(Path(QString::fromUtf8(argv[1])));
+    auto root = plugin->import(project);
+    auto import = plugin->createImportJob(root);
+    QObject::connect(import, &KJob::finished,
+                     &app, &QCoreApplication::quit);
+    import->start();
+
+    return app.exec();
+}
\ No newline at end of file


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic