mirror of
https://github.com/libretro/scummvm.git
synced 2025-02-05 18:41:12 +00:00
separated testsuite configuration to another class
svn-id: r50918
This commit is contained in:
parent
12ebe8065e
commit
407d65068a
119
engines/testbed/config.cpp
Normal file
119
engines/testbed/config.cpp
Normal file
@ -0,0 +1,119 @@
|
||||
/* 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$
|
||||
*/
|
||||
|
||||
#include "testbed/config.h"
|
||||
#include "engines/engine.h"
|
||||
|
||||
namespace Testbed {
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
void TestbedConfigManager::enableTestsuite(const Common::String &name, bool enable) {
|
||||
Common::Array<Testsuite *>::const_iterator iter;
|
||||
|
||||
for (iter = _testsuiteList.begin(); iter != _testsuiteList.end(); iter++) {
|
||||
if (name.equalsIgnoreCase((*iter)->getName())) {
|
||||
(*iter)->enable(enable);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void TestbedConfigManager::selectTestsuites() {
|
||||
|
||||
|
||||
// Parse the config file
|
||||
// Enable testsuites as per configuration.
|
||||
// If no config file is found pickup a default configuration.
|
||||
// TODO : Implement this method
|
||||
|
||||
parseConfigFile();
|
||||
|
||||
if (!Testsuite::isSessionInteractive) {
|
||||
// Non interactive sessions don't need to go beyond
|
||||
return;
|
||||
}
|
||||
|
||||
// XXX: disabling these as of now for fastly testing other tests
|
||||
// Testsuite::isSessionInteractive = false;
|
||||
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 :)");
|
||||
|
||||
Testsuite::logPrintf("Info! : Interactive tests are also being executed.\n");
|
||||
|
||||
if (Testsuite::handleInteractiveInput(prompt, "Proceed?", "Customize", kOptionRight)) {
|
||||
|
||||
// Select testsuites using checkboxes
|
||||
TestbedOptionsDialog tbd;
|
||||
tbd.runModal();
|
||||
|
||||
// check if user wanted to exit.
|
||||
if (Engine::shouldQuit()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// 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);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
} // End of namespace Testbed
|
62
engines/testbed/config.h
Normal file
62
engines/testbed/config.h
Normal file
@ -0,0 +1,62 @@
|
||||
/* 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$
|
||||
*/
|
||||
|
||||
#ifndef TESTBED_CONFIG_H
|
||||
#define TESTBED_CONFIG_H
|
||||
|
||||
#include "testbed/testsuite.h"
|
||||
#include "common/array.h"
|
||||
#include "gui/options.h"
|
||||
|
||||
namespace Testbed {
|
||||
|
||||
class TestbedConfigManager {
|
||||
public:
|
||||
TestbedConfigManager(Common::Array<Testsuite *> &tList) : _testsuiteList(tList) {}
|
||||
~TestbedConfigManager() {}
|
||||
void selectTestsuites();
|
||||
private:
|
||||
Common::Array<Testsuite *> &_testsuiteList;
|
||||
void enableTestsuite(const Common::String &name, bool enable);
|
||||
void parseConfigFile() {}
|
||||
};
|
||||
|
||||
class TestbedOptionsDialog : public GUI::OptionsDialog {
|
||||
public:
|
||||
TestbedOptionsDialog();
|
||||
~TestbedOptionsDialog();
|
||||
void addCheckbox(const Common::String &tsName);
|
||||
bool isEnabled(const Common::String &tsName);
|
||||
|
||||
private:
|
||||
Common::Array<GUI::CheckboxWidget *> _checkBoxes;
|
||||
const int _hOffset; // current offset from left
|
||||
int _vOffset; // current offset from top
|
||||
const int _boxWidth;
|
||||
const int _boxHeight;
|
||||
};
|
||||
|
||||
} // End of namespace Testbed
|
||||
|
||||
#endif // TESTBED_CONFIG_H
|
@ -1,6 +1,7 @@
|
||||
MODULE := engines/testbed
|
||||
|
||||
MODULE_OBJS := \
|
||||
config.o \
|
||||
detection.o \
|
||||
events.o \
|
||||
fs.o \
|
||||
|
@ -27,8 +27,8 @@
|
||||
#include "common/system.h"
|
||||
|
||||
#include "engines/util.h"
|
||||
#include "gui/options.h"
|
||||
|
||||
#include "testbed/config.h"
|
||||
#include "testbed/events.h"
|
||||
#include "testbed/fs.h"
|
||||
#include "testbed/graphics.h"
|
||||
@ -84,19 +84,6 @@ TestbedEngine::~TestbedEngine() {
|
||||
}
|
||||
}
|
||||
|
||||
void TestbedEngine::enableTestsuite(const Common::String &name, bool enable) {
|
||||
Common::Array<Testsuite *>::const_iterator iter;
|
||||
|
||||
for (iter = _testsuiteList.begin(); iter != _testsuiteList.end(); iter++) {
|
||||
if (name.equalsIgnoreCase((*iter)->getName())) {
|
||||
(*iter)->enable(enable);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void TestbedEngine::invokeTestsuites() {
|
||||
Common::Array<Testsuite *>::const_iterator iter;
|
||||
|
||||
@ -107,34 +94,6 @@ void TestbedEngine::invokeTestsuites() {
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
Common::Error TestbedEngine::run() {
|
||||
// Initialize graphics using following:
|
||||
initGraphics(320, 200, false);
|
||||
@ -143,37 +102,8 @@ Common::Error TestbedEngine::run() {
|
||||
// interactive mode could also be modified by a config parameter "non-interactive=1"
|
||||
// TODO: Implement that
|
||||
|
||||
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
|
||||
// By default Interactive tests are enabled
|
||||
// XXX: disabling these as of now for fastly testing other tests
|
||||
// Testsuite::isSessionInteractive = false;
|
||||
|
||||
if (Testsuite::isSessionInteractive) {
|
||||
Testsuite::logPrintf("Info! : Interactive tests are also being executed.\n");
|
||||
Testsuite::displayMessage(prompt, "Proceed?");
|
||||
}
|
||||
|
||||
// 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);
|
||||
}
|
||||
}
|
||||
TestbedConfigManager cfMan(_testsuiteList);
|
||||
cfMan.selectTestsuites();
|
||||
|
||||
invokeTestsuites();
|
||||
return Common::kNoError;
|
||||
|
@ -62,21 +62,6 @@ private:
|
||||
Common::Array<Testsuite *> _testsuiteList;
|
||||
};
|
||||
|
||||
class TestbedOptionsDialog : public GUI::OptionsDialog {
|
||||
public:
|
||||
TestbedOptionsDialog();
|
||||
~TestbedOptionsDialog();
|
||||
void addCheckbox(const Common::String &tsName);
|
||||
bool isEnabled(const Common::String &tsName);
|
||||
|
||||
private:
|
||||
Common::Array<GUI::CheckboxWidget *> _checkBoxes;
|
||||
const int _hOffset; // current offset from left
|
||||
int _vOffset; // current offset from top
|
||||
const int _boxWidth;
|
||||
const int _boxHeight;
|
||||
};
|
||||
|
||||
} // End of namespace Testbed
|
||||
|
||||
#endif // TESTBED_H
|
||||
|
Loading…
x
Reference in New Issue
Block a user