annotate tests/swig_tests/video_tests.py @ 697:ecaa4d98f05f tip

Abstracted the GUI code and refactored the GUIChan-specific code into its own module. * Most of the GUIChan code has been refactored into its own gui/guichan module. However, references to the GuiFont class still persist in the Engine and GuiManager code and these will need further refactoring. * GuiManager is now an abstract base class which specific implementations (e.g. GUIChan) should subclass. * The GUIChan GUI code is now a concrete implementation of GuiManager, most of which is in the new GuiChanGuiManager class. * The GUI code in the Console class has been refactored out of the Console and into the GUIChan module as its own GuiChanConsoleWidget class. The rest of the Console class related to executing commands was left largely unchanged. * Existing client code may need to downcast the GuiManager pointer received from FIFE::Engine::getGuiManager() to GuiChanGuiManager, since not all functionality is represented in the GuiManager abstract base class. Python client code can use the new GuiChanGuiManager.castTo static method for this purpose.
author M. George Hansen <technopolitica@gmail.com>
date Sat, 18 Jun 2011 00:28:40 -1000
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 from swig_test_utils import *
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
26 from serializers.xmlanimation import XMLAnimationLoader
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
27
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
28 class TestVideo(unittest.TestCase):
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 def setUp(self):
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
31 self.engine = getEngine()
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
32
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
33 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
34 self.engine.destroy()
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
35
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
36 def testSimpleAnimation(self):
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
37 pool = self.engine.getAnimationPool()
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
38 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
39 pool.addResourceLoader(animationloader)
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
40
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
41 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
42 animation = pool.getAnimation(id)
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
43 self.engine.initializePumping()
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
44 backend = self.engine.getRenderBackend()
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
45 gettime = self.engine.getTimeManager().getTime
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
46 starttime = gettime()
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
47 for i in xrange(50):
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
48 image = animation.getFrameByTimestamp(gettime() - starttime)
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
49 if not image:
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
50 image = animation.getFrame(0)
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
51 starttime = gettime()
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
52 #print fife.Rect(0,0,image.getWidth(),image.getHeight())
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
53 image.render(fife.Rect(0,0,image.getWidth(),image.getHeight()), 255)
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
54 self.engine.pump()
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
55 self.engine.finalizePumping()
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
56
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
57
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
58 def testDrawLine(self):
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
59 points = (
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
60 (1,1), (50,20), (20,50), (200,500), (500,200), (100,200),
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
61 (10,10), (70,40), (80,30), (300,520), (340,220), (170,600),
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
62 )
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
63 self.engine.initializePumping()
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
64
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
65 be = self.engine.getRenderBackend()
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
66 for i in xrange(20):
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
67 prevPt = fife.Point(*points[1])
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
68 for pt in points[1:]:
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
69 curPt = fife.Point(*pt)
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
70 be.drawLine(prevPt, curPt, 100, 100, 100)
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
71 prevPt = curPt
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
72 self.engine.pump()
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
73 self.engine.finalizePumping()
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
74
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 = [TestVideo]
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()
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
80