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
1=== modified file 'tests/autopilot/unity/tests/test_hud.py'
2--- tests/autopilot/unity/tests/test_hud.py 2013-05-22 02:14:27 +0000
3+++ tests/autopilot/unity/tests/test_hud.py 2013-05-22 02:14:27 +0000
4@@ -12,6 +12,7 @@
5 from autopilot.matchers import Eventually
6 from autopilot.display import Display, move_mouse_to_screen, is_rect_on_screen
7 from autopilot.testcase import multiply_scenarios
8+from autopilot.introspection.dbus import StateNotFoundError
9 from os import remove, environ
10 from os.path import exists
11 from tempfile import mktemp
12@@ -73,6 +74,14 @@
13 }
14 self.launch_test_window(window_spec)
15
16+ def hud_query_check(self):
17+ try:
18+ button = self.unity.hud.selected_hud_button
19+ if not button:
20+ return
21+ return button.label_no_formatting
22+ except StateNotFoundError:
23+ return
24
25
26 class HudBehaviorTests(HudTestsBase):
27@@ -210,13 +219,7 @@
28
29 self.keyboard.type("save")
30
31- def hud_query_check():
32- button = self.unity.hud.selected_hud_button
33- if not button:
34- return
35- return button.label_no_formatting
36-
37- self.assertThat(hud_query_check,
38+ self.assertThat(self.hud_query_check,
39 Eventually(Equals(u'Save\u2002(File)')))
40 self.keyboard.press_and_release('Return')
41 self.addCleanup(self.keyboard.press_and_release, "Ctrl+s")
42@@ -323,14 +326,7 @@
43
44 self.keyboard.type("Quit")
45 self.assertThat(self.unity.hud.search_string, Eventually(Equals("Quit")))
46-
47- def hud_query_check():
48- button = self.unity.hud.selected_hud_button
49- if not button:
50- return
51- return button.label_no_formatting
52-
53- self.assertThat(hud_query_check,
54+ self.assertThat(self.hud_query_check,
55 Eventually(Equals(u'Quit\u2002(File)'), timeout=30))
56
57 self.keyboard.press_and_release("Enter")
58
59=== modified file 'tests/autopilot/unity/tests/test_search.py'
60--- tests/autopilot/unity/tests/test_search.py 2013-05-22 02:14:27 +0000
61+++ tests/autopilot/unity/tests/test_search.py 2013-05-22 02:14:27 +0000
62@@ -147,10 +147,13 @@
63 self.keyboard.type(string)
64 self.assertThat(self.unity.hud.search_string, Eventually(Equals(string), timeout=30))
65 def hud_query_check():
66- button = self.unity.hud.selected_hud_button
67- if not button:
68+ try:
69+ button = self.unity.hud.selected_hud_button
70+ if not button:
71+ return
72+ return button.label_no_formatting
73+ except StateNotFoundError:
74 return
75- return button.label_no_formatting
76
77 self.assertThat(hud_query_check, Eventually(Equals(expected), timeout=30))
78