diff options
author | Neeraj Kumar | 2010-06-22 14:39:51 +0000 |
---|---|---|
committer | Neeraj Kumar | 2010-06-22 14:39:51 +0000 |
commit | 0012b23e8471135c7c5dcff5311db60c0164a881 (patch) | |
tree | ac2f0dd9ffd5bd8e05bd3be5d17a560b333ef916 /engines | |
parent | e86f732a7b67b6df6d78000d0f34ca8013b93b46 (diff) | |
download | scummvm-rg350-0012b23e8471135c7c5dcff5311db60c0164a881.tar.gz scummvm-rg350-0012b23e8471135c7c5dcff5311db60c0164a881.tar.bz2 scummvm-rg350-0012b23e8471135c7c5dcff5311db60c0164a881.zip |
modified the filesystem test, added a script to directly create the game-data-directory, no zip file required
svn-id: r50140
Diffstat (limited to 'engines')
-rw-r--r-- | engines/testbed/fs.cpp | 64 | ||||
-rw-r--r-- | engines/testbed/fs.h | 1 | ||||
-rw-r--r-- | engines/testbed/testbed.cpp | 2 |
3 files changed, 48 insertions, 19 deletions
diff --git a/engines/testbed/fs.cpp b/engines/testbed/fs.cpp index fc2204e41c..847cb28c21 100644 --- a/engines/testbed/fs.cpp +++ b/engines/testbed/fs.cpp @@ -7,7 +7,7 @@ namespace Testbed { /** * This test does the following: * 1) acquires the game-data path - * 2) In the game-data dir, there are three files: testbed, TeStBeD and TESTBED + * 2) In the game-root it navigates to "directory" and opens the file "file" * The former two are directories while the latter is a text file used for game engine detection * * Both the directories contain the file testbed.conf each which has a message written in it. @@ -15,25 +15,12 @@ namespace Testbed { * compares the message contained in it, with what it expects. * */ -bool FStests::testReadFile() { - const Common::String &path = ConfMan.get("path"); - Common::FSNode gameRoot(path); - - if (!gameRoot.isDirectory()) { - printf("LOG:game Path should be a directory"); - return false; - } +bool FStests::readDataFromFile(Common::FSNode &directory, const char *file) { - Common::FSNode subDir = gameRoot.getChild("TeStBeD"); - - if (!subDir.exists()) { - printf("LOG:Unable to recognize TeStBeD Inside the game Dir"); - return false; - } - Common::FSDirectory testBedDir(subDir); + Common::FSDirectory nestedDir(directory); - Common::SeekableReadStream *readStream = testBedDir.createReadStreamForMember("testbed.conf"); + Common::SeekableReadStream *readStream = nestedDir.createReadStreamForMember(file); if (!readStream) { printf("LOG:Can't open game file for reading\n"); @@ -42,7 +29,8 @@ bool FStests::testReadFile() { Common::String msg = readStream->readLine(); delete readStream; - printf("LOG: Message Extracted: %s\n", msg.c_str()); + printf("LOG: Message Extracted from %s : %s\n", file, msg.c_str()); + Common::String expectedMsg = "It works!"; @@ -54,6 +42,46 @@ bool FStests::testReadFile() { return true; } + +bool FStests::testReadFile() { + const Common::String &path = ConfMan.get("path"); + Common::FSNode gameRoot(path); + + if (!gameRoot.isDirectory()) { + printf("LOG:game Path should be a directory"); + return false; + } + + Common::FSList dirList; + gameRoot.getChildren(dirList); + + const char *file[] = {"file.txt", "File.txt", "FILE.txt", "fILe.txt", "file."}; + + for (unsigned int i = 0; i < dirList.size(); i++) { + Common::String fileName = file[i]; + if (!readDataFromFile(dirList[i], fileName.c_str())) { + printf("LOG : reading from %s failed", fileName.c_str()); + return false; + } + + fileName.toLowercase(); + + if (!readDataFromFile(dirList[i], fileName.c_str())) { + printf("LOG : reading from %s failed", fileName.c_str()); + return false; + } + + fileName.toUppercase(); + + if (!readDataFromFile(dirList[i], fileName.c_str())) { + printf("LOG : reading from %s failed", fileName.c_str()); + return false; + } + } + + return true; +} + /** * This test creates a file testbed.out, writes a sample data and confirms if * it is same by reading the file again. diff --git a/engines/testbed/fs.h b/engines/testbed/fs.h index c421725407..6f73babf7a 100644 --- a/engines/testbed/fs.h +++ b/engines/testbed/fs.h @@ -12,6 +12,7 @@ namespace FStests { // from commandline // Helper functions for FS tests +bool readDataFromFile(Common::FSNode &directory, const char *file); // will contain function declarations for FS tests bool testReadFile(); diff --git a/engines/testbed/testbed.cpp b/engines/testbed/testbed.cpp index 242504ca11..789fe7c2ec 100644 --- a/engines/testbed/testbed.cpp +++ b/engines/testbed/testbed.cpp @@ -62,7 +62,7 @@ Common::Error TestbedEngine::run() { // To be set from config file // XXX: disabling these as of now for fastly testing other tests - interactive = true; + interactive = false; if (interactive) { printf("Running Interactive tests as well\n"); |