Debian Codegraph @

tests/dbusmenu-gtk/mago_tests/dbusmenu.py

raw
1 from mago.test_suite.main import SingleApplicationTestSuite
2 from mago.application.main import Application
3
4 import ldtp, ooldtp, ldtputils, os.path
5
6 class DbusMenuGtkApp():
7 LAUNCHER = os.path.join(os.path.dirname(__file__), "..", "dbusMenuTest")
8 WINDOW = "frmlibdbusmenu-gtktest"
9
10 def open(self, menu_schema=''):
11 ldtp.launchapp(self.LAUNCHER, [menu_schema])
12
13 def menu_exists(self, menu=''):
14 app = ooldtp.context(self.WINDOW)
15
16 if menu == '':
17 menu = "mnu1"
18
19 try:
20 component = app.getchild(menu)
21 except ldtp.LdtpExecutionError:
22 return False
23
24 return True
25
26 def get_submenus(self, menu=''):
27 app = ooldtp.context(self.WINDOW)
28
29 if menu == '':
30 menu = "mnu1"
31
32 component = app.getchild(menu)
33
34 try:
35 submenus = component.listsubmenus()
36 except ldtp.LdtpExecutionError:
37 return ""
38
39 return submenus
40
41 class DbusMenuGtkTest(SingleApplicationTestSuite):
42 APPLICATION_FACTORY = DbusMenuGtkApp
43
44 def cleanup(self):
45 ldtp.waittillguinotexist(self.application.WINDOW, guiTimeOut=70)
46
47 def teardown(self):
48 ldtp.waittillguinotexist(self.application.WINDOW, guiTimeOut=70)
49
50 def testStaticMenu(self, menu_schema, menu_item='', notexists=''):
51 self.application.open(menu_schema)
52 ldtp.waittillguiexist(self.application.WINDOW)
53
54 if notexists == "True":
55 if self.application.menu_exists(menu_item):
56 raise AssertionError("The menu item exists")
57 else:
58 if not self.application.menu_exists(menu_item):
59 raise AssertionError("The menu item does not exists")
60
61
62 def testSubmenus(self, menu_schema, menu_item='', submenus=''):
63 self.application.open(menu_schema)
64 ldtp.waittillguiexist(self.application.WINDOW)
65
66 if submenus != self.application.get_submenus(menu_item):
67 raise AssertionError("The submenus are different")
68
69
70
71