aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorNeeraj Kumar2010-06-17 20:24:01 +0000
committerNeeraj Kumar2010-06-17 20:24:01 +0000
commitfb210bd45fc5f02038f3c5602d9ba602fd60b1a0 (patch)
treea36f10e09f22a210a3d8678fc94b0611ce3b3da6 /engines
parentf3dcd38c74c835b0046a849cefa7dafcf1844ccd (diff)
downloadscummvm-rg350-fb210bd45fc5f02038f3c5602d9ba602fd60b1a0.tar.gz
scummvm-rg350-fb210bd45fc5f02038f3c5602d9ba602fd60b1a0.tar.bz2
scummvm-rg350-fb210bd45fc5f02038f3c5602d9ba602fd60b1a0.zip
added a FS test to open and read a file from the game-data dir
svn-id: r49948
Diffstat (limited to 'engines')
-rw-r--r--engines/testbed/detection.cpp2
-rw-r--r--engines/testbed/fs.cpp54
-rw-r--r--engines/testbed/fs.h1
3 files changed, 55 insertions, 2 deletions
diff --git a/engines/testbed/detection.cpp b/engines/testbed/detection.cpp
index 317b9e7dbd..bbe08e8556 100644
--- a/engines/testbed/detection.cpp
+++ b/engines/testbed/detection.cpp
@@ -50,7 +50,7 @@ public:
if (!file->isDirectory()) {
const char *gameName = file->getName().c_str();
- if (0 == scumm_stricmp("README", gameName)) {
+ if (0 == scumm_stricmp("TESTBED", gameName)) {
// You could check the contents of the file now if you need to.
detectedGames.push_back(testbed_setting[0]);
break;
diff --git a/engines/testbed/fs.cpp b/engines/testbed/fs.cpp
index 8428805cf8..8720494008 100644
--- a/engines/testbed/fs.cpp
+++ b/engines/testbed/fs.cpp
@@ -1,9 +1,61 @@
+#include "common/config-manager.h"
+#include "common/stream.h"
+
#include "testbed/fs.h"
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
+ * 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.
+ * The code accesses the appropriate file using the fileSystem API, creates a read stream of it and
+ * compares the message contained in it, with what it expects.
+ *
+ */
+bool FStests::testOpenFile() {
+ 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::FSNode subDir = gameRoot.getChild("TeStBeD");
-FSTestSuite::FSTestSuite() {
+ if (!subDir.exists()) {
+ printf("LOG:Unable to recognize TeStBeD Inside the game Dir");
+ return false;
+ }
+
+ Common::FSDirectory testBedDir(subDir);
+
+ Common::SeekableReadStream *readStream = testBedDir.createReadStreamForMember("testbed.conf");
+
+ if (!readStream) {
+ printf("LOG:Can't open game file for reading\n");
+ return false;
+ }
+ Common::String msg = readStream->readLine();
+ printf("LOG: Message Extracted: %s\n", msg.c_str());
+
+ Common::String expectedMsg = "It works!";
+
+ if (!msg.equals(expectedMsg)) {
+ printf("LOG: Can't read Correct data from file\n");
+ return false;
+ }
+
+ return true;
+}
+
+
+FSTestSuite::FSTestSuite() {
+ addTest("openingFile", &FStests::testOpenFile);
}
const char *FSTestSuite::getName() const {
return "File System";
diff --git a/engines/testbed/fs.h b/engines/testbed/fs.h
index f602d984e5..f1a3e8a37d 100644
--- a/engines/testbed/fs.h
+++ b/engines/testbed/fs.h
@@ -10,6 +10,7 @@ namespace FStests {
// Helper functions for FS tests
// will contain function declarations for FS tests
+bool testOpenFile();
// add more here
}