diff options
author | Max Horn | 2011-06-07 01:47:47 -0700 |
---|---|---|
committer | Max Horn | 2011-06-07 01:47:47 -0700 |
commit | 63ca74905c4d6c4d98812b5b02bd98aa7894055b (patch) | |
tree | 268b6c0fdc33a243fd60c241ef0c68275e904452 | |
parent | a826c4422f823ec1bbd1902f05c549f94b75c8e1 (diff) | |
parent | 55f46a13767e75ffe40582c35a22bbccbb7b1568 (diff) | |
download | scummvm-rg350-63ca74905c4d6c4d98812b5b02bd98aa7894055b.tar.gz scummvm-rg350-63ca74905c4d6c4d98812b5b02bd98aa7894055b.tar.bz2 scummvm-rg350-63ca74905c4d6c4d98812b5b02bd98aa7894055b.zip |
Merge pull request #43 from Littleboy/testbed-cleanup
Testbed engine cleanup
-rw-r--r-- | engines/testbed/config.cpp | 16 | ||||
-rw-r--r-- | engines/testbed/config.h | 6 | ||||
-rw-r--r-- | engines/testbed/detection.cpp | 2 | ||||
-rw-r--r-- | engines/testbed/fs.cpp | 4 | ||||
-rw-r--r-- | engines/testbed/graphics.cpp | 26 | ||||
-rw-r--r-- | engines/testbed/graphics.h | 4 | ||||
-rw-r--r-- | engines/testbed/midi.cpp | 4 | ||||
-rw-r--r-- | engines/testbed/misc.cpp | 2 | ||||
-rw-r--r-- | engines/testbed/misc.h | 2 | ||||
-rw-r--r-- | engines/testbed/savegame.cpp | 14 | ||||
-rw-r--r-- | engines/testbed/sound.h | 4 | ||||
-rw-r--r-- | engines/testbed/testbed.cpp | 8 | ||||
-rw-r--r-- | engines/testbed/testsuite.cpp | 5 | ||||
-rw-r--r-- | engines/testbed/testsuite.h | 6 |
14 files changed, 52 insertions, 51 deletions
diff --git a/engines/testbed/config.cpp b/engines/testbed/config.cpp index 6adf82952f..6bd4c82b41 100644 --- a/engines/testbed/config.cpp +++ b/engines/testbed/config.cpp @@ -126,10 +126,13 @@ void TestbedOptionsDialog::handleCommand(GUI::CommandSender *sender, uint32 cmd, ws = _testbedConfMan->getConfigWriteStream(); _testbedConfMan->writeTestbedConfigToStream(ws); delete ws; - default: - GUI::Dialog::handleCommand(sender, cmd, data); + break; + default: + break; } + + GUI::Dialog::handleCommand(sender, cmd, data); } void TestbedInteractionDialog::addText(uint w, uint h, const Common::String text, Graphics::TextAlign textAlign, uint xOffset, uint yPadding) { @@ -150,7 +153,7 @@ void TestbedInteractionDialog::addButton(uint w, uint h, const Common::String na _yOffset += h; } -void TestbedInteractionDialog::addList(uint x, uint y, uint w, uint h, Common::Array<Common::String> &strArray, GUI::ListWidget::ColorList *colors, uint yPadding) { +void TestbedInteractionDialog::addList(uint x, uint y, uint w, uint h, const Common::Array<Common::String> &strArray, GUI::ListWidget::ColorList *colors, uint yPadding) { _yOffset += yPadding; GUI::ListWidget *list = new GUI::ListWidget(this, x, y, w, h); list->setEditable(false); @@ -159,7 +162,7 @@ void TestbedInteractionDialog::addList(uint x, uint y, uint w, uint h, Common::A _yOffset += h; } -void TestbedInteractionDialog::addButtonXY(uint x, uint y, uint w, uint h, const Common::String name, uint32 cmd) { +void TestbedInteractionDialog::addButtonXY(uint x, uint /* y */, uint w, uint h, const Common::String name, uint32 cmd) { _buttonArray.push_back(new GUI::ButtonWidget(this, x, _yOffset, w, h, name, 0, cmd)); } @@ -174,7 +177,6 @@ void TestbedConfigManager::initDefaultConfiguration() { } void TestbedConfigManager::writeTestbedConfigToStream(Common::WriteStream *ws) { - Common::String wStr; for (Common::Array<Testsuite *>::const_iterator i = _testsuiteList.begin(); i < _testsuiteList.end(); i++) { _configFileInterface.setKey("this", (*i)->getName(), boolToString((*i)->isEnabled())); const Common::Array<Test *> &testList = (*i)->getTestList(); @@ -186,13 +188,13 @@ void TestbedConfigManager::writeTestbedConfigToStream(Common::WriteStream *ws) { ws->flush(); } -Common::SeekableReadStream *TestbedConfigManager::getConfigReadStream() { +Common::SeekableReadStream *TestbedConfigManager::getConfigReadStream() const { // Look for config file using SearchMan Common::SeekableReadStream *rs = SearchMan.createReadStreamForMember(_configFileName); return rs; } -Common::WriteStream *TestbedConfigManager::getConfigWriteStream() { +Common::WriteStream *TestbedConfigManager::getConfigWriteStream() const { // Look for config file in game-path const Common::String &path = ConfMan.get("path"); Common::WriteStream *ws; diff --git a/engines/testbed/config.h b/engines/testbed/config.h index c0df65ad32..fd5588aa31 100644 --- a/engines/testbed/config.h +++ b/engines/testbed/config.h @@ -50,8 +50,8 @@ public: ~TestbedConfigManager() {} void selectTestsuites(); void setConfigFile(const Common::String fName) { _configFileName = fName; } - Common::SeekableReadStream *getConfigReadStream(); - Common::WriteStream *getConfigWriteStream(); + Common::SeekableReadStream *getConfigReadStream() const; + Common::WriteStream *getConfigWriteStream() const; void writeTestbedConfigToStream(Common::WriteStream *ws); Testsuite *getTestsuiteByName(const Common::String &name); bool stringToBool(const Common::String str) { return str.equalsIgnoreCase("true") ? true : false; } @@ -119,7 +119,7 @@ public: void addButton(uint w, uint h, const Common::String name, uint32 cmd, uint xOffset = 0, uint yPadding = 8); void addButtonXY(uint x, uint y, uint w, uint h, const Common::String name, uint32 cmd); void addText(uint w, uint h, const Common::String text, Graphics::TextAlign textAlign, uint xOffset, uint yPadding = 8); - void addList(uint x, uint y, uint w, uint h, Common::Array<Common::String> &strArray, GUI::ListWidget::ColorList *colors = 0, uint yPadding = 8); + void addList(uint x, uint y, uint w, uint h, const Common::Array<Common::String> &strArray, GUI::ListWidget::ColorList *colors = 0, uint yPadding = 8); protected: Common::Array<GUI::ButtonWidget *> _buttonArray; uint _xOffset; diff --git a/engines/testbed/detection.cpp b/engines/testbed/detection.cpp index 91518b2b8e..13af0f1584 100644 --- a/engines/testbed/detection.cpp +++ b/engines/testbed/detection.cpp @@ -83,7 +83,7 @@ public: return "Copyright (C) ScummVM"; } - virtual bool createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const { + virtual bool createInstance(OSystem *syst, Engine **engine, const ADGameDescription * /* desc */) const { // Instantiate Engine even if the game data is not found. *engine = new Testbed::TestbedEngine(syst); return true; diff --git a/engines/testbed/fs.cpp b/engines/testbed/fs.cpp index e2bedb1898..62ac616192 100644 --- a/engines/testbed/fs.cpp +++ b/engines/testbed/fs.cpp @@ -167,7 +167,7 @@ TestExitStatus FStests::testWriteFile() { return kTestPassed; } - return kTestFailed; + return kTestFailed; } @@ -189,7 +189,7 @@ FSTestSuite::FSTestSuite() { } void FSTestSuite::enable(bool flag) { - Testsuite::enable(ConfParams.isGameDataFound() & flag); + Testsuite::enable(ConfParams.isGameDataFound() ? flag : false); } } // End of namespace Testbed diff --git a/engines/testbed/graphics.cpp b/engines/testbed/graphics.cpp index d5b5da788a..36ec726fc7 100644 --- a/engines/testbed/graphics.cpp +++ b/engines/testbed/graphics.cpp @@ -102,7 +102,7 @@ void GFXtests::initMousePalette() { CursorMan.replaceCursorPalette(palette, 0, 3); } -Common::Rect GFXtests::computeSize(Common::Rect &cursorRect, int scalingFactor, int cursorTargetScale) { +Common::Rect GFXtests::computeSize(const 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. @@ -137,7 +137,7 @@ void GFXtests::HSVtoRGB(int &rComp, int &gComp, int &bComp, int hue, int sat, in float f, p, q, t; if (s == 0) { - r = g = b = v * 255; + rComp = gComp = bComp = (int)(v * 255); return; } @@ -186,7 +186,7 @@ void GFXtests::HSVtoRGB(int &rComp, int &gComp, int &bComp, int hue, int sat, in bComp = (int)(b * 255); } -Common::Rect GFXtests::drawCursor(bool cursorPaletteDisabled, const char *gfxModeName, int cursorTargetScale) { +Common::Rect GFXtests::drawCursor(bool cursorPaletteDisabled, int cursorTargetScale) { // Buffer initialized with yellow color byte buffer[500]; memset(buffer, 2, sizeof(buffer)); @@ -249,7 +249,7 @@ void GFXtests::setupMouseLoop(bool disableCursorPalette, const char *gfxModeName if (isFeaturePresent) { - cursorRect = GFXtests::drawCursor(disableCursorPalette, gfxModeName, cursorTargetScale); + cursorRect = GFXtests::drawCursor(disableCursorPalette, cursorTargetScale); Common::EventManager *eventMan = g_system->getEventManager(); Common::Event event; @@ -741,7 +741,7 @@ TestExitStatus GFXtests::scaledCursors() { 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; @@ -753,7 +753,7 @@ TestExitStatus GFXtests::scaledCursors() { } - if (isAspectRatioCorrected) { + if (isAspectRatioCorrected) { g_system->beginGFXTransaction(); g_system->setFeatureState(OSystem::kFeatureAspectRatioCorrection, false); g_system->endGFXTransaction(); @@ -766,7 +766,7 @@ 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::format("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); @@ -779,7 +779,7 @@ TestExitStatus GFXtests::scaledCursors() { 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); @@ -807,7 +807,7 @@ TestExitStatus GFXtests::scaledCursors() { 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"); @@ -824,7 +824,7 @@ TestExitStatus GFXtests::scaledCursors() { if (isAspectRatioCorrected) { g_system->setFeatureState(OSystem::kFeatureAspectRatioCorrection, true); } - + OSystem::TransactionError gfxError = g_system->endGFXTransaction(); if (gfxError != OSystem::kTransactionSuccess || !isGFXModeSet) { @@ -962,13 +962,14 @@ TestExitStatus GFXtests::paletteRotation() { Testsuite::logPrintf("Info! Skipping test : palette Rotation\n"); return kTestSkipped; } - Common::Point pt(0, 10); + Testsuite::clearEntireScreen(); // Use 256 colors byte palette[256 * 3] = {0}; int r, g, b; + r = g = b = 0; int colIndx; for (int i = 0; i < 256; i++) { @@ -1065,7 +1066,6 @@ TestExitStatus 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; @@ -1073,7 +1073,7 @@ TestExitStatus GFXtests::pixelFormats() { Testsuite::logDetailedPrintf("Testing Pixel Formats. Size of list : %d\n", pfList.size()); - for (iter = pfList.begin(); iter != pfList.end(); iter++) { + for (Common::List<Graphics::PixelFormat>::const_iterator iter = pfList.begin(); iter != pfList.end(); iter++) { numFormatsTested++; if (iter->bytesPerPixel == 1) { // Palettes already tested diff --git a/engines/testbed/graphics.h b/engines/testbed/graphics.h index 7fa8f9d708..f3013fdf53 100644 --- a/engines/testbed/graphics.h +++ b/engines/testbed/graphics.h @@ -32,9 +32,9 @@ namespace GFXtests { void drawEllipse(int x, int y, int a, int b); void setupMouseLoop(bool disableCursorPalette = false, const char *gfxModeName = "", int cursorTargetScale = 1); void initMousePalette(); -Common::Rect computeSize(Common::Rect &cursorRect, int scalingFactor, int cursorTargetScale); +Common::Rect computeSize(const Common::Rect &cursorRect, int scalingFactor, int cursorTargetScale); 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); +Common::Rect drawCursor(bool cursorPaletteDisabled = false, int cursorTargetScale = 1); // will contain function declarations for GFX tests TestExitStatus cursorTrails(); diff --git a/engines/testbed/midi.cpp b/engines/testbed/midi.cpp index 54be866b4c..69d361b0d6 100644 --- a/engines/testbed/midi.cpp +++ b/engines/testbed/midi.cpp @@ -142,12 +142,12 @@ MidiTestSuite::MidiTestSuite() { // add some fallback test if filesystem loading failed Testsuite::logPrintf("Warning! Midi: Sound data file music.mid not found\n"); _isMidiDataFound = false; - enable(false); + MidiTestSuite::enable(false); } } void MidiTestSuite::enable(bool flag) { - Testsuite::enable(_isMidiDataFound & flag); + Testsuite::enable(_isMidiDataFound ? flag : false); } } diff --git a/engines/testbed/misc.cpp b/engines/testbed/misc.cpp index 642e0b8ae2..034d3eb27e 100644 --- a/engines/testbed/misc.cpp +++ b/engines/testbed/misc.cpp @@ -24,7 +24,7 @@ namespace Testbed { -Common::String MiscTests::getHumanReadableFormat(TimeDate &td) { +Common::String MiscTests::getHumanReadableFormat(const TimeDate &td) { return Common::String::format("%d:%d:%d on %d/%d/%d (dd/mm/yyyy)", td.tm_hour, td.tm_min, td.tm_sec, td.tm_mday, td.tm_mon + 1, td.tm_year + 1900); } diff --git a/engines/testbed/misc.h b/engines/testbed/misc.h index 415fe82903..3f0772c6e5 100644 --- a/engines/testbed/misc.h +++ b/engines/testbed/misc.h @@ -40,7 +40,7 @@ namespace MiscTests { // Miscellaneous tests include testing datetime, timers and mutexes // Helper functions for Misc tests -Common::String getHumanReadableFormat(TimeDate &td); +Common::String getHumanReadableFormat(const TimeDate &td); void timerCallback(void *arg); void criticalSection(void *arg); diff --git a/engines/testbed/savegame.cpp b/engines/testbed/savegame.cpp index b19c8e3872..226e9880a6 100644 --- a/engines/testbed/savegame.cpp +++ b/engines/testbed/savegame.cpp @@ -133,11 +133,11 @@ TestExitStatus SaveGametests::testListingSavefile() { writeDataToFile("tBedSavefileToList.1", "Save me!"); writeDataToFile("tBedSavefileToList.2", "Save me!"); - Common::Error error = saveFileMan->getError(); + Common::Error err = saveFileMan->getError(); - if (error.getCode() != Common::kNoError) { + if (err.getCode() != Common::kNoError) { // Abort. Some Error in writing files - Testsuite::logDetailedPrintf("Error while creating savefiles: %s\n", error.getDesc().c_str()); + Testsuite::logDetailedPrintf("Error while creating savefiles: %s\n", err.getDesc().c_str()); return kTestFailed; } @@ -158,11 +158,9 @@ TestExitStatus SaveGametests::testListingSavefile() { } } return kTestPassed; - } else { - Testsuite::logDetailedPrintf("listing Savefiles failed!\n"); - return kTestFailed; } + Testsuite::logDetailedPrintf("listing Savefiles failed!\n"); return kTestFailed; } @@ -173,8 +171,8 @@ TestExitStatus SaveGametests::testErrorMessages() { // Try opening a non existing file readAndVerifyData("tBedSomeNonExistentSaveFile.0", "File doesn't exists!"); - Common::Error error = saveFileMan->getError(); - if (error.getCode() == Common::kNoError) { + Common::Error err = saveFileMan->getError(); + if (err.getCode() == Common::kNoError) { // blunder! how come? Testsuite::logDetailedPrintf("SaveFileMan.getError() failed\n"); return kTestFailed; diff --git a/engines/testbed/sound.h b/engines/testbed/sound.h index 76d0c7bb61..fea7d9d45b 100644 --- a/engines/testbed/sound.h +++ b/engines/testbed/sound.h @@ -69,10 +69,6 @@ public: const char *getDescription() const { return "Sound Subsystem"; } - -private: - bool _isTestDataFound; - }; } // End of namespace Testbed diff --git a/engines/testbed/testbed.cpp b/engines/testbed/testbed.cpp index 41a705e292..152764eb27 100644 --- a/engines/testbed/testbed.cpp +++ b/engines/testbed/testbed.cpp @@ -76,12 +76,16 @@ void TestbedExitDialog::init() { void TestbedExitDialog::handleCommand(GUI::CommandSender *sender, uint32 cmd, uint32 data) { switch (cmd) { + default: + break; + case kCmdRerunTestbed : ConfParams.setRerunFlag(true); cmd = GUI::kCloseCmd; - default: - GUI::Dialog::handleCommand(sender, cmd, data); + break; } + + GUI::Dialog::handleCommand(sender, cmd, data); } bool TestbedEngine::hasFeature(EngineFeature f) const { diff --git a/engines/testbed/testsuite.cpp b/engines/testbed/testsuite.cpp index 77211b3e64..655179aa74 100644 --- a/engines/testbed/testsuite.cpp +++ b/engines/testbed/testsuite.cpp @@ -113,7 +113,7 @@ bool Testsuite::handleInteractiveInput(const Common::String &textToDisplay, cons return prompt.runModal() == result ? true : false; } -void Testsuite::displayMessage(const Common::String &textToDisplay, const char *defaultButton, const char *altButton) { +void Testsuite::displayMessage(const Common::String &textToDisplay, const char *defaultButton) { GUI::MessageDialog prompt(textToDisplay, defaultButton); prompt.runModal(); } @@ -214,10 +214,11 @@ uint Testsuite::parseEvents() { return kSkipNext; } break; + case Common::EVENT_QUIT: case Common::EVENT_RTL: return kEngineQuit; - break; + default: break; } diff --git a/engines/testbed/testsuite.h b/engines/testbed/testsuite.h index 3a3a78b9bb..dc159ce25f 100644 --- a/engines/testbed/testsuite.h +++ b/engines/testbed/testsuite.h @@ -112,7 +112,7 @@ public: */ 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 void displayMessage(const Common::String &textToDisplay, const char *defaultButton = "OK"); static Common::Rect writeOnScreen(const Common::String &textToDisplay, const Common::Point &pt, bool flag = false); static void clearScreen(const Common::Rect &rect); static void clearEntireScreen() { @@ -145,7 +145,7 @@ public: static void logPrintf(const char *s, ...) GCC_PRINTF(1, 2); static void logDetailedPrintf(const char *s, ...) GCC_PRINTF(1, 2); - + // Progress bar (Information Display) related methods. /** * Display region is in the bottom. Probably 1/4th of the game screen. @@ -180,7 +180,7 @@ protected: bool _isTsEnabled; private: - + /** * Used from the code to decide if the engine needs to exit */ |