1
// Copyright (C) 2008-2011 Colin MacDonald
2
// No rights reserved: this software is in the public domain.
13
/** This tests verifies that textures opened from different places in the filesystem
14
can be distinguished, even if they have the same filename. */
15
bool disambiguateTextures(void)
17
IrrlichtDevice *device =
18
createDevice( video::EDT_NULL, dimension2d<u32>(640, 480));
22
logTestString("Unable to create EDT_NULL device\n");
26
// Expects an empty tmp/tmp directory under this app's wd and
27
// a media directory under this apps' directory with tools.png in it.
28
stringc wd = device->getFileSystem()->getWorkingDirectory();
30
if(-1 == wd.find("/tests") && -1 == wd.find("\\tests"))
32
logTestString("The tests must be run from the /tests directory, regardless of where\n"\
33
"the test executable was built.\n");
38
IVideoDriver * driver = device->getVideoDriver();
40
ITexture * tex1 = driver->getTexture("../media/tools.png");
43
logTestString("Unable to open ../media/tools.png\n");
45
ITexture * tex2 = driver->getTexture("../media/tools.png");
48
logTestString("Unable to open ../media/tools.png\n");
50
IReadFile * readFile = device->getFileSystem()->createAndOpenFile("../media/tools.png");
53
logTestString("Unable to open ../media/tools.png\n");
55
ITexture * tex3 = driver->getTexture(readFile);
58
logTestString("Unable to create texture from ../media/tools.png\n");
62
// All 3 of the above textures should be identical.
66
stringc newWd = wd + "/empty/empty";
67
bool changed = device->getFileSystem()->changeWorkingDirectoryTo(newWd.c_str());
69
ITexture * tex4 = driver->getTexture("../../media/tools.png");
72
logTestString("Unable to open ../../media/tools.png\n");
75
// The working directory must be restored for the other tests to work.
76
changed &= device->getFileSystem()->changeWorkingDirectoryTo(wd.c_str());
78
device->closeDevice();
82
return (changed && tex1 == tex2 && tex1 == tex3 && tex1 != tex4) ? true : false;