File indexing completed on 2024-05-12 04:40:04

0001 /*
0002     SPDX-FileCopyrightText: 1999-2001 Bernd Gehrmann <bernd@kdevelop.org>
0003     SPDX-FileCopyrightText: 1999-2001 the KDevelop Team
0004     SPDX-FileCopyrightText: 2010 Julien Desgats <julien.desgats@gmail.com>
0005 
0006     SPDX-License-Identifier: GPL-2.0-or-later
0007 */
0008 
0009 #ifndef KDEVPLATFORM_PLUGIN_REPLACETEST_H
0010 #define KDEVPLATFORM_PLUGIN_REPLACETEST_H
0011 
0012 #include <QObject>
0013 #include <QList>
0014 #include <QMetaType>
0015 #include <QPair>
0016 
0017 struct GrepJobSettings;
0018 
0019 namespace KDevelop
0020 {
0021 class TestCore;
0022 class TestProjectController;
0023 }
0024 class GrepViewPlugin;
0025 
0026 class FindReplaceTest : public QObject
0027 {
0028     Q_OBJECT
0029 public:
0030     struct Match {
0031         Match() {}
0032         Match(int l,int s,int e) : line(l), start(s), end(e) {}
0033         int line;
0034         int start;
0035         int end;
0036     };
0037     using MatchList = QList<Match>;
0038 
0039     using File = QPair<QString, QString>;  /// Represent a file with name => content
0040     using FileList = QList<File>;
0041 
0042 private:
0043     GrepViewPlugin* m_plugin;
0044 
0045 private Q_SLOTS:
0046     void initTestCase();
0047     void cleanupTestCase();
0048     void init();
0049 
0050     void testFind();
0051     void testFind_data();
0052 
0053     void testSingleFileAsDirectoryChoice();
0054 
0055     void testIncludeExcludeFilters();
0056     void testIncludeExcludeFilters_data();
0057 
0058     void testReplace();
0059     void testReplace_data();
0060 
0061 private:
0062     void addTestProjectFromFileSystem(const QString& path);
0063     template<typename Test>
0064     void varyProjectFilesOnly(GrepJobSettings& settings, const QString& projectPath, Test testToRun);
0065 
0066     KDevelop::TestProjectController* m_projectController;
0067 };
0068 
0069 Q_DECLARE_METATYPE(FindReplaceTest::MatchList)
0070 Q_DECLARE_METATYPE(FindReplaceTest::FileList)
0071 
0072 #endif // KDEVPLATFORM_PLUGIN_REPLACETEST_H