diff --git a/tests/testproject.cpp b/tests/testproject.cpp index e4efe4caeb..08c3149e49 100644 --- a/tests/testproject.cpp +++ b/tests/testproject.cpp @@ -1,5 +1,14 @@ +#include "testproject.h" +KDevelop::TestProject::TestProject(QObject* parent): + IProject(parent), + m_projectConfiguration(KGlobal::config()) +{ +} +void KDevelop::TestProject::set_projectFileUrl(const KUrl& url) { + m_projectFileUrl = url; +} #include "testproject.moc" diff --git a/tests/testproject.h b/tests/testproject.h index fa1a35d51a..33e08c9d2f 100644 --- a/tests/testproject.h +++ b/tests/testproject.h @@ -1,86 +1,95 @@ /*************************************************************************** * Copyright 2010 Niko Sams * * * * This program 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 program 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 General Public License for more details. * * * * You should have received a copy of the GNU Library General Public * * License along with this program; if not, write to the * * Free Software Foundation, Inc., * * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * ***************************************************************************/ +#ifndef KDEVPLATFORM_TEST_PROJECT_H +#define KDEVPLATFORM_TEST_PROJECT_H + #include #include #include "kdevplatformtestsexport.h" #include "../interfaces/iproject.h" #include "../shell/projectcontroller.h" #include "../language/duchain/indexedstring.h" namespace KDevelop { /** * Dummy Project than can be used for Unit Tests. * * Currently only FileSet methods are implemented. */ class KDEVPLATFORMTESTS_EXPORT TestProject : public IProject { Q_OBJECT public: + TestProject(QObject* parent = 0); IProjectFileManager* projectFileManager() const { return 0; } IBuildSystemManager* buildSystemManager() const { return 0; } IPlugin* managerPlugin() const { return 0; } IPlugin* versionControlPlugin() const { return 0; } ProjectFolderItem* projectItem() const { return 0; } int fileCount() const { return 0; } ProjectFileItem* fileAt( int ) const { return 0; } QList files() const { return QList(); } QList filesForUrl( const KUrl& ) const { return QList(); } QList foldersForUrl( const KUrl& ) const { return QList(); } void reloadModel() { } - KUrl projectFileUrl() const { return KUrl(); } - KSharedConfig::Ptr projectConfiguration() const { return KGlobal::config(); } + KUrl projectFileUrl() const { return m_projectFileUrl; } + KSharedConfig::Ptr projectConfiguration() const { return m_projectConfiguration; } void addToFileSet( const IndexedString& file) { m_fileSet << file; } void removeFromFileSet( const IndexedString& file) { m_fileSet.remove(file); } QSet fileSet() const { return m_fileSet; } bool isReady() const { return true; } virtual QList< ProjectBaseItem* > itemsForUrl(const KUrl&) const { return QList< ProjectBaseItem* >(); } + + void set_projectFileUrl(const KUrl& url); public Q_SLOTS: const KUrl folder() const { return KUrl(); } QString name() const { return "Test Project"; } KUrl relativeUrl(const KUrl& ) const { return KUrl(); } bool inProject(const KUrl &) const { return false; } private: QSet m_fileSet; + KUrl m_projectFileUrl; + KSharedConfig::Ptr m_projectConfiguration; }; /** * ProjectController that can clear open projects. Useful in Unit Tests. */ class KDEVPLATFORMTESTS_EXPORT TestProjectController : public ProjectController { Q_OBJECT public: TestProjectController(Core* core) : ProjectController(core) {} IProject* projectAt( int i ) const { return m_projects.at(i); } int projectCount() const { return m_projects.count(); } QList projects() const { return m_projects; } public: void addProject(IProject* p) { p->setParent(this); m_projects << p; } void clearProjects() { qDeleteAll(m_projects); m_projects.clear(); } private: QList m_projects; }; } +#endif