| 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_login, 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 |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 engine_names = out.splitlines() | 43 engine_names = out.splitlines() |
| 44 # We expect these engines to exist. | 44 # We expect these engines to exist. |
| 45 expected_engine_names = ['chewing', 'hangul', 'pinyin', 'm17n:ar:kbd'] | 45 expected_engine_names = ['chewing', 'hangul', 'pinyin', 'm17n:ar:kbd'] |
| 46 for expected_engine_name in expected_engine_names: | 46 for expected_engine_name in expected_engine_names: |
| 47 if not expected_engine_name in engine_names: | 47 if not expected_engine_name in engine_names: |
| 48 raise error.TestFail('Engine not found: ' + | 48 raise error.TestFail('Engine not found: ' + |
| 49 expected_engine_name) | 49 expected_engine_name) |
| 50 | 50 |
| 51 | 51 |
| 52 def test_config(self, type_name): | 52 def test_config(self, type_name): |
| 53 wrong_type_name = 'string' |
| 54 if type_name == 'string': |
| 55 wrong_type_name = 'int' |
| 56 # First, write a dummy value which is not |type_name| type to make sure |
| 57 # the second set_config overwrites this |wrong_type_name| value. |
| 58 out = self.run_ibusclient('set_config %s' % wrong_type_name) |
| 59 if not 'OK' in out: |
| 60 raise error.TestFail('Failed to set %s value to ' |
| 61 'the ibus config service' % wrong_type_name) |
| 62 # Then overwrite a value of |type_name| type. |
| 53 out = self.run_ibusclient('set_config %s' % type_name) | 63 out = self.run_ibusclient('set_config %s' % type_name) |
| 54 if not 'OK' in out: | 64 if not 'OK' in out: |
| 55 raise error.TestFail('Failed to set %s value to ' | 65 raise error.TestFail('Failed to set %s value to ' |
| 56 'the ibus config service' % type_name) | 66 'the ibus config service' % type_name) |
| 57 out = self.run_ibusclient('get_config %s' % type_name) | 67 out = self.run_ibusclient('get_config %s' % type_name) |
| 58 if not 'OK' in out: | 68 if not 'OK' in out: |
| 59 raise error.TestFail('Failed to get %s value from ' | 69 raise error.TestFail('Failed to get %s value from ' |
| 60 'the ibus config service' % type_name) | 70 'the ibus config service' % type_name) |
| 61 out = self.run_ibusclient('unset_config') | 71 out = self.run_ibusclient('unset_config') |
| 62 if not 'OK' in out: | 72 if not 'OK' in out: |
| (...skipping 14 matching lines...) Expand all Loading... |
| 77 try: | 87 try: |
| 78 wait_for_ibus_daemon_or_die() | 88 wait_for_ibus_daemon_or_die() |
| 79 dep = 'ibusclient' | 89 dep = 'ibusclient' |
| 80 dep_dir = os.path.join(self.autodir, 'deps', dep) | 90 dep_dir = os.path.join(self.autodir, 'deps', dep) |
| 81 self.job.install_pkg(dep, 'dep', dep_dir) | 91 self.job.install_pkg(dep, 'dep', dep_dir) |
| 82 | 92 |
| 83 self.exefile = os.path.join(self.autodir, | 93 self.exefile = os.path.join(self.autodir, |
| 84 'deps/ibusclient/ibusclient') | 94 'deps/ibusclient/ibusclient') |
| 85 self.test_reachable() | 95 self.test_reachable() |
| 86 self.test_supported_engines() | 96 self.test_supported_engines() |
| 87 for type_name in ['boolean', 'int', 'double', 'string']: | 97 for type_name in ['boolean', 'int', 'double', 'string', |
| 98 'boolean_list', 'int_list', 'double_list', |
| 99 'string_list']: |
| 88 self.test_config(type_name) | 100 self.test_config(type_name) |
| 89 finally: | 101 finally: |
| 90 # If we started logged out, log back out. | 102 # If we started logged out, log back out. |
| 91 if not logged_in: | 103 if not logged_in: |
| 92 site_login.attempt_logout() | 104 site_login.attempt_logout() |
| OLD | NEW |