Merge lp:~thomir/unity/improve-ibus-testing into lp:unity

Proposed by Thomi Richards on 2012-04-19
Status: Merged
Approved by: Thomi Richards on 2012-04-20
Approved revision: 2321
Merged at revision: 2320
Proposed branch: lp:~thomir/unity/improve-ibus-testing
Merge into: lp:unity
Prerequisite: lp:~thomir/unity/fix-launcher-tests
Diff against target: 134 lines (+24/-30)
2 files modified
plugins/unityshell/src/SearchBar.cpp (+3/-2)
tests/autopilot/autopilot/tests/test_ibus.py (+21/-28)
To merge this branch: bzr merge lp:~thomir/unity/improve-ibus-testing
Reviewer Review Type Date Requested Status
Brandon Schaefer (community) 2012-04-19 Approve on 2012-04-19
Review via email: mp+102767@code.launchpad.net

Commit Message

IBus autopilot tests now wait for input method context to be created before typing characters.

Description of the Change

This branch changes the ibus tests so they wait until the ibus input method context is created in the target widget. This eliminates the need for sleep() statements in the ibus tests, and should help some ibus tests that fail intermittently to pass.

This branch requires lp:~brandontschaefer/nux/ibus-active-reset to be merged into lp:nux before these tests will pass. At the time of writing, the branch has been approved, so this shouldnt be a problem.

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

There seems to still be a little timing issues, but I think that can be fixed by only destroying the context when we are switching engines. Instead of doing it each test. Other then that this improves it a lot so +1.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'plugins/unityshell/src/SearchBar.cpp'
2--- plugins/unityshell/src/SearchBar.cpp 2012-04-16 18:52:39 +0000
3+++ plugins/unityshell/src/SearchBar.cpp 2012-04-19 23:36:20 +0000
4@@ -520,7 +520,7 @@
5 {
6 int RADIUS = 5;
7 nux::Geometry geo(GetGeometry());
8- geo.width = layered_layout_->GetAbsoluteX() +
9+ geo.width = layered_layout_->GetAbsoluteX() +
10 layered_layout_->GetAbsoluteWidth() -
11 GetAbsoluteX() +
12 SEARCH_ENTRY_RIGHT_BORDER;
13@@ -665,7 +665,8 @@
14 .add("filter-label-x", show_filters_->GetAbsoluteX())
15 .add("filter-label-y", show_filters_->GetAbsoluteY())
16 .add("filter-label-width", show_filters_->GetAbsoluteWidth())
17- .add("filter-label-height", show_filters_->GetAbsoluteHeight());
18+ .add("filter-label-height", show_filters_->GetAbsoluteHeight())
19+ .add("im_active", pango_entry_->im_active());
20 }
21
22 } // namespace unity
23
24=== modified file 'tests/autopilot/autopilot/tests/test_ibus.py'
25--- tests/autopilot/autopilot/tests/test_ibus.py 2012-04-17 22:27:03 +0000
26+++ tests/autopilot/autopilot/tests/test_ibus.py 2012-04-19 23:36:20 +0000
27@@ -9,7 +9,6 @@
28 """Tests to ensure unity is compatible with ibus input method."""
29
30 from testtools.matchers import Equals, NotEquals
31-from time import sleep
32
33 from autopilot.emulators.ibus import (
34 set_active_engines,
35@@ -38,22 +37,24 @@
36 else:
37 self.skipTest("This test requires the '%s' engine to be installed." % (engine_name))
38
39- def activate_ibus(self):
40- # it would be nice to be able to tell if it's currently active or not.
41+ def activate_ibus(self, widget):
42+ """Activate IBus, and wait till it's actived on 'widget'"""
43+ self.assertThat(widget.im_active, Equals(False))
44 self.keyboard.press_and_release('Ctrl+Space')
45+ self.assertThat(widget.im_active, Eventually(Equals(True)))
46
47- def deactivate_ibus(self):
48- # it would be nice to be able to tell if it's currently active or not.
49+ def deactivate_ibus(self, widget):
50+ """Deactivate ibus, and wait till it's inactive on 'widget'"""
51+ self.assertThat(widget.im_active, Equals(True))
52 self.keyboard.press_and_release('Ctrl+Space')
53+ self.assertThat(widget.im_active, Eventually(Equals(False)))
54
55 def do_dash_test_with_engine(self, engine_name):
56 self.activate_input_engine_or_skip(engine_name)
57 self.dash.ensure_visible()
58 self.addCleanup(self.dash.ensure_hidden)
59- sleep(0.5)
60- self.activate_ibus()
61- self.addCleanup(self.deactivate_ibus)
62- sleep(0.5)
63+ self.activate_ibus(self.dash.searchbar)
64+ self.addCleanup(self.deactivate_ibus, self.dash.searchbar)
65 self.keyboard.type(self.input)
66 commit_key = getattr(self, 'commit_key', None)
67 if commit_key:
68@@ -64,10 +65,8 @@
69 self.activate_input_engine_or_skip(engine_name)
70 self.hud.ensure_visible()
71 self.addCleanup(self.hud.ensure_hidden)
72- sleep(0.5)
73- self.activate_ibus()
74- self.addCleanup(self.deactivate_ibus)
75- sleep(0.5)
76+ self.activate_ibus(self.hud.searchbar)
77+ self.addCleanup(self.deactivate_ibus, self.hud.searchbar)
78 self.keyboard.type(self.input)
79 commit_key = getattr(self, 'commit_key', None)
80 if commit_key:
81@@ -138,10 +137,8 @@
82 self.activate_input_engine_or_skip("pinyin")
83 self.dash.ensure_visible()
84 self.addCleanup(self.dash.ensure_hidden)
85- sleep(0.5)
86- self.activate_ibus()
87- self.addCleanup(self.deactivate_ibus)
88- sleep(0.5)
89+ self.activate_ibus(self.dash.searchbar)
90+ self.addCleanup(self.deactivate_ibus, self.dash.searchbar)
91 self.keyboard.type("cipan")
92 self.keyboard.press_and_release("Tab")
93 self.keyboard.type(" ")
94@@ -151,10 +148,10 @@
95 self.activate_input_engine_or_skip("pinyin")
96 self.hud.ensure_visible()
97 self.addCleanup(self.hud.ensure_hidden)
98- sleep(0.5)
99+
100 self.keyboard.type("a")
101- self.activate_ibus()
102- sleep(0.5)
103+ self.activate_ibus(self.hud.searchbar)
104+ self.addCleanup(self.deactivate_ibus, self.hud.searchbar)
105 self.keyboard.type("riqi")
106 old_selected = self.hud.selected_button
107 self.keyboard.press_and_release("Down")
108@@ -170,10 +167,8 @@
109 self.activate_input_engine_or_skip("anthy")
110 self.dash.ensure_visible()
111 self.addCleanup(self.dash.ensure_hidden)
112- sleep(0.5)
113- self.activate_ibus()
114- self.addCleanup(self.deactivate_ibus)
115- sleep(0.5)
116+ self.activate_ibus(self.dash.searchbar)
117+ self.addCleanup(self.deactivate_ibus, self.dash.searchbar)
118 self.keyboard.type("shisutemu ")
119 self.keyboard.press_and_release("Tab")
120 self.keyboard.press_and_release("Ctrl+j")
121@@ -185,11 +180,9 @@
122 self.activate_input_engine_or_skip("anthy")
123 self.hud.ensure_visible()
124 self.addCleanup(self.hud.ensure_hidden)
125- sleep(0.5)
126 self.keyboard.type("a")
127- self.activate_ibus()
128- self.addCleanup(self.deactivate_ibus)
129- sleep(0.5)
130+ self.activate_ibus(self.hud.searchbar)
131+ self.addCleanup(self.deactivate_ibus, self.hud.searchbar)
132 self.keyboard.type("hiduke")
133 old_selected = self.hud.selected_button
134 self.keyboard.press_and_release("Down")