OLD | NEW |
1 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved. | 1 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved. |
2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 import logging, os, time | 5 import logging, os, time |
6 from autotest_lib.client.bin import site_login, test | 6 from autotest_lib.client.bin import site_ui_test, test |
7 from autotest_lib.client.common_lib import error, site_ui, utils | 7 from autotest_lib.client.common_lib import error, site_ui, utils |
8 | 8 |
9 def wait_for_ibus_daemon_or_die(timeout=10): | 9 def wait_for_ibus_daemon_or_die(timeout=10): |
10 # Wait until ibus-daemon starts. ibus-daemon starts after a user | 10 # Wait until ibus-daemon starts. ibus-daemon starts after a user |
11 # logs in (see src/platform/init for details), hence it's not | 11 # logs in (see src/platform/init for details), hence it's not |
12 # guaranteed that ibus-daemon is running when the test starts. | 12 # guaranteed that ibus-daemon is running when the test starts. |
13 start_time = time.time() | 13 start_time = time.time() |
14 while time.time() - start_time < timeout: | 14 while time.time() - start_time < timeout: |
15 if os.system('pgrep ^ibus-daemon$') == 0: # Returns 0 on success. | 15 if os.system('pgrep ^ibus-daemon$') == 0: # Returns 0 on success. |
16 return | 16 return |
17 time.sleep(1) | 17 time.sleep(1) |
18 raise error.TestFail('ibus-daemon is not running') | 18 raise error.TestFail('ibus-daemon is not running') |
19 | 19 |
20 | 20 |
21 class desktopui_IBusTest(test.test): | 21 class desktopui_IBusTest(site_ui_test.UITest): |
22 version = 1 | 22 version = 1 |
23 preserve_srcdir = True | 23 preserve_srcdir = True |
24 | 24 |
25 def setup(self): | 25 def setup(self): |
26 self.job.setup_dep(['autox']) | |
27 self.job.setup_dep(['ibusclient']) | 26 self.job.setup_dep(['ibusclient']) |
28 | 27 |
29 | 28 |
30 def run_ibusclient(self, options): | 29 def run_ibusclient(self, options): |
31 cmd = site_ui.xcommand_as('%s %s' % (self.exefile, options), 'chronos') | 30 cmd = site_ui.xcommand_as('%s %s' % (self.exefile, options), 'chronos') |
32 return utils.system_output(cmd, retain_output=True) | 31 return utils.system_output(cmd, retain_output=True) |
33 | 32 |
34 | 33 |
35 def test_reachable(self): | 34 def test_reachable(self): |
36 out = self.run_ibusclient('check_reachable') | 35 out = self.run_ibusclient('check_reachable') |
(...skipping 26 matching lines...) Expand all Loading... |
63 raise error.TestFail('Failed to unset %s value from ' | 62 raise error.TestFail('Failed to unset %s value from ' |
64 'the ibus config service' % type_name) | 63 'the ibus config service' % type_name) |
65 out = self.run_ibusclient('get_config %s' % type_name) | 64 out = self.run_ibusclient('get_config %s' % type_name) |
66 # the value no longer exists. | 65 # the value no longer exists. |
67 if 'OK' in out: | 66 if 'OK' in out: |
68 raise error.TestFail('Failed to unset %s value from ' | 67 raise error.TestFail('Failed to unset %s value from ' |
69 'the ibus config service' % type_name) | 68 'the ibus config service' % type_name) |
70 | 69 |
71 | 70 |
72 def run_once(self): | 71 def run_once(self): |
73 logged_in = site_login.logged_in() | 72 wait_for_ibus_daemon_or_die() |
74 if not logged_in: | 73 dep = 'ibusclient' |
75 if not site_login.attempt_login(self, 'autox_script.json'): | 74 dep_dir = os.path.join(self.autodir, 'deps', dep) |
76 raise error.TestFail('Could not login') | 75 self.job.install_pkg(dep, 'dep', dep_dir) |
77 try: | |
78 wait_for_ibus_daemon_or_die() | |
79 dep = 'ibusclient' | |
80 dep_dir = os.path.join(self.autodir, 'deps', dep) | |
81 self.job.install_pkg(dep, 'dep', dep_dir) | |
82 | 76 |
83 self.exefile = os.path.join(self.autodir, | 77 self.exefile = os.path.join(self.autodir, |
84 'deps/ibusclient/ibusclient') | 78 'deps/ibusclient/ibusclient') |
85 self.test_reachable() | 79 self.test_reachable() |
86 self.test_supported_engines() | 80 self.test_supported_engines() |
87 for type_name in ['boolean', 'int', 'double', 'string']: | 81 for type_name in ['boolean', 'int', 'double', 'string']: |
88 self.test_config(type_name) | 82 self.test_config(type_name) |
89 finally: | |
90 # If we started logged out, log back out. | |
91 if not logged_in: | |
92 site_login.attempt_logout() | |
OLD | NEW |