Merge lp:~udt-contributors/mago/test-suite-class into lp:~mago-contributors/mago/mago-1.0
- test-suite-class
- Merge into mago-1.0
Status: | Merged | ||||
---|---|---|---|---|---|
Merged at revision: | not available | ||||
Proposed branch: | lp:~udt-contributors/mago/test-suite-class | ||||
Merge into: | lp:~mago-contributors/mago/mago-1.0 | ||||
Diff against target: | None lines | ||||
To merge this branch: | bzr merge lp:~udt-contributors/mago/test-suite-class | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Ubuntu Desktop Testing Contributors | Pending | ||
Review via email: mp+5733@code.launchpad.net |
Commit message
Description of the change
Javier Collado (javier.collado) wrote : | # |
Ara Pulido (ara) wrote : | # |
setup.py should be changed in order to make it work again:http://
Apart of that I think that change is needed, but it makes the framework complexity grow a bit.
The design document should explain this very carefully.
Besides, I am not sure if the folder structure is the correct one. desktop testing should contain the testsuite folder? what the rest of the udt-contributors think?
Javier Collado (javier.collado) wrote : | # |
Hello,
The packages have been added to setup.py.
Regarding the growth of complexity, I agree that this is one of the consequences of the change, but in my opinion it's acceptable to avoid using applications and test suites as if they were the same thing since this is somewhat misleading.
The location of the test_suite folder makes sense to me because what I would do when writing a new test suite is importing something under desktoptesting.
Best regards,
Javier
- 67. By Eitan Isaacson
-
Changed screenshots to the following configuration:
- Compiz.
- 120 DPI.
- Default background. - 68. By Eitan Isaacson
-
Merge from trunk.
- 69. By Eitan Isaacson
-
sensible fail message when python-indicate is not present.
- 70. By Eitan Isaacson
-
added a w second event loop to show_indicator(), seems to do a better job than simply processing pending events.
- 71. By Eitan Isaacson
-
added dx suites to setup.py
- 72. By Ara Pulido
-
Merged from tweaks
- 73. By Ara Pulido
-
Merged from test-suite-class. Resolved a small conflict
- 74. By Eitan Isaacson
-
moved enable_a11y to the Application class.
- 75. By Eitan Isaacson
-
Adjusted DX tests for the new layout.
Preview Diff
1 | === added directory 'desktoptesting/application' |
2 | === added file 'desktoptesting/application/__init__.py' |
3 | --- desktoptesting/application/__init__.py 1970-01-01 00:00:00 +0000 |
4 | +++ desktoptesting/application/__init__.py 2009-04-21 09:58:40 +0000 |
5 | @@ -0,0 +1,6 @@ |
6 | +""" |
7 | +applicatoin package |
8 | + |
9 | +Classes that wrap application functionality to ease their testing |
10 | +""" |
11 | +__all__ = ['main', 'gnome', 'ubuntu'] |
12 | |
13 | === renamed file 'desktoptesting/gnome.py' => 'desktoptesting/application/gnome.py' |
14 | --- desktoptesting/gnome.py 2009-04-14 10:02:31 +0000 |
15 | +++ desktoptesting/application/gnome.py 2009-04-21 09:58:40 +0000 |
16 | @@ -3,158 +3,8 @@ |
17 | |
18 | The gnome module provides wrappers for LDTP to make the write of Gnome tests easier. |
19 | """ |
20 | -import ooldtp |
21 | -import ldtp |
22 | - |
23 | -class Application: |
24 | - """ |
25 | - Superclass for the rest of the applications |
26 | - |
27 | - Constants that should be defined in the classes that inherit from this class |
28 | - LAUNCHER: Argument to be passed when launching the application through ldtp.launchapp |
29 | - WINDOW: Top application frame pattern using ldtp syntax |
30 | - CLOSE_TYPE: Close object type (one of 'menu' or 'button') |
31 | - CLOSE_NAME: Close object name |
32 | - """ |
33 | - CLOSE_TYPE = 'menu' |
34 | - CLOSE_NAME = 'mnuQuit' |
35 | - WINDOW = '' |
36 | - TOP_PANEL = 'frmTopExpandedEdgePanel' |
37 | - |
38 | - |
39 | - def __init__(self, name = None, close_type= None, close_name= None): |
40 | - """ |
41 | - @type close_type: string |
42 | - @param close_type: The type of close widget of the application. Types: menu, button. |
43 | - @type close_name: string |
44 | - @param close_name: The name of the close widget of the application. If not mentioned the default will be used ("Quit") |
45 | - """ |
46 | - if name: |
47 | - self.name = name |
48 | - else: |
49 | - self.name = self.WINDOW |
50 | - |
51 | - if close_type: |
52 | - self.close_type = close_type |
53 | - else: |
54 | - self.close_type = self.CLOSE_TYPE |
55 | - |
56 | - if close_name: |
57 | - self.close_name = close_name |
58 | - else: |
59 | - self.close_name = self.CLOSE_NAME |
60 | - |
61 | - |
62 | - def setup(self): |
63 | - pass |
64 | - |
65 | - def teardown(self): |
66 | - pass |
67 | - |
68 | - def cleanup(self): |
69 | - self.set_name(self.WINDOW) |
70 | - self.set_close_type(self.CLOSE_TYPE) |
71 | - self.set_close_name(self.CLOSE_NAME) |
72 | - |
73 | - def recover(self): |
74 | - self.teardown() |
75 | - sleep(1) |
76 | - self.setup() |
77 | - |
78 | - def set_name(self, name): |
79 | - if name is not None: |
80 | - self.name = name |
81 | - |
82 | - def set_close_type(self, close_type): |
83 | - if close_type is not None: |
84 | - self.close_type = close_type |
85 | - |
86 | - def set_close_name(self, close_name): |
87 | - if close_name is not None: |
88 | - self.close_name = close_name |
89 | - |
90 | - def remap(self): |
91 | - """ |
92 | - It reloads the application map for the given ooldtp.context. |
93 | - """ |
94 | - ldtp.remap(self.name) |
95 | - |
96 | - def open(self): |
97 | - """ |
98 | - Given an application, it tries to open it. |
99 | - |
100 | - """ |
101 | - ldtp.launchapp(self.LAUNCHER) |
102 | - |
103 | - ldtp.wait(2) |
104 | - response = ldtp.waittillguiexist(self.name, '', 20) |
105 | - |
106 | - if response == 0: |
107 | - raise ldtp.LdtpExecutionError, "The " + self.name + " window was not found." |
108 | - |
109 | - def close(self): |
110 | - """ |
111 | - Given an application, it tries to close it. |
112 | - """ |
113 | - try: |
114 | - app = ooldtp.context(self.name) |
115 | - try: |
116 | - close_widget = app.getchild(self.close_name) |
117 | - except ldtp.LdtpExecutionError: |
118 | - raise ldtp.LdtpExecutionError, "The " + self.close_name + " widget was not found." |
119 | - |
120 | - if self.close_type == 'menu': |
121 | - close_widget.selectmenuitem() |
122 | - elif self.close_type == 'button': |
123 | - close_widget.click() |
124 | - else: |
125 | - raise ldtp.LdtpExecutionError, "Wrong close item type." |
126 | - response = ldtp.waittillguinotexist(self.name, '', 20) |
127 | - if response == 0: |
128 | - raise ldtp.LdtpExecutionError, "Mmm, something went wrong when closing the application." |
129 | - except ldtp.LdtpExecutionError, msg: |
130 | - raise ldtp.LdtpExecutionError, "Mmm, something went wrong when closing the application: " + str(msg) |
131 | - |
132 | - def save(self, save_menu='mnuSave'): |
133 | - """ |
134 | - Given an application, it tries to save the current document. |
135 | - This method gives very basic functionality. Please, override this method in the subclasses for error checking. |
136 | - |
137 | - @type save_menu: string |
138 | - @param save_menu: The name of the Save menu of the application. If not mentioned the default will be used ("Save"). |
139 | - """ |
140 | - try: |
141 | - app = ooldtp.context(self.name) |
142 | - try: |
143 | - actualMenu = app.getchild(save_menu) |
144 | - except ldtp.LdtpExecutionError: |
145 | - raise ldtp.LdtpExecutionError, "The " + save_menu + " menu was not found." |
146 | - |
147 | - actualMenu.selectmenuitem() |
148 | - except ldtp.LdtpExecutionError: |
149 | - raise ldtp.LdtpExecutionError, "Mmm, something went wrong when saving the current document." |
150 | - |
151 | - def write_text(self, text, txt_field=''): |
152 | - """ |
153 | - Given an application it tries to write text to its current buffer. |
154 | - """ |
155 | - app = ooldtp.context(self.name) |
156 | - |
157 | - if txt_field == '': |
158 | - try: |
159 | - ldtp.enterstring(text) |
160 | - except ldtp.LdtpExecutionError: |
161 | - raise ldtp.LdtpExecutionError, "We couldn't write text." |
162 | - else: |
163 | - try: |
164 | - app_txt_field = app.getchild(txt_field) |
165 | - except ldtp.LdtpExecutionError: |
166 | - raise ldtp.LdtpExecutionError, "The " + txt_field + " text field was not found." |
167 | - try: |
168 | - app_txt_field.settextvalue(text) |
169 | - except ldtp.LdtpExecutionError: |
170 | - raise ldtp.LdtpExecutionError, "We couldn't write text." |
171 | - |
172 | +import ldtp, ooldtp |
173 | +from .main import Application |
174 | |
175 | class Seahorse(Application): |
176 | """ |
177 | @@ -187,19 +37,10 @@ |
178 | TAB_PERSONAL_KEYS = "My Personal Keys" |
179 | TAB_LIST = "ptl0" |
180 | |
181 | + |
182 | def __init__(self): |
183 | Application.__init__(self) |
184 | |
185 | - def setup(self): |
186 | - self.open() |
187 | - |
188 | - def teardown(self): |
189 | - self.close() |
190 | - |
191 | - def cleanup(self): |
192 | - #TODO: it should delete all the "My Personal Keys" |
193 | - pass |
194 | - |
195 | |
196 | def new_key(self, key_type): |
197 | """ |
198 | @@ -528,44 +369,6 @@ |
199 | def __init__(self): |
200 | Application.__init__(self) |
201 | |
202 | - def setup(self): |
203 | - self.open() |
204 | - |
205 | - def teardown(self): |
206 | - self.close() |
207 | - |
208 | - def cleanup(self): |
209 | - # Exit using the Quit menu |
210 | - try: |
211 | - try: |
212 | - gedit = ooldtp.context(self.name) |
213 | - quit_menu = gedit.getchild(self.MNU_CLOSE) |
214 | - except ldtp.LdtpExecutionError: |
215 | - raise ldtp.LdtpExecutionError, "The quit menu was not found." |
216 | - quit_menu.selectmenuitem() |
217 | - except ldtp.LdtpExecutionError: |
218 | - raise ldtp.LdtpExecutionError, "Mmm, something went wrong when closing the application." |
219 | - |
220 | - result = ldtp.waittillguiexist(self.QUESTION_DLG, |
221 | - guiTimeOut = 2) |
222 | - |
223 | - if result == 1: |
224 | - question_dialog = ooldtp.context(self.QUESTION_DLG) |
225 | - question_dlg_btn_close = question_dialog.getchild(self.QUESTION_DLG_BTN_CLOSE) |
226 | - question_dlg_btn_close.click() |
227 | - |
228 | - try: |
229 | - gedit = ooldtp.context(self.name) |
230 | - new_menu = gedit.getchild(self.MNU_NEW) |
231 | - except ldtp.LdtpExecutionError: |
232 | - raise ldtp.LdtpExecutionError, "The new menu was not found." |
233 | - new_menu.selectmenuitem() |
234 | - |
235 | - result = ldtp.waittillguiexist( |
236 | - self.name, self.TXT_FIELD) |
237 | - if result != 1: |
238 | - raise ldtp.LdtpExecutionError, "Failed to set up new document." |
239 | - |
240 | |
241 | def write_text(self, text): |
242 | """ |
243 | @@ -760,7 +563,3 @@ |
244 | |
245 | cancelButton.click() |
246 | ldtp.waittillguinotexist (self.name) |
247 | - |
248 | - |
249 | - |
250 | - |
251 | |
252 | === added file 'desktoptesting/application/main.py' |
253 | --- desktoptesting/application/main.py 1970-01-01 00:00:00 +0000 |
254 | +++ desktoptesting/application/main.py 2009-04-21 09:58:40 +0000 |
255 | @@ -0,0 +1,138 @@ |
256 | +""" |
257 | +main module contains the definition of the main Application class |
258 | +that is used to wrap applications functionality |
259 | +""" |
260 | +import ldtp, ooldtp |
261 | + |
262 | +class Application: |
263 | + """ |
264 | + Superclass for the rest of the applications |
265 | + |
266 | + Constants that should be defined in the classes that inherit from this class |
267 | + LAUNCHER: Argument to be passed when launching the application through ldtp.launchapp |
268 | + WINDOW: Top application frame pattern using ldtp syntax |
269 | + CLOSE_TYPE: Close object type (one of 'menu' or 'button') |
270 | + CLOSE_NAME: Close object name |
271 | + """ |
272 | + CLOSE_TYPE = 'menu' |
273 | + CLOSE_NAME = 'mnuQuit' |
274 | + WINDOW = '' |
275 | + TOP_PANEL = 'frmTopExpandedEdgePanel' |
276 | + |
277 | + |
278 | + def __init__(self, name = None, close_type= None, close_name= None): |
279 | + """ |
280 | + @type close_type: string |
281 | + @param close_type: The type of close widget of the application. Types: menu, button. |
282 | + @type close_name: string |
283 | + @param close_name: The name of the close widget of the application. If not mentioned the default will be used ("Quit") |
284 | + """ |
285 | + if name: |
286 | + self.name = name |
287 | + else: |
288 | + self.name = self.WINDOW |
289 | + |
290 | + if close_type: |
291 | + self.close_type = close_type |
292 | + else: |
293 | + self.close_type = self.CLOSE_TYPE |
294 | + |
295 | + if close_name: |
296 | + self.close_name = close_name |
297 | + else: |
298 | + self.close_name = self.CLOSE_NAME |
299 | + |
300 | + |
301 | + def set_name(self, name): |
302 | + if name is not None: |
303 | + self.name = name |
304 | + |
305 | + def set_close_type(self, close_type): |
306 | + if close_type is not None: |
307 | + self.close_type = close_type |
308 | + |
309 | + def set_close_name(self, close_name): |
310 | + if close_name is not None: |
311 | + self.close_name = close_name |
312 | + |
313 | + def remap(self): |
314 | + """ |
315 | + It reloads the application map for the given ooldtp.context. |
316 | + """ |
317 | + ldtp.remap(self.name) |
318 | + |
319 | + def open(self): |
320 | + """ |
321 | + Given an application, it tries to open it. |
322 | + |
323 | + """ |
324 | + ldtp.launchapp(self.LAUNCHER) |
325 | + |
326 | + ldtp.wait(2) |
327 | + response = ldtp.waittillguiexist(self.name, '', 20) |
328 | + |
329 | + if response == 0: |
330 | + raise ldtp.LdtpExecutionError, "The " + self.name + " window was not found." |
331 | + |
332 | + def close(self): |
333 | + """ |
334 | + Given an application, it tries to close it. |
335 | + """ |
336 | + try: |
337 | + app = ooldtp.context(self.name) |
338 | + try: |
339 | + close_widget = app.getchild(self.close_name) |
340 | + except ldtp.LdtpExecutionError: |
341 | + raise ldtp.LdtpExecutionError, "The " + self.close_name + " widget was not found." |
342 | + |
343 | + if self.close_type == 'menu': |
344 | + close_widget.selectmenuitem() |
345 | + elif self.close_type == 'button': |
346 | + close_widget.click() |
347 | + else: |
348 | + raise ldtp.LdtpExecutionError, "Wrong close item type." |
349 | + response = ldtp.waittillguinotexist(self.name, '', 20) |
350 | + if response == 0: |
351 | + raise ldtp.LdtpExecutionError, "Mmm, something went wrong when closing the application." |
352 | + except ldtp.LdtpExecutionError, msg: |
353 | + raise ldtp.LdtpExecutionError, "Mmm, something went wrong when closing the application: " + str(msg) |
354 | + |
355 | + def save(self, save_menu='mnuSave'): |
356 | + """ |
357 | + Given an application, it tries to save the current document. |
358 | + This method gives very basic functionality. Please, override this method in the subclasses for error checking. |
359 | + |
360 | + @type save_menu: string |
361 | + @param save_menu: The name of the Save menu of the application. If not mentioned the default will be used ("Save"). |
362 | + """ |
363 | + try: |
364 | + app = ooldtp.context(self.name) |
365 | + try: |
366 | + actualMenu = app.getchild(save_menu) |
367 | + except ldtp.LdtpExecutionError: |
368 | + raise ldtp.LdtpExecutionError, "The " + save_menu + " menu was not found." |
369 | + |
370 | + actualMenu.selectmenuitem() |
371 | + except ldtp.LdtpExecutionError: |
372 | + raise ldtp.LdtpExecutionError, "Mmm, something went wrong when saving the current document." |
373 | + |
374 | + def write_text(self, text, txt_field=''): |
375 | + """ |
376 | + Given an application it tries to write text to its current buffer. |
377 | + """ |
378 | + app = ooldtp.context(self.name) |
379 | + |
380 | + if txt_field == '': |
381 | + try: |
382 | + ldtp.enterstring(text) |
383 | + except ldtp.LdtpExecutionError: |
384 | + raise ldtp.LdtpExecutionError, "We couldn't write text." |
385 | + else: |
386 | + try: |
387 | + app_txt_field = app.getchild(txt_field) |
388 | + except ldtp.LdtpExecutionError: |
389 | + raise ldtp.LdtpExecutionError, "The " + txt_field + " text field was not found." |
390 | + try: |
391 | + app_txt_field.settextvalue(text) |
392 | + except ldtp.LdtpExecutionError: |
393 | + raise ldtp.LdtpExecutionError, "We couldn't write text." |
394 | |
395 | === renamed file 'desktoptesting/ubuntu.py' => 'desktoptesting/application/ubuntu.py' |
396 | --- desktoptesting/ubuntu.py 2009-04-14 10:02:31 +0000 |
397 | +++ desktoptesting/application/ubuntu.py 2009-04-21 09:58:40 +0000 |
398 | @@ -3,23 +3,13 @@ |
399 | |
400 | The ubuntu module provides wrappers for LDTP to make the write of Ubuntu tests easier. |
401 | """ |
402 | -import ooldtp |
403 | -import ldtp |
404 | -from desktoptesting.gnome import Application, PolicyKit |
405 | +import ldtp , ooldtp |
406 | import re |
407 | |
408 | +from .main import Application |
409 | +from .gnome import PolicyKit |
410 | + |
411 | class UbuntuMenu(Application): |
412 | - |
413 | - def setup(self): |
414 | - pass |
415 | - |
416 | - def teardown(self): |
417 | - self.cleanup() |
418 | - |
419 | - def cleanup(self): |
420 | - self.close() |
421 | - Application.cleanup(self) |
422 | - |
423 | def open_and_check_menu_item(self, menu_item_txt): |
424 | """ |
425 | Given a menu item, it tries to open the application associated with it. |
426 | |
427 | === added directory 'desktoptesting/test_suite' |
428 | === added file 'desktoptesting/test_suite/__init__.py' |
429 | --- desktoptesting/test_suite/__init__.py 1970-01-01 00:00:00 +0000 |
430 | +++ desktoptesting/test_suite/__init__.py 2009-04-21 09:58:40 +0000 |
431 | @@ -0,0 +1,6 @@ |
432 | +""" |
433 | +test_suite package |
434 | + |
435 | +Test suite classes that implement setup/teardown/cleanup methods |
436 | +""" |
437 | +__all__ = ['main', 'gnome', 'ubuntu'] |
438 | |
439 | === added file 'desktoptesting/test_suite/gnome.py' |
440 | --- desktoptesting/test_suite/gnome.py 1970-01-01 00:00:00 +0000 |
441 | +++ desktoptesting/test_suite/gnome.py 2009-04-21 10:15:09 +0000 |
442 | @@ -0,0 +1,70 @@ |
443 | +""" |
444 | +gnome module contains the definition of the test suites used for gnome |
445 | +applications |
446 | +""" |
447 | +import ldtp, ooldtp |
448 | +from .main import SingleApplicationTestSuite |
449 | +from ..application.gnome import Application, Seahorse, GEdit |
450 | + |
451 | +class SeahorseTestSuite(SingleApplicationTestSuite): |
452 | + """ |
453 | + Default test suite for Seahorse |
454 | + """ |
455 | + def __init__(self): |
456 | + SingleApplicationTestSuite.__init__(self, Seahorse) |
457 | + |
458 | + def setup(self): |
459 | + self.application.open() |
460 | + |
461 | + def teardown(self): |
462 | + self.application.close() |
463 | + |
464 | + def cleanup(self): |
465 | + #TODO: it should delete all the "My Personal Keys" |
466 | + pass |
467 | + |
468 | + |
469 | +class GEditTestSuite(SingleApplicationTestSuite): |
470 | + """ |
471 | + Default test suite for GEdit |
472 | + """ |
473 | + def __init__(self): |
474 | + SingleApplicationTestSuite.__init__(self, GEdit) |
475 | + |
476 | + def setup(self): |
477 | + self.application.open() |
478 | + |
479 | + def teardown(self): |
480 | + self.application.close() |
481 | + |
482 | + def cleanup(self): |
483 | + # Exit using the Quit menu |
484 | + try: |
485 | + try: |
486 | + gedit = ooldtp.context(self.application.name) |
487 | + quit_menu = gedit.getchild(self.application.MNU_CLOSE) |
488 | + except ldtp.LdtpExecutionError: |
489 | + raise ldtp.LdtpExecutionError, "The quit menu was not found." |
490 | + quit_menu.selectmenuitem() |
491 | + except ldtp.LdtpExecutionError: |
492 | + raise ldtp.LdtpExecutionError, "Mmm, something went wrong when closing the application." |
493 | + |
494 | + result = ldtp.waittillguiexist(self.application.QUESTION_DLG, |
495 | + guiTimeOut = 2) |
496 | + |
497 | + if result == 1: |
498 | + question_dialog = ooldtp.context(self.application.QUESTION_DLG) |
499 | + question_dlg_btn_close = question_dialog.getchild(self.application.QUESTION_DLG_BTN_CLOSE) |
500 | + question_dlg_btn_close.click() |
501 | + |
502 | + try: |
503 | + gedit = ooldtp.context(self.application.name) |
504 | + new_menu = gedit.getchild(self.application.MNU_NEW) |
505 | + except ldtp.LdtpExecutionError: |
506 | + raise ldtp.LdtpExecutionError, "The new menu was not found." |
507 | + new_menu.selectmenuitem() |
508 | + |
509 | + result = ldtp.waittillguiexist( |
510 | + self.application.name, self.application.TXT_FIELD) |
511 | + if result != 1: |
512 | + raise ldtp.LdtpExecutionError, "Failed to set up new document." |
513 | |
514 | === added file 'desktoptesting/test_suite/main.py' |
515 | --- desktoptesting/test_suite/main.py 1970-01-01 00:00:00 +0000 |
516 | +++ desktoptesting/test_suite/main.py 2009-04-21 10:15:09 +0000 |
517 | @@ -0,0 +1,31 @@ |
518 | +""" |
519 | +test_suite module contains the definition of the TestSuite class that |
520 | +must be used by all test suites written for the desktoptesting package |
521 | +""" |
522 | +class TestSuite: |
523 | + """ |
524 | + TestSuite that implements all the test suite methods desired in a |
525 | + test suite |
526 | + """ |
527 | + def setup(self): |
528 | + pass |
529 | + |
530 | + def teardown(self): |
531 | + pass |
532 | + |
533 | + def cleanup(self): |
534 | + pass |
535 | + |
536 | + |
537 | +class SingleApplicationTestSuite(TestSuite): |
538 | + """ |
539 | + Test suite intended to make sure that a single application is |
540 | + running |
541 | + """ |
542 | + def __init__(self, application_factory): |
543 | + self.application = application_factory() |
544 | + |
545 | + def cleanup(self): |
546 | + self.application.set_name(self.application.WINDOW) |
547 | + self.application.set_close_type(self.application.CLOSE_TYPE) |
548 | + self.application.set_close_name(self.application.CLOSE_NAME) |
549 | |
550 | === added file 'desktoptesting/test_suite/ubuntu.py' |
551 | --- desktoptesting/test_suite/ubuntu.py 1970-01-01 00:00:00 +0000 |
552 | +++ desktoptesting/test_suite/ubuntu.py 2009-04-21 09:58:40 +0000 |
553 | @@ -0,0 +1,22 @@ |
554 | +""" |
555 | +ubuntu module contains the definition of the test suites used for ubuntu |
556 | +applications |
557 | +""" |
558 | +from .main import SingleApplicationTestSuite |
559 | +from ..application.ubuntu import UbuntuMenu, UpdateManager |
560 | + |
561 | +class UbuntuMenuTestSuite(SingleApplicationTestSuite): |
562 | + def __init__(self): |
563 | + SingleApplicationTestSuite.__init__(self, UbuntuMenu) |
564 | + |
565 | + def teardown(self): |
566 | + self.cleanup() |
567 | + |
568 | + def cleanup(self): |
569 | + self.application.close() |
570 | + SingleApplicationTestSuite.cleanup(self) |
571 | + |
572 | + |
573 | +class UpdateManagerTestSuite(SingleApplicationTestSuite): |
574 | + def __init__(self): |
575 | + SingleApplicationTestSuite.__init__(self, UpdateManager) |
576 | |
577 | === modified file 'gedit/gedit_chains.py' |
578 | --- gedit/gedit_chains.py 2009-03-11 16:35:00 +0000 |
579 | +++ gedit/gedit_chains.py 2009-04-21 10:15:09 +0000 |
580 | @@ -1,20 +1,16 @@ |
581 | # -*- coding: utf-8 -*- |
582 | - |
583 | -import ldtp |
584 | -import ldtputils |
585 | - |
586 | from time import time, gmtime, strftime |
587 | |
588 | -from desktoptesting.gnome import GEdit |
589 | +from desktoptesting.test_suite.gnome import GEditTestSuite |
590 | from desktoptesting.check import FileComparison, FAIL |
591 | |
592 | -class GEditChain(GEdit): |
593 | +class GEditChain(GEditTestSuite): |
594 | def testChain(self, oracle=None, chain=None): |
595 | test_file = strftime( |
596 | "/tmp/" + "%Y%m%d_%H%M%S" + ".txt", gmtime((time()))) |
597 | |
598 | - self.write_text(chain) |
599 | - self.save(test_file) |
600 | + self.application.write_text(chain) |
601 | + self.application.save(test_file) |
602 | |
603 | testcheck = FileComparison(oracle, test_file) |
604 | |
605 | |
606 | === modified file 'seahorse/generate_pgp.py' |
607 | --- seahorse/generate_pgp.py 2009-03-19 10:47:43 +0000 |
608 | +++ seahorse/generate_pgp.py 2009-04-21 10:15:09 +0000 |
609 | @@ -1,18 +1,9 @@ |
610 | -import ldtp |
611 | -import ldtputils |
612 | -from time import time |
613 | - |
614 | -from desktoptesting.gnome import Seahorse |
615 | - |
616 | +from desktoptesting.test_suite.gnome import SeahorseTestSuite |
617 | |
618 | -class SeahorsePGP(Seahorse): |
619 | +class SeahorsePGP(SeahorseTestSuite): |
620 | def test_generate_pgp(self, name, email, comment, passphrase): |
621 | - |
622 | # Open the update manager and check the repositories |
623 | - self.new_pgp_key(name, email, comment, passphrase) |
624 | + self.application.new_pgp_key(name, email, comment, passphrase) |
625 | |
626 | - if self.assert_exists_key(name) == False: |
627 | + if self.application.assert_exists_key(name) == False: |
628 | raise AssertionError, "The key was not succesfully created." |
629 | - |
630 | - |
631 | - |
632 | |
633 | === modified file 'seahorse/generate_ssh.py' |
634 | --- seahorse/generate_ssh.py 2009-03-18 16:15:59 +0000 |
635 | +++ seahorse/generate_ssh.py 2009-04-21 10:15:09 +0000 |
636 | @@ -1,15 +1,10 @@ |
637 | -import ldtp |
638 | -import ldtputils |
639 | -from time import time |
640 | - |
641 | -from desktoptesting.gnome import Seahorse |
642 | - |
643 | -class SeahorseSSH(Seahorse): |
644 | +from desktoptesting.test_suite.gnome import SeahorseTestSuite |
645 | + |
646 | +class SeahorseSSH(SeahorseTestSuite): |
647 | def test_generate_ssh(self, description, set_up, passphrase, computer='', login=''): |
648 | # Create the new key |
649 | - self.new_ssh_key(description, set_up, passphrase, computer, login) |
650 | + self.application.new_ssh_key(description, set_up, passphrase, computer, login) |
651 | |
652 | # Check that the key was successfully created |
653 | - if self.assert_exists_key(description) == False: |
654 | + if self.application.assert_exists_key(description) == False: |
655 | raise AssertionError, "The key was not succesfully created." |
656 | - |
657 | |
658 | === modified file 'ubuntu-menu/ubuntu_menu.py' |
659 | --- ubuntu-menu/ubuntu_menu.py 2009-03-23 10:53:02 +0000 |
660 | +++ ubuntu-menu/ubuntu_menu.py 2009-04-21 10:15:09 +0000 |
661 | @@ -1,19 +1,13 @@ |
662 | -import ldtp |
663 | -import ldtputils |
664 | -from time import time |
665 | - |
666 | -from desktoptesting.ubuntu import UbuntuMenu |
667 | - |
668 | -class UbuntuMenuTest(UbuntuMenu): |
669 | +from desktoptesting.test_suite.ubuntu import UbuntuMenuTestSuite |
670 | + |
671 | +class UbuntuMenuTest(UbuntuMenuTestSuite): |
672 | |
673 | def testOpenMenu(self, menuitem=None, windowname=None, closetype=None, closename=None): |
674 | - self.set_name(windowname) |
675 | - self.set_close_type(closetype) |
676 | - self.set_close_name(closename) |
677 | - self.open_and_check_menu_item(menuitem) |
678 | + self.application.set_name(windowname) |
679 | + self.application.set_close_type(closetype) |
680 | + self.application.set_close_name(closename) |
681 | + self.application.open_and_check_menu_item(menuitem) |
682 | |
683 | if __name__ == "__main__": |
684 | ubuntu_menu_test = UbuntuMenuTest() |
685 | ubuntu_menu_test.run() |
686 | - |
687 | - |
688 | |
689 | === modified file 'update-manager/update_manager.py' |
690 | --- update-manager/update_manager.py 2009-03-25 10:11:44 +0000 |
691 | +++ update-manager/update_manager.py 2009-04-21 10:15:09 +0000 |
692 | @@ -1,26 +1,22 @@ |
693 | -import ldtp |
694 | -import ldtputils |
695 | - |
696 | -from desktoptesting.ubuntu import UpdateManager |
697 | - |
698 | -class UpdateManagerTest(UpdateManager): |
699 | +from desktoptesting.test_suite.ubuntu import UpdateManagerTestSuite |
700 | + |
701 | +class UpdateManagerTest(UpdateManagerTestSuite): |
702 | def test_update_first(self, password): |
703 | - |
704 | - self.set_password(password) |
705 | - |
706 | - self.check_updates() |
707 | - list = self.get_available_updates() |
708 | + self.application.set_password(password) |
709 | + |
710 | + self.application.check_updates() |
711 | + list = self.application.get_available_updates() |
712 | |
713 | # If there is any update, select the first one |
714 | if len(list) > 0: |
715 | name = list[0] |
716 | - self.unselect_all() |
717 | - self.tick_update(name) |
718 | - self.install_updates() |
719 | + self.application.unselect_all() |
720 | + self.application.tick_update(name) |
721 | + self.application.install_updates() |
722 | |
723 | |
724 | # Check again the list of updates |
725 | - list = self.get_available_updates() |
726 | + list = self.application.get_available_updates() |
727 | |
728 | # If the updated package is still in the list of |
729 | # updates, the mark the test as failed. |
730 | @@ -29,14 +25,14 @@ |
731 | |
732 | def test_update_none(self, password): |
733 | |
734 | - self.set_password(password) |
735 | + self.application.set_password(password) |
736 | |
737 | # Open the update manager and check the repositories |
738 | - self.check_updates() |
739 | - n_updates = self.number_updates() |
740 | + self.application.check_updates() |
741 | + n_updates = self.application.number_updates() |
742 | |
743 | - self.check_updates() |
744 | - n_updates2 = self.number_updates() |
745 | + self.application.check_updates() |
746 | + n_updates2 = self.application.number_updates() |
747 | |
748 | |
749 | # If the number of updates differ, the mark the test as failed. |
750 | @@ -45,13 +41,13 @@ |
751 | |
752 | def test_unselect_all(self): |
753 | |
754 | - size = self.download_size() |
755 | + size = self.application.download_size() |
756 | |
757 | if size > 0: |
758 | - self.unselect_all() |
759 | - self.remap() |
760 | + self.application.unselect_all() |
761 | + self.application.remap() |
762 | |
763 | - size = self.download_size() |
764 | + size = self.application.download_size() |
765 | |
766 | # Test size |
767 | if size > 0: |
768 | @@ -63,11 +59,11 @@ |
769 | |
770 | def test_install_updates(self, password): |
771 | |
772 | - self.check_updates() |
773 | - self.install_updates() |
774 | + self.application.check_updates() |
775 | + self.application.install_updates() |
776 | |
777 | - self.remap() |
778 | - n_updates = self.number_updates() |
779 | + self.application.remap() |
780 | + n_updates = self.application.number_updates() |
781 | |
782 | if n_updates > 0: |
783 | raise AssertionError, 'Not all the updates were installed.' |
Hello,
This is the branch with the changes to separate Applications from TesSuites.
As you will see, the code has been refactored a little and now there are two new subpackages called application and test_suite containing the code for the Application and TestSuite classes. Each package includes the following modules:
- main: Main definitions with code that applies to both gnome and ubuntu
- gnome: Definitions for gnome applications
- ubuntu: Definitions for ubuntu applications
In the main module in the test_suite package two classes are defined: TestSuite and SingleApplicati onTestSuite. When using the latter, the application object is created and stored as self.application in the test suite object so in test cases code almost every reference to self.xxxx had to be changed to self.application. Aside from that, the code should be working the same way as before this change.
For test suites that need multiple applications to be tested at the same time, no class has been defined at the moment, but it should be straightforward once some requirements are defined.
Please let me know you comments/ suggestions about this change.
Best regards,
Javier