summaryrefslogtreecommitdiff
path: root/tests/ecore/test_02_animator.py
blob: e699ed74dd802c89f57601647d5c55ac9630656d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#!/usr/bin/env python

import unittest
import logging

from efl import ecore


class TestAnimator(unittest.TestCase):

    def cb_renew(self, n, t, a):
        self.assertEqual(n, 123)
        self.assertEqual(t, "teste")
        self.assertEqual(a, 456)
        return ecore.ECORE_CALLBACK_RENEW

    def cb_cancel(self, n, t, a):
        self.assertEqual(n, 789)
        self.assertEqual(t, "bla")
        self.assertEqual(a, "something in a")
        return ecore.ECORE_CALLBACK_CANCEL

    def testInit(self):
        ecore.animator_frametime_set(1.0/24.0)
        self.assertEqual(ecore.animator_frametime_get(), 1.0/24.0)

        a1 = ecore.animator_add(self.cb_renew, 123, "teste", a=456)
        a2 = ecore.Animator(self.cb_cancel, 789, "bla", a="something in a")
        a3 = ecore.animator_add(ecore.main_loop_quit)

        self.assertIsInstance(a1, ecore.Animator)
        self.assertIsInstance(a2, ecore.Animator)
        self.assertIsInstance(a3, ecore.Animator)

        before1 = a1.__repr__()
        before2 = a2.__repr__()
        before3 = a3.__repr__()

        ecore.main_loop_begin()

        after1 = a1.__repr__()
        after2 = a2.__repr__()
        after3 = a3.__repr__()

        self.assertEqual(before1, after1)
        self.assertNotEqual(before2, after2) # already deleted
        self.assertNotEqual(before3, after3) # already deleted

        self.assertEqual(a1.is_deleted(), False)
        self.assertEqual(a2.is_deleted(), True)
        self.assertEqual(a3.is_deleted(), True)

        a1.delete()
        self.assertEqual(a1.is_deleted(), True)
        del a1
        del a2 # already deleted since returned false
        del a3 # already deleted since returned false


if __name__ == '__main__':
    formatter = logging.Formatter("[%(levelname)s] %(name)s (%(filename)s: %(lineno)d) --- %(message)s")
    handler = logging.StreamHandler()
    handler.setFormatter(formatter)
    efllog = logging.getLogger("efl")
    efllog.addHandler(handler)
    efllog.setLevel(logging.DEBUG)
    unittest.main(verbosity=2)