[Scummvm-cvs-logs] SF.net SVN: scummvm:[50918] scummvm/branches/gsoc2010-testbed/engines/ testbed

sud03r at users.sourceforge.net sud03r at users.sourceforge.net
Thu Jul 15 20:51:56 CEST 2010


Revision: 50918
          http://scummvm.svn.sourceforge.net/scummvm/?rev=50918&view=rev
Author:   sud03r
Date:     2010-07-15 18:51:56 +0000 (Thu, 15 Jul 2010)

Log Message:
-----------
separated testsuite configuration to another class

Modified Paths:
--------------
    scummvm/branches/gsoc2010-testbed/engines/testbed/module.mk
    scummvm/branches/gsoc2010-testbed/engines/testbed/testbed.cpp
    scummvm/branches/gsoc2010-testbed/engines/testbed/testbed.h

Added Paths:
-----------
    scummvm/branches/gsoc2010-testbed/engines/testbed/config.cpp
    scummvm/branches/gsoc2010-testbed/engines/testbed/config.h

Added: scummvm/branches/gsoc2010-testbed/engines/testbed/config.cpp
===================================================================
--- scummvm/branches/gsoc2010-testbed/engines/testbed/config.cpp	                        (rev 0)
+++ scummvm/branches/gsoc2010-testbed/engines/testbed/config.cpp	2010-07-15 18:51:56 UTC (rev 50918)
@@ -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


Property changes on: scummvm/branches/gsoc2010-testbed/engines/testbed/config.cpp
___________________________________________________________________
Added: svn:mime-type
   + text/plain
Added: svn:keywords
   + Date Rev Author URL Id
Added: svn:eol-style
   + native

Added: scummvm/branches/gsoc2010-testbed/engines/testbed/config.h
===================================================================
--- scummvm/branches/gsoc2010-testbed/engines/testbed/config.h	                        (rev 0)
+++ scummvm/branches/gsoc2010-testbed/engines/testbed/config.h	2010-07-15 18:51:56 UTC (rev 50918)
@@ -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


Property changes on: scummvm/branches/gsoc2010-testbed/engines/testbed/config.h
___________________________________________________________________
Added: svn:mime-type
   + text/plain
Added: svn:keywords
   + Date Rev Author URL Id
Added: svn:eol-style
   + native

Modified: scummvm/branches/gsoc2010-testbed/engines/testbed/module.mk
===================================================================
--- scummvm/branches/gsoc2010-testbed/engines/testbed/module.mk	2010-07-15 15:01:44 UTC (rev 50917)
+++ scummvm/branches/gsoc2010-testbed/engines/testbed/module.mk	2010-07-15 18:51:56 UTC (rev 50918)
@@ -1,6 +1,7 @@
 MODULE := engines/testbed
 
 MODULE_OBJS := \
+	config.o \
 	detection.o \
 	events.o \
 	fs.o \

Modified: scummvm/branches/gsoc2010-testbed/engines/testbed/testbed.cpp
===================================================================
--- scummvm/branches/gsoc2010-testbed/engines/testbed/testbed.cpp	2010-07-15 15:01:44 UTC (rev 50917)
+++ scummvm/branches/gsoc2010-testbed/engines/testbed/testbed.cpp	2010-07-15 18:51:56 UTC (rev 50918)
@@ -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 @@
 	}
 }
 
-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 @@
 	}
 }
 
-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,38 +102,9 @@
 	// 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 :)");
+	TestbedConfigManager cfMan(_testsuiteList);
+	cfMan.selectTestsuites();
 
-	// 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);
-		}
-	}
-
 	invokeTestsuites();
 	return Common::kNoError;
 }

Modified: scummvm/branches/gsoc2010-testbed/engines/testbed/testbed.h
===================================================================
--- scummvm/branches/gsoc2010-testbed/engines/testbed/testbed.h	2010-07-15 15:01:44 UTC (rev 50917)
+++ scummvm/branches/gsoc2010-testbed/engines/testbed/testbed.h	2010-07-15 18:51:56 UTC (rev 50918)
@@ -62,21 +62,6 @@
 	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


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list