summaryrefslogtreecommitdiff
path: root/tests/test_interface.py
blob: d95979170bf9fd759291d9561ed0d1d8d7e14c7e (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
import unittest

from common import gobject, testhelper

GUnknown = gobject.type_from_name("TestUnknown")
Unknown = GUnknown.pytype


class MyUnknown(Unknown, testhelper.Interface):
    some_property = gobject.property(type=str)

    def __init__(self):
        Unknown.__init__(self)
        self.called = False

    def do_iface_method(self):
        self.called = True
        Unknown.do_iface_method(self)
gobject.type_register(MyUnknown)


class MyObject(gobject.GObject, testhelper.Interface):
    some_property = gobject.property(type=str)

    def __init__(self):
        gobject.GObject.__init__(self)
        self.called = False

    def do_iface_method(self):
        self.called = True
gobject.type_register(MyObject)


class TestIfaceImpl(unittest.TestCase):

    def testReImplementInterface(self):
        m = MyUnknown()
        m.iface_method()
        self.assertEqual(m.called, True)

    def testImplementInterface(self):
        m = MyObject()
        m.iface_method()
        self.assertEqual(m.called, True)