aboutsummaryrefslogtreecommitdiff
path: root/engines/testbed
diff options
context:
space:
mode:
authorNeeraj Kumar2010-06-13 19:19:06 +0000
committerNeeraj Kumar2010-06-13 19:19:06 +0000
commit3c511eab1a3c9e3be7125a6159265e0f5e25beed (patch)
treeb3b6648acdbb374a4884303aaced022de2c05fb3 /engines/testbed
parent0bd7bf32cac760c59e2a7a140b8ee46a795465ce (diff)
downloadscummvm-rg350-3c511eab1a3c9e3be7125a6159265e0f5e25beed.tar.gz
scummvm-rg350-3c511eab1a3c9e3be7125a6159265e0f5e25beed.tar.bz2
scummvm-rg350-3c511eab1a3c9e3be7125a6159265e0f5e25beed.zip
added code for testing shake, focus, overlay, scaling, need to fix more some of these although
svn-id: r49634
Diffstat (limited to 'engines/testbed')
-rw-r--r--engines/testbed/graphics.cpp195
-rw-r--r--engines/testbed/graphics.h8
-rw-r--r--engines/testbed/testsuite.h10
3 files changed, 170 insertions, 43 deletions
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;
+}
+
}
diff --git a/engines/testbed/graphics.h b/engines/testbed/graphics.h
index 54cd58ebd4..46bd9932a7 100644
--- a/engines/testbed/graphics.h
+++ b/engines/testbed/graphics.h
@@ -9,14 +9,18 @@ namespace GFXtests {
// Helper functions for GFX tests
void drawEllipse(int x, int y, int a, int b);
+void drawCursor(const char *gfxModeName = 0, int cursorTargetScale = 1);
// will contain function declarations for GFX tests
bool fullScreenMode();
bool aspectRatio();
bool palettizedCursors();
bool copyRectToScreen();
-bool mouseMovements();
bool iconifyWindow();
+bool scaledCursors();
+bool shakingEffect();
+bool focusRectangle();
+bool overlayGraphics();
// add more here
}
@@ -33,7 +37,7 @@ public:
GFXTestSuite();
~GFXTestSuite(){}
void execute();
- const char *getName();
+ const char *getName() const;
static void setCustomColor(uint r, uint g, uint b);
private:
diff --git a/engines/testbed/testsuite.h b/engines/testbed/testsuite.h
index 7d916d5699..45ed5f1a6f 100644
--- a/engines/testbed/testsuite.h
+++ b/engines/testbed/testsuite.h
@@ -51,10 +51,10 @@ public:
}
}
- int getNumTests() { return _testsToExecute.size(); }
- int getNumTestsPassed() { return _numTestsPassed; }
- int getNumTestsFailed() { return _numTestsExecuted - _numTestsPassed; }
- void genReport() {
+ int getNumTests() const { return _testsToExecute.size(); }
+ int getNumTestsPassed() const { return _numTestsPassed; }
+ int getNumTestsFailed() const { return _numTestsExecuted - _numTestsPassed; }
+ void genReport() const {
printf("Subsystem:%s\n",getName());
printf("Tests executed:%d\n", _numTestsExecuted);
printf("Tests Passed:%d\n", _numTestsPassed);
@@ -137,7 +137,7 @@ public:
}
genReport();
}
- virtual const char *getName() = 0;
+ virtual const char *getName() const = 0;
protected:
Common::Array<Test*> _testsToExecute; ///< List of tests to be executed