File indexing completed on 2024-04-28 05:48:12

0001 // SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
0002 // SPDX-FileCopyrightText: 2022 Harald Sitter <sitter@kde.org>
0003 
0004 #include <QDebug>
0005 #include <QSignalSpy>
0006 #include <QTest>
0007 
0008 #include "fileTree.h"
0009 #include "localLister.h"
0010 #include "scan.h"
0011 #include "test-config.h"
0012 
0013 Q_DECLARE_METATYPE(std::shared_ptr<Folder>)
0014 
0015 class LocalListerTest : public QObject
0016 {
0017     Q_OBJECT
0018     const QString m_tree = QFINDTESTDATA("iterator-tree");
0019 private Q_SLOTS:
0020     void testRun()
0021     {
0022         qRegisterMetaType<std::shared_ptr<File>>("std::shared_ptr<File>");
0023         qRegisterMetaType<std::shared_ptr<Folder>>("std::shared_ptr<Folder>");
0024 
0025         auto cache = new QList<std::shared_ptr<Folder>>;
0026         Filelight::ScanManager manager(nullptr);
0027         Filelight::LocalLister lister(m_tree, cache, &manager);
0028         QSignalSpy spy(&lister, &Filelight::LocalLister::branchCompleted);
0029         lister.start();
0030         lister.wait();
0031         spy.wait();
0032         const auto arguments = spy.takeFirst();
0033         const auto root = arguments.at(0).value<std::shared_ptr<Folder>>();
0034 
0035         QVERIFY(root);
0036         QCOMPARE(root->children(), 3);
0037 #ifdef Q_OS_LINUX
0038         QCOMPARE(root->size(), 8192);
0039 #endif
0040     }
0041 };
0042 
0043 QTEST_GUILESS_MAIN(LocalListerTest)
0044 
0045 #include "localListerTest.moc"