File indexing completed on 2024-05-12 04:39:37
0001 /* 0002 SPDX-FileCopyrightText: 2010 Andreas Pakulat <apaku@gmx.de> 0003 0004 SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-or-later 0005 */ 0006 0007 #include "test_custombuildsystemplugin.h" 0008 0009 #include <QTest> 0010 #include <QDebug> 0011 0012 #include <tests/autotestshell.h> 0013 #include <tests/testcore.h> 0014 #include <tests/kdevsignalspy.h> 0015 #include <tests/projectsgenerator.h> 0016 #include <shell/sessioncontroller.h> 0017 #include <interfaces/iprojectcontroller.h> 0018 #include <interfaces/isession.h> 0019 #include <interfaces/iproject.h> 0020 #include <project/interfaces/ibuildsystemmanager.h> 0021 #include <project/projectmodel.h> 0022 0023 #include <serialization/indexedstring.h> 0024 0025 #include "testconfig.h" 0026 0027 using KDevelop::Core; 0028 using KDevelop::ICore; 0029 using KDevelop::IProject; 0030 using KDevelop::TestCore; 0031 using KDevelop::AutoTestShell; 0032 using KDevelop::KDevSignalSpy; 0033 using KDevelop::ProjectsGenerator; 0034 using KDevelop::Path; 0035 0036 QTEST_MAIN(TestCustomBuildSystemPlugin) 0037 0038 void TestCustomBuildSystemPlugin::cleanupTestCase() 0039 { 0040 TestCore::shutdown(); 0041 } 0042 void TestCustomBuildSystemPlugin::initTestCase() 0043 { 0044 AutoTestShell::init({"KDevCustomBuildSystem", "KDevStandardOutputView"}); 0045 TestCore::initialize(); 0046 } 0047 0048 void TestCustomBuildSystemPlugin::cleanup() 0049 { 0050 ICore::self()->projectController()->closeAllProjects( ); 0051 } 0052 0053 void TestCustomBuildSystemPlugin::loadSimpleProject() 0054 { 0055 m_currentProject = ProjectsGenerator::GenerateSimpleProject(); 0056 QVERIFY( m_currentProject ); 0057 QCOMPARE( m_currentProject->buildSystemManager()->buildDirectory( m_currentProject->projectItem() ), 0058 Path( QStringLiteral("file:///") + QDir::temp().absolutePath() + QStringLiteral("/simpleproject/build/") ) ); 0059 } 0060 0061 void TestCustomBuildSystemPlugin::buildDirProject() 0062 { 0063 m_currentProject = ProjectsGenerator::GenerateEmptyBuildDirProject(); 0064 QVERIFY( m_currentProject ); 0065 QCOMPARE( m_currentProject->buildSystemManager()->buildDirectory( m_currentProject->projectItem() ), 0066 Path( QStringLiteral("file:///") + QDir::temp().absolutePath() + QStringLiteral("/simpleproject/build/") ) ); 0067 } 0068 0069 void TestCustomBuildSystemPlugin::loadMultiPathProject() 0070 { 0071 m_currentProject = ProjectsGenerator::GenerateMultiPathProject(); 0072 QVERIFY( m_currentProject ); 0073 0074 KDevelop::ProjectBaseItem* mainfile = nullptr; 0075 const auto& files = m_currentProject->fileSet(); 0076 for (const auto& file : files) { 0077 const auto& filesForPath = m_currentProject->filesForPath(file); 0078 for (auto i: filesForPath) { 0079 if( i->text() == QLatin1String("main.cpp") ) { 0080 mainfile = i; 0081 break; 0082 } 0083 } 0084 } 0085 QVERIFY(mainfile); 0086 0087 QCOMPARE( m_currentProject->buildSystemManager()->buildDirectory( mainfile ), 0088 Path( QStringLiteral("file:///") + QDir::temp().absolutePath() + QStringLiteral("/multipathproject/build/src") ) ); 0089 } 0090 0091 #include "moc_test_custombuildsystemplugin.cpp"