diff options
author | Neeraj Kumar | 2010-06-02 04:45:44 +0000 |
---|---|---|
committer | Neeraj Kumar | 2010-06-02 04:45:44 +0000 |
commit | 5df3809d371c1d37d03dfd51689a58420cc337a6 (patch) | |
tree | c0983c9f67dc45b2add8197cd8cb46bd8b8c1e01 | |
parent | da1f5ee54c91cab0e8a7bf1523a7c8318ee63d1d (diff) | |
download | scummvm-rg350-5df3809d371c1d37d03dfd51689a58420cc337a6.tar.gz scummvm-rg350-5df3809d371c1d37d03dfd51689a58420cc337a6.tar.bz2 scummvm-rg350-5df3809d371c1d37d03dfd51689a58420cc337a6.zip |
enhanced the basic testsuite class
svn-id: r49390
-rw-r--r-- | engines/testbed/graphics.cpp | 40 | ||||
-rw-r--r-- | engines/testbed/graphics.h | 20 | ||||
-rw-r--r-- | engines/testbed/testbed.cpp | 23 | ||||
-rw-r--r-- | engines/testbed/testsuite.h | 59 |
4 files changed, 98 insertions, 44 deletions
diff --git a/engines/testbed/graphics.cpp b/engines/testbed/graphics.cpp new file mode 100644 index 0000000000..b8fcc40564 --- /dev/null +++ b/engines/testbed/graphics.cpp @@ -0,0 +1,40 @@ +#include "testbed/graphics.h" + +namespace Testbed { + +bool testFullScreenMode() { + + printf("Testing fullscreen mode\n"); + bool isFeaturePresent; + bool isFeatureEnabled; + + isFeaturePresent = g_system->hasFeature(OSystem::kFeatureFullscreenMode); + isFeatureEnabled = g_system->getFeatureState(OSystem::kFeatureFullscreenMode); + + printf("Testing Feature Presence.. \n"); + if (isFeaturePresent) { + //Toggle + printf("Supported\n"); + + g_system->beginGFXTransaction(); + g_system->setFeatureState(OSystem::kFeatureFullscreenMode, !isFeatureEnabled); + g_system->endGFXTransaction(); + + g_system->delayMillis(1000); + + g_system->beginGFXTransaction(); + g_system->setFeatureState(OSystem::kFeatureFullscreenMode, isFeatureEnabled); + g_system->endGFXTransaction(); + } + +} + +GFXTestSuite::GFXTestSuite() { + addTest("FullScreenMode", &testFullScreenMode); +} + +int execute() { + //TODO: Implement the method +} + +} diff --git a/engines/testbed/graphics.h b/engines/testbed/graphics.h index d10871fefe..db6a6a6d55 100644 --- a/engines/testbed/graphics.h +++ b/engines/testbed/graphics.h @@ -1,8 +1,24 @@ #ifdef GRAPHICS_H #define GRAPHICS_H +#include "testbed/testsuite.h" + namespace Testbed { -class GFXTestsuite : Testsuite { +class GFXTestSuite : public Testsuite { public: - + /** + * The constructor for the GFXTestSuite + * For every test to be executed one must: + * 1) Create a function that would invoke the test + * 2) Add that test to list by executing addTest() + * + * @see addTest() + */ + GFXTestSuite(); + ~GFXTestSuite() {}; +} + +} // End of namespace Testbed + +#endif diff --git a/engines/testbed/testbed.cpp b/engines/testbed/testbed.cpp index 5c71c60a9e..6af17c888e 100644 --- a/engines/testbed/testbed.cpp +++ b/engines/testbed/testbed.cpp @@ -49,29 +49,6 @@ Common::Error TestbedEngine::run() { // Additional setup. printf("TestbedEngine::init\n"); - printf("Testing fullscreen mode\n"); - bool isFeaturePresent; - bool isFeatureEnabled; - - isFeaturePresent = _system->hasFeature(OSystem::kFeatureFullscreenMode); - isFeatureEnabled = _system->getFeatureState(OSystem::kFeatureFullscreenMode); - - printf("Testing Feature Presence.. \n"); - if (isFeaturePresent) { - //Toggle - printf("Supported\n"); - - _system->beginGFXTransaction(); - _system->setFeatureState(OSystem::kFeatureFullscreenMode, !isFeatureEnabled); - _system->endGFXTransaction(); - - _system->delayMillis(1000); - - _system->beginGFXTransaction(); - _system->setFeatureState(OSystem::kFeatureFullscreenMode, isFeatureEnabled); - _system->endGFXTransaction(); - } - // Your main even loop should be (invoked from) here. printf("TestbedEngine::go: Hello, World!\n"); diff --git a/engines/testbed/testsuite.h b/engines/testbed/testsuite.h index fd36b1a953..3f968a6d21 100644 --- a/engines/testbed/testsuite.h +++ b/engines/testbed/testsuite.h @@ -2,29 +2,35 @@ #define TESTSUITE_H #include "common/system.h" +#include "common/str.h" +#include "common/array.h" namespace Testbed { typedef bool (*invokingFunction)(); /** - * This represents the a feature to be tested - * - * @Note - * featureName stores the name of this feature test, for display purposes - * driver is pointer to the function that will invoke this feature test - * enabled decides whether or not this test is to be executed - * passed collects and stores result of this feature test. - * + * Make g_system available to test invoker functions */ +extern OSystem *g_system; + +/** + * This represents a feature to be tested + */ + struct Test { - Test(Common::String name, invokingFunction f) : featureName(name), driver(f) {} - Common::String featureName; - invokingFunction driver; - bool enabled; - bool passed; + Test(Common::String name, invokingFunction f) : featureName(name), + driver(f), + enabled(true), + passed(false) {} + + Common::String featureName; ///< Name of feature to be tested + invokingFunction driver; ///< Pointer to the function that will invoke this feature test + bool enabled; ///< Decides whether or not this test is to be executed + bool passed; ///< Collects and stores result of this feature test }; + /** * The basic Testsuite class * All the other testsuites would inherit it and override its virtual methods @@ -35,22 +41,37 @@ public: Testsuite() { extern OSystem *g_system; _backend = g_system; + _numTestsPassed = 0; + _numTestsExecuted = 0; } ~Testsuite() {} - inline int getNumTestsPassed() { return _numTestsPassed; }; - inline int getNumTestsFailed() { return _numTestsExecuted - _numTestsPassed; }; + inline int getNumTests() { return _testsToExecute.size(); } + inline int getNumTestsPassed() { return _numTestsPassed; } + inline int getNumTestsFailed() { return _numTestsExecuted - _numTestsPassed; } + + /** + * Adds a test to the list of tests to be executed + * + * @param name the string description of the test, for display purposes + * @param f pointer to the function that invokes this test + */ inline void addTest(Common::String name, invokingFunction f) { Test featureTest(name, f); _testsToExecute.push_back(featureTest); } + + /** + * The driver function for the testsuite + * All code should go in here. + */ virtual int execute() = 0; virtual const char *getName() = 0; private: - OSystem *_backend; - int _numTestsPassed; - int _numTestsExecuted; - Common::Array<Test> _testsToExecute; + OSystem *_backend; ///< Pointer to OSystem backend + int _numTestsPassed; ///< Number of tests passed + int _numTestsExecuted; ///< Number of tests executed + Common::Array<Test> _testsToExecute; ///< List of tests to be executed } } // End of namespace testbed |