diff options
author | Neeraj Kumar | 2010-07-30 13:54:25 +0000 |
---|---|---|
committer | Neeraj Kumar | 2010-07-30 13:54:25 +0000 |
commit | a6e84128c975a220f4c2800a1d937c37e34b6cec (patch) | |
tree | 8475f9057fc2f5ad3b25cff819b1eb812b0b118d | |
parent | 4814db3a6a99f0a8920968e736494571b25d225b (diff) | |
download | scummvm-rg350-a6e84128c975a220f4c2800a1d937c37e34b6cec.tar.gz scummvm-rg350-a6e84128c975a220f4c2800a1d937c37e34b6cec.tar.bz2 scummvm-rg350-a6e84128c975a220f4c2800a1d937c37e34b6cec.zip |
TESTBED: generalized the GUI, added code for the end text gui message and option to rerun tests
svn-id: r51507
-rw-r--r-- | engines/testbed/config.cpp | 30 | ||||
-rw-r--r-- | engines/testbed/config.h | 14 | ||||
-rw-r--r-- | engines/testbed/sound.cpp | 19 | ||||
-rw-r--r-- | engines/testbed/sound.h | 11 | ||||
-rw-r--r-- | engines/testbed/testbed.cpp | 49 | ||||
-rw-r--r-- | engines/testbed/testbed.h | 23 | ||||
-rw-r--r-- | engines/testbed/testsuite.cpp | 9 | ||||
-rw-r--r-- | engines/testbed/testsuite.h | 3 |
8 files changed, 115 insertions, 43 deletions
diff --git a/engines/testbed/config.cpp b/engines/testbed/config.cpp index 7342f9d634..aa6e151a4f 100644 --- a/engines/testbed/config.cpp +++ b/engines/testbed/config.cpp @@ -127,6 +127,31 @@ void TestbedOptionsDialog::handleCommand(GUI::CommandSender *sender, uint32 cmd, } } +void TestbedInteractionDialog::addText(uint w, uint h, const Common::String text, Graphics::TextAlign textAlign, uint xOffset, uint yPadding) { + if (!xOffset) { + xOffset = _xOffset; + } + _yOffset += yPadding; + new GUI::StaticTextWidget(this, xOffset, _yOffset, w, h, text, textAlign); + _yOffset += h; +} + +void TestbedInteractionDialog::addButton(uint w, uint h, const Common::String name, uint32 cmd, uint xOffset, uint yPadding) { + if (!xOffset) { + xOffset = _xOffset; + } + _yOffset += yPadding; + _buttonArray.push_back(new GUI::ButtonWidget(this, xOffset, _yOffset, w, h, name, cmd)); + _yOffset += h; +} + +void TestbedInteractionDialog::handleCommand(GUI::CommandSender *sender, uint32 cmd, uint32 data) { + switch (cmd) { + default: + GUI::Dialog::handleCommand(sender, cmd, data); + } +} + void TestbedConfigManager::initDefaultConfiguration() { // Default Configuration // Add Global configuration Parameters here. @@ -143,6 +168,7 @@ void TestbedConfigManager::writeTestbedConfigToStream(Common::WriteStream *ws) { } } _configFileInterface.saveToStream(*ws); + ws->flush(); } Common::SeekableReadStream *TestbedConfigManager::getConfigReadStream() { @@ -243,13 +269,9 @@ void TestbedConfigManager::selectTestsuites() { Testsuite::logPrintf("Info! : Interactive tests are also being executed.\n"); if (Testsuite::handleInteractiveInput(prompt, "Proceed?", "Customize", kOptionRight)) { - // Select testsuites using checkboxes TestbedOptionsDialog tbd(_testsuiteList, this); tbd.runModal(); - - - } } diff --git a/engines/testbed/config.h b/engines/testbed/config.h index bbab1b9405..224954d44e 100644 --- a/engines/testbed/config.h +++ b/engines/testbed/config.h @@ -114,6 +114,20 @@ private: TestbedConfigManager *_testbedConfMan; }; +class TestbedInteractionDialog : public GUI::Dialog { +public: + TestbedInteractionDialog(uint x, uint y, uint w, uint h) : GUI::Dialog(x, y, w, h) {} + ~TestbedInteractionDialog() {} +protected: + virtual void handleCommand(GUI::CommandSender *sender, uint32 cmd, uint32 data); + void addButton(uint w, uint h, const Common::String name, uint32 cmd, uint xOffset = 0, uint yPadding = 8); + void addText(uint w, uint h, const Common::String text, Graphics::TextAlign textAlign, uint xOffset, uint yPadding); + Common::Array<GUI::ButtonWidget *> _buttonArray; + uint _xOffset; + uint _yOffset; + +}; + } // End of namespace Testbed #endif // TESTBED_CONFIG_H diff --git a/engines/testbed/sound.cpp b/engines/testbed/sound.cpp index dd4d26da44..37e814eda2 100644 --- a/engines/testbed/sound.cpp +++ b/engines/testbed/sound.cpp @@ -37,7 +37,7 @@ enum { kPauseChannel3 = 'pac3' }; -SoundSubsystemDialog::SoundSubsystemDialog() : GUI::Dialog(80, 60, 400, 170) { +SoundSubsystemDialog::SoundSubsystemDialog() : TestbedInteractionDialog(80, 60, 400, 170) { _xOffset = 25; _yOffset = 0; Common::String text = "Sound Subsystem Tests: Test Mixing of Audio Streams."; @@ -48,23 +48,6 @@ SoundSubsystemDialog::SoundSubsystemDialog() : GUI::Dialog(80, 60, 400, 170) { addButton(50, 20, "Close", GUI::kCloseCmd, 160, 15); } -void SoundSubsystemDialog::addText(uint w, uint h, const Common::String text, Graphics::TextAlign textAlign, uint xOffset, uint yPadding) { - if (!xOffset) { - xOffset = _xOffset; - } - _yOffset += yPadding; - new GUI::StaticTextWidget(this, xOffset, _yOffset, w, h, text, textAlign); - _yOffset += h; -} - -void SoundSubsystemDialog::addButton(uint w, uint h, const Common::String name, uint32 cmd, uint xOffset, uint yPadding) { - if (!xOffset) { - xOffset = _xOffset; - } - _yOffset += yPadding; - _buttonArray.push_back(new GUI::ButtonWidget(this, xOffset, _yOffset, w, h, name, cmd)); - _yOffset += h; -} void SoundSubsystemDialog::handleCommand(GUI::CommandSender *sender, uint32 cmd, uint32 data) { switch (cmd) { diff --git a/engines/testbed/sound.h b/engines/testbed/sound.h index 4d432a36fc..841a386b81 100644 --- a/engines/testbed/sound.h +++ b/engines/testbed/sound.h @@ -25,22 +25,17 @@ #ifndef TESTBED_SOUND_H #define TESTBED_SOUND_H -#include "testbed/testsuite.h" #include "gui/dialog.h" +#include "testbed/config.h" +#include "testbed/testsuite.h" namespace Testbed { -class SoundSubsystemDialog : public GUI::Dialog { +class SoundSubsystemDialog : public TestbedInteractionDialog { public: SoundSubsystemDialog(); ~SoundSubsystemDialog() {} void handleCommand(GUI::CommandSender *sender, uint32 cmd, uint32 data); -private: - void addButton(uint w, uint h, const Common::String name, uint32 cmd, uint xOffset = 0, uint yPadding = 8); - void addText(uint w, uint h, const Common::String text, Graphics::TextAlign textAlign, uint xOffset, uint yPadding); - Common::Array<GUI::ButtonWidget *> _buttonArray; - uint _xOffset; - uint _yOffset; }; namespace SoundSubsystem { diff --git a/engines/testbed/testbed.cpp b/engines/testbed/testbed.cpp index bb9d81d4e8..f75785c74e 100644 --- a/engines/testbed/testbed.cpp +++ b/engines/testbed/testbed.cpp @@ -28,7 +28,6 @@ #include "engines/util.h" -#include "testbed/config.h" #include "testbed/events.h" #include "testbed/fs.h" #include "testbed/graphics.h" @@ -39,6 +38,26 @@ namespace Testbed { +TestbedExitDialog::TestbedExitDialog() : TestbedInteractionDialog(80, 60, 400, 170), _rerun(false) { + _xOffset = 25; + _yOffset = 0; + Common::String text = "Here we will have the results of all the tests!"; + addText(350, 20, text, Graphics::kTextAlignCenter, _xOffset, 15); + addButton(200, 20, "Rerun Tests", kCmdRerunTestbed); + addButton(50, 20, "Close", GUI::kCloseCmd, 160, 15); + +} + +void TestbedExitDialog::handleCommand(GUI::CommandSender *sender, uint32 cmd, uint32 data) { + switch (cmd) { + case kCmdRerunTestbed : + _rerun = true; + GUI::Dialog::close(); + default: + GUI::Dialog::handleCommand(sender, cmd, data); + } +} + bool TestbedEngine::hasFeature(EngineFeature f) const { return (f == kSupportsRTL) ? true : false; } @@ -95,6 +114,7 @@ void TestbedEngine::invokeTestsuites(TestbedConfigManager &cfMan) { int numSuitesEnabled = cfMan.getNumSuitesEnabled(); for (iter = _testsuiteList.begin(); iter != _testsuiteList.end(); iter++) { + (*iter)->reset(); if ((*iter)->isEnabled()) { Testsuite::updateStats("Testsuite", (*iter)->getName(), count++, numSuitesEnabled, pt); (*iter)->execute(); @@ -111,17 +131,26 @@ Common::Error TestbedEngine::run() { // TODO: Implement that TestbedConfigManager cfMan(_testsuiteList, "testbed.config"); - cfMan.selectTestsuites(); - - // Init logging - Testsuite::initLogging(true); - // check if user wanted to exit. - if (Engine::shouldQuit()) { - return Common::kNoError; - } + // Keep running if rerun requested + TestbedExitDialog tbDialog; + + do { + Testsuite::clearEntireScreen(); + cfMan.selectTestsuites(); + // Init logging + Testsuite::initLogging(true); + // Check if user wanted to exit. + if (Engine::shouldQuit()) { + return Common::kNoError; + } + + invokeTestsuites(cfMan); + + tbDialog.run(); + + } while (tbDialog.rerunRequired()); - invokeTestsuites(cfMan); return Common::kNoError; } diff --git a/engines/testbed/testbed.h b/engines/testbed/testbed.h index a13249fe49..a880aa2ba1 100644 --- a/engines/testbed/testbed.h +++ b/engines/testbed/testbed.h @@ -29,6 +29,7 @@ #include "gui/options.h" +#include "testbed/config.h" #include "testbed/testsuite.h" namespace Testbed { @@ -37,7 +38,8 @@ class TestbedConfigManager; enum { kTestbedLogOutput = 1 << 0, - kTestbedEngineDebug = 1 << 2 + kTestbedEngineDebug = 1 << 2, + kCmdRerunTestbed = 'crtb' }; class TestbedEngine : public Engine { @@ -53,11 +55,28 @@ public: void invokeTestsuites(TestbedConfigManager &cfMan); bool hasFeature(EngineFeature f) const; - + private: Common::Array<Testsuite *> _testsuiteList; }; +class TestbedExitDialog : public TestbedInteractionDialog { +public: + TestbedExitDialog(); + ~TestbedExitDialog() {} + void handleCommand(GUI::CommandSender *sender, uint32 cmd, uint32 data); + void run() { runModal(); } + bool rerunRequired() { + if (_rerun) { + _rerun = false; + return true; + } + return false; + } +private: + bool _rerun; +}; + } // End of namespace Testbed #endif // TESTBED_H diff --git a/engines/testbed/testsuite.cpp b/engines/testbed/testsuite.cpp index 635099aab6..5ea6970241 100644 --- a/engines/testbed/testsuite.cpp +++ b/engines/testbed/testsuite.cpp @@ -131,6 +131,15 @@ Testsuite::~Testsuite() { } } +void Testsuite::reset() { + _numTestsPassed = 0; + _numTestsExecuted = 0; + toQuit = kLoopNormal; + for (Common::Array<Test *>::iterator i = _testsToExecute.begin(); i != _testsToExecute.end(); ++i) { + (*i)->passed = false; + } +} + void Testsuite::genReport() const { logPrintf("\n"); logPrintf("Consolidating results...\n"); diff --git a/engines/testbed/testsuite.h b/engines/testbed/testsuite.h index a703417204..aa47f0a8e7 100644 --- a/engines/testbed/testsuite.h +++ b/engines/testbed/testsuite.h @@ -92,7 +92,8 @@ public: _isTsEnabled = flag; } bool enableTest(const Common::String &testName, bool enable); - + void reset(); + /** * Prompts for User Input in form of "Yes" or "No" for interactive tests * e.g: "Is this like you expect?" "Yes" or "No" |