aboutsummaryrefslogtreecommitdiff
path: root/tests/dbusmenu-gtk/dbusmenu.py.in
blob: ce159e1c69db2d1d0a33d7f4c300ef963f715828 (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
68
69
70
71
from mago.test_suite.main import SingleApplicationTestSuite 
from mago.application.main import Application 

import ldtp, ooldtp, ldtputils

class DbusMenuGtkApp():
    LAUNCHER = "@srcdir@/dbusMenuTest"
    WINDOW   = "frmlibdbusmenu-gtktest"

    def open(self, menu_schema=''):
        ldtp.launchapp(self.LAUNCHER, [menu_schema])

    def menu_exists(self, menu=''):
        app = ooldtp.context(self.WINDOW)

        if menu == '':
            menu = "mnu1"

        try:
            component = app.getchild(menu)
        except ldtp.LdtpExecutionError:
            return False

        return True
    
    def get_submenus(self, menu=''):
        app = ooldtp.context(self.WINDOW)

        if menu == '':
            menu = "mnu1"

        component = app.getchild(menu)

        try:
            submenus = component.listsubmenus()
        except ldtp.LdtpExecutionError:
            return "" 
        
        return submenus

class DbusMenuGtkTest(SingleApplicationTestSuite):
    APPLICATION_FACTORY = DbusMenuGtkApp

    def cleanup(self):
        ldtp.waittillguinotexist(self.application.WINDOW, guiTimeOut=70)

    def teardown(self):
        ldtp.waittillguinotexist(self.application.WINDOW, guiTimeOut=70)

    def testStaticMenu(self, menu_schema, menu_item='', notexists=''):
        self.application.open(menu_schema)
        ldtp.waittillguiexist(self.application.WINDOW)

        if notexists == "True":
            if self.application.menu_exists(menu_item):
                raise AssertionError("The menu item exists")
        else:
            if not self.application.menu_exists(menu_item):
                raise AssertionError("The menu item does not exists")


    def testSubmenus(self, menu_schema, menu_item='', submenus=''):
        self.application.open(menu_schema)
        ldtp.waittillguiexist(self.application.WINDOW)

        if submenus != self.application.get_submenus(menu_item):
            raise AssertionError("The submenus are different")