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

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

Issue 2829023: Add test to check for unused config values in ibus (Closed) Base URL: ssh://gitrw.chromium.org/autotest.git
Patch Set: Pre-submit Created 10 years, 5 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 5 import logging, os, re, string, time
6 from autotest_lib.client.bin import site_ui_test, 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.
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 raise error.TestFail('Failed to get %s value from ' 68 raise error.TestFail('Failed to get %s value from '
69 'the ibus config service' % type_name) 69 'the ibus config service' % type_name)
70 out = self.run_ibusclient('unset_config') 70 out = self.run_ibusclient('unset_config')
71 if not 'OK' in out: 71 if not 'OK' in out:
72 raise error.TestFail('Failed to unset %s value from ' 72 raise error.TestFail('Failed to unset %s value from '
73 'the ibus config service' % type_name) 73 'the ibus config service' % type_name)
74 # TODO(yusukes): Add a get_config test here to make sure the value is 74 # TODO(yusukes): Add a get_config test here to make sure the value is
75 # actually removed. See also http://crosbug.com/2801/. 75 # actually removed. See also http://crosbug.com/2801/.
76 76
77 77
78 def test_check_unused_ibus_values(self):
79 engine_list = ['hangul', 'pinyin', 'mozc', 'chewing']
80 expected_unread = set([# TODO: Uncomment these when mozc loads config
81 # values from ibus.
82 'engine/Mozchistory_learning_level',
83 'engine/Mozcincognito_mode',
84 'engine/Mozcnumpad_character_form',
85 'engine/Mozcpreedit_method',
86 'engine/Mozcpunctuation_method',
87 'engine/Mozcsession_keymap',
88 'engine/Mozcshift_key_mode_switch',
89 'engine/Mozcspace_character_form',
90 'engine/Mozcsuggestions_size',
91 'engine/Mozcsymbol_method',
92 'engine/Mozcuse_auto_ime_turn_off',
93 'engine/Mozcuse_dictionary_suggest',
94 'engine/Mozcuse_history_suggest',
95 'engine/Mozcuse_number_conversion',
96 'engine/Mozcuse_single_kanji_conversion',
97 'engine/Mozcuse_symbol_conversion',
98 'engine/Mozcuse_date_conversion',
99
100 # These preferences are actually read, but
101 # ibus-daemon reads them before chrome connects,
102 # so they show up as a false failure.
103 'general/hotkeynext_engine_in_menu',
104 'general/hotkeyprevious_engine',
105 'generalglobal_engine',
106 'generalglobal_previous_engine'])
107
108 expected_unwritten = set(['engine/ChewingsyncCapsLockLocal',
109 'engine/ChewingnumpadAlwaysNumber',
110 'engine/ChewinginputStyle',
111 'engine/HangulHanjaKeys',
112 'engine/PinyinCorrectPinyin_GN_NG',
113 'engine/PinyinCorrectPinyin_IOU_IU',
114 'engine/PinyinCorrectPinyin_MG_NG',
115 'engine/PinyinCorrectPinyin_UEN_UN',
116 'engine/PinyinCorrectPinyin_UE_VE',
117 'engine/PinyinCorrectPinyin_VE_UE',
118 'engine/PinyinCorrectPinyin_V_U',
119 'engine/PinyinDoublePinyinShowRaw',
120 'engine/PinyinFuzzyPinyin_ANG_AN',
121 'engine/PinyinFuzzyPinyin_AN_ANG',
122 'engine/PinyinFuzzyPinyin_CH_C',
123 'engine/PinyinFuzzyPinyin_C_CH',
124 'engine/PinyinFuzzyPinyin_ENG_EN',
125 'engine/PinyinFuzzyPinyin_EN_ENG',
126 'engine/PinyinFuzzyPinyin_F_H',
127 'engine/PinyinFuzzyPinyin_G_K',
128 'engine/PinyinFuzzyPinyin_H_F',
129 'engine/PinyinFuzzyPinyin_IANG_IAN',
130 'engine/PinyinFuzzyPinyin_IAN_IANG',
131 'engine/PinyinFuzzyPinyin_ING_IN',
132 'engine/PinyinFuzzyPinyin_IN_ING',
133 'engine/PinyinFuzzyPinyin_K_G',
134 'engine/PinyinFuzzyPinyin_L_N',
135 'engine/PinyinFuzzyPinyin_L_R',
136 'engine/PinyinFuzzyPinyin_N_L',
137 'engine/PinyinFuzzyPinyin_R_L',
138 'engine/PinyinFuzzyPinyin_SH_S',
139 'engine/PinyinFuzzyPinyin_S_SH',
140 'engine/PinyinFuzzyPinyin_UANG_UAN',
141 'engine/PinyinFuzzyPinyin_UAN_UANG',
142 'engine/PinyinFuzzyPinyin_ZH_Z',
143 'engine/PinyinFuzzyPinyin_Z_ZH',
144 'engine/PinyinCorrectPinyin_UEI_UI',
145 'engine/PinyinIncompletePinyin',
146 'engine/PinyinLookupTableOrientation',
147 'engine/PinyinSpecialPhrases',
148
149 # These preferences are actually read, but
150 # ibus-daemon reads them before chrome
151 # connects, so they show up as a false
152 # failure.
153 'general/hotkeynext_engine_in_menu',
154 'general/hotkeyprevious_engine',
155 'generalglobal_engine',
156
157 # We don't set these prefernces.
158 'general/hotkeynext_engine',
159 'general/hotkeyprev_engine',
160 'general/hotkeytrigger',
161 'generalembed_preedit_text',
162 'generalenable_by_default',
163 'generalpreload_engines',
164 'generaluse_global_engine',
165 'generaluse_system_keyboard_layout'])
166
167 self.preload_engines(engine_list)
168
169 # Send a ctrl+l to enter a text field.
170 ax = self.get_autox()
171 ax.send_hotkey('Ctrl-l')
172
173 for engine_name in engine_list:
174 self.activate_engine(engine_name)
175
176 out = self.run_ibusclient('get_unused')
177 match = re.match(r"Unread:(.*)Unwritten:(.*)", out, re.DOTALL)
178 if not match:
179 raise error.TestFail('Could not read unused values from ibus')
180
181 actual_unread = set(re.split('\n', match.group(1).strip()))
182 actual_unwritten = set(re.split('\n', match.group(2).strip()))
183
184 new_unread = actual_unread.difference(expected_unread)
185 now_read = expected_unread.difference(actual_unread)
186 new_unwritten = actual_unwritten.difference(expected_unwritten)
187 now_written = expected_unwritten.difference(actual_unwritten)
188
189 if new_unread or now_read or new_unwritten or now_written:
190 message = ['iBus config has changed:']
191 if new_unread:
192 message.append('New unread values:')
193 for key in new_unread:
194 message.append(key)
195 if now_read:
196 message.append('No longer unread values:')
197 for key in now_read:
198 message.append(key)
199 if new_unwritten:
200 message.append('New unwritten values:')
201 for key in new_unwritten:
202 message.append(key)
203 if now_written:
204 message.append('No longer unwritten values:')
205 for key in now_written:
206 message.append(key)
207 raise error.TestFail(string.join(message, '\n'))
208
209
210 def preload_engines(self, engine_list):
211 engine_names = string.join(engine_list, " ")
212 out = self.run_ibusclient('preload_engines %s' % engine_names)
213 if not 'OK' in out:
214 raise error.TestFail('Failed to preload engines: %s' % engine_names)
215
216
217 def activate_engine(self, engine_name):
218 out = self.run_ibusclient('activate_engine %s' % engine_name)
219 if not 'OK' in out:
220 raise error.TestFail('Failed to activate engine: %s' % engine_name)
221
222
78 def run_once(self): 223 def run_once(self):
79 wait_for_ibus_daemon_or_die() 224 wait_for_ibus_daemon_or_die()
80 dep = 'ibusclient' 225 dep = 'ibusclient'
81 dep_dir = os.path.join(self.autodir, 'deps', dep) 226 dep_dir = os.path.join(self.autodir, 'deps', dep)
82 self.job.install_pkg(dep, 'dep', dep_dir) 227 self.job.install_pkg(dep, 'dep', dep_dir)
83 228
84 self.exefile = os.path.join(self.autodir, 229 self.exefile = os.path.join(self.autodir,
85 'deps/ibusclient/ibusclient') 230 'deps/ibusclient/ibusclient')
86 self.test_reachable() 231 self.test_reachable()
87 self.test_supported_engines() 232 self.test_supported_engines()
88 for type_name in ['boolean', 'int', 'double', 'string', 'boolean_list', 233 for type_name in ['boolean', 'int', 'double', 'string', 'boolean_list',
89 'int_list', 'double_list', 'string_list']: 234 'int_list', 'double_list', 'string_list']:
90 self.test_config(type_name) 235 self.test_config(type_name)
236
237 self.test_check_unused_ibus_values()
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