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

sud03r at users.sourceforge.net sud03r at users.sourceforge.net
Sat Jun 26 16:29:51 CEST 2010


Revision: 50322
          http://scummvm.svn.sourceforge.net/scummvm/?rev=50322&view=rev
Author:   sud03r
Date:     2010-06-26 14:29:50 +0000 (Sat, 26 Jun 2010)

Log Message:
-----------
split testsuite.h into testsuite.cpp

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

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

Modified: scummvm/branches/gsoc2010-testbed/engines/testbed/fs.h
===================================================================
--- scummvm/branches/gsoc2010-testbed/engines/testbed/fs.h	2010-06-26 13:28:22 UTC (rev 50321)
+++ scummvm/branches/gsoc2010-testbed/engines/testbed/fs.h	2010-06-26 14:29:50 UTC (rev 50322)
@@ -25,6 +25,8 @@
 #ifndef FS_H
 #define FS_H
 
+#include "common/fs.h"
+
 #include "testbed/testsuite.h"
 
 namespace Testbed {

Modified: scummvm/branches/gsoc2010-testbed/engines/testbed/module.mk
===================================================================
--- scummvm/branches/gsoc2010-testbed/engines/testbed/module.mk	2010-06-26 13:28:22 UTC (rev 50321)
+++ scummvm/branches/gsoc2010-testbed/engines/testbed/module.mk	2010-06-26 14:29:50 UTC (rev 50322)
@@ -5,7 +5,8 @@
 	fs.o \
 	graphics.o \
 	savegame.o \
-	testbed.o
+	testbed.o \
+	testsuite.o
  
 MODULE_DIRS += \
 	engines/testbed

Modified: scummvm/branches/gsoc2010-testbed/engines/testbed/testbed.cpp
===================================================================
--- scummvm/branches/gsoc2010-testbed/engines/testbed/testbed.cpp	2010-06-26 13:28:22 UTC (rev 50321)
+++ scummvm/branches/gsoc2010-testbed/engines/testbed/testbed.cpp	2010-06-26 14:29:50 UTC (rev 50322)
@@ -80,16 +80,16 @@
 	// interactive mode could also be modified by a config parameter "non-interactive=1"
 	// TODO: Implement that
 
-	bool interactive;
 	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
-	interactive = false;
+	// Testsuite::isInteractive = false;
 
-	if (interactive) {
+	if (Testsuite::isInteractive) {
 		printf("Running Interactive tests as well\n");		
 		Testsuite::displayMessage(prompt, "proceed?");
 		// Executing GFX Tests

Added: scummvm/branches/gsoc2010-testbed/engines/testbed/testsuite.cpp
===================================================================
--- scummvm/branches/gsoc2010-testbed/engines/testbed/testsuite.cpp	                        (rev 0)
+++ scummvm/branches/gsoc2010-testbed/engines/testbed/testsuite.cpp	2010-06-26 14:29:50 UTC (rev 50322)
@@ -0,0 +1,144 @@
+/* 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 "graphics/fontman.h"
+#include "graphics/surface.h"
+
+#include "gui/message.h"
+
+#include "testbed/testsuite.h"
+
+namespace Testbed {
+
+// Static public variable of Testsuite
+bool Testsuite::isInteractive = true;
+
+Testsuite::Testsuite() {
+		_numTestsPassed = 0;
+		_numTestsExecuted = 0;
+}
+
+Testsuite::~Testsuite() {
+	for (Common::Array<Test*>::iterator i = _testsToExecute.begin(); i != _testsToExecute.end(); ++i) {
+		delete (*i);
+	}
+}
+
+void Testsuite::genReport() const {
+	printf("\nSubsystem: %s\n",getName());
+	printf("Tests executed: %d\n", _numTestsExecuted);
+	printf("Tests Passed: %d\n", _numTestsPassed);
+	printf("Tests Failed: %d\n\n", getNumTestsFailed());
+}
+	
+bool Testsuite::handleInteractiveInput(const Common::String &textToDisplay, const char *opt1, const char *opt2, OptionSelected result) {
+	GUI::MessageDialog	prompt(textToDisplay, opt1, opt2);
+	return prompt.runModal() == result ? true : false;
+}
+
+void Testsuite::displayMessage(const Common::String &textToDisplay, const char *defaultButton, const char *altButton) {
+	GUI::MessageDialog	prompt(textToDisplay, defaultButton);
+	prompt.runModal();
+}
+
+Common::Rect Testsuite::writeOnScreen(const Common::String &textToDisplay, const Common::Point &pt, bool flag) {
+	const Graphics::Font &font(*FontMan.getFontByUsage(Graphics::FontManager::kConsoleFont));
+	uint fillColor = kColorBlack;
+	uint textColor = kColorWhite;
+
+	Graphics::Surface *screen = g_system->lockScreen();
+	
+	int height = font.getFontHeight();
+	int width = screen->w;
+
+	Common::Rect rect(pt.x, pt.y, pt.x + width, pt.y + height);
+
+	if (flag) {
+		Graphics::PixelFormat pf = g_system->getScreenFormat();
+		fillColor = pf.RGBToColor(0 , 0, 0);
+		textColor = pf.RGBToColor(255 , 255, 255);
+	}
+	
+	screen->fillRect(rect, fillColor);
+	font.drawString(screen, textToDisplay, rect.left, rect.top, screen->w, textColor, Graphics::kTextAlignCenter);
+
+	g_system->unlockScreen();
+	g_system->updateScreen();
+
+	return rect;
+}
+
+void Testsuite::clearScreen(const Common::Rect &rect) {
+	Graphics::Surface *screen = g_system->lockScreen();
+	
+	screen->fillRect(rect, kColorBlack);
+
+	g_system->unlockScreen();
+	g_system->updateScreen();
+}
+	
+void Testsuite::clearScreen() {
+	int numBytesPerLine = g_system->getWidth() * g_system->getScreenFormat().bytesPerPixel;
+	int size =  g_system->getHeight() * numBytesPerLine;
+	byte *buffer = new byte[size];
+	memset(buffer, 0, size);
+	g_system->copyRectToScreen(buffer, numBytesPerLine, 0, 0, g_system->getWidth(), g_system->getHeight());
+	g_system->updateScreen();	
+}
+	
+void Testsuite::clearScreen(bool flag) {
+	Graphics::Surface *screen = g_system->lockScreen();
+	uint fillColor = kColorBlack;
+
+	if (flag) {
+		fillColor = g_system->getScreenFormat().RGBToColor(0, 0, 0);
+	}
+
+	screen->fillRect(Common::Rect(0, 0, g_system->getWidth(), g_system->getHeight()), fillColor);
+
+	g_system->unlockScreen();
+	g_system->updateScreen();
+}
+
+void Testsuite::addTest(const Common::String &name, InvokingFunction f) {
+	Test*  featureTest = new Test(name, f);
+	_testsToExecute.push_back(featureTest);
+}
+	
+void Testsuite::execute() {
+	for (Common::Array<Test*>::iterator i = _testsToExecute.begin(); i != _testsToExecute.end(); ++i) {
+		printf("Executing Test:%s\n", ((*i)->featureName).c_str());
+		_numTestsExecuted++;
+		if ((*i)->driver()) {
+			printf("RESULT: Passed\n");
+			_numTestsPassed++;
+		} else {
+			printf("RESULT: Failed\n");
+		}
+	}
+	genReport();
+}
+
+} // end of namespace Testebed
+


Property changes on: scummvm/branches/gsoc2010-testbed/engines/testbed/testsuite.cpp
___________________________________________________________________
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/testsuite.h
===================================================================
--- scummvm/branches/gsoc2010-testbed/engines/testbed/testsuite.h	2010-06-26 13:28:22 UTC (rev 50321)
+++ scummvm/branches/gsoc2010-testbed/engines/testbed/testsuite.h	2010-06-26 14:29:50 UTC (rev 50322)
@@ -29,11 +29,7 @@
 #include "common/str.h"
 #include "common/array.h"
 
-#include "graphics/fontman.h"
-#include "graphics/surface.h"
 
-#include "gui/message.h"
-
 namespace Testbed {
 
 enum {
@@ -69,27 +65,13 @@
 
 class Testsuite {
 public:
-	Testsuite() {
-		_numTestsPassed = 0;
-		_numTestsExecuted = 0;
-	}
-	
-	virtual ~Testsuite() {
-		for (Common::Array<Test*>::iterator i = _testsToExecute.begin(); i != _testsToExecute.end(); ++i) {
-			delete (*i);
-		}	
-	}
-	
+	Testsuite();
+	virtual ~Testsuite();	
 	int getNumTests() const { return _testsToExecute.size(); }
 	int getNumTestsPassed() const { return _numTestsPassed; }
 	int getNumTestsFailed() const { return _numTestsExecuted - _numTestsPassed; }
-	void genReport() const {
-		printf("\nSubsystem: %s\n",getName());
-		printf("Tests executed: %d\n", _numTestsExecuted);
-		printf("Tests Passed: %d\n", _numTestsPassed);
-		printf("Tests Failed: %d\n\n", getNumTestsFailed());
-	}
-	
+	void genReport() const;
+
 	/**
 	 * Prompts for User Input in form of "Yes" or "No" for interactive tests
 	 * e.g: "Is this like you expect?" "Yes" or "No"
@@ -97,109 +79,42 @@
 	 * @param	textToDisplay Display text
 	 * @return	true if "Yes" false otherwise
 	 */ 
-	static bool handleInteractiveInput(const Common::String &textToDisplay, const char *opt1 = "Yes", const char *opt2 = "No", OptionSelected result = kOptionLeft) {
-		GUI::MessageDialog	prompt(textToDisplay, opt1, opt2);
-		return prompt.runModal() == result ? true : false;
-	}
+	static bool handleInteractiveInput(const Common::String &textToDisplay, const char *opt1 = "Yes", const char *opt2 = "No", OptionSelected result = kOptionLeft);
 	
-	static void displayMessage(const Common::String &textToDisplay, const char *defaultButton = "OK", const char *altButton = 0) {
-		GUI::MessageDialog	prompt(textToDisplay, defaultButton);
-		prompt.runModal();
-	}
+	static void displayMessage(const Common::String &textToDisplay, const char *defaultButton = "OK", const char *altButton = 0);
+	static Common::Rect writeOnScreen(const Common::String &textToDisplay, const Common::Point &pt, bool flag = false);	
+	static void clearScreen(const Common::Rect &rect);
+	static void clearScreen();
+	static void clearScreen(bool flag);
 
-	static Common::Rect writeOnScreen(const Common::String &textToDisplay, const Common::Point &pt, bool flag = false) {
-		const Graphics::Font &font(*FontMan.getFontByUsage(Graphics::FontManager::kConsoleFont));
-		uint fillColor = kColorBlack;
-		uint textColor = kColorWhite;
-		
-		Graphics::Surface *screen = g_system->lockScreen();
-		
-		int height = font.getFontHeight();
-		int width = screen->w;
-
-		Common::Rect rect(pt.x, pt.y, pt.x + width, pt.y + height);
-
-		if (flag) {
-			Graphics::PixelFormat pf = g_system->getScreenFormat();
-			fillColor = pf.RGBToColor(0 , 0, 0);
-			textColor = pf.RGBToColor(255 , 255, 255);
-		}
-		
-		screen->fillRect(rect, fillColor);
-		font.drawString(screen, textToDisplay, rect.left, rect.top, screen->w, textColor, Graphics::kTextAlignCenter);
-
-		g_system->unlockScreen();
-		g_system->updateScreen();
-
-		return rect;
-	}
-
-	static void clearScreen(const Common::Rect &rect) {
-		Graphics::Surface *screen = g_system->lockScreen();
-		
-		screen->fillRect(rect, kColorBlack);	
-
-		g_system->unlockScreen();
-		g_system->updateScreen();
-	}
-	
-	static void clearScreen() {
-		int numBytesPerLine = g_system->getWidth() * g_system->getScreenFormat().bytesPerPixel;
-		int size =  g_system->getHeight() * numBytesPerLine;
-		byte *buffer = new byte[size];
-		memset(buffer, 0, size);
-		g_system->copyRectToScreen(buffer, numBytesPerLine, 0, 0, g_system->getWidth(), g_system->getHeight());
-		g_system->updateScreen();	
-	}
-	
-	static void clearScreen(bool flag) {
-		Graphics::Surface *screen = g_system->lockScreen();
-		uint fillColor = kColorBlack;
-		
-		if (flag) {
-			fillColor = g_system->getScreenFormat().RGBToColor(0, 0, 0);
-		}
-		
-		screen->fillRect(Common::Rect(0, 0, g_system->getWidth(), g_system->getHeight()), fillColor);
-
-		g_system->unlockScreen();
-		g_system->updateScreen();
-	}
-
 	/**
 	 * Adds a test to the list of tests to be executed
 	 *
 	 * @param	name the string description of the test, for display purposes
 	 * @param	f pointer to the function that invokes this test
 	 */
-	void addTest(const Common::String &name, InvokingFunction f) {
-		Test*  featureTest = new Test(name, f);
-		_testsToExecute.push_back(featureTest);
-	}
-	
+	void addTest(const Common::String &name, InvokingFunction f);
+
 	/**
 	 * The driver function for the testsuite
 	 * All code should go in here.
 	 */
-	virtual void execute() {
-		for (Common::Array<Test*>::iterator i = _testsToExecute.begin(); i != _testsToExecute.end(); ++i) {
-			printf("Executing Test:%s\n", ((*i)->featureName).c_str());
-			_numTestsExecuted++;
-			if ((*i)->driver()) {
-				printf("RESULT: Passed\n");
-				_numTestsPassed++;
-			} else {
-				printf("RESULT: Failed\n");
-			}
-		}
-		genReport();
-	}
+	virtual void execute();
+	
 	virtual const char *getName() const = 0;
 
 protected:
 	Common::Array<Test*> _testsToExecute;			///< List of tests to be executed
 	int		    _numTestsPassed;					///< Number of tests passed
 	int  		_numTestsExecuted;					///< Number of tests executed
+
+public:
+
+	/**
+	 * Static variable of this class that determines if the tests are interactive or not.
+	 * Used by various tests to respond accordingly
+	 */
+	static bool isInteractive;
 };
 
 }	// End of namespace testbed


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