diff --git a/akonadi/tests/testrunner/config.cpp b/akonadi/tests/testrunner/config.cpp index 0f84b52d6..6a7dd37b2 100644 --- a/akonadi/tests/testrunner/config.cpp +++ b/akonadi/tests/testrunner/config.cpp @@ -1,99 +1,107 @@ /* * Copyright (c) 2008 Igor Trindade Oliveira * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library 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 * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library. If not, see . */ #include "config.h" #include "configreader.h" #include #include #include Config* Config::instance = 0; Config::Config() { } Config *Config::getInstance() { if(instance == 0){ const QString pathToConfig = KStandardDirs::locate("config","akonaditest.xml"); instance = new ConfigReader(pathToConfig); - //instance= new ConfigReader("/home/igor/codes/kde/tests/test_akonadi/config.xml"); } return instance; } +Config *Config::getInstance(const QString &pathToConfig) +{ + if(instance == 0){ + instance = new ConfigReader(pathToConfig); + } + return instance; +} + + void Config::destroyInstance() { delete instance; } QString Config::getKdeHome() const { return kdehome; } QString Config::getXdgDataHome() const { return xdgdatahome; } QString Config::getXdgConfigHome() const { return xdgconfighome; } void Config::setKdeHome(const QString &home) { QDir kdeHomeDir( home ); kdehome = kdeHomeDir.absolutePath(); } void Config::setXdgDataHome(const QString &datahome) { QDir dataHomeDir( datahome ); xdgdatahome = dataHomeDir.absolutePath(); } void Config::setXdgConfigHome(const QString &confighome) { QDir configHomeDir( confighome ); xdgconfighome = configHomeDir.absolutePath(); } void Config::insertItemConfig(const QString &itemname, const QString &colname) { itemconfig.append( qMakePair(itemname, colname) ); } QList< QPair > Config::getItemConfig() { return itemconfig; } void Config::insertAgent(QString agent) { mAgents << agent; } QStringList Config::getAgents() { return mAgents; } diff --git a/akonadi/tests/testrunner/config.h b/akonadi/tests/testrunner/config.h index 438d70f51..1d98b3d5f 100644 --- a/akonadi/tests/testrunner/config.h +++ b/akonadi/tests/testrunner/config.h @@ -1,54 +1,55 @@ /* * Copyright (c) 2008 Igor Trindade Oliveira * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library 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 * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library. If not, see . */ #ifndef CONFIG_H #define CONFIG_H #include #include #include class Config { private: QString kdehome; QString xdgdatahome; QString xdgconfighome; QList > itemconfig; QStringList mAgents; static Config *instance; public: - static Config *getInstance(); + static Config *getInstance(); //to maintain the compatibility + static Config *getInstance(const QString &pathToConfig); static void destroyInstance(); QString getKdeHome() const; QString getXdgDataHome() const; QString getXdgConfigHome() const; QList > getItemConfig(); QStringList getAgents(); protected: Config(); void setKdeHome(const QString &home); void setXdgDataHome(const QString &datahome); void setXdgConfigHome(const QString &confighome); void insertItemConfig(const QString &itemname, const QString &colname); void insertAgent(QString agent); }; #endif diff --git a/akonadi/tests/testrunner/main.cpp b/akonadi/tests/testrunner/main.cpp index fb080f1c9..334c2c5af 100644 --- a/akonadi/tests/testrunner/main.cpp +++ b/akonadi/tests/testrunner/main.cpp @@ -1,69 +1,69 @@ /*people * * Copyright (c) 2008 Igor Trindade Oliveira * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library 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 * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library. If not, see . */ #include #include #include #include #include "akonaditesting.h" #include "setup.h" #include "config.h" #include "shellscript.h" int main(int argc, char **argv) { KAboutData aboutdata("akonadi-TES", 0, ki18n("Akonadi Testing Environment Setup"), "1.0", ki18n("Setup Environmnet"), KAboutData::License_GPL, ki18n("(c) 2008 Igor Trindade Oliveira")); KCmdLineArgs::init(argc, argv, &aboutdata); KCmdLineOptions options; - - // TODO: add --config option for overriding with a specific one - - KCmdLineArgs::addCmdLineOptions(options); + options.add("+[config]", ki18n("Configuration file to open")); + KCmdLineArgs::addCmdLineOptions(options); KApplication app; KCmdLineArgs *args = KCmdLineArgs::parsedArgs(); - - Q_UNUSED( args ) // TODO pass value of --config once available + + if(args->count()) + Config *config = Config::getInstance(QString(args->arg(0))); + SetupTest *setup = new SetupTest(); setup->startAkonadiDaemon(); AkonadiTesting *testing = new AkonadiTesting(); testing->insertItemFromList(); shellScript *sh = new shellScript(); sh->makeShellScript(); int result = app.exec(); Config::destroyInstance(); delete testing; delete setup; delete sh; return result; }