~renatofilho/address-book-app/address-book-app-wily

« back to all changes in this revision

Viewing changes to tests/autopilot/address_book_app/__init__.py

  • Committer: CI Train Bot
  • Author(s): Renato Araujo Oliveira Filho
  • Date: 2016-01-07 13:20:48 UTC
  • mfrom: (500.5.50 new-bottom-edge)
  • Revision ID: ci-train-bot@canonical.com-20160107132048-kb4u1crxh1cnxmyb
Implement the new bottom edge using the SDK component.

Show diffs side-by-side

added added

removed removed

Lines of Context:
125
125
        return None
126
126
 
127
127
    def click_action_button(self, action_name):
128
 
        actionbars = self.select_many('ActionBar', objectName='headerActionBar')
129
 
        for actionbar in actionbars:
130
 
            try:
131
 
                actionbar.click_action_button(action_name)
132
 
                return
133
 
            except ubuntuuitoolkit.ToolkitException:
134
 
                continue
135
 
        raise exceptions.StateNotFoundError('Action %s not found.' % action_name)
 
128
        actions = self.select_many(objectName='%s_button'%action_name)
 
129
        for action in actions:
 
130
           if action.enabled:
 
131
               self.pointing_device.click_object(action)
 
132
               return
 
133
 
 
134
        raise exceptions.StateNotFoundError(action_name)
136
135
 
137
136
    def open_header(self):
138
137
        header = self.get_header()
155
154
 
156
155
        return header
157
156
 
 
157
    def wait_bottom_edge(self, opened):
 
158
        # wait bottom edge to fully appear
 
159
        mainStack = self.wait_select_single(objectName='mainStack')
 
160
        mainStack.bottomEdgeOpened.wait_for(opened)
 
161
 
 
162
    def reveal_bottom_edge_page(self):
 
163
        flickable = self.get_contact_list_view()
 
164
 
 
165
        globalRect = flickable.globalRect
 
166
        start_x = globalRect.x + (globalRect.width * 0.5)
 
167
        start_y = globalRect.y + (flickable.height * 0.98)
 
168
        stop_y = globalRect.y + (flickable.height * 0.4)
 
169
 
 
170
        self.pointing_device.drag(
 
171
            start_x, start_y, start_x, stop_y, rate=5)
 
172
 
 
173
        # wait bottom edge to fully appear
 
174
        self.wait_bottom_edge(True)
 
175
 
158
176
    def cancel(self):
159
177
        """
160
178
        Press the 'Cancel' button
165
183
                self.pointing_device.click_object(button)
166
184
                return
167
185
 
 
186
        self.click_action_button('cancel')
168
187
        #self.click_action_button("customBackButton")
169
188
 
170
189
    def save(self):
200
219
        """
201
220
        Press the 'Add' button and return the contact editor page
202
221
        """
203
 
        bottom_swipe_page = self.get_contact_list_page()
204
 
        bottom_swipe_page.reveal_bottom_edge_page()
 
222
        self.reveal_bottom_edge_page()
205
223
 
206
224
        return self.get_contact_edit_page()