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

« back to all changes in this revision

Viewing changes to mago/application/main.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:
99
99
        """
100
100
        Given an application, it tries to close it.
101
101
        """
102
 
        try:
103
 
            app = ooldtp.context(self.name)
104
 
            try:
105
 
                close_widget = app.getchild(self.close_name)
106
 
            except ldtp.LdtpExecutionError:
107
 
                raise ldtp.LdtpExecutionError, "The " + self.close_name + " widget was not found."
 
102
        app = ooldtp.context(self.name)
 
103
        close_widget = app.getchild(self.close_name)
108
104
 
109
 
            if self.close_type == 'menu':
110
 
                close_widget.selectmenuitem()
111
 
            elif self.close_type == 'button':
112
 
                close_widget.click()
113
 
            else:
114
 
                raise ldtp.LdtpExecutionError, "Wrong close item type."
115
 
            response = ldtp.waittillguinotexist(self.name, '', 20)
116
 
            if response == 0:
117
 
                raise ldtp.LdtpExecutionError, "Mmm, something went wrong when closing the application."
118
 
        except ldtp.LdtpExecutionError, msg:
119
 
            raise ldtp.LdtpExecutionError, "Mmm, something went wrong when closing the application: " + str(msg)
 
105
        if self.close_type == 'menu':
 
106
            close_widget.selectmenuitem()
 
107
        elif self.close_type == 'button':
 
108
            close_widget.click()
 
109
        else:
 
110
            raise ldtp.LdtpExecutionError, "Wrong close item type."
 
111
        
 
112
        response = ldtp.waittillguinotexist(self.name, '', 20)
 
113
        if response == 0:
 
114
            raise ldtp.LdtpExecutionError, "Mmm, something went wrong when closing the application."
120
115
 
121
116
    def save(self, save_menu=_('mnuSave')):
122
117
        """
126
121
        @type save_menu: string
127
122
        @param save_menu: The name of the Save menu of the application. If not mentioned the default will be used ("Save").
128
123
        """
129
 
        try:
130
 
            app = ooldtp.context(self.name)
131
 
            try:
132
 
                actualMenu = app.getchild(save_menu)
133
 
            except ldtp.LdtpExecutionError:
134
 
                raise ldtp.LdtpExecutionError, "The " + save_menu + " menu was not found."
 
124
        app = ooldtp.context(self.name)
 
125
        actualMenu = app.getchild(save_menu)
135
126
 
136
 
            actualMenu.selectmenuitem()
137
 
        except ldtp.LdtpExecutionError:
138
 
            raise ldtp.LdtpExecutionError, "Mmm, something went wrong when saving the current document."
 
127
        actualMenu.selectmenuitem()
139
128
 
140
129
    def write_text(self, text, txt_field=''):
141
130
        """
144
133
        app = ooldtp.context(self.name)
145
134
 
146
135
        if txt_field == '':
147
 
            try:
148
 
                ldtp.enterstring(text)
149
 
            except ldtp.LdtpExecutionError:
150
 
                raise ldtp.LdtpExecutionError, "We couldn't write text."
 
136
            ldtp.enterstring(text)
151
137
        else:
152
 
            try:
153
 
                app_txt_fields = app.getchild(txt_field, "text")
154
 
            except ldtp.LdtpExecutionError:
155
 
                raise ldtp.LdtpExecutionError, "The " + txt_field + " text field was not found."
156
 
            try:
157
 
                for field in app_txt_fields:
158
 
                    field.settextvalue(text)
159
 
            except ldtp.LdtpExecutionError:
160
 
                raise ldtp.LdtpExecutionError, "We couldn't write text."
 
138
            app_txt_fields = app.getchild(txt_field, "text")
 
139
            for field in app_txt_fields:
 
140
                field.settextvalue(text)
161
141
 
162
142
    def _enable_a11y(self, enable):
163
143
        os.environ['NO_GAIL'] = str(int(not enable))