Merge lp:~udt-contributors/mago/class-constants into lp:~mago-contributors/mago/mago-1.0

Proposed by Javier Collado
Status: Merged
Merged at revision: not available
Proposed branch: lp:~udt-contributors/mago/class-constants
Merge into: lp:~mago-contributors/mago/mago-1.0
Diff against target: None lines
To merge this branch: bzr merge lp:~udt-contributors/mago/class-constants
Reviewer Review Type Date Requested Status
Ara Pulido Approve
Javier Collado (community) Approve
Eitan Isaacson Approve
Review via email: mp+5023@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Javier Collado (javier.collado) wrote :

Constants moved from modules to classes to prevent name clashes from happening without adding prefixes to constant names.

Code takes advantage of using standard constants such as LAUNCHER, WINDOW, etc.

Revision history for this message
Ara Pulido (ara) wrote :

I did some minor changes to the branch (default window name and using some setters in the clean up method).

I will ask Eitan to also review this.

Cheers,
Ara.

Revision history for this message
Eitan Isaacson (eeejay) wrote :

This looks great. I like the idea.
One thing: You don't need to use __class__ to access class fields.
Instead of self.__class__.WINDOW, you could simply use self.WINDOW.

Revision history for this message
Eitan Isaacson (eeejay) wrote :

On Javier's approval I removed the __class__ prefix, script developers don't need to know/understand the distinction between class and instance variables, it will work as expected.

review: Approve
Revision history for this message
Javier Collado (javier.collado) :
review: Approve
Revision history for this message
Ara Pulido (ara) :
review: Approve
62. By Eitan Isaacson

Comment out server.hide(), it is broken (bug #351537).

63. By Eitan Isaacson

Merge from trunk.

64. By Eitan Isaacson

Added a server display test.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'desktoptesting/gnome.py'
--- desktoptesting/gnome.py 2009-03-19 10:47:43 +0000
+++ desktoptesting/gnome.py 2009-03-30 10:11:44 +0000
@@ -5,23 +5,46 @@
5"""5"""
6import ooldtp6import ooldtp
7import ldtp 7import ldtp
8import gnome_constants
98
10class Application:9class Application:
11 """10 """
12 Supperclass for the rest of the applications11 Superclass for the rest of the applications
12
13 Constants that should be defined in the classes that inherit from this class
14 LAUNCHER: Argument to be passed when launching the application through ldtp.launchapp
15 WINDOW: Top application frame pattern using ldtp syntax
16 CLOSE_TYPE: Close object type (one of 'menu' or 'button')
17 CLOSE_NAME: Close object name
13 """18 """
14 def __init__(self, name = '', close_type='menu', close_name='mnuQuit'):19 CLOSE_TYPE = 'menu'
20 CLOSE_NAME = 'mnuQuit'
21
22 TOP_PANEL = 'frmTopExpandedEdgePanel'
23
24
25 def __init__(self, name = None, close_type= None, close_name= None):
15 """26 """
16 @type close_type: string27 @type close_type: string
17 @param close_type: The type of close widget of the application. Types: menu, button.28 @param close_type: The type of close widget of the application. Types: menu, button.
18 @type close_name: string29 @type close_name: string
19 @param close_name: The name of the exit widget of the application. If not mentioned the default will be used ("Quit").30 @param close_name: The name of the exit widget of the application. If not mentioned the default will be used ("Quit")
20 """31 """
21 self.name = name32 if name:
22 self.close_type = close_type33 self.name = name
23 self.close_name = close_name34 else:
24 35 self.name = self.__class__.WINDOW
36
37 if close_type:
38 self.close_type = close_type
39 else:
40 self.close_type = self.__class__.CLOSE_TYPE
41
42 if close_name:
43 self.close_name = close_name
44 else:
45 self.close_name = self.__class__.CLOSE_NAME
46
47
25 def setup(self):48 def setup(self):
26 pass49 pass
2750
@@ -29,9 +52,9 @@
29 pass52 pass
3053
31 def cleanup(self):54 def cleanup(self):
32 self.set_name('')55 self.name = self.__class__.WINDOW
33 self.set_close_type('menu')56 self.close_type = self.__class__.CLOSE_TYPE
34 self.set_close_name('mnuQuit')57 self.close_name = self.__class__.CLOSE_NAME
3558
36 def recover(self):59 def recover(self):
37 self.teardown()60 self.teardown()
@@ -56,15 +79,14 @@
56 """79 """
57 ldtp.remap(self.name)80 ldtp.remap(self.name)
5881
59 def open_and_check_app(self, app_name):82 def open_and_check_app(self):
60 """83 """
61 Given an application, it tries to open it.84 Given an application, it tries to open it.
62 85
63 @type app_name: string86 @type app_name: string
64 @param app_name: The command to start the application.87 @param app_name: The command to start the application.
65 """88 """
66 89 ldtp.launchapp(self.__class__.LAUNCHER)
67 ldtp.launchapp(app_name)
6890
69 ldtp.wait(2)91 ldtp.wait(2)
70 response = ldtp.waittillguiexist(self.name, '', 20)92 response = ldtp.waittillguiexist(self.name, '', 20)
@@ -135,13 +157,40 @@
135 except ldtp.LdtpExecutionError:157 except ldtp.LdtpExecutionError:
136 raise ldtp.LdtpExecutionError, "We couldn't write text."158 raise ldtp.LdtpExecutionError, "We couldn't write text."
137159
160
138class Seahorse(Application):161class Seahorse(Application):
139 """162 """
140 Seahorse manages the Seahorse application.163 Seahorse manages the Seahorse application.
141 """164 """
142 165 WINDOW = "frmPasswordsandEncryptionKeys"
166 LAUNCHER = "seahorse"
167 MNU_NEWKEY = "mnuNew"
168 NEWKEY_DLG = "Create New ..."
169 BTN_CONTINUE = "btnContinue"
170 TYPE_PGP = "PGP Key"
171 NEWPGP_DLG = "dlgCreateaPGPKey"
172 DLG_NEWPGP_FULLNAME = "txtFullName"
173 DLG_NEWPGP_EMAIL = "txtEmailAddress"
174 DLG_NEWPGP_COMMENT = "txtComment"
175 BTN_NEWPGP_CREATE = "btnCreate"
176 DLG_NEWKEY_PASS = "dlgPassphrasefor*"
177 BTN_PASS_OK = "btnOK"
178 DLG_GENERATING_KEY = "dlgGeneratingkey"
179 DLG_CREATING_SSH = "dlgCreatingSecureShellKey"
180 TYPE_SSH = "Secure Shell Key"
181 NEWSSH_DLG = "New Secure Shell Key"
182 DLG_NEWSSH_DESC = "txtKeyDescription"
183 BTN_NEWSSH_CREATE_AND_SETUP = "Create and Set Up"
184 DLG_SET_UP = "Set Up Computer for SSH Connection"
185 TXT_SET_UP_COMPUTER = "txtThehostnameoraddressoftheserver."
186 TXT_SET_UP_LOGIN = "txtLoginName"
187 BTN_SET_UP = "btnSetUp"
188 BTN_NEWSSH_CREATE = "Just Create Key"
189 TAB_PERSONAL_KEYS = "My Personal Keys"
190 TAB_LIST = "ptl0"
191
143 def __init__(self):192 def __init__(self):
144 Application.__init__(self, gnome_constants.SH_WINDOW)193 Application.__init__(self)
145194
146 def setup(self):195 def setup(self):
147 self.open()196 self.open()
@@ -154,7 +203,7 @@
154 pass203 pass
155204
156 def open(self):205 def open(self):
157 Application.open_and_check_app(self, gnome_constants.SH_LAUNCHER)206 self.open_and_check_app()
158207
159 def new_key(self, key_type):208 def new_key(self, key_type):
160 """209 """
@@ -167,7 +216,7 @@
167 seahorse = ooldtp.context(self.name)216 seahorse = ooldtp.context(self.name)
168 217
169 try:218 try:
170 mnu_new_key = seahorse.getchild(gnome_constants.SH_MNU_NEWKEY)219 mnu_new_key = seahorse.getchild(self.__class__.MNU_NEWKEY)
171 except ldtp.LdtpExecutionError:220 except ldtp.LdtpExecutionError:
172 raise ldtp.LdtpExecutionError, "The new key menu was not found."221 raise ldtp.LdtpExecutionError, "The new key menu was not found."
173222
@@ -177,8 +226,8 @@
177 raise ldtp.LdtpExecutionError, "There was a problem when selecting new key menu item."226 raise ldtp.LdtpExecutionError, "There was a problem when selecting new key menu item."
178227
179 try:228 try:
180 ldtp.waittillguiexist(gnome_constants.SH_NEWKEY_DLG)229 ldtp.waittillguiexist(self.__class__.NEWKEY_DLG)
181 dlg_new_key = ooldtp.context(gnome_constants.SH_NEWKEY_DLG)230 dlg_new_key = ooldtp.context(self.__class__.NEWKEY_DLG)
182 except ldtp.LdtpExecutionError:231 except ldtp.LdtpExecutionError:
183 raise ldtp.LdtpExecutionError, "The new key dialog was not found."232 raise ldtp.LdtpExecutionError, "The new key dialog was not found."
184233
@@ -197,7 +246,7 @@
197 raise ldtp.LdtpExecutionError, "Error getting the key types table."246 raise ldtp.LdtpExecutionError, "Error getting the key types table."
198247
199 try:248 try:
200 btn_continue = dlg_new_key.getchild(gnome_constants.SH_BTN_CONTINUE)249 btn_continue = dlg_new_key.getchild(self.__class__.BTN_CONTINUE)
201 except ldtp.LdtpExecutionError:250 except ldtp.LdtpExecutionError:
202 raise ldtp.LdtpExecutionError, "The continue button at the new key dialog was not found."251 raise ldtp.LdtpExecutionError, "The continue button at the new key dialog was not found."
203252
@@ -226,16 +275,16 @@
226 @param passphrase: Passphrase to type for the PGP key275 @param passphrase: Passphrase to type for the PGP key
227 """276 """
228 277
229 self.new_key(gnome_constants.SH_TYPE_PGP)278 self.new_key(self.__class__.TYPE_PGP)
230279
231 try:280 try:
232 ldtp.waittillguiexist(gnome_constants.SH_NEWPGP_DLG)281 ldtp.waittillguiexist(self.__class__.NEWPGP_DLG)
233 dlg_new_pgp = ooldtp.context(gnome_constants.SH_NEWPGP_DLG)282 dlg_new_pgp = ooldtp.context(self.__class__.NEWPGP_DLG)
234 except ldtp.LdtpExecutionError:283 except ldtp.LdtpExecutionError:
235 raise ldtp.LdtpExecutionError, "The new key dialog was not found."284 raise ldtp.LdtpExecutionError, "The new key dialog was not found."
236285
237 try:286 try:
238 txt_field = dlg_new_pgp.getchild(gnome_constants.SH_DLG_NEWPGP_FULLNAME)287 txt_field = dlg_new_pgp.getchild(self.__class__.DLG_NEWPGP_FULLNAME)
239 except ldtp.LdtpExecutionError:288 except ldtp.LdtpExecutionError:
240 raise ldtp.LdtpExecutionError, "The " + txt_field + " text field was not found."289 raise ldtp.LdtpExecutionError, "The " + txt_field + " text field was not found."
241 try:290 try:
@@ -244,7 +293,7 @@
244 raise ldtp.LdtpExecutionError, "There was an error when writing the text."293 raise ldtp.LdtpExecutionError, "There was an error when writing the text."
245294
246 try:295 try:
247 txt_field = dlg_new_pgp.getchild(gnome_constants.SH_DLG_NEWPGP_EMAIL)296 txt_field = dlg_new_pgp.getchild(self.__class__.DLG_NEWPGP_EMAIL)
248 except ldtp.LdtpExecutionError:297 except ldtp.LdtpExecutionError:
249 raise ldtp.LdtpExecutionError, "The " + txt_field + " text field was not found."298 raise ldtp.LdtpExecutionError, "The " + txt_field + " text field was not found."
250 try:299 try:
@@ -253,7 +302,7 @@
253 raise ldtp.LdtpExecutionError, "There was a problem when writing the text."302 raise ldtp.LdtpExecutionError, "There was a problem when writing the text."
254 303
255 try:304 try:
256 txt_field = dlg_new_pgp.getchild(gnome_constants.SH_DLG_NEWPGP_COMMENT)305 txt_field = dlg_new_pgp.getchild(self.__class__.DLG_NEWPGP_COMMENT)
257 except ldtp.LdtpExecutionError:306 except ldtp.LdtpExecutionError:
258 raise ldtp.LdtpExecutionError, "The " + txt_field + " text field was not found."307 raise ldtp.LdtpExecutionError, "The " + txt_field + " text field was not found."
259 try:308 try:
@@ -262,7 +311,7 @@
262 raise ldtp.LdtpExecutionError, "There was a problem when writing the text."311 raise ldtp.LdtpExecutionError, "There was a problem when writing the text."
263312
264 try:313 try:
265 btn_create = dlg_new_pgp.getchild(gnome_constants.SH_BTN_NEWPGP_CREATE)314 btn_create = dlg_new_pgp.getchild(self.__class__.BTN_NEWPGP_CREATE)
266 except ldtp.LdtpExecutionError:315 except ldtp.LdtpExecutionError:
267 raise ldtp.LdtpExecutionError, "The create button at the new PGP key dialog was not found."316 raise ldtp.LdtpExecutionError, "The create button at the new PGP key dialog was not found."
268317
@@ -272,8 +321,8 @@
272 raise ldtp.LdtpExecutionError, "There was a problem when clicking the create button."321 raise ldtp.LdtpExecutionError, "There was a problem when clicking the create button."
273 322
274 try:323 try:
275 ldtp.waittillguiexist(gnome_constants.SH_DLG_NEWKEY_PASS)324 ldtp.waittillguiexist(self.__class__.DLG_NEWKEY_PASS)
276 dlg_new_pgp_pass = ooldtp.context(gnome_constants.SH_DLG_NEWKEY_PASS)325 dlg_new_pgp_pass = ooldtp.context(self.__class__.DLG_NEWKEY_PASS)
277 except ldtp.LdtpExecutionError:326 except ldtp.LdtpExecutionError:
278 raise ldtp.LdtpExecutionError, "The new pgp key passphrase dialog was not found."327 raise ldtp.LdtpExecutionError, "The new pgp key passphrase dialog was not found."
279328
@@ -285,7 +334,7 @@
285 raise ldtp.LdtpExecutionError, "Error entering passphrase."334 raise ldtp.LdtpExecutionError, "Error entering passphrase."
286 335
287 try:336 try:
288 btn_pass_ok = dlg_new_pgp_pass.getchild(gnome_constants.SH_BTN_PASS_OK)337 btn_pass_ok = dlg_new_pgp_pass.getchild(self.__class__.BTN_PASS_OK)
289 except ldtp.LdtpExecutionError:338 except ldtp.LdtpExecutionError:
290 raise ldtp.LdtpExecutionError, "The OK button at the new PGP key passphrase dialog was not found."339 raise ldtp.LdtpExecutionError, "The OK button at the new PGP key passphrase dialog was not found."
291340
@@ -295,8 +344,8 @@
295 raise ldtp.LdtpExecutionError, "There was a problem when clicking the OK button."344 raise ldtp.LdtpExecutionError, "There was a problem when clicking the OK button."
296 345
297 try:346 try:
298 ldtp.waittillguiexist(gnome_constants.SH_DLG_GENERATING_KEY)347 ldtp.waittillguiexist(self.__class__.DLG_GENERATING_KEY)
299 while ldtp.guiexist(gnome_constants.SH_DLG_GENERATING_KEY) == 1:348 while ldtp.guiexist(self.__class__.DLG_GENERATING_KEY) == 1:
300 ldtp.wait(1)349 ldtp.wait(1)
301 except ldtp.LdtpExecutionError:350 except ldtp.LdtpExecutionError:
302 raise ldtp.LdtpExecutionError, "The new pgp generating key dialog was not found."351 raise ldtp.LdtpExecutionError, "The new pgp generating key dialog was not found."
@@ -324,18 +373,18 @@
324 @param login: Login to use in the remote computer373 @param login: Login to use in the remote computer
325 """374 """
326 375
327 self.new_key(gnome_constants.SH_TYPE_SSH)376 self.new_key(self.__class__.TYPE_SSH)
328377
329 try:378 try:
330 ldtp.waittillguiexist(gnome_constants.SH_NEWSSH_DLG)379 ldtp.waittillguiexist(self.__class__.NEWSSH_DLG)
331 dlg_new_ssh = ooldtp.context(gnome_constants.SH_NEWSSH_DLG)380 dlg_new_ssh = ooldtp.context(self.__class__.NEWSSH_DLG)
332 except ldtp.LdtpExecutionError:381 except ldtp.LdtpExecutionError:
333 raise ldtp.LdtpExecutionError, "The new key dialog was not found."382 raise ldtp.LdtpExecutionError, "The new key dialog was not found."
334383
335 try:384 try:
336 txt_field = dlg_new_ssh.getchild(gnome_constants.SH_DLG_NEWSSH_DESC)385 txt_field = dlg_new_ssh.getchild(self.__class__.DLG_NEWSSH_DESC)
337 except ldtp.LdtpExecutionError:386 except ldtp.LdtpExecutionError:
338 raise ldtp.LdtpExecutionError, "The " + gnome_constants.SH_DLG_NEWSSH_DESC + " text field was not found."387 raise ldtp.LdtpExecutionError, "The " + self.__class__.DLG_NEWSSH_DESC + " text field was not found."
339 try:388 try:
340 txt_field.settextvalue(description)389 txt_field.settextvalue(description)
341 except ldtp.LdtpExecutionError:390 except ldtp.LdtpExecutionError:
@@ -343,13 +392,13 @@
343392
344 if set_up == True:393 if set_up == True:
345 try:394 try:
346 btn_create = dlg_new_ssh.getchild(gnome_constants.SH_BTN_NEWSSH_CREATE_AND_SETUP)395 btn_create = dlg_new_ssh.getchild(self.__class__.BTN_NEWSSH_CREATE_AND_SETUP)
347 except ldtp.LdtpExecutionError:396 except ldtp.LdtpExecutionError:
348 raise ldtp.LdtpExecutionError, "The create button at the new PGP key dialog was not found."397 raise ldtp.LdtpExecutionError, "The create button at the new PGP key dialog was not found."
349398
350 else:399 else:
351 try:400 try:
352 btn_create = dlg_new_ssh.getchild(gnome_constants.SH_BTN_NEWSSH_CREATE)401 btn_create = dlg_new_ssh.getchild(self.__class__.BTN_NEWSSH_CREATE)
353 except ldtp.LdtpExecutionError:402 except ldtp.LdtpExecutionError:
354 raise ldtp.LdtpExecutionError, "The create button at the new PGP key dialog was not found."403 raise ldtp.LdtpExecutionError, "The create button at the new PGP key dialog was not found."
355404
@@ -360,8 +409,8 @@
360 409
361 410
362 try:411 try:
363 ldtp.waittillguiexist(gnome_constants.SH_DLG_NEWKEY_PASS)412 ldtp.waittillguiexist(self.__class__.DLG_NEWKEY_PASS)
364 dlg_new_key_pass = ooldtp.context(gnome_constants.SH_DLG_NEWKEY_PASS)413 dlg_new_key_pass = ooldtp.context(self.__class__.DLG_NEWKEY_PASS)
365 except ldtp.LdtpExecutionError:414 except ldtp.LdtpExecutionError:
366 raise ldtp.LdtpExecutionError, "The new key passphrase dialog was not found."415 raise ldtp.LdtpExecutionError, "The new key passphrase dialog was not found."
367416
@@ -373,7 +422,7 @@
373 raise ldtp.LdtpExecutionError, "Error entering passphrase."422 raise ldtp.LdtpExecutionError, "Error entering passphrase."
374 423
375 try:424 try:
376 btn_pass_ok = dlg_new_key_pass.getchild(gnome_constants.SH_BTN_PASS_OK)425 btn_pass_ok = dlg_new_key_pass.getchild(self.__class__.BTN_PASS_OK)
377 except ldtp.LdtpExecutionError:426 except ldtp.LdtpExecutionError:
378 raise ldtp.LdtpExecutionError, "The OK button at the new key passphrase dialog was not found."427 raise ldtp.LdtpExecutionError, "The OK button at the new key passphrase dialog was not found."
379428
@@ -385,15 +434,15 @@
385 if set_up == True and login is not None:434 if set_up == True and login is not None:
386435
387 try:436 try:
388 ldtp.waittillguiexist(gnome_constants.SH_DLG_SET_UP)437 ldtp.waittillguiexist(self.__class__.DLG_SET_UP)
389 dlg_set_up_computer = ooldtp.context(gnome_constants.SH_DLG_SET_UP)438 dlg_set_up_computer = ooldtp.context(self.__class__.DLG_SET_UP)
390 except ldtp.LdtpExecutionError:439 except ldtp.LdtpExecutionError:
391 raise ldtp.LdtpExecutionError, "The set up computer dialog was not found."440 raise ldtp.LdtpExecutionError, "The set up computer dialog was not found."
392441
393 try:442 try:
394 txt_field = dlg_set_up_computer.getchild(gnome_constants.SH_TXT_SET_UP_LOGIN)443 txt_field = dlg_set_up_computer.getchild(self.__class__.TXT_SET_UP_LOGIN)
395 except ldtp.LdtpExecutionError:444 except ldtp.LdtpExecutionError:
396 raise ldtp.LdtpExecutionError, "The " + gnome_constants.SH_TXT_SET_UP_LOGIN + " text field was not found."445 raise ldtp.LdtpExecutionError, "The " + self.__class__.TXT_SET_UP_LOGIN + " text field was not found."
397 try:446 try:
398 txt_field.settextvalue(login)447 txt_field.settextvalue(login)
399 except ldtp.LdtpExecutionError:448 except ldtp.LdtpExecutionError:
@@ -401,16 +450,16 @@
401450
402 if set_up == True:451 if set_up == True:
403 try:452 try:
404 txt_field = dlg_set_up_computer.getchild(gnome_constants.SH_TXT_SET_UP_COMPUTER)453 txt_field = dlg_set_up_computer.getchild(self.__class__.TXT_SET_UP_COMPUTER)
405 except ldtp.LdtpExecutionError:454 except ldtp.LdtpExecutionError:
406 raise ldtp.LdtpExecutionError, "The " + gnome_constants.SH_TXT_SET_UP_COMPUTER + " text field was not found."455 raise ldtp.LdtpExecutionError, "The " + self.__class__.TXT_SET_UP_COMPUTER + " text field was not found."
407 try:456 try:
408 txt_field.settextvalue(computer)457 txt_field.settextvalue(computer)
409 except ldtp.LdtpExecutionError:458 except ldtp.LdtpExecutionError:
410 raise ldtp.LdtpExecutionError, "There was an error when writing the text."459 raise ldtp.LdtpExecutionError, "There was an error when writing the text."
411460
412 try:461 try:
413 btn_set_up = dlg_set_up_computer.getchild(gnome_constants.SH_BTN_SET_UP)462 btn_set_up = dlg_set_up_computer.getchild(self.__class__.BTN_SET_UP)
414 except ldtp.LdtpExecutionError:463 except ldtp.LdtpExecutionError:
415 raise ldtp.LdtpExecutionError, "The set up button was not found."464 raise ldtp.LdtpExecutionError, "The set up button was not found."
416465
@@ -420,7 +469,7 @@
420 raise ldtp.LdtpExecutionError, "There was a problem when clicking the set up button."469 raise ldtp.LdtpExecutionError, "There was a problem when clicking the set up button."
421 470
422 try:471 try:
423 while ldtp.guiexist(gnome_constants.SH_DLG_CREATING_SSH) == 1:472 while ldtp.guiexist(self.__class__.DLG_CREATING_SSH) == 1:
424 ldtp.wait(1)473 ldtp.wait(1)
425 474
426 except ldtp.LdtpExecutionError:475 except ldtp.LdtpExecutionError:
@@ -429,7 +478,7 @@
429 # It is too fast to grab the main window afterwards478 # It is too fast to grab the main window afterwards
430 ldtp.wait(3)479 ldtp.wait(3)
431480
432 def assert_exists_key(self, name, tab_name = gnome_constants.SH_TAB_PERSONAL_KEYS):481 def assert_exists_key(self, name, tab_name = None):
433 """482 """
434 It checks that the KEY with description 'description' is483 It checks that the KEY with description 'description' is
435 part of the keys of the current user484 part of the keys of the current user
@@ -440,12 +489,14 @@
440 @type tab_name: string489 @type tab_name: string
441 @param tab_name: The tab name to search for the key.490 @param tab_name: The tab name to search for the key.
442 """491 """
492 if not tab_name:
493 tab_name = self.__class__.TAB_PERSONAL_KEYS
443494
444 seahorse = ooldtp.context(self.name)495 seahorse = ooldtp.context(self.name)
445 try:496 try:
446497
447 page_list = seahorse.getchild(gnome_constants.SH_TAB_LIST)498 page_list = seahorse.getchild(self.__class__.TAB_LIST)
448 page_list.selecttab(gnome_constants.SH_TAB_PERSONAL_KEYS)499 page_list.selecttab(self.__class__.TAB_PERSONAL_KEYS)
449 scroll_pane = ldtp.getobjectproperty(self.name, tab_name, 'children')500 scroll_pane = ldtp.getobjectproperty(self.name, tab_name, 'children')
450 list_keys = ldtp.getobjectproperty(self.name, scroll_pane, 'children')501 list_keys = ldtp.getobjectproperty(self.name, scroll_pane, 'children')
451 list_keys = list_keys.split(' ')[0]502 list_keys = list_keys.split(' ')[0]
@@ -464,9 +515,22 @@
464 """515 """
465 GEdit manages the Gedit application.516 GEdit manages the Gedit application.
466 """517 """
467 518 WINDOW = "frm*gedit"
519 TXT_FIELD = "txt1"
520 LAUNCHER = "gedit"
521 SAVE_DLG = "dlgSave*"
522 SAVE_DLG_TXT_NAME = "txtName"
523 SAVE_DLG_BTN_SAVE = "btnSave"
524 QUESTION_DLG = "dlgQuestion"
525 QUESTION_DLG_BTN_SAVE = "btnSave"
526 QUESTION_DLG_BTN_SAVE_AS = "btnSaveAs"
527 QUESTION_DLG_BTN_CLOSE = "btnClosewithoutSaving"
528 MNU_QUIT = "mnuQuit"
529 MNU_CLOSE = "mnuClose"
530 MNU_NEW = "mnuNew"
531
468 def __init__(self):532 def __init__(self):
469 Application.__init__(self, gnome_constants.GE_WINDOW)533 Application.__init__(self)
470534
471 def setup(self):535 def setup(self):
472 self.open()536 self.open()
@@ -479,30 +543,30 @@
479 try:543 try:
480 try:544 try:
481 gedit = ooldtp.context(self.name)545 gedit = ooldtp.context(self.name)
482 quit_menu = gedit.getchild(gnome_constants.GE_MNU_CLOSE)546 quit_menu = gedit.getchild(self.__class__.MNU_CLOSE)
483 except ldtp.LdtpExecutionError:547 except ldtp.LdtpExecutionError:
484 raise ldtp.LdtpExecutionError, "The quit menu was not found."548 raise ldtp.LdtpExecutionError, "The quit menu was not found."
485 quit_menu.selectmenuitem()549 quit_menu.selectmenuitem()
486 except ldtp.LdtpExecutionError:550 except ldtp.LdtpExecutionError:
487 raise ldtp.LdtpExecutionError, "Mmm, something went wrong when closing the application."551 raise ldtp.LdtpExecutionError, "Mmm, something went wrong when closing the application."
488552
489 result = ldtp.waittillguiexist(gnome_constants.GE_QUESTION_DLG,553 result = ldtp.waittillguiexist(self.__class__.QUESTION_DLG,
490 guiTimeOut = 2)554 guiTimeOut = 2)
491555
492 if result == 1:556 if result == 1:
493 question_dialog = ooldtp.context(gnome_constants.GE_QUESTION_DLG)557 question_dialog = ooldtp.context(self.__class__.QUESTION_DLG)
494 question_dlg_btn_close = question_dialog.getchild(gnome_constants.GE_QUESTION_DLG_BTN_CLOSE)558 question_dlg_btn_close = question_dialog.getchild(self.__class__.QUESTION_DLG_BTN_CLOSE)
495 question_dlg_btn_close.click()559 question_dlg_btn_close.click()
496 560
497 try:561 try:
498 gedit = ooldtp.context(self.name)562 gedit = ooldtp.context(self.name)
499 new_menu = gedit.getchild(gnome_constants.GE_MNU_NEW)563 new_menu = gedit.getchild(self.__class__.MNU_NEW)
500 except ldtp.LdtpExecutionError:564 except ldtp.LdtpExecutionError:
501 raise ldtp.LdtpExecutionError, "The new menu was not found."565 raise ldtp.LdtpExecutionError, "The new menu was not found."
502 new_menu.selectmenuitem()566 new_menu.selectmenuitem()
503 567
504 result = ldtp.waittillguiexist(568 result = ldtp.waittillguiexist(
505 self.name, gnome_constants.GE_TXT_FIELD)569 self.name, self.__class__.TXT_FIELD)
506 if result != 1:570 if result != 1:
507 raise ldtp.LdtpExecutionError, "Failed to set up new document."571 raise ldtp.LdtpExecutionError, "Failed to set up new document."
508 572
@@ -514,7 +578,7 @@
514 @type text: string578 @type text: string
515 @param text: The text string to be written to the current buffer.579 @param text: The text string to be written to the current buffer.
516 """580 """
517 Application.write_text(self, text, gnome_constants.GE_TXT_FIELD)581 Application.write_text(self, text, self.__class__.TXT_FIELD)
518582
519 def save(self, filename):583 def save(self, filename):
520 """584 """
@@ -529,12 +593,12 @@
529 ooldtp.context(self.name)593 ooldtp.context(self.name)
530594
531 try:595 try:
532 ldtp.waittillguiexist(gnome_constants.GE_SAVE_DLG)596 ldtp.waittillguiexist(self.__class__.SAVE_DLG)
533 save_dialog = ooldtp.context(gnome_constants.GE_SAVE_DLG)597 save_dialog = ooldtp.context(self.__class__.SAVE_DLG)
534 except ldtp.LdtpExecutionError:598 except ldtp.LdtpExecutionError:
535 raise ldtp.LdtpExecutionError, "The Gedit save dialog was not found."599 raise ldtp.LdtpExecutionError, "The Gedit save dialog was not found."
536 try:600 try:
537 save_dlg_txt_filename = save_dialog.getchild(gnome_constants.GE_SAVE_DLG_TXT_NAME)601 save_dlg_txt_filename = save_dialog.getchild(self.__class__.SAVE_DLG_TXT_NAME)
538 except ldtp.LdtpExecutionError:602 except ldtp.LdtpExecutionError:
539 raise ldtp.LdtpExecutionError, "The filename txt field in Gedit save dialog was not found."603 raise ldtp.LdtpExecutionError, "The filename txt field in Gedit save dialog was not found."
540 try:604 try:
@@ -544,7 +608,7 @@
544 raise ldtp.LdtpExecutionError, "We couldn't write text."608 raise ldtp.LdtpExecutionError, "We couldn't write text."
545609
546 try:610 try:
547 save_dlg_btn_save = save_dialog.getchild(gnome_constants.GE_SAVE_DLG_BTN_SAVE)611 save_dlg_btn_save = save_dialog.getchild(self.__class__.SAVE_DLG_BTN_SAVE)
548 except ldtp.LdtpExecutionError:612 except ldtp.LdtpExecutionError:
549 raise ldtp.LdtpExecutionError, "The button Save in Gedit save dialog was not found."613 raise ldtp.LdtpExecutionError, "The button Save in Gedit save dialog was not found."
550 614
@@ -553,7 +617,7 @@
553 except ldtp.LdtpExecutionError:617 except ldtp.LdtpExecutionError:
554 raise ldtp.LdtpExecutionError, "There was an error when pushing the Save button."618 raise ldtp.LdtpExecutionError, "There was an error when pushing the Save button."
555619
556 ldtp.waittillguinotexist(gnome_constants.GE_SAVE_DLG)620 ldtp.waittillguinotexist(self.__class__.SAVE_DLG)
557 621
558 def open(self):622 def open(self):
559 """623 """
@@ -561,7 +625,7 @@
561 didn't start properly.625 didn't start properly.
562626
563 """627 """
564 Application.open_and_check_app(self, gnome_constants.GE_LAUNCHER)628 self.open_and_check_app()
565629
566 def exit(self, save=False, filename=''):630 def exit(self, save=False, filename=''):
567 """631 """
@@ -579,42 +643,42 @@
579 try:643 try:
580 gedit = ooldtp.context(self.name)644 gedit = ooldtp.context(self.name)
581 try:645 try:
582 quit_menu = gedit.getchild(gnome_constants.GE_MNU_QUIT)646 quit_menu = gedit.getchild(self.__class__.MNU_QUIT)
583 except ldtp.LdtpExecutionError:647 except ldtp.LdtpExecutionError:
584 raise ldtp.LdtpExecutionError, "The quit menu was not found."648 raise ldtp.LdtpExecutionError, "The quit menu was not found."
585 quit_menu.selectmenuitem()649 quit_menu.selectmenuitem()
586 except ldtp.LdtpExecutionError:650 except ldtp.LdtpExecutionError:
587 raise ldtp.LdtpExecutionError, "Mmm, something went wrong when closing the application."651 raise ldtp.LdtpExecutionError, "Mmm, something went wrong when closing the application."
588652
589 response = ldtp.waittillguiexist(gnome_constants.GE_QUESTION_DLG, '', 20)653 response = ldtp.waittillguiexist(self.__class__.QUESTION_DLG, '', 20)
590 654
591 # If the text has changed, the save dialog will appear655 # If the text has changed, the save dialog will appear
592 if response == 1:656 if response == 1:
593 try:657 try:
594 question_dialog = ooldtp.context(gnome_constants.GE_QUESTION_DLG)658 question_dialog = ooldtp.context(self.__class__.QUESTION_DLG)
595 except ldtp.LdtpExecutionError:659 except ldtp.LdtpExecutionError:
596 raise ldtp.LdtpExecutionError, "The Gedit question dialog was not found."660 raise ldtp.LdtpExecutionError, "The Gedit question dialog was not found."
597 661
598 # Test if the file needs to be saved662 # Test if the file needs to be saved
599 if save:663 if save:
600 try:664 try:
601 question_dlg_btn_save = question_dialog.getchild(gnome_constants.GE_QUESTION_DLG_BTN_SAVE)665 question_dlg_btn_save = question_dialog.getchild(self.__class__.QUESTION_DLG_BTN_SAVE)
602 question_dlg_btn_save.click()666 question_dlg_btn_save.click()
603 except ldtp.LdtpExecutionError:667 except ldtp.LdtpExecutionError:
604 # If the Save button was not found, we will try to find the Save As668 # If the Save button was not found, we will try to find the Save As
605 try:669 try:
606 question_dlg_btn_save = question_dialog.getchild(gnome_constants.GE_QUESTION_DLG_BTN_SAVE_AS)670 question_dlg_btn_save = question_dialog.getchild(self.__class__.QUESTION_DLG_BTN_SAVE_AS)
607 question_dlg_btn_save.click()671 question_dlg_btn_save.click()
608 except ldtp.LdtpExecutionError:672 except ldtp.LdtpExecutionError:
609 raise ldtp.LdtpExecutionError, "The save or save as buttons in Gedit question dialog were not found."673 raise ldtp.LdtpExecutionError, "The save or save as buttons in Gedit question dialog were not found."
610674
611 try:675 try:
612 ldtp.waittillguiexist(gnome_constants.GE_SAVE_DLG)676 ldtp.waittillguiexist(self.__class__.SAVE_DLG)
613 save_dialog = ooldtp.context(gnome_constants.GE_SAVE_DLG)677 save_dialog = ooldtp.context(self.__class__.SAVE_DLG)
614 except ldtp.LdtpExecutionError:678 except ldtp.LdtpExecutionError:
615 raise ldtp.LdtpExecutionError, "The Gedit save dialog was not found."679 raise ldtp.LdtpExecutionError, "The Gedit save dialog was not found."
616 try:680 try:
617 save_dlg_txt_filename = save_dialog.getchild(gnome_constants.GE_SAVE_DLG_TXT_NAME)681 save_dlg_txt_filename = save_dialog.getchild(self.__class__.SAVE_DLG_TXT_NAME)
618 except ldtp.LdtpExecutionError:682 except ldtp.LdtpExecutionError:
619 raise ldtp.LdtpExecutionError, "The filename txt field in Gedit save dialog was not found."683 raise ldtp.LdtpExecutionError, "The filename txt field in Gedit save dialog was not found."
620 try:684 try:
@@ -624,7 +688,7 @@
624 raise ldtp.LdtpExecutionError, "There was an error when writing the text."688 raise ldtp.LdtpExecutionError, "There was an error when writing the text."
625689
626 try:690 try:
627 save_dlg_btn_save = save_dialog.getchild(gnome_constants.GE_SAVE_DLG_BTN_SAVE)691 save_dlg_btn_save = save_dialog.getchild(self.__class__.SAVE_DLG_BTN_SAVE)
628 except ldtp.LdtpExecutionError:692 except ldtp.LdtpExecutionError:
629 raise ldtp.LdtpExecutionError, "The save button in Gedit save dialog was not found."693 raise ldtp.LdtpExecutionError, "The save button in Gedit save dialog was not found."
630 694
@@ -633,11 +697,11 @@
633 except ldtp.LdtpExecutionError:697 except ldtp.LdtpExecutionError:
634 raise ldtp.LdtpExecutionError, "There was an error when pushing the Save button."698 raise ldtp.LdtpExecutionError, "There was an error when pushing the Save button."
635699
636 ldtp.waittillguinotexist(gnome_constants.GE_SAVE_DLG)700 ldtp.waittillguinotexist(self.__class__.SAVE_DLG)
637 701
638 else:702 else:
639 try:703 try:
640 question_dlg_btn_close = question_dialog.getchild(gnome_constants.GE_QUESTION_DLG_BTN_CLOSE)704 question_dlg_btn_close = question_dialog.getchild(self.__class__.QUESTION_DLG_BTN_CLOSE)
641 question_dlg_btn_close.click()705 question_dlg_btn_close.click()
642 except ldtp.LdtpExecutionError:706 except ldtp.LdtpExecutionError:
643 raise ldtp.LdtpExecutionError, "It was not possible to click the close button."707 raise ldtp.LdtpExecutionError, "It was not possible to click the close button."
@@ -648,7 +712,12 @@
648 """712 """
649 PolicyKit class manages the GNOME pop up that ask for password for admin activities.713 PolicyKit class manages the GNOME pop up that ask for password for admin activities.
650 """714 """
651 715 WINDOW = "dlg0"
716 TXT_PASS = "txtPassword"
717 BTN_OK = "btnOK"
718 BTN_CANCEL = "btnCancel"
719
720
652 def __init__(self, password):721 def __init__(self, password):
653 """722 """
654 UpdateManager class main constructor723 UpdateManager class main constructor
@@ -657,7 +726,7 @@
657 @param password: User's password for administrative tasks.726 @param password: User's password for administrative tasks.
658727
659 """728 """
660 Application.__init__(self, gnome_constants.SU_WINDOW)729 Application.__init__(self)
661 self.password = password730 self.password = password
662 731
663 def wait(self):732 def wait(self):
@@ -666,14 +735,14 @@
666735
667 @return 1, if the gksu window exists, 0 otherwise.736 @return 1, if the gksu window exists, 0 otherwise.
668 """737 """
669 return ldtp.waittillguiexist(gnome_constants.SU_WINDOW)738 return ldtp.waittillguiexist(self.name)
670 739
671 def set_password(self):740 def set_password(self):
672 """741 """
673 It enters the password in the text field and clicks enter. 742 It enters the password in the text field and clicks enter.
674 """743 """
675 744
676 ooldtp.context(gnome_constants.SU_WINDOW)745 ooldtp.context(self.name)
677 746
678 try:747 try:
679 ldtp.enterstring (self.password)748 ldtp.enterstring (self.password)
@@ -684,25 +753,25 @@
684 753
685# TODO: Change this to use ooldtp754# TODO: Change this to use ooldtp
686# try:755# try:
687# btnOK = polKit.getchild(gnome_constants.SU_BTN_OK)756# btnOK = polKit.getchild(self.__class__.BTN_OK)
688# except ldtp.LdtpExecutionError, msg:757# except ldtp.LdtpExecutionError, msg:
689# raise ldtp.LdtpExecutionError, "The GtkSudo OK button was not found."758# raise ldtp.LdtpExecutionError, "The GtkSudo OK button was not found."
690# 759#
691# btnOK.click()760# btnOK.click()
692 761
693 #This also have problems because of the lack of accesibiliy information762 #This also have problems because of the lack of accesibiliy information
694 #ldtp.waittillguinotexist (gnome_constants.SU_WINDOW)763 #ldtp.waittillguinotexist (self.name)
695 764
696 def cancel(self):765 def cancel(self):
697 polKit = ooldtp.context(gnome_constants.SU_WINDOW)766 polKit = ooldtp.context(self.name)
698767
699 try:768 try:
700 cancelButton = polKit.getchild(gnome_constants.SU_BTN_CANCEL)769 cancelButton = polKit.getchild(self.__class__.BTN_CANCEL)
701 except ldtp.LdtpExecutionError:770 except ldtp.LdtpExecutionError:
702 raise ldtp.LdtpExecutionError, "The PolicyKit cancel button was not found."771 raise ldtp.LdtpExecutionError, "The PolicyKit cancel button was not found."
703 772
704 cancelButton.click()773 cancelButton.click()
705 ldtp.waittillguinotexist (gnome_constants.SU_WINDOW)774 ldtp.waittillguinotexist (self.name)
706 775
707776
708 777
709778
=== removed file 'desktoptesting/gnome_constants.py'
--- desktoptesting/gnome_constants.py 2009-03-19 10:47:43 +0000
+++ desktoptesting/gnome_constants.py 1970-01-01 00:00:00 +0000
@@ -1,58 +0,0 @@
1"""
2This is the "gnome_constants" module.
3
4The gnome_constants provides the "object map" to be used in gnome.py
5"""
6
7TOP_PANEL = 'frmTopExpandedEdgePanel'
8
9
10# GtkSudo Popup (prefix = SU)
11SU_WINDOW = "dlg0"
12SU_TXT_PASS = "txtPassword"
13SU_BTN_OK = "btnOK"
14SU_BTN_CANCEL = "btnCancel"
15
16# GEdit constants (prefix = GE)
17GE_WINDOW = "frm*gedit"
18GE_TXT_FIELD = "txt1"
19GE_LAUNCHER = "gedit"
20GE_SAVE_DLG = "dlgSave*"
21GE_SAVE_DLG_TXT_NAME = "txtName"
22GE_SAVE_DLG_BTN_SAVE = "btnSave"
23GE_QUESTION_DLG = "dlgQuestion"
24GE_QUESTION_DLG_BTN_SAVE = "btnSave"
25GE_QUESTION_DLG_BTN_SAVE_AS = "btnSaveAs"
26GE_QUESTION_DLG_BTN_CLOSE = "btnClosewithoutSaving"
27GE_MNU_QUIT = "mnuQuit"
28GE_MNU_CLOSE = "mnuClose"
29GE_MNU_NEW = "mnuNew"
30
31# Seahorse contants (prefix = SH)
32SH_WINDOW = "frmPasswordsandEncryptionKeys"
33SH_LAUNCHER = "seahorse"
34SH_MNU_NEWKEY = "mnuNew"
35SH_NEWKEY_DLG = "Create New ..."
36SH_BTN_CONTINUE = "btnContinue"
37SH_TYPE_PGP = "PGP Key"
38SH_NEWPGP_DLG = "dlgCreateaPGPKey"
39SH_DLG_NEWPGP_FULLNAME = "txtFullName"
40SH_DLG_NEWPGP_EMAIL = "txtEmailAddress"
41SH_DLG_NEWPGP_COMMENT = "txtComment"
42SH_BTN_NEWPGP_CREATE = "btnCreate"
43SH_DLG_NEWKEY_PASS = "dlgPassphrasefor*"
44SH_BTN_PASS_OK = "btnOK"
45SH_DLG_GENERATING_KEY = "dlgGeneratingkey"
46SH_DLG_CREATING_SSH = "dlgCreatingSecureShellKey"
47SH_TYPE_SSH = "Secure Shell Key"
48SH_NEWSSH_DLG = "New Secure Shell Key"
49SH_DLG_NEWSSH_DESC = "txtKeyDescription"
50SH_BTN_NEWSSH_CREATE_AND_SETUP = "Create and Set Up"
51SH_DLG_SET_UP = "Set Up Computer for SSH Connection"
52SH_TXT_SET_UP_COMPUTER = "txtThehostnameoraddressoftheserver."
53SH_TXT_SET_UP_LOGIN = "txtLoginName"
54SH_BTN_SET_UP = "btnSetUp"
55SH_BTN_NEWSSH_CREATE = "Just Create Key"
56SH_TAB_PERSONAL_KEYS = "My Personal Keys"
57SH_TAB_LIST = "ptl0"
58
590
=== modified file 'desktoptesting/ubuntu.py'
--- desktoptesting/ubuntu.py 2009-03-25 10:23:04 +0000
+++ desktoptesting/ubuntu.py 2009-03-30 10:11:44 +0000
@@ -5,7 +5,6 @@
5"""5"""
6import ooldtp 6import ooldtp
7import ldtp 7import ldtp
8import ubuntu_constants
9from desktoptesting.gnome import Application, PolicyKit8from desktoptesting.gnome import Application, PolicyKit
10import re9import re
1110
@@ -13,6 +12,7 @@
13 12
14 def setup(self):13 def setup(self):
15 pass14 pass
15
16 def teardown(self):16 def teardown(self):
17 self.cleanup() 17 self.cleanup()
1818
@@ -48,7 +48,7 @@
48 48
49 """49 """
50 50
51 topPanel = ooldtp.context(ubuntu_constants.TOP_PANEL)51 topPanel = ooldtp.context(self.__class__.TOP_PANEL)
52 52
53 try:53 try:
54 actualMenu = topPanel.getchild(menu_item_txt)54 actualMenu = topPanel.getchild(menu_item_txt)
@@ -73,6 +73,22 @@
73 73
74 i.e. C{updateManager = UpdateManager("my_password")}74 i.e. C{updateManager = UpdateManager("my_password")}
75 """75 """
76 MNU_ITEM = "mnuUpdateManager"
77 WINDOW = "frmUpdateManager"
78 LAUNCHER = "update-manager"
79 BTN_CLOSE = "btnClose"
80 BTN_CHECK = "btnCheck"
81 BTN_INSTALL = "btnInstallUpdates"
82 TBL_UPDATES = "updates"
83 BAN_LIST = " updates"
84 TAB_CHANGES = "Changes"
85 TXT_DESCRIPTION = "Description"
86 LBL_WAIT = "lblKeepyoursystemup-to-date"
87 LBL_UPTODATE = "lblYoursystemisup-to-date"
88 LBL_N_UPDATES = r'lblYoucaninstall(\d+)updates?'
89 LBL_DOWNLOADSIZE = r'lblDownloadsize((\d+)((\.)(\d+))?)(.*)'
90
91
76 92
77 def __init__(self, password = ""):93 def __init__(self, password = ""):
78 """94 """
@@ -87,7 +103,7 @@
87 @param password: User's password for administrative tasks.103 @param password: User's password for administrative tasks.
88104
89 """105 """
90 Application.__init__(self, ubuntu_constants.UM_WINDOW)106 Application.__init__(self)
91 self.password = password107 self.password = password
92 108
93 def setup(self):109 def setup(self):
@@ -110,17 +126,17 @@
110 """126 """
111127
112 if dist_upgrade:128 if dist_upgrade:
113 ldtp.launchapp(ubuntu_constants.UM_LAUNCHER, ['-d'], 0)129 ldtp.launchapp(self.__class__.LAUNCHER, ['-d'], 0)
114 response = ldtp.waittillguiexist(ubuntu_constants.UM_WINDOW, '', 20)130 response = ldtp.waittillguiexist(self.name, '', 20)
115 131
116 if response == 0:132 if response == 0:
117 raise ldtp.LdtpExecutionError, "The " + ubuntu_constants.UM_WINDOW + " window was not found." 133 raise ldtp.LdtpExecutionError, "The " + self.name + " window was not found."
118134
119 else:135 else:
120 self.open_and_check_app(ubuntu_constants.UM_LAUNCHER)136 self.open_and_check_app()
121137
122 # Wait the population of the list138 # Wait the population of the list
123 updateManager = ooldtp.context(ubuntu_constants.UM_WINDOW)139 updateManager = ooldtp.context(self.name)
124140
125 populating = True141 populating = True
126142
@@ -132,7 +148,7 @@
132 label = updateManager.getchild(role = 'label')148 label = updateManager.getchild(role = 'label')
133 for i in label:149 for i in label:
134 label_name = i.getName()150 label_name = i.getName()
135 if label_name == ubuntu_constants.UM_LBL_WAIT:151 if label_name == self.__class__.LBL_WAIT:
136 populating = True152 populating = True
137 153
138 except ldtp.LdtpExecutionError:154 except ldtp.LdtpExecutionError:
@@ -143,15 +159,15 @@
143 It closes the update-manager window using the close button.159 It closes the update-manager window using the close button.
144 """160 """
145161
146 updateManager = ooldtp.context(ubuntu_constants.UM_WINDOW)162 updateManager = ooldtp.context(self.name)
147 163
148 try:164 try:
149 closeButton = updateManager.getchild(ubuntu_constants.UM_BTN_CLOSE)165 closeButton = updateManager.getchild(self.__class__.BTN_CLOSE)
150 except ldtp.LdtpExecutionError:166 except ldtp.LdtpExecutionError:
151 raise ldtp.LdtpExecutionError, "The Update Manager Close button was not found."167 raise ldtp.LdtpExecutionError, "The Update Manager Close button was not found."
152 168
153 closeButton.click()169 closeButton.click()
154 ldtp.waittillguinotexist (ubuntu_constants.UM_WINDOW)170 ldtp.waittillguinotexist (self.name)
155 171
156 def number_updates(self):172 def number_updates(self):
157 """173 """
@@ -161,16 +177,16 @@
161 @return: An integer with the number of available updates.177 @return: An integer with the number of available updates.
162 178
163 """179 """
164 updateManager = ooldtp.context(ubuntu_constants.UM_WINDOW)180 updateManager = ooldtp.context(self.name)
165181
166 try:182 try:
167 label = updateManager.getchild(role = 'label')183 label = updateManager.getchild(role = 'label')
168 for i in label:184 for i in label:
169 label_name = i.getName()185 label_name = i.getName()
170 if label_name == ubuntu_constants.UM_LBL_UPTODATE:186 if label_name == self.__class__.LBL_UPTODATE:
171 return 0187 return 0
172 else:188 else:
173 groups = re.match(ubuntu_constants.UM_LBL_N_UPDATES, label_name)189 groups = re.match(self.__class__.LBL_N_UPDATES, label_name)
174 if groups:190 if groups:
175 number = groups.group(1)191 number = groups.group(1)
176 return int(number)192 return int(number)
@@ -186,13 +202,13 @@
186202
187 @return: A float with the download size in bytes 203 @return: A float with the download size in bytes
188 """204 """
189 updateManager = ooldtp.context(ubuntu_constants.UM_WINDOW) 205 updateManager = ooldtp.context(self.name)
190206
191 try:207 try:
192 label = updateManager.getchild(role = 'label')208 label = updateManager.getchild(role = 'label')
193 for i in label:209 for i in label:
194 label_name = i.getName()210 label_name = i.getName()
195 groups = re.match(ubuntu_constants.UM_LBL_DOWNLOADSIZE, label_name)211 groups = re.match(self.__class__.LBL_DOWNLOADSIZE, label_name)
196 212
197 if groups:213 if groups:
198 # Calculate size based on the tag after the number214 # Calculate size based on the tag after the number
@@ -220,10 +236,10 @@
220 """236 """
221 It selects all the available updates 237 It selects all the available updates
222 """238 """
223 updateManager = ooldtp.context(ubuntu_constants.UM_WINDOW) 239 updateManager = ooldtp.context(self.name)
224240
225 try:241 try:
226 table = updateManager.getchild(ubuntu_constants.UM_TBL_UPDATES, role = 'table')242 table = updateManager.getchild(self.__class__.TBL_UPDATES, role = 'table')
227 updates_table = table[0]243 updates_table = table[0]
228244
229 for i in range(0, updates_table.getrowcount(), 1):245 for i in range(0, updates_table.getrowcount(), 1):
@@ -238,10 +254,10 @@
238 """254 """
239 It unselects all the available updates 255 It unselects all the available updates
240 """256 """
241 updateManager = ooldtp.context(ubuntu_constants.UM_WINDOW) 257 updateManager = ooldtp.context(self.name)
242258
243 try:259 try:
244 table = updateManager.getchild(ubuntu_constants.UM_TBL_UPDATES, role = 'table')260 table = updateManager.getchild(self.__class__.TBL_UPDATES, role = 'table')
245 updates_table = table[0]261 updates_table = table[0]
246262
247 # TODO: When table admits right click, use the context menu263 # TODO: When table admits right click, use the context menu
@@ -266,18 +282,18 @@
266 @return: A list with the available updates282 @return: A list with the available updates
267 """283 """
268284
269 updateManager = ooldtp.context(ubuntu_constants.UM_WINDOW)285 updateManager = ooldtp.context(self.name)
270286
271 available_updates = []287 available_updates = []
272288
273 try:289 try:
274 table = updateManager.getchild(ubuntu_constants.UM_TBL_UPDATES, role = 'table')290 table = updateManager.getchild(self.__class__.TBL_UPDATES, role = 'table')
275 updates_table = table[0]291 updates_table = table[0]
276292
277 for i in range(0, updates_table.getrowcount(), 1):293 for i in range(0, updates_table.getrowcount(), 1):
278 text = updates_table.getcellvalue(i, 1)294 text = updates_table.getcellvalue(i, 1)
279 candidate = text.split('\n')[0]295 candidate = text.split('\n')[0]
280 if candidate.find(ubuntu_constants.UM_BAN_LIST) == -1:296 if candidate.find(self.__class__.BAN_LIST) == -1:
281 available_updates.append(candidate)297 available_updates.append(candidate)
282 ldtp.wait(1)298 ldtp.wait(1)
283 except ldtp.LdtpExecutionError:299 except ldtp.LdtpExecutionError:
@@ -293,10 +309,10 @@
293 @param name: The name of the package to select309 @param name: The name of the package to select
294 """310 """
295311
296 updateManager = ooldtp.context(ubuntu_constants.UM_WINDOW)312 updateManager = ooldtp.context(self.name)
297313
298 try:314 try:
299 table = updateManager.getchild(ubuntu_constants.UM_TBL_UPDATES, role = 'table')315 table = updateManager.getchild(self.__class__.TBL_UPDATES, role = 'table')
300 updates_table = table[0]316 updates_table = table[0]
301317
302 for i in range(0, updates_table.getrowcount(), 1):318 for i in range(0, updates_table.getrowcount(), 1):
@@ -317,10 +333,10 @@
317 @param name: The name of the package to select333 @param name: The name of the package to select
318 """334 """
319335
320 updateManager = ooldtp.context(ubuntu_constants.UM_WINDOW)336 updateManager = ooldtp.context(self.name)
321337
322 try:338 try:
323 table = updateManager.getchild(ubuntu_constants.UM_TBL_UPDATES, role = 'table')339 table = updateManager.getchild(self.__class__.TBL_UPDATES, role = 'table')
324 updates_table = table[0]340 updates_table = table[0]
325341
326 for i in range(0, updates_table.getrowcount(), 1):342 for i in range(0, updates_table.getrowcount(), 1):
@@ -342,7 +358,7 @@
342 """358 """
343359
344 try:360 try:
345 updateManager = ooldtp.context(ubuntu_constants.UM_WINDOW)361 updateManager = ooldtp.context(self.name)
346 except ldtp.LdtpExecutionError:362 except ldtp.LdtpExecutionError:
347 raise ldtp.LdtpExecutionError, "The Update Manager window was not found."363 raise ldtp.LdtpExecutionError, "The Update Manager window was not found."
348 364
@@ -354,7 +370,7 @@
354 polKit = PolicyKit(self.password)370 polKit = PolicyKit(self.password)
355371
356 try:372 try:
357 checkButton = updateManager.getchild(ubuntu_constants.UM_BTN_CHECK)373 checkButton = updateManager.getchild(self.__class__.BTN_CHECK)
358 except ldtp.LdtpExecutionError:374 except ldtp.LdtpExecutionError:
359 raise ldtp.LdtpExecutionError, "The Update Manager Check button was not found."375 raise ldtp.LdtpExecutionError, "The Update Manager Check button was not found."
360 376
@@ -377,7 +393,7 @@
377 """393 """
378394
379 try:395 try:
380 updateManager = ooldtp.context(ubuntu_constants.UM_WINDOW)396 updateManager = ooldtp.context(self.name)
381 except ldtp.LdtpExecutionError:397 except ldtp.LdtpExecutionError:
382 raise ldtp.LdtpExecutionError, "The Update Manager window was not found."398 raise ldtp.LdtpExecutionError, "The Update Manager window was not found."
383399
@@ -385,7 +401,7 @@
385 if self.number_updates() > 0:401 if self.number_updates() > 0:
386 402
387 try:403 try:
388 btnInstall = updateManager.getchild(ubuntu_constants.UM_BTN_INSTALL)404 btnInstall = updateManager.getchild(self.__class__.BTN_INSTALL)
389 except ldtp.LdtpExecutionError:405 except ldtp.LdtpExecutionError:
390 raise ldtp.LdtpExecutionError, "The Update Manager install button was not found."406 raise ldtp.LdtpExecutionError, "The Update Manager install button was not found."
391 407
@@ -403,7 +419,7 @@
403 419
404 # Wait for the the close button to be ready420 # Wait for the the close button to be ready
405 try:421 try:
406 btnClose = updateManager.getchild(ubuntu_constants.UM_BTN_CLOSE)422 btnClose = updateManager.getchild(self.__class__.BTN_CLOSE)
407 except ldtp.LdtpExecutionError:423 except ldtp.LdtpExecutionError:
408 raise ldtp.LdtpExecutionError, "The Update Manager Close button was not found."424 raise ldtp.LdtpExecutionError, "The Update Manager Close button was not found."
409 425
@@ -418,12 +434,12 @@
418 """434 """
419435
420 try:436 try:
421 updateManager = ooldtp.context(ubuntu_constants.UM_WINDOW)437 updateManager = ooldtp.context(self.name)
422 except ldtp.LdtpExecutionError:438 except ldtp.LdtpExecutionError:
423 raise ldtp.LdtpExecutionError, "The Update Manager window was not found."439 raise ldtp.LdtpExecutionError, "The Update Manager window was not found."
424 440
425 try:441 try:
426 btnTest = updateManager.getchild(ubuntu_constants.UM_BTN_INSTALL)442 btnTest = updateManager.getchild(self.__class__.BTN_INSTALL)
427 state = btnTest.stateenabled()443 state = btnTest.stateenabled()
428 except ldtp.LdtpExecutionError:444 except ldtp.LdtpExecutionError:
429 raise ldtp.LdtpExecutionError, "The install button was not found."445 raise ldtp.LdtpExecutionError, "The install button was not found."
@@ -455,7 +471,7 @@
455 @return: The decription of the packages, as shown in the application471 @return: The decription of the packages, as shown in the application
456 """472 """
457 try:473 try:
458 updateManager = ooldtp.context(ubuntu_constants.UM_WINDOW)474 updateManager = ooldtp.context(self.name)
459 except ldtp.LdtpExecutionError:475 except ldtp.LdtpExecutionError:
460 raise ldtp.LdtpExecutionError, "The Update Manager window was not found."476 raise ldtp.LdtpExecutionError, "The Update Manager window was not found."
461 477
@@ -464,9 +480,9 @@
464 self.select_update(name)480 self.select_update(name)
465481
466 # Get the description text field 482 # Get the description text field
467 text_field = updateManager.getchild(ubuntu_constants.UM_TXT_DESCRIPTION, role='text')483 text_field = updateManager.getchild(self.__class__.TXT_DESCRIPTION, role='text')
468 # Get the text 484 # Get the text
469 text = ldtp.gettextvalue(ubuntu_constants.UM_WINDOW, text_field[0].getName())485 text = ldtp.gettextvalue(self.name, text_field[0].getName())
470 return text486 return text
471 except ldtp.LdtpExecutionError:487 except ldtp.LdtpExecutionError:
472 raise ldtp.LdtpExecutionError, "The description text was not found."488 raise ldtp.LdtpExecutionError, "The description text was not found."
@@ -486,7 +502,7 @@
486 @return: The decription of the changes502 @return: The decription of the changes
487 """503 """
488 try:504 try:
489 ooldtp.context(ubuntu_constants.UM_WINDOW)505 ooldtp.context(self.name)
490 except ldtp.LdtpExecutionError:506 except ldtp.LdtpExecutionError:
491 raise ldtp.LdtpExecutionError, "The Update Manager window was not found."507 raise ldtp.LdtpExecutionError, "The Update Manager window was not found."
492 508
@@ -495,14 +511,14 @@
495 self.select_update(name)511 self.select_update(name)
496512
497 # Get the filler tab513 # Get the filler tab
498 filler = ldtp.getobjectproperty(ubuntu_constants.UM_WINDOW , ubuntu_constants.UM_TAB_CHANGES, 'children')514 filler = ldtp.getobjectproperty(self.name , self.__class__.TAB_CHANGES, 'children')
499 # Get the scroll pane515 # Get the scroll pane
500 scroll_pane = ldtp.getobjectproperty(ubuntu_constants.UM_WINDOW , filler, 'children')516 scroll_pane = ldtp.getobjectproperty(self.name , filler, 'children')
501 # Get the text field517 # Get the text field
502 text_field = ldtp.getobjectproperty(ubuntu_constants.UM_WINDOW , scroll_pane, 'children')518 text_field = ldtp.getobjectproperty(self.name , scroll_pane, 'children')
503 text_field = text_field.split(' ')[0]519 text_field = text_field.split(' ')[0]
504 # Get the text520 # Get the text
505 text = ldtp.gettextvalue(ubuntu_constants.UM_WINDOW, text_field)521 text = ldtp.gettextvalue(self.name, text_field)
506 return text522 return text
507 except ldtp.LdtpExecutionError:523 except ldtp.LdtpExecutionError:
508 raise ldtp.LdtpExecutionError, "The Changes tab was not found."524 raise ldtp.LdtpExecutionError, "The Changes tab was not found."
@@ -517,7 +533,7 @@
517 @param show: True, to show the description; False, to hide the description.533 @param show: True, to show the description; False, to hide the description.
518 """534 """
519 try:535 try:
520 updateManager = ooldtp.context(ubuntu_constants.UM_WINDOW)536 updateManager = ooldtp.context(self.name)
521 except ldtp.LdtpExecutionError:537 except ldtp.LdtpExecutionError:
522 raise ldtp.LdtpExecutionError, "The Update Manager window was not found."538 raise ldtp.LdtpExecutionError, "The Update Manager window was not found."
523 539
@@ -531,5 +547,3 @@
531 raise ldtp.LdtpExecutionError, "The description button was not found."547 raise ldtp.LdtpExecutionError, "The description button was not found."
532 548
533 return state549 return state
534
535
536550
=== removed file 'desktoptesting/ubuntu_constants.py'
--- desktoptesting/ubuntu_constants.py 2009-03-18 16:04:17 +0000
+++ desktoptesting/ubuntu_constants.py 1970-01-01 00:00:00 +0000
@@ -1,32 +0,0 @@
1"""
2This is the "ubuntu_constants" module.
3
4The ubuntu_constants provides the "object map" to be used in ubuntu.py
5"""
6
7TOP_PANEL = 'frmTopExpandedEdgePanel'
8
9
10# Update Manager constants (prefix = UM)
11UM_MNU_ITEM = "mnuUpdateManager"
12UM_WINDOW = "frmUpdateManager"
13UM_LAUNCHER = "update-manager"
14UM_BTN_CLOSE = "btnClose"
15UM_BTN_CHECK = "btnCheck"
16UM_BTN_INSTALL = "btnInstallUpdates"
17UM_TBL_UPDATES = "updates"
18UM_BAN_LIST = " updates"
19UM_TAB_CHANGES = "Changes"
20UM_TXT_DESCRIPTION = "Description"
21UM_LBL_WAIT = "lblKeepyoursystemup-to-date"
22UM_LBL_UPTODATE = "lblYoursystemisup-to-date"
23UM_LBL_N_UPDATES = r'lblYoucaninstall(\d+)updates?'
24UM_LBL_DOWNLOADSIZE = r'lblDownloadsize((\d+)((\.)(\d+))?)(.*)'
25
26# GtkSudo Popup (prefix = SU)
27SU_WINDOW = "dlg0"
28SU_TXT_PASS = "txtPassword"
29SU_BTN_OK = "btnOK"
30SU_BTN_CANCEL = "btnCancel"
31
32

Subscribers

People subscribed via source and target branches

to status/vote changes: