blob: dd01af81e5178a8d2056c5f95382506b57665381 (
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
|
# -*- Mode: Python -*-
import unittest
from gi.repository import GObject
import 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 test_reimplement_interface(self):
m = MyUnknown()
m.iface_method()
self.assertEqual(m.called, True)
def test_implement_interface(self):
m = MyObject()
m.iface_method()
self.assertEqual(m.called, True)
|