diff options
author | Neeraj Kumar | 2010-06-25 21:03:53 +0000 |
---|---|---|
committer | Neeraj Kumar | 2010-06-25 21:03:53 +0000 |
commit | 82bfb7b7bfce5fed14b8d0d1463a01f8cc8156fd (patch) | |
tree | cad9218740310e1df0d7c206e53312cf268bbe00 /engines | |
parent | 6e27ad3b2bdafce93a5743bdacb932b711bd7ef2 (diff) | |
download | scummvm-rg350-82bfb7b7bfce5fed14b8d0d1463a01f8cc8156fd.tar.gz scummvm-rg350-82bfb7b7bfce5fed14b8d0d1463a01f8cc8156fd.tar.bz2 scummvm-rg350-82bfb7b7bfce5fed14b8d0d1463a01f8cc8156fd.zip |
added savegame tests
svn-id: r50290
Diffstat (limited to 'engines')
-rw-r--r-- | engines/testbed/fs.cpp | 16 | ||||
-rw-r--r-- | engines/testbed/module.mk | 1 | ||||
-rw-r--r-- | engines/testbed/savegame.cpp | 51 | ||||
-rw-r--r-- | engines/testbed/savegame.h | 35 | ||||
-rw-r--r-- | engines/testbed/testbed.cpp | 6 |
5 files changed, 92 insertions, 17 deletions
diff --git a/engines/testbed/fs.cpp b/engines/testbed/fs.cpp index 53b08fd394..5b65648495 100644 --- a/engines/testbed/fs.cpp +++ b/engines/testbed/fs.cpp @@ -1,6 +1,5 @@ #include "common/config-manager.h" #include "common/stream.h" -#include "common/savefile.h" #include "common/util.h" #include "testbed/fs.h" @@ -122,26 +121,11 @@ bool FStests::testWriteFile() { return false; } -/** - * This test creates a savefile for the given testbed-state and could be reloaded using the saveFile API. - * It is intended to test saving and loading from savefiles. - */ - -bool FStests::testOpeningSaveFile() { - Common::SaveFileManager *saveFileMan = g_system->getSavefileManager(); - Common::OutSaveFile *saveFile = saveFileMan->openForSaving("saveFile.0"); - saveFile->writeString("State:FS tests"); - saveFile->flush(); - delete saveFile; - - return true; -} FSTestSuite::FSTestSuite() { addTest("ReadingFile", &FStests::testReadFile); addTest("WritingFile", &FStests::testWriteFile); - addTest("OpeningSaveFile", &FStests::testOpeningSaveFile); } const char *FSTestSuite::getName() const { return "File System"; diff --git a/engines/testbed/module.mk b/engines/testbed/module.mk index ab24d3ad37..62addd4224 100644 --- a/engines/testbed/module.mk +++ b/engines/testbed/module.mk @@ -4,6 +4,7 @@ MODULE_OBJS := \ detection.o \ fs.o \ graphics.o \ + savegame.o \ testbed.o MODULE_DIRS += \ diff --git a/engines/testbed/savegame.cpp b/engines/testbed/savegame.cpp new file mode 100644 index 0000000000..89f2a52f7b --- /dev/null +++ b/engines/testbed/savegame.cpp @@ -0,0 +1,51 @@ +#include "common/savefile.h" + +#include "testbed/savegame.h" + +namespace Testbed { + +/** + * This test creates a savefile for the given testbed-state and could be reloaded using the saveFile API. + * It is intended to test saving and loading from savefiles. + */ + +bool SaveGametests::testSaveLoadState() { + Common::SaveFileManager *saveFileMan = g_system->getSavefileManager(); + Common::OutSaveFile *saveFile = saveFileMan->openForSaving("saveFile.0"); + + if (!saveFile) { + printf("LOG: Can't open saveFile\n"); + return false; + } + + saveFile->writeString("ScummVM Rocks!"); + saveFile->finalize(); + delete saveFile; + + Common::InSaveFile *loadFile = saveFileMan->openForLoading("saveFile.0"); + + + if (!loadFile) { + printf("LOG: Can't open save File to load\n"); + return false; + } + + Common::String lineToRead = loadFile->readLine(); + delete loadFile; + + if (lineToRead.equals("ScummVM Rocks!")) { + return true; + } + + return false; +} + +SaveGameTestSuite::SaveGameTestSuite() { + addTest("Opening SaveFile", &SaveGametests::testSaveLoadState); +} + +const char *SaveGameTestSuite::getName() const { + return "SaveGames"; +} + +} // End of namespace testbed diff --git a/engines/testbed/savegame.h b/engines/testbed/savegame.h new file mode 100644 index 0000000000..337bd46786 --- /dev/null +++ b/engines/testbed/savegame.h @@ -0,0 +1,35 @@ +#ifndef SAVEGAME_H +#define SAVEGAME_H + +#include "testbed/testsuite.h" + +namespace Testbed { + +namespace SaveGametests { + +// Helper functions for SaveGame tests + +// will contain function declarations for SaveGame tests +bool testSaveLoadState(); +// add more here +} + +class SaveGameTestSuite : public Testsuite { +public: + /** + * The constructor for the SaveGameTestSuite + * 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() + */ + SaveGameTestSuite(); + ~SaveGameTestSuite(){} + const char *getName() const; + +}; + +} // End of namespace Testbed + +#endif diff --git a/engines/testbed/testbed.cpp b/engines/testbed/testbed.cpp index 242504ca11..8446bda574 100644 --- a/engines/testbed/testbed.cpp +++ b/engines/testbed/testbed.cpp @@ -3,9 +3,10 @@ #include "engines/util.h" -#include "testbed/testbed.h" #include "testbed/fs.h" #include "testbed/graphics.h" +#include "testbed/savegame.h" +#include "testbed/testbed.h" namespace Testbed { @@ -74,6 +75,9 @@ Common::Error TestbedEngine::run() { FSTestSuite fts; fts.execute(); + + SaveGameTestSuite sts; + sts.execute(); return Common::kNoError; } |