Merge lp:~brandontschaefer/unity/ap-xim-tests-gcin into lp:unity

Proposed by Brandon Schaefer
Status: Merged
Approved by: Brandon Schaefer
Approved revision: no longer in the source branch.
Merged at revision: 2642
Proposed branch: lp:~brandontschaefer/unity/ap-xim-tests-gcin
Merge into: lp:unity
Diff against target: 78 lines (+72/-0)
1 file modified
tests/autopilot/unity/tests/xim/test_gcin.py (+72/-0)
To merge this branch: bzr merge lp:~brandontschaefer/unity/ap-xim-tests-gcin
Reviewer Review Type Date Requested Status
Thomi Richards (community) quality Approve
Christopher Lee (community) Approve
Review via email: mp+121972@code.launchpad.net

Commit message

Tests gcin using XIM in unity.

Description of the change

Adds gcin tests to unity to test the XIM branch in nux. Unity uses XIM a little different in how it focuses the Dash and Hud.

To post a comment you must log in.
Revision history for this message
Christopher Lee (veebers) :
review: Approve
Revision history for this message
Thomi Richards (thomir-deactivatedaccount) :
review: Approve (quality)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added directory 'tests/autopilot/unity/tests/xim'
2=== added file 'tests/autopilot/unity/tests/xim/__init__.py'
3=== added file 'tests/autopilot/unity/tests/xim/test_gcin.py'
4--- tests/autopilot/unity/tests/xim/test_gcin.py 1970-01-01 00:00:00 +0000
5+++ tests/autopilot/unity/tests/xim/test_gcin.py 2012-08-30 16:25:23 +0000
6@@ -0,0 +1,72 @@
7+# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
8+# Copyright 2012 Canonical
9+# Author: Brandon Schaefer
10+#
11+# This program is free software: you can redistribute it and/or modify it
12+# under the terms of the GNU General Public License version 3, as published
13+# by the Free Software Foundation.
14+
15+from __future__ import absolute_import
16+
17+from autopilot.matchers import Eventually
18+from os import environ
19+import subprocess
20+from testtools.matchers import Equals
21+
22+from unity.tests import UnityTestCase
23+
24+
25+class GcinTestCase(UnityTestCase):
26+ """Tests the Input Method gcin."""
27+
28+ def setUp(self):
29+ super(GcinTestCase, self).setUp()
30+
31+ # Check that gcin is set as the active IM through im-switch
32+ if environ['XMODIFIERS'] != "@im=gcin":
33+ self.skip("Please make sure XMODIFIERS is set to @im=gcin. Set it using 'im-switch'.")
34+
35+ running_process = subprocess.check_output('ps -e', shell=True)
36+ if 'gcin' not in running_process:
37+ self.skip("gcin is not an active process, please start 'gcin' before running these tests.")
38+
39+ if 'ibus' in running_process:
40+ self.skip("IBus is currently running, please close 'ibus-daemon' before running these tests.")
41+
42+
43+class GcinTestHangul(GcinTestCase):
44+ """Tests the Dash and Hud with gcin in hangul mode."""
45+
46+ scenarios = [
47+ ('hangul', {'input': 'han geul ', 'result': u'\ud55c\uae00'}),
48+ ('morning letters', {'input': 'a chimgeul ', 'result': u'\uc544\uce68\uae00'}),
49+ ('national script', {'input': 'gug mun ', 'result': u'\uad6d\ubb38'}),
50+ ]
51+
52+ def setUp(self):
53+ super(GcinTestHangul, self).setUp()
54+
55+ def enter_hangul_mode(self):
56+ """Ctrl+Space turns gcin on, Ctrl+Alt+/ turns hangul on."""
57+ self.keyboard.press_and_release("Ctrl+Space")
58+ self.keyboard.press_and_release("Ctrl+Alt+/")
59+
60+ def test_dash_input(self):
61+ """Entering an input string through gcin will result in a Korean string result in the dash."""
62+
63+ self.dash.ensure_visible()
64+ self.addCleanup(self.dash.ensure_hidden)
65+ self.enter_hangul_mode()
66+
67+ self.keyboard.type(self.input)
68+ self.assertThat(self.dash.search_string, Eventually(Equals(self.result)))
69+
70+ def test_hud_input(self):
71+ """Entering an input string through gcin will result in a Korean string result in the hud."""
72+
73+ self.hud.ensure_visible()
74+ self.addCleanup(self.hud.ensure_hidden)
75+ self.enter_hangul_mode()
76+
77+ self.keyboard.type(self.input)
78+ self.assertThat(self.hud.search_string, Eventually(Equals(self.result)))