From f3defb0de13026f37cd69025064513ffc3d63c11 Mon Sep 17 00:00:00 2001 From: Neeraj Kumar Date: Mon, 19 Jul 2010 21:12:17 +0000 Subject: added code to display progress of the engine so far svn-id: r51038 --- engines/testbed/graphics.cpp | 28 ++++++++++++++------------ engines/testbed/testbed.cpp | 3 +++ engines/testbed/testsuite.cpp | 46 +++++++++++++++++++++++++++++++++++++++++-- engines/testbed/testsuite.h | 33 +++++++++++++++++++++++++++++++ 4 files changed, 95 insertions(+), 15 deletions(-) (limited to 'engines/testbed') diff --git a/engines/testbed/graphics.cpp b/engines/testbed/graphics.cpp index bac680ae7e..c847bc6188 100644 --- a/engines/testbed/graphics.cpp +++ b/engines/testbed/graphics.cpp @@ -66,7 +66,7 @@ GFXTestSuite::GFXTestSuite() { // Effects addTest("shakingEffect", &GFXtests::shakingEffect); - addTest("focusRectangle", &GFXtests::focusRectangle); + // addTest("focusRectangle", &GFXtests::focusRectangle); // Overlay addTest("Overlays", &GFXtests::overlayGraphics); @@ -352,13 +352,17 @@ void GFXtests::mouseMovements() { * 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 @@ void GFXtests::drawEllipse(int cx, int cy, int a, int b) { 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,10 +481,7 @@ bool GFXtests::fullScreenMode() { */ bool GFXtests::aspectRatio() { // Draw an ellipse on the screen - drawEllipse(100, 160, 72, 60); - - Common::Point pt(0, 180); - Testsuite::writeOnScreen("Testing Aspect Ratio Correction!", pt); + drawEllipse(80, 160, 72, 60); bool isFeaturePresent; bool isFeatureEnabled; @@ -720,7 +722,7 @@ bool GFXtests::shakingEffect() { } 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; } diff --git a/engines/testbed/testbed.cpp b/engines/testbed/testbed.cpp index 7785bd1a17..5702f0356f 100644 --- a/engines/testbed/testbed.cpp +++ b/engines/testbed/testbed.cpp @@ -86,9 +86,12 @@ TestbedEngine::~TestbedEngine() { void TestbedEngine::invokeTestsuites() { Common::Array::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(); } } diff --git a/engines/testbed/testsuite.cpp b/engines/testbed/testsuite.cpp index 280959b1c9..8109989e44 100644 --- a/engines/testbed/testsuite.cpp +++ b/engines/testbed/testsuite.cpp @@ -31,6 +31,7 @@ #include "gui/message.h" +#include "testbed/graphics.h" #include "testbed/testbed.h" #include "testbed/testsuite.h" @@ -42,6 +43,7 @@ bool Testsuite::isSessionInteractive = true; // 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(const Common::Rect &rect) { 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 @@ uint Testsuite::parseEvents() { 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 @@ void Testsuite::execute() { return; } + uint count = 1; + Common::Point pt = getDisplayRegionCoordinates(); + pt.y += getLineSeparation(); + for (Common::Array::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 @@ void Testsuite::execute() { } 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 @@ void Testsuite::execute() { } 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 diff --git a/engines/testbed/testsuite.h b/engines/testbed/testsuite.h index d8650915e0..08591d7b49 100644 --- a/engines/testbed/testsuite.h +++ b/engines/testbed/testsuite.h @@ -29,6 +29,7 @@ #include "common/str.h" #include "common/array.h" +#include "graphics/fontman.h" namespace Testbed { @@ -136,6 +137,33 @@ public: 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 _testsToExecute; ///< List of tests to be executed int _numTestsPassed; ///< Number of tests passed @@ -162,6 +190,11 @@ private: 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 -- cgit v1.2.3