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

sud03r at users.sourceforge.net sud03r at users.sourceforge.net
Fri Jul 30 15:54:25 CEST 2010


Revision: 51507
          http://scummvm.svn.sourceforge.net/scummvm/?rev=51507&view=rev
Author:   sud03r
Date:     2010-07-30 13:54:25 +0000 (Fri, 30 Jul 2010)

Log Message:
-----------
TESTBED: generalized the GUI, added code for the end text gui message and option to rerun tests

Modified Paths:
--------------
    scummvm/branches/gsoc2010-testbed/engines/testbed/config.cpp
    scummvm/branches/gsoc2010-testbed/engines/testbed/config.h
    scummvm/branches/gsoc2010-testbed/engines/testbed/sound.cpp
    scummvm/branches/gsoc2010-testbed/engines/testbed/sound.h
    scummvm/branches/gsoc2010-testbed/engines/testbed/testbed.cpp
    scummvm/branches/gsoc2010-testbed/engines/testbed/testbed.h
    scummvm/branches/gsoc2010-testbed/engines/testbed/testsuite.cpp
    scummvm/branches/gsoc2010-testbed/engines/testbed/testsuite.h

Modified: scummvm/branches/gsoc2010-testbed/engines/testbed/config.cpp
===================================================================
--- scummvm/branches/gsoc2010-testbed/engines/testbed/config.cpp	2010-07-30 13:29:33 UTC (rev 51506)
+++ scummvm/branches/gsoc2010-testbed/engines/testbed/config.cpp	2010-07-30 13:54:25 UTC (rev 51507)
@@ -127,6 +127,31 @@
 	}
 }
 
+void TestbedInteractionDialog::addText(uint w, uint h, const Common::String text, Graphics::TextAlign textAlign, uint xOffset, uint yPadding) {
+	if (!xOffset) {
+		xOffset = _xOffset;
+	}
+	_yOffset += yPadding;
+	new GUI::StaticTextWidget(this, xOffset, _yOffset, w, h, text, textAlign);
+	_yOffset += h;
+}
+
+void TestbedInteractionDialog::addButton(uint w, uint h, const Common::String name, uint32 cmd, uint xOffset, uint yPadding) {
+	if (!xOffset) {
+		xOffset = _xOffset;
+	}
+	_yOffset += yPadding;
+	_buttonArray.push_back(new GUI::ButtonWidget(this, xOffset, _yOffset, w, h, name, cmd));
+	_yOffset += h;
+}
+
+void TestbedInteractionDialog::handleCommand(GUI::CommandSender *sender, uint32 cmd, uint32 data) {
+	switch (cmd) {
+	default:
+		GUI::Dialog::handleCommand(sender, cmd, data);
+	}
+}
+
 void TestbedConfigManager::initDefaultConfiguration() {
 	// Default Configuration
 	// Add Global configuration Parameters here.
@@ -143,6 +168,7 @@
 		}
 	}
 	_configFileInterface.saveToStream(*ws);
+	ws->flush();
 }
 
 Common::SeekableReadStream *TestbedConfigManager::getConfigReadStream() {
@@ -243,13 +269,9 @@
 	Testsuite::logPrintf("Info! : Interactive tests are also being executed.\n");
 	
 	if (Testsuite::handleInteractiveInput(prompt, "Proceed?", "Customize", kOptionRight)) {
-
 		// Select testsuites using checkboxes
 		TestbedOptionsDialog tbd(_testsuiteList, this);
 		tbd.runModal();
-
-		
-
 	}
 }
 

Modified: scummvm/branches/gsoc2010-testbed/engines/testbed/config.h
===================================================================
--- scummvm/branches/gsoc2010-testbed/engines/testbed/config.h	2010-07-30 13:29:33 UTC (rev 51506)
+++ scummvm/branches/gsoc2010-testbed/engines/testbed/config.h	2010-07-30 13:54:25 UTC (rev 51507)
@@ -114,6 +114,20 @@
 	TestbedConfigManager *_testbedConfMan;
 };
 
+class TestbedInteractionDialog : public GUI::Dialog {
+public:
+	TestbedInteractionDialog(uint x, uint y, uint w, uint h) : GUI::Dialog(x, y, w, h) {}
+	~TestbedInteractionDialog() {}
+protected:
+	virtual void handleCommand(GUI::CommandSender *sender, uint32 cmd, uint32 data);
+	void addButton(uint w, uint h, const Common::String name, uint32 cmd, uint xOffset = 0, uint yPadding = 8);
+	void addText(uint w, uint h, const Common::String text, Graphics::TextAlign textAlign, uint xOffset, uint yPadding);
+	Common::Array<GUI::ButtonWidget *> _buttonArray;
+	uint _xOffset;
+	uint _yOffset;
+
+};
+
 } // End of namespace Testbed
 
 #endif // TESTBED_CONFIG_H

Modified: scummvm/branches/gsoc2010-testbed/engines/testbed/sound.cpp
===================================================================
--- scummvm/branches/gsoc2010-testbed/engines/testbed/sound.cpp	2010-07-30 13:29:33 UTC (rev 51506)
+++ scummvm/branches/gsoc2010-testbed/engines/testbed/sound.cpp	2010-07-30 13:54:25 UTC (rev 51507)
@@ -37,7 +37,7 @@
 	kPauseChannel3 = 'pac3'
 };
 
-SoundSubsystemDialog::SoundSubsystemDialog() : GUI::Dialog(80, 60, 400, 170) {	
+SoundSubsystemDialog::SoundSubsystemDialog() : TestbedInteractionDialog(80, 60, 400, 170) {
 	_xOffset = 25;
 	_yOffset = 0;
 	Common::String text = "Sound Subsystem Tests: Test Mixing of Audio Streams.";
@@ -48,24 +48,7 @@
 	addButton(50, 20, "Close", GUI::kCloseCmd, 160, 15);
 }
 
-void SoundSubsystemDialog::addText(uint w, uint h, const Common::String text, Graphics::TextAlign textAlign, uint xOffset, uint yPadding) {
-	if (!xOffset) {
-		xOffset = _xOffset;
-	}
-	_yOffset += yPadding;
-	new GUI::StaticTextWidget(this, xOffset, _yOffset, w, h, text, textAlign);
-	_yOffset += h;
-}
 
-void SoundSubsystemDialog::addButton(uint w, uint h, const Common::String name, uint32 cmd, uint xOffset, uint yPadding) {
-	if (!xOffset) {
-		xOffset = _xOffset;
-	}
-	_yOffset += yPadding;
-	_buttonArray.push_back(new GUI::ButtonWidget(this, xOffset, _yOffset, w, h, name, cmd));
-	_yOffset += h;
-}
-
 void SoundSubsystemDialog::handleCommand(GUI::CommandSender *sender, uint32 cmd, uint32 data) {
 	switch (cmd) {
 		case kPlayChannel1:

Modified: scummvm/branches/gsoc2010-testbed/engines/testbed/sound.h
===================================================================
--- scummvm/branches/gsoc2010-testbed/engines/testbed/sound.h	2010-07-30 13:29:33 UTC (rev 51506)
+++ scummvm/branches/gsoc2010-testbed/engines/testbed/sound.h	2010-07-30 13:54:25 UTC (rev 51507)
@@ -25,22 +25,17 @@
 #ifndef TESTBED_SOUND_H
 #define TESTBED_SOUND_H
 
-#include "testbed/testsuite.h"
 #include "gui/dialog.h"
+#include "testbed/config.h"
+#include "testbed/testsuite.h"
 
 namespace Testbed {
 
-class SoundSubsystemDialog : public GUI::Dialog {
+class SoundSubsystemDialog : public TestbedInteractionDialog {
 public:
 	SoundSubsystemDialog();
 	~SoundSubsystemDialog() {}
 	void handleCommand(GUI::CommandSender *sender, uint32 cmd, uint32 data);
-private:
-	void addButton(uint w, uint h, const Common::String name, uint32 cmd, uint xOffset = 0, uint yPadding = 8);
-	void addText(uint w, uint h, const Common::String text, Graphics::TextAlign textAlign, uint xOffset, uint yPadding);
-	Common::Array<GUI::ButtonWidget *> _buttonArray;
-	uint _xOffset;
-	uint _yOffset;
 };
 
 namespace SoundSubsystem {

Modified: scummvm/branches/gsoc2010-testbed/engines/testbed/testbed.cpp
===================================================================
--- scummvm/branches/gsoc2010-testbed/engines/testbed/testbed.cpp	2010-07-30 13:29:33 UTC (rev 51506)
+++ scummvm/branches/gsoc2010-testbed/engines/testbed/testbed.cpp	2010-07-30 13:54:25 UTC (rev 51507)
@@ -28,7 +28,6 @@
 
 #include "engines/util.h"
 
-#include "testbed/config.h"
 #include "testbed/events.h"
 #include "testbed/fs.h"
 #include "testbed/graphics.h"
@@ -39,6 +38,26 @@
 
 namespace Testbed {
 
+TestbedExitDialog::TestbedExitDialog() : TestbedInteractionDialog(80, 60, 400, 170), _rerun(false) {
+	_xOffset = 25;
+	_yOffset = 0;
+	Common::String text = "Here we will have the results of all the tests!";
+	addText(350, 20, text, Graphics::kTextAlignCenter, _xOffset, 15);
+	addButton(200, 20, "Rerun Tests", kCmdRerunTestbed);
+	addButton(50, 20, "Close", GUI::kCloseCmd, 160, 15);
+
+}
+
+void TestbedExitDialog::handleCommand(GUI::CommandSender *sender, uint32 cmd, uint32 data) {
+	switch (cmd) {
+	case kCmdRerunTestbed :
+		_rerun = true;
+		GUI::Dialog::close();
+	default:
+		GUI::Dialog::handleCommand(sender, cmd, data);
+	}
+}
+
 bool TestbedEngine::hasFeature(EngineFeature f) const {
 	return (f == kSupportsRTL) ? true : false;
 }
@@ -95,6 +114,7 @@
 	int numSuitesEnabled = cfMan.getNumSuitesEnabled();
 
 	for (iter = _testsuiteList.begin(); iter != _testsuiteList.end(); iter++) {
+		(*iter)->reset();
 		if ((*iter)->isEnabled()) {
 			Testsuite::updateStats("Testsuite", (*iter)->getName(), count++, numSuitesEnabled, pt);
 			(*iter)->execute();
@@ -111,17 +131,26 @@
 	// TODO: Implement that
 
 	TestbedConfigManager cfMan(_testsuiteList, "testbed.config");
-	cfMan.selectTestsuites();
+	
+	// Keep running if rerun requested 
+	TestbedExitDialog tbDialog;
 
-	// Init logging
-	Testsuite::initLogging(true);
+	do {
+		Testsuite::clearEntireScreen();
+		cfMan.selectTestsuites();
+		// Init logging
+		Testsuite::initLogging(true);
+		// Check if user wanted to exit.
+		if (Engine::shouldQuit()) {
+			return Common::kNoError;
+		}
+		
+		invokeTestsuites(cfMan);
+		
+		tbDialog.run();
+
+	} while (tbDialog.rerunRequired());
 	
-	// check if user wanted to exit.
-	if (Engine::shouldQuit()) {
-		return Common::kNoError;
-	}
-	
-	invokeTestsuites(cfMan);
 	return Common::kNoError;
 }
 

Modified: scummvm/branches/gsoc2010-testbed/engines/testbed/testbed.h
===================================================================
--- scummvm/branches/gsoc2010-testbed/engines/testbed/testbed.h	2010-07-30 13:29:33 UTC (rev 51506)
+++ scummvm/branches/gsoc2010-testbed/engines/testbed/testbed.h	2010-07-30 13:54:25 UTC (rev 51507)
@@ -29,6 +29,7 @@
 
 #include "gui/options.h"
 
+#include "testbed/config.h"
 #include "testbed/testsuite.h"
 
 namespace Testbed {
@@ -37,7 +38,8 @@
 
 enum {
 	kTestbedLogOutput = 1 << 0,
-	kTestbedEngineDebug = 1 << 2
+	kTestbedEngineDebug = 1 << 2, 
+	kCmdRerunTestbed = 'crtb'
 };
 
 class TestbedEngine : public Engine {
@@ -53,11 +55,28 @@
 	void invokeTestsuites(TestbedConfigManager &cfMan);
 
 	bool hasFeature(EngineFeature f) const;
-
+	
 private:
 	Common::Array<Testsuite *> _testsuiteList;
 };
 
+class TestbedExitDialog : public TestbedInteractionDialog {
+public:
+	TestbedExitDialog();
+	~TestbedExitDialog() {}
+	void handleCommand(GUI::CommandSender *sender, uint32 cmd, uint32 data);
+	void run() { runModal(); }
+	bool rerunRequired() {
+		if (_rerun) {
+			_rerun = false;
+			return true;
+		}
+		return false;
+	}
+private:
+	bool _rerun;
+};
+
 } // End of namespace Testbed
 
 #endif // TESTBED_H

Modified: scummvm/branches/gsoc2010-testbed/engines/testbed/testsuite.cpp
===================================================================
--- scummvm/branches/gsoc2010-testbed/engines/testbed/testsuite.cpp	2010-07-30 13:29:33 UTC (rev 51506)
+++ scummvm/branches/gsoc2010-testbed/engines/testbed/testsuite.cpp	2010-07-30 13:54:25 UTC (rev 51507)
@@ -131,6 +131,15 @@
 	}
 }
 
+void Testsuite::reset() {
+	_numTestsPassed = 0;
+	_numTestsExecuted = 0;
+	toQuit = kLoopNormal;
+	for (Common::Array<Test *>::iterator i = _testsToExecute.begin(); i != _testsToExecute.end(); ++i) {
+		(*i)->passed = false;
+	}
+}
+
 void Testsuite::genReport() const {
 	logPrintf("\n");
 	logPrintf("Consolidating results...\n");

Modified: scummvm/branches/gsoc2010-testbed/engines/testbed/testsuite.h
===================================================================
--- scummvm/branches/gsoc2010-testbed/engines/testbed/testsuite.h	2010-07-30 13:29:33 UTC (rev 51506)
+++ scummvm/branches/gsoc2010-testbed/engines/testbed/testsuite.h	2010-07-30 13:54:25 UTC (rev 51507)
@@ -92,7 +92,8 @@
 		_isTsEnabled = flag;
 	}
 	bool enableTest(const Common::String &testName, bool enable);
-
+	void reset();
+	
 	/**
 	 * Prompts for User Input in form of "Yes" or "No" for interactive tests
 	 * e.g: "Is this like you expect?" "Yes" or "No"


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