Merge lp:~thomir/unity/ibus-test-to-wait_for-feature into lp:unity

Proposed by Thomi Richards on 2012-04-17
Status: Superseded
Proposed branch: lp:~thomir/unity/ibus-test-to-wait_for-feature
Merge into: lp:unity
Prerequisite: lp:~thomir/unity/hud-tests-to-wait_for-feature
Diff against target: 239 lines (+47/-81)
2 files modified
tests/autopilot/autopilot/emulators/unity/dash.py (+1/-0)
tests/autopilot/autopilot/tests/test_ibus.py (+46/-81)
To merge this branch: bzr merge lp:~thomir/unity/ibus-test-to-wait_for-feature
Reviewer Review Type Date Requested Status
Brandon Schaefer (community) 2012-04-17 Approve on 2012-04-18
Review via email: mp+102236@code.launchpad.net

This proposal has been superseded by a proposal from 2012-04-18.

Commit Message

IBus tests now use Eventually autopilot feature, and other refactorings.

Description of the Change

IBus tests now use the wait_for attribute feature, and are generally much cleaner (and shorter).

To post a comment you must log in.
Brandon Schaefer (brandontschaefer) wrote :

Looks good! Awesome clean up!

review: Approve
Brandon Schaefer (brandontschaefer) wrote :

New changes look good, and all ap test pass!

review: Approve
Unity Merger (unity-merger) wrote :

The prerequisite lp:~thomir/unity/hud-tests-to-wait_for-feature has not yet been merged into lp:unity.

2249. By Thomi Richards on 2012-04-18

Merged trunk, resolved conflicts.

Unmerged revisions

2249. By Thomi Richards on 2012-04-18

Merged trunk, resolved conflicts.

2248. By Thomi Richards on 2012-04-18

Merged hud-tests-to-wait_for-feature into ibus-test-to-wait_for-feature.

2247. By Thomi Richards on 2012-04-18

Merged hud-tests-to-wait_for-feature into ibus-test-to-wait_for-feature.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'tests/autopilot/autopilot/emulators/unity/dash.py'
2--- tests/autopilot/autopilot/emulators/unity/dash.py 2012-04-17 22:30:28 +0000
3+++ tests/autopilot/autopilot/emulators/unity/dash.py 2012-04-17 22:30:28 +0000
4@@ -94,6 +94,7 @@
5 """
6 self._keyboard.press_and_release("Ctrl+a")
7 self._keyboard.press_and_release("Delete")
8+ self.search_string.wait_for("")
9
10 def reveal_application_lens(self, clear_search=True):
11 """Reveal the application lense."""
12
13=== modified file 'tests/autopilot/autopilot/tests/test_ibus.py'
14--- tests/autopilot/autopilot/tests/test_ibus.py 2012-04-05 15:14:16 +0000
15+++ tests/autopilot/autopilot/tests/test_ibus.py 2012-04-17 22:30:28 +0000
16@@ -8,12 +8,14 @@
17
18 """Tests to ensure unity is compatible with ibus input method."""
19
20+from testtools.matchers import Equals, NotEquals
21 from time import sleep
22
23 from autopilot.emulators.ibus import (
24 set_active_engines,
25 get_available_input_engines,
26 )
27+from autopilot.matchers import Eventually
28 from autopilot.tests import AutopilotTestCase, multiply_scenarios
29
30
31@@ -44,6 +46,34 @@
32 # it would be nice to be able to tell if it's currently active or not.
33 self.keyboard.press_and_release('Ctrl+Space')
34
35+ def do_dash_test_with_engine(self, engine_name):
36+ self.activate_input_engine_or_skip(engine_name)
37+ self.dash.ensure_visible()
38+ self.addCleanup(self.dash.ensure_hidden)
39+ sleep(0.5)
40+ self.activate_ibus()
41+ self.addCleanup(self.deactivate_ibus)
42+ sleep(0.5)
43+ self.keyboard.type(self.input)
44+ commit_key = getattr(self, 'commit_key', None)
45+ if commit_key:
46+ self.keyboard.press_and_release(commit_key)
47+ self.assertThat(self.dash.search_string, Eventually(Equals(self.result)))
48+
49+ def do_hud_test_with_engine(self, engine_name):
50+ self.activate_input_engine_or_skip(engine_name)
51+ self.hud.ensure_visible()
52+ self.addCleanup(self.hud.ensure_hidden)
53+ sleep(0.5)
54+ self.activate_ibus()
55+ self.addCleanup(self.deactivate_ibus)
56+ sleep(0.5)
57+ self.keyboard.type(self.input)
58+ commit_key = getattr(self, 'commit_key', None)
59+ if commit_key:
60+ self.keyboard.press_and_release(commit_key)
61+ self.assertThat(self.hud.search_string, Eventually(Equals(self.result)))
62+
63
64 class IBusTestsPinyin(IBusTests):
65 """Tests for the Pinyin(Chinese) input engine."""
66@@ -57,30 +87,10 @@
67 ]
68
69 def test_simple_input_dash(self):
70- self.activate_input_engine_or_skip("pinyin")
71- self.dash.ensure_visible()
72- sleep(0.5)
73- self.activate_ibus()
74- sleep(0.5)
75- self.keyboard.type(self.input)
76- dash_search_string = self.dash.search_string
77- self.deactivate_ibus()
78- self.dash.ensure_hidden()
79-
80- self.assertEqual(self.result, dash_search_string)
81+ self.do_dash_test_with_engine("pinyin")
82
83 def test_simple_input_hud(self):
84- self.activate_input_engine_or_skip("pinyin")
85- self.hud.ensure_visible()
86- sleep(0.5)
87- self.activate_ibus()
88- sleep(0.5)
89- self.keyboard.type(self.input)
90- hud_search_string = self.hud.search_string
91- self.deactivate_ibus()
92- self.hud.ensure_hidden()
93-
94- self.assertEqual(self.result, hud_search_string)
95+ self.do_hud_test_with_engine("pinyin")
96
97
98 class IBusTestsHangul(IBusTests):
99@@ -93,30 +103,10 @@
100 ]
101
102 def test_simple_input_dash(self):
103- self.activate_input_engine_or_skip("hangul")
104- self.dash.ensure_visible()
105- sleep(0.5)
106- self.activate_ibus()
107- sleep(0.5)
108- self.keyboard.type(self.input)
109- dash_search_string = self.dash.search_string
110- self.deactivate_ibus()
111- self.dash.ensure_hidden()
112-
113- self.assertEqual(self.result, dash_search_string)
114+ self.do_dash_test_with_engine("hangul")
115
116 def test_simple_input_hud(self):
117- self.activate_input_engine_or_skip("hangul")
118- self.hud.ensure_visible()
119- sleep(0.5)
120- self.activate_ibus()
121- sleep(0.5)
122- self.keyboard.type(self.input)
123- hud_search_string = self.hud.search_string
124- self.deactivate_ibus()
125- self.hud.ensure_hidden()
126-
127- self.assertEqual(self.result, hud_search_string)
128+ self.do_hud_test_with_engine("hangul")
129
130
131 class IBusTestsAnthy(IBusTests):
132@@ -135,32 +125,10 @@
133 )
134
135 def test_simple_input_dash(self):
136- self.activate_input_engine_or_skip("anthy")
137- self.dash.ensure_visible()
138- sleep(0.5)
139- self.activate_ibus()
140- sleep(0.5)
141- self.keyboard.type(self.input)
142- self.keyboard.press_and_release(self.commit_key)
143- dash_search_string = self.dash.search_string
144- self.deactivate_ibus()
145- self.dash.ensure_hidden()
146-
147- self.assertEqual(self.result, dash_search_string)
148+ self.do_dash_test_with_engine("anthy")
149
150 def test_simple_input_hud(self):
151- self.activate_input_engine_or_skip("anthy")
152- self.hud.ensure_visible()
153- sleep(0.5)
154- self.activate_ibus()
155- sleep(0.5)
156- self.keyboard.type(self.input)
157- self.keyboard.press_and_release(self.commit_key)
158- hud_search_string = self.hud.search_string
159- self.deactivate_ibus()
160- self.hud.ensure_hidden()
161-
162- self.assertEqual(self.result, hud_search_string)
163+ self.do_hud_test_with_engine("anthy")
164
165
166 class IBusTestsPinyinIgnore(IBusTests):
167@@ -169,21 +137,20 @@
168 def test_ignore_key_events_on_dash(self):
169 self.activate_input_engine_or_skip("pinyin")
170 self.dash.ensure_visible()
171+ self.addCleanup(self.dash.ensure_hidden)
172 sleep(0.5)
173 self.activate_ibus()
174+ self.addCleanup(self.deactivate_ibus)
175 sleep(0.5)
176 self.keyboard.type("cipan")
177 self.keyboard.press_and_release("Tab")
178 self.keyboard.type(" ")
179- dash_search_string = self.dash.get_searchbar().search_string
180- self.deactivate_ibus()
181- self.dash.ensure_hidden()
182-
183- self.assertNotEqual(" ", dash_search_string)
184+ self.assertThat(self.dash.search_string, Eventually(NotEquals(" ")))
185
186 def test_ignore_key_events_on_hud(self):
187 self.activate_input_engine_or_skip("pinyin")
188 self.hud.ensure_visible()
189+ self.addCleanup(self.hud.ensure_hidden)
190 sleep(0.5)
191 self.keyboard.type("a")
192 self.activate_ibus()
193@@ -192,9 +159,7 @@
194 old_selected = self.hud.selected_button
195 self.keyboard.press_and_release("Down")
196 new_selected = self.hud.selected_button
197- self.deactivate_ibus()
198- self.hud.ensure_hidden()
199-
200+
201 self.assertEqual(old_selected, new_selected)
202
203
204@@ -204,30 +169,30 @@
205 def test_ignore_key_events_on_dash(self):
206 self.activate_input_engine_or_skip("anthy")
207 self.dash.ensure_visible()
208+ self.addCleanup(self.dash.ensure_hidden)
209 sleep(0.5)
210 self.activate_ibus()
211+ self.addCleanup(self.deactivate_ibus)
212 sleep(0.5)
213 self.keyboard.type("shisutemu ")
214 self.keyboard.press_and_release("Tab")
215 self.keyboard.press_and_release("Ctrl+j")
216- dash_search_string = self.dash.get_searchbar().search_string
217- self.deactivate_ibus()
218- self.dash.ensure_hidden()
219+ dash_search_string = self.dash.search_string
220
221 self.assertNotEqual("", dash_search_string)
222
223 def test_ignore_key_events_on_hud(self):
224 self.activate_input_engine_or_skip("anthy")
225 self.hud.ensure_visible()
226+ self.addCleanup(self.hud.ensure_hidden)
227 sleep(0.5)
228 self.keyboard.type("a")
229 self.activate_ibus()
230+ self.addCleanup(self.deactivate_ibus)
231 sleep(0.5)
232 self.keyboard.type("hiduke")
233 old_selected = self.hud.selected_button
234 self.keyboard.press_and_release("Down")
235 new_selected = self.hud.selected_button
236- self.deactivate_ibus()
237- self.hud.ensure_hidden()
238
239 self.assertEqual(old_selected, new_selected)