[Scummvm-cvs-logs] SF.net SVN: scummvm:[49948] scummvm/branches/gsoc2010-testbed/engines/ testbed

sud03r at users.sourceforge.net sud03r at users.sourceforge.net
Thu Jun 17 22:24:02 CEST 2010


Revision: 49948
          http://scummvm.svn.sourceforge.net/scummvm/?rev=49948&view=rev
Author:   sud03r
Date:     2010-06-17 20:24:01 +0000 (Thu, 17 Jun 2010)

Log Message:
-----------
added a FS test to open and read a file from the game-data dir

Modified Paths:
--------------
    scummvm/branches/gsoc2010-testbed/engines/testbed/detection.cpp
    scummvm/branches/gsoc2010-testbed/engines/testbed/fs.cpp
    scummvm/branches/gsoc2010-testbed/engines/testbed/fs.h

Modified: scummvm/branches/gsoc2010-testbed/engines/testbed/detection.cpp
===================================================================
--- scummvm/branches/gsoc2010-testbed/engines/testbed/detection.cpp	2010-06-17 19:42:34 UTC (rev 49947)
+++ scummvm/branches/gsoc2010-testbed/engines/testbed/detection.cpp	2010-06-17 20:24:01 UTC (rev 49948)
@@ -50,7 +50,7 @@
 			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;

Modified: scummvm/branches/gsoc2010-testbed/engines/testbed/fs.cpp
===================================================================
--- scummvm/branches/gsoc2010-testbed/engines/testbed/fs.cpp	2010-06-17 19:42:34 UTC (rev 49947)
+++ scummvm/branches/gsoc2010-testbed/engines/testbed/fs.cpp	2010-06-17 20:24:01 UTC (rev 49948)
@@ -1,10 +1,62 @@
+#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";
 }

Modified: scummvm/branches/gsoc2010-testbed/engines/testbed/fs.h
===================================================================
--- scummvm/branches/gsoc2010-testbed/engines/testbed/fs.h	2010-06-17 19:42:34 UTC (rev 49947)
+++ scummvm/branches/gsoc2010-testbed/engines/testbed/fs.h	2010-06-17 20:24:01 UTC (rev 49948)
@@ -10,6 +10,7 @@
 // Helper functions for FS tests
 
 // will contain function declarations for FS tests
+bool testOpenFile();
 // add more here
 }
 


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list