diff options
author | Neeraj Kumar | 2010-07-29 13:09:14 +0000 |
---|---|---|
committer | Neeraj Kumar | 2010-07-29 13:09:14 +0000 |
commit | 4814db3a6a99f0a8920968e736494571b25d225b (patch) | |
tree | 197a314011d131b0f472888ab54fa1568997f2e7 | |
parent | 890ec11a49fb670b49d70c024318194253b4a908 (diff) | |
download | scummvm-rg350-4814db3a6a99f0a8920968e736494571b25d225b.tar.gz scummvm-rg350-4814db3a6a99f0a8920968e736494571b25d225b.tar.bz2 scummvm-rg350-4814db3a6a99f0a8920968e736494571b25d225b.zip |
TESTBED: implemented gui of Sound Subsystem tests
svn-id: r51468
-rw-r--r-- | engines/testbed/sound.cpp | 77 | ||||
-rw-r--r-- | engines/testbed/sound.h | 15 | ||||
-rw-r--r-- | engines/testbed/testsuite.cpp | 2 | ||||
-rw-r--r-- | engines/testbed/testsuite.h | 2 |
4 files changed, 94 insertions, 2 deletions
diff --git a/engines/testbed/sound.cpp b/engines/testbed/sound.cpp index 671f720be5..dd4d26da44 100644 --- a/engines/testbed/sound.cpp +++ b/engines/testbed/sound.cpp @@ -28,6 +28,76 @@ namespace Testbed { +enum { + kPlayChannel1 = 'pch1', + kPlayChannel2 = 'pch2', + kPlayChannel3 = 'pch3', + kPauseChannel1 = 'pac1', + kPauseChannel2 = 'pac2', + kPauseChannel3 = 'pac3' +}; + +SoundSubsystemDialog::SoundSubsystemDialog() : GUI::Dialog(80, 60, 400, 170) { + _xOffset = 25; + _yOffset = 0; + Common::String text = "Sound Subsystem Tests: Test Mixing of Audio Streams."; + addText(350, 20, text, Graphics::kTextAlignCenter, _xOffset, 15); + addButton(200, 20, "Play Channel #1", kPlayChannel1); + addButton(200, 20, "Play Channel #2", kPlayChannel2); + addButton(200, 20, "Play Channel #3", kPlayChannel3); + 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) { + case kPlayChannel1: + _buttonArray[0]->setLabel("Pause Channel #1"); + _buttonArray[0]->setCmd(kPauseChannel1); + // TODO: Play music #1 here + break; + case kPlayChannel2: + _buttonArray[1]->setLabel("Pause Channel #2"); + _buttonArray[1]->setCmd(kPauseChannel2); + break; + case kPlayChannel3: + _buttonArray[2]->setLabel("Pause Channel #3"); + _buttonArray[2]->setCmd(kPauseChannel3); + break; + case kPauseChannel1: + _buttonArray[0]->setLabel("Play Channel #1"); + _buttonArray[0]->setCmd(kPlayChannel1); + break; + case kPauseChannel2: + _buttonArray[1]->setLabel("Play Channel #2"); + _buttonArray[1]->setCmd(kPlayChannel2); + break; + case kPauseChannel3: + _buttonArray[2]->setLabel("Play Channel #3"); + _buttonArray[2]->setCmd(kPlayChannel3); + break; + default: + GUI::Dialog::handleCommand(sender, cmd, data); + } +} + bool SoundSubsystem::playPCSpkSound() { Audio::PCSpeaker *speaker = new Audio::PCSpeaker(); Audio::Mixer *mixer = g_system->getMixer(); @@ -43,8 +113,15 @@ bool SoundSubsystem::playPCSpkSound() { return true; } +bool SoundSubsystem::mixSounds() { + SoundSubsystemDialog sDialog; + sDialog.runModal(); + return true; +} + SoundSubsystemTestSuite::SoundSubsystemTestSuite() { addTest("PCSpkrSound", &SoundSubsystem::playPCSpkSound, true); + addTest("MixSounds", &SoundSubsystem::mixSounds, true); } } // End of namespace Testbed diff --git a/engines/testbed/sound.h b/engines/testbed/sound.h index 4078bbcac3..4d432a36fc 100644 --- a/engines/testbed/sound.h +++ b/engines/testbed/sound.h @@ -26,15 +26,30 @@ #define TESTBED_SOUND_H #include "testbed/testsuite.h" +#include "gui/dialog.h" namespace Testbed { +class SoundSubsystemDialog : public GUI::Dialog { +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 { // Helper functions for SoundSubsystem tests // will contain function declarations for SoundSubsystem tests bool playPCSpkSound(); +bool mixSounds(); } class SoundSubsystemTestSuite : public Testsuite { diff --git a/engines/testbed/testsuite.cpp b/engines/testbed/testsuite.cpp index fe407f32f2..635099aab6 100644 --- a/engines/testbed/testsuite.cpp +++ b/engines/testbed/testsuite.cpp @@ -219,7 +219,7 @@ void Testsuite::addTest(const Common::String &name, InvokingFunction f, bool isI _testsToExecute.push_back(featureTest); } -const int Testsuite::getNumTestsEnabled() { +int Testsuite::getNumTestsEnabled() { int count = 0; Common::Array<Test *>::const_iterator iter; for (iter = _testsToExecute.begin(); iter != _testsToExecute.end(); iter++) { diff --git a/engines/testbed/testsuite.h b/engines/testbed/testsuite.h index b4357e1f1e..a703417204 100644 --- a/engines/testbed/testsuite.h +++ b/engines/testbed/testsuite.h @@ -171,7 +171,7 @@ public: static void updateStats(const char *prefix, const char *info, uint numTests, uint testNum, Common::Point pt); const Common::Array<Test *>& getTestList() { return _testsToExecute; } - const int getNumTestsEnabled(); + int getNumTestsEnabled(); protected: Common::Array<Test *> _testsToExecute; ///< List of tests to be executed |