~ubuntu-branches/ubuntu/natty/mago/natty

« back to all changes in this revision

Viewing changes to mago/application/yelp.py

  • Committer: Bazaar Package Importer
  • Author(s): Ara Pulido
  • Date: 2010-12-03 16:08:32 UTC
  • Revision ID: james.westby@ubuntu.com-20101203160832-97pz2nxwmo54iwfk
Tags: 0.3-0ubuntu3
* Updated from trunk
 + Added new applications to our tests base
 + Fixes LP: #682845 

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
PACKAGE = "mago"
 
2
 
 
3
#-*- coding:utf-8 -*-
 
4
"""
 
5
This is the "yelp" module.
 
6
 
 
7
This module provides a wrapper for LDTP to make writing Yelp tests easier.
 
8
"""
 
9
import ooldtp
 
10
import ldtp
 
11
import os
 
12
from .main import Application
 
13
from ..gconfwrapper import GConf
 
14
from ..cmd import globals
 
15
import time
 
16
import gettext
 
17
 
 
18
gettext.install (True)
 
19
gettext.bindtextdomain (PACKAGE, globals.LOCALE_SHARE)
 
20
gettext.textdomain (PACKAGE)
 
21
t = gettext.translation(PACKAGE, globals.LOCALE_SHARE, fallback = True)
 
22
_ = t.gettext
 
23
 
 
24
 
 
25
class Yelp(Application):
 
26
    """
 
27
    yelp manages the Yelp application.
 
28
    """
 
29
 
 
30
    LAUNCHER = 'yelp'
 
31
    LAUNCHER_ARGS = []
 
32
    WINDOW = 'frmUbuntuHelpCenter'
 
33
 
 
34
    BTN_BACK = _('btnBack')
 
35
    BTN_CLOSE = _('btnClose')
 
36
    BTN_FORWARD = _('btnForward')
 
37
    BTN_HELPTOPICS = _('btnHelpTopics')
 
38
    MNU_ABOUT = _('mnuAbout')
 
39
    MNU_ABOUTTHISDOCUMENT = _('mnuAboutThisDocument')
 
40
    MNU_ADDBOOKMARK = _('mnuAddBookmark')
 
41
    MNU_BACK = _('mnuBack')
 
42
    MNU_CLOSEWINDOW = _('mnuCloseWindow')
 
43
    MNU_CONTENTS = _('mnuContents')
 
44
    MNU_CONTENTS1 = _('mnuContents1')
 
45
    MNU_COPY = _('mnuCopy')
 
46
    MNU_EDITBOOKMARKS = _('mnuEditBookmarks')
 
47
    MNU_EMPTY = _('mnuEmpty')
 
48
    MNU_EMPTY1 = _('mnuEmpty1')
 
49
    MNU_EMPTY2 = _('mnuEmpty2')
 
50
    MNU_EMPTY3 = _('mnuEmpty3')
 
51
    MNU_EMPTY4 = _('mnuEmpty4')
 
52
    MNU_FIND = _('mnuFind')
 
53
    MNU_FINDNEXT = _('mnuFindNext')
 
54
    MNU_FINDPREVIOUS = _('mnuFindPrevious')
 
55
    MNU_FORWARD = _('mnuForward')
 
56
    MNU_GETHELPONLINE = _('mnuGetHelpOnline')
 
57
    MNU_HELPTOPICS = _('mnuHelpTopics')
 
58
    MNU_NEWWINDOW = _('mnuNewWindow')
 
59
    MNU_NEXTSECTION = _('mnuNextSection')
 
60
    MNU_PREFERENCES = _('mnuPreferences')
 
61
    MNU_PREVIOUSSECTION = _('mnuPreviousSection')
 
62
    MNU_PRINTTHISDOCUMENT = _('mnuPrintThisDocument')
 
63
    MNU_PRINTTHISPAGE = _('mnuPrintThisPage')
 
64
    MNU_REPORTAPROBLEM = _('mnuReportaProblem')
 
65
    MNU_SELECTALL = _('mnuSelectAll')
 
66
    MNU_TRANSLATETHISAPPLICATION = _('mnuTranslateThisApplication')
 
67
    TXT_FIND = _('txtFind')
 
68
    TXT_SEARCH = _('txtSearch')
 
69
 
 
70
 
 
71
    def runAboutdialog(self):
 
72
        """
 
73
        This basic test simply verifies that the application launches
 
74
        and that the UI reacts
 
75
        The About dialog is the only menu that is always present in the UI
 
76
        """
 
77
        if self.MNU_ABOUT:
 
78
            self.main_window.click(self.MNU_ABOUT)
 
79
 
 
80
            # Wait for the dialog to open
 
81
            # Name of about dialogs change with the app
 
82
            timeout=60
 
83
            dlgAbout=None
 
84
            while not ( timeout>0 and dlgAbout):
 
85
                dlgs=[ w for w in ldtp.getwindowlist() if w.startswith('dlgAbout')]
 
86
                if dlgs:
 
87
                    dlgAbout = dlgs[0]
 
88
                timeout -= 1
 
89
                time.sleep(1)
 
90
 
 
91
            if not dlgAbout:
 
92
                raise AssertionError('About Dialog not found')
 
93
 
 
94
 
 
95
            # Looking for a button to close the window
 
96
            found = None
 
97
            for btnClose in ('btnClose', 'btnOK', 'btnCancel'):
 
98
                try:
 
99
                    found = ldtp.getchild(dlgAbout, btnClose, 'push button')
 
100
                    break
 
101
                except:
 
102
                    pass
 
103
 
 
104
            if not found:
 
105
                return
 
106
 
 
107
            ldtp.click(dlgAbout, btnClose)
 
108
 
 
109
    def close(self):
 
110
        self.main_window.click(self.MNU_CLOSEWINDOW)
 
111
 
 
112
    def __init__(self):
 
113
        Application.__init__(self)
 
114
        self.main_window = ooldtp.context(self.WINDOW)