aboutsummaryrefslogtreecommitdiff
path: root/engines/testbed
diff options
context:
space:
mode:
authorNeeraj Kumar2010-07-22 17:59:59 +0000
committerNeeraj Kumar2010-07-22 17:59:59 +0000
commitc030858cf130a20179368fb231371ae348d8fda4 (patch)
treec7b9278aa67eb1ecd2e75269f562c8081b8f9f9e /engines/testbed
parentf6be0274df5c9dbdf6de262d310460e2d1d8b2e0 (diff)
downloadscummvm-rg350-c030858cf130a20179368fb231371ae348d8fda4.tar.gz
scummvm-rg350-c030858cf130a20179368fb231371ae348d8fda4.tar.bz2
scummvm-rg350-c030858cf130a20179368fb231371ae348d8fda4.zip
TESTBED: added deselect capabilty in GUI, removed redundant code, testsuites now all enabled by default
svn-id: r51155
Diffstat (limited to 'engines/testbed')
-rw-r--r--engines/testbed/config.cpp78
-rw-r--r--engines/testbed/config.h48
-rw-r--r--engines/testbed/testsuite.cpp4
3 files changed, 58 insertions, 72 deletions
diff --git a/engines/testbed/config.cpp b/engines/testbed/config.cpp
index 8f2b8f1f93..58d0aa55bc 100644
--- a/engines/testbed/config.cpp
+++ b/engines/testbed/config.cpp
@@ -29,30 +29,34 @@ namespace Testbed {
TestbedOptionsDialog::TestbedOptionsDialog(Common::Array<Testsuite *> &tsList, TestbedConfigManager *tsConfMan) : GUI::Dialog("Browser") {
- _testbedConfMan = tsConfMan;
-
new GUI::StaticTextWidget(this, "Browser.Headline", "Select Testsuites to Execute");
new GUI::StaticTextWidget(this, "Browser.Path", "Use Double click to select / deselect");
// Construct a String Array
Common::Array<Testsuite *>::const_iterator iter;
+ Common::String description;
for (iter = tsList.begin(); iter != tsList.end(); iter++) {
- _testSuiteArray.push_back((*iter)->getName());
- _testSuiteDescArray.push_back((*iter)->getDescription());
- _colors.push_back(GUI::ThemeEngine::kFontColorAlternate);
+ _testSuiteArray.push_back(*iter);
+ description = (*iter)->getDescription();
+ if ((*iter)->isEnabled()) {
+ _testSuiteDescArray.push_back(description + "(selected)");
+ _colors.push_back(GUI::ThemeEngine::kFontColorNormal);
+ } else {
+ _testSuiteDescArray.push_back(description);
+ _colors.push_back(GUI::ThemeEngine::kFontColorAlternate);
+ }
}
- _testListDisplay = new TestbedListWidget(this, "Browser.List", _testSuiteDescArray);
+ _testListDisplay = new TestbedListWidget(this, "Browser.List", _testSuiteArray);
_testListDisplay->setNumberingMode(GUI::kListNumberingOff);
_testListDisplay->setList(_testSuiteDescArray, &_colors);
// This list shouldn't be editable
_testListDisplay->setEditable(false);
- new GUI::ButtonWidget(this, "Browser.Up", "Select All", kTestbedSelectAll, 0);
+ _selectButton = new GUI::ButtonWidget(this, "Browser.Up", "Deselect All", kTestbedDeselectAll, 0);
new GUI::ButtonWidget(this, "Browser.Cancel", "Continue", GUI::kCloseCmd);
- // XXX: Add more commands for this
new GUI::ButtonWidget(this, "Browser.Choose", "Exit Testbed", kTestbedQuitCmd);
}
@@ -62,56 +66,54 @@ void TestbedOptionsDialog::handleCommand(GUI::CommandSender *sender, uint32 cmd,
Testsuite *ts;
switch (cmd) {
case GUI::kListItemDoubleClickedCmd:
- ts = _testbedConfMan->getTestsuiteByName(_testSuiteArray[_testListDisplay->getSelected()]);
+ ts = _testSuiteArray[_testListDisplay->getSelected()];
if (ts) {
+ if (ts->isEnabled()) {
+ ts->enable(false);
+ _testListDisplay->markAsDeselected(_testListDisplay->getSelected());
+ } else {
+ ts->enable(true);
+ _testListDisplay->markAsSelected(_testListDisplay->getSelected());
+ }
ts->enable(!ts->isEnabled());
- _testListDisplay->changeColor();
}
break;
+
case kTestbedQuitCmd:
Engine::quitGame();
close();
break;
+
+ case kTestbedDeselectAll:
+ _selectButton->setLabel("Select All");
+ _selectButton->setCmd(kTestbedSelectAll);
+ for (uint i = 0; i < _testSuiteArray.size(); i++) {
+ _testListDisplay->markAsDeselected(i);
+ ts = _testSuiteArray[i];
+ if (ts) {
+ ts->enable(false);
+ }
+ }
+ break;
+
case kTestbedSelectAll:
+ _selectButton->setLabel("Deselect All");
+ _selectButton->setCmd(kTestbedDeselectAll);
for (uint i = 0; i < _testSuiteArray.size(); i++) {
- ts = _testbedConfMan->getTestsuiteByName(_testSuiteArray[i]);
+ _testListDisplay->markAsSelected(i);
+ ts = _testSuiteArray[i];
if (ts) {
ts->enable(true);
}
}
- _testListDisplay->setColorAll(GUI::ThemeEngine::kFontColorNormal);
break;
+
default:
GUI::Dialog::handleCommand(sender, cmd, data);
+
}
}
-bool TestbedConfigManager::isEnabled(const Common::String &tsName) {
- Testsuite *ts = getTestsuiteByName(tsName);
- return ts ? ts->isEnabled() : false;
-}
-
-
-void TestbedConfigManager::enableTestsuite(const Common::String &name, bool enable) {
- Testsuite *ts = getTestsuiteByName(name);
- if (ts) {
- ts->enable(enable);
- } else {
- warning("No matches found for %s\n", name.c_str());
- }
-}
-
-Testsuite *TestbedConfigManager::getTestsuiteByName(const Common::String &name) {
- Common::Array<Testsuite *>::const_iterator iter;
-
- for (iter = _testsuiteList.begin(); iter != _testsuiteList.end(); iter++) {
- if (name.equalsIgnoreCase((*iter)->getName())) {
- return *iter;
- }
- }
- return 0;
-}
-
void TestbedConfigManager::selectTestsuites() {
diff --git a/engines/testbed/config.h b/engines/testbed/config.h
index b141330b3b..bbb591d337 100644
--- a/engines/testbed/config.h
+++ b/engines/testbed/config.h
@@ -40,7 +40,8 @@ namespace Testbed {
enum {
kTestbedQuitCmd = 'Quit',
- kTestbedSelectAll = 'sAll'
+ kTestbedSelectAll = 'sAll',
+ kTestbedDeselectAll = 'dAll'
};
class TestbedConfigManager {
@@ -48,46 +49,29 @@ public:
TestbedConfigManager(Common::Array<Testsuite *> &tList) : _testsuiteList(tList) {}
~TestbedConfigManager() {}
void selectTestsuites();
- Testsuite *getTestsuiteByName(const Common::String &name);
- bool isEnabled(const Common::String &tsName);
private:
Common::Array<Testsuite *> &_testsuiteList;
- void enableTestsuite(const Common::String &name, bool enable);
void parseConfigFile() {}
};
class TestbedListWidget : public GUI::ListWidget {
public:
- TestbedListWidget(GUI::Dialog *boss, const Common::String &name, Common::StringArray &tsDescArr) : GUI::ListWidget(boss, name), _testSuiteDescArray(tsDescArr) {}
+ TestbedListWidget(GUI::Dialog *boss, const Common::String &name, Common::Array<Testsuite *> tsArray) : GUI::ListWidget(boss, name), _testSuiteArray(tsArray) {}
- void changeColor() {
- // Using Font Color Mechanism to highlight selected entries.
- // Might not be detectable with some themes
- if (_listColors.size() >= 2) {
- if (GUI::ThemeEngine::kFontColorNormal == _listColors[_selectedItem]) {
- _listColors[_selectedItem] = GUI::ThemeEngine::kFontColorAlternate;
- } else if (GUI::ThemeEngine::kFontColorAlternate == _listColors[_selectedItem]) {
- _listColors[_selectedItem] = GUI::ThemeEngine::kFontColorNormal;
- }
- }
-
- // Also append (selected) to each selected entry
- if (_list[_selectedItem].contains("selected")) {
- _list[_selectedItem] = _testSuiteDescArray[_selectedItem];
- } else {
- _list[_selectedItem] += " (selected)";
+ void markAsSelected(int i) {
+ if (!_list[i].contains("selected")) {
+ _list[i] += " (selected)";
}
+ _listColors[i] = GUI::ThemeEngine::kFontColorNormal;
draw();
}
-
- void setColorAll(GUI::ThemeEngine::FontColor color) {
- for (uint i = 0; i < _listColors.size(); i++) {
- if (!_list[i].contains("selected")) {
- _listColors[i] = color;
- _list[i] += " (selected)";
- }
+
+ void markAsDeselected(int i) {
+ if (_list[i].contains("selected")) {
+ _list[i] = _testSuiteArray[i]->getDescription();
}
- draw();;
+ _listColors[i] = GUI::ThemeEngine::kFontColorAlternate;
+ draw();
}
void setColor(uint32 indx, GUI::ThemeEngine::FontColor color) {
@@ -97,7 +81,7 @@ public:
}
private:
- const Common::StringArray _testSuiteDescArray;
+ Common::Array<Testsuite *> _testSuiteArray;
};
class TestbedOptionsDialog : public GUI::Dialog {
@@ -108,10 +92,10 @@ public:
private:
GUI::ListWidget::ColorList _colors;
- Common::StringArray _testSuiteArray;
+ GUI::ButtonWidget *_selectButton;
+ Common::Array<Testsuite *> _testSuiteArray;
Common::StringArray _testSuiteDescArray;
TestbedListWidget *_testListDisplay;
- TestbedConfigManager *_testbedConfMan;
};
} // End of namespace Testbed
diff --git a/engines/testbed/testsuite.cpp b/engines/testbed/testsuite.cpp
index 8109989e44..5dbdb72515 100644
--- a/engines/testbed/testsuite.cpp
+++ b/engines/testbed/testsuite.cpp
@@ -117,8 +117,8 @@ void Testsuite::logDetailedPrintf(const char *fmt, ...) {
Testsuite::Testsuite() {
_numTestsPassed = 0;
_numTestsExecuted = 0;
- // Initially all testsuites are disabled, enable them by calling enableTestSuite(name, true)
- _isTsEnabled = false;
+ // Initially all testsuites are enabled, disable them by calling enableTestSuite(name, false)
+ _isTsEnabled = true;
}
Testsuite::~Testsuite() {