diff options
| author | Neeraj Kumar | 2010-07-15 18:51:56 +0000 | 
|---|---|---|
| committer | Neeraj Kumar | 2010-07-15 18:51:56 +0000 | 
| commit | 407d65068a79693f42836c36d6394ef310b5238f (patch) | |
| tree | a924876a16ef986299f48bd35566f629a31b926a | |
| parent | 12ebe8065e6020415cb3a6df216a4504014371db (diff) | |
| download | scummvm-rg350-407d65068a79693f42836c36d6394ef310b5238f.tar.gz scummvm-rg350-407d65068a79693f42836c36d6394ef310b5238f.tar.bz2 scummvm-rg350-407d65068a79693f42836c36d6394ef310b5238f.zip  | |
separated testsuite configuration to another class
svn-id: r50918
| -rw-r--r-- | engines/testbed/config.cpp | 119 | ||||
| -rw-r--r-- | engines/testbed/config.h | 62 | ||||
| -rw-r--r-- | engines/testbed/module.mk | 1 | ||||
| -rw-r--r-- | engines/testbed/testbed.cpp | 76 | ||||
| -rw-r--r-- | engines/testbed/testbed.h | 15 | 
5 files changed, 185 insertions, 88 deletions
diff --git a/engines/testbed/config.cpp b/engines/testbed/config.cpp new file mode 100644 index 0000000000..f6687d1803 --- /dev/null +++ b/engines/testbed/config.cpp @@ -0,0 +1,119 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU 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 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. + * + * $URL$ + * $Id$ + */ + +#include "testbed/config.h" +#include "engines/engine.h" + +namespace Testbed { + +TestbedOptionsDialog::TestbedOptionsDialog() : GUI::OptionsDialog("Select", 120, 120, 360, 200), _hOffset(15), _vOffset(15), _boxWidth(300), _boxHeight(10) { +	new GUI::StaticTextWidget(this, _hOffset, _vOffset, _boxWidth, _boxHeight, "Select testsuites to Execute", Graphics::kTextAlignCenter); +	_vOffset += 20; +	addCheckbox("FS"); +	addCheckbox("GFX"); +	addCheckbox("Savegames"); +	addCheckbox("Misc"); +	addCheckbox("Events"); +	new GUI::ButtonWidget(this, 80 , _vOffset + 10, 80, 25, "Continue", GUI::kOKCmd, 'C'); +	new GUI::ButtonWidget(this, 200, _vOffset + 10, 80, 25, "Exit", GUI::kCloseCmd, 'X'); +} + +TestbedOptionsDialog::~TestbedOptionsDialog() {} + +void TestbedOptionsDialog::addCheckbox(const Common::String &tsName) { +	_checkBoxes.push_back(new GUI::CheckboxWidget(this, _hOffset, _vOffset, _boxWidth, _boxHeight, tsName)); +	_vOffset += 20; +} + +bool TestbedOptionsDialog::isEnabled(const Common::String &tsName) { +	for (uint i = 0; i < _checkBoxes.size(); i++) { +		if (_checkBoxes[i]->getLabel().equalsIgnoreCase(tsName)) { +			return _checkBoxes[i]->getState(); +		} +	} +	return false; +} + +void TestbedConfigManager::enableTestsuite(const Common::String &name, bool enable) { +	Common::Array<Testsuite *>::const_iterator iter; + +	for (iter = _testsuiteList.begin(); iter != _testsuiteList.end(); iter++) { +		if (name.equalsIgnoreCase((*iter)->getName())) { +			(*iter)->enable(enable); +			break; +		} +	} + +	return; +} + + + +void TestbedConfigManager::selectTestsuites() { + + +	// Parse the config file +	// Enable testsuites as per configuration. +	// If no config file is found pickup a default configuration. +	// TODO : Implement this method + +	parseConfigFile(); + +	if (!Testsuite::isSessionInteractive) { +		// Non interactive sessions don't need to go beyond +		return; +	} + +	// XXX: disabling these as of now for fastly testing other tests +	// Testsuite::isSessionInteractive = false; +	Common::String prompt("Welcome to the ScummVM testbed!\n" +						"It is a framework to test the various ScummVM subsystems namely GFX, Sound, FS, events etc.\n" +						"If you see this, it means interactive tests would run on this system :)"); + +	Testsuite::logPrintf("Info! : Interactive tests are also being executed.\n"); +	 +	if (Testsuite::handleInteractiveInput(prompt, "Proceed?", "Customize", kOptionRight)) { + +		// Select testsuites using checkboxes +		TestbedOptionsDialog tbd; +		tbd.runModal(); + +		// check if user wanted to exit. +		if (Engine::shouldQuit()) { +			return; +		} + +		// Enable selected testsuites +		Common::String tsName; +		for (uint i = 0; i < _testsuiteList.size(); i++) { +			tsName = _testsuiteList[i]->getName(); +			if (tbd.isEnabled(tsName)) { +				enableTestsuite(tsName, true); +			} +		} + +	} +} + +}	// End of namespace Testbed diff --git a/engines/testbed/config.h b/engines/testbed/config.h new file mode 100644 index 0000000000..953524d618 --- /dev/null +++ b/engines/testbed/config.h @@ -0,0 +1,62 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU 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 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. + * + * $URL$ + * $Id$ + */ + +#ifndef TESTBED_CONFIG_H +#define TESTBED_CONFIG_H + +#include "testbed/testsuite.h" +#include "common/array.h" +#include "gui/options.h" + +namespace Testbed { + +class TestbedConfigManager { +public: +	TestbedConfigManager(Common::Array<Testsuite *> &tList) : _testsuiteList(tList) {} +	~TestbedConfigManager() {} +	void selectTestsuites(); +private: +	Common::Array<Testsuite *> &_testsuiteList; +	void enableTestsuite(const Common::String &name, bool enable); +	void parseConfigFile() {} +}; + +class TestbedOptionsDialog : public GUI::OptionsDialog { +public: +	TestbedOptionsDialog(); +	~TestbedOptionsDialog(); +	void addCheckbox(const Common::String &tsName); +	bool isEnabled(const Common::String &tsName); + +private: +	Common::Array<GUI::CheckboxWidget *> _checkBoxes; +	const int _hOffset; // current offset from left +	int _vOffset; // current offset from top +	const int _boxWidth; +	const int _boxHeight; +}; + +} // End of namespace Testbed + +#endif // TESTBED_CONFIG_H diff --git a/engines/testbed/module.mk b/engines/testbed/module.mk index e9a6382895..d66242d37a 100644 --- a/engines/testbed/module.mk +++ b/engines/testbed/module.mk @@ -1,6 +1,7 @@  MODULE := engines/testbed  MODULE_OBJS := \ +	config.o \  	detection.o \  	events.o \  	fs.o \ diff --git a/engines/testbed/testbed.cpp b/engines/testbed/testbed.cpp index 3898040a21..bb3655a557 100644 --- a/engines/testbed/testbed.cpp +++ b/engines/testbed/testbed.cpp @@ -27,8 +27,8 @@  #include "common/system.h"  #include "engines/util.h" -#include "gui/options.h" +#include "testbed/config.h"  #include "testbed/events.h"  #include "testbed/fs.h"  #include "testbed/graphics.h" @@ -84,19 +84,6 @@ TestbedEngine::~TestbedEngine() {  	}  } -void TestbedEngine::enableTestsuite(const Common::String &name, bool enable) { -	Common::Array<Testsuite *>::const_iterator iter; - -	for (iter = _testsuiteList.begin(); iter != _testsuiteList.end(); iter++) { -		if (name.equalsIgnoreCase((*iter)->getName())) { -			(*iter)->enable(enable); -			break; -		} -	} - -	return; -} -  void TestbedEngine::invokeTestsuites() {  	Common::Array<Testsuite *>::const_iterator iter; @@ -107,34 +94,6 @@ void TestbedEngine::invokeTestsuites() {  	}  } -TestbedOptionsDialog::TestbedOptionsDialog() : GUI::OptionsDialog("Select", 120, 120, 360, 200), _hOffset(15), _vOffset(15), _boxWidth(300), _boxHeight(10) { -	new GUI::StaticTextWidget(this, _hOffset, _vOffset, _boxWidth, _boxHeight, "Select testsuites to Execute", Graphics::kTextAlignCenter); -	_vOffset += 20; -	addCheckbox("FS"); -	addCheckbox("GFX"); -	addCheckbox("Savegames"); -	addCheckbox("Misc"); -	addCheckbox("Events"); -	new GUI::ButtonWidget(this, 80 , _vOffset + 10, 80, 25, "Continue", GUI::kOKCmd, 'C'); -	new GUI::ButtonWidget(this, 200, _vOffset + 10, 80, 25, "Exit", GUI::kCloseCmd, 'X'); -} - -TestbedOptionsDialog::~TestbedOptionsDialog() {} - -void TestbedOptionsDialog::addCheckbox(const Common::String &tsName) { -	_checkBoxes.push_back(new GUI::CheckboxWidget(this, _hOffset, _vOffset, _boxWidth, _boxHeight, tsName)); -	_vOffset += 20; -} - -bool TestbedOptionsDialog::isEnabled(const Common::String &tsName) { -	for (uint i = 0; i < _checkBoxes.size(); i++) { -		if (_checkBoxes[i]->getLabel().equalsIgnoreCase(tsName)) { -			return _checkBoxes[i]->getState(); -		} -	} -	return false; -} -  Common::Error TestbedEngine::run() {  	// Initialize graphics using following:  	initGraphics(320, 200, false); @@ -143,37 +102,8 @@ Common::Error TestbedEngine::run() {  	// interactive mode could also be modified by a config parameter "non-interactive=1"  	// TODO: Implement that -	Common::String prompt("Welcome to the ScummVM testbed!\n" -						"It is a framework to test the various ScummVM subsystems namely GFX, Sound, FS, events etc.\n" -						"If you see this, it means interactive tests would run on this system :)"); - -	// To be set from config file -	// By default Interactive tests are enabled -	// XXX: disabling these as of now for fastly testing other tests -	// Testsuite::isSessionInteractive = false; - -	if (Testsuite::isSessionInteractive) { -		Testsuite::logPrintf("Info! : Interactive tests are also being executed.\n"); -		Testsuite::displayMessage(prompt, "Proceed?"); -	} - -	// Select testsuites using checkboxes -	TestbedOptionsDialog tbd; -	tbd.runModal(); - -	// check if user wanted to exit. -	if (shouldQuit()) { -		return Common::kNoError; -	} - -	// Enable selected testsuites -	Common::String tsName; -	for (uint i = 0; i < _testsuiteList.size(); i++) { -		tsName = _testsuiteList[i]->getName(); -		if (tbd.isEnabled(tsName)) { -			enableTestsuite(tsName, true); -		} -	} +	TestbedConfigManager cfMan(_testsuiteList); +	cfMan.selectTestsuites();  	invokeTestsuites();  	return Common::kNoError; diff --git a/engines/testbed/testbed.h b/engines/testbed/testbed.h index fdc8d2e0b0..45aff05320 100644 --- a/engines/testbed/testbed.h +++ b/engines/testbed/testbed.h @@ -62,21 +62,6 @@ private:  	Common::Array<Testsuite *> _testsuiteList;  }; -class TestbedOptionsDialog : public GUI::OptionsDialog { -public: -	TestbedOptionsDialog(); -	~TestbedOptionsDialog(); -	void addCheckbox(const Common::String &tsName); -	bool isEnabled(const Common::String &tsName); - -private: -	Common::Array<GUI::CheckboxWidget *> _checkBoxes; -	const int _hOffset; // current offset from left -	int _vOffset; // current offset from top -	const int _boxWidth; -	const int _boxHeight; -}; -  } // End of namespace Testbed  #endif // TESTBED_H  | 
