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

sud03r at users.sourceforge.net sud03r at users.sourceforge.net
Mon Jul 19 23:12:18 CEST 2010


Revision: 51038
          http://scummvm.svn.sourceforge.net/scummvm/?rev=51038&view=rev
Author:   sud03r
Date:     2010-07-19 21:12:17 +0000 (Mon, 19 Jul 2010)

Log Message:
-----------
added code to display progress of the engine so far

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

Modified: scummvm/branches/gsoc2010-testbed/engines/testbed/graphics.cpp
===================================================================
--- scummvm/branches/gsoc2010-testbed/engines/testbed/graphics.cpp	2010-07-19 20:13:17 UTC (rev 51037)
+++ scummvm/branches/gsoc2010-testbed/engines/testbed/graphics.cpp	2010-07-19 21:12:17 UTC (rev 51038)
@@ -66,7 +66,7 @@
 
 	// Effects
 	addTest("shakingEffect", &GFXtests::shakingEffect);
-	addTest("focusRectangle", &GFXtests::focusRectangle);
+	// addTest("focusRectangle", &GFXtests::focusRectangle);
 
 	// Overlay
 	addTest("Overlays", &GFXtests::overlayGraphics);
@@ -352,13 +352,17 @@
  * Used by aspectRatio()
  */
 void GFXtests::drawEllipse(int cx, int cy, int a, int b) {
+	
 	// Take a buffer of screen size
-	byte buffer[200][320] = {{0}};
+	int width = g_system->getWidth();
+	int height = Testsuite::getDisplayRegionCoordinates().y;
+	byte *buffer = new byte[height * width];
 	float theta;
 	int x, y, x1, y1;
 
+	memset(buffer, 0, sizeof(byte) * width * height);
 	// Illuminate the center
-	buffer[cx][cy] = 1;
+	buffer[cx * width + cy] = 1;
 
 	// Illuminate the points lying on ellipse
 
@@ -371,26 +375,27 @@
 		x1 = x + cx;
 		y1 = y + cy;
 
-		buffer[x1][y1] = 1;
+		buffer[x1 * width + y1] = 1;
 
 		x1 = (-1) * x + cx;
 		y1 = y + cy;
 
-		buffer[x1][y1] = 1;
+		buffer[x1 * width + y1] = 1;
 
 		x1 = x + cx;
 		y1 = (-1) * y + cy;
 
-		buffer[x1][y1] = 1;
+		buffer[x1 * width + y1] = 1;
 
 		x1 = (-1) * x + cx;
 		y1 = (-1) * y + cy;
 
-		buffer[x1][y1] = 1;
+		buffer[x1 * width + y1] = 1;
 	}
 
-	g_system->copyRectToScreen(&buffer[0][0], 320, 0, 0, 320, 200);
+	g_system->copyRectToScreen(buffer, width, 0, 0, width, height);
 	g_system->updateScreen();
+	delete[] buffer;
 }
 
 // GFXtests go here
@@ -476,11 +481,8 @@
  */
 bool GFXtests::aspectRatio() {
 	// Draw an ellipse on the screen
-	drawEllipse(100, 160, 72, 60);
+	drawEllipse(80, 160, 72, 60);
 
-	Common::Point pt(0, 180);
-	Testsuite::writeOnScreen("Testing Aspect Ratio Correction!", pt);
-
 	bool isFeaturePresent;
 	bool isFeatureEnabled;
 	bool passed;
@@ -720,7 +722,7 @@
 	}
 	g_system->delayMillis(1500);
 
-	if (Testsuite::handleInteractiveInput("Did the test worked as you were expecting?", "Yes", "No", kOptionRight)) {
+	if (Testsuite::handleInteractiveInput("Did the shaking test worked as you were expecting?", "Yes", "No", kOptionRight)) {
 		Testsuite::logDetailedPrintf("Shaking Effect didn't worked");
 		return false;
 	}

Modified: scummvm/branches/gsoc2010-testbed/engines/testbed/testbed.cpp
===================================================================
--- scummvm/branches/gsoc2010-testbed/engines/testbed/testbed.cpp	2010-07-19 20:13:17 UTC (rev 51037)
+++ scummvm/branches/gsoc2010-testbed/engines/testbed/testbed.cpp	2010-07-19 21:12:17 UTC (rev 51038)
@@ -86,9 +86,12 @@
 
 void TestbedEngine::invokeTestsuites() {
 	Common::Array<Testsuite *>::const_iterator iter;
+	uint count = 1;
+	Common::Point pt = Testsuite::getDisplayRegionCoordinates();
 
 	for (iter = _testsuiteList.begin(); iter != _testsuiteList.end(); iter++) {
 		if ((*iter)->isEnabled()) {
+			Testsuite::updateStats("Testsuite", (*iter)->getName(), count++, _testsuiteList.size(), pt);
 			(*iter)->execute();
 		}
 	}

Modified: scummvm/branches/gsoc2010-testbed/engines/testbed/testsuite.cpp
===================================================================
--- scummvm/branches/gsoc2010-testbed/engines/testbed/testsuite.cpp	2010-07-19 20:13:17 UTC (rev 51037)
+++ scummvm/branches/gsoc2010-testbed/engines/testbed/testsuite.cpp	2010-07-19 21:12:17 UTC (rev 51038)
@@ -31,6 +31,7 @@
 
 #include "gui/message.h"
 
+#include "testbed/graphics.h"
 #include "testbed/testbed.h"
 #include "testbed/testsuite.h"
 
@@ -42,6 +43,7 @@
 // Static private variable of Testsuite
 Common::String Testsuite::_logDirectory = "";
 Common::String Testsuite::_logFilename = "";
+Graphics::FontManager::FontUsage Testsuite::_displayFont = Graphics::FontManager::kGUIFont;
 Common::WriteStream *Testsuite::_ws = 0;
 uint Testsuite::toQuit = kLoopNormal;
 
@@ -183,10 +185,13 @@
 
 void Testsuite::clearScreen() {
 	int numBytesPerLine = g_system->getWidth() * g_system->getScreenFormat().bytesPerPixel;
-	int size =  g_system->getHeight() * numBytesPerLine;
+	int height = getDisplayRegionCoordinates().y;
+	
+	// Don't clear test info display region
+	int size =  height * 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->copyRectToScreen(buffer, numBytesPerLine, 0, 0, g_system->getWidth(), height);
 	g_system->updateScreen();
 	delete[] buffer;
 }
@@ -237,6 +242,37 @@
 	return kLoopNormal;
 }
 
+void Testsuite::updateStats(const char *prefix, const char *info, uint testNum, uint numTests, Common::Point pt) {
+	Common::String text = Common::String::printf(" Running %s: %s (%d of %d) ", prefix, info, testNum, numTests);
+	writeOnScreen(text, pt);
+	// below the text a rectangle denoting the progress in the testsuite can be drawn.
+	int separation = getLineSeparation();
+	pt.y += separation;
+	int wRect = 200;
+	int lRect = 7;
+	pt.x = g_system->getWidth() / 2 - 100;
+	byte *buffer = new byte[lRect * wRect];
+	memset(buffer, 0, sizeof(byte) * lRect * wRect);
+
+	int wShaded = (int) (wRect * (((float)testNum - 1) / numTests));
+
+	// draw the boundary
+	memset(buffer, 1, sizeof(byte) * wRect);
+	memset(buffer + (wRect * (lRect - 1)) , 1, sizeof(byte) * wRect);
+	
+	for (int i = 0; i < lRect; i++) {
+		for (int j = 0; j < wRect; j++) {
+			if (j < wShaded) {
+				buffer[i * wRect + j] = 1;
+			}
+		}
+		buffer[i * wRect + 0] = 1;
+		buffer[i * wRect + wRect - 1] = 1;
+	}
+	g_system->copyRectToScreen(buffer, wRect, pt.x, pt.y, wRect, lRect);
+	g_system->updateScreen();
+}
+
 void Testsuite::execute() {
 	// Main Loop for a testsuite
 
@@ -245,6 +281,10 @@
 		return;
 	}
 
+	uint count = 1;
+	Common::Point pt = getDisplayRegionCoordinates();
+	pt.y += getLineSeparation();
+
 	for (Common::Array<Test *>::iterator i = _testsToExecute.begin(); i != _testsToExecute.end(); ++i) {
 		if (toQuit == kSkipNext) {
 			logPrintf("Info! Skipping Test: %s, Skipped by user.\n", ((*i)->featureName).c_str());
@@ -258,6 +298,7 @@
 		}
 
 		logPrintf("Info! Executing Test: %s\n", ((*i)->featureName).c_str());
+		updateStats("Test", ((*i)->featureName).c_str(), count++, _testsToExecute.size(), pt);
 		_numTestsExecuted++;
 		if ((*i)->driver()) {
 			logPrintf("Result: Passed\n");
@@ -265,6 +306,7 @@
 		} else {
 			logPrintf("Result: Failed\n");
 		}
+		updateStats("Test", ((*i)->featureName).c_str(), count, _testsToExecute.size(), pt);
 		// TODO: Display a screen here to user with details of upcoming test, he can skip it or Quit or RTL
 		// Check if user wants to quit/RTL/Skip next test by parsing events.
 		// Quit directly if explicitly requested

Modified: scummvm/branches/gsoc2010-testbed/engines/testbed/testsuite.h
===================================================================
--- scummvm/branches/gsoc2010-testbed/engines/testbed/testsuite.h	2010-07-19 20:13:17 UTC (rev 51037)
+++ scummvm/branches/gsoc2010-testbed/engines/testbed/testsuite.h	2010-07-19 21:12:17 UTC (rev 51038)
@@ -29,6 +29,7 @@
 #include "common/str.h"
 #include "common/array.h"
 
+#include "graphics/fontman.h"
 
 namespace Testbed {
 
@@ -136,6 +137,33 @@
 
 	static void deleteWriteStream();
 
+	// Progress bar (Information Display) related methods.
+	/** 
+	 * Display region is in the bottom. Probably 1/4th of the game screen.
+	 * It contains:
+	 * 1) Information about executing testsuite.
+	 * 2) Total progress within this testsuite.
+	 * 3) Total overall progress in the number of testsuites
+	 */
+
+	static Common::Point getDisplayRegionCoordinates() {
+		Common::Point pt(0, 0);
+		// start from bottom
+		pt.y = g_system->getHeight();
+		// Will Contain 3 lines
+		pt.y -= (FontMan.getFontByUsage(_displayFont)->getFontHeight() * 3 + 15); // Buffer of 5 pixels per line
+		return pt;
+	}
+
+	static uint getLineSeparation() {
+		return FontMan.getFontByUsage(_displayFont)->getFontHeight() + 5;
+	}
+	static Graphics::FontManager::FontUsage getCurrentFontUsageType() { return _displayFont; }
+	static void setCurrentFontUsageType(Graphics::FontManager::FontUsage f) { _displayFont = f; }
+
+	static void updateStats(const char *prefix, const char *info, uint numTests, uint testNum, Common::Point pt);
+
+
 protected:
 	Common::Array<Test *> _testsToExecute;			///< List of tests to be executed
 	int		    _numTestsPassed;					///< Number of tests passed
@@ -162,6 +190,11 @@
 	static Common::String _logDirectory;
 	static Common::String _logFilename;
 	static Common::WriteStream *_ws;
+
+	/**
+	 * Private variable used for font
+	 */
+	static Graphics::FontManager::FontUsage	_displayFont;
 };
 
 } // 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