Commit c5eec4d1 authored by Harald Sitter's avatar Harald Sitter 🏳️‍🌈
Browse files

add a trivial test for local lister

to demonstrate that its threading works as well as have a tiny example
to debug if things end up not working in the future
parent 05c4cff8
Pipeline #271743 failed with stage
in 2 minutes and 3 seconds
......@@ -21,3 +21,4 @@ file(CREATE_LINK ${CMAKE_CURRENT_BINARY_DIR}/iterator-tree/bar ${CMAKE_CURRENT_B
configure_file(test-config.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/test-config.h)
ecm_add_test(directoryIteratorTest.cpp TEST_NAME directoryIteratorTest LINK_LIBRARIES Qt::Test filelightInternal)
ecm_add_test(localListerTest.cpp TEST_NAME localListerTest LINK_LIBRARIES Qt::Test filelightInternal)
// SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
// SPDX-FileCopyrightText: 2022 Harald Sitter <sitter@kde.org>
#include <QDebug>
#include <QSignalSpy>
#include <QTest>
#include "fileTree.h"
#include "localLister.h"
#include "scan.h"
#include "test-config.h"
Q_DECLARE_METATYPE(std::shared_ptr<Folder>)
class LocalListerTest : public QObject
{
Q_OBJECT
const QString m_tree = QFINDTESTDATA("iterator-tree");
private Q_SLOTS:
void testRun()
{
qRegisterMetaType<std::shared_ptr<File>>("std::shared_ptr<File>");
qRegisterMetaType<std::shared_ptr<Folder>>("std::shared_ptr<Folder>");
auto cache = new QList<std::shared_ptr<Folder>>;
Filelight::ScanManager manager(nullptr);
Filelight::LocalLister lister(m_tree, cache, &manager);
QSignalSpy spy(&lister, &Filelight::LocalLister::branchCompleted);
lister.start();
lister.wait();
spy.wait();
const auto arguments = spy.takeFirst();
const auto root = arguments.at(0).value<std::shared_ptr<Folder>>();
QVERIFY(root);
QCOMPARE(root->children(), 4);
#ifdef Q_OS_LINUX
QCOMPARE(root->size(), 16384);
#endif
}
};
QTEST_GUILESS_MAIN(LocalListerTest)
#include "localListerTest.moc"
......@@ -15,15 +15,26 @@ if (HAVE_SINCOS)
add_definitions(-DHAVE_SINCOS)
endif()
add_library(filelightInternal STATIC fileTree.cpp directoryIterator.cpp fileCleaner.cpp)
add_library(filelightInternal STATIC
fileTree.cpp
directoryIterator.cpp
fileCleaner.cpp
scan.cpp
Config.cpp
localLister.cpp
remoteLister.cpp
)
ecm_qt_declare_logging_category(filelightInternal HEADER filelight_debug.h IDENTIFIER FILELIGHT_LOG CATEGORY_NAME org.kde.filelight DESCRIPTION "filelight" EXPORT FILELIGHT)
if (WIN32)
target_sources(filelightInternal PRIVATE windowsWalker.cpp)
else()
target_sources(filelightInternal PRIVATE posixWalker.cpp)
endif()
target_link_libraries(filelightInternal
Qt${QT_MAJOR_VERSION}::Core
Qt${QT_MAJOR_VERSION}::Gui
KF5::CoreAddons
KF5::ConfigCore
KF5::KIOWidgets # Only used for KDirLister, may be able to move away from that.
)
add_executable(filelight)
......@@ -31,11 +42,7 @@ target_sources(filelight PRIVATE
radialMap/item.cpp
radialMap/map.cpp
radialMap/radialMap.cpp
scan.cpp
Config.cpp
settingsDialog.cpp
localLister.cpp
remoteLister.cpp
historyAction.cpp
mainContext.cpp
main.cpp
......@@ -52,7 +59,6 @@ target_sources(filelight PRIVATE
Config.h
qml/qml.qrc
)
ecm_qt_declare_logging_category(filelight HEADER filelight_debug.h IDENTIFIER FILELIGHT_LOG CATEGORY_NAME org.kde.filelight DESCRIPTION "filelight" EXPORT FILELIGHT)
set(filelight_ICONS
${CMAKE_CURRENT_SOURCE_DIR}/../misc/16-apps-filelight.png
......@@ -68,7 +74,6 @@ ki18n_wrap_ui(filelight dialog.ui)
target_link_libraries(filelight
KF5::I18n
KF5::XmlGui
KF5::KIOWidgets # Only used for KDirLister, may be able to move away from that.
Qt${QT_MAJOR_VERSION}::Svg
Qt${QT_MAJOR_VERSION}::Quick
Qt${QT_MAJOR_VERSION}::QuickControls2
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment