~ubuntu-branches/ubuntu/lucid/mago/lucid

« back to all changes in this revision

Viewing changes to mago/test_suite/gnome.py

  • Committer: Bazaar Package Importer
  • Author(s): Ara Pulido
  • Date: 2009-08-04 09:21:40 UTC
  • Revision ID: james.westby@ubuntu.com-20090804092140-mnc0rm2tr7smo107
Tags: upstream-0.1
ImportĀ upstreamĀ versionĀ 0.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
"""
 
2
gnome module contains the definition of the test suites used for gnome
 
3
applications
 
4
"""
 
5
import ldtp, ooldtp
 
6
from .main import SingleApplicationTestSuite
 
7
from ..application.gnome import Application, Seahorse, GEdit
 
8
 
 
9
class SeahorseTestSuite(SingleApplicationTestSuite):
 
10
    """
 
11
    Default test suite for Seahorse
 
12
    """
 
13
    APPLICATION_FACTORY = Seahorse
 
14
    def setup(self):
 
15
        self.application.open()
 
16
 
 
17
    def teardown(self):
 
18
        self.application.close()
 
19
 
 
20
    def cleanup(self):
 
21
        #TODO: it should delete all the "My Personal Keys"
 
22
        pass
 
23
 
 
24
 
 
25
class GEditTestSuite(SingleApplicationTestSuite):
 
26
    """
 
27
    Default test suite for GEdit
 
28
    """
 
29
    APPLICATION_FACTORY = GEdit
 
30
    def setup(self):
 
31
        self.application.open()
 
32
 
 
33
    def teardown(self):
 
34
        self.application.close()
 
35
 
 
36
    def cleanup(self):
 
37
        # Exit using the Quit menu 
 
38
        try:
 
39
            try:
 
40
                gedit = ooldtp.context(self.application.name)
 
41
                quit_menu = gedit.getchild(self.application.MNU_CLOSE)
 
42
            except ldtp.LdtpExecutionError:
 
43
                raise ldtp.LdtpExecutionError, "The quit menu was not found."
 
44
            quit_menu.selectmenuitem()
 
45
        except ldtp.LdtpExecutionError:
 
46
            raise ldtp.LdtpExecutionError, "Mmm, something went wrong when closing the application."
 
47
 
 
48
        result = ldtp.waittillguiexist(self.application.QUESTION_DLG,
 
49
                                       guiTimeOut = 2)
 
50
 
 
51
        if result == 1:
 
52
            question_dialog = ooldtp.context(self.application.QUESTION_DLG)
 
53
            question_dlg_btn_close = question_dialog.getchild(self.application.QUESTION_DLG_BTN_CLOSE)
 
54
            question_dlg_btn_close.click()
 
55
        
 
56
        try:
 
57
            gedit = ooldtp.context(self.application.name)
 
58
            new_menu = gedit.getchild(self.application.MNU_NEW)
 
59
        except ldtp.LdtpExecutionError:
 
60
            raise ldtp.LdtpExecutionError, "The new menu was not found."
 
61
        new_menu.selectmenuitem()
 
62
 
 
63
        result = ldtp.waittillguiexist(
 
64
            self.application.name, self.application.TXT_FIELD)
 
65
        if result != 1:
 
66
            raise ldtp.LdtpExecutionError, "Failed to set up new document."