blob: 89f2a52f7b728a25798931c742b97e75d86fa12a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
#include "common/savefile.h"
#include "testbed/savegame.h"
namespace Testbed {
/**
* 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.
*/
bool SaveGametests::testSaveLoadState() {
Common::SaveFileManager *saveFileMan = g_system->getSavefileManager();
Common::OutSaveFile *saveFile = saveFileMan->openForSaving("saveFile.0");
if (!saveFile) {
printf("LOG: Can't open saveFile\n");
return false;
}
saveFile->writeString("ScummVM Rocks!");
saveFile->finalize();
delete saveFile;
Common::InSaveFile *loadFile = saveFileMan->openForLoading("saveFile.0");
if (!loadFile) {
printf("LOG: Can't open save File to load\n");
return false;
}
Common::String lineToRead = loadFile->readLine();
delete loadFile;
if (lineToRead.equals("ScummVM Rocks!")) {
return true;
}
return false;
}
SaveGameTestSuite::SaveGameTestSuite() {
addTest("Opening SaveFile", &SaveGametests::testSaveLoadState);
}
const char *SaveGameTestSuite::getName() const {
return "SaveGames";
}
} // End of namespace testbed
|