From 5df3809d371c1d37d03dfd51689a58420cc337a6 Mon Sep 17 00:00:00 2001 From: Neeraj Kumar Date: Wed, 2 Jun 2010 04:45:44 +0000 Subject: enhanced the basic testsuite class svn-id: r49390 --- engines/testbed/graphics.cpp | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 engines/testbed/graphics.cpp (limited to 'engines/testbed/graphics.cpp') diff --git a/engines/testbed/graphics.cpp b/engines/testbed/graphics.cpp new file mode 100644 index 0000000000..b8fcc40564 --- /dev/null +++ b/engines/testbed/graphics.cpp @@ -0,0 +1,40 @@ +#include "testbed/graphics.h" + +namespace Testbed { + +bool testFullScreenMode() { + + printf("Testing fullscreen mode\n"); + bool isFeaturePresent; + bool isFeatureEnabled; + + isFeaturePresent = g_system->hasFeature(OSystem::kFeatureFullscreenMode); + isFeatureEnabled = g_system->getFeatureState(OSystem::kFeatureFullscreenMode); + + printf("Testing Feature Presence.. \n"); + if (isFeaturePresent) { + //Toggle + printf("Supported\n"); + + g_system->beginGFXTransaction(); + g_system->setFeatureState(OSystem::kFeatureFullscreenMode, !isFeatureEnabled); + g_system->endGFXTransaction(); + + g_system->delayMillis(1000); + + g_system->beginGFXTransaction(); + g_system->setFeatureState(OSystem::kFeatureFullscreenMode, isFeatureEnabled); + g_system->endGFXTransaction(); + } + +} + +GFXTestSuite::GFXTestSuite() { + addTest("FullScreenMode", &testFullScreenMode); +} + +int execute() { + //TODO: Implement the method +} + +} -- cgit v1.2.3 From 91a8d25cea4eb44e55ac5e966b21c89bd044bc49 Mon Sep 17 00:00:00 2001 From: Neeraj Kumar Date: Wed, 2 Jun 2010 13:56:04 +0000 Subject: completed the basic testsuite class svn-id: r49392 --- engines/testbed/graphics.cpp | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) (limited to 'engines/testbed/graphics.cpp') diff --git a/engines/testbed/graphics.cpp b/engines/testbed/graphics.cpp index b8fcc40564..a2b6a8657b 100644 --- a/engines/testbed/graphics.cpp +++ b/engines/testbed/graphics.cpp @@ -27,14 +27,29 @@ bool testFullScreenMode() { g_system->endGFXTransaction(); } + return true; } GFXTestSuite::GFXTestSuite() { addTest("FullScreenMode", &testFullScreenMode); } -int execute() { - //TODO: Implement the method +GFXTestSuite::~GFXTestSuite() { + printf("Cleanup\n"); +} + +const char *GFXTestSuite::getName() { + return "GFX"; +} + +int GFXTestSuite::execute() { + //TODO: Implement the method + for (Common::Array::iterator i = _testsToExecute.begin(); i != _testsToExecute.end(); ++i) { + printf("Executing Test:%s\n", ((*i)->featureName).c_str()); + printf("Result:%d",(*i)->driver()); + } + + return 1; } } -- cgit v1.2.3 From fababbe205395b6b8c812b458df3af65e3f5e01c Mon Sep 17 00:00:00 2001 From: Neeraj Kumar Date: Thu, 3 Jun 2010 03:55:08 +0000 Subject: able to display rectangle on screen using grabPalette() and copyRectToScreen, will use it to test palettes and autocomputeDirtyRects features svn-id: r49404 --- engines/testbed/graphics.cpp | 39 ++++++++------------------------------- 1 file changed, 8 insertions(+), 31 deletions(-) (limited to 'engines/testbed/graphics.cpp') diff --git a/engines/testbed/graphics.cpp b/engines/testbed/graphics.cpp index a2b6a8657b..67176683ee 100644 --- a/engines/testbed/graphics.cpp +++ b/engines/testbed/graphics.cpp @@ -1,41 +1,17 @@ #include "testbed/graphics.h" +#include "testbed/gfxtests.h" namespace Testbed { -bool testFullScreenMode() { - - printf("Testing fullscreen mode\n"); - bool isFeaturePresent; - bool isFeatureEnabled; - - isFeaturePresent = g_system->hasFeature(OSystem::kFeatureFullscreenMode); - isFeatureEnabled = g_system->getFeatureState(OSystem::kFeatureFullscreenMode); - - printf("Testing Feature Presence.. \n"); - if (isFeaturePresent) { - //Toggle - printf("Supported\n"); - - g_system->beginGFXTransaction(); - g_system->setFeatureState(OSystem::kFeatureFullscreenMode, !isFeatureEnabled); - g_system->endGFXTransaction(); - - g_system->delayMillis(1000); - - g_system->beginGFXTransaction(); - g_system->setFeatureState(OSystem::kFeatureFullscreenMode, isFeatureEnabled); - g_system->endGFXTransaction(); - } - - return true; -} - GFXTestSuite::GFXTestSuite() { - addTest("FullScreenMode", &testFullScreenMode); + //addTest("FullScreenMode", &testFullScreenMode); + addTest("AspectRatio", &testAspectRatio); } GFXTestSuite::~GFXTestSuite() { - printf("Cleanup\n"); + for (Common::Array::iterator i = _testsToExecute.begin(); i != _testsToExecute.end(); ++i) { + delete (*i); + } } const char *GFXTestSuite::getName() { @@ -46,10 +22,11 @@ int GFXTestSuite::execute() { //TODO: Implement the method for (Common::Array::iterator i = _testsToExecute.begin(); i != _testsToExecute.end(); ++i) { printf("Executing Test:%s\n", ((*i)->featureName).c_str()); - printf("Result:%d",(*i)->driver()); + printf("Result:%d\n",(*i)->driver()); } return 1; } + } -- cgit v1.2.3 From 1819c8b23b0beac173ed61f777a3656879d020d1 Mon Sep 17 00:00:00 2001 From: Neeraj Kumar Date: Sun, 6 Jun 2010 14:06:51 +0000 Subject: polished the interface to interact with testsuites, added code to report test results svn-id: r49456 --- engines/testbed/graphics.cpp | 42 ++++++++++++++++++++++++++++++------------ 1 file changed, 30 insertions(+), 12 deletions(-) (limited to 'engines/testbed/graphics.cpp') diff --git a/engines/testbed/graphics.cpp b/engines/testbed/graphics.cpp index 67176683ee..a5658a1213 100644 --- a/engines/testbed/graphics.cpp +++ b/engines/testbed/graphics.cpp @@ -4,29 +4,47 @@ namespace Testbed { GFXTestSuite::GFXTestSuite() { - //addTest("FullScreenMode", &testFullScreenMode); + // Initialize color palettes + // Te fourth field is for alpha channel which is unused + // Assuming 8bpp as of now + _palette[0] =_palette[1] =_palette[2] = 0; + _palette[4] =_palette[5] =_palette[6] = 255; + _palette[8] =_palette[9] =_palette[10] = 255; + g_system->setPalette(_palette, 0, 3); + g_system->grabPalette(_palette, 0, 3); + + // Add tests here + addTest("FullScreenMode", &testFullScreenMode); addTest("AspectRatio", &testAspectRatio); } -GFXTestSuite::~GFXTestSuite() { - for (Common::Array::iterator i = _testsToExecute.begin(); i != _testsToExecute.end(); ++i) { - delete (*i); - } -} - const char *GFXTestSuite::getName() { return "GFX"; } -int GFXTestSuite::execute() { - //TODO: Implement the method +void GFXTestSuite::setCustomColor(uint r, uint g, uint b) { + _palette[8] = r; + _palette[9] = g; + _palette[10] = b; + g_system->setPalette(_palette, 0, 3); + g_system->grabPalette(_palette, 0, 3); +} + +void GFXTestSuite::execute() { for (Common::Array::iterator i = _testsToExecute.begin(); i != _testsToExecute.end(); ++i) { printf("Executing Test:%s\n", ((*i)->featureName).c_str()); - printf("Result:%d\n",(*i)->driver()); + // Invoke the test + (*i)->driver(); + _numTestsExecuted++; + // Verify result by Interacting with the tester. + Common::String prompt("Was this similar to what you expected?"); + if (handleInteractiveInput(prompt)) { + _numTestsPassed++; + } } - return 1; + // Report Generation + genReport(); } - } -- cgit v1.2.3 From 52cf6e4caa04f996bc7f4f78a464564db39de480 Mon Sep 17 00:00:00 2001 From: Neeraj Kumar Date: Tue, 8 Jun 2010 20:24:54 +0000 Subject: added working test for palettized cursors, tests mouse events as well svn-id: r49516 --- engines/testbed/graphics.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'engines/testbed/graphics.cpp') diff --git a/engines/testbed/graphics.cpp b/engines/testbed/graphics.cpp index ea1c1b1130..c4701982c6 100644 --- a/engines/testbed/graphics.cpp +++ b/engines/testbed/graphics.cpp @@ -13,10 +13,10 @@ GFXTestSuite::GFXTestSuite() { g_system->grabPalette(_palette, 0, 3); // Add tests here -// addTest("FullScreenMode", &testFullScreenMode); -// addTest("AspectRatio", &testAspectRatio); + addTest("FullScreenMode", &testFullScreenMode); + addTest("AspectRatio", &testAspectRatio); addTest("PalettizedCursors", &testPalettizedCursors); -// addTest("BlitBitmaps", &testCopyRectToScreen); + addTest("BlitBitmaps", &testCopyRectToScreen); } const char *GFXTestSuite::getName() { -- cgit v1.2.3 From 1032b69f51444fb48e9ba9313180e009513fa33e Mon Sep 17 00:00:00 2001 From: Neeraj Kumar Date: Thu, 10 Jun 2010 12:40:58 +0000 Subject: some minor changes in the testsuite structure, reduced no. of files per testsuite, fixed some formatting svn-id: r49571 --- engines/testbed/graphics.cpp | 189 +++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 183 insertions(+), 6 deletions(-) (limited to 'engines/testbed/graphics.cpp') diff --git a/engines/testbed/graphics.cpp b/engines/testbed/graphics.cpp index c4701982c6..5b3759f2dd 100644 --- a/engines/testbed/graphics.cpp +++ b/engines/testbed/graphics.cpp @@ -1,5 +1,11 @@ +#include "common/events.h" + #include "testbed/graphics.h" -#include "testbed/gfxtests.h" +#include "testbed/testsuite.h" + +#include "graphics/cursorman.h" +#include "graphics/fontman.h" +#include "graphics/surface.h" namespace Testbed { @@ -7,16 +13,16 @@ byte GFXTestSuite::_palette[3 * 4] = {0, 0, 0, 0, 255, 255, 255, 0, 255, 255, 25 GFXTestSuite::GFXTestSuite() { // Initialize color palettes - // Te fourth field is for alpha channel which is unused + // The fourth field is for alpha channel which is unused // Assuming 8bpp as of now g_system->setPalette(_palette, 0, 3); g_system->grabPalette(_palette, 0, 3); // Add tests here - addTest("FullScreenMode", &testFullScreenMode); - addTest("AspectRatio", &testAspectRatio); - addTest("PalettizedCursors", &testPalettizedCursors); - addTest("BlitBitmaps", &testCopyRectToScreen); + addTest("FullScreenMode", &GFXtests::fullScreenMode); + addTest("AspectRatio", &GFXtests::aspectRatio); + addTest("PalettizedCursors", &GFXtests::palettizedCursors); + addTest("BlitBitmaps", &GFXtests::copyRectToScreen); } const char *GFXTestSuite::getName() { @@ -48,4 +54,175 @@ void GFXTestSuite::execute() { genReport(); } +// GFXtests go here + +bool GFXtests::fullScreenMode() { + + Testsuite::displayMessage("Testing fullscreen mode. \n \ + If the feature is supported by the backend, you should expect to see a toggle between fullscreen and normal modes"); + + Common::Point pt(0,100); + Common::Rect rect = Testsuite::writeOnScreen("Testing fullscreen mode", pt); + + bool isFeaturePresent; + bool isFeatureEnabled; + + isFeaturePresent = g_system->hasFeature(OSystem::kFeatureFullscreenMode); + isFeatureEnabled = g_system->getFeatureState(OSystem::kFeatureFullscreenMode); + g_system->delayMillis(1000); + + if (isFeaturePresent) { + // Toggle + + g_system->beginGFXTransaction(); + g_system->setFeatureState(OSystem::kFeatureFullscreenMode, !isFeatureEnabled); + g_system->endGFXTransaction(); + + g_system->delayMillis(1000); + + g_system->beginGFXTransaction(); + g_system->setFeatureState(OSystem::kFeatureFullscreenMode, isFeatureEnabled); + g_system->endGFXTransaction(); + } + else { + Testsuite::displayMessage("feature not supported"); + } + + Testsuite::clearScreen(rect); + return true; +} + +bool GFXtests::aspectRatio() { + Testsuite::displayMessage("Testing Aspect Ratio Correction.\n" + "With this feature enabled games running at 320x200 should be scaled upto 320x240 pixels"); + + Common::Point pt(0,100); + Common::Rect rect = Testsuite::writeOnScreen("Testing Aspect ratio correction", pt); + + bool isFeaturePresent; + bool isFeatureEnabled; + + isFeaturePresent = g_system->hasFeature(OSystem::kFeatureAspectRatioCorrection); + isFeatureEnabled = g_system->getFeatureState(OSystem::kFeatureAspectRatioCorrection); + g_system->delayMillis(1000); + + if (isFeaturePresent) { + // Toggle + + g_system->beginGFXTransaction(); + g_system->setFeatureState(OSystem::kFeatureAspectRatioCorrection, !isFeatureEnabled); + g_system->endGFXTransaction(); + + g_system->delayMillis(1000); + + g_system->beginGFXTransaction(); + g_system->setFeatureState(OSystem::kFeatureAspectRatioCorrection, isFeatureEnabled); + g_system->endGFXTransaction(); + } + else { + Testsuite::displayMessage("feature not supported"); + } + + Testsuite::clearScreen(rect); + return true; +} + +bool GFXtests::palettizedCursors() { + Testsuite::displayMessage("Testing Cursors. You should expect to see a yellow colored square cursor.\n" + "You should be able to move it. The test finishes when the mouse(L/R) is clicked"); + + Common::Point pt(0, 100); + Common::Rect rect = Testsuite::writeOnScreen("Testing Palettized Cursors", pt); + + bool isFeaturePresent; + bool isFeatureEnabled; + + isFeaturePresent = g_system->hasFeature(OSystem::kFeatureCursorHasPalette); + isFeatureEnabled = g_system->getFeatureState(OSystem::kFeatureCursorHasPalette); + + if (isFeaturePresent) { + byte palette[3 * 4]; // Black, white and yellow + palette[0] = palette[1] = palette[2] = 0; + palette[4] = palette[5] = palette[6] = 255; + palette[8] = palette[9] = 255; + palette[10] = 0; + + byte buffer[10 * 10]; + memset(buffer, 2, 10 * 10); + + CursorMan.pushCursorPalette(palette, 0, 3); + CursorMan.pushCursor(buffer, 10, 10, 45, 45, 1); + CursorMan.showMouse(true); + + Common::EventManager *eventMan = g_system->getEventManager(); + Common::Event event; + + bool quitLoop = false; + uint32 lastRedraw = 0; + const uint32 waitTime = 1000 / 45; + + while (!quitLoop) { + while (eventMan->pollEvent(event)) { + + if (lastRedraw + waitTime < g_system->getMillis()) { + g_system->updateScreen(); + lastRedraw = g_system->getMillis(); + } + + switch (event.type) { + case Common::EVENT_MOUSEMOVE: + printf("Mouse Move\n"); + break; + case Common::EVENT_LBUTTONDOWN: + case Common::EVENT_RBUTTONDOWN: + Testsuite::clearScreen(rect); + Testsuite::writeOnScreen("Mouse Clicked", pt); + printf("Mouse Clicked\n"); + g_system->delayMillis(1000); + quitLoop = true; + CursorMan.popCursorPalette(); + CursorMan.popCursor(); + Testsuite::clearScreen(rect); + Testsuite::writeOnScreen("TestFinished", pt); + g_system->delayMillis(1000); + break; + default: + ;// Ignore any other event + + } + } + } + } else { + Testsuite::displayMessage("feature not supported"); + } + Testsuite::clearScreen(rect); + return true; +} + +bool GFXtests::mouseMovements() { + return true; +} + +bool GFXtests::copyRectToScreen() { + Testsuite::displayMessage("Testing Blitting a Bitmap to screen.\n" + "You should expect to see a 20x40 yellow horizontal rectangle centred at the screen."); + + GFXTestSuite::setCustomColor(255, 255, 0); + byte buffer[20 * 40]; + memset(buffer, 2, 20 * 40); + + uint x = g_system->getWidth() / 2 - 20; + uint y = g_system->getHeight() / 2 - 10; + + g_system->copyRectToScreen(buffer, 40, x, y, 40, 20); + g_system->updateScreen(); + g_system->delayMillis(1000); + + Common::Rect rect(x, y, x+40, y+20); + Testsuite::clearScreen(rect); + + return true; + +} + } -- cgit v1.2.3 From b9ea841b8afd346c8737a14816db2144d68457f1 Mon Sep 17 00:00:00 2001 From: Neeraj Kumar Date: Fri, 11 Jun 2010 10:44:32 +0000 Subject: added code for ellipse drawing (Aspect ratio correction), fixed some more formatting svn-id: r49593 --- engines/testbed/graphics.cpp | 59 ++++++++++++++++++++++++++++++++++++++------ 1 file changed, 52 insertions(+), 7 deletions(-) (limited to 'engines/testbed/graphics.cpp') diff --git a/engines/testbed/graphics.cpp b/engines/testbed/graphics.cpp index 5b3759f2dd..4fb238a1c1 100644 --- a/engines/testbed/graphics.cpp +++ b/engines/testbed/graphics.cpp @@ -19,10 +19,10 @@ GFXTestSuite::GFXTestSuite() { g_system->grabPalette(_palette, 0, 3); // Add tests here - addTest("FullScreenMode", &GFXtests::fullScreenMode); + // addTest("FullScreenMode", &GFXtests::fullScreenMode); addTest("AspectRatio", &GFXtests::aspectRatio); - addTest("PalettizedCursors", &GFXtests::palettizedCursors); - addTest("BlitBitmaps", &GFXtests::copyRectToScreen); + // addTest("PalettizedCursors", &GFXtests::palettizedCursors); + // addTest("BlitBitmaps", &GFXtests::copyRectToScreen); } const char *GFXTestSuite::getName() { @@ -56,12 +56,54 @@ void GFXTestSuite::execute() { // GFXtests go here +void drawEllipse(int cx, int cy, int a, int b) { + byte buffer[100][100] = {0}; + int shift = 25; + // Assume a rectangle of 50x50 + // horizontal axis = y-axis + // vertical axis = x-axis + // The centre is (shift, shift). As of now assume it to be (0, 0) + // and when done shift it to (shift, shift) + float theta; + int x, y, x1, y1; + + for (theta = 0; theta <= PI / 2; theta += PI / 90 ) { + x = (int)(b * sin(theta) + 0.5); + y = (int)(a * cos(theta) + 0.5); + + // This gives us four points + + x1 = x + shift; + y1 = y + shift; + + buffer[x1][y1] = 1; + + x1 = (-1) * x + shift; + y1 = y + shift; + + buffer[x1][y1] = 1; + + x1 = x + shift; + y1 = (-1) * y + shift; + + buffer[x1][y1] = 1; + + x1 = (-1) * x + shift; + y1 = (-1) * y + shift; + + buffer[x1][y1] = 1; + } + + g_system->copyRectToScreen(&buffer[0][0], 100, cx, cy, 100, 100); + g_system->updateScreen(); +} + bool GFXtests::fullScreenMode() { - Testsuite::displayMessage("Testing fullscreen mode. \n \ - If the feature is supported by the backend, you should expect to see a toggle between fullscreen and normal modes"); + Testsuite::displayMessage("Testing fullscreen mode.\n" + "If the feature is supported by the backend, you should expect to see a toggle between fullscreen and normal modes"); - Common::Point pt(0,100); + Common::Point pt(0, 100); Common::Rect rect = Testsuite::writeOnScreen("Testing fullscreen mode", pt); bool isFeaturePresent; @@ -95,8 +137,11 @@ bool GFXtests::fullScreenMode() { bool GFXtests::aspectRatio() { Testsuite::displayMessage("Testing Aspect Ratio Correction.\n" "With this feature enabled games running at 320x200 should be scaled upto 320x240 pixels"); + + // Draw an ellipse + drawEllipse(25, 25, 24, 20); - Common::Point pt(0,100); + Common::Point pt(0, 100); Common::Rect rect = Testsuite::writeOnScreen("Testing Aspect ratio correction", pt); bool isFeaturePresent; -- cgit v1.2.3 From 12b591ed4619330adc430f61193cc1caaca702bd Mon Sep 17 00:00:00 2001 From: Neeraj Kumar Date: Sun, 13 Jun 2010 07:49:36 +0000 Subject: improved aspect ratio correction and cursor tests, added test for iconifying and testing mouse movements svn-id: r49624 --- engines/testbed/graphics.cpp | 168 +++++++++++++++++++++++++++++++++---------- 1 file changed, 131 insertions(+), 37 deletions(-) (limited to 'engines/testbed/graphics.cpp') diff --git a/engines/testbed/graphics.cpp b/engines/testbed/graphics.cpp index 4fb238a1c1..82735bca5d 100644 --- a/engines/testbed/graphics.cpp +++ b/engines/testbed/graphics.cpp @@ -6,6 +6,7 @@ #include "graphics/cursorman.h" #include "graphics/fontman.h" #include "graphics/surface.h" +#include "graphics/VectorRendererSpec.h" namespace Testbed { @@ -19,10 +20,11 @@ GFXTestSuite::GFXTestSuite() { g_system->grabPalette(_palette, 0, 3); // Add tests here - // addTest("FullScreenMode", &GFXtests::fullScreenMode); + addTest("FullScreenMode", &GFXtests::fullScreenMode); addTest("AspectRatio", &GFXtests::aspectRatio); - // addTest("PalettizedCursors", &GFXtests::palettizedCursors); - // addTest("BlitBitmaps", &GFXtests::copyRectToScreen); + addTest("PalettizedCursors", &GFXtests::palettizedCursors); + addTest("BlitBitmaps", &GFXtests::copyRectToScreen); + addTest("IconifyingWindow", &GFXtests::iconifyWindow); } const char *GFXTestSuite::getName() { @@ -56,51 +58,61 @@ void GFXTestSuite::execute() { // GFXtests go here -void drawEllipse(int cx, int cy, int a, int b) { - byte buffer[100][100] = {0}; - int shift = 25; - // Assume a rectangle of 50x50 - // horizontal axis = y-axis - // vertical axis = x-axis - // The centre is (shift, shift). As of now assume it to be (0, 0) - // and when done shift it to (shift, shift) +/** + * Used by aspectRatio() + */ + +void GFXtests::drawEllipse(int cx, int cy, int a, int b) { + + // top-left coordinates of rectangle enclosing the eclipse (cx - a, cy - a) + // length = width = 2a + // size of buffer = 4 * a * a + + byte buffer[200][320] = {{0}}; float theta; int x, y, x1, y1; - for (theta = 0; theta <= PI / 2; theta += PI / 90 ) { + // Illuminate the center + buffer[cx][cy] = 1; + + for (theta = 0; theta <= PI / 2; theta += PI / 360 ) { x = (int)(b * sin(theta) + 0.5); y = (int)(a * cos(theta) + 0.5); // This gives us four points - x1 = x + shift; - y1 = y + shift; + x1 = x + cx; + y1 = y + cy; buffer[x1][y1] = 1; - x1 = (-1) * x + shift; - y1 = y + shift; + x1 = (-1) * x + cx; + y1 = y + cy; buffer[x1][y1] = 1; - x1 = x + shift; - y1 = (-1) * y + shift; + x1 = x + cx; + y1 = (-1) * y + cy; buffer[x1][y1] = 1; - x1 = (-1) * x + shift; - y1 = (-1) * y + shift; + x1 = (-1) * x + cx; + y1 = (-1) * y + cy; buffer[x1][y1] = 1; } - g_system->copyRectToScreen(&buffer[0][0], 100, cx, cy, 100, 100); + g_system->copyRectToScreen(&buffer[0][0], 320, 0, 0, 320, 200); g_system->updateScreen(); } -bool GFXtests::fullScreenMode() { +/** + * Tests the fullscreen mode by: toggling between fullscreen and windowed mode + */ - Testsuite::displayMessage("Testing fullscreen mode.\n" +bool GFXtests::fullScreenMode() { + + Testsuite::displayMessage("Testing fullscreen mode.\n" "If the feature is supported by the backend, you should expect to see a toggle between fullscreen and normal modes"); Common::Point pt(0, 100); @@ -125,8 +137,7 @@ bool GFXtests::fullScreenMode() { g_system->beginGFXTransaction(); g_system->setFeatureState(OSystem::kFeatureFullscreenMode, isFeatureEnabled); g_system->endGFXTransaction(); - } - else { + } else { Testsuite::displayMessage("feature not supported"); } @@ -134,15 +145,20 @@ bool GFXtests::fullScreenMode() { return true; } +/** + * Tests the aspect ratio correction by: drawing an ellipse, when corrected the ellipse should render to a circle + */ + bool GFXtests::aspectRatio() { Testsuite::displayMessage("Testing Aspect Ratio Correction.\n" "With this feature enabled games running at 320x200 should be scaled upto 320x240 pixels"); - // Draw an ellipse - drawEllipse(25, 25, 24, 20); + // Draw a circle on the screen - Common::Point pt(0, 100); - Common::Rect rect = Testsuite::writeOnScreen("Testing Aspect ratio correction", pt); + drawEllipse(100, 160, 72, 60); + + Common::Point pt(0, 180); + Testsuite::writeOnScreen("when corrected, it should be a circle!", pt); bool isFeaturePresent; bool isFeatureEnabled; @@ -163,15 +179,20 @@ bool GFXtests::aspectRatio() { g_system->beginGFXTransaction(); g_system->setFeatureState(OSystem::kFeatureAspectRatioCorrection, isFeatureEnabled); g_system->endGFXTransaction(); - } - else { + } else { Testsuite::displayMessage("feature not supported"); } - Testsuite::clearScreen(rect); + g_system->delayMillis(500); + Testsuite::clearScreen(); return true; } +/** + * Tests Palettized cursors. + * Method: Create a yellow colored cursor, should be able to move it. Once you click test terminates + */ + bool GFXtests::palettizedCursors() { Testsuite::displayMessage("Testing Cursors. You should expect to see a yellow colored square cursor.\n" "You should be able to move it. The test finishes when the mouse(L/R) is clicked"); @@ -192,11 +213,17 @@ bool GFXtests::palettizedCursors() { palette[8] = palette[9] = 255; palette[10] = 0; - byte buffer[10 * 10]; - memset(buffer, 2, 10 * 10); + byte buffer[10][10]; + memset(&buffer[0][0], 2, 10 * 10); + + // Mark the hotspot + for (int i = 0; i < 10; i++) { + buffer[i][i] = 0; + buffer[9 - i][i] = 0; + } CursorMan.pushCursorPalette(palette, 0, 3); - CursorMan.pushCursor(buffer, 10, 10, 45, 45, 1); + CursorMan.pushCursor(&buffer[0][0], 10, 10, 5, 5, 1); CursorMan.showMouse(true); Common::EventManager *eventMan = g_system->getEventManager(); @@ -225,8 +252,6 @@ bool GFXtests::palettizedCursors() { printf("Mouse Clicked\n"); g_system->delayMillis(1000); quitLoop = true; - CursorMan.popCursorPalette(); - CursorMan.popCursor(); Testsuite::clearScreen(rect); Testsuite::writeOnScreen("TestFinished", pt); g_system->delayMillis(1000); @@ -241,13 +266,44 @@ bool GFXtests::palettizedCursors() { Testsuite::displayMessage("feature not supported"); } Testsuite::clearScreen(rect); + + // Testing Mouse Movements now! + + Testsuite::writeOnScreen("Moving mouse automatically from (0, 0) to (100, 100)", pt); + g_system->warpMouse(0, 0); + g_system->updateScreen(); + g_system->delayMillis(1000); + + for (int i = 0; i <= 100; i++) { + g_system->delayMillis(20); + g_system->warpMouse(i, i); + g_system->updateScreen(); + } + + Testsuite::clearScreen(); + Testsuite::writeOnScreen("Mouse Moved to (100, 100)", pt); + g_system->delayMillis(1500); + // Popping cursor + CursorMan.popCursorPalette(); + CursorMan.popCursor(); + + Testsuite::clearScreen(); return true; } +/** + * Tests Mouse Movements. + * Currently plan to implement an automove along a diagonal to the mid point. + */ + bool GFXtests::mouseMovements() { return true; } +/** + * This basically blits the screen by the contents of its buffer. + * + */ bool GFXtests::copyRectToScreen() { Testsuite::displayMessage("Testing Blitting a Bitmap to screen.\n" "You should expect to see a 20x40 yellow horizontal rectangle centred at the screen."); @@ -270,4 +326,42 @@ bool GFXtests::copyRectToScreen() { } +/** + * Testing feature : Iconifying window + * It is expected the screen minimizes when this feature is enabled + */ +bool GFXtests::iconifyWindow() { + + Testsuite::displayMessage("Testing Iconify Window mode.\n" + "If the feature is supported by the backend, you should expect to see a toggle between minimized and normal states"); + + Common::Point pt(0, 100); + Common::Rect rect = Testsuite::writeOnScreen("Testing Iconifying window", pt); + + bool isFeaturePresent; + bool isFeatureEnabled; + + isFeaturePresent = g_system->hasFeature(OSystem::kFeatureIconifyWindow); + isFeatureEnabled = g_system->getFeatureState(OSystem::kFeatureIconifyWindow); + g_system->delayMillis(1000); + + if (isFeaturePresent) { + // Toggle + + g_system->beginGFXTransaction(); + g_system->setFeatureState(OSystem::kFeatureIconifyWindow, !isFeatureEnabled); + g_system->endGFXTransaction(); + + g_system->delayMillis(1000); + + g_system->beginGFXTransaction(); + g_system->setFeatureState(OSystem::kFeatureIconifyWindow, isFeatureEnabled); + g_system->endGFXTransaction(); + } else { + Testsuite::displayMessage("feature not supported"); + } + + Testsuite::clearScreen(rect); + return true; +} } -- cgit v1.2.3 From 0bd7bf32cac760c59e2a7a140b8ee46a795465ce Mon Sep 17 00:00:00 2001 From: Neeraj Kumar Date: Sun, 13 Jun 2010 07:55:50 +0000 Subject: removed obsolete comments svn-id: r49625 --- engines/testbed/graphics.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'engines/testbed/graphics.cpp') diff --git a/engines/testbed/graphics.cpp b/engines/testbed/graphics.cpp index 82735bca5d..229c06c9ac 100644 --- a/engines/testbed/graphics.cpp +++ b/engines/testbed/graphics.cpp @@ -64,10 +64,8 @@ void GFXTestSuite::execute() { void GFXtests::drawEllipse(int cx, int cy, int a, int b) { - // top-left coordinates of rectangle enclosing the eclipse (cx - a, cy - a) - // length = width = 2a - // size of buffer = 4 * a * a - + // Take a buffer of screen size + byte buffer[200][320] = {{0}}; float theta; int x, y, x1, y1; @@ -75,6 +73,8 @@ void GFXtests::drawEllipse(int cx, int cy, int a, int b) { // Illuminate the center buffer[cx][cy] = 1; + // Illuminate the points lying on ellipse + for (theta = 0; theta <= PI / 2; theta += PI / 360 ) { x = (int)(b * sin(theta) + 0.5); y = (int)(a * cos(theta) + 0.5); @@ -153,7 +153,7 @@ bool GFXtests::aspectRatio() { Testsuite::displayMessage("Testing Aspect Ratio Correction.\n" "With this feature enabled games running at 320x200 should be scaled upto 320x240 pixels"); - // Draw a circle on the screen + // Draw an ellipse on the screen drawEllipse(100, 160, 72, 60); -- cgit v1.2.3 From 3c511eab1a3c9e3be7125a6159265e0f5e25beed Mon Sep 17 00:00:00 2001 From: Neeraj Kumar Date: Sun, 13 Jun 2010 19:19:06 +0000 Subject: added code for testing shake, focus, overlay, scaling, need to fix more some of these although svn-id: r49634 --- engines/testbed/graphics.cpp | 195 +++++++++++++++++++++++++++++++++++-------- 1 file changed, 159 insertions(+), 36 deletions(-) (limited to 'engines/testbed/graphics.cpp') diff --git a/engines/testbed/graphics.cpp b/engines/testbed/graphics.cpp index 229c06c9ac..2f42e98fa1 100644 --- a/engines/testbed/graphics.cpp +++ b/engines/testbed/graphics.cpp @@ -20,14 +20,23 @@ GFXTestSuite::GFXTestSuite() { g_system->grabPalette(_palette, 0, 3); // Add tests here + // TODO: Can do it without transactions? addTest("FullScreenMode", &GFXtests::fullScreenMode); addTest("AspectRatio", &GFXtests::aspectRatio); addTest("PalettizedCursors", &GFXtests::palettizedCursors); addTest("BlitBitmaps", &GFXtests::copyRectToScreen); + // TODO: doesn't returns back to normal states addTest("IconifyingWindow", &GFXtests::iconifyWindow); + // TODO: need to fix it + // addTest("ScaledCursors", &GFXtests::scaledCursors); + addTest("shakingEffect", &GFXtests::shakingEffect); + // TODO: unable to notice any change, make it noticable + addTest("focusRectangle", &GFXtests::focusRectangle); + // TODO: unable to notice any change, make it noticable + addTest("Overlays", &GFXtests::overlayGraphics); } -const char *GFXTestSuite::getName() { +const char *GFXTestSuite::getName() const { return "GFX"; } @@ -56,7 +65,42 @@ void GFXTestSuite::execute() { genReport(); } -// GFXtests go here +// Helper functions used by GFX tests + +void GFXtests::drawCursor(const char *gfxModeName, int cursorTargetScale) { + + byte palette[3 * 4]; // Black, white and yellow + palette[0] = palette[1] = palette[2] = 0; + palette[4] = palette[5] = palette[6] = 255; + palette[8] = palette[9] = 255; + palette[10] = 0; + + byte buffer[10][10]; + memset(&buffer[0][0], 2, 10 * 10); + + // Mark the hotspot + for (int i = 0; i < 10; i++) { + buffer[i][i] = 0; + buffer[9 - i][i] = 0; + } + + CursorMan.pushCursorPalette(palette, 0, 3); + CursorMan.pushCursor(&buffer[0][0], 10, 10, 5, 5, cursorTargetScale); + CursorMan.showMouse(true); + g_system->updateScreen(); + + if (gfxModeName) { + Common::Point pt(0, 100); + char scaleFactor[10]; + snprintf(scaleFactor, 10, "%dx", cursorTargetScale); + Common::String info = "GFX Mode:"; + info = info + gfxModeName + " Cursor scaled by:" + scaleFactor; + Testsuite::clearScreen(); + Testsuite::writeOnScreen(info, pt); + } + +} + /** * Used by aspectRatio() @@ -106,6 +150,8 @@ void GFXtests::drawEllipse(int cx, int cy, int a, int b) { g_system->updateScreen(); } +// GFXtests go here + /** * Tests the fullscreen mode by: toggling between fullscreen and windowed mode */ @@ -198,7 +244,6 @@ bool GFXtests::palettizedCursors() { "You should be able to move it. The test finishes when the mouse(L/R) is clicked"); Common::Point pt(0, 100); - Common::Rect rect = Testsuite::writeOnScreen("Testing Palettized Cursors", pt); bool isFeaturePresent; bool isFeatureEnabled; @@ -207,25 +252,10 @@ bool GFXtests::palettizedCursors() { isFeatureEnabled = g_system->getFeatureState(OSystem::kFeatureCursorHasPalette); if (isFeaturePresent) { - byte palette[3 * 4]; // Black, white and yellow - palette[0] = palette[1] = palette[2] = 0; - palette[4] = palette[5] = palette[6] = 255; - palette[8] = palette[9] = 255; - palette[10] = 0; + GFXtests::drawCursor(); - byte buffer[10][10]; - memset(&buffer[0][0], 2, 10 * 10); - - // Mark the hotspot - for (int i = 0; i < 10; i++) { - buffer[i][i] = 0; - buffer[9 - i][i] = 0; - } + Testsuite::writeOnScreen("Testing Palettized Cursors", pt); - CursorMan.pushCursorPalette(palette, 0, 3); - CursorMan.pushCursor(&buffer[0][0], 10, 10, 5, 5, 1); - CursorMan.showMouse(true); - Common::EventManager *eventMan = g_system->getEventManager(); Common::Event event; @@ -236,23 +266,23 @@ bool GFXtests::palettizedCursors() { while (!quitLoop) { while (eventMan->pollEvent(event)) { - if (lastRedraw + waitTime < g_system->getMillis()) { - g_system->updateScreen(); - lastRedraw = g_system->getMillis(); - } + if (lastRedraw + waitTime < g_system->getMillis()) { + g_system->updateScreen(); + lastRedraw = g_system->getMillis(); + } switch (event.type) { - case Common::EVENT_MOUSEMOVE: + case Common::EVENT_MOUSEMOVE: printf("Mouse Move\n"); break; case Common::EVENT_LBUTTONDOWN: case Common::EVENT_RBUTTONDOWN: - Testsuite::clearScreen(rect); + Testsuite::clearScreen(); Testsuite::writeOnScreen("Mouse Clicked", pt); printf("Mouse Clicked\n"); g_system->delayMillis(1000); quitLoop = true; - Testsuite::clearScreen(rect); + Testsuite::clearScreen(); Testsuite::writeOnScreen("TestFinished", pt); g_system->delayMillis(1000); break; @@ -265,7 +295,7 @@ bool GFXtests::palettizedCursors() { } else { Testsuite::displayMessage("feature not supported"); } - Testsuite::clearScreen(rect); + Testsuite::clearScreen(); // Testing Mouse Movements now! @@ -291,14 +321,6 @@ bool GFXtests::palettizedCursors() { return true; } -/** - * Tests Mouse Movements. - * Currently plan to implement an automove along a diagonal to the mid point. - */ - -bool GFXtests::mouseMovements() { - return true; -} /** * This basically blits the screen by the contents of its buffer. @@ -364,4 +386,105 @@ bool GFXtests::iconifyWindow() { Testsuite::clearScreen(rect); return true; } + +/** + * Testing feature: Scaled cursors + */ + +bool GFXtests::scaledCursors() { + + // TODO : Understand and fix the problem relating scaled cursors + + const OSystem::GraphicsMode *gfxMode = g_system->getSupportedGraphicsModes(); + + while (gfxMode->name) { + // for every graphics mode display cursors for cursorTargetScale 1, 2 and 3 + // Switch Graphics mode + g_system->warpMouse(80, 160); + + //if (g_system->setGraphicsMode(gfxMode->id)) { + if (1) { + drawCursor(gfxMode->name, 1); + g_system->delayMillis(5000); + drawCursor(gfxMode->name, 2); + g_system->delayMillis(5000); + drawCursor(gfxMode->name, 3); + g_system->delayMillis(5000); + } else { + printf("Switching to graphics mode %s failed\n", gfxMode->name); + } + CursorMan.popAllCursors(); + gfxMode++; + } + + return true; +} + +bool GFXtests::shakingEffect() { + Common::Point pt(0, 100); + Testsuite::writeOnScreen("Does this shakes!!?", pt); + int times = 25; + while (times--) { + g_system->setShakePos(10); + g_system->updateScreen(); + g_system->setShakePos(0); + g_system->updateScreen(); + } + g_system->delayMillis(500); + Testsuite::clearScreen(); + return true; +} + +bool GFXtests::focusRectangle() { + Testsuite::clearScreen(); + + const Graphics::Font &font(*FontMan.getFontByUsage(Graphics::FontManager::kConsoleFont)); + + Graphics::Surface *screen = g_system->lockScreen(); + int screenHeight = g_system->getHeight(); + int screenWidth = g_system->getWidth(); + + int height = font.getFontHeight(); + int width = screenWidth / 2; + + Common::Rect rectLeft(0, 0, width, height * 2); + screen->fillRect(rectLeft, kColorWhite); + font.drawString(screen, "Focus 1", rectLeft.left, rectLeft.top, width, kColorBlack, Graphics::kTextAlignLeft); + + Common::Rect rectRight(screenWidth - width, screenHeight - height * 2 , screenWidth, screenHeight); + screen->fillRect(rectRight, kColorWhite); + font.drawString(screen, "Focus 2", rectRight.left, rectRight.top, width, kColorBlack, Graphics::kTextAlignRight); + g_system->unlockScreen(); + g_system->updateScreen(); + + g_system->setFocusRectangle(rectLeft); + g_system->updateScreen(); + + g_system->delayMillis(1000); + + g_system->setFocusRectangle(rectRight); + g_system->updateScreen(); + + return true; +} + +bool GFXtests::overlayGraphics() { + Graphics::PixelFormat pf = g_system->getOverlayFormat(); + + GFXTestSuite::setCustomColor(255, 255, 0); + OverlayColor buffer[20 * 40]; + memset(buffer, 2, 20 * 40); + + int x = g_system->getWidth() / 2 - 20; + int y = g_system->getHeight() / 2 - 10; + + g_system->copyRectToOverlay(buffer, 40, x, y, 40, 20); + g_system->showOverlay(); + g_system->updateScreen(); + g_system->delayMillis(1000); + g_system->hideOverlay(); + + return true; +} + } -- cgit v1.2.3 From af60633d6873f4071fcae95c6b5681c9b27ee6a4 Mon Sep 17 00:00:00 2001 From: Neeraj Kumar Date: Mon, 14 Jun 2010 20:15:15 +0000 Subject: added some features suggested by jordi, needs more work although svn-id: r49668 --- engines/testbed/graphics.cpp | 125 ++++++++++++++++++++++++++++++------------- 1 file changed, 88 insertions(+), 37 deletions(-) (limited to 'engines/testbed/graphics.cpp') diff --git a/engines/testbed/graphics.cpp b/engines/testbed/graphics.cpp index 2f42e98fa1..734d35cd67 100644 --- a/engines/testbed/graphics.cpp +++ b/engines/testbed/graphics.cpp @@ -48,23 +48,6 @@ void GFXTestSuite::setCustomColor(uint r, uint g, uint b) { g_system->grabPalette(_palette, 0, 3); } -void GFXTestSuite::execute() { - for (Common::Array::iterator i = _testsToExecute.begin(); i != _testsToExecute.end(); ++i) { - printf("Executing Test:%s\n", ((*i)->featureName).c_str()); - // Invoke the test - (*i)->driver(); - _numTestsExecuted++; - // Verify result by Interacting with the tester. - Common::String prompt("Was this similar to what you expected?"); - if (handleInteractiveInput(prompt)) { - _numTestsPassed++; - } - } - - // Report Generation - genReport(); -} - // Helper functions used by GFX tests void GFXtests::drawCursor(const char *gfxModeName, int cursorTargetScale) { @@ -84,7 +67,7 @@ void GFXtests::drawCursor(const char *gfxModeName, int cursorTargetScale) { buffer[9 - i][i] = 0; } - CursorMan.pushCursorPalette(palette, 0, 3); + CursorMan.replaceCursorPalette(palette, 0, 3); CursorMan.pushCursor(&buffer[0][0], 10, 10, 5, 5, cursorTargetScale); CursorMan.showMouse(true); g_system->updateScreen(); @@ -158,37 +141,72 @@ void GFXtests::drawEllipse(int cx, int cy, int a, int b) { bool GFXtests::fullScreenMode() { - Testsuite::displayMessage("Testing fullscreen mode.\n" - "If the feature is supported by the backend, you should expect to see a toggle between fullscreen and normal modes"); - Common::Point pt(0, 100); Common::Rect rect = Testsuite::writeOnScreen("Testing fullscreen mode", pt); bool isFeaturePresent; bool isFeatureEnabled; + bool passed = true; + Common::String prompt; + OptionSelected shouldSelect; isFeaturePresent = g_system->hasFeature(OSystem::kFeatureFullscreenMode); - isFeatureEnabled = g_system->getFeatureState(OSystem::kFeatureFullscreenMode); - g_system->delayMillis(1000); if (isFeaturePresent) { // Toggle + isFeatureEnabled = g_system->getFeatureState(OSystem::kFeatureFullscreenMode); + shouldSelect = isFeatureEnabled ? kOptionLeft : kOptionRight; + + if (isFeatureEnabled) { + printf("LOG: Current Mode is Fullsecreen\n"); + } else { + printf("LOG: Current Mode is Windowed\n"); + } + + prompt = " Which mode do you see currently ? "; + + if (!Testsuite::handleInteractiveInput(prompt, "Fullscreen", "Windowed", shouldSelect)) { + // User selected incorrect current state + passed = false; + printf("LOG: g_system->getFeatureState() failed\n"); + } g_system->beginGFXTransaction(); g_system->setFeatureState(OSystem::kFeatureFullscreenMode, !isFeatureEnabled); g_system->endGFXTransaction(); + // Current state should be now !isFeatureEnabled + isFeatureEnabled = g_system->getFeatureState(OSystem::kFeatureFullscreenMode); + shouldSelect = isFeatureEnabled ? kOptionLeft : kOptionRight; + g_system->delayMillis(1000); + prompt = " Which mode do you see now ? "; + + if (!Testsuite::handleInteractiveInput(prompt, "Fullscreen", "Windowed", shouldSelect)) { + // User selected incorrect mode + passed = false; + printf("LOG: g_system->setFeatureState() failed\n"); + } + g_system->beginGFXTransaction(); - g_system->setFeatureState(OSystem::kFeatureFullscreenMode, isFeatureEnabled); + g_system->setFeatureState(OSystem::kFeatureFullscreenMode, !isFeatureEnabled); g_system->endGFXTransaction(); + + prompt = "This should be your initial state.Is it?"; + + if (!Testsuite::handleInteractiveInput(prompt, "Yes, it is", "Nopes", shouldSelect)) { + // User selected incorrect mode + printf("LOG: switching back to initial state failed\n"); + passed = false; + } + } else { Testsuite::displayMessage("feature not supported"); } - Testsuite::clearScreen(rect); - return true; + Testsuite::clearScreen(); + return passed; } /** @@ -196,18 +214,18 @@ bool GFXtests::fullScreenMode() { */ bool GFXtests::aspectRatio() { - Testsuite::displayMessage("Testing Aspect Ratio Correction.\n" - "With this feature enabled games running at 320x200 should be scaled upto 320x240 pixels"); - // Draw an ellipse on the screen drawEllipse(100, 160, 72, 60); Common::Point pt(0, 180); - Testsuite::writeOnScreen("when corrected, it should be a circle!", pt); + Testsuite::writeOnScreen("Testing Aspect Ratio Correction!", pt); bool isFeaturePresent; bool isFeatureEnabled; + bool passed; + Common::String prompt; + OptionSelected shouldSelect; isFeaturePresent = g_system->hasFeature(OSystem::kFeatureAspectRatioCorrection); isFeatureEnabled = g_system->getFeatureState(OSystem::kFeatureAspectRatioCorrection); @@ -215,13 +233,28 @@ bool GFXtests::aspectRatio() { if (isFeaturePresent) { // Toggle - + shouldSelect = isFeatureEnabled ? kOptionLeft : kOptionRight; + prompt = " What does the curve on screen appears to you ?"; + if (!Testsuite::handleInteractiveInput(prompt, "Circle", "Ellipse", shouldSelect)) { + // User selected incorrect option + passed = false; + printf("LOG: Aspect Ratio Correction failed\n"); + } + g_system->beginGFXTransaction(); g_system->setFeatureState(OSystem::kFeatureAspectRatioCorrection, !isFeatureEnabled); g_system->endGFXTransaction(); - + g_system->delayMillis(1000); + shouldSelect = !isFeatureEnabled ? kOptionLeft : kOptionRight; + prompt = " What does the curve on screen appears to you ?"; + if (!Testsuite::handleInteractiveInput(prompt, "Circle", "Ellipse", shouldSelect)) { + // User selected incorrect option + passed = false; + printf("LOG: Aspect Ratio Correction failed\n"); + } + g_system->beginGFXTransaction(); g_system->setFeatureState(OSystem::kFeatureAspectRatioCorrection, isFeatureEnabled); g_system->endGFXTransaction(); @@ -231,7 +264,7 @@ bool GFXtests::aspectRatio() { g_system->delayMillis(500); Testsuite::clearScreen(); - return true; + return passed; } /** @@ -246,15 +279,30 @@ bool GFXtests::palettizedCursors() { Common::Point pt(0, 100); bool isFeaturePresent; - bool isFeatureEnabled; + bool passed = true; isFeaturePresent = g_system->hasFeature(OSystem::kFeatureCursorHasPalette); - isFeatureEnabled = g_system->getFeatureState(OSystem::kFeatureCursorHasPalette); if (isFeaturePresent) { + Testsuite::writeOnScreen("Testing Palettized Cursors", pt); + + // Cursor palette is Black(0), White(1), yellow(2) GFXtests::drawCursor(); + // Change screen Palette color-value 2 to red + // This function exactly does this job + GFXTestSuite::setCustomColor(255, 0, 0); + // Now disable palette + CursorMan.disableCursorPalette(true); + g_system->updateScreen(); + g_system->delayMillis(1000); + if (Testsuite::handleInteractiveInput("Which color does cursor appears to you?", "Yellow", "Red", kOptionRight)) { + printf("LOG: Couldn't use game palette for rendering cursor\n"); + passed = false; + } - Testsuite::writeOnScreen("Testing Palettized Cursors", pt); + // Now enable cursor palette + CursorMan.disableCursorPalette(false); + GFXtests::drawCursor(); Common::EventManager *eventMan = g_system->getEventManager(); Common::Event event; @@ -318,7 +366,10 @@ bool GFXtests::palettizedCursors() { CursorMan.popCursor(); Testsuite::clearScreen(); - return true; + if (!Testsuite::handleInteractiveInput("Did it went as you were expecting?")) { + passed = false; + } + return passed; } -- cgit v1.2.3 From 5534caa65d8acbad5325245e222d81d44a2bc51a Mon Sep 17 00:00:00 2001 From: Neeraj Kumar Date: Tue, 15 Jun 2010 20:32:46 +0000 Subject: added/fixed some features in palettized cursors/aspect ratio correction etc. svn-id: r49891 --- engines/testbed/graphics.cpp | 299 ++++++++++++++++++++++++++----------------- 1 file changed, 178 insertions(+), 121 deletions(-) (limited to 'engines/testbed/graphics.cpp') diff --git a/engines/testbed/graphics.cpp b/engines/testbed/graphics.cpp index 734d35cd67..6081f2c374 100644 --- a/engines/testbed/graphics.cpp +++ b/engines/testbed/graphics.cpp @@ -20,20 +20,26 @@ GFXTestSuite::GFXTestSuite() { g_system->grabPalette(_palette, 0, 3); // Add tests here - // TODO: Can do it without transactions? + + // Blitting buffer on screen + addTest("BlitBitmaps", &GFXtests::copyRectToScreen); + + // GFX Transcations addTest("FullScreenMode", &GFXtests::fullScreenMode); addTest("AspectRatio", &GFXtests::aspectRatio); - addTest("PalettizedCursors", &GFXtests::palettizedCursors); - addTest("BlitBitmaps", &GFXtests::copyRectToScreen); - // TODO: doesn't returns back to normal states addTest("IconifyingWindow", &GFXtests::iconifyWindow); + + // Mouse Layer tests (Palettes and movements) + addTest("PalettizedCursors", &GFXtests::palettizedCursors); // TODO: need to fix it // addTest("ScaledCursors", &GFXtests::scaledCursors); + + // Effects addTest("shakingEffect", &GFXtests::shakingEffect); - // TODO: unable to notice any change, make it noticable addTest("focusRectangle", &GFXtests::focusRectangle); + // TODO: unable to notice any change, make it noticable - addTest("Overlays", &GFXtests::overlayGraphics); + // addTest("Overlays", &GFXtests::overlayGraphics); } const char *GFXTestSuite::getName() const { @@ -50,40 +56,122 @@ void GFXTestSuite::setCustomColor(uint r, uint g, uint b) { // Helper functions used by GFX tests -void GFXtests::drawCursor(const char *gfxModeName, int cursorTargetScale) { +void GFXtests::drawCursor(bool cursorPaletteDisabled, const char *gfxModeName, int cursorTargetScale) { + byte palette[3 * 4]; // Black, white and yellow + byte buffer[11][11]; + + palette[0] = palette[1] = palette[2] = 0; + palette[4] = palette[5] = palette[6] = 255; + palette[8] = palette[9] = 255; + palette[10] = 0; - byte palette[3 * 4]; // Black, white and yellow - palette[0] = palette[1] = palette[2] = 0; - palette[4] = palette[5] = palette[6] = 255; - palette[8] = palette[9] = 255; - palette[10] = 0; + memset(&buffer[0][0], 2, 11 * 11); + CursorMan.pushCursorPalette(palette, 0, 3); + + // Mark the hotspot + for (int i = 0; i < 11; i++) { + buffer[i][i] = 0; + buffer[10 - i][i] = 0; + } + + CursorMan.pushCursor(&buffer[0][0], 11, 11, 5, 5, cursorTargetScale); + CursorMan.showMouse(true); + + if (cursorPaletteDisabled) { + CursorMan.disableCursorPalette(true); + } + + g_system->updateScreen(); + + if (gfxModeName) { + Common::Point pt(0, 100); + char scaleFactor[10]; + snprintf(scaleFactor, 10, "%dx", cursorTargetScale); + Common::String info = "GFX Mode:"; + info = info + gfxModeName + " Cursor scaled by:" + scaleFactor; + Testsuite::clearScreen(); + Testsuite::writeOnScreen(info, pt); + } +} + +/** + * Sets up mouse loop, exits when user clicks any of the mouse button + */ +void GFXtests::setupMouseLoop(bool disableCursorPalette) { + + bool isFeaturePresent; + isFeaturePresent = g_system->hasFeature(OSystem::kFeatureCursorHasPalette); + + if (isFeaturePresent) { - byte buffer[10][10]; - memset(&buffer[0][0], 2, 10 * 10); + GFXtests::drawCursor(disableCursorPalette); - // Mark the hotspot - for (int i = 0; i < 10; i++) { - buffer[i][i] = 0; - buffer[9 - i][i] = 0; - } + Common::EventManager *eventMan = g_system->getEventManager(); + Common::Event event; + Common::Point pt(0, 100); + + bool quitLoop = false; + uint32 lastRedraw = 0; + const uint32 waitTime = 1000 / 45; + + while (!quitLoop) { + while (eventMan->pollEvent(event)) { - CursorMan.replaceCursorPalette(palette, 0, 3); - CursorMan.pushCursor(&buffer[0][0], 10, 10, 5, 5, cursorTargetScale); - CursorMan.showMouse(true); - g_system->updateScreen(); + if (lastRedraw + waitTime < g_system->getMillis()) { + g_system->updateScreen(); + lastRedraw = g_system->getMillis(); + } - if (gfxModeName) { - Common::Point pt(0, 100); - char scaleFactor[10]; - snprintf(scaleFactor, 10, "%dx", cursorTargetScale); - Common::String info = "GFX Mode:"; - info = info + gfxModeName + " Cursor scaled by:" + scaleFactor; - Testsuite::clearScreen(); - Testsuite::writeOnScreen(info, pt); + switch (event.type) { + case Common::EVENT_MOUSEMOVE: + printf("Mouse Move\n"); + break; + case Common::EVENT_LBUTTONDOWN: + case Common::EVENT_RBUTTONDOWN: + Testsuite::clearScreen(); + Testsuite::writeOnScreen("Mouse Clicked", pt); + printf("Mouse Clicked\n"); + g_system->delayMillis(1000); + quitLoop = true; + Testsuite::clearScreen(); + Testsuite::writeOnScreen("TestFinished", pt); + g_system->delayMillis(1000); + break; + default: + ;// Ignore any other event + + } + } } + } else { + Testsuite::displayMessage("feature not supported"); + } +} +void GFXtests::mouseMovements() { + // Testing Mouse Movements now! + Common::Point pt(0, 100); + Testsuite::writeOnScreen("Moving mouse automatically from (0, 0) to (100, 100)", pt); + g_system->warpMouse(0, 0); + g_system->updateScreen(); + g_system->delayMillis(1000); + + for (int i = 0; i <= 100; i++) { + g_system->delayMillis(20); + g_system->warpMouse(i, i); + g_system->updateScreen(); + } + + Testsuite::clearScreen(); + Testsuite::writeOnScreen("Mouse Moved to (100, 100)", pt); + } +void GFXtests::unsetMouse() { + // Popping cursor + CursorMan.popCursorPalette(); + CursorMan.popCursor(); +} /** * Used by aspectRatio() @@ -157,6 +245,8 @@ bool GFXtests::fullScreenMode() { isFeatureEnabled = g_system->getFeatureState(OSystem::kFeatureFullscreenMode); shouldSelect = isFeatureEnabled ? kOptionLeft : kOptionRight; + g_system->delayMillis(1000); + if (isFeatureEnabled) { printf("LOG: Current Mode is Fullsecreen\n"); } else { @@ -193,6 +283,8 @@ bool GFXtests::fullScreenMode() { g_system->setFeatureState(OSystem::kFeatureFullscreenMode, !isFeatureEnabled); g_system->endGFXTransaction(); + g_system->delayMillis(1000); + prompt = "This should be your initial state.Is it?"; if (!Testsuite::handleInteractiveInput(prompt, "Yes, it is", "Nopes", shouldSelect)) { @@ -273,100 +365,42 @@ bool GFXtests::aspectRatio() { */ bool GFXtests::palettizedCursors() { + + bool passed = true; + Testsuite::displayMessage("Testing Cursors. You should expect to see a yellow colored square cursor.\n" "You should be able to move it. The test finishes when the mouse(L/R) is clicked"); + // Testing with cursor Palette Common::Point pt(0, 100); + Testsuite::writeOnScreen("Using cursor Palette to render the cursor", pt); + setupMouseLoop(); + // Test Automated Mouse movements (warp) + mouseMovements(); + // done. Pop cursor now + unsetMouse(); - bool isFeaturePresent; - bool passed = true; - - isFeaturePresent = g_system->hasFeature(OSystem::kFeatureCursorHasPalette); - - if (isFeaturePresent) { - Testsuite::writeOnScreen("Testing Palettized Cursors", pt); - - // Cursor palette is Black(0), White(1), yellow(2) - GFXtests::drawCursor(); - // Change screen Palette color-value 2 to red - // This function exactly does this job - GFXTestSuite::setCustomColor(255, 0, 0); - // Now disable palette - CursorMan.disableCursorPalette(true); - g_system->updateScreen(); - g_system->delayMillis(1000); - if (Testsuite::handleInteractiveInput("Which color does cursor appears to you?", "Yellow", "Red", kOptionRight)) { - printf("LOG: Couldn't use game palette for rendering cursor\n"); - passed = false; - } - - // Now enable cursor palette - CursorMan.disableCursorPalette(false); - GFXtests::drawCursor(); - - Common::EventManager *eventMan = g_system->getEventManager(); - Common::Event event; - - bool quitLoop = false; - uint32 lastRedraw = 0; - const uint32 waitTime = 1000 / 45; - - while (!quitLoop) { - while (eventMan->pollEvent(event)) { - - if (lastRedraw + waitTime < g_system->getMillis()) { - g_system->updateScreen(); - lastRedraw = g_system->getMillis(); - } - - switch (event.type) { - case Common::EVENT_MOUSEMOVE: - printf("Mouse Move\n"); - break; - case Common::EVENT_LBUTTONDOWN: - case Common::EVENT_RBUTTONDOWN: - Testsuite::clearScreen(); - Testsuite::writeOnScreen("Mouse Clicked", pt); - printf("Mouse Clicked\n"); - g_system->delayMillis(1000); - quitLoop = true; - Testsuite::clearScreen(); - Testsuite::writeOnScreen("TestFinished", pt); - g_system->delayMillis(1000); - break; - default: - ;// Ignore any other event - - } - } - } - } else { - Testsuite::displayMessage("feature not supported"); - } + if (Testsuite::handleInteractiveInput("Which color did the cursor appeared to you?", "Yellow", "Any other", kOptionRight)) { + printf("LOG: Couldn't use cursor palette for rendering cursor\n"); + passed = false; + } Testsuite::clearScreen(); - // Testing Mouse Movements now! + // Testing with game Palette + Testsuite::writeOnScreen("Using Game Palette to render the cursor", pt); + GFXTestSuite::setCustomColor(255, 0, 0); + setupMouseLoop(true); + // done. Pop cursor now + unsetMouse(); - Testsuite::writeOnScreen("Moving mouse automatically from (0, 0) to (100, 100)", pt); - g_system->warpMouse(0, 0); - g_system->updateScreen(); + if (Testsuite::handleInteractiveInput("Which color did the cursor appeared to you?", "Red", "Any other", kOptionRight)) { + printf("LOG: Couldn't use Game palette for rendering cursor\n"); + passed = false; + } g_system->delayMillis(1000); - - for (int i = 0; i <= 100; i++) { - g_system->delayMillis(20); - g_system->warpMouse(i, i); - g_system->updateScreen(); - } - Testsuite::clearScreen(); - Testsuite::writeOnScreen("Mouse Moved to (100, 100)", pt); - g_system->delayMillis(1500); - // Popping cursor - CursorMan.popCursorPalette(); - CursorMan.popCursor(); - Testsuite::clearScreen(); - if (!Testsuite::handleInteractiveInput("Did it went as you were expecting?")) { + if (!Testsuite::handleInteractiveInput("Did Cursor tests went as you were expecting?")) { passed = false; } return passed; @@ -394,6 +428,10 @@ bool GFXtests::copyRectToScreen() { Common::Rect rect(x, y, x+40, y+20); Testsuite::clearScreen(rect); + + if (Testsuite::handleInteractiveInput("Did the test worked as expected?", "Yes", "No", kOptionRight)) { + return false; + } return true; @@ -405,8 +443,8 @@ bool GFXtests::copyRectToScreen() { */ bool GFXtests::iconifyWindow() { - Testsuite::displayMessage("Testing Iconify Window mode.\n" - "If the feature is supported by the backend, you should expect to see a toggle between minimized and normal states"); + Testsuite::displayMessage("Testing Iconify Window mode.\n If the feature is supported by the backend," + "you should expect the window to be minimized. However you would manually need to de-iconify."); Common::Point pt(0, 100); Common::Rect rect = Testsuite::writeOnScreen("Testing Iconifying window", pt); @@ -433,6 +471,10 @@ bool GFXtests::iconifyWindow() { } else { Testsuite::displayMessage("feature not supported"); } + + if (Testsuite::handleInteractiveInput("Did the test worked as expected?", "Yes", "No", kOptionRight)) { + return false; + } Testsuite::clearScreen(rect); return true; @@ -455,11 +497,11 @@ bool GFXtests::scaledCursors() { //if (g_system->setGraphicsMode(gfxMode->id)) { if (1) { - drawCursor(gfxMode->name, 1); + drawCursor(false, gfxMode->name, 1); g_system->delayMillis(5000); - drawCursor(gfxMode->name, 2); + drawCursor(false, gfxMode->name, 2); g_system->delayMillis(5000); - drawCursor(gfxMode->name, 3); + drawCursor(false, gfxMode->name, 3); g_system->delayMillis(5000); } else { printf("Switching to graphics mode %s failed\n", gfxMode->name); @@ -473,7 +515,7 @@ bool GFXtests::scaledCursors() { bool GFXtests::shakingEffect() { Common::Point pt(0, 100); - Testsuite::writeOnScreen("Does this shakes!!?", pt); + Testsuite::writeOnScreen("If Shaking effect works,this should shake!", pt); int times = 25; while (times--) { g_system->setShakePos(10); @@ -481,12 +523,19 @@ bool GFXtests::shakingEffect() { g_system->setShakePos(0); g_system->updateScreen(); } - g_system->delayMillis(500); + g_system->delayMillis(1000); + + if (Testsuite::handleInteractiveInput("Did the test worked as expected?", "Yes", "No", kOptionRight)) { + return false; + } Testsuite::clearScreen(); return true; } bool GFXtests::focusRectangle() { + + Testsuite::displayMessage("Testing : Setting and hiding Focus \n" + "If this feature is implemented, the focus should be toggled between the two rectangles on the corners"); Testsuite::clearScreen(); const Graphics::Font &font(*FontMan.getFontByUsage(Graphics::FontManager::kConsoleFont)); @@ -508,6 +557,8 @@ bool GFXtests::focusRectangle() { g_system->unlockScreen(); g_system->updateScreen(); + g_system->clearFocusRectangle(); + g_system->setFocusRectangle(rectLeft); g_system->updateScreen(); @@ -515,6 +566,12 @@ bool GFXtests::focusRectangle() { g_system->setFocusRectangle(rectRight); g_system->updateScreen(); + + g_system->clearFocusRectangle(); + + if (Testsuite::handleInteractiveInput("Do you see a variation in focus?", "Yes", "No", kOptionRight)) { + printf("LOG: Focus Rectangle feature doesn't works. Check platform."); + } return true; } -- cgit v1.2.3 From 46a555d6384f3e43c569d1f5b90b6848a661cff0 Mon Sep 17 00:00:00 2001 From: Neeraj Kumar Date: Tue, 15 Jun 2010 20:57:20 +0000 Subject: some changes in the display texts svn-id: r49893 --- engines/testbed/graphics.cpp | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) (limited to 'engines/testbed/graphics.cpp') diff --git a/engines/testbed/graphics.cpp b/engines/testbed/graphics.cpp index 6081f2c374..83d34ee586 100644 --- a/engines/testbed/graphics.cpp +++ b/engines/testbed/graphics.cpp @@ -123,8 +123,7 @@ void GFXtests::setupMouseLoop(bool disableCursorPalette) { } switch (event.type) { - case Common::EVENT_MOUSEMOVE: - printf("Mouse Move\n"); + case Common::EVENT_MOUSEMOVE: break; case Common::EVENT_LBUTTONDOWN: case Common::EVENT_RBUTTONDOWN: @@ -164,7 +163,7 @@ void GFXtests::mouseMovements() { Testsuite::clearScreen(); Testsuite::writeOnScreen("Mouse Moved to (100, 100)", pt); - + g_system->delayMillis(1000); } void GFXtests::unsetMouse() { @@ -271,7 +270,7 @@ bool GFXtests::fullScreenMode() { g_system->delayMillis(1000); - prompt = " Which mode do you see now ? "; + prompt = " Which screen mode do you see now ? "; if (!Testsuite::handleInteractiveInput(prompt, "Fullscreen", "Windowed", shouldSelect)) { // User selected incorrect mode @@ -285,7 +284,7 @@ bool GFXtests::fullScreenMode() { g_system->delayMillis(1000); - prompt = "This should be your initial state.Is it?"; + prompt = "This should be your initial state. Is it?"; if (!Testsuite::handleInteractiveInput(prompt, "Yes, it is", "Nopes", shouldSelect)) { // User selected incorrect mode @@ -387,7 +386,7 @@ bool GFXtests::palettizedCursors() { Testsuite::clearScreen(); // Testing with game Palette - Testsuite::writeOnScreen("Using Game Palette to render the cursor", pt); + Testsuite::writeOnScreen("Using Game Palette to render the cursor, Click to finish", pt); GFXTestSuite::setCustomColor(255, 0, 0); setupMouseLoop(true); // done. Pop cursor now @@ -429,7 +428,7 @@ bool GFXtests::copyRectToScreen() { Common::Rect rect(x, y, x+40, y+20); Testsuite::clearScreen(rect); - if (Testsuite::handleInteractiveInput("Did the test worked as expected?", "Yes", "No", kOptionRight)) { + if (Testsuite::handleInteractiveInput("Did the test worked as you were expecting?", "Yes", "No", kOptionRight)) { return false; } @@ -472,7 +471,7 @@ bool GFXtests::iconifyWindow() { Testsuite::displayMessage("feature not supported"); } - if (Testsuite::handleInteractiveInput("Did the test worked as expected?", "Yes", "No", kOptionRight)) { + if (Testsuite::handleInteractiveInput("Did the test worked as you were expecting?", "Yes", "No", kOptionRight)) { return false; } @@ -523,9 +522,9 @@ bool GFXtests::shakingEffect() { g_system->setShakePos(0); g_system->updateScreen(); } - g_system->delayMillis(1000); + g_system->delayMillis(1500); - if (Testsuite::handleInteractiveInput("Did the test worked as expected?", "Yes", "No", kOptionRight)) { + if (Testsuite::handleInteractiveInput("Did the test worked as you were expecting?", "Yes", "No", kOptionRight)) { return false; } Testsuite::clearScreen(); @@ -569,8 +568,8 @@ bool GFXtests::focusRectangle() { g_system->clearFocusRectangle(); - if (Testsuite::handleInteractiveInput("Do you see a variation in focus?", "Yes", "No", kOptionRight)) { - printf("LOG: Focus Rectangle feature doesn't works. Check platform."); + if (Testsuite::handleInteractiveInput("Did you noticed a variation in focus?", "Yes", "No", kOptionRight)) { + printf("LOG: Focus Rectangle feature doesn't works. Check platform.\n"); } return true; -- cgit v1.2.3 From 569caaf14e90ec66a04f22a9c361dc2e81be84cc Mon Sep 17 00:00:00 2001 From: Neeraj Kumar Date: Wed, 16 Jun 2010 13:10:59 +0000 Subject: some changes in scaling and overlay svn-id: r49904 --- engines/testbed/graphics.cpp | 90 +++++++++++++++++++++++++++----------------- 1 file changed, 55 insertions(+), 35 deletions(-) (limited to 'engines/testbed/graphics.cpp') diff --git a/engines/testbed/graphics.cpp b/engines/testbed/graphics.cpp index 83d34ee586..f79a8f98a1 100644 --- a/engines/testbed/graphics.cpp +++ b/engines/testbed/graphics.cpp @@ -22,24 +22,24 @@ GFXTestSuite::GFXTestSuite() { // Add tests here // Blitting buffer on screen - addTest("BlitBitmaps", &GFXtests::copyRectToScreen); + // addTest("BlitBitmaps", &GFXtests::copyRectToScreen); // GFX Transcations - addTest("FullScreenMode", &GFXtests::fullScreenMode); - addTest("AspectRatio", &GFXtests::aspectRatio); - addTest("IconifyingWindow", &GFXtests::iconifyWindow); + // addTest("FullScreenMode", &GFXtests::fullScreenMode); + // addTest("AspectRatio", &GFXtests::aspectRatio); + // addTest("IconifyingWindow", &GFXtests::iconifyWindow); // Mouse Layer tests (Palettes and movements) addTest("PalettizedCursors", &GFXtests::palettizedCursors); // TODO: need to fix it - // addTest("ScaledCursors", &GFXtests::scaledCursors); + addTest("ScaledCursors", &GFXtests::scaledCursors); // Effects - addTest("shakingEffect", &GFXtests::shakingEffect); - addTest("focusRectangle", &GFXtests::focusRectangle); + // addTest("shakingEffect", &GFXtests::shakingEffect); + // addTest("focusRectangle", &GFXtests::focusRectangle); // TODO: unable to notice any change, make it noticable - // addTest("Overlays", &GFXtests::overlayGraphics); + addTest("Overlays", &GFXtests::overlayGraphics); } const char *GFXTestSuite::getName() const { @@ -74,7 +74,7 @@ void GFXtests::drawCursor(bool cursorPaletteDisabled, const char *gfxModeName, i buffer[10 - i][i] = 0; } - CursorMan.pushCursor(&buffer[0][0], 11, 11, 5, 5, cursorTargetScale); + CursorMan.pushCursor(&buffer[0][0], 11, 11, 5, 5, 1); CursorMan.showMouse(true); if (cursorPaletteDisabled) { @@ -97,14 +97,14 @@ void GFXtests::drawCursor(bool cursorPaletteDisabled, const char *gfxModeName, i /** * Sets up mouse loop, exits when user clicks any of the mouse button */ -void GFXtests::setupMouseLoop(bool disableCursorPalette) { +void GFXtests::setupMouseLoop(bool disableCursorPalette, const char *gfxModeName, int cursorTargetScale) { bool isFeaturePresent; isFeaturePresent = g_system->hasFeature(OSystem::kFeatureCursorHasPalette); if (isFeaturePresent) { - GFXtests::drawCursor(disableCursorPalette); + GFXtests::drawCursor(disableCursorPalette, gfxModeName, cursorTargetScale); Common::EventManager *eventMan = g_system->getEventManager(); Common::Event event; @@ -112,7 +112,13 @@ void GFXtests::setupMouseLoop(bool disableCursorPalette) { bool quitLoop = false; uint32 lastRedraw = 0; - const uint32 waitTime = 1000 / 45; + const uint32 waitTime = 1000 / 45; + + Testsuite::clearScreen(); + Common::String info = disableCursorPalette ? "Using Game Palette" : "Using cursor palette"; + info += "to render the cursor, Click to finish"; + + Testsuite::writeOnScreen(info, pt); while (!quitLoop) { while (eventMan->pollEvent(event)) { @@ -371,8 +377,6 @@ bool GFXtests::palettizedCursors() { "You should be able to move it. The test finishes when the mouse(L/R) is clicked"); // Testing with cursor Palette - Common::Point pt(0, 100); - Testsuite::writeOnScreen("Using cursor Palette to render the cursor", pt); setupMouseLoop(); // Test Automated Mouse movements (warp) mouseMovements(); @@ -383,10 +387,8 @@ bool GFXtests::palettizedCursors() { printf("LOG: Couldn't use cursor palette for rendering cursor\n"); passed = false; } - Testsuite::clearScreen(); // Testing with game Palette - Testsuite::writeOnScreen("Using Game Palette to render the cursor, Click to finish", pt); GFXTestSuite::setCustomColor(255, 0, 0); setupMouseLoop(true); // done. Pop cursor now @@ -397,7 +399,6 @@ bool GFXtests::palettizedCursors() { passed = false; } g_system->delayMillis(1000); - Testsuite::clearScreen(); if (!Testsuite::handleInteractiveInput("Did Cursor tests went as you were expecting?")) { passed = false; @@ -486,22 +487,25 @@ bool GFXtests::iconifyWindow() { bool GFXtests::scaledCursors() { // TODO : Understand and fix the problem relating scaled cursors - + const OSystem::GraphicsMode *gfxMode = g_system->getSupportedGraphicsModes(); - while (gfxMode->name) { // for every graphics mode display cursors for cursorTargetScale 1, 2 and 3 // Switch Graphics mode - g_system->warpMouse(80, 160); - - //if (g_system->setGraphicsMode(gfxMode->id)) { + // FIXME: Doesn't works: + // if (g_system->setGraphicsMode(gfxMode->id)) { if (1) { - drawCursor(false, gfxMode->name, 1); - g_system->delayMillis(5000); - drawCursor(false, gfxMode->name, 2); - g_system->delayMillis(5000); - drawCursor(false, gfxMode->name, 3); - g_system->delayMillis(5000); + g_system->updateScreen(); + + setupMouseLoop(false, gfxMode->name, 1); + unsetMouse(); + + setupMouseLoop(false, gfxMode->name, 2); + unsetMouse(); + + setupMouseLoop(false, gfxMode->name, 3); + unsetMouse(); + } else { printf("Switching to graphics mode %s failed\n", gfxMode->name); } @@ -515,7 +519,7 @@ bool GFXtests::scaledCursors() { bool GFXtests::shakingEffect() { Common::Point pt(0, 100); Testsuite::writeOnScreen("If Shaking effect works,this should shake!", pt); - int times = 25; + int times = 35; while (times--) { g_system->setShakePos(10); g_system->updateScreen(); @@ -525,6 +529,7 @@ bool GFXtests::shakingEffect() { g_system->delayMillis(1500); if (Testsuite::handleInteractiveInput("Did the test worked as you were expecting?", "Yes", "No", kOptionRight)) { + printf("LOG: Shaking Effect didn't worked"); return false; } Testsuite::clearScreen(); @@ -576,21 +581,36 @@ bool GFXtests::focusRectangle() { } bool GFXtests::overlayGraphics() { + + // TODO: ifind out if this is required? + g_system->beginGFXTransaction(); + g_system->initSize(640, 400); + g_system->endGFXTransaction(); + + Graphics::PixelFormat pf = g_system->getOverlayFormat(); - GFXTestSuite::setCustomColor(255, 255, 0); OverlayColor buffer[20 * 40]; - memset(buffer, 2, 20 * 40); - - int x = g_system->getWidth() / 2 - 20; - int y = g_system->getHeight() / 2 - 10; + OverlayColor value = pf.RGBToColor(0, 255, 0); - g_system->copyRectToOverlay(buffer, 40, x, y, 40, 20); + for (int i = 0; i < 20 * 40; i++) { + buffer[i] = value; + } + + // FIXME: Not Working. + g_system->copyRectToOverlay(buffer, 40, 100, 100, 40, 20); g_system->showOverlay(); g_system->updateScreen(); + g_system->delayMillis(1000); + g_system->hideOverlay(); + g_system->updateScreen(); + if (Testsuite::handleInteractiveInput("Did you see a green overlayed rectangle?", "Yes", "No", kOptionRight)) { + printf("LOG: Overlay Rectangle feature doesn't works\n"); + return false; + } return true; } -- cgit v1.2.3 From f3dcd38c74c835b0046a849cefa7dafcf1844ccd Mon Sep 17 00:00:00 2001 From: Neeraj Kumar Date: Thu, 17 Jun 2010 11:23:51 +0000 Subject: few fixes in GFX tests, added template for FS tests svn-id: r49925 --- engines/testbed/graphics.cpp | 52 ++++++++++++++++++++++---------------------- 1 file changed, 26 insertions(+), 26 deletions(-) (limited to 'engines/testbed/graphics.cpp') diff --git a/engines/testbed/graphics.cpp b/engines/testbed/graphics.cpp index f79a8f98a1..3f9438d15c 100644 --- a/engines/testbed/graphics.cpp +++ b/engines/testbed/graphics.cpp @@ -22,21 +22,21 @@ GFXTestSuite::GFXTestSuite() { // Add tests here // Blitting buffer on screen - // addTest("BlitBitmaps", &GFXtests::copyRectToScreen); + addTest("BlitBitmaps", &GFXtests::copyRectToScreen); // GFX Transcations - // addTest("FullScreenMode", &GFXtests::fullScreenMode); - // addTest("AspectRatio", &GFXtests::aspectRatio); - // addTest("IconifyingWindow", &GFXtests::iconifyWindow); + addTest("FullScreenMode", &GFXtests::fullScreenMode); + addTest("AspectRatio", &GFXtests::aspectRatio); + addTest("IconifyingWindow", &GFXtests::iconifyWindow); // Mouse Layer tests (Palettes and movements) addTest("PalettizedCursors", &GFXtests::palettizedCursors); - // TODO: need to fix it + // FIXME: need to fix it addTest("ScaledCursors", &GFXtests::scaledCursors); // Effects - // addTest("shakingEffect", &GFXtests::shakingEffect); - // addTest("focusRectangle", &GFXtests::focusRectangle); + addTest("shakingEffect", &GFXtests::shakingEffect); + addTest("focusRectangle", &GFXtests::focusRectangle); // TODO: unable to notice any change, make it noticable addTest("Overlays", &GFXtests::overlayGraphics); @@ -74,7 +74,7 @@ void GFXtests::drawCursor(bool cursorPaletteDisabled, const char *gfxModeName, i buffer[10 - i][i] = 0; } - CursorMan.pushCursor(&buffer[0][0], 11, 11, 5, 5, 1); + CursorMan.pushCursor(&buffer[0][0], 11, 11, 5, 5, cursorTargetScale); CursorMan.showMouse(true); if (cursorPaletteDisabled) { @@ -82,16 +82,6 @@ void GFXtests::drawCursor(bool cursorPaletteDisabled, const char *gfxModeName, i } g_system->updateScreen(); - - if (gfxModeName) { - Common::Point pt(0, 100); - char scaleFactor[10]; - snprintf(scaleFactor, 10, "%dx", cursorTargetScale); - Common::String info = "GFX Mode:"; - info = info + gfxModeName + " Cursor scaled by:" + scaleFactor; - Testsuite::clearScreen(); - Testsuite::writeOnScreen(info, pt); - } } /** @@ -116,9 +106,21 @@ void GFXtests::setupMouseLoop(bool disableCursorPalette, const char *gfxModeName Testsuite::clearScreen(); Common::String info = disableCursorPalette ? "Using Game Palette" : "Using cursor palette"; - info += "to render the cursor, Click to finish"; + info += " to render the cursor, Click to finish"; Testsuite::writeOnScreen(info, pt); + + info = "GFX Mode"; + info += gfxModeName; + info += " "; + + char cScale = cursorTargetScale + '0'; + info += "Cursor scale: "; + info += cScale; + + if (!Common::String(gfxModeName).equals("")) { + Testsuite::writeOnScreen(info, Common::Point(0, 120)); + } while (!quitLoop) { while (eventMan->pollEvent(event)) { @@ -133,13 +135,9 @@ void GFXtests::setupMouseLoop(bool disableCursorPalette, const char *gfxModeName break; case Common::EVENT_LBUTTONDOWN: case Common::EVENT_RBUTTONDOWN: - Testsuite::clearScreen(); - Testsuite::writeOnScreen("Mouse Clicked", pt); - printf("Mouse Clicked\n"); - g_system->delayMillis(1000); quitLoop = true; Testsuite::clearScreen(); - Testsuite::writeOnScreen("TestFinished", pt); + Testsuite::writeOnScreen("Mouse clicked", pt); g_system->delayMillis(1000); break; default: @@ -505,7 +503,9 @@ bool GFXtests::scaledCursors() { setupMouseLoop(false, gfxMode->name, 3); unsetMouse(); - + + break; + } else { printf("Switching to graphics mode %s failed\n", gfxMode->name); } @@ -529,7 +529,7 @@ bool GFXtests::shakingEffect() { g_system->delayMillis(1500); if (Testsuite::handleInteractiveInput("Did the test worked as you were expecting?", "Yes", "No", kOptionRight)) { - printf("LOG: Shaking Effect didn't worked"); + printf("LOG: Shaking Effect didn't worked"); return false; } Testsuite::clearScreen(); -- cgit v1.2.3 From 492f743d47ea47ee9e28368fce1b5505399c011e Mon Sep 17 00:00:00 2001 From: Neeraj Kumar Date: Sat, 19 Jun 2010 20:50:10 +0000 Subject: some more changes with GFX and FS tests svn-id: r50064 --- engines/testbed/graphics.cpp | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) (limited to 'engines/testbed/graphics.cpp') diff --git a/engines/testbed/graphics.cpp b/engines/testbed/graphics.cpp index 3f9438d15c..6b45d6133c 100644 --- a/engines/testbed/graphics.cpp +++ b/engines/testbed/graphics.cpp @@ -425,7 +425,7 @@ bool GFXtests::copyRectToScreen() { g_system->delayMillis(1000); Common::Rect rect(x, y, x+40, y+20); - Testsuite::clearScreen(rect); + Testsuite::clearScreen(); if (Testsuite::handleInteractiveInput("Did the test worked as you were expecting?", "Yes", "No", kOptionRight)) { return false; @@ -474,7 +474,7 @@ bool GFXtests::iconifyWindow() { return false; } - Testsuite::clearScreen(rect); + Testsuite::clearScreen(); return true; } @@ -485,32 +485,46 @@ bool GFXtests::iconifyWindow() { bool GFXtests::scaledCursors() { // TODO : Understand and fix the problem relating scaled cursors + Testsuite::displayMessage("Testing : Scaled cursors\n" + "Here every graphics mode is tried with a cursorTargetScale of 1,2 and 3" + "This may take time, You may skip the later scalers and just examine the first three i.e 1x,2x and 3x"); + + int maxLimit = 1000; + if (!Testsuite::handleInteractiveInput("Do you want to skip other scalers", "Yes", "No", kOptionRight)) { + maxLimit = 3; + } const OSystem::GraphicsMode *gfxMode = g_system->getSupportedGraphicsModes(); - while (gfxMode->name) { + + while (gfxMode->name && maxLimit > 0) { // for every graphics mode display cursors for cursorTargetScale 1, 2 and 3 // Switch Graphics mode // FIXME: Doesn't works: - // if (g_system->setGraphicsMode(gfxMode->id)) { - if (1) { - g_system->updateScreen(); + g_system->beginGFXTransaction(); + bool isGFXModeSet = g_system->setGraphicsMode(gfxMode->id); + g_system->initSize(320, 200); + g_system->endGFXTransaction(); + + if (isGFXModeSet) { setupMouseLoop(false, gfxMode->name, 1); unsetMouse(); + Testsuite::clearScreen(); setupMouseLoop(false, gfxMode->name, 2); unsetMouse(); + Testsuite::clearScreen(); setupMouseLoop(false, gfxMode->name, 3); unsetMouse(); - - break; + Testsuite::clearScreen(); } else { printf("Switching to graphics mode %s failed\n", gfxMode->name); } CursorMan.popAllCursors(); gfxMode++; + maxLimit--; } return true; -- cgit v1.2.3 From 6110f16b295e90e50042c7142a26115ef5b3a291 Mon Sep 17 00:00:00 2001 From: Neeraj Kumar Date: Mon, 21 Jun 2010 19:09:19 +0000 Subject: fixed couple of leaks in testbed/fs.cpp, removed some unecesarry code from graphics.cpp/graphics.h svn-id: r50119 --- engines/testbed/graphics.cpp | 50 +++++++++++++++++++++----------------------- 1 file changed, 24 insertions(+), 26 deletions(-) (limited to 'engines/testbed/graphics.cpp') diff --git a/engines/testbed/graphics.cpp b/engines/testbed/graphics.cpp index 6b45d6133c..66a48837dc 100644 --- a/engines/testbed/graphics.cpp +++ b/engines/testbed/graphics.cpp @@ -17,7 +17,9 @@ GFXTestSuite::GFXTestSuite() { // The fourth field is for alpha channel which is unused // Assuming 8bpp as of now g_system->setPalette(_palette, 0, 3); - g_system->grabPalette(_palette, 0, 3); + + // Init Mouse Palette (White-black-yellow) + GFXtests::initMousePalette(); // Add tests here @@ -51,36 +53,44 @@ void GFXTestSuite::setCustomColor(uint r, uint g, uint b) { _palette[9] = g; _palette[10] = b; g_system->setPalette(_palette, 0, 3); - g_system->grabPalette(_palette, 0, 3); } // Helper functions used by GFX tests -void GFXtests::drawCursor(bool cursorPaletteDisabled, const char *gfxModeName, int cursorTargetScale) { +void GFXtests::initMousePalette() { byte palette[3 * 4]; // Black, white and yellow - byte buffer[11][11]; palette[0] = palette[1] = palette[2] = 0; palette[4] = palette[5] = palette[6] = 255; palette[8] = palette[9] = 255; palette[10] = 0; - memset(&buffer[0][0], 2, 11 * 11); - CursorMan.pushCursorPalette(palette, 0, 3); + CursorMan.replaceCursorPalette(palette, 0, 3); + +} + +void GFXtests::drawCursor(bool cursorPaletteDisabled, const char *gfxModeName, int cursorTargetScale) { + + // Paint the mouse with yellow + byte buffer[11][11]; + memset(&buffer[0][0], 2, sizeof(buffer)); - // Mark the hotspot + // Mark the hotspot with black for (int i = 0; i < 11; i++) { buffer[i][i] = 0; - buffer[10 - i][i] = 0; + // buffer[10 - i][i] = 0; } - CursorMan.pushCursor(&buffer[0][0], 11, 11, 5, 5, cursorTargetScale); + CursorMan.replaceCursor(&buffer[0][0], 11, 11, 0, 0, 255, cursorTargetScale); CursorMan.showMouse(true); if (cursorPaletteDisabled) { CursorMan.disableCursorPalette(true); + } else { + initMousePalette(); + CursorMan.disableCursorPalette(false); } - + g_system->updateScreen(); } @@ -170,12 +180,6 @@ void GFXtests::mouseMovements() { g_system->delayMillis(1000); } -void GFXtests::unsetMouse() { - // Popping cursor - CursorMan.popCursorPalette(); - CursorMan.popCursor(); -} - /** * Used by aspectRatio() */ @@ -368,6 +372,7 @@ bool GFXtests::aspectRatio() { */ bool GFXtests::palettizedCursors() { + bool passed = true; @@ -378,8 +383,6 @@ bool GFXtests::palettizedCursors() { setupMouseLoop(); // Test Automated Mouse movements (warp) mouseMovements(); - // done. Pop cursor now - unsetMouse(); if (Testsuite::handleInteractiveInput("Which color did the cursor appeared to you?", "Yellow", "Any other", kOptionRight)) { printf("LOG: Couldn't use cursor palette for rendering cursor\n"); @@ -389,8 +392,6 @@ bool GFXtests::palettizedCursors() { // Testing with game Palette GFXTestSuite::setCustomColor(255, 0, 0); setupMouseLoop(true); - // done. Pop cursor now - unsetMouse(); if (Testsuite::handleInteractiveInput("Which color did the cursor appeared to you?", "Red", "Any other", kOptionRight)) { printf("LOG: Couldn't use Game palette for rendering cursor\n"); @@ -401,6 +402,7 @@ bool GFXtests::palettizedCursors() { if (!Testsuite::handleInteractiveInput("Did Cursor tests went as you were expecting?")) { passed = false; } + return passed; } @@ -490,7 +492,7 @@ bool GFXtests::scaledCursors() { "This may take time, You may skip the later scalers and just examine the first three i.e 1x,2x and 3x"); int maxLimit = 1000; - if (!Testsuite::handleInteractiveInput("Do you want to skip other scalers", "Yes", "No", kOptionRight)) { + if (!Testsuite::handleInteractiveInput("Do you want to restrict scalers to 1x, 2x and 3x only?", "Yes", "No", kOptionRight)) { maxLimit = 3; } @@ -501,28 +503,24 @@ bool GFXtests::scaledCursors() { // Switch Graphics mode // FIXME: Doesn't works: g_system->beginGFXTransaction(); - bool isGFXModeSet = g_system->setGraphicsMode(gfxMode->id); + bool isGFXModeSet = g_system->setGraphicsMode("2x"); g_system->initSize(320, 200); g_system->endGFXTransaction(); if (isGFXModeSet) { setupMouseLoop(false, gfxMode->name, 1); - unsetMouse(); Testsuite::clearScreen(); setupMouseLoop(false, gfxMode->name, 2); - unsetMouse(); Testsuite::clearScreen(); setupMouseLoop(false, gfxMode->name, 3); - unsetMouse(); Testsuite::clearScreen(); } else { printf("Switching to graphics mode %s failed\n", gfxMode->name); } - CursorMan.popAllCursors(); gfxMode++; maxLimit--; } -- cgit v1.2.3 From e86f732a7b67b6df6d78000d0f34ca8013b93b46 Mon Sep 17 00:00:00 2001 From: Neeraj Kumar Date: Mon, 21 Jun 2010 21:26:07 +0000 Subject: crash with 3x sacling with cursors of odd dimmensions svn-id: r50123 --- engines/testbed/graphics.cpp | 71 +++++++++++++++++++++++++++++--------------- 1 file changed, 47 insertions(+), 24 deletions(-) (limited to 'engines/testbed/graphics.cpp') diff --git a/engines/testbed/graphics.cpp b/engines/testbed/graphics.cpp index 66a48837dc..41d22fc47a 100644 --- a/engines/testbed/graphics.cpp +++ b/engines/testbed/graphics.cpp @@ -24,24 +24,24 @@ GFXTestSuite::GFXTestSuite() { // Add tests here // Blitting buffer on screen - addTest("BlitBitmaps", &GFXtests::copyRectToScreen); + // addTest("BlitBitmaps", &GFXtests::copyRectToScreen); // GFX Transcations - addTest("FullScreenMode", &GFXtests::fullScreenMode); - addTest("AspectRatio", &GFXtests::aspectRatio); - addTest("IconifyingWindow", &GFXtests::iconifyWindow); + // addTest("FullScreenMode", &GFXtests::fullScreenMode); + // addTest("AspectRatio", &GFXtests::aspectRatio); + // addTest("IconifyingWindow", &GFXtests::iconifyWindow); // Mouse Layer tests (Palettes and movements) - addTest("PalettizedCursors", &GFXtests::palettizedCursors); + // addTest("PalettizedCursors", &GFXtests::palettizedCursors); // FIXME: need to fix it addTest("ScaledCursors", &GFXtests::scaledCursors); // Effects - addTest("shakingEffect", &GFXtests::shakingEffect); - addTest("focusRectangle", &GFXtests::focusRectangle); + // addTest("shakingEffect", &GFXtests::shakingEffect); + // addTest("focusRectangle", &GFXtests::focusRectangle); // TODO: unable to notice any change, make it noticable - addTest("Overlays", &GFXtests::overlayGraphics); + // addTest("Overlays", &GFXtests::overlayGraphics); } const char *GFXTestSuite::getName() const { @@ -71,17 +71,26 @@ void GFXtests::initMousePalette() { void GFXtests::drawCursor(bool cursorPaletteDisabled, const char *gfxModeName, int cursorTargetScale) { - // Paint the mouse with yellow - byte buffer[11][11]; - memset(&buffer[0][0], 2, sizeof(buffer)); + // Buffer initialized with yellow color + byte buffer[500]; + memset(buffer, 2, sizeof(buffer)); - // Mark the hotspot with black - for (int i = 0; i < 11; i++) { - buffer[i][i] = 0; - // buffer[10 - i][i] = 0; - } + /* Disable HotSpot highlighting as of now - CursorMan.replaceCursor(&buffer[0][0], 11, 11, 0, 0, 255, cursorTargetScale); + // Paint the cursor with yellow, except the hotspot + for (int i = 0; i < 16; i++) { + for (int j = 0; j < 16; j++) { + if (i != j && i != 15 - j) { + buffer[i * 16 + j] = 2; + } + } + } + + */ + + // Uncommenting the next line and commenting the line after that would reproduce the crash + // CursorMan.replaceCursor(buffer, 11, 11, 0, 0, 255, cursorTargetScale); + CursorMan.replaceCursor(buffer, 12, 12, 0, 0, 255, cursorTargetScale); CursorMan.showMouse(true); if (cursorPaletteDisabled) { @@ -486,7 +495,6 @@ bool GFXtests::iconifyWindow() { bool GFXtests::scaledCursors() { - // TODO : Understand and fix the problem relating scaled cursors Testsuite::displayMessage("Testing : Scaled cursors\n" "Here every graphics mode is tried with a cursorTargetScale of 1,2 and 3" "This may take time, You may skip the later scalers and just examine the first three i.e 1x,2x and 3x"); @@ -495,19 +503,22 @@ bool GFXtests::scaledCursors() { if (!Testsuite::handleInteractiveInput("Do you want to restrict scalers to 1x, 2x and 3x only?", "Yes", "No", kOptionRight)) { maxLimit = 3; } - + + const int currGFXMode = g_system->getGraphicsMode(); const OSystem::GraphicsMode *gfxMode = g_system->getSupportedGraphicsModes(); while (gfxMode->name && maxLimit > 0) { // for every graphics mode display cursors for cursorTargetScale 1, 2 and 3 // Switch Graphics mode - // FIXME: Doesn't works: + // FIXME: Crashes with "3x" mode now.: g_system->beginGFXTransaction(); - bool isGFXModeSet = g_system->setGraphicsMode("2x"); + + bool isGFXModeSet = g_system->setGraphicsMode(gfxMode->id); g_system->initSize(320, 200); - g_system->endGFXTransaction(); + + OSystem::TransactionError gfxError = g_system->endGFXTransaction(); - if (isGFXModeSet) { + if (gfxError == OSystem::kTransactionSuccess && isGFXModeSet) { setupMouseLoop(false, gfxMode->name, 1); Testsuite::clearScreen(); @@ -519,12 +530,24 @@ bool GFXtests::scaledCursors() { Testsuite::clearScreen(); } else { - printf("Switching to graphics mode %s failed\n", gfxMode->name); + printf("LOG: Switching to graphics mode %s failed\n", gfxMode->name); + return false; } gfxMode++; maxLimit--; } + // Restore Original State + g_system->beginGFXTransaction(); + bool isGFXModeSet = g_system->setGraphicsMode(currGFXMode); + g_system->initSize(320, 200); + OSystem::TransactionError gfxError = g_system->endGFXTransaction(); + + if (gfxError != OSystem::kTransactionSuccess || !isGFXModeSet) { + printf("LOG: Switcing to initial state failed\n"); + return false; + } + return true; } -- cgit v1.2.3 From f444d451169cdcf7e3dd2deef146e5a26e73bd49 Mon Sep 17 00:00:00 2001 From: Neeraj Kumar Date: Tue, 22 Jun 2010 20:49:38 +0000 Subject: some more filesystem related tweaks svn-id: r50167 --- engines/testbed/graphics.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines/testbed/graphics.cpp') diff --git a/engines/testbed/graphics.cpp b/engines/testbed/graphics.cpp index 41d22fc47a..e481b48458 100644 --- a/engines/testbed/graphics.cpp +++ b/engines/testbed/graphics.cpp @@ -90,7 +90,7 @@ void GFXtests::drawCursor(bool cursorPaletteDisabled, const char *gfxModeName, i // Uncommenting the next line and commenting the line after that would reproduce the crash // CursorMan.replaceCursor(buffer, 11, 11, 0, 0, 255, cursorTargetScale); - CursorMan.replaceCursor(buffer, 12, 12, 0, 0, 255, cursorTargetScale); + CursorMan.replaceCursor(buffer, 12, 13, 0, 0, 255, cursorTargetScale); CursorMan.showMouse(true); if (cursorPaletteDisabled) { -- cgit v1.2.3 From b243a93932ae6111d676799ce891ae63a97b0c94 Mon Sep 17 00:00:00 2001 From: Neeraj Kumar Date: Thu, 24 Jun 2010 15:27:28 +0000 Subject: added palette rotation test svn-id: r50220 --- engines/testbed/graphics.cpp | 79 +++++++++++++++++++++++++++++++++++++++----- 1 file changed, 70 insertions(+), 9 deletions(-) (limited to 'engines/testbed/graphics.cpp') diff --git a/engines/testbed/graphics.cpp b/engines/testbed/graphics.cpp index e481b48458..e44d71782f 100644 --- a/engines/testbed/graphics.cpp +++ b/engines/testbed/graphics.cpp @@ -1,4 +1,5 @@ #include "common/events.h" +#include "common/random.h" #include "testbed/graphics.h" #include "testbed/testsuite.h" @@ -34,14 +35,19 @@ GFXTestSuite::GFXTestSuite() { // Mouse Layer tests (Palettes and movements) // addTest("PalettizedCursors", &GFXtests::palettizedCursors); // FIXME: need to fix it - addTest("ScaledCursors", &GFXtests::scaledCursors); + // addTest("ScaledCursors", &GFXtests::scaledCursors); // Effects // addTest("shakingEffect", &GFXtests::shakingEffect); // addTest("focusRectangle", &GFXtests::focusRectangle); - // TODO: unable to notice any change, make it noticable + // Overlay // addTest("Overlays", &GFXtests::overlayGraphics); + + // Specific Tests: + addTest("Palette Rotation", &GFXtests::paletteRotation); + addTest("Pixel Formats", &GFXtests::pixelFormats); + } const char *GFXTestSuite::getName() const { @@ -103,6 +109,22 @@ void GFXtests::drawCursor(bool cursorPaletteDisabled, const char *gfxModeName, i g_system->updateScreen(); } +void rotatePalette(byte palette[], int size) { + // Ignore rotating black color, as that is background + // take a temporary palette color + byte tColor[4] = {0}; + // save the first color in tColor + memcpy(tColor, &palette[4], 4 * sizeof(byte)); + + // Move each color upward by 1 + for (int i = 1; i < size - 1; i++) { + memcpy(&palette[i * 4], &palette[(i + 1) * 4], 4 * sizeof(byte)); + } + // Assign last color to tcolor + memcpy(&palette[(size -1) * 4], tColor, 4 * sizeof(byte)); + g_system->setPalette(palette, 0, 10); +} + /** * Sets up mouse loop, exits when user clicks any of the mouse button */ @@ -617,12 +639,6 @@ bool GFXtests::focusRectangle() { bool GFXtests::overlayGraphics() { - // TODO: ifind out if this is required? - g_system->beginGFXTransaction(); - g_system->initSize(640, 400); - g_system->endGFXTransaction(); - - Graphics::PixelFormat pf = g_system->getOverlayFormat(); OverlayColor buffer[20 * 40]; @@ -633,8 +649,8 @@ bool GFXtests::overlayGraphics() { } // FIXME: Not Working. - g_system->copyRectToOverlay(buffer, 40, 100, 100, 40, 20); g_system->showOverlay(); + g_system->copyRectToOverlay(buffer, 40, 100, 100, 40, 20); g_system->updateScreen(); g_system->delayMillis(1000); @@ -649,4 +665,49 @@ bool GFXtests::overlayGraphics() { return true; } +bool GFXtests::paletteRotation() { + byte palette[10 * 4] = {0, 0, 0, 0, + 255, 255, 255, 0, + 135, 48, 21, 0, + 205, 190, 87, 0, + 0, 32, 64, 0, + 181, 126, 145, 0, + 47, 78, 36, 0, + 185, 115, 20, 0, + 160, 164, 137, 0, + 43, 52, 0, 0}; // 10 colors : B, W and 8 random + + Common::RandomSource rs; + + // Initialize this palette randomly + g_system->setPalette(palette, 0, 10); + + // Draw 10 Rectangles, each of width 100 pixels and height 10 pixels + byte buffer[10 * 100 * 10] = {0}; + + for (int i = 0; i < 10; i++) { + memset(buffer + i * 1000, i, 1000 * sizeof(byte)); + } + + g_system->copyRectToScreen(buffer, 100, 110, 50, 100, 100); + + int toRotate = 10; + + while (toRotate--) { + g_system->updateScreen(); + g_system->delayMillis(1000); + rotatePalette(palette, 10); + } + + if(Testsuite::handleInteractiveInput("Did you want to rotate the palettes?", "Yes", "No", kOptionRight)) { + return false; + } + + return true; +} + +bool GFXtests::pixelFormats() { + +} + } -- cgit v1.2.3 From 1e224366867490c9f0a02e3864b02f095be197e7 Mon Sep 17 00:00:00 2001 From: Neeraj Kumar Date: Fri, 25 Jun 2010 03:48:28 +0000 Subject: added code to test 16+ bit pixel formats svn-id: r50257 --- engines/testbed/graphics.cpp | 48 ++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 46 insertions(+), 2 deletions(-) (limited to 'engines/testbed/graphics.cpp') diff --git a/engines/testbed/graphics.cpp b/engines/testbed/graphics.cpp index e44d71782f..82c765d44e 100644 --- a/engines/testbed/graphics.cpp +++ b/engines/testbed/graphics.cpp @@ -1,4 +1,5 @@ #include "common/events.h" +#include "common/list.h" #include "common/random.h" #include "testbed/graphics.h" @@ -695,11 +696,11 @@ bool GFXtests::paletteRotation() { while (toRotate--) { g_system->updateScreen(); - g_system->delayMillis(1000); + g_system->delayMillis(300); rotatePalette(palette, 10); } - if(Testsuite::handleInteractiveInput("Did you want to rotate the palettes?", "Yes", "No", kOptionRight)) { + if(Testsuite::handleInteractiveInput("Did you saw palettes rotating?", "Yes", "No", kOptionRight)) { return false; } @@ -707,7 +708,50 @@ bool GFXtests::paletteRotation() { } bool GFXtests::pixelFormats() { + Common::List pfList = g_system->getSupportedFormats(); + Common::List::const_iterator iter = pfList.begin(); + + Graphics::PixelFormat currPixelformat = g_system->getScreenFormat(); + printf("Current bpp: %d List size : %d\n",currPixelformat.bytesPerPixel, pfList.size()); + + while (iter != pfList.end()) { + printf("bpp : %d\n", (*iter).bytesPerPixel); + + // Switch to that pixelFormat + g_system->beginGFXTransaction(); + g_system->initSize(320, 200, &(*iter)); + g_system->endGFXTransaction(); + + // Draw some nice gradients + // Pick up some colors + uint colors[6]; + + colors[0] = iter->RGBToColor(255, 255, 255); + colors[1] = iter->RGBToColor(135, 48, 21); + colors[2] = iter->RGBToColor(205, 190, 87); + colors[3] = iter->RGBToColor(0, 32, 64); + colors[4] = iter->RGBToColor(181, 126, 145); + colors[5] = iter->RGBToColor(47, 78, 36); + + // Draw some Rectangles, each of width 100 pixels and height 10 pixels + byte buffer[6 * 100 * 10] = {0}; + int indx; + for (int i = 0; i < ARRAYSIZE(colors); i++) { + indx = i * 1000; + for (int j = 0; j < 1000; j++) { + buffer[indx + j] = colors[i]; + } + } + + g_system->copyRectToScreen(buffer, 100, 110, 70, 100, 60); + g_system->updateScreen(); + g_system->delayMillis(2000); + break; + iter++; + } + + return true; } } -- cgit v1.2.3 From bc3a7ba915221b130bfb6390c1dedf86dac81c95 Mon Sep 17 00:00:00 2001 From: Neeraj Kumar Date: Fri, 25 Jun 2010 14:49:11 +0000 Subject: improved the pixel and other gfx tests svn-id: r50264 --- engines/testbed/graphics.cpp | 132 +++++++++++++++++++++++++++++-------------- 1 file changed, 89 insertions(+), 43 deletions(-) (limited to 'engines/testbed/graphics.cpp') diff --git a/engines/testbed/graphics.cpp b/engines/testbed/graphics.cpp index 82c765d44e..79d73a0432 100644 --- a/engines/testbed/graphics.cpp +++ b/engines/testbed/graphics.cpp @@ -26,24 +26,24 @@ GFXTestSuite::GFXTestSuite() { // Add tests here // Blitting buffer on screen - // addTest("BlitBitmaps", &GFXtests::copyRectToScreen); + addTest("BlitBitmaps", &GFXtests::copyRectToScreen); // GFX Transcations - // addTest("FullScreenMode", &GFXtests::fullScreenMode); - // addTest("AspectRatio", &GFXtests::aspectRatio); - // addTest("IconifyingWindow", &GFXtests::iconifyWindow); + addTest("FullScreenMode", &GFXtests::fullScreenMode); + addTest("AspectRatio", &GFXtests::aspectRatio); + addTest("IconifyingWindow", &GFXtests::iconifyWindow); // Mouse Layer tests (Palettes and movements) - // addTest("PalettizedCursors", &GFXtests::palettizedCursors); + addTest("PalettizedCursors", &GFXtests::palettizedCursors); // FIXME: need to fix it - // addTest("ScaledCursors", &GFXtests::scaledCursors); + addTest("ScaledCursors", &GFXtests::scaledCursors); // Effects - // addTest("shakingEffect", &GFXtests::shakingEffect); - // addTest("focusRectangle", &GFXtests::focusRectangle); + addTest("shakingEffect", &GFXtests::shakingEffect); + addTest("focusRectangle", &GFXtests::focusRectangle); // Overlay - // addTest("Overlays", &GFXtests::overlayGraphics); + addTest("Overlays", &GFXtests::overlayGraphics); // Specific Tests: addTest("Palette Rotation", &GFXtests::paletteRotation); @@ -97,7 +97,7 @@ void GFXtests::drawCursor(bool cursorPaletteDisabled, const char *gfxModeName, i // Uncommenting the next line and commenting the line after that would reproduce the crash // CursorMan.replaceCursor(buffer, 11, 11, 0, 0, 255, cursorTargetScale); - CursorMan.replaceCursor(buffer, 12, 13, 0, 0, 255, cursorTargetScale); + CursorMan.replaceCursor(buffer, 12, 12, 0, 0, 255, cursorTargetScale); CursorMan.showMouse(true); if (cursorPaletteDisabled) { @@ -110,20 +110,20 @@ void GFXtests::drawCursor(bool cursorPaletteDisabled, const char *gfxModeName, i g_system->updateScreen(); } -void rotatePalette(byte palette[], int size) { - // Ignore rotating black color, as that is background +void rotatePalette(byte *palette, int size) { + // Rotate the colors starting from address palette "size" times + // take a temporary palette color byte tColor[4] = {0}; - // save the first color in tColor - memcpy(tColor, &palette[4], 4 * sizeof(byte)); + // save first color in it. + memcpy(tColor, &palette[0], 4 * sizeof(byte)); // Move each color upward by 1 - for (int i = 1; i < size - 1; i++) { + for (int i = 0; i < size - 1; i++) { memcpy(&palette[i * 4], &palette[(i + 1) * 4], 4 * sizeof(byte)); } // Assign last color to tcolor memcpy(&palette[(size -1) * 4], tColor, 4 * sizeof(byte)); - g_system->setPalette(palette, 0, 10); } /** @@ -394,6 +394,13 @@ bool GFXtests::aspectRatio() { } g_system->delayMillis(500); + + if (Testsuite::handleInteractiveInput("This should definetely be your initial state?", "Yes, it is", "Nopes", kOptionRight)) { + // User selected incorrect mode + printf("LOG: switching back to initial state failed\n"); + passed = false; + } + Testsuite::clearScreen(); return passed; } @@ -435,6 +442,7 @@ bool GFXtests::palettizedCursors() { passed = false; } + Testsuite::clearScreen(); return passed; } @@ -570,7 +578,8 @@ bool GFXtests::scaledCursors() { printf("LOG: Switcing to initial state failed\n"); return false; } - + + Testsuite::clearScreen(); return true; } @@ -598,7 +607,6 @@ bool GFXtests::focusRectangle() { Testsuite::displayMessage("Testing : Setting and hiding Focus \n" "If this feature is implemented, the focus should be toggled between the two rectangles on the corners"); - Testsuite::clearScreen(); const Graphics::Font &font(*FontMan.getFontByUsage(Graphics::FontManager::kConsoleFont)); @@ -634,7 +642,8 @@ bool GFXtests::focusRectangle() { if (Testsuite::handleInteractiveInput("Did you noticed a variation in focus?", "Yes", "No", kOptionRight)) { printf("LOG: Focus Rectangle feature doesn't works. Check platform.\n"); } - + + Testsuite::clearScreen(); return true; } @@ -663,10 +672,15 @@ bool GFXtests::overlayGraphics() { printf("LOG: Overlay Rectangle feature doesn't works\n"); return false; } + + Testsuite::clearScreen(); return true; } bool GFXtests::paletteRotation() { + Common::Point pt(0, 10); + Testsuite::writeOnScreen("Rotating palettes, the rectangles should appear moving up!", pt); + byte palette[10 * 4] = {0, 0, 0, 0, 255, 255, 255, 0, 135, 48, 21, 0, @@ -686,7 +700,7 @@ bool GFXtests::paletteRotation() { // Draw 10 Rectangles, each of width 100 pixels and height 10 pixels byte buffer[10 * 100 * 10] = {0}; - for (int i = 0; i < 10; i++) { + for (int i = 2; i < 10; i++) { memset(buffer + i * 1000, i, 1000 * sizeof(byte)); } @@ -696,14 +710,16 @@ bool GFXtests::paletteRotation() { while (toRotate--) { g_system->updateScreen(); - g_system->delayMillis(300); - rotatePalette(palette, 10); + g_system->delayMillis(600); + rotatePalette(&palette[8], 8); + g_system->setPalette(palette, 0, 10); } - if(Testsuite::handleInteractiveInput("Did you saw palettes rotating?", "Yes", "No", kOptionRight)) { + if(Testsuite::handleInteractiveInput("Did you saw a rotation in colors of rectangles displayed on screen?", "Yes", "No", kOptionRight)) { return false; } + Testsuite::clearScreen(); return true; } @@ -711,17 +727,30 @@ bool GFXtests::pixelFormats() { Common::List pfList = g_system->getSupportedFormats(); Common::List::const_iterator iter = pfList.begin(); - Graphics::PixelFormat currPixelformat = g_system->getScreenFormat(); - printf("Current bpp: %d List size : %d\n",currPixelformat.bytesPerPixel, pfList.size()); + int numFormatsTested = 0; + int numPassed = 0; + bool numFailed = 0; + + printf("LOG: Testing Pixel Formats. Size of list : %d\n", pfList.size()); - while (iter != pfList.end()) { - printf("bpp : %d\n", (*iter).bytesPerPixel); + for (iter = pfList.begin(); iter != pfList.end(); iter++) { - // Switch to that pixelFormat + numFormatsTested++; + if (iter->bytesPerPixel == 1) { + // Palettes already tested + continue; + } else if (iter->bytesPerPixel > 2) { + printf("LOG: Can't test pixels with bpp > 2\n"); + continue; + } + + // Switch to that pixel Format g_system->beginGFXTransaction(); g_system->initSize(320, 200, &(*iter)); g_system->endGFXTransaction(); + Testsuite::clearScreen(true); + // Draw some nice gradients // Pick up some colors uint colors[6]; @@ -733,24 +762,41 @@ bool GFXtests::pixelFormats() { colors[4] = iter->RGBToColor(181, 126, 145); colors[5] = iter->RGBToColor(47, 78, 36); - // Draw some Rectangles, each of width 100 pixels and height 10 pixels - byte buffer[6 * 100 * 10] = {0}; - int indx; - for (int i = 0; i < ARRAYSIZE(colors); i++) { - indx = i * 1000; - for (int j = 0; j < 1000; j++) { - buffer[indx + j] = colors[i]; - } + Common::Point pt(0, 10); + char msg[100]; + // XXX: Can use snprintf? + snprintf(msg, sizeof(msg), "Testing Pixel Formats, %d of %d", numFormatsTested, pfList.size()); + Testsuite::writeOnScreen(msg, pt, true); + + // CopyRectToScreen could have been used, but that may involve writing code which + // already resides in graphics/surface.h + // So using Graphics::Surface + + Graphics::Surface *screen = g_system->lockScreen(); + + // Draw 6 rectangles centred at (50, 160), piled over one another + // each with color in colors[] + for (int i = 0; i < 6; i++) { + screen->fillRect(Common::Rect::center(160, 50 + i * 10, 100, 10), colors[i]); } - - g_system->copyRectToScreen(buffer, 100, 110, 70, 100, 60); + + g_system->unlockScreen(); g_system->updateScreen(); - - g_system->delayMillis(2000); - break; - iter++; + g_system->delayMillis(500); + + if(Testsuite::handleInteractiveInput("Were you able to notice the colored rectangles on the screen for this format?", "Yes", "No", kOptionLeft)) { + numPassed++; + } else { + numFailed++; + printf("LOG: Testing pixel format failed for format #%d on the list\n", numFormatsTested); + } } - + if (numFailed) { + printf("LOG: Pixel Format test: Failed : %d, Passed : %d, Ignored %d\n",numFailed, numPassed, numFormatsTested - (numPassed + numFailed)); + return false; + } + + Testsuite::clearScreen(); return true; } -- cgit v1.2.3 From 6e27ad3b2bdafce93a5743bdacb932b711bd7ef2 Mon Sep 17 00:00:00 2001 From: Neeraj Kumar Date: Fri, 25 Jun 2010 20:26:54 +0000 Subject: some more refinements to FS and GFX tests svn-id: r50286 --- engines/testbed/graphics.cpp | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'engines/testbed/graphics.cpp') diff --git a/engines/testbed/graphics.cpp b/engines/testbed/graphics.cpp index 79d73a0432..b97af6cce2 100644 --- a/engines/testbed/graphics.cpp +++ b/engines/testbed/graphics.cpp @@ -436,13 +436,14 @@ bool GFXtests::palettizedCursors() { printf("LOG: Couldn't use Game palette for rendering cursor\n"); passed = false; } - g_system->delayMillis(1000); if (!Testsuite::handleInteractiveInput("Did Cursor tests went as you were expecting?")) { passed = false; } Testsuite::clearScreen(); + // Done with cursors + CursorMan.popAllCursors(); return passed; } @@ -578,6 +579,9 @@ bool GFXtests::scaledCursors() { printf("LOG: Switcing to initial state failed\n"); return false; } + + // Done with cursors + CursorMan.popAllCursors(); Testsuite::clearScreen(); return true; @@ -651,16 +655,15 @@ bool GFXtests::overlayGraphics() { Graphics::PixelFormat pf = g_system->getOverlayFormat(); - OverlayColor buffer[20 * 40]; + OverlayColor buffer[50 * 100]; OverlayColor value = pf.RGBToColor(0, 255, 0); - for (int i = 0; i < 20 * 40; i++) { + for (int i = 0; i < 50 * 100; i++) { buffer[i] = value; } - // FIXME: Not Working. g_system->showOverlay(); - g_system->copyRectToOverlay(buffer, 40, 100, 100, 40, 20); + g_system->copyRectToOverlay(buffer, 100, 270, 175, 100, 50); g_system->updateScreen(); g_system->delayMillis(1000); @@ -762,7 +765,7 @@ bool GFXtests::pixelFormats() { colors[4] = iter->RGBToColor(181, 126, 145); colors[5] = iter->RGBToColor(47, 78, 36); - Common::Point pt(0, 10); + Common::Point pt(0, 170); char msg[100]; // XXX: Can use snprintf? snprintf(msg, sizeof(msg), "Testing Pixel Formats, %d of %d", numFormatsTested, pfList.size()); @@ -777,7 +780,7 @@ bool GFXtests::pixelFormats() { // Draw 6 rectangles centred at (50, 160), piled over one another // each with color in colors[] for (int i = 0; i < 6; i++) { - screen->fillRect(Common::Rect::center(160, 50 + i * 10, 100, 10), colors[i]); + screen->fillRect(Common::Rect::center(160, 20 + i * 10, 100, 10), colors[i]); } g_system->unlockScreen(); -- cgit v1.2.3 From 3cc204f461bc08c16b6c8a0920c432355b4a4d74 Mon Sep 17 00:00:00 2001 From: Neeraj Kumar Date: Sat, 26 Jun 2010 13:07:13 +0000 Subject: the ScummVM header included to all source files svn-id: r50320 --- engines/testbed/graphics.cpp | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'engines/testbed/graphics.cpp') diff --git a/engines/testbed/graphics.cpp b/engines/testbed/graphics.cpp index b97af6cce2..e80fb0d4b2 100644 --- a/engines/testbed/graphics.cpp +++ b/engines/testbed/graphics.cpp @@ -1,3 +1,27 @@ +/* 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 "common/events.h" #include "common/list.h" #include "common/random.h" -- cgit v1.2.3 From 68d691bc3e5ee711daad2979c7db325c16e4c1f0 Mon Sep 17 00:00:00 2001 From: Neeraj Kumar Date: Tue, 29 Jun 2010 22:46:56 +0000 Subject: removed all printfs, added logging feature in form of logPrintf svn-id: r50512 --- engines/testbed/graphics.cpp | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) (limited to 'engines/testbed/graphics.cpp') diff --git a/engines/testbed/graphics.cpp b/engines/testbed/graphics.cpp index e80fb0d4b2..51f4030dd0 100644 --- a/engines/testbed/graphics.cpp +++ b/engines/testbed/graphics.cpp @@ -311,9 +311,9 @@ bool GFXtests::fullScreenMode() { g_system->delayMillis(1000); if (isFeatureEnabled) { - printf("LOG: Current Mode is Fullsecreen\n"); + Testsuite::logDetailedPrintf("Current Mode is Fullsecreen\n"); } else { - printf("LOG: Current Mode is Windowed\n"); + Testsuite::logDetailedPrintf("Current Mode is Windowed\n"); } prompt = " Which mode do you see currently ? "; @@ -321,7 +321,7 @@ bool GFXtests::fullScreenMode() { if (!Testsuite::handleInteractiveInput(prompt, "Fullscreen", "Windowed", shouldSelect)) { // User selected incorrect current state passed = false; - printf("LOG: g_system->getFeatureState() failed\n"); + Testsuite::logDetailedPrintf("g_system->getFeatureState() failed\n"); } g_system->beginGFXTransaction(); @@ -339,7 +339,7 @@ bool GFXtests::fullScreenMode() { if (!Testsuite::handleInteractiveInput(prompt, "Fullscreen", "Windowed", shouldSelect)) { // User selected incorrect mode passed = false; - printf("LOG: g_system->setFeatureState() failed\n"); + Testsuite::logDetailedPrintf("g_system->setFeatureState() failed\n"); } g_system->beginGFXTransaction(); @@ -352,7 +352,7 @@ bool GFXtests::fullScreenMode() { if (!Testsuite::handleInteractiveInput(prompt, "Yes, it is", "Nopes", shouldSelect)) { // User selected incorrect mode - printf("LOG: switching back to initial state failed\n"); + Testsuite::logDetailedPrintf("switching back to initial state failed\n"); passed = false; } @@ -393,7 +393,7 @@ bool GFXtests::aspectRatio() { if (!Testsuite::handleInteractiveInput(prompt, "Circle", "Ellipse", shouldSelect)) { // User selected incorrect option passed = false; - printf("LOG: Aspect Ratio Correction failed\n"); + Testsuite::logDetailedPrintf("Aspect Ratio Correction failed\n"); } g_system->beginGFXTransaction(); @@ -407,7 +407,7 @@ bool GFXtests::aspectRatio() { if (!Testsuite::handleInteractiveInput(prompt, "Circle", "Ellipse", shouldSelect)) { // User selected incorrect option passed = false; - printf("LOG: Aspect Ratio Correction failed\n"); + Testsuite::logDetailedPrintf("Aspect Ratio Correction failed\n"); } g_system->beginGFXTransaction(); @@ -421,7 +421,7 @@ bool GFXtests::aspectRatio() { if (Testsuite::handleInteractiveInput("This should definetely be your initial state?", "Yes, it is", "Nopes", kOptionRight)) { // User selected incorrect mode - printf("LOG: switching back to initial state failed\n"); + Testsuite::logDetailedPrintf("Switching back to initial state failed\n"); passed = false; } @@ -448,7 +448,7 @@ bool GFXtests::palettizedCursors() { mouseMovements(); if (Testsuite::handleInteractiveInput("Which color did the cursor appeared to you?", "Yellow", "Any other", kOptionRight)) { - printf("LOG: Couldn't use cursor palette for rendering cursor\n"); + Testsuite::logDetailedPrintf("Couldn't use cursor palette for rendering cursor\n"); passed = false; } @@ -457,7 +457,7 @@ bool GFXtests::palettizedCursors() { setupMouseLoop(true); if (Testsuite::handleInteractiveInput("Which color did the cursor appeared to you?", "Red", "Any other", kOptionRight)) { - printf("LOG: Couldn't use Game palette for rendering cursor\n"); + Testsuite::logDetailedPrintf("Couldn't use Game palette for rendering cursor\n"); passed = false; } @@ -586,7 +586,7 @@ bool GFXtests::scaledCursors() { Testsuite::clearScreen(); } else { - printf("LOG: Switching to graphics mode %s failed\n", gfxMode->name); + Testsuite::logDetailedPrintf("Switching to graphics mode %s failed\n", gfxMode->name); return false; } gfxMode++; @@ -600,7 +600,7 @@ bool GFXtests::scaledCursors() { OSystem::TransactionError gfxError = g_system->endGFXTransaction(); if (gfxError != OSystem::kTransactionSuccess || !isGFXModeSet) { - printf("LOG: Switcing to initial state failed\n"); + Testsuite::logDetailedPrintf("Switcing to initial state failed\n"); return false; } @@ -624,7 +624,7 @@ bool GFXtests::shakingEffect() { g_system->delayMillis(1500); if (Testsuite::handleInteractiveInput("Did the test worked as you were expecting?", "Yes", "No", kOptionRight)) { - printf("LOG: Shaking Effect didn't worked"); + Testsuite::logDetailedPrintf("Shaking Effect didn't worked"); return false; } Testsuite::clearScreen(); @@ -668,7 +668,7 @@ bool GFXtests::focusRectangle() { g_system->clearFocusRectangle(); if (Testsuite::handleInteractiveInput("Did you noticed a variation in focus?", "Yes", "No", kOptionRight)) { - printf("LOG: Focus Rectangle feature doesn't works. Check platform.\n"); + Testsuite::logDetailedPrintf("Focus Rectangle feature doesn't works. Check platform.\n"); } Testsuite::clearScreen(); @@ -696,7 +696,7 @@ bool GFXtests::overlayGraphics() { g_system->updateScreen(); if (Testsuite::handleInteractiveInput("Did you see a green overlayed rectangle?", "Yes", "No", kOptionRight)) { - printf("LOG: Overlay Rectangle feature doesn't works\n"); + Testsuite::logDetailedPrintf("Overlay Rectangle feature doesn't works\n"); return false; } @@ -758,7 +758,7 @@ bool GFXtests::pixelFormats() { int numPassed = 0; bool numFailed = 0; - printf("LOG: Testing Pixel Formats. Size of list : %d\n", pfList.size()); + Testsuite::logDetailedPrintf("Testing Pixel Formats. Size of list : %d\n", pfList.size()); for (iter = pfList.begin(); iter != pfList.end(); iter++) { @@ -767,7 +767,7 @@ bool GFXtests::pixelFormats() { // Palettes already tested continue; } else if (iter->bytesPerPixel > 2) { - printf("LOG: Can't test pixels with bpp > 2\n"); + Testsuite::logDetailedPrintf("Can't test pixels with bpp > 2\n"); continue; } @@ -815,11 +815,11 @@ bool GFXtests::pixelFormats() { numPassed++; } else { numFailed++; - printf("LOG: Testing pixel format failed for format #%d on the list\n", numFormatsTested); + Testsuite::logDetailedPrintf("Testing pixel format failed for format #%d on the list\n", numFormatsTested); } } if (numFailed) { - printf("LOG: Pixel Format test: Failed : %d, Passed : %d, Ignored %d\n",numFailed, numPassed, numFormatsTested - (numPassed + numFailed)); + Testsuite::logDetailedPrintf("Pixel Format test: Failed : %d, Passed : %d, Ignored %d\n",numFailed, numPassed, numFormatsTested - (numPassed + numFailed)); return false; } -- cgit v1.2.3 From f470baa3144115365881a64bbe9bd82ba0e2f506 Mon Sep 17 00:00:00 2001 From: Neeraj Kumar Date: Mon, 5 Jul 2010 21:29:15 +0000 Subject: made Quit and RTL features working svn-id: r50711 --- engines/testbed/graphics.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'engines/testbed/graphics.cpp') diff --git a/engines/testbed/graphics.cpp b/engines/testbed/graphics.cpp index 51f4030dd0..a140d0ca14 100644 --- a/engines/testbed/graphics.cpp +++ b/engines/testbed/graphics.cpp @@ -26,6 +26,8 @@ #include "common/list.h" #include "common/random.h" +#include "engines/engine.h" + #include "testbed/graphics.h" #include "testbed/testsuite.h" @@ -190,7 +192,10 @@ void GFXtests::setupMouseLoop(bool disableCursorPalette, const char *gfxModeName while (!quitLoop) { while (eventMan->pollEvent(event)) { - + if (Engine::shouldQuit()) { + // Quit directly + return; + } if (lastRedraw + waitTime < g_system->getMillis()) { g_system->updateScreen(); lastRedraw = g_system->getMillis(); @@ -207,7 +212,7 @@ void GFXtests::setupMouseLoop(bool disableCursorPalette, const char *gfxModeName g_system->delayMillis(1000); break; default: - ;// Ignore any other event + break;// Ignore handling any other event } } -- cgit v1.2.3 From deb2c189c757b7d3520623a92b7769751eed4717 Mon Sep 17 00:00:00 2001 From: Neeraj Kumar Date: Mon, 5 Jul 2010 23:02:43 +0000 Subject: added code to revert back to 8bpp from other formats svn-id: r50714 --- engines/testbed/graphics.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'engines/testbed/graphics.cpp') diff --git a/engines/testbed/graphics.cpp b/engines/testbed/graphics.cpp index a140d0ca14..44d2b00cd0 100644 --- a/engines/testbed/graphics.cpp +++ b/engines/testbed/graphics.cpp @@ -823,12 +823,21 @@ bool GFXtests::pixelFormats() { Testsuite::logDetailedPrintf("Testing pixel format failed for format #%d on the list\n", numFormatsTested); } } + + // Revert back to 8bpp + g_system->beginGFXTransaction(); + g_system->initSize(320, 200); + g_system->endGFXTransaction(); + GFXTestSuite::setCustomColor(255, 0, 0); + initMousePalette(); + Testsuite::clearScreen(); + + if (numFailed) { Testsuite::logDetailedPrintf("Pixel Format test: Failed : %d, Passed : %d, Ignored %d\n",numFailed, numPassed, numFormatsTested - (numPassed + numFailed)); return false; } - Testsuite::clearScreen(); return true; } -- cgit v1.2.3 From f145391abb1823489ff03e200c50926b5aa97006 Mon Sep 17 00:00:00 2001 From: Neeraj Kumar Date: Tue, 6 Jul 2010 16:30:42 +0000 Subject: some minor fixes in cursor handling svn-id: r50726 --- engines/testbed/graphics.cpp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'engines/testbed/graphics.cpp') diff --git a/engines/testbed/graphics.cpp b/engines/testbed/graphics.cpp index 44d2b00cd0..821237b945 100644 --- a/engines/testbed/graphics.cpp +++ b/engines/testbed/graphics.cpp @@ -61,7 +61,7 @@ GFXTestSuite::GFXTestSuite() { // Mouse Layer tests (Palettes and movements) addTest("PalettizedCursors", &GFXtests::palettizedCursors); - // FIXME: need to fix it + // FIXME: Scaled cursor crsh with odd dimmensions addTest("ScaledCursors", &GFXtests::scaledCursors); // Effects @@ -471,8 +471,8 @@ bool GFXtests::palettizedCursors() { } Testsuite::clearScreen(); - // Done with cursors - CursorMan.popAllCursors(); + // Done with cursors, make them invisible, any other test the could simply make it visible + CursorMan.showMouse(false); return passed; } @@ -609,9 +609,8 @@ bool GFXtests::scaledCursors() { return false; } - // Done with cursors - CursorMan.popAllCursors(); - + // Done with cursors, Make them invisible, any other test may enable and use it. + CursorMan.showMouse(false); Testsuite::clearScreen(); return true; } -- cgit v1.2.3 From 00fc80b8d59cacdc93a71e08cb8240392f245e34 Mon Sep 17 00:00:00 2001 From: Neeraj Kumar Date: Wed, 7 Jul 2010 20:31:28 +0000 Subject: Added code to draw rainbow palette using HSV and converting it to RGB svn-id: r50739 --- engines/testbed/graphics.cpp | 120 ++++++++++++++++++++++++++++++++++--------- 1 file changed, 97 insertions(+), 23 deletions(-) (limited to 'engines/testbed/graphics.cpp') diff --git a/engines/testbed/graphics.cpp b/engines/testbed/graphics.cpp index 821237b945..46b1b0e4e4 100644 --- a/engines/testbed/graphics.cpp +++ b/engines/testbed/graphics.cpp @@ -38,7 +38,7 @@ namespace Testbed { -byte GFXTestSuite::_palette[3 * 4] = {0, 0, 0, 0, 255, 255, 255, 0, 255, 255, 255, 0}; +byte GFXTestSuite::_palette[256 * 4] = {0, 0, 0, 0, 255, 255, 255, 0, 255, 255, 255, 0}; GFXTestSuite::GFXTestSuite() { // Initialize color palettes @@ -85,7 +85,7 @@ void GFXTestSuite::setCustomColor(uint r, uint g, uint b) { _palette[8] = r; _palette[9] = g; _palette[10] = b; - g_system->setPalette(_palette, 0, 3); + g_system->setPalette(_palette, 0, 256); } // Helper functions used by GFX tests @@ -102,6 +102,69 @@ void GFXtests::initMousePalette() { } +void GFXtests::HSVtoRGB(int& rComp, int& gComp, int& bComp, int hue, int sat, int val) { + + float r = rComp; + float g = gComp; + float b = bComp; + + float h = hue * (360 / 254.0); // two colors are left for bg and fg + float s = sat; + float v = val; + + int i; + float f, p, q, t; + + if (s == 0) { + r = g = b = v * 255; + return; + } + + h /= 60; + i = (int) h; + f = h - i; + p = v * (1 - s); + q = v * (1 - s * f); + t = v * (1 - s * (1 - f)); + + switch (i) { + case 0: + r = v; + g = t; + b = p; + break; + case 1: + r = q; + g = v; + b = p; + break; + case 2: + r = p; + g = v; + b = t; + break; + case 3: + r = p; + g = q; + b = v; + break; + case 4: + r = t; + g = p; + b = v; + break; + default: + r = v; + g = p; + b = q; + break; + } + + rComp = r * 255; + gComp = g * 255; + bComp = b * 255; +} + void GFXtests::drawCursor(bool cursorPaletteDisabled, const char *gfxModeName, int cursorTargetScale) { // Buffer initialized with yellow color @@ -712,38 +775,49 @@ bool GFXtests::paletteRotation() { Common::Point pt(0, 10); Testsuite::writeOnScreen("Rotating palettes, the rectangles should appear moving up!", pt); - byte palette[10 * 4] = {0, 0, 0, 0, - 255, 255, 255, 0, - 135, 48, 21, 0, - 205, 190, 87, 0, - 0, 32, 64, 0, - 181, 126, 145, 0, - 47, 78, 36, 0, - 185, 115, 20, 0, - 160, 164, 137, 0, - 43, 52, 0, 0}; // 10 colors : B, W and 8 random + // Use 256 colors + byte palette[256 * 4] = {0, 0, 0, 0, + 255, 255, 255, 0}; - Common::RandomSource rs; - - // Initialize this palette randomly - g_system->setPalette(palette, 0, 10); + int r, g, b; + int colIndx; - // Draw 10 Rectangles, each of width 100 pixels and height 10 pixels - byte buffer[10 * 100 * 10] = {0}; + for (int i = 2; i < 256; i++) { + HSVtoRGB(r, g, b, i - 2, 1, 1); + colIndx = i * 4; + palette[colIndx] = r; + palette[colIndx + 1] = g; + palette[colIndx + 2] = b; + } - for (int i = 2; i < 10; i++) { - memset(buffer + i * 1000, i, 1000 * sizeof(byte)); + // Initialize this palette. + g_system->setPalette(palette, 0, 256); + + // Draw 254 Rectangles, each 1 pixel wide and 10 pixels long + byte buffer[254 * 10] = {0}; + + for (int i = 0; i < 10; i++) { + for (int j = 0; j < 254; j++) { + buffer[i * 256 + j] = j + 2; + } } - g_system->copyRectToScreen(buffer, 100, 110, 50, 100, 100); + g_system->copyRectToScreen(buffer, 256, 22, 50, 256, 10); + g_system->updateScreen(); + g_system->delayMillis(2000); + + // Reset initial palettes + GFXTestSuite::setCustomColor(255, 0, 0); + Testsuite::clearScreen(); int toRotate = 10; while (toRotate--) { g_system->updateScreen(); g_system->delayMillis(600); - rotatePalette(&palette[8], 8); - g_system->setPalette(palette, 0, 10); + // FIXME : fix rotation + // rotatePalette(&palette[8], 254); + // g_system->setPalette(palette, 0, 256); } if(Testsuite::handleInteractiveInput("Did you saw a rotation in colors of rectangles displayed on screen?", "Yes", "No", kOptionRight)) { -- cgit v1.2.3 From 71f0f1b25164dcfb8793cbd28f158605a8dc70f4 Mon Sep 17 00:00:00 2001 From: Neeraj Kumar Date: Wed, 7 Jul 2010 20:40:54 +0000 Subject: commented out rotation as of now, avoids 6s delay which shows blank svn-id: r50740 --- engines/testbed/graphics.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'engines/testbed/graphics.cpp') diff --git a/engines/testbed/graphics.cpp b/engines/testbed/graphics.cpp index 46b1b0e4e4..ee95fce08d 100644 --- a/engines/testbed/graphics.cpp +++ b/engines/testbed/graphics.cpp @@ -814,8 +814,9 @@ bool GFXtests::paletteRotation() { while (toRotate--) { g_system->updateScreen(); - g_system->delayMillis(600); + // XXX: disabling rotations as of now, as it makes 6s delay (will fix it tommorrow) // FIXME : fix rotation + // g_system->delayMillis(600); // rotatePalette(&palette[8], 254); // g_system->setPalette(palette, 0, 256); } -- cgit v1.2.3 From 333f704513aa59e9d92cae66a8db0d8235975175 Mon Sep 17 00:00:00 2001 From: Neeraj Kumar Date: Thu, 8 Jul 2010 20:30:11 +0000 Subject: implemented rainbow palette rotation svn-id: r50748 --- engines/testbed/graphics.cpp | 56 +++++++++++++++++++++++++++++++------------- 1 file changed, 40 insertions(+), 16 deletions(-) (limited to 'engines/testbed/graphics.cpp') diff --git a/engines/testbed/graphics.cpp b/engines/testbed/graphics.cpp index ee95fce08d..fbce3cf5a5 100644 --- a/engines/testbed/graphics.cpp +++ b/engines/testbed/graphics.cpp @@ -73,7 +73,7 @@ GFXTestSuite::GFXTestSuite() { // Specific Tests: addTest("Palette Rotation", &GFXtests::paletteRotation); - addTest("Pixel Formats", &GFXtests::pixelFormats); + //addTest("Pixel Formats", &GFXtests::pixelFormats); } @@ -773,7 +773,7 @@ bool GFXtests::overlayGraphics() { bool GFXtests::paletteRotation() { Common::Point pt(0, 10); - Testsuite::writeOnScreen("Rotating palettes, the rectangles should appear moving up!", pt); + Testsuite::writeOnScreen("Rotating palettes, palettes rotate towards left, click to stop!", pt); // Use 256 colors byte palette[256 * 4] = {0, 0, 0, 0, @@ -794,32 +794,56 @@ bool GFXtests::paletteRotation() { g_system->setPalette(palette, 0, 256); // Draw 254 Rectangles, each 1 pixel wide and 10 pixels long - byte buffer[254 * 10] = {0}; + // one for 0-255 color range other for 0-127-255 range + byte buffer[254 * 30] = {0}; - for (int i = 0; i < 10; i++) { + for (int i = 0; i < 30; i++) { for (int j = 0; j < 254; j++) { - buffer[i * 256 + j] = j + 2; + if (i < 10) { + buffer[i * 256 + j] = j + 2; + } else if (i < 20) { + buffer[i * 256 + j] = 0; + } else { + buffer[i * 256 + j] = ((j + 127) % 254) + 2; + } } } - g_system->copyRectToScreen(buffer, 256, 22, 50, 256, 10); + g_system->copyRectToScreen(buffer, 256, 22, 50, 256, 30); g_system->updateScreen(); - g_system->delayMillis(2000); + g_system->delayMillis(1000); // Reset initial palettes - GFXTestSuite::setCustomColor(255, 0, 0); - Testsuite::clearScreen(); + // GFXTestSuite::setCustomColor(255, 0, 0); + // Testsuite::clearScreen(); - int toRotate = 10; + bool toRotate = true; + Common::Event event; + CursorMan.showMouse(true); - while (toRotate--) { + while (toRotate) { + while (g_system->getEventManager()->pollEvent(event)) { + if (event.type == Common::EVENT_LBUTTONDOWN || event.type == Common::EVENT_RBUTTONDOWN) { + toRotate = false; + } + } + + /*for (int i = 2; i < 256; i++) { + debug("Palette: (%d %d %d) #", palette[i*4], palette[i*4+1], palette[i*4+2]); + }*/ + + rotatePalette(&palette[8], 254); + + /*for (int i = 2; i < 256; i++) { + debug("Palette: (%d %d %d) #", palette[i*4], palette[i*4+1], palette[i*4+2]); + }*/ + + g_system->delayMillis(10); + g_system->setPalette(palette, 2, 254); g_system->updateScreen(); - // XXX: disabling rotations as of now, as it makes 6s delay (will fix it tommorrow) - // FIXME : fix rotation - // g_system->delayMillis(600); - // rotatePalette(&palette[8], 254); - // g_system->setPalette(palette, 0, 256); } + + CursorMan.showMouse(false); if(Testsuite::handleInteractiveInput("Did you saw a rotation in colors of rectangles displayed on screen?", "Yes", "No", kOptionRight)) { return false; -- cgit v1.2.3 From d3c42b71ba2b12e3dd7877ec1e28fcaedc5f6a6c Mon Sep 17 00:00:00 2001 From: Neeraj Kumar Date: Thu, 8 Jul 2010 20:35:05 +0000 Subject: restore initial palettes when done with rotation svn-id: r50749 --- engines/testbed/graphics.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'engines/testbed/graphics.cpp') diff --git a/engines/testbed/graphics.cpp b/engines/testbed/graphics.cpp index fbce3cf5a5..2c820fbc26 100644 --- a/engines/testbed/graphics.cpp +++ b/engines/testbed/graphics.cpp @@ -813,9 +813,6 @@ bool GFXtests::paletteRotation() { g_system->updateScreen(); g_system->delayMillis(1000); - // Reset initial palettes - // GFXTestSuite::setCustomColor(255, 0, 0); - // Testsuite::clearScreen(); bool toRotate = true; Common::Event event; @@ -844,6 +841,9 @@ bool GFXtests::paletteRotation() { } CursorMan.showMouse(false); + // Reset initial palettes + GFXTestSuite::setCustomColor(255, 0, 0); + Testsuite::clearScreen(); if(Testsuite::handleInteractiveInput("Did you saw a rotation in colors of rectangles displayed on screen?", "Yes", "No", kOptionRight)) { return false; -- cgit v1.2.3 From f9c03dc8db9a745d10e628f778cb4cad0d6f6a55 Mon Sep 17 00:00:00 2001 From: Neeraj Kumar Date: Sun, 11 Jul 2010 06:48:28 +0000 Subject: a correction in palette rotations svn-id: r50797 --- engines/testbed/graphics.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'engines/testbed/graphics.cpp') diff --git a/engines/testbed/graphics.cpp b/engines/testbed/graphics.cpp index 2c820fbc26..c70f6f5726 100644 --- a/engines/testbed/graphics.cpp +++ b/engines/testbed/graphics.cpp @@ -800,16 +800,16 @@ bool GFXtests::paletteRotation() { for (int i = 0; i < 30; i++) { for (int j = 0; j < 254; j++) { if (i < 10) { - buffer[i * 256 + j] = j + 2; + buffer[i * 254 + j] = j + 2; } else if (i < 20) { - buffer[i * 256 + j] = 0; + buffer[i * 254 + j] = 0; } else { - buffer[i * 256 + j] = ((j + 127) % 254) + 2; + buffer[i * 254 + j] = ((j + 127) % 254) + 2; } } } - g_system->copyRectToScreen(buffer, 256, 22, 50, 256, 30); + g_system->copyRectToScreen(buffer, 254, 22, 50, 254, 30); g_system->updateScreen(); g_system->delayMillis(1000); @@ -836,7 +836,7 @@ bool GFXtests::paletteRotation() { }*/ g_system->delayMillis(10); - g_system->setPalette(palette, 2, 254); + g_system->setPalette(palette, 0, 256); g_system->updateScreen(); } -- cgit v1.2.3 From 570560e9b5f1b07b20111d58593bbf2f6251bf61 Mon Sep 17 00:00:00 2001 From: Neeraj Kumar Date: Sun, 11 Jul 2010 16:50:18 +0000 Subject: improved the scaling test to have a rectangle of estimated size of scaled cursor the scaled cursor should entirely cover that estimated rectangle svn-id: r50802 --- engines/testbed/graphics.cpp | 62 +++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 58 insertions(+), 4 deletions(-) (limited to 'engines/testbed/graphics.cpp') diff --git a/engines/testbed/graphics.cpp b/engines/testbed/graphics.cpp index c70f6f5726..8380de496f 100644 --- a/engines/testbed/graphics.cpp +++ b/engines/testbed/graphics.cpp @@ -102,6 +102,28 @@ void GFXtests::initMousePalette() { } +Common::Rect GFXtests::computeSize(Common::Rect &cursorRect, int scalingFactor, int cursorTargetScale) { + if (cursorTargetScale == 1 || scalingFactor == 1) { + // Game data and cursor would be scaled equally. + // so dimensions would be same. + return Common::Rect(cursorRect.width(), cursorRect.height()); + } + + if (scalingFactor == 2) { + // Game data is scaled by 2, cursor is said to be scaled by 2 or 3. so it wud not be scaled any further + // So a w/2 x h/2 rectangle when scaled would match the cursor + return Common::Rect(cursorRect.width() / 2, cursorRect.height() / 2); + } + + if (scalingFactor == 3) { + // Cursor traget scale is 2 or 3. + return Common::Rect((cursorRect.width() / cursorTargetScale), (cursorRect.height() / cursorTargetScale)); + } else { + Testsuite::logPrintf("Unsupported scaler %dx\n", scalingFactor); + return Common::Rect(); + } +} + void GFXtests::HSVtoRGB(int& rComp, int& gComp, int& bComp, int hue, int sat, int val) { float r = rComp; @@ -165,11 +187,14 @@ void GFXtests::HSVtoRGB(int& rComp, int& gComp, int& bComp, int hue, int sat, in bComp = b * 255; } -void GFXtests::drawCursor(bool cursorPaletteDisabled, const char *gfxModeName, int cursorTargetScale) { +Common::Rect GFXtests::drawCursor(bool cursorPaletteDisabled, const char *gfxModeName, int cursorTargetScale) { // Buffer initialized with yellow color byte buffer[500]; memset(buffer, 2, sizeof(buffer)); + + int cursorWidth = 12; + int cursorHeight = 12; /* Disable HotSpot highlighting as of now @@ -197,6 +222,7 @@ void GFXtests::drawCursor(bool cursorPaletteDisabled, const char *gfxModeName, i } g_system->updateScreen(); + return Common::Rect(0, 0, cursorWidth, cursorHeight); } void rotatePalette(byte *palette, int size) { @@ -222,10 +248,11 @@ void GFXtests::setupMouseLoop(bool disableCursorPalette, const char *gfxModeName bool isFeaturePresent; isFeaturePresent = g_system->hasFeature(OSystem::kFeatureCursorHasPalette); + Common::Rect cursorRect; if (isFeaturePresent) { - GFXtests::drawCursor(disableCursorPalette, gfxModeName, cursorTargetScale); + cursorRect = GFXtests::drawCursor(disableCursorPalette, gfxModeName, cursorTargetScale); Common::EventManager *eventMan = g_system->getEventManager(); Common::Event event; @@ -248,9 +275,35 @@ void GFXtests::setupMouseLoop(bool disableCursorPalette, const char *gfxModeName char cScale = cursorTargetScale + '0'; info += "Cursor scale: "; info += cScale; + + Common::String gfxScalarMode(gfxModeName); + Common::Rect estimatedCursorRect; - if (!Common::String(gfxModeName).equals("")) { + if (!gfxScalarMode.equals("")) { + + if (gfxScalarMode.contains("1x")) { + estimatedCursorRect = computeSize(cursorRect, 1, cursorTargetScale); + } else if (gfxScalarMode.contains("2x")) { + estimatedCursorRect = computeSize(cursorRect, 2, cursorTargetScale); + } else if (gfxScalarMode.contains("3x")){ + estimatedCursorRect = computeSize(cursorRect, 3, cursorTargetScale); + } else { + // If unable to detect scaler, default to 2 + Testsuite::writeOnScreen("Unable to detect scaling factor, assuming 2x", Common::Point(0, 5)); + estimatedCursorRect = computeSize(cursorRect, 2, cursorTargetScale); + } Testsuite::writeOnScreen(info, Common::Point(0, 120)); + + // Move cursor to (20, 20) + g_system->warpMouse(20, 20); + // Move estimated rect to (20, 20) + estimatedCursorRect.moveTo(20, 20); + + Graphics::Surface *screen = g_system->lockScreen(); + GFXTestSuite::setCustomColor(255, 0, 0); + screen->fillRect(estimatedCursorRect, 2); + g_system->unlockScreen(); + g_system->updateScreen(); } while (!quitLoop) { @@ -620,7 +673,8 @@ bool GFXtests::iconifyWindow() { bool GFXtests::scaledCursors() { Testsuite::displayMessage("Testing : Scaled cursors\n" - "Here every graphics mode is tried with a cursorTargetScale of 1,2 and 3" + "Here every graphics mode is tried with a cursorTargetScale of 1,2 and 3.\n" + "The expected cursor size is drawn as a rectangle, the cursor should entirely cover that rectangle.\n" "This may take time, You may skip the later scalers and just examine the first three i.e 1x,2x and 3x"); int maxLimit = 1000; -- cgit v1.2.3 From 0b3201e5e3449f90187938e5dd699535fdaadeb8 Mon Sep 17 00:00:00 2001 From: Jordi Vilalta Prat Date: Wed, 14 Jul 2010 14:12:42 +0000 Subject: Whitespace cleanup (mainly spaces and tabs at the end of line) svn-id: r50885 --- engines/testbed/graphics.cpp | 216 +++++++++++++++++++++---------------------- 1 file changed, 108 insertions(+), 108 deletions(-) (limited to 'engines/testbed/graphics.cpp') diff --git a/engines/testbed/graphics.cpp b/engines/testbed/graphics.cpp index 8380de496f..eb3f6e376d 100644 --- a/engines/testbed/graphics.cpp +++ b/engines/testbed/graphics.cpp @@ -45,25 +45,25 @@ GFXTestSuite::GFXTestSuite() { // The fourth field is for alpha channel which is unused // Assuming 8bpp as of now g_system->setPalette(_palette, 0, 3); - + // Init Mouse Palette (White-black-yellow) GFXtests::initMousePalette(); - + // Add tests here - + // Blitting buffer on screen addTest("BlitBitmaps", &GFXtests::copyRectToScreen); - + // GFX Transcations addTest("FullScreenMode", &GFXtests::fullScreenMode); addTest("AspectRatio", &GFXtests::aspectRatio); addTest("IconifyingWindow", &GFXtests::iconifyWindow); - + // Mouse Layer tests (Palettes and movements) addTest("PalettizedCursors", &GFXtests::palettizedCursors); // FIXME: Scaled cursor crsh with odd dimmensions addTest("ScaledCursors", &GFXtests::scaledCursors); - + // Effects addTest("shakingEffect", &GFXtests::shakingEffect); addTest("focusRectangle", &GFXtests::focusRectangle); @@ -74,7 +74,7 @@ GFXTestSuite::GFXTestSuite() { // Specific Tests: addTest("Palette Rotation", &GFXtests::paletteRotation); //addTest("Pixel Formats", &GFXtests::pixelFormats); - + } const char *GFXTestSuite::getName() const { @@ -82,7 +82,7 @@ const char *GFXTestSuite::getName() const { } void GFXTestSuite::setCustomColor(uint r, uint g, uint b) { - _palette[8] = r; + _palette[8] = r; _palette[9] = g; _palette[10] = b; g_system->setPalette(_palette, 0, 256); @@ -92,14 +92,14 @@ void GFXTestSuite::setCustomColor(uint r, uint g, uint b) { void GFXtests::initMousePalette() { byte palette[3 * 4]; // Black, white and yellow - + palette[0] = palette[1] = palette[2] = 0; palette[4] = palette[5] = palette[6] = 255; palette[8] = palette[9] = 255; palette[10] = 0; - + CursorMan.replaceCursorPalette(palette, 0, 3); - + } Common::Rect GFXtests::computeSize(Common::Rect &cursorRect, int scalingFactor, int cursorTargetScale) { @@ -114,7 +114,7 @@ Common::Rect GFXtests::computeSize(Common::Rect &cursorRect, int scalingFactor, // So a w/2 x h/2 rectangle when scaled would match the cursor return Common::Rect(cursorRect.width() / 2, cursorRect.height() / 2); } - + if (scalingFactor == 3) { // Cursor traget scale is 2 or 3. return Common::Rect((cursorRect.width() / cursorTargetScale), (cursorRect.height() / cursorTargetScale)); @@ -125,7 +125,7 @@ Common::Rect GFXtests::computeSize(Common::Rect &cursorRect, int scalingFactor, } void GFXtests::HSVtoRGB(int& rComp, int& gComp, int& bComp, int hue, int sat, int val) { - + float r = rComp; float g = gComp; float b = bComp; @@ -142,7 +142,7 @@ void GFXtests::HSVtoRGB(int& rComp, int& gComp, int& bComp, int hue, int sat, in return; } - h /= 60; + h /= 60; i = (int) h; f = h - i; p = v * (1 - s); @@ -175,7 +175,7 @@ void GFXtests::HSVtoRGB(int& rComp, int& gComp, int& bComp, int hue, int sat, in g = p; b = v; break; - default: + default: r = v; g = p; b = q; @@ -187,7 +187,7 @@ void GFXtests::HSVtoRGB(int& rComp, int& gComp, int& bComp, int hue, int sat, in bComp = b * 255; } -Common::Rect GFXtests::drawCursor(bool cursorPaletteDisabled, const char *gfxModeName, int cursorTargetScale) { +Common::Rect GFXtests::drawCursor(bool cursorPaletteDisabled, const char *gfxModeName, int cursorTargetScale) { // Buffer initialized with yellow color byte buffer[500]; @@ -195,9 +195,9 @@ Common::Rect GFXtests::drawCursor(bool cursorPaletteDisabled, const char *gfxMod int cursorWidth = 12; int cursorHeight = 12; - + /* Disable HotSpot highlighting as of now - + // Paint the cursor with yellow, except the hotspot for (int i = 0; i < 16; i++) { for (int j = 0; j < 16; j++) { @@ -213,7 +213,7 @@ Common::Rect GFXtests::drawCursor(bool cursorPaletteDisabled, const char *gfxMod // CursorMan.replaceCursor(buffer, 11, 11, 0, 0, 255, cursorTargetScale); CursorMan.replaceCursor(buffer, 12, 12, 0, 0, 255, cursorTargetScale); CursorMan.showMouse(true); - + if (cursorPaletteDisabled) { CursorMan.disableCursorPalette(true); } else { @@ -227,7 +227,7 @@ Common::Rect GFXtests::drawCursor(bool cursorPaletteDisabled, const char *gfxMod void rotatePalette(byte *palette, int size) { // Rotate the colors starting from address palette "size" times - + // take a temporary palette color byte tColor[4] = {0}; // save first color in it. @@ -251,7 +251,7 @@ void GFXtests::setupMouseLoop(bool disableCursorPalette, const char *gfxModeName Common::Rect cursorRect; if (isFeaturePresent) { - + cursorRect = GFXtests::drawCursor(disableCursorPalette, gfxModeName, cursorTargetScale); Common::EventManager *eventMan = g_system->getEventManager(); @@ -260,14 +260,14 @@ void GFXtests::setupMouseLoop(bool disableCursorPalette, const char *gfxModeName bool quitLoop = false; uint32 lastRedraw = 0; - const uint32 waitTime = 1000 / 45; - + const uint32 waitTime = 1000 / 45; + Testsuite::clearScreen(); Common::String info = disableCursorPalette ? "Using Game Palette" : "Using cursor palette"; info += " to render the cursor, Click to finish"; - + Testsuite::writeOnScreen(info, pt); - + info = "GFX Mode"; info += gfxModeName; info += " "; @@ -278,7 +278,7 @@ void GFXtests::setupMouseLoop(bool disableCursorPalette, const char *gfxModeName Common::String gfxScalarMode(gfxModeName); Common::Rect estimatedCursorRect; - + if (!gfxScalarMode.equals("")) { if (gfxScalarMode.contains("1x")) { @@ -327,7 +327,7 @@ void GFXtests::setupMouseLoop(bool disableCursorPalette, const char *gfxModeName Testsuite::writeOnScreen("Mouse clicked", pt); g_system->delayMillis(1000); break; - default: + default: break;// Ignore handling any other event } @@ -351,18 +351,18 @@ void GFXtests::mouseMovements() { g_system->warpMouse(i, i); g_system->updateScreen(); } - + Testsuite::clearScreen(); Testsuite::writeOnScreen("Mouse Moved to (100, 100)", pt); - g_system->delayMillis(1000); + g_system->delayMillis(1000); } /** * Used by aspectRatio() */ -void GFXtests::drawEllipse(int cx, int cy, int a, int b) { - +void GFXtests::drawEllipse(int cx, int cy, int a, int b) { + // Take a buffer of screen size byte buffer[200][320] = {{0}}; @@ -371,33 +371,33 @@ void GFXtests::drawEllipse(int cx, int cy, int a, int b) { // Illuminate the center buffer[cx][cy] = 1; - + // Illuminate the points lying on ellipse for (theta = 0; theta <= PI / 2; theta += PI / 360 ) { x = (int)(b * sin(theta) + 0.5); y = (int)(a * cos(theta) + 0.5); - + // This gives us four points - + x1 = x + cx; y1 = y + cy; - + buffer[x1][y1] = 1; x1 = (-1) * x + cx; y1 = y + cy; - + buffer[x1][y1] = 1; - + x1 = x + cx; y1 = (-1) * y + cy; - + buffer[x1][y1] = 1; x1 = (-1) * x + cx; y1 = (-1) * y + cy; - + buffer[x1][y1] = 1; } @@ -412,10 +412,10 @@ void GFXtests::drawEllipse(int cx, int cy, int a, int b) { */ bool GFXtests::fullScreenMode() { - + Common::Point pt(0, 100); Common::Rect rect = Testsuite::writeOnScreen("Testing fullscreen mode", pt); - + bool isFeaturePresent; bool isFeatureEnabled; bool passed = true; @@ -428,9 +428,9 @@ bool GFXtests::fullScreenMode() { // Toggle isFeatureEnabled = g_system->getFeatureState(OSystem::kFeatureFullscreenMode); shouldSelect = isFeatureEnabled ? kOptionLeft : kOptionRight; - + g_system->delayMillis(1000); - + if (isFeatureEnabled) { Testsuite::logDetailedPrintf("Current Mode is Fullsecreen\n"); } else { @@ -438,7 +438,7 @@ bool GFXtests::fullScreenMode() { } prompt = " Which mode do you see currently ? "; - + if (!Testsuite::handleInteractiveInput(prompt, "Fullscreen", "Windowed", shouldSelect)) { // User selected incorrect current state passed = false; @@ -452,25 +452,25 @@ bool GFXtests::fullScreenMode() { // Current state should be now !isFeatureEnabled isFeatureEnabled = g_system->getFeatureState(OSystem::kFeatureFullscreenMode); shouldSelect = isFeatureEnabled ? kOptionLeft : kOptionRight; - + g_system->delayMillis(1000); - + prompt = " Which screen mode do you see now ? "; - + if (!Testsuite::handleInteractiveInput(prompt, "Fullscreen", "Windowed", shouldSelect)) { // User selected incorrect mode passed = false; Testsuite::logDetailedPrintf("g_system->setFeatureState() failed\n"); } - + g_system->beginGFXTransaction(); g_system->setFeatureState(OSystem::kFeatureFullscreenMode, !isFeatureEnabled); g_system->endGFXTransaction(); - + g_system->delayMillis(1000); - + prompt = "This should be your initial state. Is it?"; - + if (!Testsuite::handleInteractiveInput(prompt, "Yes, it is", "Nopes", shouldSelect)) { // User selected incorrect mode Testsuite::logDetailedPrintf("switching back to initial state failed\n"); @@ -491,12 +491,12 @@ 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); - + bool isFeaturePresent; bool isFeatureEnabled; bool passed; @@ -516,13 +516,13 @@ bool GFXtests::aspectRatio() { passed = false; Testsuite::logDetailedPrintf("Aspect Ratio Correction failed\n"); } - + g_system->beginGFXTransaction(); g_system->setFeatureState(OSystem::kFeatureAspectRatioCorrection, !isFeatureEnabled); g_system->endGFXTransaction(); - + g_system->delayMillis(1000); - + shouldSelect = !isFeatureEnabled ? kOptionLeft : kOptionRight; prompt = " What does the curve on screen appears to you ?"; if (!Testsuite::handleInteractiveInput(prompt, "Circle", "Ellipse", shouldSelect)) { @@ -530,7 +530,7 @@ bool GFXtests::aspectRatio() { passed = false; Testsuite::logDetailedPrintf("Aspect Ratio Correction failed\n"); } - + g_system->beginGFXTransaction(); g_system->setFeatureState(OSystem::kFeatureAspectRatioCorrection, isFeatureEnabled); g_system->endGFXTransaction(); @@ -539,13 +539,13 @@ bool GFXtests::aspectRatio() { } g_system->delayMillis(500); - + if (Testsuite::handleInteractiveInput("This should definetely be your initial state?", "Yes, it is", "Nopes", kOptionRight)) { // User selected incorrect mode Testsuite::logDetailedPrintf("Switching back to initial state failed\n"); passed = false; } - + Testsuite::clearScreen(); return passed; } @@ -557,35 +557,35 @@ bool GFXtests::aspectRatio() { bool GFXtests::palettizedCursors() { - + bool passed = true; - + Testsuite::displayMessage("Testing Cursors. You should expect to see a yellow colored square cursor.\n" "You should be able to move it. The test finishes when the mouse(L/R) is clicked"); - + // Testing with cursor Palette setupMouseLoop(); // Test Automated Mouse movements (warp) mouseMovements(); - + if (Testsuite::handleInteractiveInput("Which color did the cursor appeared to you?", "Yellow", "Any other", kOptionRight)) { Testsuite::logDetailedPrintf("Couldn't use cursor palette for rendering cursor\n"); passed = false; - } + } // Testing with game Palette GFXTestSuite::setCustomColor(255, 0, 0); setupMouseLoop(true); - + if (Testsuite::handleInteractiveInput("Which color did the cursor appeared to you?", "Red", "Any other", kOptionRight)) { Testsuite::logDetailedPrintf("Couldn't use Game palette for rendering cursor\n"); passed = false; - } + } if (!Testsuite::handleInteractiveInput("Did Cursor tests went as you were expecting?")) { passed = false; } - + Testsuite::clearScreen(); // Done with cursors, make them invisible, any other test the could simply make it visible CursorMan.showMouse(false); @@ -614,7 +614,7 @@ bool GFXtests::copyRectToScreen() { Common::Rect rect(x, y, x+40, y+20); Testsuite::clearScreen(); - + if (Testsuite::handleInteractiveInput("Did the test worked as you were expecting?", "Yes", "No", kOptionRight)) { return false; } @@ -625,16 +625,16 @@ bool GFXtests::copyRectToScreen() { /** * Testing feature : Iconifying window - * It is expected the screen minimizes when this feature is enabled + * It is expected the screen minimizes when this feature is enabled */ bool GFXtests::iconifyWindow() { - + Testsuite::displayMessage("Testing Iconify Window mode.\n If the feature is supported by the backend," "you should expect the window to be minimized. However you would manually need to de-iconify."); Common::Point pt(0, 100); Common::Rect rect = Testsuite::writeOnScreen("Testing Iconifying window", pt); - + bool isFeaturePresent; bool isFeatureEnabled; @@ -650,14 +650,14 @@ bool GFXtests::iconifyWindow() { g_system->endGFXTransaction(); g_system->delayMillis(1000); - + g_system->beginGFXTransaction(); g_system->setFeatureState(OSystem::kFeatureIconifyWindow, isFeatureEnabled); g_system->endGFXTransaction(); } else { Testsuite::displayMessage("feature not supported"); } - + if (Testsuite::handleInteractiveInput("Did the test worked as you were expecting?", "Yes", "No", kOptionRight)) { return false; } @@ -681,10 +681,10 @@ bool GFXtests::scaledCursors() { if (!Testsuite::handleInteractiveInput("Do you want to restrict scalers to 1x, 2x and 3x only?", "Yes", "No", kOptionRight)) { maxLimit = 3; } - + const int currGFXMode = g_system->getGraphicsMode(); const OSystem::GraphicsMode *gfxMode = g_system->getSupportedGraphicsModes(); - + while (gfxMode->name && maxLimit > 0) { // for every graphics mode display cursors for cursorTargetScale 1, 2 and 3 // Switch Graphics mode @@ -693,17 +693,17 @@ bool GFXtests::scaledCursors() { bool isGFXModeSet = g_system->setGraphicsMode(gfxMode->id); g_system->initSize(320, 200); - + OSystem::TransactionError gfxError = g_system->endGFXTransaction(); if (gfxError == OSystem::kTransactionSuccess && isGFXModeSet) { - + setupMouseLoop(false, gfxMode->name, 1); Testsuite::clearScreen(); - + setupMouseLoop(false, gfxMode->name, 2); Testsuite::clearScreen(); - + setupMouseLoop(false, gfxMode->name, 3); Testsuite::clearScreen(); @@ -715,7 +715,7 @@ bool GFXtests::scaledCursors() { maxLimit--; } - // Restore Original State + // Restore Original State g_system->beginGFXTransaction(); bool isGFXModeSet = g_system->setGraphicsMode(currGFXMode); g_system->initSize(320, 200); @@ -780,39 +780,39 @@ bool GFXtests::focusRectangle() { g_system->setFocusRectangle(rectLeft); g_system->updateScreen(); - + g_system->delayMillis(1000); g_system->setFocusRectangle(rectRight); g_system->updateScreen(); - + g_system->clearFocusRectangle(); if (Testsuite::handleInteractiveInput("Did you noticed a variation in focus?", "Yes", "No", kOptionRight)) { Testsuite::logDetailedPrintf("Focus Rectangle feature doesn't works. Check platform.\n"); } - + Testsuite::clearScreen(); return true; } bool GFXtests::overlayGraphics() { - + Graphics::PixelFormat pf = g_system->getOverlayFormat(); - + OverlayColor buffer[50 * 100]; OverlayColor value = pf.RGBToColor(0, 255, 0); for (int i = 0; i < 50 * 100; i++) { buffer[i] = value; } - + g_system->showOverlay(); g_system->copyRectToOverlay(buffer, 100, 270, 175, 100, 50); g_system->updateScreen(); - + g_system->delayMillis(1000); - + g_system->hideOverlay(); g_system->updateScreen(); @@ -820,7 +820,7 @@ bool GFXtests::overlayGraphics() { Testsuite::logDetailedPrintf("Overlay Rectangle feature doesn't works\n"); return false; } - + Testsuite::clearScreen(); return true; } @@ -828,7 +828,7 @@ bool GFXtests::overlayGraphics() { bool GFXtests::paletteRotation() { Common::Point pt(0, 10); Testsuite::writeOnScreen("Rotating palettes, palettes rotate towards left, click to stop!", pt); - + // Use 256 colors byte palette[256 * 4] = {0, 0, 0, 0, 255, 255, 255, 0}; @@ -843,7 +843,7 @@ bool GFXtests::paletteRotation() { palette[colIndx + 1] = g; palette[colIndx + 2] = b; } - + // Initialize this palette. g_system->setPalette(palette, 0, 256); @@ -862,11 +862,11 @@ bool GFXtests::paletteRotation() { } } } - + g_system->copyRectToScreen(buffer, 254, 22, 50, 254, 30); g_system->updateScreen(); g_system->delayMillis(1000); - + bool toRotate = true; Common::Event event; @@ -884,7 +884,7 @@ bool GFXtests::paletteRotation() { }*/ rotatePalette(&palette[8], 254); - + /*for (int i = 2; i < 256; i++) { debug("Palette: (%d %d %d) #", palette[i*4], palette[i*4+1], palette[i*4+2]); }*/ @@ -893,7 +893,7 @@ bool GFXtests::paletteRotation() { g_system->setPalette(palette, 0, 256); g_system->updateScreen(); } - + CursorMan.showMouse(false); // Reset initial palettes GFXTestSuite::setCustomColor(255, 0, 0); @@ -910,15 +910,15 @@ bool GFXtests::paletteRotation() { bool GFXtests::pixelFormats() { Common::List pfList = g_system->getSupportedFormats(); Common::List::const_iterator iter = pfList.begin(); - + int numFormatsTested = 0; int numPassed = 0; bool numFailed = 0; - + Testsuite::logDetailedPrintf("Testing Pixel Formats. Size of list : %d\n", pfList.size()); - + for (iter = pfList.begin(); iter != pfList.end(); iter++) { - + numFormatsTested++; if (iter->bytesPerPixel == 1) { // Palettes already tested @@ -927,18 +927,18 @@ bool GFXtests::pixelFormats() { Testsuite::logDetailedPrintf("Can't test pixels with bpp > 2\n"); continue; } - + // Switch to that pixel Format g_system->beginGFXTransaction(); g_system->initSize(320, 200, &(*iter)); g_system->endGFXTransaction(); Testsuite::clearScreen(true); - + // Draw some nice gradients // Pick up some colors uint colors[6]; - + colors[0] = iter->RGBToColor(255, 255, 255); colors[1] = iter->RGBToColor(135, 48, 21); colors[2] = iter->RGBToColor(205, 190, 87); @@ -952,22 +952,22 @@ bool GFXtests::pixelFormats() { snprintf(msg, sizeof(msg), "Testing Pixel Formats, %d of %d", numFormatsTested, pfList.size()); Testsuite::writeOnScreen(msg, pt, true); - // CopyRectToScreen could have been used, but that may involve writing code which + // CopyRectToScreen could have been used, but that may involve writing code which // already resides in graphics/surface.h // So using Graphics::Surface Graphics::Surface *screen = g_system->lockScreen(); // Draw 6 rectangles centred at (50, 160), piled over one another - // each with color in colors[] + // each with color in colors[] for (int i = 0; i < 6; i++) { screen->fillRect(Common::Rect::center(160, 20 + i * 10, 100, 10), colors[i]); } - + g_system->unlockScreen(); g_system->updateScreen(); g_system->delayMillis(500); - + if(Testsuite::handleInteractiveInput("Were you able to notice the colored rectangles on the screen for this format?", "Yes", "No", kOptionLeft)) { numPassed++; } else { @@ -989,7 +989,7 @@ bool GFXtests::pixelFormats() { Testsuite::logDetailedPrintf("Pixel Format test: Failed : %d, Passed : %d, Ignored %d\n",numFailed, numPassed, numFormatsTested - (numPassed + numFailed)); return false; } - + return true; } -- cgit v1.2.3 From 555acf4ba17898c0192c262f9dae45ab43a47185 Mon Sep 17 00:00:00 2001 From: Jordi Vilalta Prat Date: Wed, 14 Jul 2010 19:44:51 +0000 Subject: Some code formatting fixes svn-id: r50893 --- engines/testbed/graphics.cpp | 118 +++++++++++++++++-------------------------- 1 file changed, 46 insertions(+), 72 deletions(-) (limited to 'engines/testbed/graphics.cpp') diff --git a/engines/testbed/graphics.cpp b/engines/testbed/graphics.cpp index eb3f6e376d..b8a3e1ff63 100644 --- a/engines/testbed/graphics.cpp +++ b/engines/testbed/graphics.cpp @@ -74,7 +74,6 @@ GFXTestSuite::GFXTestSuite() { // Specific Tests: addTest("Palette Rotation", &GFXtests::paletteRotation); //addTest("Pixel Formats", &GFXtests::pixelFormats); - } const char *GFXTestSuite::getName() const { @@ -99,7 +98,6 @@ void GFXtests::initMousePalette() { palette[10] = 0; CursorMan.replaceCursorPalette(palette, 0, 3); - } Common::Rect GFXtests::computeSize(Common::Rect &cursorRect, int scalingFactor, int cursorTargetScale) { @@ -124,8 +122,7 @@ Common::Rect GFXtests::computeSize(Common::Rect &cursorRect, int scalingFactor, } } -void GFXtests::HSVtoRGB(int& rComp, int& gComp, int& bComp, int hue, int sat, int val) { - +void GFXtests::HSVtoRGB(int &rComp, int &gComp, int &bComp, int hue, int sat, int val) { float r = rComp; float g = gComp; float b = bComp; @@ -143,43 +140,43 @@ void GFXtests::HSVtoRGB(int& rComp, int& gComp, int& bComp, int hue, int sat, in } h /= 60; - i = (int) h; + i = (int)h; f = h - i; p = v * (1 - s); q = v * (1 - s * f); t = v * (1 - s * (1 - f)); switch (i) { - case 0: - r = v; - g = t; - b = p; - break; - case 1: - r = q; - g = v; - b = p; - break; - case 2: - r = p; - g = v; - b = t; - break; - case 3: - r = p; - g = q; - b = v; - break; - case 4: - r = t; - g = p; - b = v; - break; - default: - r = v; - g = p; - b = q; - break; + case 0: + r = v; + g = t; + b = p; + break; + case 1: + r = q; + g = v; + b = p; + break; + case 2: + r = p; + g = v; + b = t; + break; + case 3: + r = p; + g = q; + b = v; + break; + case 4: + r = t; + g = p; + b = v; + break; + default: + r = v; + g = p; + b = q; + break; } rComp = r * 255; @@ -188,7 +185,6 @@ void GFXtests::HSVtoRGB(int& rComp, int& gComp, int& bComp, int hue, int sat, in } Common::Rect GFXtests::drawCursor(bool cursorPaletteDisabled, const char *gfxModeName, int cursorTargetScale) { - // Buffer initialized with yellow color byte buffer[500]; memset(buffer, 2, sizeof(buffer)); @@ -238,14 +234,13 @@ void rotatePalette(byte *palette, int size) { memcpy(&palette[i * 4], &palette[(i + 1) * 4], 4 * sizeof(byte)); } // Assign last color to tcolor - memcpy(&palette[(size -1) * 4], tColor, 4 * sizeof(byte)); + memcpy(&palette[(size - 1) * 4], tColor, 4 * sizeof(byte)); } /** * Sets up mouse loop, exits when user clicks any of the mouse button */ void GFXtests::setupMouseLoop(bool disableCursorPalette, const char *gfxModeName, int cursorTargetScale) { - bool isFeaturePresent; isFeaturePresent = g_system->hasFeature(OSystem::kFeatureCursorHasPalette); Common::Rect cursorRect; @@ -285,7 +280,7 @@ void GFXtests::setupMouseLoop(bool disableCursorPalette, const char *gfxModeName estimatedCursorRect = computeSize(cursorRect, 1, cursorTargetScale); } else if (gfxScalarMode.contains("2x")) { estimatedCursorRect = computeSize(cursorRect, 2, cursorTargetScale); - } else if (gfxScalarMode.contains("3x")){ + } else if (gfxScalarMode.contains("3x")) { estimatedCursorRect = computeSize(cursorRect, 3, cursorTargetScale); } else { // If unable to detect scaler, default to 2 @@ -360,11 +355,8 @@ 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}}; float theta; int x, y, x1, y1; @@ -374,7 +366,7 @@ void GFXtests::drawEllipse(int cx, int cy, int a, int b) { // Illuminate the points lying on ellipse - for (theta = 0; theta <= PI / 2; theta += PI / 360 ) { + for (theta = 0; theta <= PI / 2; theta += PI / 360) { x = (int)(b * sin(theta) + 0.5); y = (int)(a * cos(theta) + 0.5); @@ -410,9 +402,7 @@ void GFXtests::drawEllipse(int cx, int cy, int a, int b) { /** * Tests the fullscreen mode by: toggling between fullscreen and windowed mode */ - bool GFXtests::fullScreenMode() { - Common::Point pt(0, 100); Common::Rect rect = Testsuite::writeOnScreen("Testing fullscreen mode", pt); @@ -488,10 +478,8 @@ bool GFXtests::fullScreenMode() { /** * Tests the aspect ratio correction by: drawing an ellipse, when corrected the ellipse should render to a circle */ - bool GFXtests::aspectRatio() { // Draw an ellipse on the screen - drawEllipse(100, 160, 72, 60); Common::Point pt(0, 180); @@ -554,14 +542,11 @@ bool GFXtests::aspectRatio() { * Tests Palettized cursors. * Method: Create a yellow colored cursor, should be able to move it. Once you click test terminates */ - bool GFXtests::palettizedCursors() { - - bool passed = true; Testsuite::displayMessage("Testing Cursors. You should expect to see a yellow colored square cursor.\n" - "You should be able to move it. The test finishes when the mouse(L/R) is clicked"); + "You should be able to move it. The test finishes when the mouse(L/R) is clicked"); // Testing with cursor Palette setupMouseLoop(); @@ -599,7 +584,7 @@ bool GFXtests::palettizedCursors() { */ bool GFXtests::copyRectToScreen() { Testsuite::displayMessage("Testing Blitting a Bitmap to screen.\n" - "You should expect to see a 20x40 yellow horizontal rectangle centred at the screen."); + "You should expect to see a 20x40 yellow horizontal rectangle centred at the screen."); GFXTestSuite::setCustomColor(255, 255, 0); byte buffer[20 * 40]; @@ -612,7 +597,7 @@ bool GFXtests::copyRectToScreen() { g_system->updateScreen(); g_system->delayMillis(1000); - Common::Rect rect(x, y, x+40, y+20); + Common::Rect rect(x, y, x + 40, y + 20); Testsuite::clearScreen(); if (Testsuite::handleInteractiveInput("Did the test worked as you were expecting?", "Yes", "No", kOptionRight)) { @@ -620,7 +605,6 @@ bool GFXtests::copyRectToScreen() { } return true; - } /** @@ -628,9 +612,8 @@ bool GFXtests::copyRectToScreen() { * It is expected the screen minimizes when this feature is enabled */ bool GFXtests::iconifyWindow() { - Testsuite::displayMessage("Testing Iconify Window mode.\n If the feature is supported by the backend," - "you should expect the window to be minimized. However you would manually need to de-iconify."); + "you should expect the window to be minimized. However you would manually need to de-iconify."); Common::Point pt(0, 100); Common::Rect rect = Testsuite::writeOnScreen("Testing Iconifying window", pt); @@ -669,13 +652,12 @@ bool GFXtests::iconifyWindow() { /** * Testing feature: Scaled cursors */ - bool GFXtests::scaledCursors() { Testsuite::displayMessage("Testing : Scaled cursors\n" - "Here every graphics mode is tried with a cursorTargetScale of 1,2 and 3.\n" - "The expected cursor size is drawn as a rectangle, the cursor should entirely cover that rectangle.\n" - "This may take time, You may skip the later scalers and just examine the first three i.e 1x,2x and 3x"); + "Here every graphics mode is tried with a cursorTargetScale of 1,2 and 3.\n" + "The expected cursor size is drawn as a rectangle, the cursor should entirely cover that rectangle.\n" + "This may take time, You may skip the later scalers and just examine the first three i.e 1x,2x and 3x"); int maxLimit = 1000; if (!Testsuite::handleInteractiveInput("Do you want to restrict scalers to 1x, 2x and 3x only?", "Yes", "No", kOptionRight)) { @@ -697,7 +679,6 @@ bool GFXtests::scaledCursors() { OSystem::TransactionError gfxError = g_system->endGFXTransaction(); if (gfxError == OSystem::kTransactionSuccess && isGFXModeSet) { - setupMouseLoop(false, gfxMode->name, 1); Testsuite::clearScreen(); @@ -706,7 +687,6 @@ bool GFXtests::scaledCursors() { setupMouseLoop(false, gfxMode->name, 3); Testsuite::clearScreen(); - } else { Testsuite::logDetailedPrintf("Switching to graphics mode %s failed\n", gfxMode->name); return false; @@ -753,9 +733,8 @@ bool GFXtests::shakingEffect() { } bool GFXtests::focusRectangle() { - Testsuite::displayMessage("Testing : Setting and hiding Focus \n" - "If this feature is implemented, the focus should be toggled between the two rectangles on the corners"); + "If this feature is implemented, the focus should be toggled between the two rectangles on the corners"); const Graphics::Font &font(*FontMan.getFontByUsage(Graphics::FontManager::kConsoleFont)); @@ -797,7 +776,6 @@ bool GFXtests::focusRectangle() { } bool GFXtests::overlayGraphics() { - Graphics::PixelFormat pf = g_system->getOverlayFormat(); OverlayColor buffer[50 * 100]; @@ -867,7 +845,6 @@ bool GFXtests::paletteRotation() { g_system->updateScreen(); g_system->delayMillis(1000); - bool toRotate = true; Common::Event event; CursorMan.showMouse(true); @@ -880,13 +857,13 @@ bool GFXtests::paletteRotation() { } /*for (int i = 2; i < 256; i++) { - debug("Palette: (%d %d %d) #", palette[i*4], palette[i*4+1], palette[i*4+2]); + debug("Palette: (%d %d %d) #", palette[i * 4], palette[i * 4 + 1], palette[i * 4 + 2]); }*/ rotatePalette(&palette[8], 254); /*for (int i = 2; i < 256; i++) { - debug("Palette: (%d %d %d) #", palette[i*4], palette[i*4+1], palette[i*4+2]); + debug("Palette: (%d %d %d) #", palette[i * 4], palette[i * 4 + 1], palette[i * 4 + 2]); }*/ g_system->delayMillis(10); @@ -918,7 +895,6 @@ bool GFXtests::pixelFormats() { Testsuite::logDetailedPrintf("Testing Pixel Formats. Size of list : %d\n", pfList.size()); for (iter = pfList.begin(); iter != pfList.end(); iter++) { - numFormatsTested++; if (iter->bytesPerPixel == 1) { // Palettes already tested @@ -934,7 +910,6 @@ bool GFXtests::pixelFormats() { g_system->endGFXTransaction(); Testsuite::clearScreen(true); - // Draw some nice gradients // Pick up some colors uint colors[6]; @@ -984,7 +959,6 @@ bool GFXtests::pixelFormats() { initMousePalette(); Testsuite::clearScreen(); - if (numFailed) { Testsuite::logDetailedPrintf("Pixel Format test: Failed : %d, Passed : %d, Ignored %d\n",numFailed, numPassed, numFormatsTested - (numPassed + numFailed)); return false; @@ -993,4 +967,4 @@ bool GFXtests::pixelFormats() { return true; } -} +} // End of namespace Testbed -- cgit v1.2.3 From 12ebe8065e6020415cb3a6df216a4504014371db Mon Sep 17 00:00:00 2001 From: Max Horn Date: Wed, 14 Jul 2010 22:43:59 +0000 Subject: Fix warnings svn-id: r50899 --- engines/testbed/graphics.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'engines/testbed/graphics.cpp') diff --git a/engines/testbed/graphics.cpp b/engines/testbed/graphics.cpp index b8a3e1ff63..23747674cc 100644 --- a/engines/testbed/graphics.cpp +++ b/engines/testbed/graphics.cpp @@ -179,9 +179,9 @@ void GFXtests::HSVtoRGB(int &rComp, int &gComp, int &bComp, int hue, int sat, in break; } - rComp = r * 255; - gComp = g * 255; - bComp = b * 255; + rComp = (int)(r * 255); + gComp = (int)(g * 255); + bComp = (int)(b * 255); } Common::Rect GFXtests::drawCursor(bool cursorPaletteDisabled, const char *gfxModeName, int cursorTargetScale) { -- cgit v1.2.3 From b6c2be3bb9eed92a6e583844d7197093dd42ef50 Mon Sep 17 00:00:00 2001 From: Neeraj Kumar Date: Sun, 18 Jul 2010 09:08:18 +0000 Subject: Some more improvements in the TestbedListWidget and added description method in testsuite class svn-id: r50984 --- engines/testbed/graphics.cpp | 4 ---- 1 file changed, 4 deletions(-) (limited to 'engines/testbed/graphics.cpp') diff --git a/engines/testbed/graphics.cpp b/engines/testbed/graphics.cpp index 23747674cc..70bf267456 100644 --- a/engines/testbed/graphics.cpp +++ b/engines/testbed/graphics.cpp @@ -76,10 +76,6 @@ GFXTestSuite::GFXTestSuite() { //addTest("Pixel Formats", &GFXtests::pixelFormats); } -const char *GFXTestSuite::getName() const { - return "GFX"; -} - void GFXTestSuite::setCustomColor(uint r, uint g, uint b) { _palette[8] = r; _palette[9] = g; -- cgit v1.2.3 From 7065c87a0d67ba4ec0536e52a465688edadbc602 Mon Sep 17 00:00:00 2001 From: Neeraj Kumar Date: Mon, 19 Jul 2010 14:54:25 +0000 Subject: replaced use of snprintf by String::printf svn-id: r51030 --- engines/testbed/graphics.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'engines/testbed/graphics.cpp') diff --git a/engines/testbed/graphics.cpp b/engines/testbed/graphics.cpp index 70bf267456..bac680ae7e 100644 --- a/engines/testbed/graphics.cpp +++ b/engines/testbed/graphics.cpp @@ -918,9 +918,9 @@ bool GFXtests::pixelFormats() { colors[5] = iter->RGBToColor(47, 78, 36); Common::Point pt(0, 170); - char msg[100]; + Common::String msg; // XXX: Can use snprintf? - snprintf(msg, sizeof(msg), "Testing Pixel Formats, %d of %d", numFormatsTested, pfList.size()); + msg = Common::String::printf("Testing Pixel Formats, %d of %d", numFormatsTested, pfList.size()); Testsuite::writeOnScreen(msg, pt, true); // CopyRectToScreen could have been used, but that may involve writing code which -- cgit v1.2.3 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 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) (limited to 'engines/testbed/graphics.cpp') 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; } -- cgit v1.2.3 From f6be0274df5c9dbdf6de262d310460e2d1d8b2e0 Mon Sep 17 00:00:00 2001 From: Neeraj Kumar Date: Tue, 20 Jul 2010 20:20:44 +0000 Subject: TESTBED: added preface to tests, can skip tests now. svn-id: r51073 --- engines/testbed/graphics.cpp | 208 +++++++++++++++++++++++++++++++------------ 1 file changed, 153 insertions(+), 55 deletions(-) (limited to 'engines/testbed/graphics.cpp') diff --git a/engines/testbed/graphics.cpp b/engines/testbed/graphics.cpp index c847bc6188..371b012734 100644 --- a/engines/testbed/graphics.cpp +++ b/engines/testbed/graphics.cpp @@ -61,6 +61,7 @@ GFXTestSuite::GFXTestSuite() { // Mouse Layer tests (Palettes and movements) addTest("PalettizedCursors", &GFXtests::palettizedCursors); + addTest("MouseMovements", &GFXtests::mouseMovements); // FIXME: Scaled cursor crsh with odd dimmensions addTest("ScaledCursors", &GFXtests::scaledCursors); @@ -329,25 +330,6 @@ void GFXtests::setupMouseLoop(bool disableCursorPalette, const char *gfxModeName } } -void GFXtests::mouseMovements() { - // Testing Mouse Movements now! - Common::Point pt(0, 100); - Testsuite::writeOnScreen("Moving mouse automatically from (0, 0) to (100, 100)", pt); - g_system->warpMouse(0, 0); - g_system->updateScreen(); - g_system->delayMillis(1000); - - for (int i = 0; i <= 100; i++) { - g_system->delayMillis(20); - g_system->warpMouse(i, i); - g_system->updateScreen(); - } - - Testsuite::clearScreen(); - Testsuite::writeOnScreen("Mouse Moved to (100, 100)", pt); - g_system->delayMillis(1000); -} - /** * Used by aspectRatio() */ @@ -404,8 +386,17 @@ void GFXtests::drawEllipse(int cx, int cy, int a, int b) { * Tests the fullscreen mode by: toggling between fullscreen and windowed mode */ bool GFXtests::fullScreenMode() { + Testsuite::clearScreen(); + Common::String info = "Fullscreen test. Here you should expect a toggle between windowed and fullscreen states depending " + "upon your initial state."; + Common::Point pt(0, 100); Common::Rect rect = Testsuite::writeOnScreen("Testing fullscreen mode", pt); + + if (Testsuite::handleInteractiveInput(info, "OK", "Skip", kOptionRight)) { + Testsuite::logPrintf("Info! Skipping test : FullScreenMode"); + return true; + } bool isFeaturePresent; bool isFeatureEnabled; @@ -472,7 +463,6 @@ bool GFXtests::fullScreenMode() { Testsuite::displayMessage("feature not supported"); } - Testsuite::clearScreen(); return passed; } @@ -480,6 +470,15 @@ bool GFXtests::fullScreenMode() { * Tests the aspect ratio correction by: drawing an ellipse, when corrected the ellipse should render to a circle */ bool GFXtests::aspectRatio() { + + Testsuite::clearScreen(); + Common::String info = "Aspect Ratio Correction test. If aspect ratio correction is enabled you should expect a circle on screen," + " an ellipse otherwise."; + + if (Testsuite::handleInteractiveInput(info, "OK", "Skip", kOptionRight)) { + Testsuite::logPrintf("Info! Skipping test : Aspect Ratio"); + return true; + } // Draw an ellipse on the screen drawEllipse(80, 160, 72, 60); @@ -532,7 +531,6 @@ bool GFXtests::aspectRatio() { passed = false; } - Testsuite::clearScreen(); return passed; } @@ -541,16 +539,25 @@ bool GFXtests::aspectRatio() { * Method: Create a yellow colored cursor, should be able to move it. Once you click test terminates */ bool GFXtests::palettizedCursors() { - bool passed = true; - Testsuite::displayMessage("Testing Cursors. You should expect to see a yellow colored square cursor.\n" - "You should be able to move it. The test finishes when the mouse(L/R) is clicked"); + Testsuite::clearScreen(); + Common::String info = "Palettized Cursors test.\n " + "Here you should expect to see a yellow mouse cursor rendered with mouse graphics.\n" + "You would be able to move the cursor. Later we use game graphics to render the cursor.\n" + "For cursor palette it should be yellow and will be red if rendered by the game palette.\n" + "The test finishes when mouse (L/R) is clicked."; + + + if (Testsuite::handleInteractiveInput(info, "OK", "Skip", kOptionRight)) { + Testsuite::logPrintf("Info! Skipping test : Palettized Cursors"); + return true; + } + + bool passed = true; // Testing with cursor Palette setupMouseLoop(); - // Test Automated Mouse movements (warp) - mouseMovements(); - + if (Testsuite::handleInteractiveInput("Which color did the cursor appeared to you?", "Yellow", "Any other", kOptionRight)) { Testsuite::logDetailedPrintf("Couldn't use cursor palette for rendering cursor\n"); passed = false; @@ -569,21 +576,71 @@ bool GFXtests::palettizedCursors() { passed = false; } - Testsuite::clearScreen(); + // re-enable cursor palette + CursorMan.disableCursorPalette(false); // Done with cursors, make them invisible, any other test the could simply make it visible CursorMan.showMouse(false); return passed; } +/** + * Tests automated mouse movements. "Warp" functionality provided by the backend. + */ + +bool GFXtests::mouseMovements() { + Testsuite::clearScreen(); + // Make mouse visible + CursorMan.showMouse(true); + + Common::String info = "Testing Automated Mouse movements.\n" + "You should expect cursor to automatically move from (0, 0) to (100, 100)"; + + if (Testsuite::handleInteractiveInput(info, "OK", "Skip", kOptionRight)) { + Testsuite::logPrintf("Info! Skipping test : Mouse Movements"); + return true; + } + + // Testing Mouse Movements now! + Common::Point pt(0, 100); + Testsuite::writeOnScreen("Moving mouse automatically from (0, 0) to (100, 100)", pt); + g_system->warpMouse(0, 0); + g_system->updateScreen(); + g_system->delayMillis(1000); + + for (int i = 0; i <= 100; i++) { + g_system->delayMillis(20); + g_system->warpMouse(i, i); + g_system->updateScreen(); + } + + Testsuite::clearScreen(); + Testsuite::writeOnScreen("Mouse Moved to (100, 100)", pt); + g_system->delayMillis(1000); + + if (Testsuite::handleInteractiveInput("Were you able to see an automated mouse movement?", "Yes", "No", kOptionRight)) { + return false; + } + + return true; +} + + /** * This basically blits the screen by the contents of its buffer. * */ bool GFXtests::copyRectToScreen() { - Testsuite::displayMessage("Testing Blitting a Bitmap to screen.\n" - "You should expect to see a 20x40 yellow horizontal rectangle centred at the screen."); + + Testsuite::clearScreen(); + Common::String info = "Testing Blitting a Bitmap to screen.\n" + "You should expect to see a 20x40 yellow horizontal rectangle centred at the screen."; + if (Testsuite::handleInteractiveInput(info, "OK", "Skip", kOptionRight)) { + Testsuite::logPrintf("Info! Skipping test : Blitting Bitmap"); + return true; + } + GFXTestSuite::setCustomColor(255, 255, 0); byte buffer[20 * 40]; memset(buffer, 2, 20 * 40); @@ -595,9 +652,6 @@ bool GFXtests::copyRectToScreen() { g_system->updateScreen(); g_system->delayMillis(1000); - Common::Rect rect(x, y, x + 40, y + 20); - Testsuite::clearScreen(); - if (Testsuite::handleInteractiveInput("Did the test worked as you were expecting?", "Yes", "No", kOptionRight)) { return false; } @@ -610,9 +664,16 @@ bool GFXtests::copyRectToScreen() { * It is expected the screen minimizes when this feature is enabled */ bool GFXtests::iconifyWindow() { - Testsuite::displayMessage("Testing Iconify Window mode.\n If the feature is supported by the backend," - "you should expect the window to be minimized. However you would manually need to de-iconify."); + + Testsuite::clearScreen(); + Common::String info = "Testing Iconify Window mode.\n If the feature is supported by the backend," + "you should expect the window to be minimized.\n However you would manually need to de-iconify."; + if (Testsuite::handleInteractiveInput(info, "OK", "Skip", kOptionRight)) { + Testsuite::logPrintf("Info! Skipping test : Iconifying window"); + return true; + } + Common::Point pt(0, 100); Common::Rect rect = Testsuite::writeOnScreen("Testing Iconifying window", pt); @@ -643,7 +704,6 @@ bool GFXtests::iconifyWindow() { return false; } - Testsuite::clearScreen(); return true; } @@ -652,10 +712,16 @@ bool GFXtests::iconifyWindow() { */ bool GFXtests::scaledCursors() { - Testsuite::displayMessage("Testing : Scaled cursors\n" + Testsuite::clearScreen(); + Common::String info = "Testing : Scaled cursors\n" "Here every graphics mode is tried with a cursorTargetScale of 1,2 and 3.\n" "The expected cursor size is drawn as a rectangle, the cursor should entirely cover that rectangle.\n" - "This may take time, You may skip the later scalers and just examine the first three i.e 1x,2x and 3x"); + "This may take time, You may skip the later scalers and just examine the first three i.e 1x,2x and 3x"; + + if (Testsuite::handleInteractiveInput(info, "OK", "Skip", kOptionRight)) { + Testsuite::logPrintf("Info! Skipping test : Scaled Cursors"); + return true; + } int maxLimit = 1000; if (!Testsuite::handleInteractiveInput("Do you want to restrict scalers to 1x, 2x and 3x only?", "Yes", "No", kOptionRight)) { @@ -706,11 +772,19 @@ bool GFXtests::scaledCursors() { // Done with cursors, Make them invisible, any other test may enable and use it. CursorMan.showMouse(false); - Testsuite::clearScreen(); return true; } bool GFXtests::shakingEffect() { + + Testsuite::clearScreen(); + Common::String info = "Shaking test. You should expect the graphics(text/bars etc) drawn on the screen to shake!"; + + if (Testsuite::handleInteractiveInput(info, "OK", "Skip", kOptionRight)) { + Testsuite::logPrintf("Info! Skipping test : Shaking Effect"); + return true; + } + Common::Point pt(0, 100); Testsuite::writeOnScreen("If Shaking effect works,this should shake!", pt); int times = 35; @@ -726,14 +800,20 @@ bool GFXtests::shakingEffect() { Testsuite::logDetailedPrintf("Shaking Effect didn't worked"); return false; } - Testsuite::clearScreen(); return true; } bool GFXtests::focusRectangle() { - Testsuite::displayMessage("Testing : Setting and hiding Focus \n" - "If this feature is implemented, the focus should be toggled between the two rectangles on the corners"); + + Testsuite::clearScreen(); + Common::String info = "Testing : Setting and hiding Focus \n" + "If this feature is implemented, the focus should be toggled between the two rectangles on the corners"; + if (Testsuite::handleInteractiveInput(info, "OK", "Skip", kOptionRight)) { + Testsuite::logPrintf("Info! Skipping test : focus Rectangle"); + return true; + } + const Graphics::Font &font(*FontMan.getFontByUsage(Graphics::FontManager::kConsoleFont)); Graphics::Surface *screen = g_system->lockScreen(); @@ -769,11 +849,18 @@ bool GFXtests::focusRectangle() { Testsuite::logDetailedPrintf("Focus Rectangle feature doesn't works. Check platform.\n"); } - Testsuite::clearScreen(); return true; } bool GFXtests::overlayGraphics() { + Testsuite::clearScreen(); + Common::String info = "Overlay Graphics. You should expect to see a green colored rectangle on the screen"; + + if (Testsuite::handleInteractiveInput(info, "OK", "Skip", kOptionRight)) { + Testsuite::logPrintf("Info! Skipping test : Overlay Graphics"); + return true; + } + Graphics::PixelFormat pf = g_system->getOverlayFormat(); OverlayColor buffer[50 * 100]; @@ -797,11 +884,19 @@ bool GFXtests::overlayGraphics() { return false; } - Testsuite::clearScreen(); return true; } bool GFXtests::paletteRotation() { + + Testsuite::clearScreen(); + Common::String info = "Palette rotation. Here we draw a full 256 colored rainbow and then rotate it.\n" + "Note that the screen graphics change without having to draw anything."; + + if (Testsuite::handleInteractiveInput(info, "OK", "Skip", kOptionRight)) { + Testsuite::logPrintf("Info! Skipping test : palette Rotation"); + return true; + } Common::Point pt(0, 10); Testsuite::writeOnScreen("Rotating palettes, palettes rotate towards left, click to stop!", pt); @@ -840,13 +935,16 @@ bool GFXtests::paletteRotation() { } g_system->copyRectToScreen(buffer, 254, 22, 50, 254, 30); + + // Show mouse + CursorMan.showMouse(true); g_system->updateScreen(); + g_system->delayMillis(1000); bool toRotate = true; Common::Event event; - CursorMan.showMouse(true); - + while (toRotate) { while (g_system->getEventManager()->pollEvent(event)) { if (event.type == Common::EVENT_LBUTTONDOWN || event.type == Common::EVENT_RBUTTONDOWN) { @@ -854,16 +952,8 @@ bool GFXtests::paletteRotation() { } } - /*for (int i = 2; i < 256; i++) { - debug("Palette: (%d %d %d) #", palette[i * 4], palette[i * 4 + 1], palette[i * 4 + 2]); - }*/ - rotatePalette(&palette[8], 254); - /*for (int i = 2; i < 256; i++) { - debug("Palette: (%d %d %d) #", palette[i * 4], palette[i * 4 + 1], palette[i * 4 + 2]); - }*/ - g_system->delayMillis(10); g_system->setPalette(palette, 0, 256); g_system->updateScreen(); @@ -878,11 +968,19 @@ bool GFXtests::paletteRotation() { return false; } - Testsuite::clearScreen(); return true; } bool GFXtests::pixelFormats() { + Testsuite::clearScreen(); + Common::String info = "Testing pixel formats. Here we iterate over all the supported pixel formats and display some colors using them\n" + "This may take long, especially if the backend supports many pixel formats"; + + if (Testsuite::handleInteractiveInput(info, "OK", "Skip", kOptionRight)) { + Testsuite::logPrintf("Info! Skipping test : focus Rectangle"); + return true; + } + Common::List pfList = g_system->getSupportedFormats(); Common::List::const_iterator iter = pfList.begin(); -- cgit v1.2.3 From 12275cd36edec4b73211e6d0458ee68afe0c1d09 Mon Sep 17 00:00:00 2001 From: Neeraj Kumar Date: Thu, 22 Jul 2010 19:59:11 +0000 Subject: TESTBED: some changes in interaction messages, couple of fixes svn-id: r51160 --- engines/testbed/graphics.cpp | 45 +++++++++++++++++++++++++++----------------- 1 file changed, 28 insertions(+), 17 deletions(-) (limited to 'engines/testbed/graphics.cpp') diff --git a/engines/testbed/graphics.cpp b/engines/testbed/graphics.cpp index 371b012734..40eab3de3e 100644 --- a/engines/testbed/graphics.cpp +++ b/engines/testbed/graphics.cpp @@ -258,6 +258,12 @@ void GFXtests::setupMouseLoop(bool disableCursorPalette, const char *gfxModeName Common::String info = disableCursorPalette ? "Using Game Palette" : "Using cursor palette"; info += " to render the cursor, Click to finish"; + Common::String gfxScalarMode(gfxModeName); + + if (!gfxScalarMode.equals("")) { + info = "The cursor size (yellow) should match the red rectangle."; + } + Testsuite::writeOnScreen(info, pt); info = "GFX Mode"; @@ -268,7 +274,6 @@ void GFXtests::setupMouseLoop(bool disableCursorPalette, const char *gfxModeName info += "Cursor scale: "; info += cScale; - Common::String gfxScalarMode(gfxModeName); Common::Rect estimatedCursorRect; if (!gfxScalarMode.equals("")) { @@ -572,7 +577,7 @@ bool GFXtests::palettizedCursors() { passed = false; } - if (!Testsuite::handleInteractiveInput("Did Cursor tests went as you were expecting?")) { + if (!Testsuite::handleInteractiveInput("Did test run as was described?")) { passed = false; } @@ -593,16 +598,22 @@ bool GFXtests::mouseMovements() { CursorMan.showMouse(true); Common::String info = "Testing Automated Mouse movements.\n" - "You should expect cursor to automatically move from (0, 0) to (100, 100)"; + "You should expect cursor hotspot(top-left corner) to automatically move from (0, 0) to (100, 100).\n" + "There we have a rectangle drawn, finally the rectangle should symmetrically contain the cursor."; if (Testsuite::handleInteractiveInput(info, "OK", "Skip", kOptionRight)) { Testsuite::logPrintf("Info! Skipping test : Mouse Movements"); return true; } + // Draw Rectangle + Graphics::Surface *screen = g_system->lockScreen(); + screen->fillRect(Common::Rect::center(106, 106, 14, 14), 2); + g_system->unlockScreen(); + // Testing Mouse Movements now! - Common::Point pt(0, 100); - Testsuite::writeOnScreen("Moving mouse automatically from (0, 0) to (100, 100)", pt); + Common::Point pt(0, 10); + Testsuite::writeOnScreen("Moving mouse hotspot automatically from (0, 0) to (100, 100)", pt); g_system->warpMouse(0, 0); g_system->updateScreen(); g_system->delayMillis(1000); @@ -613,11 +624,11 @@ bool GFXtests::mouseMovements() { g_system->updateScreen(); } - Testsuite::clearScreen(); - Testsuite::writeOnScreen("Mouse Moved to (100, 100)", pt); - g_system->delayMillis(1000); + Testsuite::writeOnScreen("Mouse hotspot Moved to (100, 100)", pt); + g_system->delayMillis(1500); + CursorMan.showMouse(false); - if (Testsuite::handleInteractiveInput("Were you able to see an automated mouse movement?", "Yes", "No", kOptionRight)) { + if (Testsuite::handleInteractiveInput("Was the cursor symmetrically contained in the rectangle at (100, 100)?", "Yes", "No", kOptionRight)) { return false; } @@ -652,7 +663,7 @@ bool GFXtests::copyRectToScreen() { g_system->updateScreen(); g_system->delayMillis(1000); - if (Testsuite::handleInteractiveInput("Did the test worked as you were expecting?", "Yes", "No", kOptionRight)) { + if (Testsuite::handleInteractiveInput("Did you see yellow rectangle?", "Yes", "No", kOptionRight)) { return false; } @@ -666,7 +677,7 @@ bool GFXtests::copyRectToScreen() { bool GFXtests::iconifyWindow() { Testsuite::clearScreen(); - Common::String info = "Testing Iconify Window mode.\n If the feature is supported by the backend," + Common::String info = "Testing Iconify Window mode.\n If the feature is supported by the backend, " "you should expect the window to be minimized.\n However you would manually need to de-iconify."; if (Testsuite::handleInteractiveInput(info, "OK", "Skip", kOptionRight)) { @@ -700,7 +711,7 @@ bool GFXtests::iconifyWindow() { Testsuite::displayMessage("feature not supported"); } - if (Testsuite::handleInteractiveInput("Did the test worked as you were expecting?", "Yes", "No", kOptionRight)) { + if (Testsuite::handleInteractiveInput("Did you see window minimized?", "Yes", "No", kOptionRight)) { return false; } @@ -714,9 +725,9 @@ bool GFXtests::scaledCursors() { Testsuite::clearScreen(); Common::String info = "Testing : Scaled cursors\n" - "Here every graphics mode is tried with a cursorTargetScale of 1,2 and 3.\n" + "Here every graphics mode is tried with a cursorTargetScale of 1, 2 and 3.\n" "The expected cursor size is drawn as a rectangle, the cursor should entirely cover that rectangle.\n" - "This may take time, You may skip the later scalers and just examine the first three i.e 1x,2x and 3x"; + "This may take time, You may skip the later scalers and just examine the first three i.e 1x, 2x and 3x"; if (Testsuite::handleInteractiveInput(info, "OK", "Skip", kOptionRight)) { Testsuite::logPrintf("Info! Skipping test : Scaled Cursors"); @@ -724,7 +735,7 @@ bool GFXtests::scaledCursors() { } int maxLimit = 1000; - if (!Testsuite::handleInteractiveInput("Do you want to restrict scalers to 1x, 2x and 3x only?", "Yes", "No", kOptionRight)) { + if (!Testsuite::handleInteractiveInput("Do You want to restrict scalers to 1x, 2x and 3x only?", "Yes", "No", kOptionRight)) { maxLimit = 3; } @@ -786,7 +797,7 @@ bool GFXtests::shakingEffect() { } Common::Point pt(0, 100); - Testsuite::writeOnScreen("If Shaking effect works,this should shake!", pt); + Testsuite::writeOnScreen("If Shaking Effect works, this should shake!", pt); int times = 35; while (times--) { g_system->setShakePos(10); @@ -796,7 +807,7 @@ bool GFXtests::shakingEffect() { } g_system->delayMillis(1500); - if (Testsuite::handleInteractiveInput("Did the shaking 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; } -- cgit v1.2.3 From 3f2527a48aab2d98bab252a4e77e55c7dcae0e67 Mon Sep 17 00:00:00 2001 From: Neeraj Kumar Date: Sat, 24 Jul 2010 16:05:19 +0000 Subject: Implemented selection of tests using a config file, config file layout resembles to that of .scummvmrc on linux svn-id: r51248 --- engines/testbed/graphics.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'engines/testbed/graphics.cpp') diff --git a/engines/testbed/graphics.cpp b/engines/testbed/graphics.cpp index 40eab3de3e..4cbe963031 100644 --- a/engines/testbed/graphics.cpp +++ b/engines/testbed/graphics.cpp @@ -73,7 +73,7 @@ GFXTestSuite::GFXTestSuite() { addTest("Overlays", &GFXtests::overlayGraphics); // Specific Tests: - addTest("Palette Rotation", &GFXtests::paletteRotation); + addTest("PaletteRotation", &GFXtests::paletteRotation); //addTest("Pixel Formats", &GFXtests::pixelFormats); } @@ -800,7 +800,7 @@ bool GFXtests::shakingEffect() { Testsuite::writeOnScreen("If Shaking Effect works, this should shake!", pt); int times = 35; while (times--) { - g_system->setShakePos(10); + g_system->setShakePos(25); g_system->updateScreen(); g_system->setShakePos(0); g_system->updateScreen(); -- cgit v1.2.3 From 89988af11ddf2feb0a028230d544b39c5cdc96bd Mon Sep 17 00:00:00 2001 From: Neeraj Kumar Date: Sat, 24 Jul 2010 21:02:21 +0000 Subject: TESTBED: reimplemented the config functionality using ConfigFile Class svn-id: r51258 --- engines/testbed/graphics.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines/testbed/graphics.cpp') diff --git a/engines/testbed/graphics.cpp b/engines/testbed/graphics.cpp index 4cbe963031..88e44b8d0a 100644 --- a/engines/testbed/graphics.cpp +++ b/engines/testbed/graphics.cpp @@ -599,7 +599,7 @@ bool GFXtests::mouseMovements() { Common::String info = "Testing Automated Mouse movements.\n" "You should expect cursor hotspot(top-left corner) to automatically move from (0, 0) to (100, 100).\n" - "There we have a rectangle drawn, finally the rectangle should symmetrically contain the cursor."; + "There we have a rectangle drawn, finally the cursor would lie centred in that rectangle."; if (Testsuite::handleInteractiveInput(info, "OK", "Skip", kOptionRight)) { Testsuite::logPrintf("Info! Skipping test : Mouse Movements"); -- cgit v1.2.3 From c675c1fe296f3fad5e11fca8671fa4c6cd11c3be Mon Sep 17 00:00:00 2001 From: Neeraj Kumar Date: Sat, 24 Jul 2010 22:01:15 +0000 Subject: TESTBED: added a test for checking cursor trails in the GUI, fixed some display stuff svn-id: r51263 --- engines/testbed/graphics.cpp | 45 ++++++++++++++++++++++++++++++++------------ 1 file changed, 33 insertions(+), 12 deletions(-) (limited to 'engines/testbed/graphics.cpp') diff --git a/engines/testbed/graphics.cpp b/engines/testbed/graphics.cpp index 88e44b8d0a..4ac683568f 100644 --- a/engines/testbed/graphics.cpp +++ b/engines/testbed/graphics.cpp @@ -74,6 +74,7 @@ GFXTestSuite::GFXTestSuite() { // Specific Tests: addTest("PaletteRotation", &GFXtests::paletteRotation); + addTest("cursorTrailsInGUI", &GFXtests::cursorTrails); //addTest("Pixel Formats", &GFXtests::pixelFormats); } @@ -399,7 +400,7 @@ bool GFXtests::fullScreenMode() { Common::Rect rect = Testsuite::writeOnScreen("Testing fullscreen mode", pt); if (Testsuite::handleInteractiveInput(info, "OK", "Skip", kOptionRight)) { - Testsuite::logPrintf("Info! Skipping test : FullScreenMode"); + Testsuite::logPrintf("Info! Skipping test : FullScreenMode\n"); return true; } @@ -481,7 +482,7 @@ bool GFXtests::aspectRatio() { " an ellipse otherwise."; if (Testsuite::handleInteractiveInput(info, "OK", "Skip", kOptionRight)) { - Testsuite::logPrintf("Info! Skipping test : Aspect Ratio"); + Testsuite::logPrintf("Info! Skipping test : Aspect Ratio\n"); return true; } // Draw an ellipse on the screen @@ -554,7 +555,7 @@ bool GFXtests::palettizedCursors() { if (Testsuite::handleInteractiveInput(info, "OK", "Skip", kOptionRight)) { - Testsuite::logPrintf("Info! Skipping test : Palettized Cursors"); + Testsuite::logPrintf("Info! Skipping test : Palettized Cursors\n"); return true; } @@ -602,7 +603,7 @@ bool GFXtests::mouseMovements() { "There we have a rectangle drawn, finally the cursor would lie centred in that rectangle."; if (Testsuite::handleInteractiveInput(info, "OK", "Skip", kOptionRight)) { - Testsuite::logPrintf("Info! Skipping test : Mouse Movements"); + Testsuite::logPrintf("Info! Skipping test : Mouse Movements\n"); return true; } @@ -648,7 +649,7 @@ bool GFXtests::copyRectToScreen() { "You should expect to see a 20x40 yellow horizontal rectangle centred at the screen."; if (Testsuite::handleInteractiveInput(info, "OK", "Skip", kOptionRight)) { - Testsuite::logPrintf("Info! Skipping test : Blitting Bitmap"); + Testsuite::logPrintf("Info! Skipping test : Blitting Bitmap\n"); return true; } @@ -681,7 +682,7 @@ bool GFXtests::iconifyWindow() { "you should expect the window to be minimized.\n However you would manually need to de-iconify."; if (Testsuite::handleInteractiveInput(info, "OK", "Skip", kOptionRight)) { - Testsuite::logPrintf("Info! Skipping test : Iconifying window"); + Testsuite::logPrintf("Info! Skipping test : Iconifying window\n"); return true; } @@ -730,7 +731,7 @@ bool GFXtests::scaledCursors() { "This may take time, You may skip the later scalers and just examine the first three i.e 1x, 2x and 3x"; if (Testsuite::handleInteractiveInput(info, "OK", "Skip", kOptionRight)) { - Testsuite::logPrintf("Info! Skipping test : Scaled Cursors"); + Testsuite::logPrintf("Info! Skipping test : Scaled Cursors\n"); return true; } @@ -792,7 +793,7 @@ bool GFXtests::shakingEffect() { Common::String info = "Shaking test. You should expect the graphics(text/bars etc) drawn on the screen to shake!"; if (Testsuite::handleInteractiveInput(info, "OK", "Skip", kOptionRight)) { - Testsuite::logPrintf("Info! Skipping test : Shaking Effect"); + Testsuite::logPrintf("Info! Skipping test : Shaking Effect\n"); return true; } @@ -821,7 +822,7 @@ bool GFXtests::focusRectangle() { "If this feature is implemented, the focus should be toggled between the two rectangles on the corners"; if (Testsuite::handleInteractiveInput(info, "OK", "Skip", kOptionRight)) { - Testsuite::logPrintf("Info! Skipping test : focus Rectangle"); + Testsuite::logPrintf("Info! Skipping test : focus Rectangle\n"); return true; } @@ -868,7 +869,7 @@ bool GFXtests::overlayGraphics() { Common::String info = "Overlay Graphics. You should expect to see a green colored rectangle on the screen"; if (Testsuite::handleInteractiveInput(info, "OK", "Skip", kOptionRight)) { - Testsuite::logPrintf("Info! Skipping test : Overlay Graphics"); + Testsuite::logPrintf("Info! Skipping test : Overlay Graphics\n"); return true; } @@ -905,7 +906,7 @@ bool GFXtests::paletteRotation() { "Note that the screen graphics change without having to draw anything."; if (Testsuite::handleInteractiveInput(info, "OK", "Skip", kOptionRight)) { - Testsuite::logPrintf("Info! Skipping test : palette Rotation"); + Testsuite::logPrintf("Info! Skipping test : palette Rotation\n"); return true; } Common::Point pt(0, 10); @@ -982,13 +983,33 @@ bool GFXtests::paletteRotation() { return true; } +bool GFXtests::cursorTrails() { + Common::String info = "With some shake offset the cursor was known to leave trails in the GUI\n" + "Here we set some offset and ask user to check for mouse trails, \n" + "the test is passed when there are no trails"; + + if (Testsuite::handleInteractiveInput(info, "OK", "Skip", kOptionRight)) { + Testsuite::logPrintf("Info! Skipping test : Cursor Trails\n"); + return true; + } + bool passed = false; + g_system->setShakePos(25); + g_system->updateScreen(); + if (Testsuite::handleInteractiveInput("Does the cursor leaves trails while moving?", "Yes", "No", kOptionRight)) { + passed = true; + } + g_system->setShakePos(0); + g_system->updateScreen(); + return passed; +} + bool GFXtests::pixelFormats() { Testsuite::clearScreen(); Common::String info = "Testing pixel formats. Here we iterate over all the supported pixel formats and display some colors using them\n" "This may take long, especially if the backend supports many pixel formats"; if (Testsuite::handleInteractiveInput(info, "OK", "Skip", kOptionRight)) { - Testsuite::logPrintf("Info! Skipping test : focus Rectangle"); + Testsuite::logPrintf("Info! Skipping test : focus Rectangle\n"); return true; } -- cgit v1.2.3 From a9941138dadd796ca2a8fbd6e2c9c66436a48c4b Mon Sep 17 00:00:00 2001 From: Neeraj Kumar Date: Sun, 25 Jul 2010 20:50:59 +0000 Subject: TETBED: fixed the boundary error in palette rotation, added colored progress bar now svn-id: r51284 --- engines/testbed/graphics.cpp | 38 +++++++++++++++++++++----------------- 1 file changed, 21 insertions(+), 17 deletions(-) (limited to 'engines/testbed/graphics.cpp') diff --git a/engines/testbed/graphics.cpp b/engines/testbed/graphics.cpp index 4ac683568f..38f5daf35d 100644 --- a/engines/testbed/graphics.cpp +++ b/engines/testbed/graphics.cpp @@ -82,6 +82,12 @@ void GFXTestSuite::setCustomColor(uint r, uint g, uint b) { _palette[8] = r; _palette[9] = g; _palette[10] = b; + + // Set colorNum kColorSpecial with a special color. + int absIndx = kColorSpecial * 4; + _palette[absIndx + 1] = 173; + _palette[absIndx + 2] = 255; + _palette[absIndx + 3] = 47; g_system->setPalette(_palette, 0, 256); } @@ -125,7 +131,7 @@ void GFXtests::HSVtoRGB(int &rComp, int &gComp, int &bComp, int hue, int sat, in float g = gComp; float b = bComp; - float h = hue * (360 / 254.0); // two colors are left for bg and fg + float h = hue * (360 / 256.0); // All colors are tried float s = sat; float v = val; @@ -901,26 +907,25 @@ bool GFXtests::overlayGraphics() { bool GFXtests::paletteRotation() { - Testsuite::clearScreen(); Common::String info = "Palette rotation. Here we draw a full 256 colored rainbow and then rotate it.\n" - "Note that the screen graphics change without having to draw anything."; + "Note that the screen graphics change without having to draw anything.\n" + "The palette should appear to rotate, Click the mouse button to exit."; if (Testsuite::handleInteractiveInput(info, "OK", "Skip", kOptionRight)) { Testsuite::logPrintf("Info! Skipping test : palette Rotation\n"); return true; } Common::Point pt(0, 10); - Testsuite::writeOnScreen("Rotating palettes, palettes rotate towards left, click to stop!", pt); + Testsuite::clearEntireScreen(); // Use 256 colors - byte palette[256 * 4] = {0, 0, 0, 0, - 255, 255, 255, 0}; + byte palette[256 * 4] = {0}; int r, g, b; int colIndx; - for (int i = 2; i < 256; i++) { - HSVtoRGB(r, g, b, i - 2, 1, 1); + for (int i = 0; i < 256; i++) { + HSVtoRGB(r, g, b, i, 1, 1); colIndx = i * 4; palette[colIndx] = r; palette[colIndx + 1] = g; @@ -930,29 +935,28 @@ bool GFXtests::paletteRotation() { // Initialize this palette. g_system->setPalette(palette, 0, 256); - // Draw 254 Rectangles, each 1 pixel wide and 10 pixels long + // Draw 256 Rectangles, each 1 pixel wide and 10 pixels long // one for 0-255 color range other for 0-127-255 range - byte buffer[254 * 30] = {0}; + byte buffer[256 * 30] = {0}; for (int i = 0; i < 30; i++) { - for (int j = 0; j < 254; j++) { + for (int j = 0; j < 256; j++) { if (i < 10) { - buffer[i * 254 + j] = j + 2; + buffer[i * 256 + j] = j + 2; } else if (i < 20) { - buffer[i * 254 + j] = 0; + buffer[i * 256 + j] = 0; } else { - buffer[i * 254 + j] = ((j + 127) % 254) + 2; + buffer[i * 256 + j] = ((j + 127) % 256) + 2; } } } - g_system->copyRectToScreen(buffer, 254, 22, 50, 254, 30); + g_system->copyRectToScreen(buffer, 256, 22, 50, 256, 30); // Show mouse CursorMan.showMouse(true); g_system->updateScreen(); - g_system->delayMillis(1000); bool toRotate = true; Common::Event event; @@ -964,7 +968,7 @@ bool GFXtests::paletteRotation() { } } - rotatePalette(&palette[8], 254); + rotatePalette(palette, 256); g_system->delayMillis(10); g_system->setPalette(palette, 0, 256); -- cgit v1.2.3 From 4e92b3a17ea963d3c006c93abd28287e0fac153a Mon Sep 17 00:00:00 2001 From: Neeraj Kumar Date: Mon, 9 Aug 2010 20:10:53 +0000 Subject: TESTBED: Some refinemnts related to skipping tests and display in GUI svn-id: r51945 --- engines/testbed/graphics.cpp | 119 +++++++++++++++++++++---------------------- 1 file changed, 59 insertions(+), 60 deletions(-) (limited to 'engines/testbed/graphics.cpp') diff --git a/engines/testbed/graphics.cpp b/engines/testbed/graphics.cpp index 38f5daf35d..22b453a763 100644 --- a/engines/testbed/graphics.cpp +++ b/engines/testbed/graphics.cpp @@ -397,7 +397,7 @@ void GFXtests::drawEllipse(int cx, int cy, int a, int b) { /** * Tests the fullscreen mode by: toggling between fullscreen and windowed mode */ -bool GFXtests::fullScreenMode() { +TestExitStatus GFXtests::fullScreenMode() { Testsuite::clearScreen(); Common::String info = "Fullscreen test. Here you should expect a toggle between windowed and fullscreen states depending " "upon your initial state."; @@ -407,12 +407,12 @@ bool GFXtests::fullScreenMode() { if (Testsuite::handleInteractiveInput(info, "OK", "Skip", kOptionRight)) { Testsuite::logPrintf("Info! Skipping test : FullScreenMode\n"); - return true; + return kTestSkipped; } bool isFeaturePresent; bool isFeatureEnabled; - bool passed = true; + TestExitStatus passed = kTestPassed; Common::String prompt; OptionSelected shouldSelect; @@ -435,7 +435,7 @@ bool GFXtests::fullScreenMode() { if (!Testsuite::handleInteractiveInput(prompt, "Fullscreen", "Windowed", shouldSelect)) { // User selected incorrect current state - passed = false; + passed = kTestFailed; Testsuite::logDetailedPrintf("g_system->getFeatureState() failed\n"); } @@ -453,7 +453,7 @@ bool GFXtests::fullScreenMode() { if (!Testsuite::handleInteractiveInput(prompt, "Fullscreen", "Windowed", shouldSelect)) { // User selected incorrect mode - passed = false; + passed = kTestFailed; Testsuite::logDetailedPrintf("g_system->setFeatureState() failed\n"); } @@ -468,7 +468,7 @@ bool GFXtests::fullScreenMode() { if (!Testsuite::handleInteractiveInput(prompt, "Yes, it is", "Nopes", shouldSelect)) { // User selected incorrect mode Testsuite::logDetailedPrintf("switching back to initial state failed\n"); - passed = false; + passed = kTestFailed; } } else { @@ -481,7 +481,7 @@ bool GFXtests::fullScreenMode() { /** * Tests the aspect ratio correction by: drawing an ellipse, when corrected the ellipse should render to a circle */ -bool GFXtests::aspectRatio() { +TestExitStatus GFXtests::aspectRatio() { Testsuite::clearScreen(); Common::String info = "Aspect Ratio Correction test. If aspect ratio correction is enabled you should expect a circle on screen," @@ -489,14 +489,14 @@ bool GFXtests::aspectRatio() { if (Testsuite::handleInteractiveInput(info, "OK", "Skip", kOptionRight)) { Testsuite::logPrintf("Info! Skipping test : Aspect Ratio\n"); - return true; + return kTestSkipped; } // Draw an ellipse on the screen drawEllipse(80, 160, 72, 60); bool isFeaturePresent; bool isFeatureEnabled; - bool passed; + TestExitStatus passed = kTestPassed; Common::String prompt; OptionSelected shouldSelect; @@ -510,7 +510,7 @@ bool GFXtests::aspectRatio() { prompt = " What does the curve on screen appears to you ?"; if (!Testsuite::handleInteractiveInput(prompt, "Circle", "Ellipse", shouldSelect)) { // User selected incorrect option - passed = false; + passed = kTestFailed; Testsuite::logDetailedPrintf("Aspect Ratio Correction failed\n"); } @@ -524,7 +524,7 @@ bool GFXtests::aspectRatio() { prompt = " What does the curve on screen appears to you ?"; if (!Testsuite::handleInteractiveInput(prompt, "Circle", "Ellipse", shouldSelect)) { // User selected incorrect option - passed = false; + passed = kTestFailed; Testsuite::logDetailedPrintf("Aspect Ratio Correction failed\n"); } @@ -540,7 +540,7 @@ bool GFXtests::aspectRatio() { if (Testsuite::handleInteractiveInput("This should definetely be your initial state?", "Yes, it is", "Nopes", kOptionRight)) { // User selected incorrect mode Testsuite::logDetailedPrintf("Switching back to initial state failed\n"); - passed = false; + passed = kTestFailed; } return passed; @@ -550,7 +550,7 @@ bool GFXtests::aspectRatio() { * Tests Palettized cursors. * Method: Create a yellow colored cursor, should be able to move it. Once you click test terminates */ -bool GFXtests::palettizedCursors() { +TestExitStatus GFXtests::palettizedCursors() { Testsuite::clearScreen(); Common::String info = "Palettized Cursors test.\n " @@ -562,17 +562,17 @@ bool GFXtests::palettizedCursors() { if (Testsuite::handleInteractiveInput(info, "OK", "Skip", kOptionRight)) { Testsuite::logPrintf("Info! Skipping test : Palettized Cursors\n"); - return true; + return kTestSkipped; } - bool passed = true; + TestExitStatus passed = kTestPassed; // Testing with cursor Palette setupMouseLoop(); if (Testsuite::handleInteractiveInput("Which color did the cursor appeared to you?", "Yellow", "Any other", kOptionRight)) { Testsuite::logDetailedPrintf("Couldn't use cursor palette for rendering cursor\n"); - passed = false; + passed = kTestFailed; } // Testing with game Palette @@ -581,11 +581,11 @@ bool GFXtests::palettizedCursors() { if (Testsuite::handleInteractiveInput("Which color did the cursor appeared to you?", "Red", "Any other", kOptionRight)) { Testsuite::logDetailedPrintf("Couldn't use Game palette for rendering cursor\n"); - passed = false; + passed = kTestFailed; } if (!Testsuite::handleInteractiveInput("Did test run as was described?")) { - passed = false; + passed = kTestFailed; } // re-enable cursor palette @@ -599,7 +599,7 @@ bool GFXtests::palettizedCursors() { * Tests automated mouse movements. "Warp" functionality provided by the backend. */ -bool GFXtests::mouseMovements() { +TestExitStatus GFXtests::mouseMovements() { Testsuite::clearScreen(); // Make mouse visible CursorMan.showMouse(true); @@ -610,7 +610,7 @@ bool GFXtests::mouseMovements() { if (Testsuite::handleInteractiveInput(info, "OK", "Skip", kOptionRight)) { Testsuite::logPrintf("Info! Skipping test : Mouse Movements\n"); - return true; + return kTestSkipped; } // Draw Rectangle @@ -636,10 +636,10 @@ bool GFXtests::mouseMovements() { CursorMan.showMouse(false); if (Testsuite::handleInteractiveInput("Was the cursor symmetrically contained in the rectangle at (100, 100)?", "Yes", "No", kOptionRight)) { - return false; + return kTestFailed; } - return true; + return kTestPassed; } @@ -648,7 +648,7 @@ bool GFXtests::mouseMovements() { * This basically blits the screen by the contents of its buffer. * */ -bool GFXtests::copyRectToScreen() { +TestExitStatus GFXtests::copyRectToScreen() { Testsuite::clearScreen(); Common::String info = "Testing Blitting a Bitmap to screen.\n" @@ -656,7 +656,7 @@ bool GFXtests::copyRectToScreen() { if (Testsuite::handleInteractiveInput(info, "OK", "Skip", kOptionRight)) { Testsuite::logPrintf("Info! Skipping test : Blitting Bitmap\n"); - return true; + return kTestSkipped; } GFXTestSuite::setCustomColor(255, 255, 0); @@ -671,17 +671,17 @@ bool GFXtests::copyRectToScreen() { g_system->delayMillis(1000); if (Testsuite::handleInteractiveInput("Did you see yellow rectangle?", "Yes", "No", kOptionRight)) { - return false; + return kTestFailed; } - return true; + return kTestPassed; } /** * Testing feature : Iconifying window * It is expected the screen minimizes when this feature is enabled */ -bool GFXtests::iconifyWindow() { +TestExitStatus GFXtests::iconifyWindow() { Testsuite::clearScreen(); Common::String info = "Testing Iconify Window mode.\n If the feature is supported by the backend, " @@ -689,7 +689,7 @@ bool GFXtests::iconifyWindow() { if (Testsuite::handleInteractiveInput(info, "OK", "Skip", kOptionRight)) { Testsuite::logPrintf("Info! Skipping test : Iconifying window\n"); - return true; + return kTestSkipped; } Common::Point pt(0, 100); @@ -719,16 +719,16 @@ bool GFXtests::iconifyWindow() { } if (Testsuite::handleInteractiveInput("Did you see window minimized?", "Yes", "No", kOptionRight)) { - return false; + return kTestFailed; } - return true; + return kTestPassed; } /** * Testing feature: Scaled cursors */ -bool GFXtests::scaledCursors() { +TestExitStatus GFXtests::scaledCursors() { Testsuite::clearScreen(); Common::String info = "Testing : Scaled cursors\n" @@ -738,7 +738,7 @@ bool GFXtests::scaledCursors() { if (Testsuite::handleInteractiveInput(info, "OK", "Skip", kOptionRight)) { Testsuite::logPrintf("Info! Skipping test : Scaled Cursors\n"); - return true; + return kTestSkipped; } int maxLimit = 1000; @@ -771,7 +771,7 @@ bool GFXtests::scaledCursors() { Testsuite::clearScreen(); } else { Testsuite::logDetailedPrintf("Switching to graphics mode %s failed\n", gfxMode->name); - return false; + return kTestFailed; } gfxMode++; maxLimit--; @@ -785,22 +785,22 @@ bool GFXtests::scaledCursors() { if (gfxError != OSystem::kTransactionSuccess || !isGFXModeSet) { Testsuite::logDetailedPrintf("Switcing to initial state failed\n"); - return false; + return kTestFailed; } // Done with cursors, Make them invisible, any other test may enable and use it. CursorMan.showMouse(false); - return true; + return kTestPassed; } -bool GFXtests::shakingEffect() { +TestExitStatus GFXtests::shakingEffect() { Testsuite::clearScreen(); Common::String info = "Shaking test. You should expect the graphics(text/bars etc) drawn on the screen to shake!"; if (Testsuite::handleInteractiveInput(info, "OK", "Skip", kOptionRight)) { Testsuite::logPrintf("Info! Skipping test : Shaking Effect\n"); - return true; + return kTestSkipped; } Common::Point pt(0, 100); @@ -816,12 +816,12 @@ bool GFXtests::shakingEffect() { if (Testsuite::handleInteractiveInput("Did the Shaking test worked as you were expecting?", "Yes", "No", kOptionRight)) { Testsuite::logDetailedPrintf("Shaking Effect didn't worked"); - return false; + return kTestFailed; } - return true; + return kTestPassed; } -bool GFXtests::focusRectangle() { +TestExitStatus GFXtests::focusRectangle() { Testsuite::clearScreen(); Common::String info = "Testing : Setting and hiding Focus \n" @@ -829,7 +829,7 @@ bool GFXtests::focusRectangle() { if (Testsuite::handleInteractiveInput(info, "OK", "Skip", kOptionRight)) { Testsuite::logPrintf("Info! Skipping test : focus Rectangle\n"); - return true; + return kTestSkipped; } const Graphics::Font &font(*FontMan.getFontByUsage(Graphics::FontManager::kConsoleFont)); @@ -867,16 +867,16 @@ bool GFXtests::focusRectangle() { Testsuite::logDetailedPrintf("Focus Rectangle feature doesn't works. Check platform.\n"); } - return true; + return kTestPassed; } -bool GFXtests::overlayGraphics() { +TestExitStatus GFXtests::overlayGraphics() { Testsuite::clearScreen(); Common::String info = "Overlay Graphics. You should expect to see a green colored rectangle on the screen"; if (Testsuite::handleInteractiveInput(info, "OK", "Skip", kOptionRight)) { Testsuite::logPrintf("Info! Skipping test : Overlay Graphics\n"); - return true; + return kTestSkipped; } Graphics::PixelFormat pf = g_system->getOverlayFormat(); @@ -899,13 +899,13 @@ bool GFXtests::overlayGraphics() { if (Testsuite::handleInteractiveInput("Did you see a green overlayed rectangle?", "Yes", "No", kOptionRight)) { Testsuite::logDetailedPrintf("Overlay Rectangle feature doesn't works\n"); - return false; + return kTestFailed; } - return true; + return kTestPassed; } -bool GFXtests::paletteRotation() { +TestExitStatus GFXtests::paletteRotation() { Common::String info = "Palette rotation. Here we draw a full 256 colored rainbow and then rotate it.\n" "Note that the screen graphics change without having to draw anything.\n" @@ -913,7 +913,7 @@ bool GFXtests::paletteRotation() { if (Testsuite::handleInteractiveInput(info, "OK", "Skip", kOptionRight)) { Testsuite::logPrintf("Info! Skipping test : palette Rotation\n"); - return true; + return kTestSkipped; } Common::Point pt(0, 10); Testsuite::clearEntireScreen(); @@ -981,40 +981,40 @@ bool GFXtests::paletteRotation() { Testsuite::clearScreen(); if(Testsuite::handleInteractiveInput("Did you saw a rotation in colors of rectangles displayed on screen?", "Yes", "No", kOptionRight)) { - return false; + return kTestFailed; } - return true; + return kTestPassed; } -bool GFXtests::cursorTrails() { +TestExitStatus GFXtests::cursorTrails() { Common::String info = "With some shake offset the cursor was known to leave trails in the GUI\n" "Here we set some offset and ask user to check for mouse trails, \n" "the test is passed when there are no trails"; if (Testsuite::handleInteractiveInput(info, "OK", "Skip", kOptionRight)) { Testsuite::logPrintf("Info! Skipping test : Cursor Trails\n"); - return true; + return kTestSkipped; } - bool passed = false; + TestExitStatus passed = kTestFailed; g_system->setShakePos(25); g_system->updateScreen(); if (Testsuite::handleInteractiveInput("Does the cursor leaves trails while moving?", "Yes", "No", kOptionRight)) { - passed = true; + passed = kTestPassed; } g_system->setShakePos(0); g_system->updateScreen(); return passed; } -bool GFXtests::pixelFormats() { +TestExitStatus GFXtests::pixelFormats() { Testsuite::clearScreen(); Common::String info = "Testing pixel formats. Here we iterate over all the supported pixel formats and display some colors using them\n" "This may take long, especially if the backend supports many pixel formats"; if (Testsuite::handleInteractiveInput(info, "OK", "Skip", kOptionRight)) { - Testsuite::logPrintf("Info! Skipping test : focus Rectangle\n"); - return true; + Testsuite::logPrintf("Info! Skipping test : Pixel Formats\n"); + return kTestSkipped; } Common::List pfList = g_system->getSupportedFormats(); @@ -1055,7 +1055,6 @@ bool GFXtests::pixelFormats() { Common::Point pt(0, 170); Common::String msg; - // XXX: Can use snprintf? msg = Common::String::printf("Testing Pixel Formats, %d of %d", numFormatsTested, pfList.size()); Testsuite::writeOnScreen(msg, pt, true); @@ -1093,10 +1092,10 @@ bool GFXtests::pixelFormats() { if (numFailed) { Testsuite::logDetailedPrintf("Pixel Format test: Failed : %d, Passed : %d, Ignored %d\n",numFailed, numPassed, numFormatsTested - (numPassed + numFailed)); - return false; + return kTestFailed; } - return true; + return kTestPassed; } } // End of namespace Testbed -- cgit v1.2.3 From acb32580ce440aa687309999ed11ee6e5ca1fa72 Mon Sep 17 00:00:00 2001 From: Neeraj Kumar Date: Mon, 9 Aug 2010 21:18:27 +0000 Subject: TESTBED: Some more refinements to the GUI and mouse event tests svn-id: r51946 --- engines/testbed/graphics.cpp | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'engines/testbed/graphics.cpp') diff --git a/engines/testbed/graphics.cpp b/engines/testbed/graphics.cpp index 22b453a763..40f77a98c1 100644 --- a/engines/testbed/graphics.cpp +++ b/engines/testbed/graphics.cpp @@ -584,7 +584,7 @@ TestExitStatus GFXtests::palettizedCursors() { passed = kTestFailed; } - if (!Testsuite::handleInteractiveInput("Did test run as was described?")) { + if (!Testsuite::handleInteractiveInput(" Did test run as was described? ")) { passed = kTestFailed; } @@ -635,7 +635,7 @@ TestExitStatus GFXtests::mouseMovements() { g_system->delayMillis(1500); CursorMan.showMouse(false); - if (Testsuite::handleInteractiveInput("Was the cursor symmetrically contained in the rectangle at (100, 100)?", "Yes", "No", kOptionRight)) { + if (Testsuite::handleInteractiveInput("Was the cursor centred in the rectangle at (100, 100)?", "Yes", "No", kOptionRight)) { return kTestFailed; } @@ -670,7 +670,7 @@ TestExitStatus GFXtests::copyRectToScreen() { g_system->updateScreen(); g_system->delayMillis(1000); - if (Testsuite::handleInteractiveInput("Did you see yellow rectangle?", "Yes", "No", kOptionRight)) { + if (Testsuite::handleInteractiveInput(" Did you see yellow rectangle ? ", "Yes", "No", kOptionRight)) { return kTestFailed; } @@ -718,7 +718,7 @@ TestExitStatus GFXtests::iconifyWindow() { Testsuite::displayMessage("feature not supported"); } - if (Testsuite::handleInteractiveInput("Did you see window minimized?", "Yes", "No", kOptionRight)) { + if (Testsuite::handleInteractiveInput(" Did you see the window minimized? ", "Yes", "No", kOptionRight)) { return kTestFailed; } @@ -733,7 +733,7 @@ TestExitStatus GFXtests::scaledCursors() { Testsuite::clearScreen(); Common::String info = "Testing : Scaled cursors\n" "Here every graphics mode is tried with a cursorTargetScale of 1, 2 and 3.\n" - "The expected cursor size is drawn as a rectangle, the cursor should entirely cover that rectangle.\n" + "The expected cursor size is drawn as a rectangle.\n The cursor should approximately match that rectangle.\n" "This may take time, You may skip the later scalers and just examine the first three i.e 1x, 2x and 3x"; if (Testsuite::handleInteractiveInput(info, "OK", "Skip", kOptionRight)) { @@ -909,7 +909,8 @@ TestExitStatus GFXtests::paletteRotation() { Common::String info = "Palette rotation. Here we draw a full 256 colored rainbow and then rotate it.\n" "Note that the screen graphics change without having to draw anything.\n" - "The palette should appear to rotate, Click the mouse button to exit."; + "The palette should appear to rotate, as a result, the background will change its color too.\n" + "Click the mouse button to exit."; if (Testsuite::handleInteractiveInput(info, "OK", "Skip", kOptionRight)) { Testsuite::logPrintf("Info! Skipping test : palette Rotation\n"); @@ -980,7 +981,7 @@ TestExitStatus GFXtests::paletteRotation() { GFXTestSuite::setCustomColor(255, 0, 0); Testsuite::clearScreen(); - if(Testsuite::handleInteractiveInput("Did you saw a rotation in colors of rectangles displayed on screen?", "Yes", "No", kOptionRight)) { + if(Testsuite::handleInteractiveInput("Did you see a rotation in colors of rectangles displayed on screen?", "Yes", "No", kOptionRight)) { return kTestFailed; } -- cgit v1.2.3 From 0a7bda50cca6ac76245254c6eb0de84547a018c1 Mon Sep 17 00:00:00 2001 From: Neeraj Kumar Date: Sat, 14 Aug 2010 08:32:39 +0000 Subject: TESTBED: formatting fix, deleted spaces/tabs at end of line svn-id: r52081 --- engines/testbed/graphics.cpp | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) (limited to 'engines/testbed/graphics.cpp') diff --git a/engines/testbed/graphics.cpp b/engines/testbed/graphics.cpp index 40f77a98c1..d2e9a4ccad 100644 --- a/engines/testbed/graphics.cpp +++ b/engines/testbed/graphics.cpp @@ -82,7 +82,7 @@ void GFXTestSuite::setCustomColor(uint r, uint g, uint b) { _palette[8] = r; _palette[9] = g; _palette[10] = b; - + // Set colorNum kColorSpecial with a special color. int absIndx = kColorSpecial * 4; _palette[absIndx + 1] = 173; @@ -270,7 +270,7 @@ void GFXtests::setupMouseLoop(bool disableCursorPalette, const char *gfxModeName if (!gfxScalarMode.equals("")) { info = "The cursor size (yellow) should match the red rectangle."; } - + Testsuite::writeOnScreen(info, pt); info = "GFX Mode"; @@ -346,7 +346,7 @@ void GFXtests::setupMouseLoop(bool disableCursorPalette, const char *gfxModeName * Used by aspectRatio() */ void GFXtests::drawEllipse(int cx, int cy, int a, int b) { - + // Take a buffer of screen size int width = g_system->getWidth(); int height = Testsuite::getDisplayRegionCoordinates().y; @@ -404,7 +404,7 @@ TestExitStatus GFXtests::fullScreenMode() { Common::Point pt(0, 100); Common::Rect rect = Testsuite::writeOnScreen("Testing fullscreen mode", pt); - + if (Testsuite::handleInteractiveInput(info, "OK", "Skip", kOptionRight)) { Testsuite::logPrintf("Info! Skipping test : FullScreenMode\n"); return kTestSkipped; @@ -482,7 +482,7 @@ TestExitStatus GFXtests::fullScreenMode() { * Tests the aspect ratio correction by: drawing an ellipse, when corrected the ellipse should render to a circle */ TestExitStatus GFXtests::aspectRatio() { - + Testsuite::clearScreen(); Common::String info = "Aspect Ratio Correction test. If aspect ratio correction is enabled you should expect a circle on screen," " an ellipse otherwise."; @@ -564,12 +564,12 @@ TestExitStatus GFXtests::palettizedCursors() { Testsuite::logPrintf("Info! Skipping test : Palettized Cursors\n"); return kTestSkipped; } - + TestExitStatus passed = kTestPassed; // Testing with cursor Palette setupMouseLoop(); - + if (Testsuite::handleInteractiveInput("Which color did the cursor appeared to you?", "Yellow", "Any other", kOptionRight)) { Testsuite::logDetailedPrintf("Couldn't use cursor palette for rendering cursor\n"); passed = kTestFailed; @@ -603,7 +603,7 @@ TestExitStatus GFXtests::mouseMovements() { Testsuite::clearScreen(); // Make mouse visible CursorMan.showMouse(true); - + Common::String info = "Testing Automated Mouse movements.\n" "You should expect cursor hotspot(top-left corner) to automatically move from (0, 0) to (100, 100).\n" "There we have a rectangle drawn, finally the cursor would lie centred in that rectangle."; @@ -612,7 +612,7 @@ TestExitStatus GFXtests::mouseMovements() { Testsuite::logPrintf("Info! Skipping test : Mouse Movements\n"); return kTestSkipped; } - + // Draw Rectangle Graphics::Surface *screen = g_system->lockScreen(); screen->fillRect(Common::Rect::center(106, 106, 14, 14), 2); @@ -649,7 +649,7 @@ TestExitStatus GFXtests::mouseMovements() { * */ TestExitStatus GFXtests::copyRectToScreen() { - + Testsuite::clearScreen(); Common::String info = "Testing Blitting a Bitmap to screen.\n" "You should expect to see a 20x40 yellow horizontal rectangle centred at the screen."; @@ -658,7 +658,7 @@ TestExitStatus GFXtests::copyRectToScreen() { Testsuite::logPrintf("Info! Skipping test : Blitting Bitmap\n"); return kTestSkipped; } - + GFXTestSuite::setCustomColor(255, 255, 0); byte buffer[20 * 40]; memset(buffer, 2, 20 * 40); @@ -682,7 +682,7 @@ TestExitStatus GFXtests::copyRectToScreen() { * It is expected the screen minimizes when this feature is enabled */ TestExitStatus GFXtests::iconifyWindow() { - + Testsuite::clearScreen(); Common::String info = "Testing Iconify Window mode.\n If the feature is supported by the backend, " "you should expect the window to be minimized.\n However you would manually need to de-iconify."; @@ -691,7 +691,7 @@ TestExitStatus GFXtests::iconifyWindow() { Testsuite::logPrintf("Info! Skipping test : Iconifying window\n"); return kTestSkipped; } - + Common::Point pt(0, 100); Common::Rect rect = Testsuite::writeOnScreen("Testing Iconifying window", pt); @@ -794,7 +794,7 @@ TestExitStatus GFXtests::scaledCursors() { } TestExitStatus GFXtests::shakingEffect() { - + Testsuite::clearScreen(); Common::String info = "Shaking test. You should expect the graphics(text/bars etc) drawn on the screen to shake!"; @@ -822,7 +822,7 @@ TestExitStatus GFXtests::shakingEffect() { } TestExitStatus GFXtests::focusRectangle() { - + Testsuite::clearScreen(); Common::String info = "Testing : Setting and hiding Focus \n" "If this feature is implemented, the focus should be toggled between the two rectangles on the corners"; @@ -831,7 +831,7 @@ TestExitStatus GFXtests::focusRectangle() { Testsuite::logPrintf("Info! Skipping test : focus Rectangle\n"); return kTestSkipped; } - + const Graphics::Font &font(*FontMan.getFontByUsage(Graphics::FontManager::kConsoleFont)); Graphics::Surface *screen = g_system->lockScreen(); @@ -878,7 +878,7 @@ TestExitStatus GFXtests::overlayGraphics() { Testsuite::logPrintf("Info! Skipping test : Overlay Graphics\n"); return kTestSkipped; } - + Graphics::PixelFormat pf = g_system->getOverlayFormat(); OverlayColor buffer[50 * 100]; @@ -906,7 +906,7 @@ TestExitStatus GFXtests::overlayGraphics() { } TestExitStatus GFXtests::paletteRotation() { - + Common::String info = "Palette rotation. Here we draw a full 256 colored rainbow and then rotate it.\n" "Note that the screen graphics change without having to draw anything.\n" "The palette should appear to rotate, as a result, the background will change its color too.\n" @@ -953,7 +953,7 @@ TestExitStatus GFXtests::paletteRotation() { } g_system->copyRectToScreen(buffer, 256, 22, 50, 256, 30); - + // Show mouse CursorMan.showMouse(true); g_system->updateScreen(); @@ -961,7 +961,7 @@ TestExitStatus GFXtests::paletteRotation() { bool toRotate = true; Common::Event event; - + while (toRotate) { while (g_system->getEventManager()->pollEvent(event)) { if (event.type == Common::EVENT_LBUTTONDOWN || event.type == Common::EVENT_RBUTTONDOWN) { -- cgit v1.2.3 From 5e26238916ae9c22286bd8beaa2d1a139697878d Mon Sep 17 00:00:00 2001 From: Neeraj Kumar Date: Mon, 16 Aug 2010 04:27:05 +0000 Subject: TESTBED: disable aspect ratio correction while running scaling tests svn-id: r52111 --- engines/testbed/graphics.cpp | 45 ++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 43 insertions(+), 2 deletions(-) (limited to 'engines/testbed/graphics.cpp') diff --git a/engines/testbed/graphics.cpp b/engines/testbed/graphics.cpp index d2e9a4ccad..b6a39295bd 100644 --- a/engines/testbed/graphics.cpp +++ b/engines/testbed/graphics.cpp @@ -62,7 +62,7 @@ GFXTestSuite::GFXTestSuite() { // Mouse Layer tests (Palettes and movements) addTest("PalettizedCursors", &GFXtests::palettizedCursors); addTest("MouseMovements", &GFXtests::mouseMovements); - // FIXME: Scaled cursor crsh with odd dimmensions + // FIXME: Scaled cursor crash with odd dimmensions addTest("ScaledCursors", &GFXtests::scaledCursors); // Effects @@ -746,6 +746,14 @@ TestExitStatus GFXtests::scaledCursors() { maxLimit = 3; } + bool isAspectRatioCorrected = g_system->getFeatureState(OSystem::kFeatureAspectRatioCorrection); + + if (isAspectRatioCorrected) { + g_system->beginGFXTransaction(); + g_system->setFeatureState(OSystem::kFeatureAspectRatioCorrection, false); + g_system->endGFXTransaction(); + } + const int currGFXMode = g_system->getGraphicsMode(); const OSystem::GraphicsMode *gfxMode = g_system->getSupportedGraphicsModes(); @@ -753,6 +761,20 @@ TestExitStatus GFXtests::scaledCursors() { // for every graphics mode display cursors for cursorTargetScale 1, 2 and 3 // Switch Graphics mode // FIXME: Crashes with "3x" mode now.: + + info = Common::String::printf("Testing : Scaled cursors with GFX Mode %s\n", gfxMode->name); + if (Testsuite::handleInteractiveInput(info, "OK", "Skip", kOptionRight)) { + Testsuite::logPrintf("\tInfo! Skipping sub-test : Scaled Cursors :: GFX Mode %s\n", gfxMode->name); + gfxMode++; + maxLimit--; + continue; + } + if (Engine::shouldQuit()) { + // Explicit exit requested + Testsuite::logPrintf("Info! Explicit exit requested during scaling test, this test may be incomplete\n"); + return kTestSkipped; + } + g_system->beginGFXTransaction(); bool isGFXModeSet = g_system->setGraphicsMode(gfxMode->id); @@ -775,12 +797,29 @@ TestExitStatus GFXtests::scaledCursors() { } gfxMode++; maxLimit--; + + info = "Did the expected cursor size and the actual cursor size matched?"; + if (Testsuite::handleInteractiveInput(info, "Yes", "No", kOptionRight)) { + Testsuite::logPrintf("\tInfo! Failed sub-test : Scaled Cursors :: GFX Mode %s\n", gfxMode->name); + } + + if (Engine::shouldQuit()) { + // Explicit exit requested + Testsuite::logPrintf("Info! Explicit exit requested during scaling test, this test may be incomplete\n"); + return kTestSkipped; + } + } // Restore Original State g_system->beginGFXTransaction(); bool isGFXModeSet = g_system->setGraphicsMode(currGFXMode); g_system->initSize(320, 200); + + if (isAspectRatioCorrected) { + g_system->setFeatureState(OSystem::kFeatureAspectRatioCorrection, true); + } + OSystem::TransactionError gfxError = g_system->endGFXTransaction(); if (gfxError != OSystem::kTransactionSuccess || !isGFXModeSet) { @@ -805,11 +844,13 @@ TestExitStatus GFXtests::shakingEffect() { Common::Point pt(0, 100); Testsuite::writeOnScreen("If Shaking Effect works, this should shake!", pt); - int times = 35; + int times = 15; while (times--) { g_system->setShakePos(25); + g_system->delayMillis(50); g_system->updateScreen(); g_system->setShakePos(0); + g_system->delayMillis(50); g_system->updateScreen(); } g_system->delayMillis(1500); -- cgit v1.2.3 From 81a646c9bd32662f2a72fc0b3db32105857b9416 Mon Sep 17 00:00:00 2001 From: Neeraj Kumar Date: Mon, 16 Aug 2010 22:04:15 +0000 Subject: TESTBED: added a README file, some description fixes svn-id: r52134 --- engines/testbed/graphics.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'engines/testbed/graphics.cpp') diff --git a/engines/testbed/graphics.cpp b/engines/testbed/graphics.cpp index b6a39295bd..bf82058dbc 100644 --- a/engines/testbed/graphics.cpp +++ b/engines/testbed/graphics.cpp @@ -601,7 +601,7 @@ TestExitStatus GFXtests::palettizedCursors() { TestExitStatus GFXtests::mouseMovements() { Testsuite::clearScreen(); - // Make mouse visible + // Ensure that the cursor is visible CursorMan.showMouse(true); Common::String info = "Testing Automated Mouse movements.\n" @@ -615,6 +615,8 @@ TestExitStatus GFXtests::mouseMovements() { // Draw Rectangle Graphics::Surface *screen = g_system->lockScreen(); + // Ensure that 2 represents red in current palette + GFXTestSuite::setCustomColor(255, 0, 0); screen->fillRect(Common::Rect::center(106, 106, 14, 14), 2); g_system->unlockScreen(); @@ -736,6 +738,12 @@ TestExitStatus GFXtests::scaledCursors() { "The expected cursor size is drawn as a rectangle.\n The cursor should approximately match that rectangle.\n" "This may take time, You may skip the later scalers and just examine the first three i.e 1x, 2x and 3x"; + bool isAspectRatioCorrected = g_system->getFeatureState(OSystem::kFeatureAspectRatioCorrection); + + if (isAspectRatioCorrected) { + info += "\nDisabling Aspect ratio correction, for letting cusors match exactly, will be restored after this test."; + } + if (Testsuite::handleInteractiveInput(info, "OK", "Skip", kOptionRight)) { Testsuite::logPrintf("Info! Skipping test : Scaled Cursors\n"); return kTestSkipped; @@ -746,7 +754,6 @@ TestExitStatus GFXtests::scaledCursors() { maxLimit = 3; } - bool isAspectRatioCorrected = g_system->getFeatureState(OSystem::kFeatureAspectRatioCorrection); if (isAspectRatioCorrected) { g_system->beginGFXTransaction(); -- cgit v1.2.3 From 09ae34f4a4631b72a0b91ef28ec7658c0c00aed5 Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Sun, 12 Sep 2010 14:20:52 +0000 Subject: TESTBED: Fix warnings svn-id: r52685 --- engines/testbed/graphics.cpp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'engines/testbed/graphics.cpp') diff --git a/engines/testbed/graphics.cpp b/engines/testbed/graphics.cpp index 38f5daf35d..a732a74ae2 100644 --- a/engines/testbed/graphics.cpp +++ b/engines/testbed/graphics.cpp @@ -403,7 +403,7 @@ bool GFXtests::fullScreenMode() { "upon your initial state."; Common::Point pt(0, 100); - Common::Rect rect = Testsuite::writeOnScreen("Testing fullscreen mode", pt); + Testsuite::writeOnScreen("Testing fullscreen mode", pt); if (Testsuite::handleInteractiveInput(info, "OK", "Skip", kOptionRight)) { Testsuite::logPrintf("Info! Skipping test : FullScreenMode\n"); @@ -496,7 +496,7 @@ bool GFXtests::aspectRatio() { bool isFeaturePresent; bool isFeatureEnabled; - bool passed; + bool passed = true; Common::String prompt; OptionSelected shouldSelect; @@ -693,7 +693,7 @@ bool GFXtests::iconifyWindow() { } Common::Point pt(0, 100); - Common::Rect rect = Testsuite::writeOnScreen("Testing Iconifying window", pt); + Testsuite::writeOnScreen("Testing Iconifying window", pt); bool isFeaturePresent; bool isFeatureEnabled; @@ -915,7 +915,6 @@ bool GFXtests::paletteRotation() { Testsuite::logPrintf("Info! Skipping test : palette Rotation\n"); return true; } - Common::Point pt(0, 10); Testsuite::clearEntireScreen(); // Use 256 colors @@ -1022,7 +1021,7 @@ bool GFXtests::pixelFormats() { int numFormatsTested = 0; int numPassed = 0; - bool numFailed = 0; + int numFailed = 0; Testsuite::logDetailedPrintf("Testing Pixel Formats. Size of list : %d\n", pfList.size()); @@ -1092,7 +1091,7 @@ bool GFXtests::pixelFormats() { Testsuite::clearScreen(); if (numFailed) { - Testsuite::logDetailedPrintf("Pixel Format test: Failed : %d, Passed : %d, Ignored %d\n",numFailed, numPassed, numFormatsTested - (numPassed + numFailed)); + Testsuite::logDetailedPrintf("Pixel Format test: Failed : %d, Passed : %d, Ignored %d\n", numFailed, numPassed, numFormatsTested - (numPassed + numFailed)); return false; } -- cgit v1.2.3 From 6fed6a75d53259f90b69ca951275e11d6c98042a Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Sat, 18 Sep 2010 09:52:05 +0000 Subject: TESTBED: Fix warnings svn-id: r52790 --- engines/testbed/graphics.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines/testbed/graphics.cpp') diff --git a/engines/testbed/graphics.cpp b/engines/testbed/graphics.cpp index a732a74ae2..7e462a18b0 100644 --- a/engines/testbed/graphics.cpp +++ b/engines/testbed/graphics.cpp @@ -351,7 +351,7 @@ void GFXtests::drawEllipse(int cx, int cy, int a, int b) { int width = g_system->getWidth(); int height = Testsuite::getDisplayRegionCoordinates().y; byte *buffer = new byte[height * width]; - float theta; + double theta; int x, y, x1, y1; memset(buffer, 0, sizeof(byte) * width * height); -- cgit v1.2.3