Merge lp:~brandontschaefer/unity/move-ibus-emulator-from-autopilot into lp:unity

Proposed by Brandon Schaefer
Status: Merged
Approved by: Brandon Schaefer
Approved revision: 3453
Merged at revision: 3460
Proposed branch: lp:~brandontschaefer/unity/move-ibus-emulator-from-autopilot
Merge into: lp:unity
Diff against target: 135 lines (+114/-3)
2 files modified
tests/autopilot/unity/emulators/ibus.py (+113/-0)
tests/autopilot/unity/tests/test_ibus.py (+1/-3)
To merge this branch: bzr merge lp:~brandontschaefer/unity/move-ibus-emulator-from-autopilot
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Approve
Christopher Townsend Approve
Review via email: mp+178614@code.launchpad.net

Commit message

Add ibus.py to the tests/autopilot/unity/emulators from lp:autopilot.

Description of the change

Add ibus.py to the tests/autopilot/unity/emulators from lp:autopilot. As this is where it'll live now :)

To post a comment you must log in.
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Marco Trevisan (Treviño) (3v1n0) wrote :

Mh, ok...

After this would you reconsider to add back what reverted in http://http://bazaar.launchpad.net/~unity-team/unity/trunk/revision/3449?

Marco Trevisan (Treviño) (3v1n0) wrote :

Mh, I've also noticed that the release tests I added in 2591 have been removed... Could we try to re-add them? As I remember that some people complained that the release key support was broken, so we should ensure it keeps working...

Brandon Schaefer (brandontschaefer) wrote :

@ Marco

What I removed in 3449 has to be re implemented, not just added back in... ibus 1.5 no longer users gconf and it was causing tests to fail. So we need to figure out how to correctly set hot keys now using gsettings + python, which I need to spend time digging into....

Christopher Townsend (townsend) wrote :

@ Marco,

Brandon has added https://bugs.launchpad.net/ubuntu/+source/unity/+bug/1210658 about the tests removed in rev. 3449. We are not 100% sure which tests you say have been removed that you added in rev. 2591. Could you open a new bug open those?

Otherwise, this looks good and is needed to get the ibus tests into Unity.

review: Approve
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== added file 'tests/autopilot/unity/emulators/ibus.py'
--- tests/autopilot/unity/emulators/ibus.py 1970-01-01 00:00:00 +0000
+++ tests/autopilot/unity/emulators/ibus.py 2013-08-05 17:55:40 +0000
@@ -0,0 +1,113 @@
1# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
2#
3# Autopilot Functional Test Tool
4# Copyright (C) 2012-2013 Canonical
5#
6# This program is free software: you can redistribute it and/or modify
7# it under the terms of the GNU General Public License as published by
8# the Free Software Foundation, either version 3 of the License, or
9# (at your option) any later version.
10#
11# This program is distributed in the hope that it will be useful,
12# but WITHOUT ANY WARRANTY; without even the implied warranty of
13# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14# GNU General Public License for more details.
15#
16# You should have received a copy of the GNU General Public License
17# along with this program. If not, see <http://www.gnu.org/licenses/>.
18#
19
20
21"""Functions to deal with ibus service."""
22
23from __future__ import absolute_import
24
25from gi.repository import IBus, GLib
26import os
27import logging
28import subprocess
29
30
31logger = logging.getLogger(__name__)
32
33
34def get_ibus_bus():
35 """Get the ibus bus object, possibly starting the ibus daemon if it's
36 not already running.
37
38 :raises: **RuntimeError** in the case of ibus-daemon being unavailable.
39
40 """
41 bus = IBus.Bus()
42 if bus.is_connected():
43 return bus
44
45 main_loop = GLib.MainLoop()
46
47 timeout = 5
48 GLib.timeout_add_seconds(timeout, lambda *args: main_loop.quit())
49 bus.connect("connected", lambda *args: main_loop.quit())
50
51 os.spawnlp(os.P_NOWAIT, "ibus-daemon", "ibus-daemon", "--xim")
52
53 main_loop.run()
54
55 if not bus.is_connected():
56 raise RuntimeError(
57 "Could not start ibus-daemon after %d seconds." % (timeout))
58 return bus
59
60
61def get_available_input_engines():
62 """Get a list of available input engines."""
63 bus = get_ibus_bus()
64 return [e.get_name() for e in bus.list_engines()]
65
66
67def get_active_input_engines():
68 """Get the list of input engines that have been activated."""
69 bus = get_ibus_bus()
70 return [e.get_name() for e in bus.list_active_engines()]
71
72
73def set_active_engines(engine_list):
74 """Installs the engines in *engine_list* into the list of active iBus
75 engines.
76
77 The specified engines must appear in the return list from
78 get_available_input_engines().
79
80 .. note:: This function removes all other engines.
81
82 This function returns the list of engines installed before this function
83 was called. The caller should pass this list to set_active_engines to
84 restore ibus to it's old state once the test has finished.
85
86 :param engine_list: List of engine names
87 :type engine_list: List of strings
88 :raises: **TypeError** on invalid *engine_list* parameter.
89 :raises: **ValueError** when engine_list contains invalid engine name.
90
91 """
92 if type(engine_list) is not list:
93 raise TypeError("engine_list must be a list of valid engine names.")
94 available_engines = get_available_input_engines()
95 for engine in engine_list:
96 if not isinstance(engine, basestring):
97 raise TypeError("Engines in engine_list must all be strings.")
98 if engine not in available_engines:
99 raise ValueError(
100 "engine_list contains invalid engine name: '%s'", engine)
101
102 bus = get_ibus_bus()
103 config = bus.get_config()
104
105 config.set_value("general",
106 "preload_engine_mode",
107 GLib.Variant.new_int32(IBus.PreloadEngineMode.USER))
108
109 old_engines = get_active_input_engines()
110 config.set_value(
111 "general", "preload_engines", GLib.Variant("as", engine_list))
112
113 return old_engines
0114
=== modified file 'tests/autopilot/unity/tests/test_ibus.py'
--- tests/autopilot/unity/tests/test_ibus.py 2013-08-01 15:58:22 +0000
+++ tests/autopilot/unity/tests/test_ibus.py 2013-08-05 17:55:40 +0000
@@ -10,12 +10,10 @@
1010
11from __future__ import absolute_import11from __future__ import absolute_import
1212
13from autopilot.ibus import (13from unity.emulators.ibus import (
14 get_active_input_engines,14 get_active_input_engines,
15 set_active_engines,15 set_active_engines,
16 get_available_input_engines,16 get_available_input_engines,
17 get_gconf_option,
18 set_gconf_option,
19 get_ibus_bus,17 get_ibus_bus,
20 )18 )
21from autopilot.matchers import Eventually19from autopilot.matchers import Eventually