~ubuntu-branches/ubuntu/utopic/dogtail/utopic

« back to all changes in this revision

Viewing changes to dogtail/apps/wrappers/yelp.py

  • Committer: Bazaar Package Importer
  • Author(s): Daniel Holbach
  • Date: 2006-12-21 13:33:47 UTC
  • mfrom: (1.2.1 upstream)
  • mto: This revision was merged to the branch mainline in revision 5.
  • Revision ID: james.westby@ubuntu.com-20061221133347-xo9jg11afp5plcka
Tags: upstream-0.6.1
ImportĀ upstreamĀ versionĀ 0.6.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
"""Wrapper code to help when scripting yelp
2
 
 
3
 
Author: David Malcolm <dmalcolm@redhat.com>"""
4
 
 
5
 
__author__ = 'David Malcolm <dmalcolm@redhat.com>'
6
 
 
7
 
from dogtail.tree import *
8
 
from dogtail.distro import packageDb
9
 
from dogtail.apps.categories import *
10
 
from dogtail.version import Version
11
 
 
12
 
class YelpApp(Application):
13
 
        def __init__(self):
14
 
                Application.__init__(self, root.application("gnome-help"))
15
 
 
16
 
                self.version = packageDb.getVersion("yelp")
17
 
                
18
 
                print "yelp version %s"%self.version
19
 
        
20
 
        def checkError(self):
21
 
                """
22
 
                Look for error dialogs, raising an error if one is found.
23
 
                """
24
 
                errorDlg = self.findChild(predicate.GenericPredicate(name="Error", roleName="alert"), requireResult=False)
25
 
                if errorDlg!=None:
26
 
                        msg = ""
27
 
                        for text in errorDlg.findChildren(predicate.GenericPredicate(roleName='label')):
28
 
                                msg += text.text
29
 
                        raise msg
30
 
        
31
 
        def window(self):
32
 
                """
33
 
                Find a window of the app
34
 
                """
35
 
                return self.findChild(predicate.GenericPredicate(roleName="frame"))
36
 
 
37
 
        def ensureLoadingComplete(self):
38
 
                """
39
 
                Wait for yelp to stop having "Loading..." as a title
40
 
                """
41
 
                window = self.window()
42
 
 
43
 
                numWaits = 0
44
 
                
45
 
                # FIXME: i18n issues!
46
 
                while window.name =='Loading...':
47
 
                        sleep(5)
48
 
                        if ++numWaits > 20:
49
 
                                raise "Yelp took too long to open help"
50
 
                
51
 
                                
52
 
def checkAppHelp(app):
53
 
        """
54
 
        Click on Help->Contents and check that help comes up properly.
55
 
        """
56
 
        app.menu('Help').menuItem('Contents').click()
57
 
 
58
 
        yelp = YelpApp()
59
 
        yelp.ensureLoadingComplete()
60
 
        yelp.checkError()