Merge lp:~cjwatson/ubiquity/indicator-keymaps-960047 into lp:ubiquity

Proposed by Colin Watson on 2012-03-20
Status: Merged
Merged at revision: 5281
Proposed branch: lp:~cjwatson/ubiquity/indicator-keymaps-960047
Merge into: lp:ubiquity
Diff against target: 69 lines (+31/-2)
3 files modified
debian/changelog (+7/-0)
tests/test_misc.py (+21/-0)
ubiquity/misc.py (+3/-2)
To merge this branch: bzr merge lp:~cjwatson/ubiquity/indicator-keymaps-960047
Reviewer Review Type Date Requested Status
Stéphane Graber 2012-03-20 Approve on 2012-03-20
Review via email: mp+98407@code.launchpad.net

Description of the Change

Fix misc.set_indicator_keymaps to handle ll_CC forms of lang, and also to avoid crashing on unknown languages in general (LP: #960047).

To post a comment you must log in.
5281. By Colin Watson on 2012-03-20

call engine.lock_group(0) in all cases, per stgraber

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'debian/changelog'
2--- debian/changelog 2012-03-19 22:03:15 +0000
3+++ debian/changelog 2012-03-20 13:43:22 +0000
4@@ -1,3 +1,10 @@
5+ubiquity (2.9.31) UNRELEASED; urgency=low
6+
7+ * Fix misc.set_indicator_keymaps to handle ll_CC forms of lang, and also
8+ to avoid crashing on unknown languages in general (LP: #960047).
9+
10+ -- Colin Watson <cjwatson@ubuntu.com> Tue, 20 Mar 2012 13:28:02 +0000
11+
12 ubiquity (2.9.30) precise; urgency=low
13
14 [ Adam Conrad ]
15
16=== modified file 'tests/test_misc.py'
17--- tests/test_misc.py 2012-03-19 20:24:05 +0000
18+++ tests/test_misc.py 2012-03-20 13:43:22 +0000
19@@ -183,6 +183,27 @@
20 self.assertEqual(mock_set_list.call_args[0][1], 'layouts')
21 self.assertIn('se\tdvorak', mock_set_list.call_args[0][2])
22
23+ @mock.patch('ubiquity.gsettings.set_list')
24+ @mock.patch('ubiquity.misc.execute')
25+ def test_set_indicator_keymaps_simplified_chinese(self, mock_execute,
26+ mock_set_list):
27+ misc.set_indicator_keymaps('zh_CN')
28+ self.assertEqual(mock_execute.call_count, 1)
29+ self.assertEqual(mock_execute.call_args[0][0], 'setxkbmap')
30+ self.assertEqual(mock_set_list.call_count, 1)
31+ self.assertEqual(mock_set_list.call_args[0][0],
32+ 'org.gnome.libgnomekbd.keyboard')
33+ self.assertEqual(mock_set_list.call_args[0][1], 'layouts')
34+ self.assertEqual('cn', mock_set_list.call_args[0][2][0])
35+ self.assertEqual(len(mock_set_list.call_args[0][2]), 1)
36+
37+ @mock.patch('ubiquity.gsettings.set_list')
38+ @mock.patch('ubiquity.misc.execute')
39+ def test_set_indicator_keymaps_unknown(self, mock_execute, mock_set_list):
40+ misc.set_indicator_keymaps('unknownlanguage')
41+ self.assertEqual(mock_execute.call_count, 0)
42+ self.assertEqual(mock_set_list.call_count, 0)
43+
44 #class PartedServerTests(unittest.TestCase):
45 # def setUp(self):
46 # patcher = mock.patch('ubiquity.parted_server.PartedServer')
47
48=== modified file 'ubiquity/misc.py'
49--- ubiquity/misc.py 2012-03-19 20:24:05 +0000
50+++ ubiquity/misc.py 2012-03-20 13:43:22 +0000
51@@ -581,6 +581,7 @@
52
53 xpath = "//iso_639_3_entry[@part1_code='%s']"
54 gsettings_key = ['org.gnome.libgnomekbd.keyboard','layouts']
55+ lang = lang.split('_')[0]
56 variants = []
57
58 # Map inspired from that of gfxboot-theme-ubuntu that's itself
59@@ -691,9 +692,9 @@
60 fp = libxml2.parseFile('/usr/share/xml/iso-codes/iso_639_3.xml')
61 context = fp.xpathNewContext()
62 nodes = context.xpathEvalExpression(xpath % lang)
63+ display = GdkX11.x11_get_default_xdisplay()
64+ engine = Xkl.Engine.get_instance(display)
65 if nodes:
66- display = GdkX11.x11_get_default_xdisplay()
67- engine = Xkl.Engine.get_instance(display)
68 configreg = Xkl.ConfigRegistry.get_instance(engine)
69 configreg.load(False)
70

Subscribers

People subscribed via source and target branches

to status/vote changes: