~ubuntu-branches/ubuntu/quantal/mago/quantal

« back to all changes in this revision

Viewing changes to mago/application/software_center.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 "software_center" module.
 
6
 
 
7
This module provides a wrapper for LDTP to make writing Software_center 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
from .policykit import PolicyKit
 
18
 
 
19
gettext.install (True)
 
20
gettext.bindtextdomain (PACKAGE, globals.LOCALE_SHARE)
 
21
gettext.textdomain (PACKAGE)
 
22
t = gettext.translation(PACKAGE, globals.LOCALE_SHARE, fallback = True)
 
23
_ = t.gettext
 
24
 
 
25
 
 
26
class Software_center(Application):
 
27
    """
 
28
    software_center manages the Software_center application.
 
29
    """
 
30
 
 
31
    LAUNCHER = 'software-center'
 
32
    LAUNCHER_ARGS = []
 
33
    WINDOW = 'frmUbuntuSoftwareCenter'
 
34
 
 
35
    BTN_69 = _('btn69')
 
36
    BTN_74 = _('btn74')
 
37
    BTN_79 = _('btn79')
 
38
    BTN_ACCESSORIES = _('btnAccessories')
 
39
    BTN_APPLYCHANGES = _('btnApplyChanges')
 
40
    BTN_APPLYCHANGES1 = _('btnApplyChanges1')
 
41
    BTN_APPLYCHANGES2 = _('btnApplyChanges2')
 
42
    BTN_BACKBUTTON = _('btnBackButton')
 
43
    BTN_CANCEL = _('btnCancel')
 
44
    BTN_CANCEL1 = _('btnCancel1')
 
45
    BTN_CANCEL2 = _('btnCancel2')
 
46
    BTN_DEVELOPERTOOLS = _('btnDeveloperTools')
 
47
    BTN_EDUCATION = _('btnEducation')
 
48
    BTN_FEATUREDSECTIONSHOWALL = _('btnFeaturedsectionshowall')
 
49
    BTN_FONTS = _('btnFonts')
 
50
    BTN_FORWARDBUTTON = _('btnForwardButton')
 
51
    BTN_FROZEN_BUBBLE = _('btnFrozen-Bubble')
 
52
    BTN_GADMIN_DHCPD = _('btnGADMIN-DHCPD')
 
53
    BTN_GAMES = _('btnGames')
 
54
    BTN_GETSOFTWARE = _('btnGetSoftware')
 
55
    BTN_GOTOPAGE1 = _('btnGotopage1')
 
56
    BTN_GOTOPAGE10 = _('btnGotopage10')
 
57
    BTN_GOTOPAGE101 = _('btnGotopage101')
 
58
    BTN_GOTOPAGE11 = _('btnGotopage11')
 
59
    BTN_GOTOPAGE110 = _('btnGotopage110')
 
60
    BTN_GOTOPAGE111 = _('btnGotopage111')
 
61
    BTN_GOTOPAGE12 = _('btnGotopage12')
 
62
    BTN_GOTOPAGE121 = _('btnGotopage121')
 
63
    BTN_GOTOPAGE13 = _('btnGotopage13')
 
64
    BTN_GOTOPAGE131 = _('btnGotopage131')
 
65
    BTN_GOTOPAGE14 = _('btnGotopage14')
 
66
    BTN_GOTOPAGE141 = _('btnGotopage141')
 
67
    BTN_GOTOPAGE15 = _('btnGotopage15')
 
68
    BTN_GOTOPAGE151 = _('btnGotopage151')
 
69
    BTN_GOTOPAGE16 = _('btnGotopage16')
 
70
    BTN_GOTOPAGE161 = _('btnGotopage161')
 
71
    BTN_GOTOPAGE17 = _('btnGotopage17')
 
72
    BTN_GOTOPAGE171 = _('btnGotopage171')
 
73
    BTN_GOTOPAGE18 = _('btnGotopage18')
 
74
    BTN_GOTOPAGE181 = _('btnGotopage181')
 
75
    BTN_GOTOPAGE19 = _('btnGotopage19')
 
76
    BTN_GOTOPAGE191 = _('btnGotopage191')
 
77
    BTN_GOTOPAGE2 = _('btnGotopage2')
 
78
    BTN_GOTOPAGE20 = _('btnGotopage20')
 
79
    BTN_GOTOPAGE201 = _('btnGotopage201')
 
80
    BTN_GOTOPAGE21 = _('btnGotopage21')
 
81
    BTN_GOTOPAGE22 = _('btnGotopage22')
 
82
    BTN_GOTOPAGE23 = _('btnGotopage23')
 
83
    BTN_GOTOPAGE24 = _('btnGotopage24')
 
84
    BTN_GOTOPAGE25 = _('btnGotopage25')
 
85
    BTN_GOTOPAGE26 = _('btnGotopage26')
 
86
    BTN_GOTOPAGE27 = _('btnGotopage27')
 
87
    BTN_GOTOPAGE28 = _('btnGotopage28')
 
88
    BTN_GOTOPAGE29 = _('btnGotopage29')
 
89
    BTN_GOTOPAGE3 = _('btnGotopage3')
 
90
    BTN_GOTOPAGE31 = _('btnGotopage31')
 
91
    BTN_GOTOPAGE4 = _('btnGotopage4')
 
92
    BTN_GOTOPAGE41 = _('btnGotopage41')
 
93
    BTN_GOTOPAGE5 = _('btnGotopage5')
 
94
    BTN_GOTOPAGE51 = _('btnGotopage51')
 
95
    BTN_GOTOPAGE6 = _('btnGotopage6')
 
96
    BTN_GOTOPAGE61 = _('btnGotopage61')
 
97
    BTN_GOTOPAGE7 = _('btnGotopage7')
 
98
    BTN_GOTOPAGE71 = _('btnGotopage71')
 
99
    BTN_GOTOPAGE8 = _('btnGotopage8')
 
100
    BTN_GOTOPAGE81 = _('btnGotopage81')
 
101
    BTN_GOTOPAGE9 = _('btnGotopage9')
 
102
    BTN_GOTOPAGE91 = _('btnGotopage91')
 
103
    BTN_GRAPHICS = _('btnGraphics')
 
104
    BTN_INTERNET = _('btnInternet')
 
105
    BTN_OFFICE = _('btnOffice')
 
106
    BTN_SCIENCE_ENGINEERING = _('btnScience&Engineering')
 
107
    BTN_SEARCHRESULTS = _('btnSearchResults')
 
108
    BTN_SHARE = _('btnShare')
 
109
    BTN_SHARE1 = _('btnShare1')
 
110
    BTN_SHARE2 = _('btnShare2')
 
111
    BTN_SOUND_VIDEO = _('btnSound&Video')
 
112
    BTN_SYSTEM = _('btnSystem')
 
113
    BTN_THEMES_TWEAKS = _('btnThemes&Tweaks')
 
114
    BTN_UNIVERSALACCESS = _('btnUniversalAccess')
 
115
    BTN_WEBSITE = _('btnWebsite')
 
116
    BTN_WEBSITE1 = _('btnWebsite1')
 
117
    BTN_WEBSITE2 = _('btnWebsite2')
 
118
    BTN_WHAT___SNEWSECTIONSHOWALL = _('btnWhat*sNewsectionshowall')
 
119
    MNU_ABOUT = _('mnuAbout')
 
120
    MNU_CLOSE = _('mnuClose')
 
121
    MNU_COPY = _('mnuCopy')
 
122
    MNU_COPYWEBLINK = _('mnuCopyWebLink')
 
123
    MNU_CUT = _('mnuCut')
 
124
    MNU_DELETE = _('mnuDelete')
 
125
    MNU_GETHELPONLINE = _('mnuGetHelpOnline')
 
126
    MNU_GOBACK = _('mnuGoBack')
 
127
    MNU_GOFORWARD = _('mnuGoForward')
 
128
    MNU_INSTALL = _('mnuInstall')
 
129
    MNU_PASTE = _('mnuPaste')
 
130
    MNU_REDO = _('mnuRedo')
 
131
    MNU_REINSTALLPREVIOUSPURCHASES___ = _('mnuReinstallPreviousPurchases*')
 
132
    MNU_REMOVE = _('mnuRemove')
 
133
    MNU_REPORTAPROBLEM = _('mnuReportaProblem')
 
134
    MNU_SEARCH___ = _('mnuSearch*')
 
135
    MNU_SELECTALL = _('mnuSelectAll')
 
136
    MNU_SOFTWARECENTERHELP = _('mnuSoftwareCenterHelp')
 
137
    MNU_SOFTWARESOURCES___ = _('mnuSoftwareSources*')
 
138
    MNU_TRANSLATETHISAPPLICATION = _('mnuTranslateThisApplication')
 
139
    MNU_UNDO = _('mnuUndo')
 
140
    TXT_SEARCH = _('txtSearch')
 
141
    TXT_SEARCH1 = _('txtSearch1')
 
142
    TXT_SEARCH2 = _('txtSearch2')
 
143
    TXT_SEARCH3 = _('txtSearch3')
 
144
 
 
145
    CLOSE_NAME=MNU_CLOSE
 
146
 
 
147
    def __init__(self, password = ""):
 
148
        """
 
149
        SoftwareCenter class init method
 
150
        
 
151
        If the test is going to need admin permissions, you need to provide the su password
 
152
        when creating an instance of the class.
 
153
        
 
154
        @type password: string
 
155
        @param password: User's password for administrative tasks.
 
156
 
 
157
        """
 
158
        Application.__init__(self)
 
159
        self.main_window = ooldtp.context(self.WINDOW)
 
160
        self.password = password
 
161
 
 
162
    def set_password(self, password):
 
163
        self.password = password
 
164
 
 
165
    def getpackagelistrow(self, rowindex):
 
166
        """ Return row at index 'rowindex' """
 
167
        return self.main_window.getcellvalue('tbl0', rowindex, 0)
 
168
 
 
169
    def search_package(self, package=None):
 
170
        """Search for a package with the quicksearch box"""
 
171
        if not package:
 
172
            return
 
173
 
 
174
        if not Application.is_opened(self):
 
175
            Application.open(self)
 
176
 
 
177
        sc=self.main_window
 
178
        ldtp.waittillguiexist(self.WINDOW)
 
179
        sc.settextvalue('txtSearch', package)
 
180
        ldtp.wait(2)
 
181
        sc.remap()
 
182
        ldtp.wait(2)
 
183
 
 
184
    def install_or_remove_package(self, action="install", package=None):
 
185
        """Install or remove a package"""
 
186
        if not package:
 
187
            return
 
188
 
 
189
        if not Application.is_opened(self):
 
190
            Application.open(self)
 
191
 
 
192
        action = action.lower()
 
193
 
 
194
        sc=self.main_window
 
195
 
 
196
        self.search_package(package)
 
197
        sc.getrowcount('tbl0')
 
198
        firstrow = sc.getcellvalue('tbl0',0,0)
 
199
        sc.doubleclickrow('tbl0', firstrow)
 
200
        ldtp.wait(2)
 
201
        sc.remap()
 
202
        ldtp.wait(2)
 
203
 
 
204
        # We will need administrative permission
 
205
        polKit = PolicyKit(self.password)
 
206
 
 
207
        if action == 'install':
 
208
            sc.click('btnInstall')
 
209
        elif action == 'remove' :
 
210
            sc.click('btnRemove')
 
211
 
 
212
        if polKit.wait():
 
213
            # HACK
 
214
            ldtp.wait(2)
 
215
            polKit.set_password()
 
216
 
 
217
        ldtp.wait(10)
 
218
 
 
219
        return 0
 
220