diff options
author | Jordi Vilalta Prat | 2010-07-14 14:12:42 +0000 |
---|---|---|
committer | Jordi Vilalta Prat | 2010-07-14 14:12:42 +0000 |
commit | 0b3201e5e3449f90187938e5dd699535fdaadeb8 (patch) | |
tree | 5f4c179ad8028063a9297d45477f7842b1dc9434 /engines/testbed | |
parent | 85958744a2314d5b2556bece162dbf6bc4d54505 (diff) | |
download | scummvm-rg350-0b3201e5e3449f90187938e5dd699535fdaadeb8.tar.gz scummvm-rg350-0b3201e5e3449f90187938e5dd699535fdaadeb8.tar.bz2 scummvm-rg350-0b3201e5e3449f90187938e5dd699535fdaadeb8.zip |
Whitespace cleanup (mainly spaces and tabs at the end of line)
svn-id: r50885
Diffstat (limited to 'engines/testbed')
-rw-r--r-- | engines/testbed/events.cpp | 18 | ||||
-rw-r--r-- | engines/testbed/fs.cpp | 38 | ||||
-rw-r--r-- | engines/testbed/fs.h | 2 | ||||
-rw-r--r-- | engines/testbed/graphics.cpp | 216 | ||||
-rw-r--r-- | engines/testbed/graphics.h | 2 | ||||
-rw-r--r-- | engines/testbed/misc.cpp | 14 | ||||
-rw-r--r-- | engines/testbed/module.mk | 10 | ||||
-rw-r--r-- | engines/testbed/savegame.cpp | 14 | ||||
-rw-r--r-- | engines/testbed/testbed.cpp | 26 | ||||
-rw-r--r-- | engines/testbed/testbed.h | 10 | ||||
-rw-r--r-- | engines/testbed/testsuite.cpp | 28 | ||||
-rw-r--r-- | engines/testbed/testsuite.h | 16 |
12 files changed, 197 insertions, 197 deletions
diff --git a/engines/testbed/events.cpp b/engines/testbed/events.cpp index fb71334d78..9facc200db 100644 --- a/engines/testbed/events.cpp +++ b/engines/testbed/events.cpp @@ -71,7 +71,7 @@ char EventTests::keystrokeToChar() { Common::EventManager *eventMan = g_system->getEventManager(); bool quitLoop = false; Common::Event event; - + // handle all keybd events while (!quitLoop) { while (eventMan->pollEvent(event)) { @@ -83,7 +83,7 @@ char EventTests::keystrokeToChar() { switch (event.type) { case Common::EVENT_KEYDOWN : - + if (event.kbd.keycode == Common::KEYCODE_ESCAPE) { return 0; } @@ -107,7 +107,7 @@ bool EventTests::mouseEvents() { Common::Point pt(0, 100); Testsuite::writeOnScreen("Generate mouse events make L/R/M button clicks", pt); - pt.y = 120; + pt.y = 120; Testsuite::writeOnScreen("Testbed should be able to detect them, Press X to exit", pt); // Init Mouse Palette @@ -166,7 +166,7 @@ bool EventTests::mouseEvents() { case Common::EVENT_KEYDOWN: if (event.kbd.keycode == Common::KEYCODE_x) { Testsuite::clearScreen(); - Testsuite::writeOnScreen("Exit requested", pt); + Testsuite::writeOnScreen("Exit requested", pt); quitLoop = true; } break; @@ -177,7 +177,7 @@ bool EventTests::mouseEvents() { } } - + CursorMan.showMouse(false); // Verify results now! @@ -207,9 +207,9 @@ bool EventTests::kbdEvents() { text += letter; rect = Testsuite::writeOnScreen(text, pt); } - + bool passed = true; - + if (Testsuite::handleInteractiveInput("Was the word you entered same as that displayed on screen?", "Yes", "No", kOptionRight)) { Testsuite::logDetailedPrintf("Keyboard Events failed"); passed = false; @@ -226,12 +226,12 @@ bool EventTests::showMainMenu() { eventMan->pushEvent(mainMenuEvent); bool passed = true; - + if (Testsuite::handleInteractiveInput("Were you able to see a main menu widget?", "Yes", "No", kOptionRight)) { Testsuite::logDetailedPrintf("Event MAINMENU failed"); passed = false; } - + return passed; } diff --git a/engines/testbed/fs.cpp b/engines/testbed/fs.cpp index 67062c17db..6951793e5c 100644 --- a/engines/testbed/fs.cpp +++ b/engines/testbed/fs.cpp @@ -39,14 +39,14 @@ namespace Testbed { * */ bool FStests::readDataFromFile(Common::FSDirectory *directory, const char *file) { - + Common::SeekableReadStream *readStream = directory->createReadStreamForMember(file); if (!readStream) { Testsuite::logDetailedPrintf("Can't open game file for reading\n"); return false; - } - + } + Common::String msg = readStream->readLine(); delete readStream; Testsuite::logDetailedPrintf("Message Extracted from %s/%s : %s\n",directory->getFSNode().getName().c_str(), file, msg.c_str()); @@ -67,44 +67,44 @@ bool FStests::testReadFile() { const Common::String &path = ConfMan.get("path"); Common::FSDirectory gameRoot(path); int numFailed = 0; - + if (!gameRoot.getFSNode().isDirectory()) { Testsuite::logDetailedPrintf("game Path should be a directory"); return false; } - + const char *dirList[] = {"test1" ,"Test2", "TEST3" , "tEST4", "test5"}; const char *file[] = {"file.txt", "File.txt", "FILE.txt", "fILe.txt", "file"}; for (unsigned int i = 0; i < ARRAYSIZE(dirList); i++) { Common::String dirName = dirList[i]; Common::String fileName = file[i]; - Common::FSDirectory *directory = gameRoot.getSubDirectory(dirName); + Common::FSDirectory *directory = gameRoot.getSubDirectory(dirName); if (!readDataFromFile(directory, fileName.c_str())) { Testsuite::logDetailedPrintf("Reading from %s/%s failed\n", dirName.c_str(), fileName.c_str()); numFailed++; } - + dirName.toLowercase(); fileName.toLowercase(); - directory = gameRoot.getSubDirectory(dirName); - + directory = gameRoot.getSubDirectory(dirName); + if (!readDataFromFile(directory, fileName.c_str())) { Testsuite::logDetailedPrintf("Reading from %s/%s failed\n", dirName.c_str(), fileName.c_str()); numFailed++; } - + dirName.toUppercase(); fileName.toUppercase(); - directory = gameRoot.getSubDirectory(dirName); - + directory = gameRoot.getSubDirectory(dirName); + if (!readDataFromFile(directory, fileName.c_str())) { Testsuite::logDetailedPrintf("Reading from %s/%s failed\n", dirName.c_str(), fileName.c_str()); numFailed++; } } - + Testsuite::logDetailedPrintf("Failed %d out of 15\n", numFailed); return false; } @@ -119,14 +119,14 @@ bool FStests::testWriteFile() { Common::FSNode gameRoot(path); Common::FSNode fileToWrite = gameRoot.getChild("testbed.out"); - + Common::WriteStream *ws = fileToWrite.createWriteStream(); - + if (!ws) { Testsuite::logDetailedPrintf("Can't open writable file in game data dir\n"); return false; } - + ws->writeString("ScummVM Rocks!"); ws->flush(); delete ws; @@ -141,15 +141,15 @@ bool FStests::testWriteFile() { return true; } - + return false; } FSTestSuite::FSTestSuite() { - addTest("ReadingFile", &FStests::testReadFile, false); - addTest("WritingFile", &FStests::testWriteFile, false); + addTest("ReadingFile", &FStests::testReadFile, false); + addTest("WritingFile", &FStests::testWriteFile, false); } const char *FSTestSuite::getName() const { diff --git a/engines/testbed/fs.h b/engines/testbed/fs.h index cc28147b2b..07060ec457 100644 --- a/engines/testbed/fs.h +++ b/engines/testbed/fs.h @@ -34,7 +34,7 @@ namespace Testbed { namespace FStests { // Note: These tests require a game-data directory -// So would work if game-path is set in the launcher or invoked as ./scummvm --path="path-to-testbed-data" testbed +// So would work if game-path is set in the launcher or invoked as ./scummvm --path="path-to-testbed-data" testbed // from commandline // Helper functions for FS tests 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<Graphics::PixelFormat> pfList = g_system->getSupportedFormats(); Common::List<Graphics::PixelFormat>::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; } diff --git a/engines/testbed/graphics.h b/engines/testbed/graphics.h index 7f004f36ac..8ee0328642 100644 --- a/engines/testbed/graphics.h +++ b/engines/testbed/graphics.h @@ -41,7 +41,7 @@ void HSVtoRGB(int& rComp, int& gComp,int& bComp, int hue, int sat, int val); Common::Rect drawCursor(bool cursorPaletteDisabled = false, const char *gfxModeName = "", int cursorTargetScale = 1); // will contain function declarations for GFX tests -bool fullScreenMode(); +bool fullScreenMode(); bool aspectRatio(); bool palettizedCursors(); bool copyRectToScreen(); diff --git a/engines/testbed/misc.cpp b/engines/testbed/misc.cpp index 12b31ea5ab..46a2788690 100644 --- a/engines/testbed/misc.cpp +++ b/engines/testbed/misc.cpp @@ -44,7 +44,7 @@ void MiscTests::timerCallback(void *arg) { void MiscTests::criticalSection(void *arg) { SharedVars &sv = *((SharedVars *) arg); - + Testsuite::logDetailedPrintf("Before critical section: %d %d\n", sv.first, sv.second); g_system->lockMutex(sv.mutex); @@ -92,7 +92,7 @@ bool MiscTests::testDateTime() { Testsuite::logDetailedPrintf("Time and Date 2s later: "); getHumanReadableFormat(t2, dateTimeNow); Testsuite::logDetailedPrintf("%s\n", dateTimeNow.c_str()); - + if (t1.tm_year == t2.tm_year && t1.tm_mon == t2.tm_mon && t1.tm_mday == t2.tm_mday) { if (t1.tm_mon == t2.tm_mon && t1.tm_year == t2.tm_year){ // Ignore lag due to processing time @@ -109,7 +109,7 @@ bool MiscTests::testTimers() { if (g_system->getTimerManager()->installTimerProc(timerCallback, 100000, &valToModify)) { g_system->delayMillis(150); g_system->getTimerManager()->removeTimerProc(timerCallback); - + if (999 == valToModify) { return true; } @@ -119,7 +119,7 @@ bool MiscTests::testTimers() { bool MiscTests::testMutexes() { static SharedVars sv = {1, 1, true, g_system->createMutex()}; - + if (g_system->getTimerManager()->installTimerProc(criticalSection, 100000, &sv)) { g_system->delayMillis(150); } @@ -143,9 +143,9 @@ bool MiscTests::testMutexes() { } MiscTestSuite::MiscTestSuite() { - addTest("Date/time", &MiscTests::testDateTime, false); - addTest("Timers", &MiscTests::testTimers, false); - addTest("Mutexes", &MiscTests::testMutexes, false); + addTest("Date/time", &MiscTests::testDateTime, false); + addTest("Timers", &MiscTests::testTimers, false); + addTest("Mutexes", &MiscTests::testMutexes, false); } const char *MiscTestSuite::getName() const { return "Misc"; diff --git a/engines/testbed/module.mk b/engines/testbed/module.mk index d14e5b551e..e9a6382895 100644 --- a/engines/testbed/module.mk +++ b/engines/testbed/module.mk @@ -1,5 +1,5 @@ MODULE := engines/testbed - + MODULE_OBJS := \ detection.o \ events.o \ @@ -9,14 +9,14 @@ MODULE_OBJS := \ savegame.o \ testbed.o \ testsuite.o - + MODULE_DIRS += \ engines/testbed - + # This module can be built as a plugin ifeq ($(ENABLE_TESTBED), DYNAMIC_PLUGIN) PLUGIN := 1 endif - -# Include common rules + +# Include common rules include $(srcdir)/rules.mk diff --git a/engines/testbed/savegame.cpp b/engines/testbed/savegame.cpp index 6349f0af7f..9f9097219c 100644 --- a/engines/testbed/savegame.cpp +++ b/engines/testbed/savegame.cpp @@ -54,7 +54,7 @@ bool SaveGametests::readAndVerifyData(const char *fileName, const char *expected Common::SaveFileManager *saveFileMan = g_system->getSavefileManager(); Common::InSaveFile *loadFile = saveFileMan->openForLoading(fileName); - + if (!loadFile) { Testsuite::logDetailedPrintf("Can't open save File to load\n"); return false; @@ -88,7 +88,7 @@ bool SaveGametests::testSaveLoadState() { } bool SaveGametests::testRemovingSavefile() { - + Common::SaveFileManager *saveFileMan = g_system->getSavefileManager(); // Create a dummy savefile @@ -118,7 +118,7 @@ bool SaveGametests::testRenamingSavefile() { Testsuite::logDetailedPrintf("Writing data to savefile failed\n"); return false; } - + // Rename it saveFileMan->renameSavefile("tBedSomeWeirdName.0", "tBedSomeCoolName.0"); @@ -127,11 +127,11 @@ bool SaveGametests::testRenamingSavefile() { Testsuite::logDetailedPrintf("Renaming savefile failed\n"); return false; } - + return true; } -bool SaveGametests::testListingSavefile() { +bool SaveGametests::testListingSavefile() { Common::SaveFileManager *saveFileMan = g_system->getSavefileManager(); saveFileMan->clearError(); @@ -175,10 +175,10 @@ bool SaveGametests::testListingSavefile() { } -bool SaveGametests::testErrorMessages() { +bool SaveGametests::testErrorMessages() { Common::SaveFileManager *saveFileMan = g_system->getSavefileManager(); saveFileMan->clearError(); - + // Try opening a non existing file readAndVerifyData("tBedSomeNonExistentSaveFile.0", "File doesn't exists!"); diff --git a/engines/testbed/testbed.cpp b/engines/testbed/testbed.cpp index db1fe6045c..762d67b156 100644 --- a/engines/testbed/testbed.cpp +++ b/engines/testbed/testbed.cpp @@ -35,23 +35,23 @@ #include "testbed/misc.h" #include "testbed/savegame.h" #include "testbed/testbed.h" - + namespace Testbed { - + bool TestbedEngine::hasFeature(EngineFeature f) const { return (f == kSupportsRTL) ? true : false; } -TestbedEngine::TestbedEngine(OSystem *syst) +TestbedEngine::TestbedEngine(OSystem *syst) : Engine(syst) { // Put your engine in a sane state, but do nothing big yet; // in particular, do not load data from files; rather, if you // need to do such things, do them from init(). - + // Do not initialize graphics here - + // However this is the place to specify all default directories - + DebugMan.addDebugChannel(kTestbedLogOutput, "LOG", "Log of test results generated by testbed"); DebugMan.addDebugChannel(kTestbedEngineDebug, "Debug", "Engine-specific debug statements"); DebugMan.enableDebugChannel("LOG"); @@ -73,12 +73,12 @@ TestbedEngine::TestbedEngine(OSystem *syst) ts = new EventTestSuite(); _testsuiteList.push_back(ts); } - + TestbedEngine::~TestbedEngine() { Testsuite::deleteWriteStream(); // Remove all of our debug levels here DebugMan.clearAllDebugChannels(); - + for (Common::Array<Testsuite*>::const_iterator i = _testsuiteList.begin(); i != _testsuiteList.end(); ++i) { delete (*i); } @@ -93,13 +93,13 @@ void TestbedEngine::enableTestsuite(const Common::String &name, bool enable) { break; } } - + return; } void TestbedEngine::invokeTestsuites() { Common::Array<Testsuite*>::const_iterator iter; - + for (iter = _testsuiteList.begin(); iter != _testsuiteList.end(); iter++) { if ((*iter)->isEnabled()) { (*iter)->execute(); @@ -138,7 +138,7 @@ bool TestbedOptionsDialog::isEnabled(const Common::String &tsName) { Common::Error TestbedEngine::run() { // Initialize graphics using following: initGraphics(320, 200, false); - + // As of now we are using GUI::MessageDialog for interaction, Test if it works. // interactive mode could also be modified by a config parameter "non-interactive=1" // TODO: Implement that @@ -153,7 +153,7 @@ Common::Error TestbedEngine::run() { // Testsuite::isSessionInteractive = false; if (Testsuite::isSessionInteractive) { - Testsuite::logPrintf("Info! : Interactive tests are also being executed.\n"); + Testsuite::logPrintf("Info! : Interactive tests are also being executed.\n"); Testsuite::displayMessage(prompt, "Proceed?"); } @@ -178,5 +178,5 @@ Common::Error TestbedEngine::run() { invokeTestsuites(); return Common::kNoError; } - + } // End of namespace Testbed diff --git a/engines/testbed/testbed.h b/engines/testbed/testbed.h index e85bae3784..0a6a235e17 100644 --- a/engines/testbed/testbed.h +++ b/engines/testbed/testbed.h @@ -24,7 +24,7 @@ #ifndef TESTBED_H #define TESTBED_H - + #include "engines/engine.h" #include "gui/options.h" @@ -42,15 +42,15 @@ class TestbedEngine : public Engine { public: TestbedEngine(OSystem *syst); ~TestbedEngine(); - + virtual Common::Error run(); - + /** * All testsuites are disabled by default * To enable testsuite X, call enableTestsuite("X", true); */ void enableTestsuite(const Common::String &name, bool enable); - + /** * Invokes configured testsuites. */ @@ -78,5 +78,5 @@ private: }; } // End of namespace Testbed - + #endif diff --git a/engines/testbed/testsuite.cpp b/engines/testbed/testsuite.cpp index ab87a31c52..52502aefec 100644 --- a/engines/testbed/testsuite.cpp +++ b/engines/testbed/testsuite.cpp @@ -62,7 +62,7 @@ void Testsuite::deleteWriteStream() { void Testsuite::initLogging(const char *logdir, const char *filename, bool enable) { setLogDir(logdir); setLogFile(filename); - + if (enable) { _ws = Common::FSNode(_logDirectory).getChild(_logFilename).createWriteStream(); } else { @@ -73,7 +73,7 @@ void Testsuite::initLogging(const char *logdir, const char *filename, bool enabl void Testsuite::initLogging(bool enable) { setLogDir(ConfMan.get("path").c_str()); setLogFile("testbed.log"); - + if (enable) { _ws = Common::FSNode(_logDirectory).getChild(_logFilename).createWriteStream(); } else { @@ -88,7 +88,7 @@ void Testsuite::logPrintf(const char *fmt, ...) { va_start(vl, fmt); vsnprintf(buffer, STRINGBUFLEN, fmt, vl); va_end(vl); - + if (_ws) { _ws->writeString(buffer); } else { @@ -104,7 +104,7 @@ void Testsuite::logDetailedPrintf(const char *fmt, ...) { va_start(vl, fmt); vsnprintf(buffer, STRINGBUFLEN, fmt, vl); va_end(vl); - + if (_ws) { _ws->writeString(buffer); } else { @@ -134,7 +134,7 @@ void Testsuite::genReport() const { logPrintf("Failed: %d\n", getNumTestsFailed()); logPrintf("\n"); } - + bool Testsuite::handleInteractiveInput(const Common::String &textToDisplay, const char *opt1, const char *opt2, OptionSelected result) { GUI::MessageDialog prompt(textToDisplay, opt1, opt2); return prompt.runModal() == result ? true : false; @@ -151,7 +151,7 @@ Common::Rect Testsuite::writeOnScreen(const Common::String &textToDisplay, const uint textColor = kColorWhite; Graphics::Surface *screen = g_system->lockScreen(); - + int height = font.getFontHeight(); int width = screen->w; @@ -162,7 +162,7 @@ Common::Rect Testsuite::writeOnScreen(const Common::String &textToDisplay, const fillColor = pf.RGBToColor(0 , 0, 0); textColor = pf.RGBToColor(255 , 255, 255); } - + screen->fillRect(rect, fillColor); font.drawString(screen, textToDisplay, rect.left, rect.top, screen->w, textColor, Graphics::kTextAlignCenter); @@ -174,13 +174,13 @@ Common::Rect Testsuite::writeOnScreen(const Common::String &textToDisplay, const void Testsuite::clearScreen(const Common::Rect &rect) { Graphics::Surface *screen = g_system->lockScreen(); - + screen->fillRect(rect, kColorBlack); g_system->unlockScreen(); g_system->updateScreen(); } - + void Testsuite::clearScreen() { int numBytesPerLine = g_system->getWidth() * g_system->getScreenFormat().bytesPerPixel; int size = g_system->getHeight() * numBytesPerLine; @@ -190,7 +190,7 @@ void Testsuite::clearScreen() { g_system->updateScreen(); delete[] buffer; } - + void Testsuite::clearScreen(bool flag) { Graphics::Surface *screen = g_system->lockScreen(); uint fillColor = kColorBlack; @@ -244,7 +244,7 @@ void Testsuite::execute() { if (toQuit == kEngineQuit) { return; } - + for (Common::Array<Test*>::iterator i = _testsToExecute.begin(); i != _testsToExecute.end(); ++i) { if (toQuit == kSkipNext) { logPrintf("Info! Skipping Test: %s, Skipped by user.\n", ((*i)->featureName).c_str()); @@ -266,16 +266,16 @@ void Testsuite::execute() { logPrintf("Result: Failed\n"); } // TODO: Display a screen here to user with details of upcoming test, he can skip it or Quit or RTL - // Check if user wants to quit/RTL/Skip next test by parsing events. + // Check if user wants to quit/RTL/Skip next test by parsing events. // Quit directly if explicitly requested - + if (Engine::shouldQuit()) { toQuit = kEngineQuit; genReport(); return; } - toQuit = parseEvents(); + toQuit = parseEvents(); } genReport(); } diff --git a/engines/testbed/testsuite.h b/engines/testbed/testsuite.h index 2a496e12a3..5438176a34 100644 --- a/engines/testbed/testsuite.h +++ b/engines/testbed/testsuite.h @@ -80,7 +80,7 @@ struct Test { class Testsuite { public: Testsuite(); - virtual ~Testsuite(); + virtual ~Testsuite(); int getNumTests() const { return _testsToExecute.size(); } int getNumTestsPassed() const { return _numTestsPassed; } int getNumTestsFailed() const { return _numTestsExecuted - _numTestsPassed; } @@ -96,11 +96,11 @@ public: * * @param textToDisplay Display text * @return true if "Yes" false otherwise - */ + */ static bool handleInteractiveInput(const Common::String &textToDisplay, const char *opt1 = "Yes", const char *opt2 = "No", OptionSelected result = kOptionLeft); - + static void displayMessage(const Common::String &textToDisplay, const char *defaultButton = "OK", const char *altButton = 0); - static Common::Rect writeOnScreen(const Common::String &textToDisplay, const Common::Point &pt, bool flag = false); + static Common::Rect writeOnScreen(const Common::String &textToDisplay, const Common::Point &pt, bool flag = false); static void clearScreen(const Common::Rect &rect); static void clearScreen(); static void clearScreen(bool flag); @@ -120,7 +120,7 @@ public: */ virtual void execute(); static uint parseEvents(); - + virtual const char *getName() const = 0; static void logPrintf(const char *s, ...) GCC_PRINTF(1, 2); @@ -132,13 +132,13 @@ public: static void initLogging(bool enable = true); static void setLogDir(const char *dirname); static void setLogFile(const char *filename); - + static void deleteWriteStream(); protected: Common::Array<Test*> _testsToExecute; ///< List of tests to be executed int _numTestsPassed; ///< Number of tests passed - int _numTestsExecuted; ///< Number of tests executed + int _numTestsExecuted; ///< Number of tests executed bool _isTsEnabled; public: @@ -148,7 +148,7 @@ public: * Used by various tests to respond accordingly */ static bool isSessionInteractive; - + /** * Used from the code to decide if the engine needs to exit */ |