Merge lp:~pitti/autopilot/fix-gdk-display into lp:autopilot

Proposed by Martin Pitt
Status: Merged
Approved by: Thomi Richards
Approved revision: 391
Merged at revision: 392
Proposed branch: lp:~pitti/autopilot/fix-gdk-display
Merge into: lp:autopilot
Diff against target: 64 lines (+24/-2)
2 files modified
autopilot/process/_bamf.py (+2/-2)
autopilot/tests/functional/test_introspection_features.py (+22/-0)
To merge this branch: bzr merge lp:~pitti/autopilot/fix-gdk-display
Reviewer Review Type Date Requested Status
Thomi Richards (community) Approve
PS Jenkins bot continuous-integration Approve
Review via email: mp+198288@code.launchpad.net

Commit message

Fix initialization of GdkDisplay, to fix crash when accessing Window.geometry.

Description of the change

Fix initialization of GdkDisplay, see bzr changelog.

To post a comment you must log in.
Revision history for this message
Martin Pitt (pitti) wrote :

I ran this with

PYTHONPATH=. python -m autopilot.run run autopilot.tests.functional.test_introspection_features.IntrospectionFeatureTests

as the full functional test suite currently seems to be in a rather sorry state -- I get 97 failures :(

Revision history for this message
Martin Pitt (pitti) wrote :

> as the full functional test suite currently seems to be in a rather sorry
> state -- I get 97 failures :(

Fixing in https://code.launchpad.net/~pitti/autopilot/fix-run.py/+merge/198292

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Thomi Richards (thomir-deactivatedaccount) wrote :

LGTM

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'autopilot/process/_bamf.py'
2--- autopilot/process/_bamf.py 2013-11-07 05:53:36 +0000
3+++ autopilot/process/_bamf.py 2013-12-09 16:35:58 +0000
4@@ -487,11 +487,11 @@
5 # builder.
6 from gi import require_version
7 require_version('GdkX11', '3.0')
8- from gi.repository import GdkX11
9+ from gi.repository import Gdk, GdkX11
10 # FIXME: We need to use the gdk window here to get the real coordinates
11 geometry = self._x_win.get_geometry()
12 origin = GdkX11.X11Window.foreign_new_for_display(
13- GdkX11.X11Display(), self._xid).get_origin()
14+ Gdk.Display().get_default(), self._xid).get_origin()
15 return (origin[0], origin[1], geometry.width, geometry.height)
16
17 @property
18
19=== modified file 'autopilot/tests/functional/test_introspection_features.py'
20--- autopilot/tests/functional/test_introspection_features.py 2013-12-06 00:43:23 +0000
21+++ autopilot/tests/functional/test_introspection_features.py 2013-12-09 16:35:58 +0000
22@@ -26,6 +26,7 @@
23 import tempfile
24 from tempfile import mktemp
25 from testtools.matchers import Equals, IsInstance, MatchesRegex, Not, Contains
26+from testtools.matchers import LessThan, GreaterThan
27 from textwrap import dedent
28 from six import StringIO
29
30@@ -33,6 +34,7 @@
31 from autopilot.testcase import AutopilotTestCase
32 from autopilot.introspection.dbus import CustomEmulatorBase
33 from autopilot.introspection import _connection_matches_pid
34+from autopilot.display import Display
35
36
37 class EmulatorBase(CustomEmulatorBase):
38@@ -179,6 +181,26 @@
39 self.assertThat(out, Not(Contains(
40 "/Root/QMainWindow/QMenuBar/QToolButton")))
41
42+ def test_window_geometry(self):
43+ """Window.geometry property
44+
45+ Check that all Window geometry properties work and have a plausible
46+ range.
47+ """
48+ # ensure we have at least one open app window
49+ app = self.start_mock_app(EmulatorBase)
50+
51+ display = Display.create()
52+ for monitor in range(display.get_num_screens()):
53+ (_, _, swidth, sheight) = Display.create().get_screen_geometry(0)
54+ for win in self.process_manager.get_open_windows():
55+ geom = win.geometry
56+ self.assertThat(len(geom), Equals(4))
57+ self.assertThat(geom[0], GreaterThan(-1)) # no GreaterEquals
58+ self.assertThat(geom[1], GreaterThan(-1))
59+ self.assertThat(geom[2], LessThan(swidth + 1))
60+ self.assertThat(geom[3], LessThan(sheight + 1))
61+
62
63 class QMLCustomEmulatorTestCase(AutopilotTestCase):
64 """Test the introspection of a QML application with a custom emulator."""

Subscribers

People subscribed via source and target branches