~baltix/+junk/irrlicht-test

« back to all changes in this revision

Viewing changes to tests/loadTextures.cpp

  • Committer: Mantas Kriaučiūnas
  • Date: 2011-07-18 13:06:25 UTC
  • Revision ID: mantas@akl.lt-20110718130625-c5pvifp61e7kj1ol
Included whole irrlicht SVN libraries to work around launchpad recipe issue with quilt, see https://answers.launchpad.net/launchpad/+question/165193

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// Copyright (C) 2008-2011 Colin MacDonald
 
2
// No rights reserved: this software is in the public domain.
 
3
 
 
4
#include "testUtils.h"
 
5
 
 
6
using namespace irr;
 
7
using namespace core;
 
8
using namespace scene;
 
9
using namespace video;
 
10
using namespace io;
 
11
using namespace gui;
 
12
 
 
13
/** This tests verifies that textures opened from different places in the
 
14
        filesystem don't create duplicated textures. */
 
15
bool loadFromFileFolder(void)
 
16
{
 
17
        IrrlichtDevice *device =
 
18
                createDevice( video::EDT_NULL, dimension2du(160, 120));
 
19
 
 
20
        if (!device)
 
21
        {
 
22
                logTestString("Unable to create EDT_NULL device\n");
 
23
                return false;
 
24
        }
 
25
 
 
26
        IVideoDriver * driver = device->getVideoDriver();
 
27
 
 
28
        u32 numTexs = driver->getTextureCount();
 
29
 
 
30
        ITexture * tex1 = driver->getTexture("../media/tools.png");
 
31
        assert(tex1);
 
32
        if(!tex1)
 
33
                logTestString("Unable to open ../media/tools.png\n");
 
34
        if (driver->getTextureCount()!=numTexs+1)
 
35
        {
 
36
                logTestString("No additional texture in the texture cache %s:%d\n", __FILE__, __LINE__);
 
37
                return false;
 
38
        }
 
39
 
 
40
        IReadFile * readFile = device->getFileSystem()->createAndOpenFile("../media/tools.png");
 
41
        assert(readFile);
 
42
        if(!readFile)
 
43
                logTestString("Unable to open ../media/tools.png\n");
 
44
        if (driver->getTextureCount()!=numTexs+1)
 
45
        {
 
46
                logTestString("Additional texture in the texture cache %s:%d\n", __FILE__, __LINE__);
 
47
                return false;
 
48
        }
 
49
 
 
50
        ITexture * tex2 = driver->getTexture(readFile);
 
51
        assert(tex2);
 
52
        if(!readFile)
 
53
                logTestString("Unable to create texture from ../media/tools.png\n");
 
54
        if (driver->getTextureCount()!=numTexs+1)
 
55
        {
 
56
                logTestString("Additional texture in the texture cache %s:%d\n", __FILE__, __LINE__);
 
57
                return false;
 
58
        }
 
59
 
 
60
        readFile->drop();
 
61
 
 
62
        // adding  a folder archive
 
63
        device->getFileSystem()->addFileArchive( "../media/" );
 
64
 
 
65
        ITexture * tex3 = driver->getTexture("tools.png");
 
66
        assert(tex3);
 
67
        if(!tex3)
 
68
                logTestString("Unable to open tools.png\n");
 
69
        if (driver->getTextureCount()!=numTexs+1)
 
70
        {
 
71
                logTestString("Additional texture in the texture cache %s:%d\n", __FILE__, __LINE__);
 
72
                return false;
 
73
        }
 
74
 
 
75
        ITexture * tex4 = driver->getTexture("tools.png");
 
76
        assert(tex4);
 
77
        if(!tex4)
 
78
                logTestString("Unable to open tools.png\n");
 
79
        if (driver->getTextureCount()!=numTexs+1)
 
80
        {
 
81
                logTestString("Additional texture in the texture cache %s:%d\n", __FILE__, __LINE__);
 
82
                return false;
 
83
        }
 
84
 
 
85
        device->closeDevice();
 
86
        device->run();
 
87
        device->drop();
 
88
        return ((tex1 == tex2) && (tex1 == tex3) && (tex1 == tex4));
 
89
}
 
90
 
 
91
bool loadTextures()
 
92
{
 
93
        bool result = true;
 
94
        result &= loadFromFileFolder();
 
95
        return result;
 
96
}
 
97