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
1=== modified file 'tests/autopilot/ubuntuuitoolkit/emulators.py'
2--- tests/autopilot/ubuntuuitoolkit/emulators.py 2013-08-07 17:33:32 +0000
3+++ tests/autopilot/ubuntuuitoolkit/emulators.py 2013-08-09 08:04:48 +0000
4@@ -152,6 +152,15 @@
5 raise ValueError(
6 'Tab with objectName "{0}" not found.'.format(object_name))
7
8+ def get_action_selection_popover(self, object_name):
9+ """Return an ActionSelectionPopover emulator.
10+
11+ :parameter object_name: The QML objectName property of the popover.
12+
13+ """
14+ return self.select_single(
15+ ActionSelectionPopover, objectName=object_name)
16+
17
18 class Header(UbuntuUIToolkitEmulatorBase):
19 """Header Autopilot emulator."""
20@@ -235,3 +244,37 @@
21
22 def _get_tab_buttons(self):
23 return self.select_many('AbstractButton')
24+
25+
26+class ActionSelectionPopover(UbuntuUIToolkitEmulatorBase):
27+ """ActionSelectionPopover Autopilot emulator."""
28+
29+ def __init__(self, *args):
30+ super(ActionSelectionPopover, self).__init__(*args)
31+ self.pointing_device = get_pointing_device()
32+
33+ def click_button_by_text(self, text):
34+ """Click a button on the popover.
35+
36+ XXX We are receiving the text because there's no way to set the
37+ objectName on the action. This is reported at
38+ https://bugs.launchpad.net/ubuntu-ui-toolkit/+bug/1205144
39+ --elopio - 2013-07-25
40+
41+ :parameter text: The text of the button.
42+
43+ """
44+ assert self.visible, 'The popover is not open.'
45+ button = self._get_button(text)
46+ if button is None:
47+ raise ValueError(
48+ 'Button with text "{0}" not found.'.format(text))
49+ self.pointing_device.click_object(button)
50+ if self.autoClose:
51+ self.visible.wait_for(False)
52+
53+ def _get_button(self, text):
54+ buttons = self.select_many('Empty')
55+ for button in buttons:
56+ if button.text == text:
57+ return button
58
59=== modified file 'tests/autopilot/ubuntuuitoolkit/tests/test_emulators.py'
60--- tests/autopilot/ubuntuuitoolkit/tests/test_emulators.py 2013-08-07 17:33:32 +0000
61+++ tests/autopilot/ubuntuuitoolkit/tests/test_emulators.py 2013-08-09 08:04:48 +0000
62@@ -258,3 +258,77 @@
63 ValueError, self.main_view.switch_to_tab, 'unexisting')
64 self.assertEqual(
65 error.message, 'Tab with objectName "unexisting" not found.')
66+
67+
68+class ActionSelectionPopoverTestCase(tests.UbuntuUiToolkitTestCase):
69+
70+ test_qml = ("""
71+import QtQuick 2.0
72+import Ubuntu.Components 0.1
73+import Ubuntu.Components.Popups 0.1
74+
75+MainView {
76+ width: units.gu(48)
77+ height: units.gu(60)
78+
79+ Button {
80+ objectName: "open_popover"
81+ text: "Open Popover"
82+ onClicked: testActionsPopover.show();
83+ }
84+
85+ Label {
86+ id: "label"
87+ objectName: "clicked_label"
88+ anchors.centerIn: parent
89+ text: "Button not clicked."
90+ }
91+
92+ ActionSelectionPopover {
93+ objectName: "test_actions_popover"
94+ id: testActionsPopover
95+ actions: ActionList {
96+ Action {
97+ text: "Action one"
98+ onTriggered: label.text = "Button clicked."
99+ }
100+ }
101+ }
102+}
103+""")
104+
105+ def test_action_selection_popover_emulator(self):
106+ popover = self.main_view.get_action_selection_popover(
107+ 'test_actions_popover')
108+ self.assertIsInstance(popover, emulators.ActionSelectionPopover)
109+
110+ def test_click_action_select_popover_button(self):
111+ label = self.app.select_single('Label', objectName='clicked_label')
112+ self.assertNotEqual(label.text, 'Button clicked.')
113+ self._open_popover()
114+ popover = self.main_view.get_action_selection_popover(
115+ 'test_actions_popover')
116+ popover.click_button_by_text('Action one')
117+ self.assertEqual(label.text, 'Button clicked.')
118+
119+ def _open_popover(self):
120+ open_button = self.main_view.select_single(
121+ 'Button', objectName='open_popover')
122+ self.pointing_device.click_object(open_button)
123+
124+ def test_click_unexisting_button(self):
125+ self._open_popover()
126+ popover = self.main_view.get_action_selection_popover(
127+ 'test_actions_popover')
128+ error = self.assertRaises(
129+ ValueError, popover.click_button_by_text, 'unexisting')
130+ self.assertEqual(
131+ error.message, 'Button with text "unexisting" not found.')
132+
133+ def test_click_button_with_closed_popover(self):
134+ popover = self.main_view.get_action_selection_popover(
135+ 'test_actions_popover')
136+ error = self.assertRaises(
137+ AssertionError, popover.click_button_by_text, 'Action one')
138+ self.assertEqual(
139+ error.message, 'The popover is not open.')

Subscribers

People subscribed via source and target branches

to status/vote changes: