Merge lp:~elopio/ubuntu-ui-toolkit/ap-toolbar-open-missing_tests into lp:~tpeeters/ubuntu-ui-toolkit/ap-toolbar-open

Proposed by Leo Arias
Status: Merged
Merged at revision: 834
Proposed branch: lp:~elopio/ubuntu-ui-toolkit/ap-toolbar-open-missing_tests
Merge into: lp:~tpeeters/ubuntu-ui-toolkit/ap-toolbar-open
Diff against target: 73 lines (+28/-9)
2 files modified
tests/autopilot/ubuntuuitoolkit/emulators.py (+8/-9)
tests/autopilot/ubuntuuitoolkit/tests/test_emulators.py (+20/-0)
To merge this branch: bzr merge lp:~elopio/ubuntu-ui-toolkit/ap-toolbar-open-missing_tests
Reviewer Review Type Date Requested Status
Tim Peeters Pending
Review via email: mp+194476@code.launchpad.net

Commit message

Added missing tests and fixed pep257.

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

We have just asked if the toolbar is opened, no need to open it again.

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-11-07 17:47:46 +0000
3+++ tests/autopilot/ubuntuuitoolkit/emulators.py 2013-11-08 10:00:48 +0000
4@@ -239,11 +239,12 @@
5 self.pointing_device.drag(line_x, start_y, line_x, stop_y)
6
7 def click_button(self, object_name):
8- """Click a button of the toolbar. The toolbar should be opened before
9- clicking the button, or an exception will be raised. If the toolbar
10- is closed for some reason (e.g., timer finishes) after moving the mouse cursor
11- and before clicking the button, it is re-opened automatically by
12- this function.
13+ """Click a button of the toolbar.
14+
15+ The toolbar should be opened before clicking the button, or an
16+ exception will be raised. If the toolbar is closed for some reason
17+ (e.g., timer finishes) after moving the mouse cursor and before
18+ clicking the button, it is re-opened automatically by this function.
19
20 :parameter object_name: The QML objectName property of the button.
21 :raise ToolkitEmulatorException: If there is no button with that object
22@@ -258,12 +259,10 @@
23 # ensure the toolbar is open
24 if not self.opened:
25 raise ToolkitEmulatorException(
26- 'Toolbar must be opened before calling click_button()')
27- self.open()
28+ 'Toolbar must be opened before calling click_button().')
29 self.pointing_device.move_to_object(button)
30 # ensure the toolbar is still open (may have closed due to timeout)
31- if not self.opened:
32- self.open()
33+ self.open()
34 # click the button
35 self.pointing_device.click_object(button)
36
37
38=== modified file 'tests/autopilot/ubuntuuitoolkit/tests/test_emulators.py'
39--- tests/autopilot/ubuntuuitoolkit/tests/test_emulators.py 2013-11-07 17:51:46 +0000
40+++ tests/autopilot/ubuntuuitoolkit/tests/test_emulators.py 2013-11-08 10:00:48 +0000
41@@ -61,6 +61,18 @@
42 toolbar = self.main_view.get_toolbar()
43 self.assertIsInstance(toolbar, emulators.Toolbar)
44
45+ def test_open_toolbar(self):
46+ with mock.patch.object(emulators.Toolbar, 'open') as mock_open:
47+ self.main_view.open_toolbar()
48+
49+ mock_open.assert_called_once_with()
50+
51+ def test_close_toolbar(self):
52+ with mock.patch.object(emulators.Toolbar, 'close') as mock_close:
53+ self.main_view.close_toolbar()
54+
55+ mock_close.assert_called_once_with()
56+
57 def test_open_toolbar_returns_the_toolbar(self):
58 toolbar = self.main_view.open_toolbar()
59 self.assertIsInstance(toolbar, emulators.Toolbar)
60@@ -187,6 +199,14 @@
61 self.assertEqual(
62 error.message, 'Button with objectName "unexisting" not found.')
63
64+ def test_click_button_on_closed_toolbar(self):
65+ error = self.assertRaises(
66+ emulators.ToolkitEmulatorException, self.toolbar.click_button,
67+ 'buttonName')
68+ self.assertEqual(
69+ error.message,
70+ 'Toolbar must be opened before calling click_button().')
71+
72
73 class TabsTestCase(tests.QMLStringAppTestCase):
74

Subscribers

People subscribed via source and target branches

to all changes: