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
=== modified file 'autopilot/display/__init__.py'
--- autopilot/display/__init__.py 2016-11-22 13:12:14 +0000
+++ autopilot/display/__init__.py 2017-03-13 16:42:57 +0000
@@ -107,8 +107,8 @@
107 return Display()107 return Display()
108108
109 backends = OrderedDict()109 backends = OrderedDict()
110 backends['X11'] = get_x11_display
110 backends['UPA'] = get_upa_display111 backends['UPA'] = get_upa_display
111 backends['X11'] = get_x11_display
112 return _pick_backend(backends, preferred_backend)112 return _pick_backend(backends, preferred_backend)
113113
114 class BlacklistedDriverError(RuntimeError):114 class BlacklistedDriverError(RuntimeError):
115115
=== modified file 'autopilot/input/__init__.py'
--- autopilot/input/__init__.py 2016-11-22 12:42:52 +0000
+++ autopilot/input/__init__.py 2017-03-13 16:42:57 +0000
@@ -57,6 +57,9 @@
5757
58from collections import OrderedDict58from collections import OrderedDict
59from contextlib import contextmanager59from contextlib import contextmanager
60
61import psutil
62
60from autopilot.input._common import get_center_point63from autopilot.input._common import get_center_point
61from autopilot.utilities import _pick_backend, CleanupRegistered64from autopilot.utilities import _pick_backend, CleanupRegistered
6265
@@ -119,16 +122,21 @@
119122
120 def get_osk_kb():123 def get_osk_kb():
121 try:124 try:
122 from autopilot.input._osk import Keyboard125 maliit = [p for p in
123 return Keyboard()126 psutil.process_iter() if p.name() == 'maliit-server']
127 if maliit:
128 from autopilot.input._osk import Keyboard
129 return Keyboard()
130 else:
131 raise RuntimeError('maliit-server is not running')
124 except ImportError as e:132 except ImportError as e:
125 e.args += ("Unable to import the OSK backend",)133 e.args += ("Unable to import the OSK backend",)
126 raise134 raise
127135
128 backends = OrderedDict()136 backends = OrderedDict()
137 backends['X11'] = get_x11_kb
138 backends['OSK'] = get_osk_kb
129 backends['UInput'] = get_uinput_kb139 backends['UInput'] = get_uinput_kb
130 backends['OSK'] = get_osk_kb
131 backends['X11'] = get_x11_kb
132 return _pick_backend(backends, preferred_backend)140 return _pick_backend(backends, preferred_backend)
133141
134 @contextmanager142 @contextmanager
135143
=== added file 'autopilot/tests/unit/test_display.py'
--- autopilot/tests/unit/test_display.py 1970-01-01 00:00:00 +0000
+++ autopilot/tests/unit/test_display.py 2017-03-13 16:42:57 +0000
@@ -0,0 +1,33 @@
1# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
2#
3# Autopilot Functional Test Tool
4# Copyright (C) 2016 Canonical
5#
6# This program is free software: you can redistribute it and/or modify
7# it under the terms of the GNU General Public License as published by
8# the Free Software Foundation, either version 3 of the License, or
9# (at your option) any later version.
10#
11# This program is distributed in the hope that it will be useful,
12# but WITHOUT ANY WARRANTY; without even the implied warranty of
13# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14# GNU General Public License for more details.
15#
16# You should have received a copy of the GNU General Public License
17# along with this program. If not, see <http://www.gnu.org/licenses/>.
18#
19import unittest
20from unittest.mock import patch
21from autopilot.display import Display
22
23
24class DisplayTestCase(unittest.TestCase):
25
26 @patch('autopilot.display._pick_backend')
27 def test_input_backends_default_order(self, pick_backend):
28 d = Display()
29 d.create()
30
31 backends = list(pick_backend.call_args[0][0].items())
32 self.assertTrue(backends[0][0] == 'X11')
33 self.assertTrue(backends[1][0] == 'UPA')
034
=== modified file 'autopilot/tests/unit/test_input.py'
--- autopilot/tests/unit/test_input.py 2016-06-24 11:13:25 +0000
+++ autopilot/tests/unit/test_input.py 2017-03-13 16:42:57 +0000
@@ -18,6 +18,7 @@
18#18#
1919
20import logging20import logging
21import unittest
2122
22import testscenarios23import testscenarios
23from evdev import ecodes, uinput24from evdev import ecodes, uinput
@@ -30,7 +31,7 @@
30 tests,31 tests,
31 utilities32 utilities
32)33)
33from autopilot.input import _uinput, get_center_point34from autopilot.input import _uinput, get_center_point, Keyboard
3435
3536
36class Empty(object):37class Empty(object):
@@ -1101,3 +1102,16 @@
1101 self.assert_power_button_press_release_emitted_write_and_sync(1102 self.assert_power_button_press_release_emitted_write_and_sync(
1102 device._device.mock_calls1103 device._device.mock_calls
1103 )1104 )
1105
1106
1107class KeyboardTestCase(unittest.TestCase):
1108
1109 @patch('autopilot.input._pick_backend')
1110 def test_input_backends_default_order(self, pick_backend):
1111 k = Keyboard()
1112 k.create()
1113
1114 backends = list(pick_backend.call_args[0][0].items())
1115 self.assertTrue(backends[0][0] == 'X11')
1116 self.assertTrue(backends[1][0] == 'OSK')
1117 self.assertTrue(backends[2][0] == 'UInput')

Subscribers

People subscribed via source and target branches