Merge lp:~fginther/unity/autopilot_hud_button_label_fixes into lp:unity

Proposed by Francis Ginther
Status: Merged
Approved by: Łukasz Zemczak
Approved revision: no longer in the source branch.
Merged at revision: 3338
Proposed branch: lp:~fginther/unity/autopilot_hud_button_label_fixes
Merge into: lp:unity
Prerequisite: lp:~sil2100/unity/autopilot_hud_more_fixes
Diff against target: 77 lines (+17/-18)
2 files modified
tests/autopilot/unity/tests/test_hud.py (+11/-15)
tests/autopilot/unity/tests/test_search.py (+6/-3)
To merge this branch: bzr merge lp:~fginther/unity/autopilot_hud_button_label_fixes
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Approve
Łukasz Zemczak Approve
Review via email: mp+164999@code.launchpad.net

Commit message

Handle StateNotFoundError when querying the label of a hud button.

Description of the change

Handle StateNotFoundError when querying the label of a hud button.

When querying the contents of the hud and the button lables, buttons may be destroyed as the contents change. This ignores the StateNotFoundError and allows the query logic to keep trying.

To post a comment you must log in.
Revision history for this message
Łukasz Zemczak (sil2100) wrote :

Awesome, thanks Francis! Indeed this can happen here as well. Good catch!

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
=== modified file 'tests/autopilot/unity/tests/test_hud.py'
--- tests/autopilot/unity/tests/test_hud.py 2013-05-22 02:14:27 +0000
+++ tests/autopilot/unity/tests/test_hud.py 2013-05-22 02:14:27 +0000
@@ -12,6 +12,7 @@
12from autopilot.matchers import Eventually12from autopilot.matchers import Eventually
13from autopilot.display import Display, move_mouse_to_screen, is_rect_on_screen13from autopilot.display import Display, move_mouse_to_screen, is_rect_on_screen
14from autopilot.testcase import multiply_scenarios14from autopilot.testcase import multiply_scenarios
15from autopilot.introspection.dbus import StateNotFoundError
15from os import remove, environ16from os import remove, environ
16from os.path import exists17from os.path import exists
17from tempfile import mktemp18from tempfile import mktemp
@@ -73,6 +74,14 @@
73 }74 }
74 self.launch_test_window(window_spec)75 self.launch_test_window(window_spec)
7576
77 def hud_query_check(self):
78 try:
79 button = self.unity.hud.selected_hud_button
80 if not button:
81 return
82 return button.label_no_formatting
83 except StateNotFoundError:
84 return
7685
7786
78class HudBehaviorTests(HudTestsBase):87class HudBehaviorTests(HudTestsBase):
@@ -210,13 +219,7 @@
210219
211 self.keyboard.type("save")220 self.keyboard.type("save")
212221
213 def hud_query_check():222 self.assertThat(self.hud_query_check,
214 button = self.unity.hud.selected_hud_button
215 if not button:
216 return
217 return button.label_no_formatting
218
219 self.assertThat(hud_query_check,
220 Eventually(Equals(u'Save\u2002(File)')))223 Eventually(Equals(u'Save\u2002(File)')))
221 self.keyboard.press_and_release('Return')224 self.keyboard.press_and_release('Return')
222 self.addCleanup(self.keyboard.press_and_release, "Ctrl+s")225 self.addCleanup(self.keyboard.press_and_release, "Ctrl+s")
@@ -323,14 +326,7 @@
323326
324 self.keyboard.type("Quit")327 self.keyboard.type("Quit")
325 self.assertThat(self.unity.hud.search_string, Eventually(Equals("Quit")))328 self.assertThat(self.unity.hud.search_string, Eventually(Equals("Quit")))
326329 self.assertThat(self.hud_query_check,
327 def hud_query_check():
328 button = self.unity.hud.selected_hud_button
329 if not button:
330 return
331 return button.label_no_formatting
332
333 self.assertThat(hud_query_check,
334 Eventually(Equals(u'Quit\u2002(File)'), timeout=30))330 Eventually(Equals(u'Quit\u2002(File)'), timeout=30))
335331
336 self.keyboard.press_and_release("Enter")332 self.keyboard.press_and_release("Enter")
337333
=== modified file 'tests/autopilot/unity/tests/test_search.py'
--- tests/autopilot/unity/tests/test_search.py 2013-05-22 02:14:27 +0000
+++ tests/autopilot/unity/tests/test_search.py 2013-05-22 02:14:27 +0000
@@ -147,10 +147,13 @@
147 self.keyboard.type(string)147 self.keyboard.type(string)
148 self.assertThat(self.unity.hud.search_string, Eventually(Equals(string), timeout=30))148 self.assertThat(self.unity.hud.search_string, Eventually(Equals(string), timeout=30))
149 def hud_query_check():149 def hud_query_check():
150 button = self.unity.hud.selected_hud_button150 try:
151 if not button:151 button = self.unity.hud.selected_hud_button
152 if not button:
153 return
154 return button.label_no_formatting
155 except StateNotFoundError:
152 return156 return
153 return button.label_no_formatting
154157
155 self.assertThat(hud_query_check, Eventually(Equals(expected), timeout=30))158 self.assertThat(hud_query_check, Eventually(Equals(expected), timeout=30))
156159