Merge lp:~bregma/unity/lp-1436095 into lp:unity

Proposed by Stephen M. Webb
Status: Merged
Approved by: Christopher Townsend
Approved revision: no longer in the source branch.
Merged at revision: 3943
Proposed branch: lp:~bregma/unity/lp-1436095
Merge into: lp:unity
Diff against target: 32 lines (+15/-6)
1 file modified
tests/autopilot/unity/tests/test_spread.py (+15/-6)
To merge this branch: bzr merge lp:~bregma/unity/lp-1436095
Reviewer Review Type Date Requested Status
Christopher Townsend Approve
PS Jenkins bot (community) continuous-integration Approve
Review via email: mp+254012@code.launchpad.net

Commit message

AP tests: accounted for arbitrarily-raised exceptions in checking scaled windows

Description of the change

Fixes a couple of recurring AP test errors to do with closing windows in the spread.

It seems the D-Bus introspection class of the Autopilot suite raises an exception when you're trying to examine certain data that does not match some criterion (the likes of which was not worth investigating) and the order of appearance of the data was largely random, so the closing-windows-in-the-spread test would error out just as randomly.

Note that these were not failing tests but errors in the test infrastructure. The workaround is to catch the raised exceptions and ignore them, because they only happened on irrelevant data that was being filtered out any way.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Christopher Townsend (townsend) wrote :

Ok, makes sense. +1

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'tests/autopilot/unity/tests/test_spread.py'
2--- tests/autopilot/unity/tests/test_spread.py 2014-03-05 22:14:16 +0000
3+++ tests/autopilot/unity/tests/test_spread.py 2015-03-24 22:42:09 +0000
4@@ -59,13 +59,22 @@
5 self.assertThat(lambda: self.unity.screen.spread_filter, Eventually(NotEquals(None)))
6 return self.unity.screen.spread_filter
7
8- def assertWindowIsScaledEquals(self, xid, scaled):
9+ def assertWindowIsScaledEquals(self, xid, is_scaled):
10 """Assert weather a window is scaled"""
11- # Add a short delay to ensure the Spread has finished.
12- sleep(0.5)
13-
14- refresh_fn = lambda: xid in [w.xid for w in self.unity.screen.scaled_windows]
15- self.assertThat(refresh_fn, Eventually(Equals(scaled)))
16+ def scaled_windows_for_screen_contains_xid():
17+ """Predicates the window is in the list of scaled windows for the screen.
18+ The DBus introspection object actually raises an exception if you try to look
19+ at a window in the scaled_windows list and it's not a scaled window. Buggzorz.
20+ """
21+ scaled_windows = self.unity.screen.scaled_windows
22+ for w in scaled_windows:
23+ try:
24+ if xid == w.xid:
25+ return True
26+ except:
27+ pass
28+ return False
29+ self.assertThat(scaled_windows_for_screen_contains_xid, Eventually(Equals(is_scaled)))
30
31 def assertWindowIsClosed(self, xid):
32 """Assert that a window is not in the list of the open windows"""