Merge lp:autopilot into lp:autopilot/1.6

Proposed by Santiago Baldassin
Status: Merged
Approved by: Richard Huddie
Approved revision: 593
Merged at revision: 586
Proposed branch: lp:autopilot
Merge into: lp:autopilot/1.6
Diff against target: 129 lines (+61/-6)
4 files modified
autopilot/display/__init__.py (+1/-1)
autopilot/input/__init__.py (+12/-4)
autopilot/tests/unit/test_display.py (+33/-0)
autopilot/tests/unit/test_input.py (+15/-1)
To merge this branch: bzr merge lp:autopilot
Reviewer Review Type Date Requested Status
Richard Huddie (community) Approve
Review via email: mp+319718@code.launchpad.net

Commit message

New release

Description of the change

New release

To post a comment you must log in.
Revision history for this message
Richard Huddie (rhuddie) wrote :

Code looks good.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'autopilot/display/__init__.py'
2--- autopilot/display/__init__.py 2016-11-22 13:12:14 +0000
3+++ autopilot/display/__init__.py 2017-03-13 16:42:57 +0000
4@@ -107,8 +107,8 @@
5 return Display()
6
7 backends = OrderedDict()
8+ backends['X11'] = get_x11_display
9 backends['UPA'] = get_upa_display
10- backends['X11'] = get_x11_display
11 return _pick_backend(backends, preferred_backend)
12
13 class BlacklistedDriverError(RuntimeError):
14
15=== modified file 'autopilot/input/__init__.py'
16--- autopilot/input/__init__.py 2016-11-22 12:42:52 +0000
17+++ autopilot/input/__init__.py 2017-03-13 16:42:57 +0000
18@@ -57,6 +57,9 @@
19
20 from collections import OrderedDict
21 from contextlib import contextmanager
22+
23+import psutil
24+
25 from autopilot.input._common import get_center_point
26 from autopilot.utilities import _pick_backend, CleanupRegistered
27
28@@ -119,16 +122,21 @@
29
30 def get_osk_kb():
31 try:
32- from autopilot.input._osk import Keyboard
33- return Keyboard()
34+ maliit = [p for p in
35+ psutil.process_iter() if p.name() == 'maliit-server']
36+ if maliit:
37+ from autopilot.input._osk import Keyboard
38+ return Keyboard()
39+ else:
40+ raise RuntimeError('maliit-server is not running')
41 except ImportError as e:
42 e.args += ("Unable to import the OSK backend",)
43 raise
44
45 backends = OrderedDict()
46+ backends['X11'] = get_x11_kb
47+ backends['OSK'] = get_osk_kb
48 backends['UInput'] = get_uinput_kb
49- backends['OSK'] = get_osk_kb
50- backends['X11'] = get_x11_kb
51 return _pick_backend(backends, preferred_backend)
52
53 @contextmanager
54
55=== added file 'autopilot/tests/unit/test_display.py'
56--- autopilot/tests/unit/test_display.py 1970-01-01 00:00:00 +0000
57+++ autopilot/tests/unit/test_display.py 2017-03-13 16:42:57 +0000
58@@ -0,0 +1,33 @@
59+# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
60+#
61+# Autopilot Functional Test Tool
62+# Copyright (C) 2016 Canonical
63+#
64+# This program is free software: you can redistribute it and/or modify
65+# it under the terms of the GNU General Public License as published by
66+# the Free Software Foundation, either version 3 of the License, or
67+# (at your option) any later version.
68+#
69+# This program is distributed in the hope that it will be useful,
70+# but WITHOUT ANY WARRANTY; without even the implied warranty of
71+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
72+# GNU General Public License for more details.
73+#
74+# You should have received a copy of the GNU General Public License
75+# along with this program. If not, see <http://www.gnu.org/licenses/>.
76+#
77+import unittest
78+from unittest.mock import patch
79+from autopilot.display import Display
80+
81+
82+class DisplayTestCase(unittest.TestCase):
83+
84+ @patch('autopilot.display._pick_backend')
85+ def test_input_backends_default_order(self, pick_backend):
86+ d = Display()
87+ d.create()
88+
89+ backends = list(pick_backend.call_args[0][0].items())
90+ self.assertTrue(backends[0][0] == 'X11')
91+ self.assertTrue(backends[1][0] == 'UPA')
92
93=== modified file 'autopilot/tests/unit/test_input.py'
94--- autopilot/tests/unit/test_input.py 2016-06-24 11:13:25 +0000
95+++ autopilot/tests/unit/test_input.py 2017-03-13 16:42:57 +0000
96@@ -18,6 +18,7 @@
97 #
98
99 import logging
100+import unittest
101
102 import testscenarios
103 from evdev import ecodes, uinput
104@@ -30,7 +31,7 @@
105 tests,
106 utilities
107 )
108-from autopilot.input import _uinput, get_center_point
109+from autopilot.input import _uinput, get_center_point, Keyboard
110
111
112 class Empty(object):
113@@ -1101,3 +1102,16 @@
114 self.assert_power_button_press_release_emitted_write_and_sync(
115 device._device.mock_calls
116 )
117+
118+
119+class KeyboardTestCase(unittest.TestCase):
120+
121+ @patch('autopilot.input._pick_backend')
122+ def test_input_backends_default_order(self, pick_backend):
123+ k = Keyboard()
124+ k.create()
125+
126+ backends = list(pick_backend.call_args[0][0].items())
127+ self.assertTrue(backends[0][0] == 'X11')
128+ self.assertTrue(backends[1][0] == 'OSK')
129+ self.assertTrue(backends[2][0] == 'UInput')

Subscribers

People subscribed via source and target branches