2010-06-26 13:07:13 +00:00
|
|
|
/* 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.
|
|
|
|
*/
|
|
|
|
|
2010-06-29 22:46:56 +00:00
|
|
|
#include "common/debug-channels.h"
|
2010-05-24 17:43:55 +00:00
|
|
|
#include "common/scummsys.h"
|
2011-04-24 08:34:27 +00:00
|
|
|
#include "common/archive.h"
|
|
|
|
#include "common/config-manager.h"
|
|
|
|
#include "common/error.h"
|
|
|
|
#include "common/fs.h"
|
|
|
|
#include "common/rect.h"
|
|
|
|
#include "common/str.h"
|
2010-06-29 22:46:56 +00:00
|
|
|
|
2010-05-24 17:43:55 +00:00
|
|
|
#include "engines/util.h"
|
2010-07-13 19:26:45 +00:00
|
|
|
|
2010-07-03 21:14:44 +00:00
|
|
|
#include "testbed/events.h"
|
2010-06-17 11:23:51 +00:00
|
|
|
#include "testbed/fs.h"
|
2010-06-02 13:56:04 +00:00
|
|
|
#include "testbed/graphics.h"
|
2010-08-10 20:20:28 +00:00
|
|
|
#include "testbed/midi.h"
|
2010-06-27 21:09:57 +00:00
|
|
|
#include "testbed/misc.h"
|
2010-06-25 21:03:53 +00:00
|
|
|
#include "testbed/savegame.h"
|
2010-07-26 20:59:50 +00:00
|
|
|
#include "testbed/sound.h"
|
2010-06-25 21:03:53 +00:00
|
|
|
#include "testbed/testbed.h"
|
2010-07-14 14:12:42 +00:00
|
|
|
|
2010-05-31 04:58:19 +00:00
|
|
|
namespace Testbed {
|
2010-07-14 14:12:42 +00:00
|
|
|
|
2010-08-01 23:26:38 +00:00
|
|
|
void TestbedExitDialog::init() {
|
2010-07-30 13:54:25 +00:00
|
|
|
_xOffset = 25;
|
|
|
|
_yOffset = 0;
|
2010-08-01 23:26:38 +00:00
|
|
|
Common::String text = "Thank you for using ScummVM testbed! Here are yor summarized results:";
|
|
|
|
addText(450, 20, text, Graphics::kTextAlignCenter, _xOffset, 15);
|
|
|
|
Common::Array<Common::String> strArray;
|
2010-08-09 20:10:53 +00:00
|
|
|
GUI::ListWidget::ColorList colors;
|
2010-08-14 08:32:39 +00:00
|
|
|
|
2010-08-01 23:26:38 +00:00
|
|
|
for (Common::Array<Testsuite *>::const_iterator i = _testsuiteList.begin(); i != _testsuiteList.end(); ++i) {
|
2010-11-01 16:02:28 +00:00
|
|
|
strArray.push_back(Common::String::format("%s :", (*i)->getDescription()));
|
2010-08-09 20:10:53 +00:00
|
|
|
colors.push_back(GUI::ThemeEngine::kFontColorNormal);
|
|
|
|
if ((*i)->isEnabled()) {
|
2010-11-01 16:02:28 +00:00
|
|
|
strArray.push_back(Common::String::format("Passed: %d Failed: %d Skipped: %d", (*i)->getNumTestsPassed(), (*i)->getNumTestsFailed(), (*i)->getNumTestsSkipped()));
|
2010-08-09 20:10:53 +00:00
|
|
|
} else {
|
|
|
|
strArray.push_back("Skipped");
|
|
|
|
}
|
|
|
|
colors.push_back(GUI::ThemeEngine::kFontColorAlternate);
|
2010-08-01 23:26:38 +00:00
|
|
|
}
|
2010-08-14 08:32:39 +00:00
|
|
|
|
2010-08-09 20:10:53 +00:00
|
|
|
addList(0, _yOffset, 500, 200, strArray, &colors);
|
2010-10-02 01:05:16 +00:00
|
|
|
text = "More Details can be viewed in the Log file : " + ConfParams.getLogFilename();
|
2010-08-01 23:26:38 +00:00
|
|
|
addText(450, 20, text, Graphics::kTextAlignLeft, 0, 0);
|
2010-10-02 01:05:16 +00:00
|
|
|
if (ConfParams.getLogDirectory().size()) {
|
|
|
|
text = "Directory : " + ConfParams.getLogDirectory();
|
2010-08-09 21:18:27 +00:00
|
|
|
} else {
|
|
|
|
text = "Directory : .";
|
|
|
|
}
|
2010-08-01 23:26:38 +00:00
|
|
|
addText(500, 20, text, Graphics::kTextAlignLeft, 0, 0);
|
|
|
|
_yOffset += 5;
|
2010-08-09 20:10:53 +00:00
|
|
|
addButtonXY(_xOffset + 80, _yOffset, 120, 24, "Rerun test suite", kCmdRerunTestbed);
|
|
|
|
addButtonXY(_xOffset + 240, _yOffset, 60, 24, "Close", GUI::kCloseCmd);
|
2010-07-30 13:54:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void TestbedExitDialog::handleCommand(GUI::CommandSender *sender, uint32 cmd, uint32 data) {
|
|
|
|
switch (cmd) {
|
2011-06-06 23:11:09 +00:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
|
2010-07-30 13:54:25 +00:00
|
|
|
case kCmdRerunTestbed :
|
2010-10-02 01:05:16 +00:00
|
|
|
ConfParams.setRerunFlag(true);
|
2010-08-09 20:10:53 +00:00
|
|
|
cmd = GUI::kCloseCmd;
|
2011-06-06 23:11:09 +00:00
|
|
|
break;
|
2010-07-30 13:54:25 +00:00
|
|
|
}
|
2011-06-06 23:11:09 +00:00
|
|
|
|
|
|
|
GUI::Dialog::handleCommand(sender, cmd, data);
|
2010-07-30 13:54:25 +00:00
|
|
|
}
|
|
|
|
|
2010-07-05 21:29:15 +00:00
|
|
|
bool TestbedEngine::hasFeature(EngineFeature f) const {
|
|
|
|
return (f == kSupportsRTL) ? true : false;
|
|
|
|
}
|
|
|
|
|
2010-07-14 14:12:42 +00:00
|
|
|
TestbedEngine::TestbedEngine(OSystem *syst)
|
2010-05-24 17:43:55 +00:00
|
|
|
: 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().
|
2010-07-14 14:12:42 +00:00
|
|
|
|
2010-05-24 17:43:55 +00:00
|
|
|
// Do not initialize graphics here
|
2010-07-14 14:12:42 +00:00
|
|
|
|
2010-05-24 17:43:55 +00:00
|
|
|
// However this is the place to specify all default directories
|
2010-08-14 06:06:41 +00:00
|
|
|
// Put game-data dir in search path
|
|
|
|
Common::FSNode gameRoot(ConfMan.get("path"));
|
|
|
|
if (gameRoot.exists()) {
|
|
|
|
SearchMan.addDirectory(gameRoot.getDisplayName(), gameRoot);
|
|
|
|
}
|
2010-07-14 14:12:42 +00:00
|
|
|
|
2010-06-29 22:46:56 +00:00
|
|
|
DebugMan.addDebugChannel(kTestbedLogOutput, "LOG", "Log of test results generated by testbed");
|
|
|
|
DebugMan.addDebugChannel(kTestbedEngineDebug, "Debug", "Engine-specific debug statements");
|
|
|
|
DebugMan.enableDebugChannel("LOG");
|
2010-07-01 12:30:56 +00:00
|
|
|
|
|
|
|
// Initialize testsuites here
|
|
|
|
// GFX
|
|
|
|
Testsuite *ts = new GFXTestSuite();
|
|
|
|
_testsuiteList.push_back(ts);
|
|
|
|
// FS
|
|
|
|
ts = new FSTestSuite();
|
|
|
|
_testsuiteList.push_back(ts);
|
|
|
|
// Savegames
|
|
|
|
ts = new SaveGameTestSuite();
|
|
|
|
_testsuiteList.push_back(ts);
|
|
|
|
// Misc.
|
|
|
|
ts = new MiscTestSuite();
|
|
|
|
_testsuiteList.push_back(ts);
|
2010-07-03 21:14:44 +00:00
|
|
|
// Events
|
|
|
|
ts = new EventTestSuite();
|
|
|
|
_testsuiteList.push_back(ts);
|
2010-07-26 20:59:50 +00:00
|
|
|
// Sound
|
|
|
|
ts = new SoundSubsystemTestSuite();
|
|
|
|
_testsuiteList.push_back(ts);
|
2010-08-10 20:20:28 +00:00
|
|
|
// Midi
|
|
|
|
ts = new MidiTestSuite();
|
|
|
|
_testsuiteList.push_back(ts);
|
2010-05-24 17:43:55 +00:00
|
|
|
}
|
2010-07-14 14:12:42 +00:00
|
|
|
|
2010-05-31 04:58:19 +00:00
|
|
|
TestbedEngine::~TestbedEngine() {
|
2010-10-02 01:05:16 +00:00
|
|
|
ConfParams.deleteWriteStream();
|
2010-05-24 17:43:55 +00:00
|
|
|
// Remove all of our debug levels here
|
2010-06-29 22:46:56 +00:00
|
|
|
DebugMan.clearAllDebugChannels();
|
2010-07-14 14:12:42 +00:00
|
|
|
|
2010-07-14 19:44:51 +00:00
|
|
|
for (Common::Array<Testsuite *>::const_iterator i = _testsuiteList.begin(); i != _testsuiteList.end(); ++i) {
|
2010-07-01 12:30:56 +00:00
|
|
|
delete (*i);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-07-27 09:32:19 +00:00
|
|
|
void TestbedEngine::invokeTestsuites(TestbedConfigManager &cfMan) {
|
2010-07-14 19:44:51 +00:00
|
|
|
Common::Array<Testsuite *>::const_iterator iter;
|
2010-07-19 21:12:17 +00:00
|
|
|
uint count = 1;
|
|
|
|
Common::Point pt = Testsuite::getDisplayRegionCoordinates();
|
2010-07-27 09:32:19 +00:00
|
|
|
int numSuitesEnabled = cfMan.getNumSuitesEnabled();
|
2010-07-14 14:12:42 +00:00
|
|
|
|
2010-07-01 12:30:56 +00:00
|
|
|
for (iter = _testsuiteList.begin(); iter != _testsuiteList.end(); iter++) {
|
2010-08-14 06:06:41 +00:00
|
|
|
if (shouldQuit()) {
|
|
|
|
return;
|
|
|
|
}
|
2010-07-30 13:54:25 +00:00
|
|
|
(*iter)->reset();
|
2010-07-01 12:30:56 +00:00
|
|
|
if ((*iter)->isEnabled()) {
|
2010-07-27 09:32:19 +00:00
|
|
|
Testsuite::updateStats("Testsuite", (*iter)->getName(), count++, numSuitesEnabled, pt);
|
2010-07-01 12:30:56 +00:00
|
|
|
(*iter)->execute();
|
|
|
|
}
|
2010-07-14 19:44:51 +00:00
|
|
|
}
|
2010-05-24 17:43:55 +00:00
|
|
|
}
|
2010-05-31 04:58:19 +00:00
|
|
|
|
|
|
|
Common::Error TestbedEngine::run() {
|
2010-05-24 17:43:55 +00:00
|
|
|
// Initialize graphics using following:
|
|
|
|
initGraphics(320, 200, false);
|
2010-07-14 14:12:42 +00:00
|
|
|
|
2010-06-06 14:06:51 +00:00
|
|
|
// 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
|
2010-06-02 13:56:04 +00:00
|
|
|
|
2010-07-24 16:05:19 +00:00
|
|
|
TestbedConfigManager cfMan(_testsuiteList, "testbed.config");
|
2010-08-14 08:32:39 +00:00
|
|
|
|
2010-08-09 20:10:53 +00:00
|
|
|
// Keep running if rerun requested
|
2010-07-30 13:54:25 +00:00
|
|
|
|
|
|
|
do {
|
|
|
|
Testsuite::clearEntireScreen();
|
|
|
|
cfMan.selectTestsuites();
|
|
|
|
// Init logging
|
2010-10-02 01:05:16 +00:00
|
|
|
ConfParams.initLogging(true);
|
2010-08-14 06:06:41 +00:00
|
|
|
invokeTestsuites(cfMan);
|
2010-07-30 13:54:25 +00:00
|
|
|
// Check if user wanted to exit.
|
|
|
|
if (Engine::shouldQuit()) {
|
|
|
|
return Common::kNoError;
|
|
|
|
}
|
2010-08-14 08:32:39 +00:00
|
|
|
|
2010-08-09 20:10:53 +00:00
|
|
|
TestbedExitDialog tbDialog(_testsuiteList);
|
2010-08-01 23:26:38 +00:00
|
|
|
tbDialog.init();
|
2010-07-30 13:54:25 +00:00
|
|
|
tbDialog.run();
|
|
|
|
|
2010-10-02 01:05:16 +00:00
|
|
|
} while (ConfParams.isRerunRequired());
|
2010-08-14 08:32:39 +00:00
|
|
|
|
2010-05-24 17:43:55 +00:00
|
|
|
return Common::kNoError;
|
|
|
|
}
|
2010-07-14 14:12:42 +00:00
|
|
|
|
2010-05-31 04:58:19 +00:00
|
|
|
} // End of namespace Testbed
|