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.
|
|
|
|
*
|
|
|
|
* $URL$
|
|
|
|
* $Id$
|
|
|
|
*/
|
|
|
|
|
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"
|
2010-05-31 04:58:19 +00:00
|
|
|
#include "common/system.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
|
|
|
#include "gui/options.h"
|
|
|
|
|
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-06-27 21:09:57 +00:00
|
|
|
#include "testbed/misc.h"
|
2010-06-25 21:03:53 +00:00
|
|
|
#include "testbed/savegame.h"
|
|
|
|
#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-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-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-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-06-29 22:46:56 +00:00
|
|
|
Testsuite::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-13 19:26:45 +00:00
|
|
|
void TestbedEngine::enableTestsuite(const Common::String &name, bool enable) {
|
2010-07-14 19:44:51 +00:00
|
|
|
Common::Array<Testsuite *>::const_iterator iter;
|
2010-07-01 12:30:56 +00:00
|
|
|
|
|
|
|
for (iter = _testsuiteList.begin(); iter != _testsuiteList.end(); iter++) {
|
2010-07-13 19:26:45 +00:00
|
|
|
if (name.equalsIgnoreCase((*iter)->getName())) {
|
2010-07-01 12:30:56 +00:00
|
|
|
(*iter)->enable(enable);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2010-07-14 14:12:42 +00:00
|
|
|
|
2010-07-01 12:30:56 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
void TestbedEngine::invokeTestsuites() {
|
2010-07-14 19:44:51 +00:00
|
|
|
Common::Array<Testsuite *>::const_iterator iter;
|
2010-07-14 14:12:42 +00:00
|
|
|
|
2010-07-01 12:30:56 +00:00
|
|
|
for (iter = _testsuiteList.begin(); iter != _testsuiteList.end(); iter++) {
|
|
|
|
if ((*iter)->isEnabled()) {
|
|
|
|
(*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
|
|
|
|
2010-07-13 19:26:45 +00:00
|
|
|
TestbedOptionsDialog::TestbedOptionsDialog() : GUI::OptionsDialog("Select", 120, 120, 360, 200), _hOffset(15), _vOffset(15), _boxWidth(300), _boxHeight(10) {
|
|
|
|
new GUI::StaticTextWidget(this, _hOffset, _vOffset, _boxWidth, _boxHeight, "Select testsuites to Execute", Graphics::kTextAlignCenter);
|
|
|
|
_vOffset += 20;
|
|
|
|
addCheckbox("FS");
|
|
|
|
addCheckbox("GFX");
|
|
|
|
addCheckbox("Savegames");
|
|
|
|
addCheckbox("Misc");
|
|
|
|
addCheckbox("Events");
|
|
|
|
new GUI::ButtonWidget(this, 80 , _vOffset + 10, 80, 25, "Continue", GUI::kOKCmd, 'C');
|
|
|
|
new GUI::ButtonWidget(this, 200, _vOffset + 10, 80, 25, "Exit", GUI::kCloseCmd, 'X');
|
|
|
|
}
|
|
|
|
|
|
|
|
TestbedOptionsDialog::~TestbedOptionsDialog() {}
|
|
|
|
|
|
|
|
void TestbedOptionsDialog::addCheckbox(const Common::String &tsName) {
|
|
|
|
_checkBoxes.push_back(new GUI::CheckboxWidget(this, _hOffset, _vOffset, _boxWidth, _boxHeight, tsName));
|
|
|
|
_vOffset += 20;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool TestbedOptionsDialog::isEnabled(const Common::String &tsName) {
|
|
|
|
for (uint i = 0; i < _checkBoxes.size(); i++) {
|
|
|
|
if (_checkBoxes[i]->getLabel().equalsIgnoreCase(tsName)) {
|
|
|
|
return _checkBoxes[i]->getState();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
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-06-10 12:40:58 +00:00
|
|
|
Common::String prompt("Welcome to the ScummVM testbed!\n"
|
|
|
|
"It is a framework to test the various ScummVM subsystems namely GFX, Sound, FS, events etc.\n"
|
|
|
|
"If you see this, it means interactive tests would run on this system :)");
|
|
|
|
|
|
|
|
// To be set from config file
|
2010-06-26 14:29:50 +00:00
|
|
|
// By default Interactive tests are enabled
|
2010-06-17 11:23:51 +00:00
|
|
|
// XXX: disabling these as of now for fastly testing other tests
|
2010-07-03 21:14:44 +00:00
|
|
|
// Testsuite::isSessionInteractive = false;
|
2010-06-06 14:06:51 +00:00
|
|
|
|
2010-07-01 12:30:56 +00:00
|
|
|
if (Testsuite::isSessionInteractive) {
|
2010-07-14 14:12:42 +00:00
|
|
|
Testsuite::logPrintf("Info! : Interactive tests are also being executed.\n");
|
2010-06-29 22:46:56 +00:00
|
|
|
Testsuite::displayMessage(prompt, "Proceed?");
|
2010-06-06 14:06:51 +00:00
|
|
|
}
|
2010-07-13 19:26:45 +00:00
|
|
|
|
|
|
|
// Select testsuites using checkboxes
|
|
|
|
TestbedOptionsDialog tbd;
|
|
|
|
tbd.runModal();
|
|
|
|
|
|
|
|
// check if user wanted to exit.
|
|
|
|
if (shouldQuit()) {
|
|
|
|
return Common::kNoError;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Enable selected testsuites
|
|
|
|
Common::String tsName;
|
|
|
|
for (uint i = 0; i < _testsuiteList.size(); i++) {
|
|
|
|
tsName = _testsuiteList[i]->getName();
|
|
|
|
if (tbd.isEnabled(tsName)) {
|
|
|
|
enableTestsuite(tsName, true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-07-01 12:30:56 +00:00
|
|
|
invokeTestsuites();
|
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
|