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

sud03r at users.sourceforge.net sud03r at users.sourceforge.net
Fri Jun 18 10:45:58 CEST 2010


Revision: 50009
          http://scummvm.svn.sourceforge.net/scummvm/?rev=50009&view=rev
Author:   sud03r
Date:     2010-06-18 08:45:57 +0000 (Fri, 18 Jun 2010)

Log Message:
-----------
added testcase for writing files in the filesystem

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

Modified: scummvm/branches/gsoc2010-testbed/engines/testbed/fs.cpp
===================================================================
--- scummvm/branches/gsoc2010-testbed/engines/testbed/fs.cpp	2010-06-18 06:47:16 UTC (rev 50008)
+++ scummvm/branches/gsoc2010-testbed/engines/testbed/fs.cpp	2010-06-18 08:45:57 UTC (rev 50009)
@@ -15,7 +15,7 @@
  * compares the message contained in it, with what it expects.
  *
  */
-bool FStests::testOpenFile() {
+bool FStests::testReadFile() {
 	const Common::String &path = ConfMan.get("path");
 	Common::FSNode gameRoot(path);
 	
@@ -53,9 +53,45 @@
 	return true;
 }
 
+/**
+ * This test creates a file testbed.out, writes a sample data and confirms if
+ * it is same by reading the file again.
+ */
 
+bool FStests::testWriteFile() {
+	const Common::String &path = ConfMan.get("path");
+	Common::FSNode gameRoot(path);
+
+	Common::FSNode fileToWrite = gameRoot.getChild("testbed.out");
+	if (!fileToWrite.isWritable()) {
+		printf("LOG: Can't open writable file in game data dir\n");
+		return false;
+	}
+	
+	Common::WriteStream *ws = fileToWrite.createWriteStream();
+	if (!ws) {
+		printf("LOG: Can't create a write stream");
+		return false;
+	}
+
+	ws->writeString("ScummVM Rocks!");
+	ws->flush();
+
+	Common::SeekableReadStream *rs = fileToWrite.createReadStream();
+	Common::String readFromFile = rs->readLine();
+
+	if (readFromFile.equals("ScummVM Rocks!")) {
+		// All good
+		printf("LOG: Data written and read correctly\n");
+		return true;
+	}
+	
+	return false;
+}
+
 FSTestSuite::FSTestSuite() {
-	addTest("openingFile", &FStests::testOpenFile);	
+	addTest("openingFile", &FStests::testReadFile);	
+	addTest("WritingFile", &FStests::testWriteFile);	
 }
 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-18 06:47:16 UTC (rev 50008)
+++ scummvm/branches/gsoc2010-testbed/engines/testbed/fs.h	2010-06-18 08:45:57 UTC (rev 50009)
@@ -7,10 +7,15 @@
 
 namespace FStests {
 
+// Note: These tests require a game-data directory
+// So would work if game-path is set in the launcher or invoked as ./scummvm --path="path-to-testbed-data" testbed 
+// from commandline
+
 // Helper functions for FS tests
 
 // will contain function declarations for FS tests
-bool testOpenFile();
+bool testReadFile();
+bool testWriteFile();
 // 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