Mercurial > fife-parpg
comparison tests/swig_tests/timer_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 import time | |
4 | |
5 class MyTimeEvent(fife.TimeEvent): | |
6 def __init__(self, period): | |
7 fife.TimeEvent.__init__(self, period) | |
8 self.counter = 0 | |
9 | |
10 def updateEvent(self, curtime): | |
11 print "testing timer event... %d, %d" % (curtime, self.counter) | |
12 self.counter += 1 | |
13 | |
14 class TestTimer(unittest.TestCase): | |
15 def setUp(self): | |
16 self.engine = getEngine(True) | |
17 self.timemanager = self.engine.getTimeManager() | |
18 | |
19 def tearDown(self): | |
20 del self.engine | |
21 | |
22 def testEvents(self): | |
23 e = MyTimeEvent(100) | |
24 self.timemanager.registerEvent(e) | |
25 | |
26 for i in xrange(10): | |
27 time.sleep(0.1) | |
28 self.timemanager.update() | |
29 | |
30 self.timemanager.unregisterEvent(e) | |
31 | |
32 TEST_CLASSES = [TestTimer] | |
33 | |
34 if __name__ == '__main__': | |
35 unittest.main() | |
36 |