Merge lp:~autopilot/autopilot/more_ap_ap_test_fixes into lp:autopilot

Proposed by Łukasz Zemczak
Status: Merged
Approved by: Mathieu Trudel-Lapierre
Approved revision: 219
Merged at revision: 210
Proposed branch: lp:~autopilot/autopilot/more_ap_ap_test_fixes
Merge into: lp:autopilot
Diff against target: 331 lines (+69/-57)
11 files modified
autopilot/__init__.py (+11/-2)
autopilot/input/_uinput.py (+14/-2)
autopilot/testcase.py (+3/-2)
autopilot/tests/functional/test_application_mixin.py (+12/-0)
autopilot/tests/functional/test_autopilot_functional.py (+11/-1)
autopilot/tests/functional/test_custom_assertions.py (+1/-1)
autopilot/tests/functional/test_process_emulator.py (+3/-3)
autopilot/tests/unit/test_application_mixin.py (+0/-39)
autopilot/tests/unit/test_command_line_args.py (+5/-0)
autopilot/tests/unit/test_matchers.py (+6/-5)
autopilot/tests/unit/test_out_of_test_addcleanup.py (+3/-2)
To merge this branch: bzr merge lp:~autopilot/autopilot/more_ap_ap_test_fixes
Reviewer Review Type Date Requested Status
PS Jenkins bot continuous-integration Approve
Mathieu Trudel-Lapierre (community) Approve
Thomi Richards (community) Approve
Review via email: mp+164037@code.launchpad.net

Commit message

Branch for fixing the latest failing autopilot tests

Description of the change

Branch for fixing the latest failing autopilot tests:

(on private jenkins):
/job/ps-generic-autopilot-release-testing/391/label=autopilot-nvidia/testReport/

To post a comment you must log in.
Revision history for this message
Thomi Richards (thomir-deactivatedaccount) :
review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :

FAILED: Continuous integration, rev:218
No commit message was specified in the merge proposal. Click on the following link and set the commit message (if you want a jenkins rebuild you need to trigger it yourself):
https://code.launchpad.net/~autopilot/autopilot/more_ap_ap_test_fixes/+merge/164037/+edit-commit-message

http://jenkins.qa.ubuntu.com/job/autopilot-ci/88/
Executed test runs:
    FAILURE: http://jenkins.qa.ubuntu.com/job/autopilot-saucy-amd64-ci/16/console
    FAILURE: http://jenkins.qa.ubuntu.com/job/autopilot-saucy-armhf-ci/16/console

Click here to trigger a rebuild:
http://s-jenkins:8080/job/autopilot-ci/88/rebuild

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

FAILED: Autolanding.
No commit message was specified in the merge proposal. Hit 'Add commit message' on the merge proposal web page or follow the link below. You can approve the merge proposal yourself to rerun.
https://code.launchpad.net/~autopilot/autopilot/more_ap_ap_test_fixes/+merge/164037/+edit-commit-message

review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Didier Roche-Tolomelli (didrocks) wrote :

ok, Thomi, I think this is for you :p

219. By Thomi Richards

Fix test.

Revision history for this message
Mathieu Trudel-Lapierre (cyphermox) wrote :

Approve.

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

This branch breaks autopilot on touch devices.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'autopilot/__init__.py'
2--- autopilot/__init__.py 2013-05-06 23:19:57 +0000
3+++ autopilot/__init__.py 2013-05-16 15:55:46 +0000
4@@ -17,7 +17,7 @@
5 # along with this program. If not, see <http://www.gnu.org/licenses/>.
6 #
7
8-from argparse import ArgumentParser, REMAINDER
9+from argparse import ArgumentParser, REMAINDER, Action
10
11 version = '1.3'
12
13@@ -97,7 +97,8 @@
14 action='count', help="Show autopilot log messages. \
15 Set twice to also log data useful for debugging \
16 autopilot itself.")
17- parser_launch.add_argument('application', nargs=REMAINDER, type=str,
18+ parser_launch.add_argument('application', action=_OneOrMoreArgumentStoreAction,
19+ type=str, nargs=REMAINDER,
20 help="The application to launch. Can be a full path, \
21 or just an application name (in which case Autopilot \
22 will search for it in $PATH).")
23@@ -106,6 +107,14 @@
24 return args
25
26
27+class _OneOrMoreArgumentStoreAction(Action):
28+
29+ def __call__(self, parser, namespace, values, option_string=None):
30+ if len(values) == 0:
31+ parser.error("Must specify at least one argument to the 'launch' command")
32+ setattr(namespace, self.dest, values)
33+
34+
35 def have_vis():
36 """Return true if the vis package is installed."""
37 try:
38
39=== modified file 'autopilot/input/_uinput.py'
40--- autopilot/input/_uinput.py 2013-05-13 04:43:32 +0000
41+++ autopilot/input/_uinput.py 2013-05-16 15:55:46 +0000
42@@ -176,8 +176,20 @@
43 if res_x is None or res_y is None:
44 from autopilot.display import Display
45 display = Display.create()
46- res_x = display.get_screen_width()
47- res_y = display.get_screen_height()
48+ # TODO: This calculation needs to become part of the display module:
49+ l = r = t = b = 0
50+ for screen in range(display.get_num_screens()):
51+ geometry = display.get_screen_geometry(screen)
52+ if geometry[0] < l:
53+ l = geometry[0]
54+ if geometry[1] < t:
55+ t = geometry[1]
56+ if geometry[0] + geometry[2] > r:
57+ r = geometry[0] + geometry[2]
58+ if geometry[1] + geometry[3] > b:
59+ b = geometry[1] + geometry[3];
60+ res_x = r - l
61+ res_y = b - t
62
63 # android uses BTN_TOOL_FINGER, whereas desktop uses BTN_TOUCH. I have no
64 # idea why...
65
66=== modified file 'autopilot/testcase.py'
67--- autopilot/testcase.py 2013-05-09 00:04:33 +0000
68+++ autopilot/testcase.py 2013-05-16 15:55:46 +0000
69@@ -139,12 +139,13 @@
70 self._kb = None
71 self._display = None
72
73+ self._app_snapshot = self.process_manager.get_running_applications()
74+ self.addCleanup(self._compare_system_with_app_snapshot)
75+
76 @property
77 def process_manager(self):
78 if self._process_manager is None:
79 self._process_manager = ProcessManager.create()
80- self._app_snapshot = self.process_manager.get_running_applications()
81- self.addCleanup(self._compare_system_with_app_snapshot)
82 return self._process_manager
83
84 @property
85
86=== modified file 'autopilot/tests/functional/test_application_mixin.py'
87--- autopilot/tests/functional/test_application_mixin.py 2013-05-05 21:22:50 +0000
88+++ autopilot/tests/functional/test_application_mixin.py 2013-05-16 15:55:46 +0000
89@@ -26,6 +26,18 @@
90
91 class ApplicationSupportTests(AutopilotTestCase):
92
93+ def test_launch_with_bad_types_raises_typeerror(self):
94+ """Calling launch_test_application with something other than a string must
95+ raise a TypeError"""
96+
97+ self.assertThat(lambda: self.launch_test_application(1), raises(TypeError))
98+ self.assertThat(lambda: self.launch_test_application(True), raises(TypeError))
99+ self.assertThat(lambda: self.launch_test_application(1.0), raises(TypeError))
100+ self.assertThat(lambda: self.launch_test_application(object()), raises(TypeError))
101+ self.assertThat(lambda: self.launch_test_application(None), raises(TypeError))
102+ self.assertThat(lambda: self.launch_test_application([]), raises(TypeError))
103+ self.assertThat(lambda: self.launch_test_application((None,)), raises(TypeError))
104+
105 def test_launch_raises_ValueError_on_unknown_kwargs(self):
106 """launch_test_application must raise ValueError when given unknown
107 keyword arguments.
108
109=== modified file 'autopilot/tests/functional/test_autopilot_functional.py'
110--- autopilot/tests/functional/test_autopilot_functional.py 2013-05-15 05:24:14 +0000
111+++ autopilot/tests/functional/test_autopilot_functional.py 2013-05-16 15:55:46 +0000
112@@ -88,6 +88,7 @@
113 os.path.join(
114 os.path.dirname(__file__),
115 '..',
116+ '..',
117 '..'
118 )
119 )
120@@ -376,14 +377,18 @@
121
122 def test_record_flag_works(self):
123 """Must be able to record videos when the -r flag is present."""
124+
125+ # The sleep is to avoid the case where recordmydesktop does not create a
126+ # file because it gets stopped before it's even started capturing anything.
127 self.create_test_file("test_simple.py", dedent("""\
128
129 from autopilot.testcase import AutopilotTestCase
130-
131+ from time import sleep
132
133 class SimpleTest(AutopilotTestCase):
134
135 def test_simple(self):
136+ sleep(1)
137 self.fail()
138 """
139 ))
140@@ -397,14 +402,19 @@
141
142 def test_record_dir_option_works(self):
143 """Must be able to specify record directory flag."""
144+
145+ # The sleep is to avoid the case where recordmydesktop does not create a
146+ # file because it gets stopped before it's even started capturing anything.
147 self.create_test_file("test_simple.py", dedent("""\
148
149 from autopilot.testcase import AutopilotTestCase
150+ from time import sleep
151
152
153 class SimpleTest(AutopilotTestCase):
154
155 def test_simple(self):
156+ sleep(1)
157 self.fail()
158 """
159 ))
160
161=== renamed file 'autopilot/tests/unit/test_custom_assertions.py' => 'autopilot/tests/functional/test_custom_assertions.py'
162--- autopilot/tests/unit/test_custom_assertions.py 2013-05-05 02:39:14 +0000
163+++ autopilot/tests/functional/test_custom_assertions.py 2013-05-16 15:55:46 +0000
164@@ -20,9 +20,9 @@
165
166 from __future__ import absolute_import
167
168+from autopilot.testcase import AutopilotTestCase
169 from testtools.matchers import Equals, raises, Not
170
171-from autopilot.testcase import AutopilotTestCase
172 import logging
173 logger = logging.getLogger(__name__)
174
175
176=== modified file 'autopilot/tests/functional/test_process_emulator.py'
177--- autopilot/tests/functional/test_process_emulator.py 2013-05-15 10:07:35 +0000
178+++ autopilot/tests/functional/test_process_emulator.py 2013-05-16 15:55:46 +0000
179@@ -23,9 +23,9 @@
180 from autopilot.process import ProcessManager
181 from autopilot.globals import on_test_started
182
183-from subprocess import Popen, call, CalledProcessError, check_output
184+from subprocess import Popen, call
185 from testtools import TestCase
186-from testtools.matchers import Equals, NotEquals, LessThan, Raises
187+from testtools.matchers import Equals, NotEquals, LessThan
188 from threading import Thread
189 from time import sleep, time
190
191@@ -102,7 +102,7 @@
192 def test_can_close_all_app(self):
193 """Ensure that closing an app actually closes all app instances."""
194 try:
195- process_manager = ProcessManager.create(preferred_backend="BAM")
196+ process_manager = ProcessManager.create(preferred_backend="BAMF")
197 except BackendException as e:
198 self.skip("Test is only for BAMF backend ({}).".format(e.message))
199
200
201=== removed file 'autopilot/tests/unit/test_application_mixin.py'
202--- autopilot/tests/unit/test_application_mixin.py 2013-05-05 21:22:50 +0000
203+++ autopilot/tests/unit/test_application_mixin.py 1970-01-01 00:00:00 +0000
204@@ -1,39 +0,0 @@
205-# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
206-#
207-# Autopilot Functional Test Tool
208-# Copyright (C) 2012-2013 Canonical
209-#
210-# This program is free software: you can redistribute it and/or modify
211-# it under the terms of the GNU General Public License as published by
212-# the Free Software Foundation, either version 3 of the License, or
213-# (at your option) any later version.
214-#
215-# This program is distributed in the hope that it will be useful,
216-# but WITHOUT ANY WARRANTY; without even the implied warranty of
217-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
218-# GNU General Public License for more details.
219-#
220-# You should have received a copy of the GNU General Public License
221-# along with this program. If not, see <http://www.gnu.org/licenses/>.
222-#
223-
224-
225-from __future__ import absolute_import
226-
227-from autopilot.testcase import AutopilotTestCase
228-from testtools.matchers import raises
229-
230-
231-class ApplicationSupportTests(AutopilotTestCase):
232-
233- def test_launch_with_bad_types_raises_typeerror(self):
234- """Calling launch_test_application with something other than a string must
235- raise a TypeError"""
236-
237- self.assertThat(lambda: self.launch_test_application(1), raises(TypeError))
238- self.assertThat(lambda: self.launch_test_application(True), raises(TypeError))
239- self.assertThat(lambda: self.launch_test_application(1.0), raises(TypeError))
240- self.assertThat(lambda: self.launch_test_application(object()), raises(TypeError))
241- self.assertThat(lambda: self.launch_test_application(None), raises(TypeError))
242- self.assertThat(lambda: self.launch_test_application([]), raises(TypeError))
243- self.assertThat(lambda: self.launch_test_application((None,)), raises(TypeError))
244
245=== modified file 'autopilot/tests/unit/test_command_line_args.py'
246--- autopilot/tests/unit/test_command_line_args.py 2013-05-06 23:26:22 +0000
247+++ autopilot/tests/unit/test_command_line_args.py 2013-05-16 15:55:46 +0000
248@@ -89,6 +89,11 @@
249 self.assertThat(args.application,
250 Equals(["app", "-s", "--long", "--key=val", "arg1", "arg2"]))
251
252+ @patch('sys.stderr', new=StringIO())
253+ @expectedFailure
254+ def test_launch_command_must_specify_app(self):
255+ self.parse_args("launch")
256+
257 @patch('autopilot.have_vis', new=lambda: True)
258 def test_vis_present_when_vis_module_installed(self):
259 args = self.parse_args('vis')
260
261=== modified file 'autopilot/tests/unit/test_matchers.py'
262--- autopilot/tests/unit/test_matchers.py 2013-05-05 02:39:14 +0000
263+++ autopilot/tests/unit/test_matchers.py 2013-05-16 15:55:46 +0000
264@@ -22,9 +22,10 @@
265
266 from autopilot.introspection.dbus import DBusIntrospectionObject
267 from autopilot.matchers import Eventually
268-from autopilot.testcase import AutopilotTestCase
269
270 import dbus
271+from testscenarios import TestWithScenarios
272+from testtools import TestCase
273 from testtools.matchers import (
274 Contains,
275 Equals,
276@@ -60,15 +61,15 @@
277 return obj.attr
278
279
280-class ObjectPatchingMatcherTests(AutopilotTestCase):
281+class ObjectPatchingMatcherTests(TestCase):
282 """Ensure the core functionality the matchers use is correct."""
283
284 def test_default_wait_for_args(self):
285- """Ensure"""
286+ """Ensure we can call wait_for with the correct arg."""
287 intro_obj = make_fake_attribute_with_result(False)
288 intro_obj.wait_for(False)
289
290-class EventuallyMatcherTests(AutopilotTestCase):
291+class EventuallyMatcherTests(TestWithScenarios, TestCase):
292
293 scenarios = [
294 ('callable', dict(attribute_type='callable')),
295@@ -113,7 +114,7 @@
296 self.assertThat(mismatch.describe(), Contains("After 1.0 seconds test"))
297
298
299-class EventuallyNonScenariodTests(AutopilotTestCase):
300+class EventuallyNonScenariodTests(TestCase):
301
302 def test_eventually_matcher_raises_ValueError_on_unknown_kwargs(self):
303 self.assertThat(lambda: Eventually(Equals(True), foo=123),
304
305=== modified file 'autopilot/tests/unit/test_out_of_test_addcleanup.py'
306--- autopilot/tests/unit/test_out_of_test_addcleanup.py 2013-05-05 02:39:14 +0000
307+++ autopilot/tests/unit/test_out_of_test_addcleanup.py 2013-05-16 15:55:46 +0000
308@@ -21,7 +21,7 @@
309 from testtools import TestCase
310 from testtools.matchers import Equals
311
312-from autopilot.testcase import AutopilotTestCase
313+from autopilot.globals import on_test_started
314 from autopilot.utilities import addCleanup
315
316 log = ''
317@@ -33,12 +33,13 @@
318 args and kwargs.
319
320 """
321- class InnerTest(AutopilotTestCase):
322+ class InnerTest(TestCase):
323 def write_to_log(self, *args, **kwargs):
324 global log
325 log = "Hello %r %r" % (args, kwargs)
326
327 def test_foo(self):
328+ on_test_started(self)
329 addCleanup(self.write_to_log, "arg1", 2, foo='bar')
330
331 InnerTest('test_foo').run()

Subscribers

People subscribed via source and target branches