Merge lp:~elopio/ubuntu-ui-toolkit/fix1205205-actionselectionpopover_emulator into lp:ubuntu-ui-toolkit

Proposed by Leo Arias
Status: Merged
Approved by: Zsombor Egri
Approved revision: 687
Merged at revision: 685
Proposed branch: lp:~elopio/ubuntu-ui-toolkit/fix1205205-actionselectionpopover_emulator
Merge into: lp:ubuntu-ui-toolkit
Diff against target: 139 lines (+117/-0)
2 files modified
tests/autopilot/ubuntuuitoolkit/emulators.py (+43/-0)
tests/autopilot/ubuntuuitoolkit/tests/test_emulators.py (+74/-0)
To merge this branch: bzr merge lp:~elopio/ubuntu-ui-toolkit/fix1205205-actionselectionpopover_emulator
Reviewer Review Type Date Requested Status
PS Jenkins bot continuous-integration Approve
Ubuntu SDK team Pending
Review via email: mp+179312@code.launchpad.net

Commit message

Moved the ActionSelectionPopover autopilot emulator from the filemanager app. Added tests.

To post a comment you must log in.
686. By Leo Arias

Renamed the click button method of the popover, so it will be easier to deprecated when the bug is fixed.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
687. By Leo Arias

If the autoClose property is true, wait for the popover to disappear after clicking a button.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'tests/autopilot/ubuntuuitoolkit/emulators.py'
--- tests/autopilot/ubuntuuitoolkit/emulators.py 2013-08-07 17:33:32 +0000
+++ tests/autopilot/ubuntuuitoolkit/emulators.py 2013-08-09 08:04:48 +0000
@@ -152,6 +152,15 @@
152 raise ValueError(152 raise ValueError(
153 'Tab with objectName "{0}" not found.'.format(object_name))153 'Tab with objectName "{0}" not found.'.format(object_name))
154154
155 def get_action_selection_popover(self, object_name):
156 """Return an ActionSelectionPopover emulator.
157
158 :parameter object_name: The QML objectName property of the popover.
159
160 """
161 return self.select_single(
162 ActionSelectionPopover, objectName=object_name)
163
155164
156class Header(UbuntuUIToolkitEmulatorBase):165class Header(UbuntuUIToolkitEmulatorBase):
157 """Header Autopilot emulator."""166 """Header Autopilot emulator."""
@@ -235,3 +244,37 @@
235244
236 def _get_tab_buttons(self):245 def _get_tab_buttons(self):
237 return self.select_many('AbstractButton')246 return self.select_many('AbstractButton')
247
248
249class ActionSelectionPopover(UbuntuUIToolkitEmulatorBase):
250 """ActionSelectionPopover Autopilot emulator."""
251
252 def __init__(self, *args):
253 super(ActionSelectionPopover, self).__init__(*args)
254 self.pointing_device = get_pointing_device()
255
256 def click_button_by_text(self, text):
257 """Click a button on the popover.
258
259 XXX We are receiving the text because there's no way to set the
260 objectName on the action. This is reported at
261 https://bugs.launchpad.net/ubuntu-ui-toolkit/+bug/1205144
262 --elopio - 2013-07-25
263
264 :parameter text: The text of the button.
265
266 """
267 assert self.visible, 'The popover is not open.'
268 button = self._get_button(text)
269 if button is None:
270 raise ValueError(
271 'Button with text "{0}" not found.'.format(text))
272 self.pointing_device.click_object(button)
273 if self.autoClose:
274 self.visible.wait_for(False)
275
276 def _get_button(self, text):
277 buttons = self.select_many('Empty')
278 for button in buttons:
279 if button.text == text:
280 return button
238281
=== modified file 'tests/autopilot/ubuntuuitoolkit/tests/test_emulators.py'
--- tests/autopilot/ubuntuuitoolkit/tests/test_emulators.py 2013-08-07 17:33:32 +0000
+++ tests/autopilot/ubuntuuitoolkit/tests/test_emulators.py 2013-08-09 08:04:48 +0000
@@ -258,3 +258,77 @@
258 ValueError, self.main_view.switch_to_tab, 'unexisting')258 ValueError, self.main_view.switch_to_tab, 'unexisting')
259 self.assertEqual(259 self.assertEqual(
260 error.message, 'Tab with objectName "unexisting" not found.')260 error.message, 'Tab with objectName "unexisting" not found.')
261
262
263class ActionSelectionPopoverTestCase(tests.UbuntuUiToolkitTestCase):
264
265 test_qml = ("""
266import QtQuick 2.0
267import Ubuntu.Components 0.1
268import Ubuntu.Components.Popups 0.1
269
270MainView {
271 width: units.gu(48)
272 height: units.gu(60)
273
274 Button {
275 objectName: "open_popover"
276 text: "Open Popover"
277 onClicked: testActionsPopover.show();
278 }
279
280 Label {
281 id: "label"
282 objectName: "clicked_label"
283 anchors.centerIn: parent
284 text: "Button not clicked."
285 }
286
287 ActionSelectionPopover {
288 objectName: "test_actions_popover"
289 id: testActionsPopover
290 actions: ActionList {
291 Action {
292 text: "Action one"
293 onTriggered: label.text = "Button clicked."
294 }
295 }
296 }
297}
298""")
299
300 def test_action_selection_popover_emulator(self):
301 popover = self.main_view.get_action_selection_popover(
302 'test_actions_popover')
303 self.assertIsInstance(popover, emulators.ActionSelectionPopover)
304
305 def test_click_action_select_popover_button(self):
306 label = self.app.select_single('Label', objectName='clicked_label')
307 self.assertNotEqual(label.text, 'Button clicked.')
308 self._open_popover()
309 popover = self.main_view.get_action_selection_popover(
310 'test_actions_popover')
311 popover.click_button_by_text('Action one')
312 self.assertEqual(label.text, 'Button clicked.')
313
314 def _open_popover(self):
315 open_button = self.main_view.select_single(
316 'Button', objectName='open_popover')
317 self.pointing_device.click_object(open_button)
318
319 def test_click_unexisting_button(self):
320 self._open_popover()
321 popover = self.main_view.get_action_selection_popover(
322 'test_actions_popover')
323 error = self.assertRaises(
324 ValueError, popover.click_button_by_text, 'unexisting')
325 self.assertEqual(
326 error.message, 'Button with text "unexisting" not found.')
327
328 def test_click_button_with_closed_popover(self):
329 popover = self.main_view.get_action_selection_popover(
330 'test_actions_popover')
331 error = self.assertRaises(
332 AssertionError, popover.click_button_by_text, 'Action one')
333 self.assertEqual(
334 error.message, 'The popover is not open.')

Subscribers

People subscribed via source and target branches

to status/vote changes: