aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorNeeraj Kumar2010-06-22 20:49:38 +0000
committerNeeraj Kumar2010-06-22 20:49:38 +0000
commitf444d451169cdcf7e3dd2deef146e5a26e73bd49 (patch)
treed088bb07c2f395282898c1e11ed018213b7c7130 /engines
parent0012b23e8471135c7c5dcff5311db60c0164a881 (diff)
downloadscummvm-rg350-f444d451169cdcf7e3dd2deef146e5a26e73bd49.tar.gz
scummvm-rg350-f444d451169cdcf7e3dd2deef146e5a26e73bd49.tar.bz2
scummvm-rg350-f444d451169cdcf7e3dd2deef146e5a26e73bd49.zip
some more filesystem related tweaks
svn-id: r50167
Diffstat (limited to 'engines')
-rw-r--r--engines/testbed/fs.cpp63
-rw-r--r--engines/testbed/fs.h1
-rw-r--r--engines/testbed/graphics.cpp2
3 files changed, 41 insertions, 25 deletions
diff --git a/engines/testbed/fs.cpp b/engines/testbed/fs.cpp
index 847cb28c21..ff1ae31777 100644
--- a/engines/testbed/fs.cpp
+++ b/engines/testbed/fs.cpp
@@ -1,5 +1,7 @@
#include "common/config-manager.h"
#include "common/stream.h"
+#include "common/savefile.h"
+#include "common/util.h"
#include "testbed/fs.h"
@@ -8,9 +10,7 @@ namespace Testbed {
* This test does the following:
* 1) acquires the game-data path
* 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.
* 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.
*
@@ -29,7 +29,7 @@ bool FStests::readDataFromFile(Common::FSNode &directory, const char *file) {
Common::String msg = readStream->readLine();
delete readStream;
- printf("LOG: Message Extracted from %s : %s\n", file, msg.c_str());
+ printf("LOG: Message Extracted from %s/%s : %s\n",directory.getName().c_str(), file, msg.c_str());
Common::String expectedMsg = "It works!";
@@ -46,40 +46,47 @@ bool FStests::readDataFromFile(Common::FSNode &directory, const char *file) {
bool FStests::testReadFile() {
const Common::String &path = ConfMan.get("path");
Common::FSNode gameRoot(path);
+ int numFailed = 0;
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."};
+ const char *dirList[] = {"test1" ,"Test2", "TEST3" , "tEST4", "test5"};
+ const char *file[] = {"file.txt", "File.txt", "FILE.txt", "fILe.txt", "file"};
- for (unsigned int i = 0; i < dirList.size(); i++) {
+ for (unsigned int i = 0; i < ARRAYSIZE(dirList); i++) {
+ Common::String dirName = dirList[i];
Common::String fileName = file[i];
- if (!readDataFromFile(dirList[i], fileName.c_str())) {
- printf("LOG : reading from %s failed", fileName.c_str());
- return false;
+ Common::FSNode directory = gameRoot.getChild(dirName);
+
+ if (!readDataFromFile(directory, fileName.c_str())) {
+ printf("LOG : reading from %s/%s failed\n", dirName.c_str(), fileName.c_str());
+ numFailed++;
}
+ dirName.toLowercase();
fileName.toLowercase();
+ directory = gameRoot.getChild(dirName);
- if (!readDataFromFile(dirList[i], fileName.c_str())) {
- printf("LOG : reading from %s failed", fileName.c_str());
- return false;
+ if (!readDataFromFile(directory, fileName.c_str())) {
+ printf("LOG : reading from %s/%s failed\n", dirName.c_str(), fileName.c_str());
+ numFailed++;
}
+ dirName.toUppercase();
fileName.toUppercase();
+ directory = gameRoot.getChild(dirName);
- if (!readDataFromFile(dirList[i], fileName.c_str())) {
- printf("LOG : reading from %s failed", fileName.c_str());
- return false;
+ if (!readDataFromFile(directory, fileName.c_str())) {
+ printf("LOG : reading from %s/%s failed\n", dirName.c_str(), fileName.c_str());
+ numFailed++;
}
}
-
- return true;
+
+ printf("LOG:failed %d out of 15\n", numFailed);
+ return false;
}
/**
@@ -122,14 +129,22 @@ bool FStests::testWriteFile() {
* 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.
*/
-/*
-GFXtests::testSavingGame() {
- Common::SaveFileManager saveFileMan = g_system->getSavefileManager();
-}*/
+
+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("openingFile", &FStests::testReadFile);
+ 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/fs.h b/engines/testbed/fs.h
index 6f73babf7a..c7180390dd 100644
--- a/engines/testbed/fs.h
+++ b/engines/testbed/fs.h
@@ -17,6 +17,7 @@ bool readDataFromFile(Common::FSNode &directory, const char *file);
// will contain function declarations for FS tests
bool testReadFile();
bool testWriteFile();
+bool testOpeningSaveFile();
// add more here
}
diff --git a/engines/testbed/graphics.cpp b/engines/testbed/graphics.cpp
index 41d22fc47a..e481b48458 100644
--- a/engines/testbed/graphics.cpp
+++ b/engines/testbed/graphics.cpp
@@ -90,7 +90,7 @@ void GFXtests::drawCursor(bool cursorPaletteDisabled, const char *gfxModeName, i
// Uncommenting the next line and commenting the line after that would reproduce the crash
// CursorMan.replaceCursor(buffer, 11, 11, 0, 0, 255, cursorTargetScale);
- CursorMan.replaceCursor(buffer, 12, 12, 0, 0, 255, cursorTargetScale);
+ CursorMan.replaceCursor(buffer, 12, 13, 0, 0, 255, cursorTargetScale);
CursorMan.showMouse(true);
if (cursorPaletteDisabled) {