Mercurial > fife-parpg
annotate tests/swig_tests/resource_tests.py @ 570:0e0a30f0eb20
Finally found the bug when you create a new map and are unable to place instances on the map until you save and re-load the map.
author | prock@33b003aa-7bff-0310-803a-e67f0ece8222 |
---|---|
date | Mon, 28 Jun 2010 21:28:44 +0000 |
parents | 81641655bc38 |
children |
rev | line source |
---|---|
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
1 #!/usr/bin/env python |
396
81641655bc38
Adding the correct header in a lot of files. Also made a small change to the CHANGES file by adding the 0.3.1 section.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
144
diff
changeset
|
2 # -*- coding: utf-8 -*- |
81641655bc38
Adding the correct header in a lot of files. Also made a small change to the CHANGES file by adding the 0.3.1 section.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
144
diff
changeset
|
3 |
81641655bc38
Adding the correct header in a lot of files. Also made a small change to the CHANGES file by adding the 0.3.1 section.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
144
diff
changeset
|
4 # #################################################################### |
81641655bc38
Adding the correct header in a lot of files. Also made a small change to the CHANGES file by adding the 0.3.1 section.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
144
diff
changeset
|
5 # Copyright (C) 2005-2009 by the FIFE team |
81641655bc38
Adding the correct header in a lot of files. Also made a small change to the CHANGES file by adding the 0.3.1 section.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
144
diff
changeset
|
6 # http://www.fifengine.de |
81641655bc38
Adding the correct header in a lot of files. Also made a small change to the CHANGES file by adding the 0.3.1 section.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
144
diff
changeset
|
7 # This file is part of FIFE. |
81641655bc38
Adding the correct header in a lot of files. Also made a small change to the CHANGES file by adding the 0.3.1 section.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
144
diff
changeset
|
8 # |
81641655bc38
Adding the correct header in a lot of files. Also made a small change to the CHANGES file by adding the 0.3.1 section.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
144
diff
changeset
|
9 # FIFE is free software; you can redistribute it and/or |
81641655bc38
Adding the correct header in a lot of files. Also made a small change to the CHANGES file by adding the 0.3.1 section.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
144
diff
changeset
|
10 # modify it under the terms of the GNU Lesser General Public |
81641655bc38
Adding the correct header in a lot of files. Also made a small change to the CHANGES file by adding the 0.3.1 section.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
144
diff
changeset
|
11 # License as published by the Free Software Foundation; either |
81641655bc38
Adding the correct header in a lot of files. Also made a small change to the CHANGES file by adding the 0.3.1 section.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
144
diff
changeset
|
12 # version 2.1 of the License, or (at your option) any later version. |
81641655bc38
Adding the correct header in a lot of files. Also made a small change to the CHANGES file by adding the 0.3.1 section.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
144
diff
changeset
|
13 # |
81641655bc38
Adding the correct header in a lot of files. Also made a small change to the CHANGES file by adding the 0.3.1 section.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
144
diff
changeset
|
14 # This library is distributed in the hope that it will be useful, |
81641655bc38
Adding the correct header in a lot of files. Also made a small change to the CHANGES file by adding the 0.3.1 section.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
144
diff
changeset
|
15 # but WITHOUT ANY WARRANTY; without even the implied warranty of |
81641655bc38
Adding the correct header in a lot of files. Also made a small change to the CHANGES file by adding the 0.3.1 section.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
144
diff
changeset
|
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
81641655bc38
Adding the correct header in a lot of files. Also made a small change to the CHANGES file by adding the 0.3.1 section.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
144
diff
changeset
|
17 # Lesser General Public License for more details. |
81641655bc38
Adding the correct header in a lot of files. Also made a small change to the CHANGES file by adding the 0.3.1 section.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
144
diff
changeset
|
18 # |
81641655bc38
Adding the correct header in a lot of files. Also made a small change to the CHANGES file by adding the 0.3.1 section.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
144
diff
changeset
|
19 # You should have received a copy of the GNU Lesser General Public |
81641655bc38
Adding the correct header in a lot of files. Also made a small change to the CHANGES file by adding the 0.3.1 section.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
144
diff
changeset
|
20 # License along with this library; if not, write to the |
81641655bc38
Adding the correct header in a lot of files. Also made a small change to the CHANGES file by adding the 0.3.1 section.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
144
diff
changeset
|
21 # Free Software Foundation, Inc., |
81641655bc38
Adding the correct header in a lot of files. Also made a small change to the CHANGES file by adding the 0.3.1 section.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
144
diff
changeset
|
22 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
81641655bc38
Adding the correct header in a lot of files. Also made a small change to the CHANGES file by adding the 0.3.1 section.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
144
diff
changeset
|
23 # #################################################################### |
81641655bc38
Adding the correct header in a lot of files. Also made a small change to the CHANGES file by adding the 0.3.1 section.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
144
diff
changeset
|
24 |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
25 import sys |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
26 from swig_test_utils import * |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
27 from serializers import * |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
28 from serializers.xmlanimation import XMLAnimationLoader |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
29 |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
30 class TestPool(unittest.TestCase): |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
31 |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
32 def setUp(self): |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
33 self.engine = getEngine() |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
34 |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
35 def tearDown(self): |
144
d2f1e81fbe2c
* Fixed a scons issue, where libraries checked for C instead of C++
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
0
diff
changeset
|
36 self.engine.destroy() |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
37 |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
38 def testImagePool(self): |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
39 pool = self.engine.getImagePool() |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
40 self.assert_(pool) |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
41 self.assert_(pool.getResourceCount(fife.RES_LOADED) == 0) |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
42 id = pool.addResourceFromFile('tests/data/beach_e1.png') |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
43 self.assertEqual(pool.getResourceCount(fife.RES_LOADED), 0) |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
44 self.assertEqual(pool.getResourceCount(fife.RES_NON_LOADED), 1) |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
45 img = pool.getImage(id) |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
46 self.assertEqual(pool.getResourceCount(fife.RES_LOADED), 1) |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
47 self.assertEqual(pool.getResourceCount(fife.RES_NON_LOADED), 0) |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
48 |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
49 def testImagePoolFail(self): |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
50 pool = self.engine.getImagePool() |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
51 id = pool.addResourceFromFile('bogus_image.png') |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
52 self.assertRaises(RuntimeError,pool.getImage,id) |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
53 |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
54 def testAnimationPool(self): |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
55 pool = self.engine.getAnimationPool() |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
56 animationloader = XMLAnimationLoader(self.engine.getImagePool(), self.engine.getVFS()) |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
57 pool.addResourceLoader(animationloader) |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
58 |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
59 self.assert_(pool) |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
60 self.assert_(pool.getResourceCount(fife.RES_LOADED) == 0) |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
61 id = pool.addResourceFromFile('tests/data/wolf_walk/wolf_walk_sw.xml') |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
62 self.assertEqual(pool.getResourceCount(fife.RES_LOADED), 0) |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
63 self.assertEqual(pool.getResourceCount(fife.RES_NON_LOADED), 1) |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
64 animation = pool.getAnimation(id) |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
65 self.assertEqual(pool.getResourceCount(fife.RES_LOADED), 1) |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
66 self.assertEqual(pool.getResourceCount(fife.RES_NON_LOADED), 0) |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
67 |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
68 def testAnimationPoolFail(self): |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
69 pool = self.engine.getAnimationPool() |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
70 animationloader = XMLAnimationLoader(self.engine.getImagePool(), self.engine.getVFS()) |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
71 pool.addResourceLoader(animationloader) |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
72 |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
73 id = pool.addResourceFromFile('bogus_animation.xml') |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
74 #self.assertRaises(RuntimeError, pool.getAnimation, id) #<- this test still passes, but crashes python on exit |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
75 |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
76 TEST_CLASSES = [TestPool] |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
77 |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
78 if __name__ == '__main__': |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
79 unittest.main() |