Fix some tests, add new test for loading textures from FileFolders.

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@3041 dfc29bdd-3216-0410-991c-e03cc46cb475
master
hybrid 2009-12-12 01:01:32 +00:00
parent 27b5b6633c
commit 3553813721
4 changed files with 106 additions and 2 deletions

95
tests/loadTextures.cpp Normal file
View File

@ -0,0 +1,95 @@
// Copyright (C) 2008-2009 Colin MacDonald
// No rights reserved: this software is in the public domain.
#include "testUtils.h"
using namespace irr;
using namespace core;
using namespace scene;
using namespace video;
using namespace io;
using namespace gui;
/** This tests verifies that textures opened from different places in the
filesystem don't create duplicated textures. */
bool loadFromFileFolder(void)
{
IrrlichtDevice *device =
createDevice( video::EDT_NULL, dimension2du(160, 120));
if (!device)
{
logTestString("Unable to create EDT_NULL device\n");
return false;
}
IVideoDriver * driver = device->getVideoDriver();
u32 numTexs = driver->getTextureCount();
ITexture * tex1 = driver->getTexture("../media/tools.png");
assert(tex1);
if(!tex1)
logTestString("Unable to open ../media/tools.png\n");
if (!driver->getTextureCount()==numTexs+1)
{
logTestString("No additional texture in the texture cache");
return false;
}
IReadFile * readFile = device->getFileSystem()->createAndOpenFile("../media/tools.png");
assert(readFile);
if(!readFile)
logTestString("Unable to open ../media/tools.png\n");
if (!driver->getTextureCount()==numTexs+1)
{
logTestString("Additional texture in the texture cache");
return false;
}
ITexture * tex2 = driver->getTexture(readFile);
assert(tex2);
if(!readFile)
logTestString("Unable to create texture from ../media/tools.png\n");
if (!driver->getTextureCount()==numTexs+1)
{
logTestString("Additional texture in the texture cache");
return false;
}
readFile->drop();
// adding a folder archive
device->getFileSystem()->addFolderFileArchive( "../media/" );
ITexture * tex3 = driver->getTexture("tools.png");
assert(tex3);
if(!tex3)
logTestString("Unable to open tools.png\n");
if (!driver->getTextureCount()==numTexs+1)
{
logTestString("Additional texture in the texture cache");
return false;
}
ITexture * tex4 = driver->getTexture("tools.png");
assert(tex4);
if(!tex4)
logTestString("Unable to open tools.png\n");
if (!driver->getTextureCount()==numTexs+1)
{
logTestString("Additional texture in the texture cache");
return false;
}
device->drop();
return (tex1 == tex2 && tex1 == tex3 && tex1 == tex4);
}
bool loadTextures()
{
bool result = true;
result |= loadFromFileFolder();
return result;
}

View File

@ -71,6 +71,7 @@ int main(int argumentCount, char * arguments[])
TEST(serializeAttributes);
// null driver
TEST(fast_atof);
TEST(loadTextures);
TEST(collisionResponseAnimator);
TEST(enumerateImageManipulators);
TEST(removeCustomAnimator);

View File

@ -1,2 +1,2 @@
Test suite pass at GMT Wed Dec 9 01:28:55 2009
Test suite pass at GMT Sat Dec 12 00:51:43 2009

View File

@ -242,6 +242,10 @@
RelativePath=".\line2dIntersectWith.cpp"
>
</File>
<File
RelativePath=".\loadTextures.cpp"
>
</File>
<File
RelativePath=".\main.cpp"
>
@ -282,6 +286,10 @@
RelativePath=".\sceneNodeAnimator.cpp"
>
</File>
<File
RelativePath=".\serializeAttributes.cpp"
>
</File>
<File
RelativePath=".\softwareDevice.cpp"
>