From 184b704ddfeb9ad687c51cfa125108fcbdec863b Mon Sep 17 00:00:00 2001 From: Neeraj Kumar Date: Sat, 24 Jul 2010 22:32:08 +0000 Subject: TESTBED: removed unnecessary code from config file implementation svn-id: r51267 --- engines/testbed/config.cpp | 52 ++++++++-------------------------------------- engines/testbed/config.h | 2 +- 2 files changed, 10 insertions(+), 44 deletions(-) diff --git a/engines/testbed/config.cpp b/engines/testbed/config.cpp index 5226b63eb3..16194d90ce 100644 --- a/engines/testbed/config.cpp +++ b/engines/testbed/config.cpp @@ -127,50 +127,19 @@ void TestbedOptionsDialog::handleCommand(GUI::CommandSender *sender, uint32 cmd, } } -void TestbedConfigManager::initConfigFile(Common::WriteStream *ws) { - Common::String wStr; - // Global Params - wStr = "[Global]\n"; - ws->writeString(wStr); - wStr = "isSessionInteractive"; - wStr += "="; - wStr += "true\n"; - ws->writeString(wStr); - ws->writeString("\n"); - - for (Common::Array::const_iterator i = _testsuiteList.begin(); i < _testsuiteList.end(); i++) { - // Construct the string - wStr = "["; - wStr += (*i)->getName(); - wStr += "]\n"; - ws->writeString(wStr); - wStr = "this"; - wStr += "="; - wStr += boolToString((*i)->isEnabled()); - wStr += "\n"; - ws->writeString(wStr); - - const Common::Array &testList = (*i)->getTestList(); - for (Common::Array::const_iterator j = testList.begin(); j != testList.end(); j++) { - wStr = (*j)->featureName; - wStr += "="; - wStr += boolToString((*j)->enabled); - wStr += "\n"; - ws->writeString(wStr); - } - ws->writeString("\n"); - } +void TestbedConfigManager::initDefaultConfiguration() { + // Default Configuration + // Add Global configuration Parameters here. + _configFileInterface.setKey("isSessionInteractive", "Global", "true"); } void TestbedConfigManager::writeTestbedConfigToStream(Common::WriteStream *ws) { Common::String wStr; for (Common::Array::const_iterator i = _testsuiteList.begin(); i < _testsuiteList.end(); i++) { - if (_configFileInterface.hasSection((*i)->getName())) { - _configFileInterface.setKey("this", (*i)->getName(), boolToString((*i)->isEnabled())); - const Common::Array &testList = (*i)->getTestList(); - for (Common::Array::const_iterator j = testList.begin(); j != testList.end(); j++) { - _configFileInterface.setKey((*j)->featureName, (*i)->getName(), boolToString((*j)->enabled)); - } + _configFileInterface.setKey("this", (*i)->getName(), boolToString((*i)->isEnabled())); + const Common::Array &testList = (*i)->getTestList(); + for (Common::Array::const_iterator j = testList.begin(); j != testList.end(); j++) { + _configFileInterface.setKey((*j)->featureName, (*i)->getName(), boolToString((*j)->enabled)); } } _configFileInterface.saveToStream(*ws); @@ -191,10 +160,6 @@ Common::WriteStream *TestbedConfigManager::getConfigWriteStream() { Common::FSNode gameRoot(path); Common::FSNode config = gameRoot.getChild(_configFileName); ws = config.createWriteStream(); - if (!config.exists()) { - Testsuite::logPrintf("Info! No config file found, creating new one\n"); - initConfigFile(ws); - } return ws; } @@ -203,6 +168,7 @@ void TestbedConfigManager::parseConfigFile() { if (!rs) { Testsuite::logPrintf("Info! No config file found, using default configuration.\n"); + initDefaultConfiguration(); return; } _configFileInterface.loadFromStream(*rs); diff --git a/engines/testbed/config.h b/engines/testbed/config.h index 8fbed858d1..2ecbf44930 100644 --- a/engines/testbed/config.h +++ b/engines/testbed/config.h @@ -59,7 +59,7 @@ public: Testsuite *getTestsuiteByName(const Common::String &name); bool stringToBool(const Common::String str) { return str.equalsIgnoreCase("true") ? true : false; } Common::String boolToString(bool val) { return val ? "true" : "false"; } - void initConfigFile(Common::WriteStream *ws); + void initDefaultConfiguration(); private: Common::Array &_testsuiteList; Common::String _configFileName; -- cgit v1.2.3