Merge lp:~thomir/unity/ibus-anthy-autopilot into lp:unity

Proposed by Thomi Richards on 2012-03-22
Status: Merged
Approved by: Thomi Richards on 2012-03-23
Approved revision: 2158
Merged at revision: 2163
Proposed branch: lp:~thomir/unity/ibus-anthy-autopilot
Merge into: lp:unity
Diff against target: 79 lines (+37/-6)
2 files modified
tests/autopilot/autopilot/tests/__init__.py (+25/-0)
tests/autopilot/autopilot/tests/test_ibus.py (+12/-6)
To merge this branch: bzr merge lp:~thomir/unity/ibus-anthy-autopilot
Reviewer Review Type Date Requested Status
Brandon Schaefer (community) 2012-03-22 Approve on 2012-03-22
Review via email: mp+98939@code.launchpad.net

Commit Message

Added extra tests for the ibus Anthy engine: we now test both Ctrl+J and Enter as a commit key.

Description of the Change

Took bschaefer's branch and changed it to use multiply_scenarios to generate scenarios for the Anthy ibus tests.

UNBLOCK

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

+1 Looks good!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'tests/autopilot/autopilot/tests/__init__.py'
2--- tests/autopilot/autopilot/tests/__init__.py 2012-03-21 12:31:11 +0000
3+++ tests/autopilot/autopilot/tests/__init__.py 2012-03-22 22:38:19 +0000
4@@ -37,6 +37,31 @@
5 logger = logging.getLogger(__name__)
6
7
8+try:
9+ from testscenarios.scenarios import multiple_scenarios
10+except ImportError:
11+ from itertools import product
12+ def multiply_scenarios(*scenarios):
13+ """Multiply two or more iterables of scenarios.
14+
15+ It is safe to pass scenario generators or iterators.
16+
17+ :returns: A list of compound scenarios: the cross-product of all
18+ scenarios, with the names concatenated and the parameters
19+ merged together.
20+ """
21+ result = []
22+ scenario_lists = map(list, scenarios)
23+ for combination in product(*scenario_lists):
24+ names, parameters = zip(*combination)
25+ scenario_name = ','.join(names)
26+ scenario_parameters = {}
27+ for parameter in parameters:
28+ scenario_parameters.update(parameter)
29+ result.append((scenario_name, scenario_parameters))
30+ return result
31+
32+
33 class LoggedTestCase(TestWithScenarios, TestCase):
34 """Initialize the logging for the test case."""
35
36
37=== modified file 'tests/autopilot/autopilot/tests/test_ibus.py'
38--- tests/autopilot/autopilot/tests/test_ibus.py 2012-02-26 20:40:15 +0000
39+++ tests/autopilot/autopilot/tests/test_ibus.py 2012-03-22 22:38:19 +0000
40@@ -14,7 +14,7 @@
41 )
42 from autopilot.emulators.unity.dash import Dash
43 from autopilot.emulators.X11 import Keyboard
44-from autopilot.tests import AutopilotTestCase
45+from autopilot.tests import AutopilotTestCase, multiply_scenarios
46
47 from time import sleep
48
49@@ -99,11 +99,17 @@
50 class IBusTestsAnthy(IBusTests):
51 """Tests for the Anthy(Japanese) input engine."""
52
53- scenarios = [
54- ('system', {'input': 'shisutemu ', 'result': u'\u30b7\u30b9\u30c6\u30e0'}),
55- ('game', {'input': 'ge-mu ', 'result': u'\u30b2\u30fc\u30e0'}),
56- ('user', {'input': 'yu-za- ', 'result': u'\u30e6\u30fc\u30b6\u30fc'}),
57+ scenarios = multiply_scenarios(
58+ [
59+ ('system', {'input': 'shisutemu ', 'result': u'\u30b7\u30b9\u30c6\u30e0'}),
60+ ('game', {'input': 'ge-mu ', 'result': u'\u30b2\u30fc\u30e0'}),
61+ ('user', {'input': 'yu-za- ', 'result': u'\u30e6\u30fc\u30b6\u30fc'}),
62+ ],
63+ [
64+ ('commit_j', {'commit_key': 'Ctrl+j'}),
65+ ('commit_enter', {'commit_key': 'Enter'}),
66 ]
67+ )
68
69 def test_simple_input(self):
70 self.activate_input_engine_or_skip("anthy")
71@@ -112,7 +118,7 @@
72 self.activate_ibus()
73 sleep(0.5)
74 self.kb.type(self.input)
75- self.kb.press_and_release("Ctrl+j")
76+ self.kb.press_and_release(self.commit_key)
77 dash_search_string = self.dash.get_searchbar().search_string
78 self.deactivate_ibus()
79 self.dash.ensure_hidden()