Mercurial > fife-parpg
comparison tests/swig_tests/video_tests.py @ 0:4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
author | mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222 |
---|---|
date | Sun, 29 Jun 2008 18:44:17 +0000 |
parents | |
children | d2f1e81fbe2c |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:4a0efb7baf70 |
---|---|
1 #!/usr/bin/env python | |
2 from swig_test_utils import * | |
3 from serializers.xmlanimation import XMLAnimationLoader | |
4 | |
5 class TestVideo(unittest.TestCase): | |
6 | |
7 def setUp(self): | |
8 self.engine = getEngine() | |
9 | |
10 def tearDown(self): | |
11 del self.engine | |
12 | |
13 def testSimpleAnimation(self): | |
14 pool = self.engine.getAnimationPool() | |
15 animationloader = XMLAnimationLoader(self.engine.getImagePool(), self.engine.getVFS()) | |
16 pool.addResourceLoader(animationloader) | |
17 | |
18 id = pool.addResourceFromFile('tests/data/wolf_walk/wolf_walk_sw.xml') | |
19 animation = pool.getAnimation(id) | |
20 self.engine.initializePumping() | |
21 backend = self.engine.getRenderBackend() | |
22 gettime = self.engine.getTimeManager().getTime | |
23 starttime = gettime() | |
24 for i in xrange(50): | |
25 image = animation.getFrameByTimestamp(gettime() - starttime) | |
26 if not image: | |
27 image = animation.getFrame(0) | |
28 starttime = gettime() | |
29 #print fife.Rect(0,0,image.getWidth(),image.getHeight()) | |
30 image.render(fife.Rect(0,0,image.getWidth(),image.getHeight()), 255) | |
31 self.engine.pump() | |
32 self.engine.finalizePumping() | |
33 | |
34 | |
35 def testDrawLine(self): | |
36 points = ( | |
37 (1,1), (50,20), (20,50), (200,500), (500,200), (100,200), | |
38 (10,10), (70,40), (80,30), (300,520), (340,220), (170,600), | |
39 ) | |
40 self.engine.initializePumping() | |
41 | |
42 be = self.engine.getRenderBackend() | |
43 for i in xrange(20): | |
44 prevPt = fife.Point(*points[1]) | |
45 for pt in points[1:]: | |
46 curPt = fife.Point(*pt) | |
47 be.drawLine(prevPt, curPt, 100, 100, 100) | |
48 prevPt = curPt | |
49 self.engine.pump() | |
50 self.engine.finalizePumping() | |
51 | |
52 | |
53 TEST_CLASSES = [TestVideo] | |
54 | |
55 if __name__ == '__main__': | |
56 unittest.main() | |
57 |