Merge lp:~veebers/autopilot/custom_emulator_lp-1191164 into lp:autopilot

Proposed by Christopher Lee
Status: Merged
Approved by: Thomi Richards
Approved revision: 249
Merged at revision: 247
Proposed branch: lp:~veebers/autopilot/custom_emulator_lp-1191164
Merge into: lp:autopilot
Diff against target: 41 lines (+16/-0)
2 files modified
autopilot/introspection/dbus.py (+2/-0)
autopilot/tests/functional/test_introspection_features.py (+14/-0)
To merge this branch: bzr merge lp:~veebers/autopilot/custom_emulator_lp-1191164
Reviewer Review Type Date Requested Status
PS Jenkins bot continuous-integration Approve
Thomi Richards (community) Approve
Leo Arias (community) code review Approve
Review via email: mp+170480@code.launchpad.net

Commit message

Make sure the Custom emulators _Backend is set when creating an introspection object.

Description of the change

CustomEmulator cls._Backend wasn't being set. Make sure it's set when creating an introspection object.

To post a comment you must log in.
Revision history for this message
Christopher Lee (veebers) wrote :

I can't help but feel that this is a bandaid and that I'm missing a more fundamental fix.

Revision history for this message
Leo Arias (elopio) wrote :

<elopio> veebers: I think it will work.
<elopio> when I read this code in autopilot I got the feeling that a lot is black magic, not really clear.
<elopio> but I don't have an alternate solution. If the test added passes, I'm happy.
<veebers> elopio: it works at the moment (i.e. all the autopilot tests pass, I'm just going to run the Unity tests) but I'm not sure that it is as intended
<veebers> elopio: aye, It's not the easiest to read (with metaclasses et. al). If all the tests pass I'll get it merged in. I'll hit up thomi once he gets back to check if there is a better option too
<elopio> veebers: +1
<elopio> let me leave an approve comment.

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

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'autopilot/introspection/dbus.py'
2--- autopilot/introspection/dbus.py 2013-05-23 23:09:52 +0000
3+++ autopilot/introspection/dbus.py 2013-06-20 21:26:23 +0000
4@@ -475,6 +475,8 @@
5 name = get_classname_from_path(path)
6 try:
7 class_type = _object_registry[cls._id][name]
8+ if class_type._Backend is None:
9+ class_type._Backend = cls._Backend
10 except KeyError:
11 logger.warning("Generating introspection instance for type '%s' based on generic class.", name)
12 # override the _id attr from cls, since we don't want generated types
13
14=== modified file 'autopilot/tests/functional/test_introspection_features.py'
15--- autopilot/tests/functional/test_introspection_features.py 2013-05-23 05:05:58 +0000
16+++ autopilot/tests/functional/test_introspection_features.py 2013-06-20 21:26:23 +0000
17@@ -22,6 +22,7 @@
18 from tempfile import mktemp
19 from testtools.matchers import Equals
20
21+from autopilot.matchers import Eventually
22 from autopilot.testcase import AutopilotTestCase
23 from autopilot.introspection.dbus import CustomEmulatorBase
24
25@@ -73,3 +74,16 @@
26
27 self.assertThat(type(test_widget), Equals(MouseTestWidget))
28
29+ def test_can_access_custom_emulator_properties(self):
30+ """Must be able to access properties of a custom emulator."""
31+
32+ class EmulatorBase(CustomEmulatorBase):
33+ pass
34+
35+ class MouseTestWidget(EmulatorBase):
36+ pass
37+
38+ app = self.start_mock_app(EmulatorBase)
39+ test_widget = app.select_single(MouseTestWidget)
40+
41+ self.assertThat(test_widget.visible, Eventually(Equals(True)))

Subscribers

People subscribed via source and target branches