Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(110)

Side by Side Diff: client/site_tests/desktopui_IBusTest/desktopui_IBusTest.py

Issue 1371006: Add more tests to desktopui_IBusTest (Closed)
Patch Set: add time back Created 10 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « client/deps/ibusclient/src/ibusclient.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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, utils 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 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(test.test):
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']) 26 self.job.setup_dep(['autox'])
27 self.job.setup_dep(['ibusclient']) 27 self.job.setup_dep(['ibusclient'])
28 28
29 29
30 def run_ibusclient(self, options):
31 cmd = site_ui.xcommand_as('%s %s' % (self.exefile, options), 'chronos')
32 return utils.system_output(cmd, retain_output=True)
33
34
35 def test_reachable(self):
36 out = self.run_ibusclient('check_reachable')
37 if not 'YES' in out:
38 raise error.TestFail('ibus-daemon is not reachable')
39
40
41 def test_supported_engines(self):
42 out = self.run_ibusclient('list_engines')
43 engine_names = out.splitlines()
44 # We expect these engines to exist.
45 expected_engine_names = ['chewing', 'hangul', 'pinyin', 'm17n:ar:kbd']
46 for expected_engine_name in expected_engine_names:
47 if not expected_engine_name in engine_names:
48 raise error.TestFail('Engine not found: ' +
49 expected_engine_name)
50
51
30 def run_once(self): 52 def run_once(self):
31 logged_in = site_login.logged_in() 53 logged_in = site_login.logged_in()
32 if not logged_in: 54 if not logged_in:
33 if not site_login.attempt_login(self, 'autox_script.json'): 55 if not site_login.attempt_login(self, 'autox_script.json'):
34 raise error.TestFail('Could not login') 56 raise error.TestFail('Could not login')
35 try: 57 try:
36 wait_for_ibus_daemon_or_die() 58 wait_for_ibus_daemon_or_die()
37 dep = 'ibusclient' 59 dep = 'ibusclient'
38 dep_dir = os.path.join(self.autodir, 'deps', dep) 60 dep_dir = os.path.join(self.autodir, 'deps', dep)
39 self.job.install_pkg(dep, 'dep', dep_dir) 61 self.job.install_pkg(dep, 'dep', dep_dir)
40 62
41 exefile = os.path.join(self.autodir, 'deps/ibusclient/ibusclient') 63 self.exefile = os.path.join(self.autodir,
42 cmd = site_ui.xcommand_as(exefile, 'chronos') 64 'deps/ibusclient/ibusclient')
43 utils.system_output(cmd, retain_output=True) 65 self.test_reachable()
66 self.test_supported_engines()
44 finally: 67 finally:
45 # If we started logged out, log back out. 68 # If we started logged out, log back out.
46 if not logged_in: 69 if not logged_in:
47 site_login.attempt_logout() 70 site_login.attempt_logout()
OLDNEW
« no previous file with comments | « client/deps/ibusclient/src/ibusclient.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698