Merge lp:~sil2100/unity/autopilot_hud_2.0_fixes into lp:unity

Proposed by Łukasz Zemczak
Status: Merged
Approved by: Łukasz Zemczak
Approved revision: no longer in the source branch.
Merged at revision: 3314
Proposed branch: lp:~sil2100/unity/autopilot_hud_2.0_fixes
Merge into: lp:unity
Diff against target: 120 lines (+34/-13)
1 file modified
tests/autopilot/unity/tests/test_hud.py (+34/-13)
To merge this branch: bzr merge lp:~sil2100/unity/autopilot_hud_2.0_fixes
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Approve
Mathieu Trudel-Lapierre Approve
Review via email: mp+160610@code.launchpad.net

Commit message

Now that we're using the new HUD, there have been some changes that typically cause test_hud tests to fail. Fix the tests to fit the new model.
The first one is that generally we do not have indicator entries visible in the HUD anymore. Only application menu entries are in it now.
The second one - the way the results are displayed is different. Now, instead of "Menu > Entry" we have "Entry (Menu)" etc.

Description of the change

- Problem:

HUD 2.0 has some changes, which cause some test_hud and test_search autopilot tests to fail.

- Fix:

Quoting the commit message:
Now that we're using the new HUD, there have been some changes that typically cause test_hud tests to fail. Fix the tests to fit the new model.
The first one is that generally we do not have indicator entries visible in the HUD anymore. Only application menu entries are in it now.
The second one - the way the results are displayed is different. Now, instead of "Menu > Entry" we have "Entry (Menu)" etc.

We're not fixing the test_search tests, since in my opinion that's a real regression (see LP: #1172228).

- Tests:

N/A

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Mathieu Trudel-Lapierre (cyphermox) wrote :

Seems fine to me. Just why did you change the tests from trying 'a' to trying 'e'?

review: Approve
Revision history for this message
Łukasz Zemczak (sil2100) wrote :

I changed those because e is more likely to return results of the test application, as I added entries that are called 'Entry 1', 'Entry 2' <- there is no letter a in those ;) And I thought that 'Entry NUMBER' is better than 'asdf 1' and such ;)

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

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_hud.py'
2--- tests/autopilot/unity/tests/test_hud.py 2013-03-20 22:10:59 +0000
3+++ tests/autopilot/unity/tests/test_hud.py 2013-04-24 15:27:27 +0000
4@@ -66,6 +66,14 @@
5 }
6 self.launch_test_window(window_spec)
7
8+ def start_menu_app(self):
9+ window_spec = {
10+ "Title": "Test menu application",
11+ "Menu": ["Entry 1", "Entry 2", "Entry 3", "Entry 4", "Entry 5", "Quit"],
12+ }
13+ self.launch_test_window(window_spec)
14+
15+
16
17 class HudBehaviorTests(HudTestsBase):
18
19@@ -83,16 +91,20 @@
20 self.assertThat(self.unity.hud.selected_button, Equals(0))
21
22 def test_check_a_values(self):
23+ self.start_menu_app()
24 self.unity.hud.ensure_visible()
25- self.keyboard.type('a')
26- self.assertThat(self.unity.hud.search_string, Eventually(Equals('a')))
27+ self.keyboard.type('e')
28+ self.assertThat(self.unity.hud.search_string, Eventually(Equals('e')))
29 self.assertThat(self.unity.hud.num_buttons, Eventually(Equals(5)))
30 self.assertThat(self.unity.hud.selected_button, Eventually(Equals(1)))
31
32 def test_up_down_arrows(self):
33+ self.start_menu_app()
34 self.unity.hud.ensure_visible()
35- self.keyboard.type('a')
36- self.assertThat(self.unity.hud.search_string, Eventually(Equals('a')))
37+ self.keyboard.type('e')
38+ self.assertThat(self.unity.hud.search_string, Eventually(Equals('e')))
39+ self.assertThat(self.unity.hud.num_buttons, Eventually(Equals(5)))
40+
41 self.keyboard.press_and_release('Down')
42 self.assertThat(self.unity.hud.selected_button, Eventually(Equals(2)))
43 self.keyboard.press_and_release('Down')
44@@ -120,6 +132,8 @@
45 """Hud must not change selected button when results update over time."""
46 # TODO - this test doesn't test anything. Onmy system the results never update.
47 # ideally we'd send artificial results to the hud from the test.
48+ self.skipTest("This test makes no sense in its current state, needs reworking.")
49+
50 self.unity.hud.ensure_visible()
51 self.keyboard.type('is')
52 self.assertThat(self.unity.hud.search_string, Eventually(Equals('is')))
53@@ -198,8 +212,10 @@
54
55 self.keyboard.type("undo")
56 hud_query_check = lambda: self.unity.hud.selected_hud_button.label_no_formatting
57+ # XXX: with the new HUD, command and description is separated by '\u2002' and
58+ # not a regular space ' '. Is that correct? (LP: #1172237)
59 self.assertThat(hud_query_check,
60- Eventually(Equals("Edit > Undo")))
61+ Eventually(Equals(u'Undo\u2002(Edit)')))
62 self.keyboard.press_and_release('Return')
63 self.assertThat(self.unity.hud.visible, Eventually(Equals(False)))
64
65@@ -306,8 +322,11 @@
66
67 self.unity.hud.ensure_visible()
68
69- self.keyboard.type("File > Quit")
70- self.assertThat(self.unity.hud.search_string, Eventually(Equals("File > Quit")))
71+ self.keyboard.type("Quit")
72+ self.assertThat(self.unity.hud.search_string, Eventually(Equals("Quit")))
73+ hud_query_check = lambda: self.unity.hud.selected_hud_button.label_no_formatting
74+ self.assertThat(hud_query_check,
75+ Eventually(Equals(u'Quit\u2002(File)')))
76
77 self.keyboard.press_and_release("Enter")
78
79@@ -368,10 +387,11 @@
80 """This tests moves the mouse from the top of the screen to the bottom, this must
81 change the selected button from 1 to 5.
82 """
83-
84+ self.start_menu_app()
85 self.unity.hud.ensure_visible()
86
87- self.keyboard.type("a")
88+ self.keyboard.type("e")
89+ self.assertThat(self.unity.hud.num_buttons, Eventually(Equals(5)))
90 (x,y,w,h) = self.unity.hud.view.geometry
91
92 # Specify a slower rate so that HUD can register the mouse movement properly
93@@ -385,10 +405,11 @@
94 """This tests moves the mouse from the top of the screen to the bottom,
95 then it presses the keyboard up 5 times, this must change the selected button from 5 to 1.
96 """
97-
98+ self.start_menu_app()
99 self.unity.hud.ensure_visible()
100
101- self.keyboard.type("a")
102+ self.keyboard.type("e")
103+ self.assertThat(self.unity.hud.num_buttons, Eventually(Equals(5)))
104 (x,y,w,h) = self.unity.hud.view.geometry
105
106 self.mouse.move(w/2, 0)
107@@ -462,13 +483,13 @@
108
109 def test_mouse_does_not_steal_button_focus(self):
110 """When typing in the hud the mouse must not steal button focus."""
111-
112+ self.start_menu_app()
113 self.unity.hud.ensure_visible()
114
115 (x,y,w,h) = self.unity.hud.view.geometry
116 self.mouse.move(w/4, h/4)
117
118- self.keyboard.type("a")
119+ self.keyboard.type("e")
120 self.assertThat(self.unity.hud.view.selected_button, Eventually(Equals(1)))
121
122