Merge lp:~townsend/unity/fix-lp1286143 into lp:unity

Proposed by Christopher Townsend
Status: Merged
Approved by: Brandon Schaefer
Approved revision: no longer in the source branch.
Merged at revision: 3691
Proposed branch: lp:~townsend/unity/fix-lp1286143
Merge into: lp:unity
Diff against target: 54 lines (+20/-4)
2 files modified
tests/autopilot/unity/tests/test_dash.py (+10/-2)
tests/autopilot/unity/tests/test_hud.py (+10/-2)
To merge this branch: bzr merge lp:~townsend/unity/fix-lp1286143
Reviewer Review Type Date Requested Status
Brandon Schaefer (community) Approve
PS Jenkins bot (community) continuous-integration Approve
Review via email: mp+208813@code.launchpad.net

Commit message

Fix corner case depending on where a test window opens, a Dash and Hud Autopilot test failure can occur.

Description of the change

Depending on where a test window opens, it can cause both a Dash and Hud Autopilot test to fail. This is because the mouse may move to where the unmaximized window is opened when clicking to close the Dash/Hud which focuses it. However, the test is checking that the maximized window is focused which causes the test to fail since the unmaximized window is focused.

The tests are:
unity.tests.test_hud.HudBehaviorTests.test_closes_then_focuses_window_on_mouse_down
unity.tests.test_dash.DashRevealTests.test_closes_then_focuses_window_on_mouse_down

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
Brandon Schaefer (brandontschaefer) wrote :

LGTM

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_dash.py'
2--- tests/autopilot/unity/tests/test_dash.py 2014-02-11 21:47:29 +0000
3+++ tests/autopilot/unity/tests/test_dash.py 2014-02-28 14:27:31 +0000
4@@ -144,13 +144,21 @@
5
6 char_win = self.process_manager.start_app("Character Map")
7 self.keybinding("window/maximize")
8- self.process_manager.start_app("Calculator")
9+ calc_win = self.process_manager.start_app("Calculator")
10
11 self.unity.dash.ensure_visible()
12
13- #Click bottom right of the screen
14+ # Click bottom right of the screen, but take into account the non-maximized window -
15+ # we do not want to click on it as it focuses the wrong window
16 w = self.display.get_screen_width() - 1
17 h = self.display.get_screen_height() - 1
18+
19+ # If the mouse is over the non-maximized window, move it away from it.
20+ (calc_x, calc_y, calc_w, calc_h) = calc_win.get_windows()[0].geometry
21+ if calc_x <= w <= calc_x+calc_w:
22+ grab_padding = 15
23+ w = w - (calc_w + grab_padding)
24+
25 self.mouse.move(w,h)
26 self.mouse.click()
27
28
29=== modified file 'tests/autopilot/unity/tests/test_hud.py'
30--- tests/autopilot/unity/tests/test_hud.py 2014-02-14 16:40:28 +0000
31+++ tests/autopilot/unity/tests/test_hud.py 2014-02-28 14:27:31 +0000
32@@ -467,13 +467,21 @@
33 char_win = self.process_manager.start_app("Character Map")
34 self.assertProperty(char_win, is_active=True)
35 self.keybinding("window/maximize")
36- self.process_manager.start_app("Calculator")
37+ calc_win = self.process_manager.start_app("Calculator")
38
39 self.unity.hud.ensure_visible()
40
41- #Click bottom right of the screen
42+ # Click bottom right of the screen, but take into account the non-maximized window -
43+ # we do not want to click on it as it focuses the wrong window
44 w = self.display.get_screen_width() - 1
45 h = self.display.get_screen_height() - 1
46+
47+ # If the mouse is over the non-maximized window, move it away from it.
48+ (calc_x, calc_y, calc_w, calc_h) = calc_win.get_windows()[0].geometry
49+ if calc_x <= w <= calc_x+calc_w:
50+ grab_padding = 15
51+ w = w - (calc_w + grab_padding)
52+
53 self.mouse.move(w,h)
54 self.mouse.click()
55